From: Markus Metzger <markus.t.metzger@intel.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v1 2/7] gdb, btrace: disable tracing in linux_btrace_target_info dtor
Date: Tue, 10 Nov 2026 07:43:11 +0100 [thread overview]
Message-ID: <20261110064317.405487-3-markus.t.metzger@intel.com> (raw)
In-Reply-To: <20261110064317.405487-1-markus.t.metzger@intel.com>
For native targets, there is no disconnect() that would keep tracing
enabled for a later re-connect.
For Linux perf, tracing is enabled by opening the perf_event virtual file
and mapping the trace buffer. As long as tracing is enabled, GDB will
have that memory mapped and that file open.
By moving trace disabling into the target info dtor, we allow tracing to
be disabled and those resources to be released without requiring the
record-btrace target to be pushed. This will become relevant in a
subsequent patch.
---
gdb/nat/linux-btrace.c | 33 ++++++++++++++-------------------
gdb/nat/linux-btrace.h | 2 ++
2 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c
index 2e0c2eedfbb..2c1d9068827 100644
--- a/gdb/nat/linux-btrace.c
+++ b/gdb/nat/linux-btrace.c
@@ -800,23 +800,23 @@ linux_enable_btrace (ptid_t ptid, const struct btrace_config *conf)
}
}
-/* Disable BTS tracing. */
+/* See linux-btrace.h. */
-static void
-linux_disable_bts (struct linux_btrace_target_info *tinfo)
+linux_btrace_target_info::~linux_btrace_target_info ()
{
- munmap ((void *) tinfo->header, tinfo->pev.size + PAGE_SIZE);
- close (tinfo->file);
-}
-
-/* Disable Intel Processor Trace tracing. */
+ switch (conf.format)
+ {
+ case BTRACE_FORMAT_BTS:
+ munmap ((void *) header, pev.size + PAGE_SIZE);
+ close (file);
+ return;
-static void
-linux_disable_pt (struct linux_btrace_target_info *tinfo)
-{
- munmap ((void *) tinfo->pev.mem, tinfo->pev.size);
- munmap ((void *) tinfo->header, PAGE_SIZE);
- close (tinfo->file);
+ case BTRACE_FORMAT_PT:
+ munmap ((void *) pev.mem, pev.size);
+ munmap ((void *) header, PAGE_SIZE);
+ close (file);
+ return;
+ }
}
/* See linux-btrace.h. */
@@ -833,12 +833,7 @@ linux_disable_btrace (struct btrace_target_info *gtinfo)
return BTRACE_ERR_NOT_SUPPORTED;
case BTRACE_FORMAT_BTS:
- linux_disable_bts (tinfo);
- delete tinfo;
- return BTRACE_ERR_NONE;
-
case BTRACE_FORMAT_PT:
- linux_disable_pt (tinfo);
delete tinfo;
return BTRACE_ERR_NONE;
}
diff --git a/gdb/nat/linux-btrace.h b/gdb/nat/linux-btrace.h
index 3a1ca8f4801..a9271cea585 100644
--- a/gdb/nat/linux-btrace.h
+++ b/gdb/nat/linux-btrace.h
@@ -55,6 +55,8 @@ struct linux_btrace_target_info final : public btrace_target_info
: btrace_target_info (ptid)
{}
+ ~linux_btrace_target_info ();
+
#if HAVE_LINUX_PERF_EVENT_H
/* The Linux perf_event configuration for collecting the branch trace. */
struct perf_event_attr attr {};
--
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:43 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 ` [PATCH v1 1/7] gdb, btrace: add clear_btrace_resources() Markus Metzger
2026-11-10 6:43 ` Markus Metzger [this message]
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-3-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