#include "defs.h"
#include "record.h"
+#include "record-btrace.h"
#include "gdbthread.h"
#include "target.h"
#include "gdbcmd.h"
#include "event-loop.h"
#include "inf-loop.h"
#include "vec.h"
+#include <algorithm>
/* The target_ops of record-btrace. */
static struct target_ops record_btrace_ops;
inferior_event_handler (INF_REG_EVENT, NULL);
}
+/* See record-btrace.h. */
+
+void
+record_btrace_push_target (void)
+{
+ const char *format;
+
+ record_btrace_auto_enable ();
+
+ push_target (&record_btrace_ops);
+
+ record_btrace_async_inferior_event_handler
+ = create_async_event_handler (record_btrace_handle_async_inferior_event,
+ NULL);
+ record_btrace_generating_corefile = 0;
+
+ format = btrace_format_short_string (record_btrace_conf.format);
+ observer_notify_record_changed (current_inferior (), 1, "btrace", format);
+}
+
/* The to_open method of target record-btrace. */
static void
disable_chain = make_cleanup (null_cleanup, NULL);
ALL_NON_EXITED_THREADS (tp)
- if (args == NULL || *args == 0 || number_is_in_list (args, tp->num))
+ if (args == NULL || *args == 0 || number_is_in_list (args, tp->global_num))
{
btrace_enable (tp, &record_btrace_conf);
make_cleanup (record_btrace_disable_callback, tp);
}
- record_btrace_auto_enable ();
-
- push_target (&record_btrace_ops);
-
- record_btrace_async_inferior_event_handler
- = create_async_event_handler (record_btrace_handle_async_inferior_event,
- NULL);
- record_btrace_generating_corefile = 0;
-
- observer_notify_record_changed (current_inferior (), 1);
+ record_btrace_push_target ();
discard_cleanups (disable_chain);
}
btrace_disable (tp);
}
+/* The to_disconnect method of target record-btrace. */
+
+static void
+record_btrace_disconnect (struct target_ops *self, const char *args,
+ int from_tty)
+{
+ struct target_ops *beneath = self->beneath;
+
+ /* Do not stop recording, just clean up GDB side. */
+ unpush_target (self);
+
+ /* Forward disconnect. */
+ beneath->to_disconnect (beneath, args, from_tty);
+}
+
/* The to_close method of target record-btrace. */
static void
}
}
-/* Print an Intel(R) Processor Trace configuration. */
+/* Print an Intel Processor Trace configuration. */
static void
record_btrace_print_pt_conf (const struct btrace_config_pt *conf)
}
printf_unfiltered (_("Recorded %u instructions in %u functions (%u gaps) "
- "for thread %d (%s).\n"), insns, calls, gaps,
- tp->num, target_pid_to_str (tp->ptid));
+ "for thread %s (%s).\n"), insns, calls, gaps,
+ print_thread_id (tp), target_pid_to_str (tp->ptid));
if (btrace_is_replaying (tp))
printf_unfiltered (_("Replay in progress. At instruction %u.\n"),
if (sal.symtab != symtab || sal.line == 0)
continue;
- begin = min (begin, sal.line);
- end = max (end, sal.line);
+ begin = std::min (begin, sal.line);
+ end = std::max (end, sal.line);
}
out:
& SEC_READONLY) != 0)
{
/* Truncate the request to fit into this section. */
- len = min (len, section->endaddr - offset);
+ len = std::min (len, section->endaddr - offset);
break;
}
}
static int
record_btrace_remove_breakpoint (struct target_ops *ops,
struct gdbarch *gdbarch,
- struct bp_target_info *bp_tgt)
+ struct bp_target_info *bp_tgt,
+ enum remove_bp_reason reason)
{
const char *old;
int ret;
ret = 0;
TRY
{
- ret = ops->beneath->to_remove_breakpoint (ops->beneath, gdbarch, bp_tgt);
+ ret = ops->beneath->to_remove_breakpoint (ops->beneath, gdbarch, bp_tgt,
+ reason);
}
CATCH (except, RETURN_MASK_ALL)
{
{
struct btrace_thread_info *btinfo;
- DEBUG ("resuming thread %d (%s): %x (%s)", tp->num,
+ DEBUG ("resuming thread %s (%s): %x (%s)", print_thread_id (tp),
target_pid_to_str (tp->ptid), flag, btrace_thread_flag_to_str (flag));
btinfo = &tp->btrace;
if (flags == 0)
return;
- DEBUG ("cancel resume thread %d (%s): %x (%s)", tp->num,
+ DEBUG ("cancel resume thread %s (%s): %x (%s)",
+ print_thread_id (tp),
target_pid_to_str (tp->ptid), flags,
btrace_thread_flag_to_str (flags));
flags = btinfo->flags & (BTHR_MOVE | BTHR_STOP);
btinfo->flags &= ~(BTHR_MOVE | BTHR_STOP);
- DEBUG ("stepping thread %d (%s): %x (%s)", tp->num,
+ DEBUG ("stepping thread %s (%s): %x (%s)", print_thread_id (tp),
target_pid_to_str (tp->ptid), flags,
btrace_thread_flag_to_str (flags));
/* We moved the replay position but did not update registers. */
registers_changed_ptid (eventing->ptid);
- DEBUG ("wait ended by thread %d (%s): %s", eventing->num,
+ DEBUG ("wait ended by thread %s (%s): %s",
+ print_thread_id (eventing),
target_pid_to_str (eventing->ptid),
target_waitstatus_to_string (status));
ops->to_close = record_btrace_close;
ops->to_async = record_btrace_async;
ops->to_detach = record_detach;
- ops->to_disconnect = record_disconnect;
+ ops->to_disconnect = record_btrace_disconnect;
ops->to_mourn_inferior = record_mourn_inferior;
ops->to_kill = record_kill;
ops->to_stop_recording = record_btrace_stop_recording;
END_CATCH
}
-/* Start recording Intel(R) Processor Trace. */
+/* Start recording in Intel Processor Trace format. */
static void
cmd_record_btrace_pt_start (char *args, int from_tty)
add_cmd ("pt", class_obscure, cmd_record_btrace_pt_start,
_("\
-Start branch trace recording in Intel(R) Processor Trace format.\n\n\
+Start branch trace recording in Intel Processor Trace format.\n\n\
This format may not be available on all processors."),
&record_btrace_cmdlist);
add_alias_cmd ("pt", "btrace pt", class_obscure, 1, &record_cmdlist);