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 V3] Add negative repeat count to 'x' command


On 16-04-28 02:02 PM, Toshihito Kikuchi wrote:
> @@ -868,6 +1077,38 @@ do_examine (struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR addr)
>  
>    get_formatted_print_options (&opts, format);
>  
> +  if (count < 0)
> +    {
> +      /* This is the negative repeat count case.
> +         We rewind the address based on the given repeat count and format,
> +         then examine memory from there in forward direction.  */
> +
> +      count = -count;
> +      if (format == 'i')
> +        {
> +          next_address = find_instruction_backward (gdbarch, addr, count,
> +                                                    &count);
> +        }
> +      else if (format == 's')
> +        {
> +          next_address = find_string_backward (gdbarch, addr, count,
> +                                               val_type->length,

You could use the TYPE_LENGTH macro.

> +                                               &opts, &count);
> +        }
> +      else
> +        {
> +          next_address = addr - count * val_type->length;

Same.

> +        }
> +
> +      /* The following call to print_formatted updates next_address in every
> +         iteration. In backward case, we store the start address here
> +         and update next_address with it before exiting the function.  */
> +      addr_rewound = (format == 's'
> +                      ? next_address - val_type->length

Same.


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