CreateBugReport usage

delphi package - automated exception handling
Post Reply
mj
Posts: 13
Joined: Wed Sep 15, 2004 8:00 pm

CreateBugReport usage

Post by mj »

Hi, I'm writing a DLL that needs to nicely trap its errors, so the call from the main app has a try..except around all the works. I'm therefore unable to use the normal madExcept handling which starts when an unhandled exception occurs. The problem though is that when I call CreateBugReport, the only information I get is about the NT exception handler, and not about where it originally occurred. My current exception handler is as follows:

Code: Select all

	except
		on errInfo : Exception do
		begin
			szTrapInfo := CreateBugReport (false,
						  ErrInfo,
						  nil,	// exceptAddr      : pointer;
						  GetCurrentThreadID,	// callingThreadID : dword;
						  0,	// currentEsp      : dword;
						  0,	// currentEbp      : dword;
						  false);
			Report('An internal spamfilter error occurred: ' + errInfo.Message);
			Report(szTrapInfo);
		end;
Is there any way to improve this? I have some custom handlers in my other (full) applications, but they too depend on the normal handling. I just can't see a way to give madExcept more details about the exception, and still catch it before the main app sees it.

Could you give me any clues please?

Thanks,

Matthew

Sample output that I'm getting:

Code: Select all

madExcept version : 2.7d beta 1
exception class   : EAccessViolation
exception message : Access violation at address 00404D84 in module 'spamfilter.exe'. Write of address 0000001C.

main thread ($e00):
00404d84 +28 spamfilter.exe System @LStrAsg

thread $e74: <priority:15>
7c90eb94 +00 ntdll.dll                            KiFastSystemCallRet
7c90e9be +0a ntdll.dll                            NtWaitForSingleObject
7c8025d5 +85 kernel32.dll                         WaitForSingleObjectEx
7c80253d +0d kernel32.dll                         WaitForSingleObject
0040bbba +e6 spamfilter.exe nxllMemoryManagerImpl CleanupThreadProc
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Try using HandleException(false, errInfo) instead. This will let madExcept do the normal processing of the exception.
mj
Posts: 13
Joined: Wed Sep 15, 2004 8:00 pm

Post by mj »

Many thanks - that does indeed work just fine. I don't know why, but looking at the help about it I sort of glossed over it as it mentioned it put up the dialog. Given I didn't want the dialog, I sought other methods. Of course if the madExcept settings say no dialog and just continue, then HandleException is just what I want.

Thanks for the exceptional service. (I expect you get that pun a lot).

Matthew
Post Reply