static void record_btrace_insn_history_range (struct target_ops *self, ULONGEST from, ULONGEST to, int flags) { struct btrace_thread_info *btinfo; struct btrace_insn_history *history; struct btrace_insn_iterator begin, end; struct cleanup *uiout_cleanup; struct ui_out *uiout; unsigned int low, high; int found; uiout = current_uiout; uiout_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, "insn history"); low = from; high = to; DEBUG ("insn-history (0x%x): [%u; %u)", flags, low, high); /* Check for wrap-arounds. */ if (low != from || high != to) error (_("Bad range.")); if (high < low) error (_("Bad range.")); btinfo = require_btrace (); found = btrace_find_insn_by_number (&begin, btinfo, low); if (found == 0) error (_("Range out of bounds.")); found = btrace_find_insn_by_number (&end, btinfo, high); if (found == 0) { /* Silently truncate the range. */ btrace_insn_end (&end, btinfo); } else { /* We want both begin and end to be inclusive. */ btrace_insn_next (&end, 1); } btrace_insn_history (uiout, &begin, &end, flags); btrace_set_insn_history (btinfo, &begin, &end); do_cleanups (uiout_cleanup); }
static PyObject * btpy_insn_or_gap_new (thread_info *tinfo, Py_ssize_t number) { btrace_insn_iterator iter; int err_code; btrace_find_insn_by_number (&iter, &tinfo->btrace, number); err_code = btrace_insn_get_error (&iter); if (err_code != 0) { const btrace_config *config; const char *err_string; config = btrace_conf (&tinfo->btrace); err_string = btrace_decode_error (config->format, err_code); return recpy_gap_new (err_code, err_string, number); } return recpy_insn_new (tinfo, RECORD_METHOD_BTRACE, number); }
static const btrace_insn * btrace_insn_from_recpy_insn (const PyObject * const pyobject) { const btrace_insn *insn; const recpy_element_object *obj; thread_info *tinfo; btrace_insn_iterator iter; if (Py_TYPE (pyobject) != &recpy_insn_type) { PyErr_Format (gdbpy_gdb_error, _("Must be gdb.RecordInstruction")); return NULL; } obj = (const recpy_element_object *) pyobject; tinfo = obj->thread; if (tinfo == NULL || btrace_is_empty (tinfo)) { PyErr_Format (gdbpy_gdb_error, _("No such instruction.")); return NULL; } if (btrace_find_insn_by_number (&iter, &tinfo->btrace, obj->number) == 0) { PyErr_Format (gdbpy_gdb_error, _("No such instruction.")); return NULL; } insn = btrace_insn_get (&iter); if (insn == NULL) { PyErr_Format (gdbpy_gdb_error, _("Not a valid instruction.")); return NULL; } return insn; }
static void record_btrace_goto (struct target_ops *self, ULONGEST insn) { struct thread_info *tp; struct btrace_insn_iterator it; unsigned int number; int found; number = insn; /* Check for wrap-arounds. */ if (number != insn) error (_("Instruction number out of range.")); tp = require_btrace_thread (); found = btrace_find_insn_by_number (&it, &tp->btrace, number); if (found == 0) error (_("No such instruction.")); record_btrace_set_replay (tp, &it); print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1); }