I've looked at all kinds of pages:
1] http://www.winwonk.com/writing/minidump/
2] http://www.codeproject.com/debug/postmortemdebug_standalone1.asp
3] http://msdn.com/msdnmag/issues/02/06/Bugslayer/
4] http://msdn.com/msdnmag/issues/02/03/hood/
I have it working in my own exception handler, and I've tried
John Robbins' Bugslayer [3] but it still doesn't work the way I want
it to.
The problem is that inside an exception handler, as set like this:
::SetUnhandledExceptionFilter( IGExceptionHandler );
and defined like this:
LONG IGDebug::IGExceptionHandler( struct _EXCEPTION_POINTERS *pExceptionInfo )
{
...
}
if I call MiniDumpWriteDump from the exeception handler, I get the call stack
for the exception handler, *not* where the exception happened.
I looked at Matt Pietrek's WheatyExceptionReport [4], but it requires
the PDB file to be around when it is called - not something we're going
to ship to customers. It does, however, do what I think I need to do
with the MiniDump function - set the stack frame to be the one found in
pExceptionInfo, and not to use the current one from the exception handler.
Dr. Watson does it correctly, so I should be able to as well, right? How
can I set the context for the MiniDump?
--
Jonathan Arnold
inSORS
> if I call MiniDumpWriteDump from the exeception handler, I get the call stack
> for the exception handler, *not* where the exception happened.
I don't know the exact answer to your question, but I haven't had any problems myself...
Do you populate the MINIDUMP_EXCEPTION_INFORMATION properly?
What does your call to MiniDumpWriteDump look like?
--
Best regards,
Kim Gräsman
Thanks for the reply. Here's my structured exception handler code, strip
to its bare essentials:
LONG IGDebug::IGExceptionHandler( struct _EXCEPTION_POINTERS *pExceptionInfo )
{
LONG retval = EXCEPTION_CONTINUE_SEARCH;
HWND hParent = NULL; // find a better value for your app
// firstly see if dbghelp.dll is around and has the function we need
// look next to the EXE first, as the one in System32 might be old
// (e.g. Windows 2000)
HMODULE hDll = NULL;
std::string appPath;
GetMyFolder( appPath );
appPath += "\\DBGHELP.DLL";
hDll = ::LoadLibrary( appPath.c_str() );
MINIDUMPWRITEDUMP pDump = (MINIDUMPWRITEDUMP)::GetProcAddress( hDll, "MiniDumpWriteDump" );
char szDumpPath[_MAX_PATH];
// work out a good place for the dump file
if (!GetTempPath( _MAX_PATH, szDumpPath ))
_tcscpy( szDumpPath, "c:\\temp\\" );
_tcscat( szDumpPath, appName_ );
_tcscat( szDumpPath, ".dmp" );
HANDLE hFile = ::CreateFile( szDumpPath, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL );
_MINIDUMP_EXCEPTION_INFORMATION ExInfo;
ExInfo.ThreadId = ::GetCurrentThreadId();
ExInfo.ExceptionPointers = pExceptionInfo;
ExInfo.ClientPointers = FALSE;
// write the dump
BOOL bOK = pDump( GetCurrentProcess(), GetCurrentProcessId(),
hFile, MiniDumpNormal, &ExInfo, NULL, NULL );
::CloseHandle(hFile);
return retval;
}
The only thing I'm a little unsure on is the value of ClientPointers. I've
tried both TRUE and FALSE, and neither seems to make any difference. The
dump file generated has a stack starting in the exception handler and going
up to the CRT, and not where the exception happened.
--
Jonathan Arnold
inSORS
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Jonathan Arnold" <jdarnold_online@insors_comm.com> wrote in message
news:#F8pD34r...@TK2MSFTNGP12.phx.gbl...
Yup - just moments ago I found this magical .ecxr command! Works
like a charm.
> As far as using the MiniDumpWriteDump on your own,
> I would recomend levereging faultrep!ReportFault
> and the built-in error reporting mechanism.
I'm not sure what you mean by "faultrep!ReportFault", and the built-in
error reporting mechanism. Do you mean the Windows Error Reporting
stuff?
--
Jonathan Arnold
inSORS
Best regards,
Rhett Gong [MSFT]
Microsoft Online Partner Support
This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only. Thanks.