【问题标题】:How to redirect windbg command to a file without echoing the output on the windbg console?如何将windbg命令重定向到文件而不在windbg控制台上回显输出?
【发布时间】:2015-11-05 21:56:43
【问题描述】:

.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)。我知道编写一个仅将标准输入转发到标准输出的小实用程序是一件微不足道的工作,但我还是不想这样做。

【问题讨论】:

    标签: windbg


    【解决方案1】:
    .shell -i- -ci "!dumpgen 2" findstr "^" >D:\tmp\dumpgen2.log
    

    ^ 会找到任何行的开头,所以它应该是 1:1 的副本。

    【讨论】:

      【解决方案2】:

      你也可以使用 gnuwin32 猫

      C:\>dir /b foogg.txt   
      File Not Found
      

      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)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2010-11-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-12-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多