aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorFelix Willgerodt <felix.willgerodt@intel.com>2019-02-25 15:30:29 +0100
committerFelix Willgerodt <felix.willgerodt@intel.com>2024-08-14 11:20:56 +0200
commit8958aefd34200c8d2cd6e81bba32198468789c62 (patch)
tree3811d80cd4d2a0743da4ab090cfd5640ef8c4c42 /gdb/python
parentbea4f6fac4e0b1700188fad19499c62c46f8e70d (diff)
downloadbinutils-8958aefd34200c8d2cd6e81bba32198468789c62.zip
binutils-8958aefd34200c8d2cd6e81bba32198468789c62.tar.gz
binutils-8958aefd34200c8d2cd6e81bba32198468789c62.tar.bz2
python: Add clear() to gdb.Record.
This function allows to clear the trace data from python, forcing to re-decode the trace for successive commands. This will be used in future ptwrite patches, to trigger re-decoding when the ptwrite filter changes. Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-By: Markus Metzger <markus.t.metzger@intel.com>
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-record-btrace.c13
-rw-r--r--gdb/python/py-record-btrace.h3
-rw-r--r--gdb/python/py-record.c16
3 files changed, 32 insertions, 0 deletions
diff --git a/gdb/python/py-record-btrace.c b/gdb/python/py-record-btrace.c
index 0ff2708..49b6c74 100644
--- a/gdb/python/py-record-btrace.c
+++ b/gdb/python/py-record-btrace.c
@@ -847,6 +847,19 @@ recpy_bt_goto (PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
+/* Implementation of BtraceRecord.clear (self) -> None. */
+
+PyObject *
+recpy_bt_clear (PyObject *self, PyObject *args)
+{
+ const recpy_record_object * const record = (recpy_record_object *) self;
+ thread_info *const tinfo = record->thread;
+
+ btrace_clear (tinfo);
+
+ Py_RETURN_NONE;
+}
+
/* BtraceList methods. */
static PyMethodDef btpy_list_methods[] =
diff --git a/gdb/python/py-record-btrace.h b/gdb/python/py-record-btrace.h
index 5010cb3..3be5860 100644
--- a/gdb/python/py-record-btrace.h
+++ b/gdb/python/py-record-btrace.h
@@ -31,6 +31,9 @@ extern PyObject *recpy_bt_format (PyObject *self, void *closure);
/* Implementation of record.goto (instruction) -> None. */
extern PyObject *recpy_bt_goto (PyObject *self, PyObject *value);
+/* Implementation of BtraceRecord.clear (self) -> None. */
+extern PyObject *recpy_bt_clear (PyObject *self, PyObject *args);
+
/* Implementation of record.instruction_history [list]. */
extern PyObject *recpy_bt_instruction_history (PyObject *self, void *closure);
diff --git a/gdb/python/py-record.c b/gdb/python/py-record.c
index 0efd631..2e0834c 100644
--- a/gdb/python/py-record.c
+++ b/gdb/python/py-record.c
@@ -114,6 +114,19 @@ recpy_goto (PyObject *self, PyObject *value)
return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
}
+/* Implementation of record.clear () -> None. */
+
+static PyObject *
+recpy_clear (PyObject *self, PyObject *value)
+{
+ const recpy_record_object * const obj = (recpy_record_object *) self;
+
+ if (obj->method == RECORD_METHOD_BTRACE)
+ return recpy_bt_clear (self, value);
+
+ return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
+}
+
/* Implementation of record.replay_position [instruction] */
static PyObject *
@@ -522,6 +535,9 @@ static PyMethodDef recpy_record_methods[] = {
{ "goto", recpy_goto, METH_VARARGS,
"goto (instruction|function_call) -> None.\n\
Rewind to given location."},
+ { "clear", recpy_clear, METH_VARARGS,
+ "clear () -> None.\n\
+Clears the trace."},
{ NULL }
};