From: Markus Metzger <markus.t.metzger@intel.com>
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 [thread overview]
Message-ID: <20261110064317.405487-2-markus.t.metzger@intel.com> (raw)
In-Reply-To: <20261110064317.405487-1-markus.t.metzger@intel.com>
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.
next prev parent reply other threads:[~2026-11-10 6:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 6:43 [PATCH v1 0/7] gdb, btrace: fix unexpected core file Markus Metzger
2026-11-10 6:43 ` Markus Metzger [this message]
2026-11-10 6:43 ` [PATCH v1 2/7] gdb, btrace: disable tracing in linux_btrace_target_info dtor Markus Metzger
2026-11-10 6:43 ` [PATCH v1 3/7] gdb, btrace: do not use btrace_teardown() for an exited thread Markus Metzger
2026-11-10 6:43 ` [PATCH v1 4/7] gdb, btrace: do not stop recording on close Markus Metzger
2026-11-10 6:43 ` [PATCH v1 5/7] gdb, btrace: remove btrace_teardown() Markus Metzger
2026-11-10 6:43 ` [PATCH v1 6/7] gdb, btrace: remove the teardown_btrace() target method Markus Metzger
2026-11-10 6:43 ` [PATCH v1 7/7] gdb, btrace: remove the disconnect() record-btrace " Markus Metzger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261110064317.405487-2-markus.t.metzger@intel.com \
--to=markus.t.metzger@intel.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox