[PATCH v2 5/6] Guile QUIT processing updates

Kevin Buettner kevinb@redhat.com
Sun Aug 22 23:20:02 GMT 2021


This commit contains QUIT processing updates for GDB's Guile support.
As with the Python updates, we want the extension language to be able
to handle Ctrl-C / SIGINT if it wants, but we don't want to allow it
to swallow a SIGTERM.

This commit changes gdbscm_throw_gdb_exception to check for
sync_quit_force_run, throwing a suitable exception when it
is set.  (Note that a gdbscm_gdb_exception must be converted to
a gdb_exception.)

The other changes are straightforward: catch blocks for
gdb_exception_quit are added in a few places.
---
 gdb/guile/scm-exception.c    | 4 ++++
 gdb/guile/scm-pretty-print.c | 4 ++++
 gdb/guile/scm-type.c         | 4 ++++
 gdb/guile/scm-value.c        | 4 ++++
 4 files changed, 16 insertions(+)

diff --git a/gdb/guile/scm-exception.c b/gdb/guile/scm-exception.c
index b62eaebfda6..97ee6a4e53e 100644
--- a/gdb/guile/scm-exception.c
+++ b/gdb/guile/scm-exception.c
@@ -456,6 +456,10 @@ gdbscm_scm_from_gdb_exception (const gdbscm_gdb_exception &exception)
 void
 gdbscm_throw_gdb_exception (gdbscm_gdb_exception exception)
 {
+  /* Throw to higher level for SIGTERM sent to GDB.  */
+  if (sync_quit_force_run)
+    throw_quit ("%s", exception.message);
+
   SCM scm_exception = gdbscm_scm_from_gdb_exception (exception);
   xfree (exception.message);
   gdbscm_throw (scm_exception);
diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c
index 96a3ef584c9..7ac5bff8d6c 100644
--- a/gdb/guile/scm-pretty-print.c
+++ b/gdb/guile/scm-pretty-print.c
@@ -558,6 +558,10 @@ ppscm_pretty_print_one_value (SCM printer, struct value **out_value,
 	    (_("invalid result from pretty-printer to-string"), result);
 	}
     }
+  catch (const gdb_exception_quit &except)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (unpack (except));
+    }
   catch (const gdb_exception &except)
     {
     }
diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c
index d65102b01c7..564d574beb9 100644
--- a/gdb/guile/scm-type.c
+++ b/gdb/guile/scm-type.c
@@ -111,6 +111,10 @@ tyscm_type_name (struct type *type)
       LA_PRINT_TYPE (type, "", &stb, -1, 0, &type_print_raw_options);
       return std::move (stb.string ());
     }
+  catch (const gdb_exception_quit &except)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (unpack (except));
+    }
   catch (const gdb_exception &except)
     {
       excp = gdbscm_scm_from_gdb_exception (unpack (except));
diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c
index d4d76df0411..d1962e1a562 100644
--- a/gdb/guile/scm-value.c
+++ b/gdb/guile/scm-value.c
@@ -416,6 +416,10 @@ gdbscm_value_address (SCM self)
 	    {
 	      address = vlscm_scm_from_value (value_addr (value));
 	    }
+	  catch (const gdb_exception_quit &except)
+	    {
+	      GDBSCM_HANDLE_GDB_EXCEPTION (unpack (except));
+	    }
 	  catch (const gdb_exception &except)
 	    {
 	    }
-- 
2.31.1



More information about the Gdb-patches mailing list