From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 50864 invoked by alias); 29 Nov 2016 15:48:52 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 50764 invoked by uid 89); 29 Nov 2016 15:48:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=pts, eli, Eli, Recordings X-HELO: mga02.intel.com Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 29 Nov 2016 15:48:42 +0000 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP; 29 Nov 2016 07:48:41 -0800 X-ExtLoop1: 1 Received: from irsmsx108.ger.corp.intel.com ([163.33.3.3]) by orsmga004.jf.intel.com with ESMTP; 29 Nov 2016 07:48:40 -0800 Received: from irsmsx104.ger.corp.intel.com ([169.254.5.52]) by IRSMSX108.ger.corp.intel.com ([169.254.11.145]) with mapi id 14.03.0248.002; Tue, 29 Nov 2016 15:48:38 +0000 From: "Metzger, Markus T" To: "Wiederhake, Tim" , "gdb-patches@sourceware.org" CC: "palves@redhat.com" Subject: RE: [PATCH v3 8/8] Add documentation for new instruction record Python bindings. Date: Tue, 29 Nov 2016 15:48:00 -0000 Message-ID: References: <1479743318-24523-1-git-send-email-tim.wiederhake@intel.com> <1479743318-24523-9-git-send-email-tim.wiederhake@intel.com> In-Reply-To: <1479743318-24523-9-git-send-email-tim.wiederhake@intel.com> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2016-11/txt/msg00958.txt.bz2 > -----Original Message----- > From: Wiederhake, Tim > Sent: Monday, November 21, 2016 4:49 PM > To: gdb-patches@sourceware.org > Cc: palves@redhat.com; Metzger, Markus T > Subject: [PATCH v3 8/8] Add documentation for new instruction record Pyth= on > bindings. >=20 > 2016-11-21 Tim Wiederhake >=20 > gdb/ChangeLog: >=20 > * NEWS: Add record Python bindings entry. >=20 > gdb/doc/ChangeLog: >=20 > * python.texi (Recordings In Python): New section. > +@defvar Record.format > +A string with the current recording format, e.g.@: @code{bt} or > +@code{pts}. Can be empty. This should be "bts" instead of "pts". IIRC the patches don't really allow it to be empty. > +@end defvar > + > +@defvar Record.begin > +A format specific instruction object representing the first instruction Should this be "method-specific" instead of "format-specific"? > +The attributes and methods of instruction objects depend on the current > +recording format. Currently, only btrace instructions are supported. Should this be "method" instead of "format"? > +@defvar BtraceInstruction.number > +An integer identifying this instruction. @var{number} corresponds to > +the numbers seen in @code{record instruction-history} > +(@pxref{Process Record and Replay}). > +@end defvar > + > +@defvar BtraceInstruction.error > +An integer identifying the error code for gaps in the record. Should this be "history" instead of "record"? > +@defvar BtraceInstruction.decoded > +A human readable string with the decoded instruction. Contains the Should this be "disassembled" instead of "decoded"? > +@defvar BtraceFunctionCall.instructions > +A list of instructions associated with this function call. Should this be "a list of gdb.BtraceInstruction objects"? > +The following example demonstrates the usage of these objects and > +functions to create a function that will rewind a record to the last > +time a function in a different file was executed. This would typically > +be used to track the execution of user provided callback functions in a > +library which typically are not visible in a back trace. > + > +@smallexample > +def bringback (): > + rec =3D gdb.current_recording () > + if not rec: > + return > + > + insn =3D rec.instruction_history > + if len (insn) =3D=3D 0: > + return > + > + try: > + position =3D insn.index (rec.replay_position) > + except: > + position =3D -1 > + try: > + filename =3D insn[position].symbol.symtab.fullname () > + except: > + filename =3D None > + > + for i in reversed (insn[:position]): > + try: > + current =3D i.symbol.symtab.fullname () > + except: > + current =3D None > + > + if filename =3D=3D current: > + continue > + > + rec.goto (i) > + return > +@end smallexample > + > +Another possible application is to write a function that counts the > +number of code executions in a given line range. This line range can > +contain parts of functions or span across several functions and is not > +limited to be contiguous. > + > +@smallexample > +def countrange (filename, linerange): > + count =3D 0 > + > + def filter_only (file_name): > + for call in gdb.current_recording ().function_call_history: > + try: > + if file_name in call.symbol.symtab.fullname (): > + yield call > + except: > + pass > + > + for c in filter_only (filename): > + for i in c.instructions: > + try: > + if i.symbol.line in linerange: > + count +=3D 1 > + break; > + except: > + pass > + > + return count > +@end smallexample > + > @node Commands In Python > @subsubsection Commands In Python The examples are really helpful. The patch looks good to me but we need Eli to approve it. Thanks, Markus. Intel Deutschland GmbH Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Christian Lamprechter Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928