Closed MKKnauer closed 4 years ago
Yes, it seems there's no exception per se.
Using DbgHelp API (ditto for MgwHelp) directly requires a lot of work. They are full of subtle quirks. I really don't recommend using them directly unless you're writing general purpose debugging tools/libraries.
I think the most practical way to do this is to:
MY_ASSERT
macro, which calls MyAssertFailed(...)
MyAssertFailed
raise an exceptionI don't know if Q_ASSERT() provides some callback that's called when assertions failed. If it did, it would eliminate one step above.
Thanks for the quick reply.
The issue I'm dealing with is Q_ASSERTs inside Qt libraries (ex: ASSERT failure in QList
Thanks again.
In that case I recommend you use the catchsegv
utility that's included with drmingw
. It will dump the stack back trace when the program aborts.
So if you run something like
catchsegv yourapp.exe
it should catch when Q_ASSERT() terminates the process with a non-zero exit code, and dump the stack back trace to stderr.
Thank you again - that does the trick.
I've set it up to redirect the stderr to a file, and it leads me to one final question. After the crash, I do get the stack trace but catchsegv just sort of sits there after that. I end up hitting ctrl-c twice to get it to exit.
I tried setting a timeout to see what that would do and got the following message a little while after the stack dump: catchsegv: time out (60 sec) exceeded catchsegv: error: failed to interrupt target (0x00000005)
If I run my app and exit without crashing, catchsegv exits with no problem.
Any thoughts?
Sometimes catchsegv takes a long time downloading symbols from Microsoft symbol store. Perhaps it's a matter of waiting.
Otherwise it could be a bug. I'll need to repro to investigate it further though
Looks like that was is it. Thanks once more.
I'm trying to use mgwhelp to get a call stack after a Qt assert, but I can't figure out how to get the right context (and no, I don't have a lot of experience with this, so any help would be useful).
The code I've seen used elsewhere (with dbghelp) is this:
But GetExceptionInformation() doesn't seem to be available (or isn't linking correctly for me) in mgwhelp.
I am successfully using exchndl for crash reports, but in the case of these Qt asserts, nothing is generated (I'm assuming this is because Qt is handling them and then exiting instead of having an exception thrown).