windbg: Command output to text file
Asked Answered
R

4

54

How can I Save Output of a command in WinDbg to a Text File?

Raimes answered 17/6, 2009 at 9:38 Comment(0)
L
61

Start WinDbg from the command line using the -logo option:

windbg.exe -logo logfile.txt

That will get everything done logged to the file specified. You can find more details of the command line options here.

Or, if you are already in a debugging session, you can use the .logopen command to start logging. For more info on this command see here

Or you can click edit->Open/Close log file in the WinDbg GUI.

More info on log files is here.

Lookeron answered 17/6, 2009 at 10:11 Comment(0)
T
32

You can use .logopen , all of the commands you input and response from windbg will be logged, and then use .logclose to flush the data into

Tristatristam answered 29/12, 2011 at 3:44 Comment(0)
C
16

You can also do this from the WinDbg gui 'Edit>Write Window Text To File...' if you find that easier.

Chargeable answered 1/3, 2012 at 11:3 Comment(0)
U
0

To send the output of a specific command to a file, go and get Tee, (I use Tee.bat), put it into a directory covered by the Windows PATH environment variable (or add the directory you've put it in). Then use the following syntax from the WinDbg GUI to send the output of a command to a file

.shell -ci "<command>" tee <file>

.shell -ci "!gcroot 000002b56c414750" tee c:\path\out_01.log

There's an undocumented !! abbreviation of .shell. So you could just do:

!! -ci "!gcroot 000002b56c414750" tee c:\path\out_01.log

Background

You can run shell commands in the WinDbg GUI. The syntax is:

.shell [Options] [ShellCommand] 
.shell -i InFile [-o OutFile [-e ErrFile]] [Options] ShellCommand

Here I found the solution to send the command output to the clipboard.

.shell -ci "<command>" clip

If you can send the output to clip, shouldn't it be possible to send it to a file, like so?

.shell -ci "<command>" > <file>
.shell -ci "!gcroot 000002b56c414750" > c:\path\out_01.log

Would be nice, but it does not work. In the MS docs I found this example.

.shell -ci "!process 0 7" perl.exe parsemyoutput.pl

So it is possible to send the output to an application. Just like the above example using clip. And that's where Tee came in. But you could use any other script or .exe which takes the output and stores it in a file or another place.

Unbuild answered 4/11, 2022 at 10:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.