aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-09-18 06:27:09 -0600
committerTom Tromey <tom@tromey.com>2018-10-06 22:17:45 -0600
commit2a8be20359dba9cc684fd3ffa222d985399f3b18 (patch)
treecfd6e84fca0e481698a7f8ab984ae48beaac7b89
parent2fb009bbd1d65a837e5032e744ba30b49c7f472a (diff)
downloadgdb-2a8be20359dba9cc684fd3ffa222d985399f3b18.zip
gdb-2a8be20359dba9cc684fd3ffa222d985399f3b18.tar.gz
gdb-2a8be20359dba9cc684fd3ffa222d985399f3b18.tar.bz2
Fix Python gdb.Breakpoint.location crash
I noticed today that gdb.Breakpoint.location will crash when applied to a catchpoint made with "catch throw". The bug is that "catch throw" makes a breakpoint that is of type bp_breakpoint, but which does not have a location. Regression tested on x86-64 Fedora 28. gdb/ChangeLog 2018-10-06 Tom Tromey <tom@tromey.com> * python/py-breakpoint.c (bppy_get_location): Handle a bp_breakpoint without a location. gdb/testsuite/ChangeLog 2018-10-06 Tom Tromey <tom@tromey.com> * gdb.python/py-breakpoint.exp (check_last_event): Check location of a "throw" catchpoint.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/python/py-breakpoint.c7
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.python/py-breakpoint.exp5
4 files changed, 21 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 7196472..e6f821d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2018-10-06 Tom Tromey <tom@tromey.com>
+ * python/py-breakpoint.c (bppy_get_location): Handle a
+ bp_breakpoint without a location.
+
+2018-10-06 Tom Tromey <tom@tromey.com>
+
* python/lib/gdb/function/strfns.py (_MemEq, _StrLen, _StrEq)
(_RegEx): Reformat help text.
* python/lib/gdb/function/caller_is.py (CallerIs, CallerMatches)
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index e1db674..94afd50 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -391,7 +391,12 @@ bppy_get_location (PyObject *self, void *closure)
if (obj->bp->type != bp_breakpoint)
Py_RETURN_NONE;
- str = event_location_to_string (obj->bp->location.get ());
+ struct event_location *location = obj->bp->location.get ();
+ /* "catch throw" makes a breakpoint of type bp_breakpoint that does
+ not have a location. */
+ if (location == nullptr)
+ Py_RETURN_NONE;
+ str = event_location_to_string (location);
if (! str)
str = "";
return host_string_to_python_string (str);
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index c78c09a..fc37967 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-10-06 Tom Tromey <tom@tromey.com>
+
+ * gdb.python/py-breakpoint.exp (check_last_event): Check location
+ of a "throw" catchpoint.
+
2018-10-06 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.base/info-proc.exp: Update string expected from "help info
diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp
index 3ce0ea1..7d5fbcc 100644
--- a/gdb/testsuite/gdb.python/py-breakpoint.exp
+++ b/gdb/testsuite/gdb.python/py-breakpoint.exp
@@ -616,6 +616,11 @@ proc_with_prefix test_bkpt_explicit_loc {} {
gdb_test "python bp1 = gdb.Breakpoint (function=\"blah\")" \
"Function \"blah\" not defined.*" \
"set invalid explicit breakpoint by missing function"
+
+ delete_breakpoints
+ gdb_test "catch throw" "Catchpoint .* \\(throw\\)"
+ gdb_test "python print (gdb.breakpoints()\[0\].location)" None \
+ "Examine location of catchpoint"
}
proc_with_prefix test_bkpt_qualified {} {