2017-02-10 211 views
1

我试图过滤命令的输出,例如lm的输出太长。windbg的过滤器输出

类似于lm | find "some_string"的东西。

windbg支持吗?我无法在网上找到任何有关它的文件。

+0

使用内幕SDK版本。 – conio

回答

3

我通常使用.shell命令,无论是与Windows工具(如findstr)或与cygwin安装的二进制文件。 .shell command help from MSDN

例子:

WinDBG的版本,虽然这应该与旧版本工作过:

0:000> version 
[snip] 
Microsoft (R) Windows Debugger Version 10.0.14321.1024 X86 
Copyright (c) Microsoft Corporation. All rights reserved. 

开始记事本

0:000> | 
. 0 id: 31a0 create name: notepad.exe 

列表模块:

0:000> lm 
start end  module name 
00030000 0006e000 notepad (deferred)    
52270000 52280000 FeClient (deferred)    
6d360000 6d4af000 PROPSYS (deferred)    
6f650000 6f879000 iertutil (deferred)    
6f880000 6fa14000 urlmon  (deferred)    
73c40000 73c5b000 bcrypt  (deferred)    
73dc0000 73e2a000 WINSPOOL (deferred)    
73ee0000 740ea000 COMCTL32 (deferred)    
74130000 7413a000 CRYPTBASE (deferred)    
74140000 7415e000 SspiCli (deferred)    
746b0000 7472b000 msvcp_win (deferred)    
74730000 7488f000 USER32  (deferred)    
74890000 74970000 KERNEL32 (deferred)    
749d0000 74a58000 shcore  (deferred)    
[snip] 

使用Windows findstr让所有模块 “克恩”(不区分大小写)

0:000> .shell -ci "lm" findstr /i kern 
74890000 74970000 KERNEL32 (deferred)    
76ac0000 76acd000 kernel_appcore (deferred)    
77530000 776d1000 KERNELBASE (deferred)    
.shell: Process exited 

与grep.exe相同(cygwin的版本,这是我的%PATH%

0:000> .shell -ci "lm" grep.exe -i kern 
74890000 74970000 KERNEL32 (deferred)    
76ac0000 76acd000 kernel_appcore (deferred)    
77530000 776d1000 KERNELBASE (deferred)    
.shell: Process exited 

[编辑]

这个命令是非常强大的,你可以轻松地发送的WinDbg的命令输出到脚本解释器(我使用Python了很多工作):

.shell -ci "<windbg command>" python mypythonscript.py 
1

如果你不能使用shell,那么很少有像domdbg这样的扩展名。 Mex by microsoft等提供grep/findstr实现。所以你可以使用它。 !grep foo“lm”

2

我刚刚写了一个Grep-like WinDbg extension,请尝试一下并回复我,如果它符合您的要求。

支持的命令如下:WinDbg中和JS的

!silent    : Switch On/Off silent mode  
!grep     : Filter lines by regular expression 
!igrep    : Filter lines by regular expression, case-insensitive 
!grep_format   : Do regular expression searching, output formatted result upon captured groups 
!igrep_format   : Do regular expression searching, output formatted result upon captured groups, case-insensitive 
!grep_formatx   : Do regular expression searching, output formatted result upon captured groups, then execute formatted string as windbg commands 
!igrep_formatx  : Do regular expression searching, output formatted result upon captured groups, case-insensitive, then execute formatted string as windbg commands