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] Remove MAX_REGISTER_SIZE from target.c


Alan Hayward <Alan.Hayward@arm.com> writes:

> +extern void regcache_debug_print_register (const char *func,
> +					   struct regcache *regcache,
> +					   int regno);

Comments are needed.

> +
>  #endif /* REGCACHE_H */
> diff --git a/gdb/regcache.c b/gdb/regcache.c
> index f190eda0e47c5c03744fc26263505d1c30ea1ee8..31aa1baf7ef69c27c00e45e3c8d4eb3c41dc4203 100644
> --- a/gdb/regcache.c
> +++ b/gdb/regcache.c
> @@ -1259,6 +1259,42 @@ regcache_write_pc (struct regcache *regcache, CORE_ADDR pc)
>    reinit_frame_cache ();
>  }
>
> +void
> +regcache_debug_print_register (const char *func, struct regcache *regcache,
> +			       int regno)
> +{
> +  struct gdbarch *gdbarch = get_regcache_arch (regcache);
> +
> +  fprintf_unfiltered (gdb_stdlog, "%s ", func);
> +  if (regno >= 0 && regno < gdbarch_num_regs (gdbarch)
> +      && gdbarch_register_name (gdbarch, regno) != NULL
> +      && gdbarch_register_name (gdbarch, regno)[0] != '\0')
> +    fprintf_unfiltered (gdb_stdlog, "(%s)",
> +			gdbarch_register_name (gdbarch, regno));
> +  else
> +    fprintf_unfiltered (gdb_stdlog, "(%d)", regno);
> +  if (regno >= 0 && regno < gdbarch_num_regs (gdbarch))
> +    {
> +      enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> +      int i, size = register_size (gdbarch, regno);
> +      gdb_byte *buf = register_buffer (regcache, regno);
> +
> +      regcache_raw_collect (regcache, regno, buf);

Don't need to call regcache_raw_collect, otherwise, the src and dst of
copy is at the same address (register_buffer (regcache, regno)).

-- 
Yao (齐尧)


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