From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11115 invoked by alias); 1 Mar 2013 20:57:25 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 11019 invoked by uid 306); 1 Mar 2013 20:57:23 -0000 Date: Fri, 01 Mar 2013 20:57:00 -0000 Message-ID: <20130301205723.11002.qmail@sourceware.org> From: tromey@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] tromey/exception-improvements: canonicalize type name before applying regexp X-Git-Refname: refs/heads/tromey/exception-improvements X-Git-Reftype: branch X-Git-Oldrev: 3cd1c59aca2ae45f85e77f95a1ed1d0327d5700f X-Git-Newrev: 3169700d5559c1de86de44260312218ab06fda9d X-SW-Source: 2013-q1/txt/msg00227.txt.bz2 List-Id: The branch, tromey/exception-improvements has been updated via 3169700d5559c1de86de44260312218ab06fda9d (commit) via 87165103837aa18e8faa1a2b188307d1ced354ef (commit) via 4f0b0f419272b8ca0a0ed0e9073b6cfeaf817343 (commit) from 3cd1c59aca2ae45f85e77f95a1ed1d0327d5700f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 3169700d5559c1de86de44260312218ab06fda9d Author: Tom Tromey Date: Fri Mar 1 13:48:56 2013 -0700 canonicalize type name before applying regexp commit 87165103837aa18e8faa1a2b188307d1ced354ef Author: Tom Tromey Date: Fri Mar 1 13:28:30 2013 -0700 add test cases for $_exception commit 4f0b0f419272b8ca0a0ed0e9073b6cfeaf817343 Author: Tom Tromey Date: Fri Mar 1 13:55:32 2013 -0700 use parse_expression to find the type from the decoded type_info ----------------------------------------------------------------------- Summary of changes: gdb/break-catch-throw.c | 9 ++++ gdb/gnu-v3-abi.c | 26 +++++++---- gdb/testsuite/gdb.cp/exceptprint.cc | 65 +++++++++++++++++++++++++++ gdb/testsuite/gdb.cp/exceptprint.exp | 81 ++++++++++++++++++++++++++++++++++ 4 files changed, 171 insertions(+), 10 deletions(-) create mode 100644 gdb/testsuite/gdb.cp/exceptprint.cc create mode 100644 gdb/testsuite/gdb.cp/exceptprint.exp First 500 lines of diff: diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c index 35f8488..4c6207e 100644 --- a/gdb/break-catch-throw.c +++ b/gdb/break-catch-throw.c @@ -35,6 +35,7 @@ #include "objfiles.h" #include "cp-abi.h" #include "gdb_regex.h" +#include "cp-support.h" /* Enums for exception-handling support. */ enum exception_event_kind @@ -178,9 +179,17 @@ check_status_exception_catchpoint (struct bpstats *bs) TRY_CATCH (e, RETURN_MASK_ERROR) { struct value *typeinfo_arg; + char *canon; fetch_probe_arguments (NULL, &typeinfo_arg); typename = cplus_typename_from_type_info (typeinfo_arg); + + canon = cp_canonicalize_string (typename); + if (canon != NULL) + { + xfree (typename); + typename = canon; + } } if (e.reason < 0) diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index 58a71bc..44cfbf3 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -1177,22 +1177,28 @@ gnuv3_get_typename_from_type_info (struct value *type_info_ptr) static struct type * gnuv3_get_type_from_type_info (struct value *type_info_ptr) { - char *class_name; - struct symbol *typesym; + char *typename; struct cleanup *cleanup; + struct value *type_val; + struct expression *expr; + struct type *result; - class_name = gnuv3_get_typename_from_type_info (type_info_ptr); - cleanup = make_cleanup (xfree, class_name); + typename = gnuv3_get_typename_from_type_info (type_info_ptr); + cleanup = make_cleanup (xfree, typename); + + /* We have to parse the type name, since in general there is not a + symbol for a type. This is somewhat bogus since there may be a + mis-parse. Another approach might be to re-use the demangler's + internal form to reconstruct the type somehow. */ - typesym = lookup_symbol (class_name, NULL, VAR_DOMAIN, NULL); - if (typesym == NULL || SYMBOL_CLASS (typesym) != LOC_TYPEDEF) - typesym = lookup_symbol (class_name, NULL, STRUCT_DOMAIN, NULL); + expr = parse_expression (typename); + make_cleanup (xfree, expr); - if (typesym == NULL) - error (_("could not find type '%s'"), class_name); + type_val = evaluate_type (expr); + result = value_type (type_val); do_cleanups (cleanup); - return SYMBOL_TYPE (typesym); + return result; } /* Determine if we are currently in a C++ thunk. If so, get the address diff --git a/gdb/testsuite/gdb.cp/exceptprint.cc b/gdb/testsuite/gdb.cp/exceptprint.cc new file mode 100644 index 0000000..994b501 --- /dev/null +++ b/gdb/testsuite/gdb.cp/exceptprint.cc @@ -0,0 +1,65 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2013 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +template +void +throwit (T val) +{ + throw val; +} + +template +void +rethrowit (T val) +{ + try + { + try + { + throwit (val); + } + catch (...) + { + throw; + } + } + catch (...) + { + // Ignore. + } +} + +struct maude +{ + int mv; + + maude (int x) : mv (x) { } +}; + +int +main (int argc, char **argv) +{ + maude mm (77); + maude &mmm (mm); + + rethrowit ("hi bob"); + rethrowit (23); + rethrowit (mm); + rethrowit (mmm); + + return 0; +} diff --git a/gdb/testsuite/gdb.cp/exceptprint.exp b/gdb/testsuite/gdb.cp/exceptprint.exp new file mode 100644 index 0000000..3f993d4 --- /dev/null +++ b/gdb/testsuite/gdb.cp/exceptprint.exp @@ -0,0 +1,81 @@ +# Copyright 2013 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +standard_testfile .cc + +if {[skip_cplus_tests]} { + return -1 +} + +if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} { + return -1 +} + +if {![runto_main]} { + return -1 +} + +set ok 0 +gdb_test_multiple "info probe" "check for stap probe in libstdc++" { + -re ".*libstdcxx.*catch.*\r\n$gdb_prompt $" { + set ok 1 + } + -re "\r\n$gdb_prompt $" { + } +} +if {!$ok} { + untested "could not find libstdc++ stap probe" + return -1 +} + +proc do_continue_to_catchpoint {name} { + global gdb_prompt + + gdb_test_multiple "continue" $name { + -re "Continuing.*Catchpoint \[0-9\].*\r\n$gdb_prompt $" { + pass $name + } + } +} + +proc do_exceptprint_tests {prefix output} { + with_test_prefix $prefix { + do_continue_to_catchpoint "continue to throw" + gdb_test "print \$_exception" " = $output" \ + "print exception value at throw" + + do_continue_to_catchpoint "continue to catch" + gdb_test "print \$_exception" " = $output" \ + "print exception value at catch" + + do_continue_to_catchpoint "continue to rethrow" + gdb_test "print \$_exception" " = $output" \ + "print exception value at rethrow" + + do_continue_to_catchpoint "continue to final catch" + } +} + +gdb_test "catch catch" "Catchpoint \[0-9\]+ \\(catch\\)" \ + "catch catch" +gdb_test "catch throw" "Catchpoint \[0-9\]+ \\(throw\\)" \ + "catch throw" +gdb_test "catch rethrow" "Catchpoint \[0-9\]+ \\(rethrow\\)" \ + "catch rethrow" + +do_exceptprint_tests string "$hex \"hi bob\"" +do_exceptprint_tests int 23 +do_exceptprint_tests struct "{mv = 77}" +do_exceptprint_tests "reference to struct" "{mv = 77}" hooks/post-receive -- Repository for Project Archer.