private void PrintLocationAndILMapInfo(ClrMethod method, ILOffsetSourceLocation location, IList <ILToNativeMap> ilMaps)
 {
     try
     {
         var ilMapsInfo = ilMaps.Select(ilMap =>
                                        string.Format("IL_{0:X4} [{1:X8}-{2:X8} ({3:X8}-{4:X8})] ",
                                                      ilMap.ILOffset,
                                                      ilMap.StartAddress,
                                                      ilMap.EndAddress,
                                                      ilMap.StartAddress - @method.NativeCode,
                                                      ilMap.EndAddress - @method.NativeCode));
         logger?.WriteLine(BenchmarkLogKind.Statistic, string.Join("\n  ", ilMapsInfo));
     }
     catch (Exception ex)
     {
         logger?.WriteLine(BenchmarkLogKind.Error, ex.ToString());
     }
 }
 private void PrintSourceCode(IList <string> lines, ILOffsetSourceLocation location)
 {
     try
     {
         const int indent      = 7;
         var       lineToPrint = location.SourceLocation.LineNumber - 1;
         if (lineToPrint >= 0 && lineToPrint < lines.Count)
         {
             logger?.WriteLine(BenchmarkLogKind.Help, "{0,6}:{1}", location.SourceLocation.LineNumber, lines[location.SourceLocation.LineNumber - 1]);
             logger?.WriteLine(BenchmarkLogKind.Info,
                               new string(' ', location.SourceLocation.ColStart - 1 + indent) +
                               new string('*', location.SourceLocation.ColEnd - location.SourceLocation.ColStart));
         }
         else
         {
             logger?.WriteLine("Unable to show line {0} (0x{0:X8}), there are only {1} lines", lineToPrint, lines.Count);
         }
     }
     catch (Exception ex)
     {
         logger?.WriteLine(BenchmarkLogKind.Error, ex.ToString());
     }
 }
Esempio n. 3
0
        private static void PrintILToNativeOffsetAlternative(ClrMethod method, IList <string> lines)
        {
            DesktopModule module = (DesktopModule)@method.Type.Module;

            if (!module.IsPdbLoaded)
            {
                // Have to load the Pdb, if it's not already loaded!!
                string val = module.TryDownloadPdb(null);
                if (val != null)
                {
                    module.LoadPdb(val);
                }
            }

            foreach (var location in module.GetSourceLocationsForMethod(@method.MetadataToken))
            {
                ILOffsetSourceLocation ILLocation = location;
                var ilMaps = @method.ILOffsetMap.Where(il => il.ILOffset == ILLocation.ILOffset);
                Console.WriteLine("{0:X8} -> {1}:{2}",
                                  location.ILOffset,
                                  Path.GetFileName(location.SourceLocation.FilePath),
                                  location.SourceLocation.LineNumber);
                Console.WriteLine("  " + String.Join("\n  ",
                                                     ilMaps.Select(
                                                         ilMap =>
                                                         String.Format("[{0:X8}-{1:X8} ({2:X8}-{3:X8})] ILOffset: {4:X2}",
                                                                       ilMap.StartAddress - @method.NativeCode,
                                                                       ilMap.EndAddress - @method.NativeCode,
                                                                       ilMap.StartAddress, ilMap.EndAddress, ilMap.ILOffset))));
                var indent = 7;
                Console.WriteLine("{0,6}:{1}", location.SourceLocation.LineNumber, lines[location.SourceLocation.LineNumber - 1]);
                Console.WriteLine(new string(' ', location.SourceLocation.ColStart - 1 + indent) +
                                  new string('*', location.SourceLocation.ColEnd - location.SourceLocation.ColStart));
            }
            Console.WriteLine();
        }
Esempio n. 4
0
 private void PrintSourceCode(IList<string> lines, ILOffsetSourceLocation location)
 {
     try
     {
         const int indent = 7;
         var lineToPrint = location.SourceLocation.LineNumber - 1;
         if (lineToPrint >= 0 && lineToPrint < lines.Count)
         {
             logger?.WriteLine(LogKind.Help, "{0,6}:{1}", location.SourceLocation.LineNumber, lines[location.SourceLocation.LineNumber - 1]);
             logger?.WriteLine(LogKind.Info,
                               new string(' ', location.SourceLocation.ColStart - 1 + indent) +
                               new string('*', location.SourceLocation.ColEnd - location.SourceLocation.ColStart));
         }
         else
         {
             logger?.WriteLine("Unable to show line {0} (0x{0:X8}), there are only {1} lines", lineToPrint, lines.Count);
         }
     }
     catch (Exception ex)
     {
         logger?.WriteLine(LogKind.Error, ex.ToString());
     }
 }
Esempio n. 5
0
 private void PrintLocationAndILMapInfo(ClrMethod method, ILOffsetSourceLocation location, IList<ILToNativeMap> ilMaps)
 {
     try
     {
         var ilMapsInfo = ilMaps.Select(ilMap =>
                                 string.Format("IL_{0:X4} [{1:X8}-{2:X8} ({3:X8}-{4:X8})] ",
                                     ilMap.ILOffset,
                                     ilMap.StartAddress,
                                     ilMap.EndAddress,
                                     ilMap.StartAddress - @method.NativeCode,
                                     ilMap.EndAddress - @method.NativeCode));
         logger?.WriteLine(LogKind.Statistic, string.Join("\n  ", ilMapsInfo));
     }
     catch (Exception ex)
     {
         logger?.WriteLine(LogKind.Error, ex.ToString());
     }
 }