public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb, btrace: switch threads in remote_btrace_maybe_reopen()
@ 2022-01-27 12:50 Markus Metzger
0 siblings, 0 replies; only message in thread
From: Markus Metzger @ 2022-01-27 12:50 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b674665b51112de22260709a214d4d6ba01c7e57
commit b674665b51112de22260709a214d4d6ba01c7e57
Author: Markus Metzger <markus.t.metzger@intel.com>
Date: Thu Nov 25 07:33:20 2021 +0100
gdb, btrace: switch threads in remote_btrace_maybe_reopen()
In remote_btrace_maybe_reopen() we iterate over threads and use
set_general_thread() to set the thread from which to transfer the btrace
configuration.
This sets the remote general thread but does not affect inferior_ptid. On
the xfer request later on, remote_target::xfer_partial() again sets the
remote general thread to inferior_ptid, overwriting what
remote_btrace_maybe_reopen() had done.
In one case, this led to inferior_ptid being null_ptid when we tried to
enable tracing on a newly created thread inside a newly created process
during attach.
This, in turn, led to find_inferior_pid() asserting when we iterated over
threads in record_btrace_is_replaying(), which was called from
record_btrace_target::xfer_partial() when reading the btrace configuration
of the new thread to check whether it was already being recorded.
The bug was exposed by
0618ae41497 gdb: optimize all_matching_threads_iterator
and found by
FAIL: gdb.btrace/enable-new-thread.exp: ... (GDB internal error)
Use switch_to_thread() in remote_btrace_maybe_reopen().
Diff:
---
gdb/remote.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/remote.c b/gdb/remote.c
index bb41a18daf9..f19a2f7c1f9 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -14136,7 +14136,7 @@ remote_target::remote_btrace_maybe_reopen ()
for (thread_info *tp : all_non_exited_threads (this))
{
- set_general_thread (tp->ptid);
+ switch_to_thread (tp);
memset (&rs->btrace_config, 0x00, sizeof (struct btrace_config));
btrace_read_config (&rs->btrace_config);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-01-27 12:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-27 12:50 [binutils-gdb] gdb, btrace: switch threads in remote_btrace_maybe_reopen() Markus Metzger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).