Skip to content

Commit

Permalink
force PDB generation switch to force compatibility with dot Peek pdb …
Browse files Browse the repository at this point in the history
…generation option.
  • Loading branch information
earnol committed Oct 21, 2015
1 parent f279bed commit 24c6e69
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
12 changes: 11 additions & 1 deletion de4dot.code/AssemblyModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public void Save(string newFilename, MetaDataFlags mdFlags, IModuleWriterListene
var writerOptions = new ModuleWriterOptions(module, writerListener);
writerOptions.MetaDataOptions.Flags |= mdFlags;
writerOptions.Logger = Logger.Instance;
if(Logger.Instance.ForcePDBGeneration)
{
writerOptions.WritePdb = true;
module.CreatePdbState();
}
module.Write(newFilename, writerOptions);
}
else {
Expand All @@ -64,7 +69,12 @@ public void Save(string newFilename, MetaDataFlags mdFlags, IModuleWriterListene
writerOptions.Logger = Logger.Instance;
writerOptions.KeepExtraPEData = true;
writerOptions.KeepWin32Resources = true;
module.NativeWrite(newFilename, writerOptions);
if (Logger.Instance.ForcePDBGeneration)
{
writerOptions.WritePdb = true;
module.CreatePdbState();
}
module.NativeWrite(newFilename, writerOptions);
}
}

Expand Down
7 changes: 7 additions & 0 deletions de4dot.code/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class Logger : ILogger {
Dictionary<string, bool> ignoredMessages = new Dictionary<string, bool>(StringComparer.Ordinal);
int numIgnoredMessages;
bool canIgnoreMessages;
bool forcePDBGeneration = false;

public int IndentLevel {
get { return indentLevel; }
Expand All @@ -57,6 +58,12 @@ public int NumIgnoredMessages {
get { return numIgnoredMessages; }
}

public bool ForcePDBGeneration
{
get { return forcePDBGeneration; }
set { forcePDBGeneration = value; }
}

public Logger()
: this(2, true) {
}
Expand Down
7 changes: 6 additions & 1 deletion de4dot.cui/CommandLineParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,12 @@ void AddAllOptions() {
Logger.Instance.MaxLoggerEvent = LoggerEvent.VeryVerbose;
Logger.Instance.CanIgnoreMessages = false;
}));
miscOptions.Add(new NoArgOption("h", "help", "Show this help message", () => {
miscOptions.Add(new NoArgOption("fpdb", null, "Force PDB file generation for output", () =>
{
Logger.Instance.ForcePDBGeneration = true;
}));
miscOptions.Add(new NoArgOption("h", "help", "Show this help message", () =>
{
Usage();
Exit(0);
}));
Expand Down

0 comments on commit 24c6e69

Please sign in to comment.