Currently I'm doing the following for analysing a memory leak:
I'd like to automate this, starting from the final Excel sheet, using VBA, as follows:
Windbg.exe
) and open both dumps with them.Windbg
instances, launch the necessary commands (.load pykd.pykd
, followed by .py heap_stat.py -stat
).heap_stat.py
script to finish, and copy the result to the Excel sheet.Match()
worksheet functions and Excel formulas for completing the analysis.In order to do this, I need to be able to:
Shell
command.Windbg
allows concatenating commands, using a semi-colon, so that can be skipped. In order to perform this, I'm thinking about the trick, explained in mentioned URL.My issue is : is it possible to read the output? I know it is possible to wait for a command to finish, to verify if the result is ok or if there is an error, but I don't find a way to read the actual output, thrown by the command.
Does anybody know if this is (easily) feasible?
I've found following solution to my problem:
I'll windbg from Excel VBA as follows:
Shell "windbg -z ""C:\Directory\Dumpfile.dmp"" -c "".load pykd.pyd;.logopen C:\Directory\output.txt;!py heap_stat.py -stat""", vbMaximizedFocus
The meaning of the Windbg commands is the following:
.load pykd.pyd // load PYKD library
.logopen ... // open a logfile, for all Windbg output (thanks, Zac and Tate, for the idea)
!py heap_stat.py -stat // launch the heap_stat script
while
-loop, verifying for the presence of the flag file.