From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id KcLIOGO98mq6cD0AWB0awg (envelope-from ) for ; Tue, 10 Nov 2026 01:44:51 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=jwqoVRo+; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E0B7D1E0DC; Tue, 10 Nov 2026 01:44:51 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (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 ESMTPS id DF85E1E043 for ; Tue, 10 Nov 2026 01:44:50 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C8A444BA23DF for ; Tue, 10 Nov 2026 06:44:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C8A444BA23DF Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=jwqoVRo+ Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) by sourceware.org (Postfix) with ESMTPS id 5D1A44BA2E18 for ; Tue, 10 Nov 2026 06:43:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5D1A44BA2E18 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5D1A44BA2E18 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794293003; cv=none; b=yGU2YyRPG3iS4J/5Qwj/NeTjtuFSShtIX1N4c51OhJFNTIZw6phqvbW9YCs+M4AJI6FzICICWCajU8gNqW50E0c+gS7KpYQu+4j/D7zR4h1l/IAmp89yNvhNaT0eiqWSJNQifsLgX/EoKZ5L7CFATHIo3vTm/y+Zxxnp0/n/wno= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794293003; c=relaxed/simple; bh=TMgTE+AIlJ9MG5+fpQbwft5q8xLs9qYymQwN7NDElfc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=fWsuactvpePAtAyqBD+KhlSChHp8G7IUEzbFFqLkgenc652Cwc9zMqhpuDC/7qHT1+lHCuqxxbT2rWTFOAQX4oZNAtXkE8FNI1DjYJOCk4xoMqxH6bo0FNmNgoWAaee3mfnecPUlKiTclJiHaDeV7reaCQ36iuUD9Uf3Yzfp19A= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=jwqoVRo+ DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5D1A44BA2E18 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1794293003; x=1825829003; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=TMgTE+AIlJ9MG5+fpQbwft5q8xLs9qYymQwN7NDElfc=; b=jwqoVRo+JwG4vslvGrjvrJALWiqizEbMXwiAEk2Ytt7Rv18jRWKDmLWb CdFt5whtxyxm9YQ4T8fGysnvILSSTRY8pRqKnZc2IqN+teFjQ83VumJae q8aTB/+oyaJXESUjOXaw0c0DkPry+azsL2E1t5J53syLxNpzVzsbmCl4P k0XMWx3DLxQD35syJrCQsELEaYWDOvSNIQt5c+wxA/TRkzN2Q8DxwcCKd FiEqpu0Isz6Gg+7qtegV5yVYN1OmaLAineeAxht7QseoSapb0XqCyJqS2 8ZfBWZr67JfUo6xwUEzPIHAkvQNuLu/rSTn2pwQrj1r5owt5cqsGagg+G Q==; X-CSE-ConnectionGUID: pyHyearqQVewqGwLyXUqqQ== X-CSE-MsgGUID: CAwSqAoZT1i7AHTJadRXPw== X-IronPort-AV: E=McAfee;i="6800,10657,11961"; a="2921391" X-IronPort-AV: E=Sophos;i="6.27,205,1787036400"; d="scan'208";a="2921391" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2026 22:43:22 -0800 X-CSE-ConnectionGUID: 7NhjHn6ZQNSqVLpxSQtWmQ== X-CSE-MsgGUID: 9s5MT7yPS9GRLCbF6Az4hQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,205,1787036400"; d="scan'208";a="8649317" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2026 22:43:22 -0800 From: Markus Metzger To: gdb-patches@sourceware.org Subject: [PATCH v1 1/7] gdb, btrace: add clear_btrace_resources() Date: Tue, 10 Nov 2026 07:43:10 +0100 Message-ID: <20261110064317.405487-2-markus.t.metzger@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261110064317.405487-1-markus.t.metzger@intel.com> References: <20261110064317.405487-1-markus.t.metzger@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Add a function to clear GDB resources associated with branch tracing a given thread. This will be used in subsequent patches and eventually replace btrace_teardown() and the teardown_btrace() target method. --- gdb/btrace.c | 18 ++++++++++++++++++ gdb/btrace.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/gdb/btrace.c b/gdb/btrace.c index f5f2d6da972..db8177ffecc 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -2103,6 +2103,24 @@ btrace_teardown (struct thread_info *tp) btrace_clear (tp); } +/* See btrace.h. */ + +void +clear_btrace_resources (struct thread_info *tp) +{ + struct btrace_thread_info &btp = tp->btrace; + if (btp.target == nullptr) + return; + + DEBUG ("clear resources of thread %s (%s)", print_thread_id (tp), + tp->ptid.to_string ().c_str ()); + + delete btp.target; + btp.target = nullptr; + + btrace_clear (tp); +} + /* Stitch branch trace in BTS format. */ static int diff --git a/gdb/btrace.h b/gdb/btrace.h index 642871b0471..c93ec0f07c8 100644 --- a/gdb/btrace.h +++ b/gdb/btrace.h @@ -414,6 +414,9 @@ extern void btrace_disable (struct thread_info *); target_teardown_btrace instead of target_disable_btrace. */ extern void btrace_teardown (struct thread_info *); +/* Clear branch tracing resources for a thread. */ +extern void clear_btrace_resources (struct thread_info *); + /* Return a human readable error string for the given ERRCODE in FORMAT. The pointer will never be NULL and must not be freed. */ -- 2.53.0 ________________________________________ Intel Deutschland GmbH Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany Tel: +49 (89) 99143-0 www.intel.de Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran Sitaraman Chairperson of the Supervisory Board: Sonja Pierer Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB 186928 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.