如何将windbg命令重定向到文件而不在windbg控制台上输出?

4

.logopen 不是解决方案,因为它允许命令输出到windbg控制台。

例如,!sosex.dumpgen 2 会产生大量输出,我不想在调试器控制台中看到。现在我正在使用以下内容:

.shell -i- -ci "!dumpgen 2" cmd /c more > D:\tmp\dumpgen2.log

我的问题是 more 命令是交互式的,并且在输出一定量的数据后需要用户输入,这对我来说是一个大问题。
其中一个解决方案是使用脚本以非交互方式运行调试器,并在那里使用 .logopen 命令。
我想知道能否在以下情况下实现我的目标:
  1. 从交互式 WinDbg 会话中进行操作
  2. 使用普通的标准 shell 命令(也可以是 cmd.exe 或 powershell.exe)。 我知道编写一个只将 stdin 转发到 stdout 的小型实用程序是微不足道的工作,但我宁愿不这样做。
2个回答

8
.shell -i- -ci "!dumpgen 2" findstr "^" >D:\tmp\dumpgen2.log

^ 会找到任何行的开头,因此它应该是一个一对一的复制。


1
你也可以使用GNUWin32的cat命令。
C:\>dir /b foogg.txt   
File Not Found

C:>cdb -c ".shell -ci \"lm\" -o \"c:\\foogg.txt\" cat -" calc.exe

C:\>cdb -c ".shell -ci \"lm\" -o \"c:\foogg.txt\" cat -" calc.exe
0:000> cdb: Reading initial command '.shell -ci "lm" -o "c:\\\\foogg.txt" cat -'

<.shell waiting 10 second(s) for process>
.shell: Process exited
0:000> q
quit:

检查文件是否存在并打印内容

C:\>dir /b foogg.txt
foogg.txt

C:\>cat foogg.txt

start    end        module name
01000000 0101f000   calc       (deferred)
77c10000 77c68000   msvcrt     (deferred)
77dd0000 77e6b000   ADVAPI32   (deferred)
77e70000 77f02000   RPCRT4     (deferred)
77f10000 77f59000   GDI32      (deferred)
77f60000 77fd6000   SHLWAPI    (deferred)
77fe0000 77ff1000   Secur32    (deferred)
7c800000 7c8f6000   kernel32   (deferred)
7c900000 7c9b2000   ntdll      (pdb symbols)
7c9c0000 7d1d7000   SHELL32    (deferred)
7e410000 7e4a1000   USER32     (deferred)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接