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 8B3B93858D35 for ; Thu, 5 Jan 2023 20:12:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8B3B93858D35 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca 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 305KCUhk015480 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 5 Jan 2023 15:12:35 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 305KCUhk015480 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1672949555; bh=VYS8x5fQl4V12Dab1WyKvpDo2se0b31V57lcHq4oBvM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eRjwHRh7qASTPPPYeXX/ARfo1EHA767dJWzpPmQ+wewTb7GKTPaHD11esbDYQy+QX Ic5WChNQo2CBhLt3N9I3HtBTw/MjzW+nYgcI8+jiFLqDv4UtKd1sS9h9O4nqrh/6Rw ZsbB4GX0ndAlCYZuVzEz20ggMrxMEzqzN+hWPfsw= Received: from simark.localdomain (unknown [217.28.27.60]) (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 ESMTPSA id 882DF1E224; Thu, 5 Jan 2023 15:02:40 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi , Andrew Burgess Subject: [PATCH v2 4/8] gdb: add inferior_pre_detach observable Date: Thu, 5 Jan 2023 15:02:33 -0500 Message-Id: <20230105200237.987771-5-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230105200237.987771-1-simon.marchi@polymtl.ca> References: <20230105200237.987771-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 5 Jan 2023 20:12:30 +0000 X-Spam-Status: No, score=-3189.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: From: Simon Marchi 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 Approved-By: Andrew Burgess --- 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 5906e58628ee..28249a5ad015 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 aed326e43388..efd0446e1689 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 d5bfd7d0849b..d0aa8f5cc6c1 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -2528,6 +2528,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.39.0