Re: [PATCH] Removal of uses of MAX_REGISTER_SIZE

Yao Qi
2017-02-08T17:36:49Z

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

> @@ -1279,7 +1335,7 @@ regcache_dump (struct regcache *regcache, struct ui_file *file,
> int footnote_register_offset = 0;
> int footnote_register_type_name_null = 0;
> long register_offset = 0;
> - gdb_byte buf[MAX_REGISTER_SIZE];
> + std::vector<gdb_byte> buf (max_register_size (gdbarch));
>
> #if 0
> fprintf_unfiltered (file, "nr_raw_registers %d\n",
> @@ -1406,8 +1462,8 @@ regcache_dump (struct regcache *regcache, struct ui_file *file,
> fprintf_unfiltered (file, "<unavailable>");
> else
> {
> - regcache_raw_read (regcache, regnum, buf);
> - print_hex_chars (file, buf,
> + regcache_raw_update (regcache, regnum);
> + print_hex_chars (file, register_buffer (regcache, regnum),
> regcache->descr->sizeof_register[regnum],
> gdbarch_byte_order (gdbarch));
> }
> @@ -1422,13 +1478,13 @@ regcache_dump (struct regcache *regcache, struct ui_file *file,
> {
> enum register_status status;
>
> - status = regcache_cooked_read (regcache, regnum, buf);
> + status = regcache_cooked_read (regcache, regnum, buf.data ());

Can we use regcache_cooked_read_value so that we don't need buf at all.

> if (status == REG_UNKNOWN)
> fprintf_unfiltered (file, "<invalid>");
> else if (status == REG_UNAVAILABLE)
> fprintf_unfiltered (file, "<unavailable>");
> else
> - print_hex_chars (file, buf,
> + print_hex_chars (file, buf.data (),
> regcache->descr->sizeof_register[regnum],
> gdbarch_byte_order (gdbarch));
> }

--
Yao (齐尧)