This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Remove MAX_REGISTER_SIZE from target.c
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: Alan Hayward <Alan dot Hayward at arm dot com>
- Cc: "gdb-patches\@sourceware.org" <gdb-patches at sourceware dot org>,
- Date: Wed, 01 Mar 2017 17:22:52 +0000
- Subject: Re: [PATCH] Remove MAX_REGISTER_SIZE from target.c
- Authentication-results: sourceware.org; auth=none
- References: <CF801F56-59C3-4A53-9309-2AC05D7C8501@arm.com>
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 (齐尧)