This is the mail archive of the
gdb@sourceware.cygnus.com
mailing list for the GDB project.
problem catching C++ exceptions with gdb 4.18 on i686-pc-linux-gnu
- To: gdb@sourceware.cygnus.com
- Subject: problem catching C++ exceptions with gdb 4.18 on i686-pc-linux-gnu
- From: "Matthew D. Langston" <langston@SLAC.Stanford.EDU>
- Date: Fri, 21 May 1999 04:00:03 +0000
- Organization: Stanford Linear Accelerator Center
Hello all,
Is this list appropriate for reporting problems such as mine? If not,
then would you direct me to an appropriate resource please?
I cannot seem to set a catchpoint on a C++ exception using gdb 4.18 and
egcs 1.1.2 (AKA egcs-2.91.66) under x86 Linux (Pentium III, Linux
2.0.36, glibc 2.0.7, i686-pc-linux-gnu). According to "help catch":
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Raised exceptions may be caught:
catch throw - all exceptions, when thrown
catch throw <exceptname> - a particular exception, when thrown
catch catch - all exceptions, when caught
catch catch <exceptname> - a particular exception, when caught
[snip]
C++ exceptions may be caught:
catch throw - all exceptions, when thrown
catch catch - all exceptions, when caught
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
However, when I try to do, e.g. "catch throw", gdb prints the following:
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
(gdb) catch throw
Unsupported with this platform/compiler combination.
Perhaps you can achieve the effect you want by setting
a breakpoint on __raise_exception().
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
So, I will take gdb 4.18 at its word that setting catchpoints on C++
exceptions isn't supported on my platform. However, the gdb 4.18 manual
(section 5.1.3, "Setting catchpoints") led me to believe that although
most of the catchpoint functionality currently only works under HP-UX,
the commands "catch throw" and "catch catch" should work on all or most
platforms. On which platforms are these commands supposed to work?
Since I am using GNU C++, I next tried to set a breakpoint on
"__raise_exception" (as instructed in the gdb 4.18 online help and in
section 5.1.3, "Setting catchpoints", of the printed manual for gdb
4.18). However, gdb couldn't find this function with the simple command
"break __raise_exception", and I am unsure where to tell gdb to find it.
I realize that this type of a breakpoint is probably very system
dependent, but could you tell me approximately how I might set such a
breakpoint?
I have attached with this email the tiny little C++ program, `test.cxx',
that I have been using to test the gdb catchpoint functionality. Here
is the complete transcript which demonstrates the problems that I have
described:
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$ g++ --version
egcs-2.91.66
$ g++ -ggdb test.cxx
$ gdb -q a.out
(gdb) b main
Breakpoint 1 at 0x80490d8: file test.cxx, line 13.
(gdb) run
Starting program: /mnt/hdc/projects/c++/a.out
Breakpoint 1, main (argc=1, argv=0xbffff4bc) at test.cxx:13
13 throw foo();
(gdb) catch throw
Unsupported with this platform/compiler combination.
Perhaps you can achieve the effect you want by setting
a breakpoint on __raise_exception().
(gdb) b __raise_exception
Function "__raise_exception" not defined.
(gdb)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Could someone instruct me on the proper way to set "breakpoints" when
C++ exceptions are thrown for "egcs + x86 Linux"? Thank you.
--
Matthew D. Langston
SLD, Stanford Linear Accelerator Center
langston@SLAC.Stanford.EDU
#include <iostream>
#include <stdexcept>
class foo {};
int
main( int argc, char* argv[] )
{
try
{
throw foo();
}
catch ( foo& )
{
cout << "Caught the exception" << endl;
return 0;
}
cout << "Didn't catch the exception" << endl;
return 0;
}