文章插图
稍等片刻,你会得到如下三个文件 。
- ConsoleApp101.run录制文件
- ConsoleApp101.idx录制的索引文件
- ConsoleApp101.out日志文件
- 找到 tid=20 的 OSID 线程ID
tid=20
的 OSID 已经不存在了,所以用 !tt
在时间刻度上折半查找 OSID
存在的 position 。0:007> !tt 94Setting position to 94% into the traceSetting position: 396DB:0(5ac8.20): Break instruction exception - code 80000003 (first/second chance not available)Time Travel Position: 396DB:0eax=00be602c ebx=00c7c2b0 ecx=00be6028 edx=0024e000 esi=00be6028 edi=00000000eip=77d8e925 esp=07acf1c8 ebp=07acf1c8 iopl=0nv up ei pl nz na po nccs=0023ss=002bds=002bes=002bfs=0053gs=002befl=00000202ntdll!RtlEnterCriticalSection+0x15:77d8e925 f00fba3000lock btr dword ptr [eax],0ds:002b:00be602c=ffffffff0:007> !tThreadCount:20UnstartedThread:0BackgroundThread: 19PendingThread:0DeadThread:0Hosted Runtime:noLock DBGIDOSID ThreadOBJState GC ModeGC Alloc ContextDomainCount Apt Exception...2420145c 0887AFB8302b220 Preemptive03C4C1A4:03C4DFE8 00c462f8 -00001 MTA (Threadpool Worker)
可以清楚的看到原来是 OSID =145c
及WindbgID=24
有了这个信息不代表此时它正在执行托管方法,所以我们还需要找到这个 145c
是何时出生的?- 找到当前视频中所有的
ThreadCreated
事件 。
id=0x145c
的线程出生信息 。0:024> dx -r2 @$curprocess.TTD.Events.Where(t => t.Type == "ThreadCreated").Select(t => t.Thread).Where(t=>t.Id==0x145c).Select(t=>t)@$curprocess.TTD.Events.Where(t => t.Type == "ThreadCreated").Select(t => t.Thread).Where(t=>t.Id==0x145c).Select(t=>t)[0x0]: UID: 27, TID: 0x145CUniqueId: 0x1bId: 0x145cLifetime: [38B21:0, 3BB45:0]ActiveTime: [38B6A:0, 3BB45:0]GatherMemoryUse[Gather inputs, outputs and memory used by a range of execution within a thread]
从输出中可以看到, Lifetime 表示这个线程的一生, ActiveTime 则是从线程的Start处开始的,画个图如下:
文章插图
接下来将进度条调到
!tt 38B21:0
处,那如何看代码进入到托管方法中呢?这个就得各显神通 , 我知道的有这么几种 。- 使用单步调试
!tt
调整大致范围,然后用 p,pc,pt,t,tc,tt 微调,比如我们这篇的 !tt 94
就能获取到 tid=20
号线程的托管部分 。0:024> !tt 94Setting position to 94% into the traceSetting position: 396DB:0(5ac8.20): Break instruction exception - code 80000003 (first/second chance not available)Time Travel Position: 396DB:0eax=00be602c ebx=00c7c2b0 ecx=00be6028 edx=0024e000 esi=00be6028 edi=00000000eip=77d8e925 esp=07acf1c8 ebp=07acf1c8 iopl=0nv up ei pl nz na po nccs=0023ss=002bds=002bes=002bfs=0053gs=002befl=00000202ntdll!RtlEnterCriticalSection+0x15:77d8e925 f00fba3000lock btr dword ptr [eax],0ds:002b:00be602c=ffffffff0:007> ~24seax=00000000 ebx=0b1bfab8 ecx=00000000 edx=00000000 esi=00000001 edi=0b1bfab8eip=77dc196c esp=0b1bfa78 ebp=0b1bfadc iopl=0nv up ei pl nz na pe nccs=0023ss=002bds=002bes=002bfs=0053gs=002befl=00000206ntdll!NtDelayExecution+0xc:77dc196c c20800ret80:024> !clrstackOS Thread Id: 0x145c (24)Child SPIP Call Site0B1BFB50 77dc196c [HelperMethodFrame: 0b1bfb50] System.Threading.Thread.SleepInternal(Int32)0B1BFBBC 07b906940B1BFBD0 03b99078 ConsoleApp1.Program.Test()0B1BFC04 03b98a03 ConsoleApp1.Program+c.b__0_0()0B1BFC10 07b9065d System.Threading.Tasks.Task.InnerInvoke() [/_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs @ 2387]0B1BFC1C 07b900cd System.Threading.Tasks.Task+c.<.cctor>b__272_0(System.Object) [/_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs @ 2375]0B1BFC24 07b90047 System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(System.Threading.Thread, System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) [/_/src/libraries/System.Private.CoreLib/src/System/Threading/ExecutionContext.cs @ 268]0B1BFC54 07b907d2 System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread) [/_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs @ 2337]0B1BFCB8 03b9ff34 System.Threading.Tasks.Task.ExecuteEntryUnsafe(System.Threading.Thread) [/_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs @ 2277]0B1BFCC8 070f7a36 System.Threading.ThreadPoolWorkQueue.Dispatch()0B1BFD24 070ff222 System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart() [/_/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.WorkerThread.cs @ 63]0B1BFDB0 070e6545 System.Threading.Thread.StartCallback() [/_/src/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs @ 105]0B1BFF04 0307b9cf [DebuggerU2MCatchHandlerFrame: 0b1bff04]
推荐阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 第五周 python实验报告
- 自定义View6 -塔防小游戏:第三篇防御塔随意放置+多组野怪
- 2021年Q4手机用户偏好榜-2021年安兔兔第四季度用户偏好榜
- 龙王五子饕餮怎么念(龙王第五个儿子饕餮之死)
- 保卫萝卜4阿波道长第24关怎么过
- 保卫萝卜4阿波道长第23关怎么过
- 一篇文章带你掌握主流基础框架——Spring
- 斗罗大陆:武魂觉醒荒野行纪第八章怎么过
- 斗罗大陆:武魂觉醒荒野行纪第七章怎么过
- ipad分屏怎么打开(ipad第九代分屏功能)