Saturday, December 6, 2008
Stack trace from within a program
Ever coding and want to be able get a stack trace at runtime? Edd Dawson's stack trace source, here, bundles this functionality nicely with C++ with cross-platform support. The MSVC source uses imagehlp.dll or dbghelp.dll to obtain the trace and decipher the addresses to symbol names. GCC/MinGW doesn't produce PDB files which contain the symbol names, which makes it impossible to use dbghelp for the stack trace. To solve this, I have attempted to compile Wine's dbghelp.dll for Windows. Wine's dbghelp.dll is able to interpret dwarf and stabs debugging information, which are produced by GCC/MinGW, and Wine's uses the LGPL license, allowing it to be used in more liberally licensed projects. I started a project on SourceForge to host the code ( basically a makefile to download Wine's source, and compile dbghelp.dll using some modified source files ).