Пример #1
0
        public void PrintManagedCallStacks()
        {
            //Threads test, get info of all managed threads found in dump
            context.WriteInfo("--- Managed callstacks ---");
            if (context.Runtime != null)
            {
                foreach (ClrThread thread in context.Runtime.Threads)
                {
                    if (!thread.IsAlive)
                    {
                        continue;
                    }

                    context.WriteInfo("Thread        {0}, managed id: {1}:", thread.OSThreadId, thread.ManagedThreadId);
                    context.WriteInfo("GC mode:      {0} ", thread.GcMode);
                    context.WriteInfo("Thread type:  {0}", thread);
                    context.WriteInfo("Callstack: {0:X} - {1:X}", thread.StackBase, thread.StackLimit);

                    // get last thrown exception of thread
                    ClrException lastException = thread.CurrentException;
                    if (lastException != null)
                    {
                        this.PrintException(lastException);
                    }
                    // walk each stack frame
                    foreach (ClrStackFrame frame in thread.StackTrace)
                    {
                        SDFileAndLineNumber info = frame.GetSourceLocation();
                        context.WriteLine("{0,12:X} {1,12:X} {2} - {3}:{4}", frame.StackPointer, frame.InstructionPointer, frame.DisplayString, info.File, info.Line);
                    }
                    context.WriteLine(null);
                }
                context.WriteInfo("Total amount of all (managed) threads: " + context.Runtime.Threads.Count);
            }
        }