【问题标题】:Windbg "!locks" command doesn't work, can I get information anyway?Windbg "!locks" 命令不起作用,我还能获取信息吗?
【发布时间】:2019-05-19 18:50:14
【问题描述】:

在调试转储文件时,我需要定期检查锁,为此我使用windbg 扩展命令!locks。当一切顺利时,它会提供如下输出:

CritSec +54a8a8 at 0054a8a8
WaiterWoken        No
LockCount          0
RecursionCount     1
OwningThread       13d8
EntryCount         0
ContentionCount    0
*** Locked

CritSec +b73a8d at 00135e8d
WaiterWoken        No
LockCount          0
RecursionCount     1
OwningThread       55f3
EntryCount         0
ContentionCount    0
*** Locked

...

Scanned 662 critical sections

但是,有时我会收到以下错误消息:

Stopped scanning because of problem reading critical section debug info

Scanned 7 critical sections

是否有可能获得一些信息? (例如,critical section debug info 在哪里,如果没有!locks 命令,我如何阅读它,...)

【问题讨论】:

  • 您可以尝试!cs -s -l -o,但您可能会看到同样的情况,您可能需要使用 glags 启用用户模式堆栈跟踪!gflag +ust
  • @EdChum:感谢您的快速回复。请把它写成答案,我会接受的。显然!locks!cs -s -l -o 命令的摘要。

标签: c++ debugging windbg locks


【解决方案1】:

!locks 的更好替代方法是使用 !cs -s -l -o 参见 !cs 这将显示所有锁定的临界区、所有者堆栈跟踪和临界区堆栈跟踪,如果你想要全部可以省略 -l关键部分。您可能需要使用gflags !gflag +ust 启用用户模式堆栈跟踪,请记住在不需要时将其删除!glag -ust

要显示关键部分信息,如果您有地址,则可以这样做:https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/displaying-a-critical-section

所以!critsec ADDRESS 或使用显示类型命令dt dt RTL_CRITICAL_SECTION ADDRESS 如果你有地址就可以工作。

【讨论】:

  • 谢谢。实际上 !cs -l 更接近于 !locks,然后您可以使用任何您想要的选项显示调用堆栈。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-08
  • 1970-01-01
  • 1970-01-01
  • 2014-02-11
  • 1970-01-01
相关资源
最近更新 更多