This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch v9 17/23] record: add "record instruction-history" command


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 <eliz@gnu.org>
> 
> 2013-03-04  Markus Metzger  <markus.t.metzger@intel.com>
> 
> 	* target.h (target_ops) <to_insn_history, to_insn_history_from,
> 	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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]