summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-09-15 00:07:32 -0600
committerTom Tromey <tom@tromey.com>2018-09-23 23:15:12 -0600
commit39a24317ac65837663ce1e1b0adcf880758ddc8e (patch)
treed60747875bd25c65c064c2fcfdd14370ecbcec2f
parentf5769a2c696affc3ae1274e2329777d7d4d7e8be (diff)
downloadbinutils-gdb-39a24317ac65837663ce1e1b0adcf880758ddc8e.tar.gz
Report Python errors coming from gdb.post_event
PR python/14062 points out that errors coming from the gdb.post_event callback are not reported. This can make it hard to understand why your Python code in gdb isn't working. Because users have control over whether exceptions are printed at all, it seems good to simply have post_event report errors in the usual way. 2018-09-23 Tom Tromey <tom@tromey.com> PR python/14062: * python/python.c (gdbpy_run_events): Do not ignore exceptions. gdb/testsuite/ChangeLog 2018-09-23 Tom Tromey <tom@tromey.com> PR python/14062: * gdb.python/python.exp: Add test for post_event error.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/python/python.c3
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.python/python.exp13
4 files changed, 23 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a03163ff7dd..15ae55a1841 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2018-09-23 Tom Tromey <tom@tromey.com>
+ PR python/14062:
+ * python/python.c (gdbpy_run_events): Do not ignore exceptions.
+
+2018-09-23 Tom Tromey <tom@tromey.com>
+
PR python/18170:
* python/py-value.c (valpy_int): Allow conversion from pointer
type.
diff --git a/gdb/python/python.c b/gdb/python/python.c
index c16305b900f..8fbce784695 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -987,10 +987,9 @@ gdbpy_run_events (int error, gdb_client_data client_data)
if (gdbpy_event_list == NULL)
gdbpy_event_list_end = &gdbpy_event_list;
- /* Ignore errors. */
gdbpy_ref<> call_result (PyObject_CallObject (item->event, NULL));
if (call_result == NULL)
- PyErr_Clear ();
+ gdbpy_print_stack ();
Py_DECREF (item->event);
xfree (item);
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index c04f09a352e..131940bc184 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2018-09-23 Tom Tromey <tom@tromey.com>
+ PR python/14062:
+ * gdb.python/python.exp: Add test for post_event error.
+
+2018-09-23 Tom Tromey <tom@tromey.com>
+
PR python/18170:
* gdb.python/py-value.exp (test_value_numeric_ops): Add tests to
convert pointers to int and long.
diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index a37113c17c7..0723507af3e 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -134,7 +134,18 @@ gdb_py_test_multiple "post event insertion" \
"end" ""
gdb_test "python print (someVal)" "1" "test post event execution"
-gdb_test "python gdb.post_event(str(1))" "RuntimeError: Posted event is not callable.*" "test non callable class"
+gdb_test "python gdb.post_event(str(1))" "RuntimeError: Posted event is not callable.*" \
+ "test non callable class"
+
+send_gdb "python gdb.post_event(lambda: invalid())\n"
+gdb_expect {
+ -re "name 'invalid' is not defined" {
+ pass "test post_event error on receipt"
+ }
+ default {
+ fail "test post_event error on receipt"
+ }
+}
# Test (no) pagination of the executed command.
gdb_test "show height" {Number of lines gdb thinks are in a page is unlimited\.}