Re: [GD-Windows] Finding routine that's crashing
Brought to you by:
vexxed72
From: Colin F. <cp...@ea...> - 2002-08-01 21:58:40
|
2002 August 1st Thursday That code is very interesting. There are at least two things that caused me trouble, though: [1] Under Windows 98, the DLL with the symbol handler and StackWalk() functions is called: "imagehlp.dll". (i.e., different from the "dbghelp.dll" references scattered around the source and project settings) [2] Under Windows 98, we need the process **ID** for SymInitialize(), NOT the process handle. (See MSDN Library documentation for SymInitialize().) HANDLE hProcess = GetCurrentProcess(); DWORD idProcess = GetCurrentProcessId(); #ifdef WIN_98 SymInitialize( ((HANDLE)(idProcess)), mSearchPath, FALSE ); #else SymInitialize( hProcess, mSearchPath, FALSE ); #endif (NOTE: Read MSDN Library documentation for how to proceed with the other functions.) Despite the glitches (I still can't get the code to work under Windows 98; minor stuff), I'm glad for the code example; it inspired me to study this area, which is fascinating. By the way... >>>Hey, thanks! what a nice code! >>>by the way, there's a little leak in line 96 in file ExceptionHandler.cpp: >>>tt = new char[TTBUFLEN]; >>>is never freed, just replace it by: >>>char tt[TTBUFLEN]; >>>and should be fine, or add the appropiate delete at the end >>>of the function. >>>And there's no need to have TTBUFLEN = 0xFFFF, that's too big I think... >>>Ignacio Castaño >>>cas...@ya... Perhaps "tt = new char[TTBUFLEN]" was done instead of "char tt[TTBUFLEN]" to avoid putting more stuff on the stack? I guess if the exception was a stack overflow, then you're pretty much doomed anyway. --- Colin ============================================================== Andrew Grant wrote: > This would be very handy, if you're willing to share! > > I can find SymGetSymFromAddr in MSDN, but I'm fuzzy on how you get the > stack trace. (Second sending, apparently the mail list has an attatchment limit which I went over by more than I thought it'd be). Files are at <http://www.b0rked.clara.co.uk/assert.zip> Attatched is the source for something similar (and a drop in module for people who don't really want to worry about how it works). Sorry for the attatchment, it's fairly small and I don't have anywhere at hand to upload it to. I wrote this a while ago for tracking down some rare crashes we had in art tools, it's basically a drop in that replaces the standard MSVC runtime assert but provides more info. You place the dll in your working folder and add the two files to your project so when an assert triggers you get the below dialog. If the DLL doesn't exist then it defaults back to the standard version. use ASSERT(x) or one of the macros in stdassert.h and you should get a dialog like the image below. Hopefully it might be of some use to someone. It's very old code that I wrote in one evening so be kind, also some of the stack trace code is ripped from an MSDN sample but tidied up. Andrew Grant- Climax Brighton |