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 v5 3/7] Refactor arm_software_single_step to use regcache.


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), &reg);

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


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