Exemplo n.º 1
0
 public void ProcessOne(CodeCollection code, MonoStateFrame frame)
 {
     if (frame is MonoStateManagedFrame)
     {
         code.Enrich(frame as MonoStateManagedFrame);
     }
     else if (frame is MonoStateUnmanagedFrame)
     {
         code.Enrich(frame as MonoStateUnmanagedFrame);
     }
 }
Exemplo n.º 2
0
        public void Process(CodeCollection code)
        {
            foreach (var thread in Threads)
            {
                if (thread == null)
                {
                    continue;
                }

                foreach (var frame in thread.ManagedFrames)
                {
                    ProcessOne(code, frame);
                }
                foreach (var frame in thread.NativeFrames)
                {
                    ProcessOne(code, frame);
                }
            }
        }
Exemplo n.º 3
0
        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);
        }