Download demo project - 24 Kb
Motivation
When dealing with application crashes, customers don't always send details of the crash
when they report problems. They often don't realise they have to press the Details button,
they dont tell you which version it is, or they might get Dr Watson dumps. Either way, you
get either too much information, or not enough.
Having seen Martin Ziacek's article "SEH and C++ Exceptions - catch all in one" article, this
provided me with a method to get better application crash handling.
Implementaion
Martin's article shows how to gain control after an Exception, what was needed was to
present the information to the user. Firstly I added some code to traverse the stack
in a backwards fashion, and collect all the adresses of all the calls.
void SeTranslator(UINT nSeCode, _EXCEPTION_POINTERS* pExcPointers)
{
CSeException *se = new CSeException(nSeCode, pExcPointers);
DWORD * sp = (DWORD *)(pExcPointers->ContextRecord->Ebp);
for(int i=0;i<32;i++)
{
if(!IsBadReadPtr(sp,sizeof(DWORD)) && *sp)
{
DWORD *np = (DWORD *)*sp;
se->m_StackTrace[i] = *(sp+1);
sp = np;
}
else
se->m_StackTrace[i] = 0;
}
throw se;
}
This way, when the application regains control after the throw
, the
stack at the time of the crash is known.
Implementation
All that is needed now is to present the crash details to the user. This is done by deriving
your application object from CDumpHandleApp
instead of CWinApp
.
CDumpHandleApp
does the rest. In the InitInstance
you need to add a
call to the base class CDumpHandleApp::InitInstance
and to set the support email
address.
BOOL CDumpHandleDemoApp::InitInstance()
{
if(!CDumpHandleApp::InitInstance())
return FALSE;
m_strSupportEmail = "shyde@trontech.net";
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.