From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 38BDF3858C42 for ; Tue, 23 Apr 2024 13:25:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 38BDF3858C42 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 38BDF3858C42 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713878727; cv=none; b=bPtPE0sSPxgRv1uZoBHDUuQ0ODvUxHOpN/EWNxtcKiydJlZ4rt3XfanDRFdO9iVyIR6PqAxN/RqQIg+4LxgR6UkH0Ef/jVSP6lwEvYL3HZPdPGxV0sYjiv0j0SslKjz8O78QPykOfb91EKT4IvVf521SzIMxJs9Ub3BSiYZWVQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713878727; c=relaxed/simple; bh=eJ1B8HS64BywAFVtLmhHc5i/XPg/EhcpqNRHGPVpb8g=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=jp6/W3uz/CqLChZcwYbH53a1IB7yiDBGFxfCn2mPaY4cFEivmcd3pKQiQA6Dx4djxdKoAE5gUHZfFnY8oMJOJl7SAsVlaveOR9K/nOeHArM7deEAAo+1WaQdCs6XYlkOqMk3SFcAC30rePb1t8nv2YMhEt8nS4VHWhS3fS+SSvA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 43NDPJVh056466 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Apr 2024 09:25:24 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 43NDPJVh056466 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1713878724; bh=aeQgaGubUwe78QW2Eso1sCaXcx19rkYnuLBazUiGPFc=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=FWFbOF3J3HHnv0/xAXFE1242BfFdU9KSYayuGL2aDgoOHjMrgYFUh2dPoke++DOnl 0EWNE0fynkQmc3i9rZGTAD/GvY23/t8GAAg+6+R6A7DvQ4dMPcykhKw8r1rYrmhfBj XRBKXvQaGcckVlJ1D83Tg4XDuig6Mp3GW8mFeKA0= Received: from simark.localdomain (modemcable238.237-201-24.mc.videotron.ca [24.201.237.238]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 51BBF1E0AC; Tue, 23 Apr 2024 09:25:19 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 1/7] gdb: move declarations of check_quit_flag and set_quit_flag to extension.h Date: Tue, 23 Apr 2024 09:22:56 -0400 Message-ID: <20240423132517.2625632-2-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423132517.2625632-1-simon.marchi@polymtl.ca> References: <20240423132517.2625632-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Tue, 23 Apr 2024 13:25:19 +0000 X-Spam-Status: No, score=-3188.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Move them out of defs.h, to extension.h, since the implementations are in extension.c. Change-Id: Ie7321468bd7fecc684d70b09f72c3ee8ac75d8f4 --- gdb/defs.h | 19 ------------------- gdb/extension.c | 17 ++++------------- gdb/extension.h | 30 ++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/gdb/defs.h b/gdb/defs.h index 91724d30195f..6f9c0d1f781a 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -94,25 +94,6 @@ extern std::string python_libdir; /* * Search path for separate debug files. */ extern std::string debug_file_directory; -/* GDB's SIGINT handler basically sets a flag; code that might take a - long time before it gets back to the event loop, and which ought to - be interruptible, checks this flag using the QUIT macro, which, if - GDB has the terminal, throws a quit exception. - - In addition to setting a flag, the SIGINT handler also marks a - select/poll-able file descriptor as read-ready. That is used by - interruptible_select in order to support interrupting blocking I/O - in a race-free manner. - - These functions use the extension_language_ops API to allow extension - language(s) and GDB SIGINT handling to coexist seamlessly. */ - -/* * Evaluate to non-zero if the quit flag is set, zero otherwise. This - will clear the quit flag as a side effect. */ -extern int check_quit_flag (void); -/* * Set the quit flag. */ -extern void set_quit_flag (void); - /* The current quit handler (and its type). This is called from the QUIT macro. See default_quit_handler below for default behavior. Parts of GDB temporarily override this to e.g., completely suppress diff --git a/gdb/extension.c b/gdb/extension.c index f4bdcc1f6110..2d692d054315 100644 --- a/gdb/extension.c +++ b/gdb/extension.c @@ -863,16 +863,10 @@ restore_active_ext_lang (struct active_ext_lang_state *previous) xfree (previous); } -/* Set the quit flag. - This only sets the flag in the currently active extension language. - If the currently active extension language does not have cooperative - SIGINT handling, then GDB's global flag is set, and it is up to the - extension language to call check_quit_flag. The extension language - is free to install its own SIGINT handler, but we still need to handle - the transition. */ +/* See extension.h. */ void -set_quit_flag (void) +set_quit_flag () { #if CXX_STD_THREAD std::lock_guard guard (ext_lang_mutex); @@ -894,13 +888,10 @@ set_quit_flag (void) } } -/* Return true if the quit flag has been set, false otherwise. - Note: The flag is cleared as a side-effect. - The flag is checked in all extension languages that support cooperative - SIGINT handling, not just the current one. This simplifies transitions. */ +/* See extension.h. */ int -check_quit_flag (void) +check_quit_flag () { #if CXX_STD_THREAD std::lock_guard guard (ext_lang_mutex); diff --git a/gdb/extension.h b/gdb/extension.h index 9ba1299f95e1..94a500d74586 100644 --- a/gdb/extension.h +++ b/gdb/extension.h @@ -429,4 +429,34 @@ class scoped_disable_cooperative_sigint_handling bool m_prev_cooperative_sigint_handling_disabled; }; +/* GDB's SIGINT handler basically sets a flag; code that might take a + long time before it gets back to the event loop, and which ought to + be interruptible, checks this flag using the QUIT macro, which, if + GDB has the terminal, throws a quit exception. + + In addition to setting a flag, the SIGINT handler also marks a + select/poll-able file descriptor as read-ready. That is used by + interruptible_select in order to support interrupting blocking I/O + in a race-free manner. + + These functions use the extension_language_ops API to allow extension + language(s) and GDB SIGINT handling to coexist seamlessly. */ + +/* Return true if the quit flag has been set, false otherwise. + Note: The flag is cleared as a side-effect. + The flag is checked in all extension languages that support cooperative + SIGINT handling, not just the current one. This simplifies transitions. */ + +extern int check_quit_flag (); + +/* Set the quit flag. + This only sets the flag in the currently active extension language. + If the currently active extension language does not have cooperative + SIGINT handling, then GDB's global flag is set, and it is up to the + extension language to call check_quit_flag. The extension language + is free to install its own SIGINT handler, but we still need to handle + the transition. */ + +extern void set_quit_flag (); + #endif /* EXTENSION_H */ -- 2.44.0