From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17946 invoked by alias); 5 Mar 2013 20:11:23 -0000 Received: (qmail 17931 invoked by uid 22791); 5 Mar 2013 20:11:20 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 05 Mar 2013 20:11:15 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r25KBCIh013921 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 5 Mar 2013 15:11:13 -0500 Received: from host2.jankratochvil.net (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r25KB7FP004125 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Tue, 5 Mar 2013 15:11:10 -0500 Date: Tue, 05 Mar 2013 20:11:00 -0000 From: Jan Kratochvil To: Markus Metzger Cc: gdb-patches@sourceware.org, markus.t.metzger@gmail.com, Eli Zaretskii Subject: Re: [patch v9 17/23] record: add "record instruction-history" command Message-ID: <20130305201107.GQ2386@host2.jankratochvil.net> References: <1362416770-19750-1-git-send-email-markus.t.metzger@intel.com> <1362416770-19750-18-git-send-email-markus.t.metzger@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1362416770-19750-18-git-send-email-markus.t.metzger@intel.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 X-SW-Source: 2013-03/txt/msg00180.txt.bz2 On Mon, 04 Mar 2013 18:06:04 +0100, Markus Metzger wrote: > Add a command to provide a disassembly of the execution trace log. > > The command iterates over the execution trace log similar to the > "list" command. > > CC: Eli Zaretskii > > 2013-03-04 Markus Metzger > > * target.h (target_ops) to_insn_history_range>: New fields. > (target_insn_history): New. > (target_insn_history_from): New. > (target_insn_history_range): New. > * target.c (target_insn_history): New. > (target_insn_history_from): New. > (target_insn_history_range): New. > * record.c: Include cli/cli-utils.h, disasm.h, ctype.h. > (record_insn_history_size): New. > (get_insn_number): New. > (get_context_size): New. > (no_chunk): New. > (get_insn_history_modifiers): New. > (cmd_record_insn_history): New. > (_initialize_record): Add "set/show record instruction-history-size" > command. Add "record instruction-history" command. [...] > --- a/gdb/record.c > +++ b/gdb/record.c [...] > +/* The "record instruction-history" command. */ > + > +static void > +cmd_record_insn_history (char *arg, int from_tty) > +{ > + int flags, size; > + > + require_record_target (); > + > + flags = get_insn_history_modifiers (&arg); > + size = (int) record_insn_history_size; > + if (size < 0) > + size = INT_MAX; Could you make some comment what is the goal of casting unsigned record_insn_history_size here and comparing it to < 0 etc.? > + > + if (arg == NULL || *arg == 0 || strcmp (arg, "+") == 0) > + target_insn_history (size, flags); > + else if (strcmp (arg, "-") == 0) > + target_insn_history (- size, flags); > + else > + { > + ULONGEST begin, end; > + > + begin = get_insn_number (&arg); > + > + if (*arg == ',') > + { > + arg = skip_spaces (++arg); > + > + if (*arg == '+') > + { > + arg += 1; > + size = get_context_size (&arg); > + > + no_chunk (arg); > + > + target_insn_history_from (begin, size, flags); > + } > + else if (*arg == '-') > + { > + arg += 1; > + size = get_context_size (&arg); > + > + no_chunk (arg); > + > + target_insn_history_from (begin, - size, flags); > + } > + else > + { > + end = get_insn_number (&arg); > + > + no_chunk (arg); > + > + target_insn_history_range (begin, end, flags); > + } > + } > + else > + { > + no_chunk (arg); > + > + target_insn_history_from (begin, size, flags); > + } > + > + dont_repeat (); > + } > +} > + > /* Provide a prototype to silence -Wmissing-prototypes. */ > extern initialize_file_ftype _initialize_record; > [...] > --- a/gdb/target.h > +++ b/gdb/target.h > @@ -897,6 +897,17 @@ struct target_ops > /* Go to a specific location in the recorded execution trace. */ > void (*to_goto_record) (ULONGEST insn); > > + /* Disassemble SIZE instructions in the recorded execution trace from > + the current position. */ > + void (*to_insn_history) (int size, int flags); > + > + /* Disassemble SIZE instructions in the recorded execution trace around > + FROM. */ > + void (*to_insn_history_from) (ULONGEST FROM, int size, int flags); FROM should be lowercased here in the code. Please comment here the rules about FROM and SIZE, one needs to look at record_btrace_insn_history_from to find out what it should do. > + > + /* Disassemble a section of the recorded execution trace. */ > + void (*to_insn_history_range) (ULONGEST begin, ULONGEST end, int flags); > + > int to_magic; > /* Need sub-structure for target machine related rather than comm related? > */ > @@ -1983,4 +1994,13 @@ extern void target_goto_record_end (void); > /* See to_goto_record in struct target_ops. */ > extern void target_goto_record (ULONGEST insn); > > +/* See to_insn_history. */ > +extern void target_insn_history (int size, int flags); > + > +/* See to_insn_history_from. */ > +extern void target_insn_history_from (ULONGEST from, int size, int flags); > + > +/* See to_insn_history_range. */ > +extern void target_insn_history_range (ULONGEST begin, ULONGEST end, int flags); > + > #endif /* !defined (TARGET_H) */ > -- > 1.7.1 OK for check-in with those changes. Thanks, Jan