Пример #1
0
        private void FillFaultingThreadAndModuleInformation(CommandExecutionContext context)
        {
            UnifiedStackTrace stackTrace = new UnifiedStackTrace(_dbgEngTarget.DebuggerInterface, context);

            _triageInformation.TotalThreadCount   = (int)stackTrace.NumThreads;
            _triageInformation.ManagedThreadCount = stackTrace.Threads.Count(t => t.IsManagedThread);

            LastEventInformation lastEventInformation = _dbgEngTarget.GetLastEventInformation();

            if (lastEventInformation == null)
            {
                return;
            }

            ThreadInfo faultingThread = stackTrace.Threads.SingleOrDefault(t => t.OSThreadId == lastEventInformation.OSThreadId);

            if (faultingThread == null)
            {
                return;
            }

            _triageInformation.FaultingThreadOSID      = faultingThread.OSThreadId;
            _triageInformation.IsFaultingThreadManaged = faultingThread.IsManagedThread;
            _triageInformation.EventDescription        = lastEventInformation.EventDescription;

            if (lastEventInformation.ExceptionRecord.HasValue)
            {
                _triageInformation.ExceptionCode = lastEventInformation.ExceptionRecord.Value.ExceptionCode;
            }
            if (faultingThread.IsManagedThread && faultingThread.ManagedThread.CurrentException != null)
            {
                _triageInformation.ManagedExceptionType = faultingThread.ManagedThread.CurrentException.Type.Name;
            }

            var frames = stackTrace.GetStackTrace(faultingThread.Index);

            UnifiedStackFrame faultingFrame = frames.FirstOrDefault(f => f.Module != null && !WellKnownMicrosoftModules.Contains(f.Module));

            if (faultingFrame != null)
            {
                _triageInformation.FaultingModule = faultingFrame.Module;
                _triageInformation.FaultingMethod = faultingFrame.Method;
            }

            if (ShowFaultingStack)
            {
                context.WriteLine("Faulting call stack:");
                stackTrace.PrintStackTrace(context, frames);
            }
        }
Пример #2
0
        public void Execute(CommandExecutionContext context)
        {
            if (OSThreadId == 0)
            {
                OSThreadId = context.CurrentThread.OSThreadId;
            }

            context.WriteLine("{0,-10} {1,-20} {2}", "Type", "IP", "Function");
            using (var target = context.CreateTemporaryDbgEngTarget())
            {
                var stackTracer = new UnifiedStackTrace(target.DebuggerInterface, context);
                stackTracer.PrintStackTrace(context, (from thr in stackTracer.Threads
                                                      where thr.OSThreadId == OSThreadId
                                                      select thr.Index).Single());
            }
        }
Пример #3
0
        public void Execute(CommandExecutionContext context)
        {
            if (OSThreadId == 0)
            {
                OSThreadId = context.CurrentThread.OSThreadId;
            }

            context.WriteLine("{0,-10} {1,-20} {2}", "Type", "IP", "Function");
            using (var target = context.CreateTemporaryDbgEngTarget())
            {
                var stackTracer = new UnifiedStackTrace(target.DebuggerInterface, context);
                stackTracer.PrintStackTrace(context, (from thr in stackTracer.Threads
                                                      where thr.OSThreadId == OSThreadId
                                                      select thr.Index).Single());
            }
        }
Пример #4
0
        public void Execute(CommandExecutionContext context)
        {
            _context = context;

            if (IncludeNativeThreads)
            {
                using (var target = context.CreateTemporaryDbgEngTarget())
                {
                    var tracer = new UnifiedStackTrace(target.DebuggerInterface, context);
                    context.WriteLine("Stack tree for {0} threads:", tracer.NumThreads);
                    var allStacks = from thread in tracer.Threads
                                    let frames = from frame in tracer.GetStackTrace(thread.Index)
                                                 where frame.Type != UnifiedStackFrameType.Special
                                                 select String.Format("{0}!{1}", frame.Module, frame.Method)
                                                 select new ThreadAndStack
                    {
                        ManagedThreadId = thread.IsManagedThread ? thread.ManagedThread.ManagedThreadId : 0,
                        OSThreadId      = thread.OSThreadId,
                        Stack           = frames.Reverse()
                    };
                    ProcessStacks(allStacks);
                }
            }
            else
            {
                context.WriteLine("Stack tree for {0} threads:", context.Runtime.Threads.Count);
                var allStacks = from thread in context.Runtime.Threads
                                let frames = from frame in thread.StackTrace
                                             where frame.Kind == ClrStackFrameType.ManagedMethod
                                             select frame.DisplayString
                                             select new ThreadAndStack
                {
                    ManagedThreadId = thread.ManagedThreadId,
                    Stack           = frames.Reverse()
                };
                ProcessStacks(allStacks);
            }
        }
Пример #5
0
        public void Execute(CommandExecutionContext context)
        {
            _context = context;

            if (IncludeNativeThreads)
            {
                using (var target = context.CreateTemporaryDbgEngTarget())
                {
                    var tracer = new UnifiedStackTrace(target.DebuggerInterface, context);
                    context.WriteLine("Stack tree for {0} threads:", tracer.NumThreads);
                    var allStacks = from thread in tracer.Threads
                                let frames = from frame in tracer.GetStackTrace(thread.Index)
                                             where frame.Type != UnifiedStackFrameType.Special
                                             select String.Format("{0}!{1}", frame.Module, frame.Method)
                                select new ThreadAndStack
                                {
                                    ManagedThreadId = thread.IsManagedThread ? thread.ManagedThread.ManagedThreadId : 0,
                                    OSThreadId = thread.OSThreadId,
                                    Stack = frames.Reverse()
                                };
                    ProcessStacks(allStacks);
                }
            }
            else
            {
                context.WriteLine("Stack tree for {0} threads:", context.Runtime.Threads.Count);
                var allStacks = from thread in context.Runtime.Threads
                                let frames = from frame in thread.StackTrace
                                             where frame.Kind == ClrStackFrameType.ManagedMethod
                                             select frame.DisplayString
                                select new ThreadAndStack
                                {
                                    ManagedThreadId = thread.ManagedThreadId,
                                    Stack = frames.Reverse()
                                };
                ProcessStacks(allStacks);
            }
        }
Пример #6
0
        private void FillFaultingThreadAndModuleInformation(CommandExecutionContext context)
        {
            UnifiedStackTrace stackTrace = new UnifiedStackTrace(_dbgEngTarget.DebuggerInterface, context);
            _triageInformation.TotalThreadCount = (int)stackTrace.NumThreads;
            _triageInformation.ManagedThreadCount = stackTrace.Threads.Count(t => t.IsManagedThread);

            LastEventInformation lastEventInformation = _dbgEngTarget.GetLastEventInformation();
            if (lastEventInformation == null)
                return;

            ThreadInfo faultingThread = stackTrace.Threads.SingleOrDefault(t => t.OSThreadId == lastEventInformation.OSThreadId);
            if (faultingThread == null)
                return;

            _triageInformation.FaultingThreadOSID = faultingThread.OSThreadId;
            _triageInformation.IsFaultingThreadManaged = faultingThread.IsManagedThread;
            _triageInformation.EventDescription = lastEventInformation.EventDescription;

            if (lastEventInformation.ExceptionRecord.HasValue)
            {
                _triageInformation.ExceptionCode = lastEventInformation.ExceptionRecord.Value.ExceptionCode;
            }
            if (faultingThread.IsManagedThread && faultingThread.ManagedThread.CurrentException != null)
            {
                _triageInformation.ManagedExceptionType = faultingThread.ManagedThread.CurrentException.Type.Name;
            }

            var frames = stackTrace.GetStackTrace(faultingThread.Index);

            UnifiedStackFrame faultingFrame = frames.FirstOrDefault(f => f.Module != null && !WellKnownMicrosoftModules.Contains(f.Module));
            if (faultingFrame != null)
            {
                _triageInformation.FaultingModule = faultingFrame.Module;
                _triageInformation.FaultingMethod = faultingFrame.Method;
            }

            if (ShowFaultingStack)
            {
                context.WriteLine("Faulting call stack:");
                stackTrace.PrintStackTrace(context, frames);
            }
        }