Ejemplo n.º 1
0
 public UnifiedThread GetThreadWithBlockingObjects(ThreadInformation threadInfo)
 {
     var blockingObjects = GetUnmanagedBlockingObjects(threadInfo.OSThreadId);
     if (threadInfo.IsManagedThread)
     {
         blockingObjects.AddRange(GetManagedBlockingObjects(threadInfo.OSThreadId));
     }
     return new UnifiedThread(threadInfo, blockingObjects);
 }
Ejemplo n.º 2
0
        public UnifiedThread GetThreadWithBlockingObjects(ThreadInformation threadInfo)
        {
            var blockingObjects = GetUnmanagedBlockingObjects(threadInfo.OSThreadId);

            if (threadInfo.IsManagedThread)
            {
                blockingObjects.AddRange(GetManagedBlockingObjects(threadInfo.OSThreadId));
            }
            return(new UnifiedThread(threadInfo, blockingObjects));
        }
Ejemplo n.º 3
0
 public UnifiedThread(ThreadInformation info, IEnumerable <UnifiedBlockingObject> blockingObjects)
 {
     IsManagedThread = info.IsManagedThread;
     if (info.IsManagedThread)
     {
         ManagedThreadId = info.ManagedThread.ManagedThreadId;
     }
     Index          = info.Index;
     EngineThreadId = info.EngineThreadId;
     OSThreadId     = info.OSThreadId;
     Detail         = info.Detail;
     BlockingObjects.AddRange(blockingObjects);
 }
Ejemplo n.º 4
0
        private void FillFaultingThreadAndModuleInformation(CommandExecutionContext context)
        {
            UnifiedStackTraces stackTrace = new UnifiedStackTraces(_dbgEngTarget.DebuggerInterface, context);

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

            LastEventInformation lastEventInformation = _dbgEngTarget.GetLastEventInformation();

            if (lastEventInformation == null)
            {
                return;
            }

            ThreadInformation 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);
            }
        }
Ejemplo n.º 5
0
        public List <UnifiedStackFrame> GetStackTraceFromContext(uint?threadIndex, CONTEXT?context)
        {
            ThreadInformation        threadInfo        = GetThreadInfo(threadIndex);
            List <UnifiedStackFrame> unifiedStackTrace = new List <UnifiedStackFrame>();
            List <UnifiedStackFrame> nativeStackTrace  = GetNativeStackTrace(
                threadIndex.HasValue ? (uint?)threadInfo.EngineThreadId : null, context);

            if (threadInfo.IsManagedThread)
            {
                List <UnifiedStackFrame> managedStackTrace = GetManagedStackTrace(threadInfo.ManagedThread);
                int managedFrame = 0;
                for (int nativeFrame = 0; nativeFrame < nativeStackTrace.Count; ++nativeFrame)
                {
                    bool found = false;
                    for (int temp = managedFrame; temp < managedStackTrace.Count; ++temp)
                    {
                        if (nativeStackTrace[nativeFrame].InstructionPointer == managedStackTrace[temp].InstructionPointer)
                        {
                            managedStackTrace[temp].LinkedStackFrame = nativeStackTrace[nativeFrame];
                            unifiedStackTrace.Add(managedStackTrace[temp]);
                            managedFrame = temp + 1;
                            found        = true;
                            break;
                        }
                        else if (managedFrame > 0)
                        {
                            // We have already seen at least one managed frame, and we're about
                            // to skip a managed frame because we didn't find a matching native
                            // frame. In this case, add the managed frame into the stack anyway.
                            unifiedStackTrace.Add(managedStackTrace[temp]);
                            managedFrame = temp + 1;
                            found        = true;
                            break;
                        }
                    }
                    // We didn't find a matching managed frame, so add the native frame directly.
                    if (!found)
                    {
                        unifiedStackTrace.Add(nativeStackTrace[nativeFrame]);
                    }
                }
            }
            else
            {
                return(nativeStackTrace);
            }
            return(unifiedStackTrace);
        }
Ejemplo n.º 6
0
 public UnifiedThread(ThreadInformation info, IEnumerable<UnifiedBlockingObject> blockingObjects)
 {
     IsManagedThread = info.IsManagedThread;
     if (info.IsManagedThread)
     {
         ManagedThreadId = info.ManagedThread.ManagedThreadId;
     }
     Index = info.Index;
     EngineThreadId = info.EngineThreadId;
     OSThreadId = info.OSThreadId;
     Detail = info.Detail;
     BlockingObjects.AddRange(blockingObjects);
 }