From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1028) id 4E1E03850855; Mon, 27 Feb 2023 23:21:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E1E03850855 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677540113; bh=J4oD2ORAYemHleaDtCl47PGN7RmEYCLvf5NQzJizyos=; h=From:To:Subject:Date:From; b=QUyDkA/64kFjCKNqGhzycYbc+aHUd6aUMvCgvrpcMlAiPaj0E44Q/GhJAc0xbwDBs Ptj+6dKgWLDY28oeVACqCBWJXNxDN3Yl9jgOuxr8D7m6z6bkA8x525eTi3+CpkP9zY ERYUi4Ahcc006UN+hRv86Ndjhf9Coz9BPXHjCpyA= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Kevin Buettner To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Introduce set_force_quit_flag and change type of sync_quit_force_run X-Act-Checkin: binutils-gdb X-Git-Author: Kevin Buettner X-Git-Refname: refs/heads/master X-Git-Oldrev: 363429d593eb1eb17f3f2cf6c247f60fadf660d9 X-Git-Newrev: 80d03917838c16ee0da53a4a8642d5df3bee724e Message-Id: <20230227232153.4E1E03850855@sourceware.org> Date: Mon, 27 Feb 2023 23:21:53 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D80d03917838c= 16ee0da53a4a8642d5df3bee724e commit 80d03917838c16ee0da53a4a8642d5df3bee724e Author: Kevin Buettner Date: Mon Feb 27 16:11:37 2023 -0700 Introduce set_force_quit_flag and change type of sync_quit_force_run =20 At the moment, handle_sigterm() in event-top.c does the following: =20 sync_quit_force_run =3D 1; set_quit_flag (); =20 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. =20 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. =20 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D26761 Approved-By: Pedro Alves Diff: --- 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 aba33b82e6b..90748c586f4 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -171,7 +171,10 @@ extern quit_handler_ftype *quit_handler; extern void default_quit_handler (void); =20 /* 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 (); =20 extern void quit (void); =20 diff --git a/gdb/event-top.c b/gdb/event-top.c index 36863292696..53ddd515be7 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -1209,7 +1209,15 @@ async_sigterm_handler (gdb_client_data arg) } =20 /* 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 =3D true; + set_quit_flag (); +} =20 /* Quit GDB if SIGTERM is received. GDB would quit anyway, but this way it will clean up properly. */ @@ -1218,8 +1226,7 @@ handle_sigterm (int sig) { signal (sig, handle_sigterm); =20 - sync_quit_force_run =3D 1; - set_quit_flag (); + set_force_quit_flag (); =20 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 =3D 0; + sync_quit_force_run =3D false; throw_forced_quit ("SIGTERM"); }