This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
Re: Simple exception use-case
Daniel Jacobowitz wrote:
gdb simple
GNU gdb Fedora (6.8-11.fc9)
(gdb) catch catch
Function "__cxa_begin_catch" not defined.
(gdb) catch throw
Function "__cxa_throw" not defined.
IIRC this is because GDB does not (did not?) use pending breakpoints.
Try again after starting the program, so libstdc++ is loaded. If it's
still broken it's an easy fix.
Ok if I break main, then run, and then finally add the catch throw and
catch catch, it works. That's another on my list to investigate. But
while doing this I stumbled onto something interesting. If you look at
these two test-runs, one from upstream GDB one from a patched Fedora GDB
you'll see that the Fedora GDB did not loose control of the inferior.
This test is by no means conclusive, but it intrigues me. For the
purpose of this use-case and estimation I was going to concentrate
purely on upstream, but I think I'll take a look at Fedora GDB and
investigate the patch load. There may be a patch that already fixes
possible longjmp or other inferior control issues. If so, can look at
the estimation to convert this patch upstream, tweak it - whatever -
over writing new support. At the very least I'll investigate why this
one use-cases diverges on two different GDBs.
** UPSTREAM GDB
~/gdb_obj/gdb/gdb simple
GNU gdb (GDB) 6.8.50.20080728-cvs
(gdb) break main
Breakpoint 1 at 0x400be7: file simple.cxx, line 17.
(gdb) r
Starting program: /home/pmuldoon/exceptions/simple
Breakpoint 1, main () at simple.cxx:17
17 throw simple;
(gdb) catch throw
Catchpoint 2 (throw)
(gdb) c
Continuing.
Catchpoint 2 (exception thrown), 0x000000333d0c3d70 in __cxa_throw ()
from /usr/lib64/libstdc++.so.6
(gdb) s
Single stepping until exit from function __cxa_throw,
which has no line number information.
Exception: simple exception occurred
Program exited normally.
** CURRENT FEDORA GDB
gdb simple
GNU gdb Fedora (6.8-11.fc9)
(gdb) break main
Breakpoint 1 at 0x400be7: file simple.cxx, line 17.
(gdb) r
Starting program: /home/pmuldoon/exceptions/simple
warning:
"/usr/lib/debug/lib/modules/2.6.25.10-86.fc9.x86_64/vdso/vdso.so.debug":
The separate debug info file has no debug info
Breakpoint 1, main () at simple.cxx:17
17 throw simple;
(gdb) catch throw
Catchpoint 2 (throw)
(gdb) c
Continuing.
Catchpoint 2 (exception thrown)
__cxa_throw (obj=<value optimized out>, tinfo=<value optimized out>,
dest=<value optimized out>) at
../../../../libstdc++-v3/libsupc++/eh_throw.cc:63
63 header->unexpectedHandler = __unexpected_handler;
(gdb) s
58 void (*dest) (void *))
(gdb) s
71 _Unwind_RaiseException (&header->unwindHeader);
(gdb) s
61 header->exceptionType = tinfo;
(gdb) s
62 header->exceptionDestructor = dest;
(gdb) finish
Run till exit from #0 __cxa_throw (obj=<value optimized out>,
tinfo=<value optimized out>, dest=<value optimized out>)
at ../../../../libstdc++-v3/libsupc++/eh_throw.cc:62
0x0000000000400c13 in main () at simple.cxx:17
(gdb) s
19 catch (exception &e)
(gdb) s
__cxa_begin_catch (exc_obj_in=<value optimized out>) at
../../../../libstdc++-v3/libsupc++/eh_catch.cc:45
45 __cxxabiv1::__cxa_begin_catch (void *exc_obj_in) throw()
(gdb) finish
Run till exit from #0 __cxa_begin_catch (exc_obj_in=<value optimized
out>) at ../../../../libstdc++-v3/libsupc++/eh_catch.cc:45
0x0000000000400c34 in main () at simple.cxx:19
19 catch (exception &e)
Value returned is $1 = (void *) 0x15fa080
(gdb) s
21 cout << "Exception: " << e.what() << endl;
(gdb) s
simple::what (this=0x15fa080) at simple.cxx:10
10 return "simple exception occurred";
(gdb) s
11 }
(gdb) c
Continuing.
Exception: simple exception occurred
Program exited normally.