* [PATCH v1 0/7] gdb, btrace: fix unexpected core file
@ 2026-11-10 6:43 Markus Metzger
2026-11-10 6:43 ` [PATCH v1 1/7] gdb, btrace: add clear_btrace_resources() Markus Metzger
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Markus Metzger @ 2026-11-10 6:43 UTC (permalink / raw)
To: gdb-patches
When running gdb.btrace/multi-inferior.exp with extended-remote target, an
unexpected core file appears in gdb.sum but not in gdb.log, due to an
uncaught exception thrown by the dummy target when the remote connection
is closed.
The remote target iterates over all inferiors, unpushes all targets at or
above the process stratum, then exits the inferior and all threads within
it. This flow calls the teardown_btrace() target method, which ends up in
the dummy target because the record-btrace target was unpushed.
Unpushing the record-btrace target calls its close() target method when
the last reference to the target is dropped. This flow also calls the
teardown_btrace() target method for all non-exited threads in the current
inferior. This time, however, we end up in the correct method because the
record-btrace target has not been unpushed, yet.
So, if there is only a single inferior, the close() target method handles
the cleanup. But if there are more inferiors, it doesn't.
This patch series changes the cleanup flow, thereby also simplifying it.
Markus Metzger (7):
gdb, btrace: add clear_btrace_resources()
gdb, btrace: disable tracing in linux_btrace_target_info dtor
gdb, btrace: do not use btrace_teardown() for an exited thread
gdb, btrace: do not stop recording on close
gdb, btrace: remove btrace_teardown()
gdb, btrace: remove the teardown_btrace() target method
gdb, btrace: remove the disconnect() record-btrace target method
gdb/btrace.c | 13 ++++++-------
gdb/btrace.h | 6 ++----
gdb/nat/linux-btrace.c | 33 ++++++++++++++-------------------
gdb/nat/linux-btrace.h | 2 ++
gdb/record-btrace.c | 22 ----------------------
gdb/remote.c | 11 -----------
gdb/target-delegates-gen.c | 24 ------------------------
gdb/target.c | 8 --------
gdb/target.h | 10 ----------
gdb/thread.c | 2 +-
gdb/x86-linux-nat.c | 9 ---------
gdb/x86-linux-nat.h | 1 -
12 files changed, 25 insertions(+), 116 deletions(-)
base-commit: 892d98146139de38662c1f5b7d48fc3a606ec3f6
--
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v1 1/7] gdb, btrace: add clear_btrace_resources()
2026-11-10 6:43 [PATCH v1 0/7] gdb, btrace: fix unexpected core file Markus Metzger
@ 2026-11-10 6:43 ` Markus Metzger
2026-11-10 6:43 ` [PATCH v1 2/7] gdb, btrace: disable tracing in linux_btrace_target_info dtor Markus Metzger
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Markus Metzger @ 2026-11-10 6:43 UTC (permalink / raw)
To: gdb-patches
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v1 2/7] gdb, btrace: disable tracing in linux_btrace_target_info dtor
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
2026-11-10 6:43 ` [PATCH v1 3/7] gdb, btrace: do not use btrace_teardown() for an exited thread Markus Metzger
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Markus Metzger @ 2026-11-10 6:43 UTC (permalink / raw)
To: gdb-patches
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v1 3/7] gdb, btrace: do not use btrace_teardown() for an exited thread
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 ` [PATCH v1 2/7] gdb, btrace: disable tracing in linux_btrace_target_info dtor Markus Metzger
@ 2026-11-10 6:43 ` Markus Metzger
2026-11-10 6:43 ` [PATCH v1 4/7] gdb, btrace: do not stop recording on close Markus Metzger
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Markus Metzger @ 2026-11-10 6:43 UTC (permalink / raw)
To: gdb-patches
In clear_thread_inferior_resources(), which itself is called from
set_thread_exited(), we call btrace_teardown() to stop recording but
ignore errors.
In the extended-remote case, when the remote target exited and the
connection closed, we first unpush all targets, then exit all inferiors,
which exits all threads:
#0 clear_thread_inferior_resources (tp=0x555558c01d60)
at ...gdb/thread.c:183
#1 0x00005555567f4ad2 in set_thread_exited (tp=0x555558c01d60, exit_code=std::optional [no contained value],
silent=true) at ...gdb/thread.c:243
#2 0x00005555562d7364 in operator() (__closure=0x7fffffffbb37, thr=0x555558c01d60)
at ...gdb/inferior.c:260
#3 0x00005555562db0e9 in intrusive_list<thread_info, intrusive_base_node<thread_info> >::clear_and_dispose<inferior::clear_thread_list()::<lambda(thread_info*)> >(struct {...}) (this=0x55555893a7b8, disposer=...)
at ...gdb/../gdbsupport/intrusive_list.h:529
#4 0x00005555562d7402 in inferior::clear_thread_list (this=0x55555893a7a0)
at ...gdb/inferior.c:256
#5 0x00005555562d7593 in exit_inferior (inf=0x55555893a7a0)
at ...gdb/inferior.c:313
#6 0x00005555567d2858 in generic_mourn_inferior ()
at ...gdb/target.c:3669
#7 0x00005555565ee529 in remote_unpush_target (target=0x555558c1ebc0)
at ...gdb/remote.c:6532
By the time we call target_teardown_btrace() from btrace_teardown(), the
record-btrace target has already been unpushed from that inferior, but it
may not have been closed, yet, if there is more than one inferior. We end
up in the dummy target that throws an error. That error is never caught
and GDB crashes.
This is exposed by gdb.btrace/multi-inferior.exp. For some reason, this
happens after the test completed, so the resulting coredump is shown in
gdb.sum but not in gdb.log, which is why I missed it for so long.
Call the new clear_btrace_resources() instead, which deletes the btrace
target info but does not call any target methods.
---
gdb/thread.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/thread.c b/gdb/thread.c
index e2b89afc118..052d499bf7a 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -188,7 +188,7 @@ clear_thread_inferior_resources (struct thread_info *tp)
bpstat_clear (&tp->control.stop_bpstat);
- btrace_teardown (tp);
+ clear_btrace_resources (tp);
thread_cancel_execution_command (tp);
--
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v1 4/7] gdb, btrace: do not stop recording on close
2026-11-10 6:43 [PATCH v1 0/7] gdb, btrace: fix unexpected core file Markus Metzger
` (2 preceding siblings ...)
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 ` Markus Metzger
2026-11-10 6:43 ` [PATCH v1 5/7] gdb, btrace: remove btrace_teardown() Markus Metzger
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Markus Metzger @ 2026-11-10 6:43 UTC (permalink / raw)
To: gdb-patches
When the record-btrace target is closed, it has already been removed from
all inferior target stacks and target_teardown_btrace() would end up in
the dummy target and throw an exception (see parent patch).
Recording has already been stopped before unpushing the record-btrace
target except for disconnect(), where we call clear_btrace_resources() to
release branch tracing resources for all threads that are exited when
unpushing the remote target.
---
gdb/record-btrace.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index dae243ee2db..cbebb3dbee2 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -453,11 +453,6 @@ record_btrace_target::close ()
/* Make sure automatic recording gets disabled even if we did not stop
recording before closing the record-btrace target. */
record_btrace_auto_disable ();
-
- /* We should have already stopped recording.
- Tear down btrace in case we have not. */
- for (thread_info &tp : current_inferior ()->non_exited_threads ())
- btrace_teardown (&tp);
}
/* The async method of target record-btrace. */
--
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v1 5/7] gdb, btrace: remove btrace_teardown()
2026-11-10 6:43 [PATCH v1 0/7] gdb, btrace: fix unexpected core file Markus Metzger
` (3 preceding siblings ...)
2026-11-10 6:43 ` [PATCH v1 4/7] gdb, btrace: do not stop recording on close Markus Metzger
@ 2026-11-10 6:43 ` 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
6 siblings, 0 replies; 8+ messages in thread
From: Markus Metzger @ 2026-11-10 6:43 UTC (permalink / raw)
To: gdb-patches
The function is no longer used. Remove it.
---
gdb/btrace.c | 19 -------------------
gdb/btrace.h | 5 -----
2 files changed, 24 deletions(-)
diff --git a/gdb/btrace.c b/gdb/btrace.c
index db8177ffecc..1ac25444a03 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -2086,25 +2086,6 @@ btrace_disable (struct thread_info *tp)
/* See btrace.h. */
-void
-btrace_teardown (struct thread_info *tp)
-{
- struct btrace_thread_info *btp = &tp->btrace;
-
- if (btp->target == NULL)
- return;
-
- DEBUG ("teardown thread %s (%s)", print_thread_id (tp),
- tp->ptid.to_string ().c_str ());
-
- target_teardown_btrace (btp->target);
- btp->target = NULL;
-
- btrace_clear (tp);
-}
-
-/* See btrace.h. */
-
void
clear_btrace_resources (struct thread_info *tp)
{
diff --git a/gdb/btrace.h b/gdb/btrace.h
index c93ec0f07c8..8fc51ab86a6 100644
--- a/gdb/btrace.h
+++ b/gdb/btrace.h
@@ -409,11 +409,6 @@ extern const struct btrace_config *
This will also delete the current branch trace data. */
extern void btrace_disable (struct thread_info *);
-/* Disable branch tracing for a thread during teardown.
- This is similar to btrace_disable, except that it will use
- 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 *);
--
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v1 6/7] gdb, btrace: remove the teardown_btrace() target method
2026-11-10 6:43 [PATCH v1 0/7] gdb, btrace: fix unexpected core file Markus Metzger
` (4 preceding siblings ...)
2026-11-10 6:43 ` [PATCH v1 5/7] gdb, btrace: remove btrace_teardown() Markus Metzger
@ 2026-11-10 6:43 ` Markus Metzger
2026-11-10 6:43 ` [PATCH v1 7/7] gdb, btrace: remove the disconnect() record-btrace " Markus Metzger
6 siblings, 0 replies; 8+ messages in thread
From: Markus Metzger @ 2026-11-10 6:43 UTC (permalink / raw)
To: gdb-patches
The teardown_btrace() target method is no longer used. Remove it.
---
gdb/remote.c | 11 -----------
gdb/target-delegates-gen.c | 24 ------------------------
gdb/target.c | 8 --------
gdb/target.h | 10 ----------
gdb/x86-linux-nat.c | 9 ---------
gdb/x86-linux-nat.h | 1 -
6 files changed, 63 deletions(-)
diff --git a/gdb/remote.c b/gdb/remote.c
index a728d57df6e..38e0802a68a 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -1228,8 +1228,6 @@ class remote_target : public process_stratum_target
void disable_btrace (struct btrace_target_info *tinfo) override;
- void teardown_btrace (struct btrace_target_info *tinfo) override;
-
enum btrace_error read_btrace (struct btrace_data *data,
struct btrace_target_info *btinfo,
enum btrace_read_type type) override;
@@ -15708,15 +15706,6 @@ remote_target::disable_btrace (struct btrace_target_info *tinfo)
delete tinfo;
}
-/* Teardown branch tracing. */
-
-void
-remote_target::teardown_btrace (struct btrace_target_info *tinfo)
-{
- /* We must not talk to the target during teardown. */
- delete tinfo;
-}
-
/* Read the branch trace. */
enum btrace_error
diff --git a/gdb/target-delegates-gen.c b/gdb/target-delegates-gen.c
index b39fd7cb33a..2ef0ae503ef 100644
--- a/gdb/target-delegates-gen.c
+++ b/gdb/target-delegates-gen.c
@@ -168,7 +168,6 @@ struct dummy_target : public target_ops
bool can_use_agent () override;
struct btrace_target_info *enable_btrace (thread_info *arg0, const struct btrace_config *arg1) override;
void disable_btrace (struct btrace_target_info *arg0) override;
- void teardown_btrace (struct btrace_target_info *arg0) override;
enum btrace_error read_btrace (struct btrace_data *arg0, struct btrace_target_info *arg1, enum btrace_read_type arg2) override;
const struct btrace_config *btrace_conf (const struct btrace_target_info *arg0) override;
enum record_method record_method (ptid_t arg0) override;
@@ -349,7 +348,6 @@ struct debug_target : public target_ops
bool can_use_agent () override;
struct btrace_target_info *enable_btrace (thread_info *arg0, const struct btrace_config *arg1) override;
void disable_btrace (struct btrace_target_info *arg0) override;
- void teardown_btrace (struct btrace_target_info *arg0) override;
enum btrace_error read_btrace (struct btrace_data *arg0, struct btrace_target_info *arg1, enum btrace_read_type arg2) override;
const struct btrace_config *btrace_conf (const struct btrace_target_info *arg0) override;
enum record_method record_method (ptid_t arg0) override;
@@ -3693,28 +3691,6 @@ debug_target::disable_btrace (struct btrace_target_info *arg0)
target_debug_print_btrace_target_info_p (arg0).c_str ());
}
-void
-target_ops::teardown_btrace (struct btrace_target_info *arg0)
-{
- this->beneath ()->teardown_btrace (arg0);
-}
-
-void
-dummy_target::teardown_btrace (struct btrace_target_info *arg0)
-{
- tcomplain ();
-}
-
-void
-debug_target::teardown_btrace (struct btrace_target_info *arg0)
-{
- target_debug_printf_nofunc ("-> %s->teardown_btrace (...)", this->beneath ()->shortname ());
- this->beneath ()->teardown_btrace (arg0);
- target_debug_printf_nofunc ("<- %s->teardown_btrace (%s)",
- this->beneath ()->shortname (),
- target_debug_print_btrace_target_info_p (arg0).c_str ());
-}
-
enum btrace_error
target_ops::read_btrace (struct btrace_data *arg0, struct btrace_target_info *arg1, enum btrace_read_type arg2)
{
diff --git a/gdb/target.c b/gdb/target.c
index 56a5f78c4c0..10f24d954fa 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -4051,14 +4051,6 @@ target_disable_btrace (struct btrace_target_info *btinfo)
/* See target.h. */
-void
-target_teardown_btrace (struct btrace_target_info *btinfo)
-{
- current_inferior ()->top_target ()->teardown_btrace (btinfo);
-}
-
-/* See target.h. */
-
enum btrace_error
target_read_btrace (struct btrace_data *btrace,
struct btrace_target_info *btinfo,
diff --git a/gdb/target.h b/gdb/target.h
index 38bdc68f6a3..3df31199feb 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1208,13 +1208,6 @@ struct target_ops
virtual void disable_btrace (struct btrace_target_info *tinfo)
TARGET_DEFAULT_NORETURN (tcomplain ());
- /* Disable branch tracing and deallocate TINFO. This function is similar
- to to_disable_btrace, except that it is called during teardown and is
- only allowed to perform actions that are safe. A counter-example would
- be attempting to talk to a remote target. */
- virtual void teardown_btrace (struct btrace_target_info *tinfo)
- TARGET_DEFAULT_NORETURN (tcomplain ());
-
/* Read branch trace data for the thread indicated by BTINFO into DATA.
DATA is cleared before new trace is added. */
virtual enum btrace_error read_btrace (struct btrace_data *data,
@@ -2618,9 +2611,6 @@ extern struct btrace_target_info *
/* See to_disable_btrace in struct target_ops. */
extern void target_disable_btrace (struct btrace_target_info *btinfo);
-/* See to_teardown_btrace in struct target_ops. */
-extern void target_teardown_btrace (struct btrace_target_info *btinfo);
-
/* See to_read_btrace in struct target_ops. */
extern enum btrace_error target_read_btrace (struct btrace_data *,
struct btrace_target_info *,
diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c
index 9c49b3bed47..9fe8afe98f3 100644
--- a/gdb/x86-linux-nat.c
+++ b/gdb/x86-linux-nat.c
@@ -146,15 +146,6 @@ x86_linux_nat_target::disable_btrace (struct btrace_target_info *tinfo)
error (_("Could not disable branch tracing."));
}
-/* Teardown branch tracing. */
-
-void
-x86_linux_nat_target::teardown_btrace (struct btrace_target_info *tinfo)
-{
- /* Ignore errors. */
- linux_disable_btrace (tinfo);
-}
-
enum btrace_error
x86_linux_nat_target::read_btrace (struct btrace_data *data,
struct btrace_target_info *btinfo,
diff --git a/gdb/x86-linux-nat.h b/gdb/x86-linux-nat.h
index 61d534a3adf..10c44416bf8 100644
--- a/gdb/x86-linux-nat.h
+++ b/gdb/x86-linux-nat.h
@@ -37,7 +37,6 @@ struct x86_linux_nat_target : public x86_nat_target<linux_nat_target>
struct btrace_target_info *enable_btrace (thread_info *tp,
const struct btrace_config *conf) override;
void disable_btrace (struct btrace_target_info *tinfo) override;
- void teardown_btrace (struct btrace_target_info *tinfo) override;
enum btrace_error read_btrace (struct btrace_data *data,
struct btrace_target_info *btinfo,
enum btrace_read_type type) override;
--
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v1 7/7] gdb, btrace: remove the disconnect() record-btrace target method
2026-11-10 6:43 [PATCH v1 0/7] gdb, btrace: fix unexpected core file Markus Metzger
` (5 preceding siblings ...)
2026-11-10 6:43 ` [PATCH v1 6/7] gdb, btrace: remove the teardown_btrace() target method Markus Metzger
@ 2026-11-10 6:43 ` Markus Metzger
6 siblings, 0 replies; 8+ messages in thread
From: Markus Metzger @ 2026-11-10 6:43 UTC (permalink / raw)
To: gdb-patches
There is no need to unpush the record-btrace target. The remote target
beneath will do that.
---
gdb/record-btrace.c | 17 -----------------
1 file changed, 17 deletions(-)
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index cbebb3dbee2..72228c0ee48 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -70,8 +70,6 @@ class record_btrace_target final : public target_ops
void detach (inferior *inf, int from_tty) override
{ record_detach (this, inf, from_tty); }
- void disconnect (const char *, int) override;
-
void mourn_inferior () override
{ record_mourn_inferior (this); }
@@ -427,21 +425,6 @@ record_btrace_target::stop_recording ()
return is_replaying;
}
-/* The disconnect method of target record-btrace. */
-
-void
-record_btrace_target::disconnect (const char *args,
- int from_tty)
-{
- struct target_ops *beneath = this->beneath ();
-
- /* Do not stop recording, just clean up GDB side. */
- current_inferior ()->unpush_target (this);
-
- /* Forward disconnect. */
- beneath->disconnect (args, from_tty);
-}
-
/* The close method of target record-btrace. */
void
--
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-11-10 6:45 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox