public static void Main(string[] args) { var url = System.Environment.GetEnvironmentVariable("MONO_SENTRY_URL"); if (url == null) { Console.WriteLine("MONO_SENTRY_URL missing"); return; } var fileRoot = System.Environment.GetEnvironmentVariable("MONO_SENTRY_ROOT"); if (fileRoot == null) { Console.WriteLine("MONO_SENTRY_ROOT missing"); return; } var os_tag = System.Environment.GetEnvironmentVariable("MONO_SENTRY_OS"); if (os_tag == null) { Console.WriteLine("MONO_SENTRY_OS missing"); return; } var dsn = new Dsn(url); var files = GetFiles(fileRoot); if (files.Length == 0) { return; } // Find all of the assemblies in tree that could have made the crash dump var assemblies = GetAssemblies(fileRoot); var codebase = new CodeCollection(assemblies); foreach (var file in files) { Console.WriteLine($"Processing {file} ..."); var state = new Uploader(codebase); state.Upload(file, os_tag, dsn); } }
public Uploader(string inputFolder) { string[] assemblies = Directory.GetFiles(inputFolder, "*", SearchOption.AllDirectories); Console.WriteLine("Traversing {0} assemblies", assemblies.Length); this.codebase = new CodeCollection(); // AppDomain safe_domain = AppDomain.CreateDomain("SafeDomain"); foreach (string assembly in assemblies) { if (assembly.EndsWith(".dll") || assembly.EndsWith(".exe")) { // Console.WriteLine("Reading {0}", assembly); var readerParameters = new ReaderParameters { ReadSymbols = true }; AssemblyDefinition myLibrary = null; try { myLibrary = AssemblyDefinition.ReadAssembly(assembly, readerParameters); } catch (Exception e) { Console.WriteLine("Error parsing assembly {1}: {0}", e.Message, assembly); continue; } string mvid = myLibrary.MainModule.Mvid.ToString().ToUpper(); Console.WriteLine("{0} {1}", assembly, mvid); Console.WriteLine("Read {0}", assembly); foreach (var ty in myLibrary.MainModule.Types) { for (int i = 0; i < ty.Methods.Count; i++) { string klass = ty.FullName; string function = ty.Methods[i].FullName; uint token = Convert.ToUInt32(ty.Methods[i].MetadataToken.ToInt32()); codebase.Add(assembly, klass, function, mvid, token, ty.Methods[i].DebugInformation.SequencePoints); } } } } }
public Uploader(CodeCollection assemblies) { this.codebase = assemblies; }