static struct thread_info * require_btrace_thread (void) { struct thread_info *tp; DEBUG ("require"); tp = find_thread_ptid (inferior_ptid); if (tp == NULL) error (_("No thread.")); btrace_fetch (tp); if (btrace_is_empty (tp)) error (_("No trace.")); return tp; }
static void record_btrace_info (struct target_ops *self) { struct btrace_thread_info *btinfo; struct thread_info *tp; unsigned int insns, calls; DEBUG ("info"); tp = find_thread_ptid (inferior_ptid); if (tp == NULL) error (_("No thread.")); btrace_fetch (tp); insns = 0; calls = 0; btinfo = &tp->btrace; if (!btrace_is_empty (tp)) { struct btrace_call_iterator call; struct btrace_insn_iterator insn; btrace_call_end (&call, btinfo); btrace_call_prev (&call, 1); calls = btrace_call_number (&call); btrace_insn_end (&insn, btinfo); btrace_insn_prev (&insn, 1); insns = btrace_insn_number (&insn); } printf_unfiltered (_("Recorded %u instructions in %u functions for thread " "%d (%s).\n"), insns, calls, tp->num, target_pid_to_str (tp->ptid)); if (btrace_is_replaying (tp)) printf_unfiltered (_("Replay in progress. At instruction %u.\n"), btrace_insn_number (btinfo->replay)); }
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 const btrace_function * btrace_func_from_recpy_func (const PyObject * const pyobject) { const btrace_function *func; const recpy_element_object *obj; thread_info *tinfo; btrace_call_iterator iter; if (Py_TYPE (pyobject) != &recpy_func_type) { PyErr_Format (gdbpy_gdb_error, _("Must be gdb.RecordFunctionSegment")); 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 function segment.")); return NULL; } if (btrace_find_call_by_number (&iter, &tinfo->btrace, obj->number) == 0) { PyErr_Format (gdbpy_gdb_error, _("No such function segment.")); return NULL; } func = btrace_call_get (&iter); if (func == NULL) { PyErr_Format (gdbpy_gdb_error, _("Not a valid function segment.")); return NULL; } return func; }