Im looking for a way to generate minidump files in my applications simular to what ProcDump does but prefarably with code and not having to extract a 3dparty tool to do it.
The main reasons for not wanting to use ProcDump is:
1) Size of the binary would increase greatly ( This is a problem because my apps are freeware, and bandwith is not free).
2) Feels dirty.
3) No way i can port that app to run inn windows mobile.
My requirements are:
1) Ability to generate mdump files in a fatale crash.
2) Abilityt to do “pause” the app do a dump, and contiune would be a bonus
.
If this is not realy a option, is there a way to get the values of local varibales in the current context dynamicly?
Side note:
I did find this article, but its very old so i so im hesitant to base my work of it.
There seems to either be a issue with IE 9 or with the site, so i had problems with tags.
So there is one solution that comes to mind and meets the following goals:
I’ll give this requirement a complete unknown:
So what’s the solution?
Integrate the required parts you need from the Microsoft Sample for MDbg.exe to provide you with a ‘just-in-time’ debugger that attaches, dumps, and detaches from the crashing process.
Step 1 – Start by downloading the source code to the mdbg from here: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=38449a42-6b7a-4e28-80ce-c55645ab1310&DisplayLang=en
Step 2 – Create a ‘crash’ handler that spawns a debugger process and waits for completion. I used the following few lines of code to re-launch the same exe with a few extra arguments to invoke the debugger and output an xml file to std::out.
Step 3 – Write the debug dump routine, this can be in the same exe or in a different exe. You will need to reference (or include the source from) the ‘raw’, ‘corapi’, and ‘mdbgeng’ modules from the sample. Then add a few lines to your Main():
Example Output
Since you have the full power of a debugger there is nothing stopping you from writing as much or as little as you like, but the above example should get you started.
UPDATE
This works with the .Net 2.0 and/or 3.5 runtime without any further dependencies.
This can debug .Net 2.0/3.5 code running in a .Net 4.0 process; however, it does not work with 4.0 (yet).
For 4.0 CLR see this post:
http://blogs.msdn.com/b/rmbyers/archive/2008/10/27/icordebug-re-architecture-in-clr-4-0.aspx