Currently I'm doing the following for analysing a memory leak:
- I open both dumps, using Windbg.
- I launch heap_stat script, a Python-based script for making a summary of the objects, used in the heap.
- I copy the results of both heap_stat scripts, and paste them in an Excel sheet, where the results are analysed.
I'd like to automate this, starting from the final Excel sheet, using VBA, as follows:
- Start two instances of an external program (
Windbg.exe
) and open both dumps with them. - In those
Windbg
instances, launch the necessary commands (.load pykd.pykd
, followed by.py heap_stat.py -stat
). - Wait for the
heap_stat.py
script to finish, and copy the result to the Excel sheet. - Add some necessary
Match()
worksheet functions and Excel formulas for completing the analysis.
In order to do this, I need to be able to:
- Launch an external program from VBA. This can be done, using the
Shell
command. - Within that external program, launch two other commands. (Launching one command is easy, as explained here, but what about two?) In case this is not possible:
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. - Wait for everything to be finished. This can be done using this link.
- Read the output.
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?