gdb, btrace: forward fetch_registers for unknown threads
authorMarkus Metzger <markus.t.metzger@intel.com>
Wed, 18 Mar 2020 09:53:41 +0000 (10:53 +0100)
committerMarkus Metzger <markus.t.metzger@intel.com>
Tue, 21 Apr 2020 13:51:06 +0000 (15:51 +0200)
commit1a476b6d68f338e6daa0345501c0cf0fe97dd8f3
treef9e909c6d92dfbd11943892ccb24458b680251ad
parent4778a5f87d253399083565b4919816f541ebe414
gdb, btrace: forward fetch_registers for unknown threads

In the record-btrace target, while replaying, we can only provide the PC
register.  The btrace state is stored in the thread_info.  So, when trying
to determine whether we are currently replaying, GDB calls
find_thread_ptid() to obtain the thread_info.  It also asserts that we do
have a thread_info.

For new threads, libthread-db may fetch registers before the thread is
known to GDB.  In this case, find_thread_ptid() returns nullptr and the
assertion fails.

Forward the fetch_registers request to the target beneath in that case.

gdb/ChangeLog:

2020-03-19  Markus Metzger  <markus.t.metzger@intel.com>

* record-btrace.c (record_btrace_target::fetch_registers): Forward
request if we do not have a thread_info.

gdb/testsuite/ChangeLog:

2020-03-19  Markus Metzger  <markus.t.metzger@intel.com>

* gdb.btrace/enable-new-thread.c: New test.
* gdb.btrace/enable-new-thread.exp: New file.
gdb/ChangeLog
gdb/record-btrace.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.btrace/enable-new-thread.c [new file with mode: 0644]
gdb/testsuite/gdb.btrace/enable-new-thread.exp [new file with mode: 0644]