X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Ftools%2Fpdb2mdb%2FDriver.cs;h=93d9e8a4544535b8f1c568064365d818bebbf195;hb=4c368c394e0d1aba39235e32a49c1feb32a42876;hp=bdec17678153d8d8088615d8acd30a75274d2aff;hpb=58fdac7b8a191881c721c1e04592fc4a8b4b6ab1;p=mono.git diff --git a/mcs/tools/pdb2mdb/Driver.cs b/mcs/tools/pdb2mdb/Driver.cs index bdec1767815..93d9e8a4544 100644 --- a/mcs/tools/pdb2mdb/Driver.cs +++ b/mcs/tools/pdb2mdb/Driver.cs @@ -21,17 +21,30 @@ using Mono.CompilerServices.SymbolWriter; namespace Pdb2Mdb { - class Converter { + public class Converter { MonoSymbolWriter mdb; Dictionary files = new Dictionary (); - public Converter (MonoSymbolWriter mdb) + public static void Convert (string filename) + { + var asm = AssemblyDefinition.ReadAssembly (filename); + + var pdb = asm.Name.Name + ".pdb"; + pdb = Path.Combine (Path.GetDirectoryName (filename), pdb); + + using (var stream = File.OpenRead (pdb)) { + var funcs = PdbFile.LoadFunctions (stream, true); + Converter.Convert (asm, funcs, new MonoSymbolWriter (filename)); + } + } + + internal Converter (MonoSymbolWriter mdb) { this.mdb = mdb; } - public static void Convert (AssemblyDefinition assembly, IEnumerable functions, MonoSymbolWriter mdb) + internal static void Convert (AssemblyDefinition assembly, IEnumerable functions, MonoSymbolWriter mdb) { var converter = new Converter (mdb); @@ -43,6 +56,9 @@ namespace Pdb2Mdb { void ConvertFunction (PdbFunction function) { + if (function.lines == null) + return; + var method = new SourceMethod { Name = function.name, Token = (int) function.token }; var file = GetSourceFile (mdb, function); @@ -58,15 +74,19 @@ namespace Pdb2Mdb { void ConvertSequencePoints (PdbFunction function, SourceFile file, SourceMethodBuilder builder) { - if (function.lines == null) - return; - - foreach (var line in function.lines.SelectMany (lines => lines.lines)) + int last_line = 0; + foreach (var line in function.lines.SelectMany (lines => lines.lines)) { + // 0xfeefee is an MS convention, we can't pass it into mdb files, so we use the last non-hidden line + bool is_hidden = line.lineBegin == 0xfeefee; builder.MarkSequencePoint ( (int) line.offset, file.CompilationUnit.SourceFile, - (int) line.lineBegin, - (int) line.colBegin, line.lineBegin == 0xfeefee); + is_hidden ? last_line : (int) line.lineBegin, + (int) line.colBegin, is_hidden ? -1 : (int)line.lineEnd, is_hidden ? -1 : (int)line.colEnd, + is_hidden); + if (!is_hidden) + last_line = (int) line.lineBegin; + } } void ConvertVariables (PdbFunction function) @@ -77,16 +97,20 @@ namespace Pdb2Mdb { void ConvertScope (PdbScope scope) { - ConvertSlots (scope.slots); + ConvertSlots (scope, scope.slots); foreach (var s in scope.scopes) ConvertScope (s); } - void ConvertSlots (IEnumerable slots) + void ConvertSlots (PdbScope scope, IEnumerable slots) { - foreach (var slot in slots) + int scope_idx = mdb.OpenScope ((int)scope.address); + foreach (var slot in slots) { mdb.DefineLocalVariable ((int) slot.slot, slot.name); + mdb.DefineScopeVariable (scope_idx, (int)slot.slot); + } + mdb.CloseScope ((int)(scope.address + scope.length)); } SourceFile GetSourceFile (MonoSymbolWriter mdb, PdbFunction function) @@ -149,6 +173,7 @@ namespace Pdb2Mdb { var assembly = AssemblyDefinition.ReadAssembly (asm); var pdb = assembly.Name.Name + ".pdb"; + pdb = Path.Combine (Path.GetDirectoryName (asm), pdb); if (!File.Exists (pdb)) Usage ();