public SymbolicationRequest(JObject input) { var payload = input["payload"]; var version = payload["protocol_version"]; var crash_threads = (JArray)payload["threads"]; Console.WriteLine("There were {0} threads", crash_threads.Count); Threads = new MonoStateThread [crash_threads.Count]; for (int i = 0; i < this.Threads.Length; i++) { var thread = ((JObject)crash_threads [i]); var managed_frames = SymbolicationRequest.ParseFrames((JArray)thread ["managed_frames"]); var unmanaged_frames = SymbolicationRequest.ParseFrames((JArray)thread["unmanaged_frames"]); var name = ""; Threads[i] = new MonoStateThread(managed_frames, unmanaged_frames, name); } }
public static void Main(string[] args) { if (args.Length < 1) { throw new Exception("Symbolcation file not provided"); } if (!File.Exists(args[0])) { throw new Exception(String.Format("Symbolcation file not found {0}", args[0])); } var crashFile = Symbolicator.TryReadJson(args[0]); var request = new SymbolicationRequest(crashFile); if (args.Length < 2) { throw new Exception("Symbolcation folder not provided"); } var inputFolder = args[1]; if (args.Length < 3) { throw new Exception("Unmanaged mono not given"); } var unmanaged_mono = args [2]; // Only load assemblies for which we have debug info string[] assemblies = Directory.GetFiles(inputFolder); Console.WriteLine("Traversing {0} assemblies", assemblies.Length); var mapping = new CodeCollection(unmanaged_mono); // 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()); mapping.Add(assembly, klass, function, mvid, token, ty.Methods [i].DebugInformation.SequencePoints); } } } } request.Process(mapping); var result = request.Emit(); mapping.Shutdown(); Console.WriteLine(result); //var MonoState = new MonoStateParser (argv [1]); //foreach (var thread in MonoState.Threads) //foreach (var frame in thread.Frames) //FormatFrame (frame); // AppDomain.Unload(safe_domain); }