void btrace_enable (struct thread_info *tp, const struct btrace_config *conf) { if (tp->btrace.target != NULL) return; if (!target_supports_btrace (conf->format)) error (_("Target does not support branch tracing.")); DEBUG ("enable thread %d (%s)", tp->num, target_pid_to_str (tp->ptid)); tp->btrace.target = target_enable_btrace (tp->ptid, conf); /* Add an entry for the current PC so we start tracing from where we enabled it. */ if (tp->btrace.target != NULL) btrace_add_pc (tp); }
static void record_btrace_open (char *args, int from_tty) { struct cleanup *disable_chain; struct thread_info *tp; DEBUG ("open"); record_preopen (); if (!target_has_execution) error (_("The program is not being run.")); if (!target_supports_btrace ()) error (_("Target does not support branch tracing.")); if (non_stop) error (_("Record btrace can't debug inferior in non-stop mode.")); gdb_assert (record_btrace_thread_observer == NULL); disable_chain = make_cleanup (null_cleanup, NULL); ALL_THREADS (tp) if (args == NULL || *args == 0 || number_is_in_list (args, tp->num)) { btrace_enable (tp); make_cleanup (record_btrace_disable_callback, tp); } record_btrace_auto_enable (); push_target (&record_btrace_ops); observer_notify_record_changed (current_inferior (), 1); discard_cleanups (disable_chain); }