2003-07-02 16:13:13 +04:00
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Xml;
|
|
|
|
using System.IO;
|
|
|
|
using System.Reflection;
|
2004-12-06 23:03:37 +03:00
|
|
|
using Mono.CompilerServices.SymbolWriter;
|
2003-07-02 16:13:13 +04:00
|
|
|
|
2006-04-03 22:37:11 +04:00
|
|
|
public class SymbolDumper
|
|
|
|
{
|
2003-07-02 16:13:13 +04:00
|
|
|
|
2006-04-03 22:37:11 +04:00
|
|
|
public static void Main (String[] args)
|
|
|
|
{
|
2003-07-02 16:13:13 +04:00
|
|
|
if (args.Length != 2) {
|
2006-04-03 22:37:11 +04:00
|
|
|
Console.WriteLine ("USAGE: symbols <ASSEMBLY> <METHOD NAME PATTERN>");
|
2003-07-02 16:13:13 +04:00
|
|
|
Environment.Exit (1);
|
|
|
|
}
|
2006-04-03 22:37:11 +04:00
|
|
|
|
2003-07-02 16:13:13 +04:00
|
|
|
string assemblyName = args [0];
|
|
|
|
string methodNamePattern = args [1];
|
|
|
|
|
2005-03-29 13:10:19 +04:00
|
|
|
Assembly assembly = Assembly.LoadFrom (assemblyName);
|
2003-07-02 16:13:13 +04:00
|
|
|
|
|
|
|
Console.WriteLine ("Reading symbols for " + assembly + " ...");
|
|
|
|
MonoSymbolFile symbolFile = MonoSymbolFile.ReadSymbolFile (assembly);
|
2006-04-03 22:37:11 +04:00
|
|
|
|
2003-07-02 16:13:13 +04:00
|
|
|
if (symbolFile == null)
|
|
|
|
Console.WriteLine ("WARNING: No symbols found for " + assembly);
|
2006-04-03 22:37:11 +04:00
|
|
|
else
|
2003-07-02 16:13:13 +04:00
|
|
|
Console.WriteLine ("Loaded symbol info for " + symbolFile.SourceCount + " source files and " + symbolFile.MethodCount + " methods.");
|
|
|
|
|
2006-04-03 22:37:11 +04:00
|
|
|
Module[] modules = assembly.GetModules();
|
2003-07-02 16:13:13 +04:00
|
|
|
|
2006-04-03 22:37:11 +04:00
|
|
|
if (modules.Length > 1)
|
|
|
|
Console.WriteLine("WARNING: Assembly had more than one module. Using the first.");
|
2003-07-02 16:13:13 +04:00
|
|
|
|
2006-04-03 22:37:11 +04:00
|
|
|
Module module = modules[0];
|
2005-03-29 13:10:19 +04:00
|
|
|
|
2006-04-03 22:37:11 +04:00
|
|
|
foreach (MethodEntry entry in symbolFile.Methods) {
|
|
|
|
|
|
|
|
MethodBase methodBase = module.ResolveMethod(entry.Token);
|
|
|
|
|
|
|
|
if (methodBase.Name.IndexOf (methodNamePattern) != -1) {
|
|
|
|
Console.WriteLine (methodBase.DeclaringType.FullName + ":" + methodBase.Name + " " + entry);
|
2003-07-02 16:13:13 +04:00
|
|
|
|
2008-07-16 16:23:47 +04:00
|
|
|
foreach (LineNumberEntry line in entry.GetLineNumberTable ().LineNumbers)
|
2003-07-02 16:13:13 +04:00
|
|
|
Console.WriteLine ("\t" + line);
|
2006-04-03 22:37:11 +04:00
|
|
|
}
|
|
|
|
}
|
2003-07-02 16:13:13 +04:00
|
|
|
}
|
|
|
|
}
|