parsing WinDbg output in real-time and setting a trigger on a specific line of output

403 Views Asked by At

Is there any way to parse the output of WinDbg and set a "trigger" on a specific line of output? I mean - executing a line of WinDbg script / pykd script when a specific line of output appears.

I've tried performing this using WinDbg scripting, but I was unsuccessful.

2

There are 2 best solutions below

1
Thomas Weller On BEST ANSWER

If you want to control the debugger using OutputDebugString(), then have a look at .ocommand.

Otherwise I'm not aware of something that could directly achieve what you want. You could write a PyKD script that runs forever and emulates the command prompt. You could then use dbgCommand() to execute the command and get the result back as a string. Forward it to the output and analyze it in order to run a script.

0
ussrhero On

with pykd you can try make your own eventHandler:

class outputHandler(pykd.eventHandler):

     def onDebugOutput(self, str):
          if str == "something interesting":
              do_handler()

eh = outputHandler()

Then you should run you script with 'global' interpreter:

!py -g my_script.py

I hope it will work