2016-08-11 20 views

回答

2

我不知道这样一个现成的使用功能的,所以我在这里看到两个选项:

  • 摆弄一些WinDbg的内部命令(你可以难以理解半年后)
  • 使用PyKd,写一个不错的剧本在Python

接近)

这可能类似于此:

~*e .foreach(word {!clrstack}) {.if ($spat("${word}", "?*RunMessageLoop?*") == 1) {.printf "Found!\n"}} 

B方法)

把下列句子变成一个名为clrfindstack.py

from pykd import * 
import sys 

if len(sys.argv) == 1: # script name only 
    print "Please provide a search string as argument" 
    exit() 
threads = getNumberThreads() 
for thread in range(0, threads): 
    dbgCommand("~"+str(thread)+"s") # select the thread 
    stack = dbgCommand("!clrstack") # run !clrstack 
    if sys.argv[1] in stack: # [0] is the script name 
     print "Found", sys.argv[1], "in thread", thread, "(Use ~"+str(thread)+"s to select it)" 

,然后运行它

0:000> !py c:\tmp\clrfindstack.py 
Please provide a search string as argument 
0:000> !py c:\tmp\clrfindstack.py RunMessageLoop 
Found RunMessageLoop in thread 0 (Use ~0s to select it) 

的实现可能不是很Python的,但确实它的工作。

+0

太好了,谢谢托马斯。 – Jason

相关问题