At one point, "catch catch" and "catch throw" were documented as taking an argument that would filter exceptions by type. This was never implemented. However, it would be very useful to have.
For "catch throw" it seems like we could get the needed info relatively easily, by extracting the typeinfo argument to __cxa_throw: extern "C" void __cxxabiv1::__cxa_throw (void *obj, std::type_info *tinfo, void (_GLIBCXX_CDTOR_CALLABI *dest) (void *)) It is less clear how to get this for "catch catch", though, and this also doesn't handle re-throws. Adding some SDT probes in libsupc++ would be simpler.
See also PR 15176.
Testing a patch.
CVSROOT: /cvs/src Module name: src Changes by: tromey@sourceware.org 2013-04-15 18:13:01 Modified files: gdb : ChangeLog NEWS break-catch-throw.c cp-abi.c cp-abi.h gdb_regex.h gnu-v3-abi.c probe.c utils.c gdb/doc : ChangeLog gdb.texinfo gdb/testsuite : ChangeLog gdb/testsuite/gdb.cp: exceptprint.exp Log message: PR c++/13588: * NEWS: Update. * break-catch-throw.c (struct exception_catchpoint) <exception_rx, pattern>: New fields. (fetch_probe_arguments, dtor_exception_catchpoint) (check_status_exception_catchpoint) (print_one_detail_exception_catchpoint): New functions. (handle_gnu_v3_exceptions): Add "except_rx" argument. Compile regular expression if needed. (extract_exception_regexp): New function. (catch_exception_command_1): Use extract_exception_regexp. (compute_exception): Use fetch_probe_arguments. (initialize_throw_catchpoint_ops): Set dtor, print_one_detail, and check_status fields. * cp-abi.c (cplus_typename_from_type_info): New function. * cp-abi.h (cplus_typename_from_type_info): Declare. (struct cp_abi_ops) <get_typename_from_type_info>: New field. * gdb_regex.h (compile_rx_or_error): Declare. * gnu-v3-abi.c (gnuv3_get_typename_from_type_info): Update comment. (init_gnuv3_ops): Set get_type_from_type_info field. * probe.c (compile_rx_or_error): Move... * utils.c (compile_rx_or_error): ... here. gdb/doc * gdb.texinfo (Set Catchpoints): Document regexp syntax for exception catchpoints. gdb/testsuite * gdb.cp/exceptprint.exp: Add regexp catchpoint tests. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.15417&r2=1.15418 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/NEWS.diff?cvsroot=src&r1=1.590&r2=1.591 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/break-catch-throw.c.diff?cvsroot=src&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/cp-abi.c.diff?cvsroot=src&r1=1.42&r2=1.43 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/cp-abi.h.diff?cvsroot=src&r1=1.27&r2=1.28 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/gdb_regex.h.diff?cvsroot=src&r1=1.13&r2=1.14 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/gnu-v3-abi.c.diff?cvsroot=src&r1=1.84&r2=1.85 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/probe.c.diff?cvsroot=src&r1=1.6&r2=1.7 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/utils.c.diff?cvsroot=src&r1=1.297&r2=1.298 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/doc/ChangeLog.diff?cvsroot=src&r1=1.1446&r2=1.1447 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/doc/gdb.texinfo.diff?cvsroot=src&r1=1.1080&r2=1.1081 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.3626&r2=1.3627 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.cp/exceptprint.exp.diff?cvsroot=src&r1=1.1&r2=1.2
Fix checked in.