views:

74

answers:

2

How can I automate the debugging process?

I have a WinDbg script with some basic commands which I want to run when a break occurred in the process/application that I attached to WinDbg. How can I know that there is break in WinDbg, and how to launch the script automatically?

+2  A: 

You can use the command string option when setting the breakpoint to run any windbg command. Have this run your script.

Something like:

bp  <address to set break> "$$><c:\\temp\\dbgscript.txt;g"

I believe you should be able to do the same thing with the sx command if you mean "when an exception is thrown" by "when there is a break occurred in the process".

Russell Troywest
A: 

Are you running the application with windbg already attached, or are you JIT debugging? If the latter (i.e., you're relying on the setting in HKLM\Softare\Microsoft\Windows NT\AEDebug\Debugger), then simply modify the value of the Debugger key to use the "-c" command to run a command after the debugger attaches.

Assuming the former, then you could try starting the debugging server using a named pipe or tcp (with the .server command). You can then write a console app to start an instance of cdb as a client to connect to the aforementioned windbg server and have the app parse stdout until you see the debugger prompt. You can then effectively automate the debugging session from that point on. Thus, it gets reduced a parsing exercise, possibly wrapped in an FSM depending on how complex you want to get.

nithins
Thanks for the inputs. as u guessed, it is the 1st scenario that I want to implement.
satya