From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id wNp1K8Cp9mPWHTsAWB0awg (envelope-from ) for ; Wed, 22 Feb 2023 18:48:16 -0500 Received: by simark.ca (Postfix, from userid 112) id AFCE11E222; Wed, 22 Feb 2023 18:48:16 -0500 (EST) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=IclWT0bm; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 528AE1E128 for ; Wed, 22 Feb 2023 18:48:16 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C65DA385B52E for ; Wed, 22 Feb 2023 23:48:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C65DA385B52E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677109694; bh=y6mozHO33GQulazhunI4nqp/a81yrjhE+BT2zXRSXJM=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=IclWT0bmVk9GEnpXfBV48ZLUpu84pHuGWziyxbJuHhTbU44qAb1584iQXTaghNw8I O/HR1tOYUIdf8anGVYvLdljrpIsZmsIGy6vEonmKhwKTBoks8vn8cNCCYf3XUF8JmP fW+xhuTR5TVX4/UE38NoMtUaGBNDEY0oUDmztvO0= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 6F5A2385800C for ; Wed, 22 Feb 2023 23:47:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6F5A2385800C Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-230-k75na_tCMd6hX0LiqQDI7w-1; Wed, 22 Feb 2023 18:47:14 -0500 X-MC-Unique: k75na_tCMd6hX0LiqQDI7w-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AAF213810B13; Wed, 22 Feb 2023 23:47:13 +0000 (UTC) Received: from f34-1.lan (unknown [10.2.16.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E59F440DF; Wed, 22 Feb 2023 23:47:13 +0000 (UTC) To: gdb-patches@sourceware.org Cc: pedro@palves.net, Kevin Buettner 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 Message-Id: <20230222234613.29662-8-kevinb@redhat.com> In-Reply-To: <20230222234613.29662-1-kevinb@redhat.com> References: <20230222234613.29662-1-kevinb@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Kevin Buettner via Gdb-patches Reply-To: Kevin Buettner Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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