#include "gdbarch.h"
#include "cli/cli-style.h"
#include "async-event.h"
+#include <forward_list>
static const target_info record_btrace_target_info = {
"record-btrace",
static void
record_btrace_enable_warn (struct thread_info *tp)
{
+ /* Ignore this thread if its inferior is not recorded by us. */
+ target_ops *rec = tp->inf->target_at (record_stratum);
+ if (rec != &record_btrace_ops)
+ return;
+
try
{
btrace_enable (tp, &record_btrace_conf);
static void
record_btrace_handle_async_inferior_event (gdb_client_data data)
{
- inferior_event_handler (INF_REG_EVENT, NULL);
+ inferior_event_handler (INF_REG_EVENT);
}
/* See record-btrace.h. */
if (!target_has_execution)
error (_("The program is not being run."));
- for (thread_info *tp : all_non_exited_threads ())
+ for (thread_info *tp : current_inferior ()->non_exited_threads ())
if (args == NULL || *args == 0 || number_is_in_list (args, tp->global_num))
{
btrace_enable (tp, &record_btrace_conf);
record_btrace_auto_disable ();
- for (thread_info *tp : all_non_exited_threads ())
+ for (thread_info *tp : current_inferior ()->non_exited_threads ())
if (tp->btrace.target != NULL)
btrace_disable (tp);
}
/* We should have already stopped recording.
Tear down btrace in case we have not. */
- for (thread_info *tp : all_non_exited_threads ())
+ for (thread_info *tp : current_inferior ()->non_exited_threads ())
btrace_teardown (tp);
}
void
record_btrace_target::fetch_registers (struct regcache *regcache, int regno)
{
+ btrace_insn_iterator *replay = nullptr;
+
+ /* Thread-db may ask for a thread's registers before GDB knows about the
+ thread. We forward the request to the target beneath in this
+ case. */
thread_info *tp = find_thread_ptid (regcache->target (), regcache->ptid ());
- gdb_assert (tp != NULL);
+ if (tp != nullptr)
+ replay = tp->btrace.replay;
- btrace_insn_iterator *replay = tp->btrace.replay;
- if (replay != NULL && !record_btrace_generating_corefile)
+ if (replay != nullptr && !record_btrace_generating_corefile)
{
const struct btrace_insn *insn;
struct gdbarch *gdbarch;
/* Stop all other threads. */
if (!target_is_non_stop_p ())
{
- for (thread_info *tp : all_non_exited_threads ())
+ for (thread_info *tp : current_inferior ()->non_exited_threads ())
record_btrace_cancel_resume (tp);
}
void
record_btrace_target::record_stop_replaying ()
{
- for (thread_info *tp : all_non_exited_threads ())
+ for (thread_info *tp : current_inferior ()->non_exited_threads ())
record_btrace_stop_replaying (tp);
}