public override void Invoke()
 {
     if (Thread.HasValue)
     {
         IThread thread;
         if (ThreadId)
         {
             thread = ThreadService.GetThreadFromId(Thread.Value);
         }
         else
         {
             thread = ThreadService.GetThreadFromIndex(unchecked ((int)Thread.Value));
         }
         ContextService.SetCurrentThread(thread.ThreadId);
     }
     else
     {
         uint currentThreadId = CurrentThread != null ? CurrentThread.ThreadId : uint.MaxValue;
         foreach (IThread thread in ThreadService.EnumerateThreads())
         {
             WriteLine("{0}{1} 0x{2:X4} ({2})", thread.ThreadId == currentThreadId ? "*" : " ", thread.ThreadIndex, thread.ThreadId);
             if (Verbose)
             {
                 thread.TryGetRegisterValue(ThreadService.InstructionPointerIndex, out ulong ip);
                 thread.TryGetRegisterValue(ThreadService.StackPointerIndex, out ulong sp);
                 thread.TryGetRegisterValue(ThreadService.FramePointerIndex, out ulong fp);
                 WriteLine("    IP  0x{0:X16}", ip);
                 WriteLine("    SP  0x{0:X16}", sp);
                 WriteLine("    FP  0x{0:X16}", fp);
                 WriteLine("    TEB 0x{0:X16}", thread.GetThreadTeb());
             }
         }
     }
 }
예제 #2
0
        public override IThread GetCurrentThread()
        {
            HResult hr = _debuggerServices.GetCurrentThreadId(out uint threadId);

            if (hr != HResult.S_OK)
            {
                Trace.TraceError("GetCurrentThreadId() FAILED {0:X8}", hr);
                return(null);
            }
            return(ThreadService?.GetThreadFromId(threadId));
        }