This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: How does "bt" determine where to stop? (C++ and exceptions)

"George T. Talbot" <> writes:

> I didn't realize that the current method for exception handling does setjmp()
> and longjmp().
It varies from platform to platform, but the code you show implies that is what your platform is using.

What platform are you using, anyway?
> Unfortunately, whatever it uses, the approach you suggest only works in a
> program which throws exceptions very infrequently.  If I have a program that
> uses exceptions frequently, this approach isn't going to work.  Also, in the
> backtrace I showed you, I know that there are a zillion frames below that
> throw_helper, so I know it isn't the top of the stack.  Is there anything that
> could be done to the debugger to help it to recognize the situation?

Actually, i implemented catch throw, and catch catch on BeOS by doing just this, plus a little extra code to determine why we threw/caught.
If you tell me what platform/version of gcc you are using, it would help a bunch.
Their really aren't a zillion frames when you setjmp, the top is the setjmp caller. Until the longjmp, that is really the stack.

It would take a *lot* of work to make it identify what variable the setjmp was stored into, read the rest of the stack from that variable, and so on.
The real solution is what was already done, which is use a better exception handling mechanism.

> --
> George T. Talbot
> <george at moberg dot com>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]