!thread扩展显示目标系统中线程包括ETHREAD块在内的摘要信息。该命令只能在内核模式调试下使用

!thread [-p] [-t] [Address [Flags]]

-p
显示拥有该线程的进程的摘要信息。
-t
包含这个选项时,Address是线程ID,而不是线程地址。
Address
指定目标机上线程的16进制地址。如果Address为-1或省略,则表示当前线程。
Flags
指定显示的详细级别。Flags可以是下面这些位的任意组合。如果Flags为0,只会显示最少量的信息。默认为0x6:

Bit 1 (0x2)
显示线程的等待状态。
Bit 2 (0x4)
如果不和Bit 1(0x2)一起使用则不会起作用。如果和Bit 1一起使用,线程会和调用堆栈一起显示出来。
Bit 3 (0x8)
(Windows XP和之后)

在每个函数的显示信息中加入返回地址、堆栈指针、以及bsp寄存器的值(在Itanium系统中),但是不显示函数的参数。

Bit 4 (0x10)
(Windows XP和之后) 在这个命令持续期间,将进程上下文设置为拥有指定线程的那个进程。这回使得线程调用堆栈的显示更加精确。

显示当前线程的详细信息:

kd> !thread -1 6
THREAD 821ec390 Cid 06e8.06e4 Teb: 7ffdd000 Win32Thread: 00000000 RUNNING on processor 0
IRP List:
82265a38: (0006,0094) Flags: 00000a00 Mdl: 81e91b68
Not impersonating
DeviceMap e19c40c8
Owning Process 0 Image: <Unknown>
Attached Process 821f5da0 Image: test.exe
Wait Start TickCount 21156 Ticks: 1 (0:00:00:00.015)
Context Switch Count 22
UserTime 00:00:00.000
KernelTime 00:00:00.031
Win32 Start Address test (0x00401356)
Start Address kernel32!BaseProcessStartThunk (0x7c8106f5)
Stack Init b2325000 Current b2324b84 Base b2325000 Limit b2322000 Call 0
Priority 8 BasePriority 8 PriorityDecrement 0 DecrementCount 0
ChildEBP RetAddr Args to Child
b2324c80 80580982 82265aa8 00000000 82265a38 nt!IopfCallDriver+0x31 (FPO: [0,0,0])
b2324c94 8057e4c9 81e6a518 82265a38 822272d8 nt!IopSynchronousServiceTail+0x70 (FPO: [7,0,4])
b2324d38 8054261c 00000038 00000000 00000000 nt!NtWriteFile+0x5d7 (FPO: [Non-Fpo])
b2324d38 7c92e4f4 00000038 00000000 00000000 nt!KiFastCallEntry+0xfc (FPO: [0,0] TrapFrame @ b2324d64)
0012fee0 7c92df6c 7c810e86 00000038 00000000 ntdll!KiFastSystemCallRet (FPO: [0,0,0])
0012fee4 7c810e86 00000038 00000000 00000000 ntdll!ZwWriteFile+0xc (FPO: [9,0,0])
0012ff44 00401070 00000038 0012ff60 0000000a kernel32!WriteFile+0xf7 (FPO: [Non-Fpo])
WARNING: Stack unwind information not available. Following frames may be wrong.
0012ff7c 0040120e 00000001 003d3ef8 003d2eb8 test+0x1070
0012ffc0 7c817067 00310031 00330031 7ffde000 test+0x120e
0012fff0 00000000 00401356 00000000 78746341 kernel32!BaseProcessStart+0x23 (FPO: [Non-Fpo])

.thread 命令指定哪个线程用作寄存器上下文。

和.process有点相似

当前线程:

kd> .thread
Implicit thread is now

.thread /r /p xxx同样是切换到指定的线程,但.thread同时可以切换回中断的线程上下文

kd> .thread /p /r 81e64da8
Implicit thread is now 81e64da8
Implicit process is now 821f5da0
.cache forcedecodeuser done
Loading User Symbols
.........
kd> kv
*** Stack trace for last set context - .thread/.cxr resets it
ChildEBP RetAddr Args to Child
b29b6cb8 80504836 81e64e18 81e64da8 804fc068 nt!KiSwapContext+0x2f (FPO: [Uses EBP] [0,0,4])
b29b6cc4 804fc068 00000000 b29b6d1c 00000000 nt!KiSwapThread+0x8a (FPO: [0,0,0])
b29b6cec 805c1750 00000001 00000006 004db801 nt!KeWaitForSingleObject+0x1c2 (FPO: [5,5,4])
b29b6d50 8054261c 00000010 00000000 b29b6d1c nt!NtWaitForSingleObject+0x9a (FPO: [Non-Fpo])
b29b6d50 7c92e4f4 00000010 00000000 b29b6d1c nt!KiFastCallEntry+0xfc (FPO: [0,0] TrapFrame @ b29b6d64)
003cfa70 7c92df3c 7c8025db 00000010 00000000 ntdll!KiFastSystemCallRet (FPO: [0,0,0])
003cfa74 7c8025db 00000010 00000000 003cfaa8 ntdll!NtWaitForSingleObject+0xc (FPO: [3,0,0])
003cfad8 7c802542 00000010 00002710 00000000 kernel32!WaitForSingleObjectEx+0xa8 (FPO: [Non-Fpo])
003cfaec 7c875f27 00000010 00002710 00000000 kernel32!WaitForSingleObject+0x12 (FPO: [2,0,0])
003cffb4 7c80b713 00000000 00610072 006f0074 kernel32!ConsoleIMERoutine+0xf4 (FPO: [1,300,4])
003cffec 00000000 7c875e33 00000000 00000000 kernel32!BaseThreadStart+0x37 (FPO: [Non-Fpo])
kd> .thread
Implicit thread is now 821ec390
kd> kv
ChildEBP RetAddr Args to Child
b2324c80 80580982 82265aa8 00000000 82265a38 nt!IopfCallDriver+0x31 (FPO: [0,0,0])
b2324c94 8057e4c9 81e6a518 82265a38 822272d8 nt!IopSynchronousServiceTail+0x70 (FPO: [7,0,4])
b2324d38 8054261c 00000038 00000000 00000000 nt!NtWriteFile+0x5d7 (FPO: [Non-Fpo])
b2324d38 7c92e4f4 00000038 00000000 00000000 nt!KiFastCallEntry+0xfc (FPO: [0,0] TrapFrame @ b2324d64)
0012fee0 7c92df6c 7c810e86 00000038 00000000 ntdll!KiFastSystemCallRet (FPO: [0,0,0])
0012fee4 7c810e86 00000038 00000000 00000000 ntdll!ZwWriteFile+0xc (FPO: [9,0,0])
*** ERROR: Module load completed but symbols could not be loaded for test.exe
0012ff44 00401070 00000038 0012ff60 0000000a kernel32!WriteFile+0xf7 (FPO: [Non-Fpo])
WARNING: Stack unwind information not available. Following frames may be wrong.
0012ff7c 0040120e 00000001 003d3ef8 003d2eb8 test+0x1070
0012ffc0 7c817067 00310031 00330031 7ffde000 test+0x120e

可以看到不同的线程时,对应不同的堆栈

windbg学习---!thread和.thread的更多相关文章

  1. 学习笔记——线程 Thread

    Thread是.net1.0 1.1时出现的 主要了解线程等待.回调.前后台线程区别 1.实例: //定义:public delegate void ThreadStart(); ThreadStar ...

  2. 多线程学习三:Thread API,ThreadLocal,synchronized,volatile和Condition

    一.Thread API: setDefaultUncaughtExceptionHandler(Thread.UncaughtExceptionHandler eh) 首先要了解什么是Thread. ...

  3. 被废弃的 Thread.stop, Thread.suspend, Thread.resume 和Runtime.runFinalizersOnExit

    最近学习多线程的知识,看到API里说这些方法被废弃了,就查了一下原因 Thread.stop 这个方法会解除被加锁的对象的锁,因而可能造成这些对象处于不一致的状态,而且这个方法造成的ThreadDea ...

  4. Life Cycle of Thread – Understanding Thread States in Java

    Life Cycle of Thread – Understanding Thread States in Java 深入理解java线程生命周期. Understanding Life Cycle ...

  5. Why Are Thread.stop, Thread.suspend, Thread.resume and Runtime.runFinalizersOnExit Deprecated ?

    Thread.stop, Thread.suspend, Thread.resume被标记为废弃的方法.在查看JDK的文档时,提到了下面的参考文章,先是英文版,接着是中文翻译. Why is Thre ...

  6. java中的线程(1):如何正确停止线程Why Are Thread.stop, Thread.suspend, Thread.resume and Runtime.runFinalizersOnExit Deprecated?

    转自 : http://docs.oracle.com/javase/1.5.0/docs/guide/misc/threadPrimitiveDeprecation.html 1.Why is Th ...

  7. 【C# 线程】 volatile 关键字和Volatile类、Thread.VolatileRead|Thread.VolatileWrite 详细 完整

    overview 同步基元分为用户模式和内核模式 用户模式:Iterlocked.Exchange(互锁).SpinLocked(自旋锁).易变构造(volatile关键字.volatile类.Thr ...

  8. cuda学习2-block与thread数量的选取

    由上一节可知,在main函数中,cuda程序的并行能力是在add<<<N,1>>>( dev_a, dev_b, dev_c )函数中体现的,这里面设置的是由N个b ...

  9. Java多线程高并发学习笔记(一)——Thread&Runnable

    进程与线程 首先来看百度百科关于进程的介绍: 进程是一个具有独立功能的程序关于某个数据集合的一次运行活动.它可以申请和拥有系统资源,是一个动态的概念,是一个活动的实体.它不只是程序的代码,还包括当前的 ...

随机推荐

  1. HDU 1166 敌兵布阵(线段树单点更新)

    敌兵布阵 单点更新和区间更新还是有一些区别的,应该注意! [题目链接]敌兵布阵 [题目类型]线段树单点更新 &题意: 第一行一个整数T,表示有T组数据. 每组数据第一行一个正整数N(N< ...

  2. Bash Shell 获取进程 PID

    转载地址:http://weyo.me/pages/techs/linux-get-pid/ 导读 Linux 的交互式 Shell 与 Shell 脚本存在一定的差异,主要是由于后者存在一个独立的运 ...

  3. dubbo简单demo

    zookeeper,可以集群,可以只安装一台 依赖dubbo jar,  zkclient等 发布服务 <?xml version="1.0" encoding=" ...

  4. hive 基本语法

    本来想讲自己用到的写出来了,结果发现一个比较全面的文章已经介绍过了,那我就不在重新发明轮子了,我也跟着学习一下. 转自:http://jeffxie.blog.51cto.com/1365360/31 ...

  5. Python单链表实现

    class Node(): def __init__(self,InitDate): self.Date=InitDate self.next=None def setNext(self,newnex ...

  6. python——argsort函数

    numpy中argsort函数用法,有需要的朋友可以参考下. 在Python中使用help帮助 >>> import numpy >>> help(numpy.ar ...

  7. Strint类成员

    String& String::operator=(const string& other){ if(this == &other) {  return *this; } de ...

  8. 外壳exe通过反射调用dll时

    外壳exe通过反射调用dll时,dll是 4.0的框架,外壳exe也需要编译成4.0的框架,如果dll本身有调用32位的dll,那么外壳exe也需要编译成32位. 调试时报的那个错,直接继续运行,不影 ...

  9. Samba 4 Domain Controller on Ubuntu 14.04 LTS

    1. Configure network with a static ip address $sudo nano /etc/network/interfaces auto eth0 iface eth ...

  10. OnNcCalcSize改变标题栏等的高度

    在创建窗口时,当收到 WM_NCCALCSIZE 消息时才指定客户区.不管什么时候,只要 Windows 想知道窗口客户区的大小,它便会发送这个消息. NCCALCSIZE_PARAMS 结构保存三个 ...