This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH V3] Add negative repeat count to 'x' command
- From: Simon Marchi <simon dot marchi at ericsson dot com>
- To: Toshihito Kikuchi <k dot toshihito at yahoo dot de>, Pedro Alves <palves at redhat dot com>, <gdb-patches at sourceware dot org>
- Date: Tue, 24 May 2016 13:52:16 -0400
- Subject: Re: [PATCH V3] Add negative repeat count to 'x' command
- Authentication-results: sourceware.org; auth=none
- References: <1461866539-24965-1-git-send-email-k dot toshihito at yahoo dot de>
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.