From: Felix Willgerodt <felix.willgerodt@intel.com>
To: markus.t.metzger@intel.com, gdb-patches@sourceware.org
Subject: [PATCH v3 06/12] python: Add clear() to gdb.Record.
Date: Wed, 16 Jun 2021 09:41:59 +0200 [thread overview]
Message-ID: <20210616074205.1129553-7-felix.willgerodt@intel.com> (raw)
In-Reply-To: <20210616074205.1129553-1-felix.willgerodt@intel.com>
This function allows to clear the trace data from python, forcing to
re-decode the trace for successive commands.
gdb/ChangeLog:
2021-06-14 Felix Willgerodt <felix.willgerodt@intel.com>
* py-record-btrace.c (recpy_bt_clear): New function.
* py-record-btrace.h (recpy_bt_clear): New export.
* py-record.c (recpy_clear): New function.
(recpy_record_methods): Add clear().
testsuite/ChangeLog:
2021-06-14 Felix Willgerodt <felix.willgerodt@intel.com>
* gdb.python/py-record-btrace.exp: Add tests for clear().
gdb/doc/ChangeLog:
2021-06-14 Felix Willgerodt <felix.willgerodt@intel.com>
* python.texi (gdb.Record): Document clear().
---
gdb/doc/python.texi | 5 +++++
gdb/python/py-record-btrace.c | 13 +++++++++++++
gdb/python/py-record-btrace.h | 3 +++
gdb/python/py-record.c | 16 ++++++++++++++++
gdb/testsuite/gdb.python/py-record-btrace.exp | 6 +++++-
5 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index 333732f42f2..fa1c69a2283 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -3567,6 +3567,11 @@ A @code{gdb.Record} object has the following methods:
Move the replay position to the given @var{instruction}.
@end defun
+@defun Record.clear ()
+Clear the trace data of the current recording. This forces re-decoding of the
+trace for successive commands.
+@end defun
+
The common @code{gdb.Instruction} class that recording method specific
instruction objects inherit from, has the following attributes:
diff --git a/gdb/python/py-record-btrace.c b/gdb/python/py-record-btrace.c
index 128dd14dd81..97649b206a5 100644
--- a/gdb/python/py-record-btrace.c
+++ b/gdb/python/py-record-btrace.c
@@ -815,6 +815,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 0022704883e..adb03c5eab4 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 481cd282ba3..9b46b2452bf 100644
--- a/gdb/python/py-record.c
+++ b/gdb/python/py-record.c
@@ -127,6 +127,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 *
@@ -538,6 +551,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 }
};
diff --git a/gdb/testsuite/gdb.python/py-record-btrace.exp b/gdb/testsuite/gdb.python/py-record-btrace.exp
index bf0fa18720e..7d45d6728a3 100644
--- a/gdb/testsuite/gdb.python/py-record-btrace.exp
+++ b/gdb/testsuite/gdb.python/py-record-btrace.exp
@@ -93,7 +93,11 @@ with_test_prefix "instruction " {
}
gdb_test "python print(i.decoded)" ".*"
gdb_test "python print(i.size)" "$decimal"
- gdb_test "python print(i.is_speculative)" "False"
+ gdb_test "python print(i.is_speculative)" "False"
+ gdb_test_no_output "python r.clear()"
+ gdb_test "python insn = r.instruction_history"
+ gdb_test_no_output "python i = insn\[0\]"
+ gdb_test "python print(i.size)" "$decimal"
}
with_test_prefix "function call" {
--
2.25.4
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
next prev parent reply other threads:[~2021-06-16 7:46 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-16 7:41 [PATCH v3 00/12] Extensions for PTWRITE Felix Willgerodt
2021-06-16 7:41 ` [PATCH v3 01/12] btrace: Introduce auxiliary instructions Felix Willgerodt
2021-08-12 11:06 ` Metzger, Markus T
2022-05-06 11:26 ` Willgerodt, Felix
2021-06-16 7:41 ` [PATCH v3 02/12] btrace: Enable auxiliary instructions in record instruction-history Felix Willgerodt
2021-08-12 11:06 ` Metzger, Markus T
2022-05-06 11:26 ` Willgerodt, Felix
2021-06-16 7:41 ` [PATCH v3 03/12] btrace: Enable auxiliary instructions in record function-call-history Felix Willgerodt
2021-08-12 11:14 ` Metzger, Markus T
2022-05-06 11:26 ` Willgerodt, Felix
2021-06-16 7:41 ` [PATCH v3 04/12] btrace: Handle stepping and goto for auxiliary instructions Felix Willgerodt
2021-08-12 11:07 ` Metzger, Markus T
2022-05-06 11:26 ` Willgerodt, Felix
2021-06-16 7:41 ` [PATCH v3 05/12] python: Introduce gdb.RecordAuxiliary class Felix Willgerodt
2021-08-12 11:07 ` Metzger, Markus T
2022-05-06 11:26 ` Willgerodt, Felix
2021-06-16 7:41 ` Felix Willgerodt [this message]
2021-08-12 11:07 ` [PATCH v3 06/12] python: Add clear() to gdb.Record Metzger, Markus T
2021-06-16 7:42 ` [PATCH v3 07/12] btrace, gdbserver: Add ptwrite to btrace_config_pt Felix Willgerodt
2021-08-12 11:07 ` Metzger, Markus T
2022-05-06 11:26 ` Willgerodt, Felix
2022-05-10 13:59 ` Metzger, Markus T
2022-06-24 6:57 ` Willgerodt, Felix
2021-06-16 7:42 ` [PATCH v3 08/12] btrace, linux: Enable ptwrite packets Felix Willgerodt
2021-08-12 11:07 ` Metzger, Markus T
2021-06-16 7:42 ` [PATCH v3 09/12] btrace, python: Enable ptwrite listener registration Felix Willgerodt
2021-08-13 10:36 ` Metzger, Markus T
2022-05-06 11:26 ` Willgerodt, Felix
2022-05-30 14:55 ` Metzger, Markus T
2022-05-31 11:26 ` Willgerodt, Felix
2022-05-31 11:50 ` Eli Zaretskii
2021-06-16 7:42 ` [PATCH v3 10/12] btrace, python: Enable calling the ptwrite listener Felix Willgerodt
2021-08-13 10:36 ` Metzger, Markus T
2022-05-06 11:26 ` Willgerodt, Felix
2022-05-30 15:01 ` Metzger, Markus T
2021-06-16 7:42 ` [PATCH v3 11/12] gdb, testsuite, lib: Add libipt version check Felix Willgerodt
2021-08-13 10:36 ` Metzger, Markus T
2022-05-02 9:55 ` Willgerodt, Felix
2021-06-16 7:42 ` [PATCH v3 12/12] btrace: Extend ptwrite event decoding Felix Willgerodt
2021-06-17 7:00 ` Eli Zaretskii
2021-06-17 11:51 ` Willgerodt, Felix
2021-08-13 13:36 ` Metzger, Markus T
2022-05-06 11:26 ` Willgerodt, Felix
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210616074205.1129553-7-felix.willgerodt@intel.com \
--to=felix.willgerodt@intel.com \
--cc=gdb-patches@sourceware.org \
--cc=markus.t.metzger@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).