Stacktracing exceptions with Mingw

Hi,
I'm having an STL code, in which the STL throws an exception I didn't catch (I didn't catch it on purpose, since this exceptions means bugs in my code. The exception is vector.at getting wrong index). I want, just like in Java, to see who (which line) threw the exception. I found no way to do that with mingw (I heard one should put a breakpoint at '__raise_exception', and then have a look at the stack with bt, but Mingw say no such function exists.
Is there any way to do that? Knowing who threw the exception, really helps with debugging. If it was me who threw the exception I could incorporate a __LINE__ macro that would tell me who threw it, but it's STL, and I can't (and don't want) to change it.

Many thanks
Well, Java is compiled to bytecode, which lets it keep more data about the original source than native exes. I don't think there's any way to know which line throws an exception. Specially since the exception comes from a different function that has no idea what function is calling it from which line.
The way you could use __LINE__ is by catching the exception and displaying the line somewhere.
You could use a debugger. It holds stack trace information, which is very helpful in these cases.

Yeah. Change the STL. That sounds like a good idea right there.
Last edited on
The debugger will tell you where the exception was thrown, assuming you are running it with symbols compiled in.

But regardless, you should exception handle your code. Then display information about the exception etc.
Zaita:
Thanks!
But which debugger does that? gdb didn't do that for me automatically, and I don't know how to tell him to do that. I don't think VS 6 do that automatically also.
Can you guide me with what to do to have the debugger do that?
The debugger in VC++ 7 and up will do that and more. I don't know how to do it with gdb without an IDE, though.
GDB can print a stack trace. I don't remember the command for it but you should get a GDB cheat sheat :)
Topic archived. No new replies allowed.