From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 6PQnGTlwx2CkRAAAWB0awg (envelope-from ) for ; Mon, 14 Jun 2021 11:05:29 -0400 Received: by simark.ca (Postfix, from userid 112) id 642791F163; Mon, 14 Jun 2021 11:05:29 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 8BC0B1E813 for ; Mon, 14 Jun 2021 11:05:28 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4D03F395144A for ; Mon, 14 Jun 2021 15:05:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4D03F395144A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1623683128; bh=cB7vz0dBnWZCRnv6OPTW4RToMoWgzp1QpHSudZ8DT7E=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=NzbVOf9wgOXKReDW+rHcjQRM1l5qSG73dofUneyW3EJIk3xv0kOW7Kcx6ddqHeIrS GmUHnZHkekHeDbaGSXX3QnFmRigZqRGvd1GZbgt6Z0APIqkHbVVd1I6HSXNwJeOHVz 8gKWE0mZeu6+MEmrlwhMhx1NT42irr87yn3Tzcyo= Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by sourceware.org (Postfix) with ESMTPS id C7C313947420 for ; Mon, 14 Jun 2021 14:57:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C7C313947420 IronPort-SDR: RhE0N0cnX7YjQf3C5MHcMyrqVCtSLBB+q9Wbjgp3ACnataW+Ou17mPrwH02739CNaWLPWLHaq6 r/8lgEW0WV0w== X-IronPort-AV: E=McAfee;i="6200,9189,10015"; a="205641896" X-IronPort-AV: E=Sophos;i="5.83,273,1616482800"; d="scan'208";a="205641896" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2021 07:57:33 -0700 IronPort-SDR: Z1lwnYWawNyn5L3DvYc7nvOaBmdWeqKx09gvBX/Rp4MxaRhF3WoEhKp7A1qnE29htycCMhug3i GVpUcHwo5hnA== X-IronPort-AV: E=Sophos;i="5.83,273,1616482800"; d="scan'208";a="451616786" Received: from mulvlfelix.iul.intel.com (HELO localhost) ([172.28.48.31]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2021 07:57:32 -0700 To: markus.t.metzger@intel.com, gdb-patches@sourceware.org Subject: [PATCH v2 06/12] python: Add clear() to gdb.Record. Date: Mon, 14 Jun 2021 16:54:05 +0200 Message-Id: <20210614145411.689277-2-felix.willgerodt@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210614145411.689277-1-felix.willgerodt@intel.com> References: <20210614145411.689277-1-felix.willgerodt@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Felix Willgerodt via Gdb-patches Reply-To: Felix Willgerodt Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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 * 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 * gdb.python/py-record-btrace.exp: Add tests for clear(). gdb/doc/ChangeLog: 2021-06-14 Felix Willgerodt * 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 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