Dave's Brain

Browse - Programming Tips - How can I log a stack trace if my (Microsoft Visual C++) program crashes?\

Date: 2016sep29
OS: Windows

Q.  How can I log a stack trace if my (Microsoft Visual C++) program crashes?\

A.  Include all .pdb (program symbol database) files in your install

Include dbghelp.dll in your install

Catch the crash with when your program starts:

#include <crtdbg.h> // ... _CrtSetReportHook(OurReportingFunction);
Here's how that function could be:
int OurReportingFunction(int iReportType, LPSTR szUserMessage, int *retVal) { if (iReportType != _CRT_WARN) // Ignore warnings { // Probablly log something here } MyDumpStack(); // Implemented with StackWalker }
Use Stackwalker to dump your stack: https://stackwalker.codeplex.com/

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.