Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kevin Buettner via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Cc: pedro@palves.net, Kevin Buettner <kevinb@redhat.com>
Subject: [PATCH v5 7/8] Introduce set_force_quit_flag and change type of sync_quit_force_run
Date: Wed, 22 Feb 2023 16:46:12 -0700	[thread overview]
Message-ID: <20230222234613.29662-8-kevinb@redhat.com> (raw)
In-Reply-To: <20230222234613.29662-1-kevinb@redhat.com>

At the moment, handle_sigterm() in event-top.c does the following:

  sync_quit_force_run = 1;
  set_quit_flag ();

This was used several more times in a later patch in this series, so
I'm introducing (at Pedro's suggestion) a new function named
'set_force_quit_flag'.  It simply sets sync_quit_force_run and also
calls set_quit_flag().  I've revised the later patch to call
set_force_quit_flag instead.

I noticed that sync_quit_force_run is declared as an int but is being
used as a bool, so I also changed its type to bool in this commit.
---
 gdb/defs.h      |  5 ++++-
 gdb/event-top.c | 13 ++++++++++---
 gdb/utils.c     |  2 +-
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/gdb/defs.h b/gdb/defs.h
index f4fba9acf30..e7c9a39dd89 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -173,7 +173,10 @@ extern quit_handler_ftype *quit_handler;
 extern void default_quit_handler (void);
 
 /* Flag that function quit should call quit_force.  */
-extern volatile int sync_quit_force_run;
+extern volatile bool sync_quit_force_run;
+
+/* Set sync_quit_force_run and also call set_quit_flag().  */
+extern void set_force_quit_flag ();
 
 extern void quit (void);
 
diff --git a/gdb/event-top.c b/gdb/event-top.c
index 563050a4081..eed0ec0eb44 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -1217,7 +1217,15 @@ async_sigterm_handler (gdb_client_data arg)
 }
 
 /* See defs.h.  */
-volatile int sync_quit_force_run;
+volatile bool sync_quit_force_run;
+
+/* See defs.h.  */
+void
+set_force_quit_flag ()
+{
+  sync_quit_force_run = true;
+  set_quit_flag ();
+}
 
 /* Quit GDB if SIGTERM is received.
    GDB would quit anyway, but this way it will clean up properly.  */
@@ -1226,8 +1234,7 @@ handle_sigterm (int sig)
 {
   signal (sig, handle_sigterm);
 
-  sync_quit_force_run = 1;
-  set_quit_flag ();
+  set_force_quit_flag ();
 
   mark_async_signal_handler (async_sigterm_token);
 }
diff --git a/gdb/utils.c b/gdb/utils.c
index 08cc41b4ef8..0138c8e9fb6 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -641,7 +641,7 @@ quit (void)
 {
   if (sync_quit_force_run)
     {
-      sync_quit_force_run = 0;
+      sync_quit_force_run = false;
       throw_forced_quit ("SIGTERM");
     }
 
-- 
2.34.3


  parent reply	other threads:[~2023-02-22 23:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-22 23:46 [PATCH v5 0/8] Fix gdb.base/gdb-sigterm.exp failure/error Kevin Buettner via Gdb-patches
2023-02-22 23:46 ` [PATCH v5 1/8] Introduce gdb_exception_forced_quit Kevin Buettner via Gdb-patches
2023-02-22 23:46 ` [PATCH v5 2/8] Handle gdb SIGTERM by throwing / catching gdb_exception_force_quit Kevin Buettner via Gdb-patches
2023-03-02 20:14   ` Simon Marchi via Gdb-patches
2023-02-22 23:46 ` [PATCH v5 3/8] Catch gdb_exception_error instead of gdb_exception (in many places) Kevin Buettner via Gdb-patches
2023-02-22 23:46 ` [PATCH v5 4/8] Python QUIT processing updates Kevin Buettner via Gdb-patches
2023-02-22 23:46 ` [PATCH v5 5/8] Guile " Kevin Buettner via Gdb-patches
2023-02-22 23:46 ` [PATCH v5 6/8] QUIT processing w/ explicit throw for gdb_exception_forced_quit Kevin Buettner via Gdb-patches
2023-02-22 23:46 ` Kevin Buettner via Gdb-patches [this message]
2023-02-22 23:46 ` [PATCH v5 8/8] Forced quit cases handled by resetting sync_quit_force_run Kevin Buettner via Gdb-patches
2023-02-23 13:01 ` [PATCH v5 0/8] Fix gdb.base/gdb-sigterm.exp failure/error Pedro Alves
2023-02-27 23:22   ` Kevin Buettner via Gdb-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230222234613.29662-8-kevinb@redhat.com \
    --to=gdb-patches@sourceware.org \
    --cc=kevinb@redhat.com \
    --cc=pedro@palves.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox