如何将WinDbg命令的输出保存到文本文件中?
如果您发现这种方法更容易,您也可以在WinDbg图形用户界面中执行此操作:“编辑>将窗口文本写入文件...”。
要将特定命令的输出发送到文件,请获取Tee(我使用Tee.bat),将其放入Windows PATH
环境变量覆盖的目录中(或添加该目录)。然后从WinDbg GUI使用以下语法将命令的输出发送到文件
.shell -ci "<command>" tee <file>
.shell -ci "!gcroot 000002b56c414750" tee c:\path\out_01.log
有一个未记录的!!
缩写形式的.shell
。所以你可以这样做:
!! -ci "!gcroot 000002b56c414750" tee c:\path\out_01.log
背景
你可以在 WinDbg 图形界面中运行 shell 命令。语法 如下:
.shell [Options] [ShellCommand]
.shell -i InFile [-o OutFile [-e ErrFile]] [Options] ShellCommand
这里我找到了将命令输出发送到剪贴板的解决方案。
.shell -ci "<command>" clip
clip
,那么将其发送到文件中是否也是可能的呢?
.shell -ci "<command>" > <file>
.shell -ci "!gcroot 000002b56c414750" > c:\path\out_01.log
虽然这样做会很好,但它无法正常工作。在MS文档中,我找到了这个例子。
.shell -ci "!process 0 7" perl.exe parsemyoutput.pl
所以可以将输出发送到应用程序中。就像上面的例子使用clip
一样。这就是Tee的作用。但是你也可以使用任何其他脚本或.exe将输出存储在文件或其他位置中。