aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2020-05-09 20:17:10 +0200
committerTom de Vries <tdevries@suse.de>2020-05-09 20:17:10 +0200
commit4343499695830fbd4bfe75058fc5570e280ba831 (patch)
tree1ce4db3abd59e1af063d4b6db504ab30068efeaf
parent2f78cffc1671188924ab3ec46a6a962894add49a (diff)
downloadgdb-4343499695830fbd4bfe75058fc5570e280ba831.zip
gdb-4343499695830fbd4bfe75058fc5570e280ba831.tar.gz
gdb-4343499695830fbd4bfe75058fc5570e280ba831.tar.bz2
[gdb] Fix catch throw regexp matching
When running test-case gdb.mi/mi-catch-cpp-exceptions.exp, we have: ... FAIL: gdb.mi/mi-catch-cpp-exceptions.exp: all with invalid regexp: run until \ breakpoint in main (unknown output after running) ... This is a regression since commit 596dc4adff "Speed up psymbol reading by removing a copy". Before that commit, we have: ... $ gdb \ -batch \ ./outputs/gdb.mi/mi-catch-cpp-exceptions/mi-catch-cpp-exceptions \ -ex "break 67" \ -ex "catch throw -r blahblah" \ -ex r Breakpoint 1 at 0x4008e5: file mi-catch-cpp-exceptions.cc, line 67. Catchpoint 2 (throw) Breakpoint 1, main () at mi-catch-cpp-exceptions.cc:67 67 return 1; /* Stop here. */ ... In other words: - we set a breakpoint somewhere in main, - we set a catchpoint with a regexp that is intended to not match any exception, and - run to the breakpoint, without the catchpoint triggering. After the commit, we have: ... $ gdb \ -batch \ ./outputs/gdb.mi/mi-catch-cpp-exceptions/mi-catch-cpp-exceptions \ -ex "break 67" \ -ex "catch throw -r blahblah" \ -ex r Breakpoint 1 at 0x4008e5: file mi-catch-cpp-exceptions.cc, line 67. Catchpoint 2 (throw) Catchpoint 2 (exception thrown), 0x00007ffff7ab037e in __cxa_throw () from \ /usr/lib64/libstdc++.so.6 ... In other words, the catchpoint triggers. This is caused by this bit of the commit: ... type_name = cplus_typename_from_type_info (typeinfo_arg); canon = cp_canonicalize_string (type_name.c_str ()); - if (!canon.empty ()) - std::swap (type_name, canon); + name = (canon == nullptr + ? canon.get () + : type_name.c_str ()); } catch (const gdb_exception_error &e) { exception_print (gdb_stderr, e); } - if (!type_name.empty ()) + if (name != nullptr) { - if (self->pattern->exec (type_name.c_str (), 0, NULL, 0) != 0) + if (self->pattern->exec (name, 0, NULL, 0) != 0) ... Before the commit, we have: - type_name == "my_exception" - canon = "" and the !type_name.empty () test succeeds, and gdb executes the self->pattern->exec call. After the commit, we have: - type_name == "my_exception" - canon == NULL - name == NULL and the name != nullptr test fails, and gdb doesn't execute the self->pattern->exec call. Fix this by inverting the condition for the calculation of name: ... - name = (canon == nullptr + name = (canon != nullptr ... Build and tested on x86_64-linux. gdb/ChangeLog: 2020-05-09 Tom de Vries <tdevries@suse.de> PR gdb/25955 * break-catch-throw.c (check_status_exception_catchpoint): Fix name calculation.
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/break-catch-throw.c2
2 files changed, 7 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1abdf9f..a132f20 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2020-05-09 Tom de Vries <tdevries@suse.de>
+
+ PR gdb/25955
+ * break-catch-throw.c (check_status_exception_catchpoint): Fix name
+ calculation.
+
2020-05-09 Tom Tromey <tom@tromey.com>
* top.c (server_command): Now bool.
diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index 59293c4..7f4a9f9 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -166,7 +166,7 @@ check_status_exception_catchpoint (struct bpstats *bs)
type_name = cplus_typename_from_type_info (typeinfo_arg);
canon = cp_canonicalize_string (type_name.c_str ());
- name = (canon == nullptr
+ name = (canon != nullptr
? canon.get ()
: type_name.c_str ());
}