aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Buettner <kevinb@redhat.com>2023-02-27 16:11:37 -0700
committerKevin Buettner <kevinb@redhat.com>2023-02-27 16:20:39 -0700
commitb940a061c0d549dbe981463414da87cb84a8a9bb (patch)
tree53926eb45e331288f2a49431b5e001339221a474
parentb1ffd1124a8c5170a9e06b867a886b1138d28514 (diff)
downloadbinutils-b940a061c0d549dbe981463414da87cb84a8a9bb.zip
binutils-b940a061c0d549dbe981463414da87cb84a8a9bb.tar.gz
binutils-b940a061c0d549dbe981463414da87cb84a8a9bb.tar.bz2
Python QUIT processing updates
See the previous patches in this series for the motivation behind these changes. This commit contains updates to Python's QUIT handling. Ideally, we'd like to throw gdb_exception_forced_quit through the extension language; I made an attempt to do this for gdb_exception_quit in an earlier version of this patch, but Pedro pointed out that it is (almost certainly) not safe to do so. Still, we definitely don't want to swallow the exception representing a SIGTERM for GDB, nor do we want to force modules written in the extension language to have to explicitly handle this case. Since the idea is for GDB to cleanup and quit for this exception, we'll simply call quit_force() just as if the gdb_exception_forced_quit propagation had managed to make it back to the top level. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=26761 Tested-by: Tom de Vries <tdevries@suse.de> Approved-By: Pedro Alves <pedro@palves.net>
-rw-r--r--gdb/python/py-finishbreakpoint.c5
-rw-r--r--gdb/python/py-gdb-readline.c4
-rw-r--r--gdb/python/py-symbol.c5
-rw-r--r--gdb/python/py-utils.c3
-rw-r--r--gdb/python/py-value.c5
5 files changed, 22 insertions, 0 deletions
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
index 3b682f5..159164e 100644
--- a/gdb/python/py-finishbreakpoint.c
+++ b/gdb/python/py-finishbreakpoint.c
@@ -20,6 +20,7 @@
#include "defs.h"
+#include "top.h" /* For quit_force(). */
#include "python-internal.h"
#include "breakpoint.h"
#include "frame.h"
@@ -275,6 +276,10 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
}
}
}
+ catch (const gdb_exception_forced_quit &except)
+ {
+ quit_force (NULL, 0);
+ }
catch (const gdb_exception &except)
{
/* Just swallow. Either the return type or the function value
diff --git a/gdb/python/py-gdb-readline.c b/gdb/python/py-gdb-readline.c
index ea0f78c..b9294ad 100644
--- a/gdb/python/py-gdb-readline.c
+++ b/gdb/python/py-gdb-readline.c
@@ -46,6 +46,10 @@ gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout,
p = command_line_input (buffer, prompt, "python");
}
/* Handle errors by raising Python exceptions. */
+ catch (const gdb_exception_forced_quit &e)
+ {
+ quit_force (NULL, 0);
+ }
catch (const gdb_exception &except)
{
/* Detect user interrupt (Ctrl-C). */
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index e6497ed..066a27f 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -18,6 +18,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
+#include "top.h" /* For force_quit (). */
#include "block.h"
#include "frame.h"
#include "symtab.h"
@@ -517,6 +518,10 @@ gdbpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw)
= get_selected_frame (_("No frame selected."));
block = get_frame_block (selected_frame, NULL);
}
+ catch (const gdb_exception_forced_quit &e)
+ {
+ quit_force (NULL, 0);
+ }
catch (const gdb_exception &except)
{
/* Nothing. */
diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c
index 624b90a..d5b07a8 100644
--- a/gdb/python/py-utils.c
+++ b/gdb/python/py-utils.c
@@ -18,6 +18,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
+#include "top.h" /* For quit_force (). */
#include "charset.h"
#include "value.h"
#include "python-internal.h"
@@ -219,6 +220,8 @@ gdbpy_convert_exception (const struct gdb_exception &exception)
if (exception.reason == RETURN_QUIT)
exc_class = PyExc_KeyboardInterrupt;
+ else if (exception.reason == RETURN_FORCED_QUIT)
+ quit_force (NULL, 0);
else if (exception.error == MEMORY_ERROR)
exc_class = gdbpy_gdb_memory_error;
else
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index 9441a43..65384c7 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -18,6 +18,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
+#include "top.h" /* For quit_force (). */
#include "charset.h"
#include "value.h"
#include "language.h"
@@ -371,6 +372,10 @@ valpy_get_address (PyObject *self, void *closure)
res_val = value_addr (val_obj->value);
val_obj->address = value_to_value_object (res_val);
}
+ catch (const gdb_exception_forced_quit &except)
+ {
+ quit_force (NULL, 0);
+ }
catch (const gdb_exception &except)
{
val_obj->address = Py_None;