From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 5C6963864A32 for ; Tue, 6 Dec 2022 13:57:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5C6963864A32 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com X-ASG-Debug-ID: 1670335052-0c856e762b1bb00001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id ZheY87fI9JjM5O81 (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Tue, 06 Dec 2022 08:57:32 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from epycamd.internal.efficios.com (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtp.ebox.ca (Postfix) with ESMTP id 56704441D64; Tue, 6 Dec 2022 08:57:32 -0500 (EST) From: Simon Marchi X-Barracuda-RBL-IP: 192.222.180.24 X-Barracuda-Effective-Source-IP: 192-222-180-24.qc.cable.ebox.net[192.222.180.24] X-Barracuda-Apparent-Source-IP: 192.222.180.24 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 04/12] gdb: add inferior_pre_detach observable Date: Tue, 6 Dec 2022 08:57:21 -0500 X-ASG-Orig-Subj: [PATCH 04/12] gdb: add inferior_pre_detach observable Message-Id: <20221206135729.3937767-5-simon.marchi@efficios.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221206135729.3937767-1-simon.marchi@efficios.com> References: <20221206135729.3937767-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1670335052 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 2102 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.102644 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-3498.3 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_SOFTFAIL,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: Add an observable notified in target_detach just before calling the detach method on the inferior's target stack. This allows observer to do some work on the inferior while it's still ptrace-attached, in the case of a native Linux inferior. Specifically, the amd-dbgapi target will need it in order to call amd_dbgapi_process_detach before the process gets ptrace-detached. Change-Id: I28b6065e251012a4c2db8a600fe13ba31671e3c9 --- gdb/observable.c | 1 + gdb/observable.h | 3 +++ gdb/target.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/gdb/observable.c b/gdb/observable.c index 0bc8697f137..7b23e038b25 100644 --- a/gdb/observable.c +++ b/gdb/observable.c @@ -62,6 +62,7 @@ DEFINE_OBSERVABLE (architecture_changed); DEFINE_OBSERVABLE (thread_ptid_changed); DEFINE_OBSERVABLE (inferior_added); DEFINE_OBSERVABLE (inferior_appeared); +DEFINE_OBSERVABLE (inferior_pre_detach); DEFINE_OBSERVABLE (inferior_exit); DEFINE_OBSERVABLE (inferior_removed); DEFINE_OBSERVABLE (memory_changed); diff --git a/gdb/observable.h b/gdb/observable.h index 1103c5c98a6..e8cc2d28a86 100644 --- a/gdb/observable.h +++ b/gdb/observable.h @@ -181,6 +181,9 @@ extern observable inferior_added; process. */ extern observable inferior_appeared; +/* Inferior INF is about to be detached. */ +extern observable inferior_pre_detach; + /* Either the inferior associated with INF has been detached from the process, or the process has exited. */ extern observable inferior_exit; diff --git a/gdb/target.c b/gdb/target.c index 1dd0f42af7d..04a4e1fd877 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -2561,6 +2561,8 @@ target_detach (inferior *inf, int from_tty) prepare_for_detach (); + gdb::observers::inferior_pre_detach.notify (inf); + /* Hold a strong reference because detaching may unpush the target. */ auto proc_target_ref = target_ops_ref::new_reference (inf->process_target ()); -- 2.38.1