【问题标题】:Is there a way in windbg to print the current thread id and frame id?windbg 有没有办法打印当前线程 id 和框架 id?
【发布时间】:2013-05-03 12:26:50
【问题描述】:

有点跟进:Is there a way to itereate through all frames in windbg?

~*e .echo Thread Frames and Locals:; !for_each_frame dv

有没有办法回显类似的内容: 当前线程#{ThreadID} 当前帧#{帧号}

我找不到任何关于代表当前帧号或线程号的变量。

.frame 命令显示当前帧号。

举个简单的例子:如果我这样做:~*e .thread

我得到如下输出:

Implicit thread is now 000007ff`fffde000
Implicit thread is now 000007ff`fffdc000
Implicit thread is now 000007ff`fffd8000
Implicit thread is now 000007ff`fffd6000
Implicit thread is now 000007ff`ffefa000

但我想查看 windbg 线程 ID。 同样,我希望看到一个遍历所有线程和框架并打印如下内容的示例:

当前线程#00 当前帧#01

【问题讨论】:

    标签: windbg


    【解决方案1】:

    我不认为您可以关闭 !for_each_frame 向您显示的内容,您只能添加它。所以,例如:

    ~*e .printf "Thread is: 0x%x\n", @@c++(@$teb->ClientId.UniqueThread) ; !for_each_frame .printf "Frame is: %d\n", @$frame
    

    给你一些接近的东西,但输出中仍然有一些垃圾。如果您编写自己的扩展程序,您将拥有更大的灵活性。

    【讨论】:

    • 这非常接近,但它的线程部分似乎有错误。即使我取出框架部分 - 我不能只让线程部分工作:~*e .printf "Thread is: 0x%x\n", @@c++(@$teb->ClientId.UniqueThread) Gives:0:031> ~*e .printf "Thread is: 0x%x\n", @@c++(@$teb->ClientId.UniqueThread) Thread is: 0x2c9c ^ Trailing quote missing in '~*e .printf "Thread is: 0x%x ' ^ Trailing quote missing in '~*e .printf "Thread is: 0x%x 第一个打印正常,但下一个打印不。
    • 对那个格式很抱歉。感谢您的所有帮助...我注意到您也回答了我的最后一个问题:)
    • 这可能是一个普通的windbg错误? ~*e .printf "Thread:0x%x\n",@$tid 好像有同样的问题。
    • 该命令对我来说很好用。尝试更新您的 WinDbg 版本,最新的是 6.2.9200(是的,比 6.11 更新)
    猜你喜欢
    • 1970-01-01
    • 2017-05-21
    • 1970-01-01
    • 1970-01-01
    • 2012-02-04
    • 2020-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多