This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v5 3/7] Refactor arm_software_single_step to use regcache.
- From: Pedro Alves <palves at redhat dot com>
- To: Antoine Tremblay <antoine dot tremblay at ericsson dot com>, gdb-patches at sourceware dot org
- Date: Fri, 04 Dec 2015 15:10:22 +0000
- Subject: Re: [PATCH v5 3/7] Refactor arm_software_single_step to use regcache.
- Authentication-results: sourceware.org; auth=none
- References: <1449234783-11424-1-git-send-email-antoine dot tremblay at ericsson dot com> <1449234783-11424-4-git-send-email-antoine dot tremblay at ericsson dot com>
On 12/04/2015 01:12 PM, Antoine Tremblay wrote:
> @@ -4727,7 +4754,8 @@ thumb_get_next_pc_raw (struct frame_info *frame, CORE_ADDR pc)
> {
> /* CBNZ or CBZ. */
> int imm = (bit (inst1, 9) << 6) + (bits (inst1, 3, 7) << 1);
> - ULONGEST reg = get_frame_register_unsigned (frame, bits (inst1, 0, 2));
> + ULONGEST reg;
> + regcache_raw_read_unsigned (regcache, bits (inst1, 0, 2), ®);
Missing empty line.
Note that get_frame_register_unsigned throws if the register is
unavailable, while regcache_raw_read_unsigned uses the return value as
status indication.
Shouldn't really happen normally in get_next_pcs to see an unavailable
register, but, wouldn't it be nicer to add a small wrapper like:
ULONGEST
get_regcache_raw_unsigned (struct regcache *regcache, int regnum)
{
ULONGEST value;
enum register_status status;
status = regcache_raw_read_unsigned (regcache, regnum, &value);
if (status == REG_UNAVAILABLE)
throw_error (NOT_AVAILABLE_ERROR,
_("Register %s is not available"), regnum);
return value;
}
?
Then the rest of the patch would look like:
> - ULONGEST reg = get_frame_register_unsigned (frame, bits (inst1, 0, 2));
> + ULONGEST reg = get_regcache_register_unsigned (frame, bits (inst1, 0, 2));
etc., and the reader no longer need to worry about considering why is the
return value of regcache_raw_read_unsigned ignored.
>
> if (bit (inst1, 11) && reg != 0)
> nextpc = pc_val + imm;
> @@ -4746,20 +4774,21 @@ thumb_get_next_pc_raw (struct frame_info *frame, CORE_ADDR pc)
Thanks,
Pedro Alves