Re: [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE (3/4)

Alan Hayward
2017-05-05T08:04:23Z

> On 11 Apr 2017, at 16:37, Yao Qi <qiyaoltc@gmail.com> wrote:
>
> Alan Hayward <Alan.Hayward@arm.com> writes:
>
> Hi Alan,
> There are different ways of getting rid of MAX_REGISTER_SIZE, let us try
> some simple approaches first. Some uses of MAX_REGISTER_SIZE still
> can't be removed, but let us start from easy part.
>

Patch split into multiple parts.

This part removes an unused and commented out buffer.
This part also replaces a use of deprecated_frame_register_read with
get_frame_register_value.

Tested on a --enable-targets=all build using make check with board files
unix and native-gdbserver.
I do not have a MIPS machine to test on.

Ok to commit?

2017-05-05 Alan Hayward <alan.hayward@arm.com>

* mips-tdep.c (mips_o32_return_value): Remove unused buffer.
(print_gp_register_row): Use get_frame_register_value.

diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index f8e68090cfafbe4339b691ceda085a7ee7ffbc14..2f5a90be46b568826dc44cad7d8935afa1794cd1 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -5759,7 +5759,6 @@ mips_o32_return_value (struct gdbarch *gdbarch, struct value *function,
/* A struct that contains one or two floats. Each value is part
in the least significant part of their floating point
register.. */
- gdb_byte reg[MAX_REGISTER_SIZE];
int regnum;
int field;
for (field = 0, regnum = mips_regnum (gdbarch)->fp0;
@@ -6474,7 +6473,8 @@ print_gp_register_row (struct ui_file *file, struct frame_info *frame,
{
struct gdbarch *gdbarch = get_frame_arch (frame);
/* Do values for GP (int) regs. */
- gdb_byte raw_buffer[MAX_REGISTER_SIZE];
+ const gdb_byte *raw_buffer;
+ struct value *value;
int ncols = (mips_abi_regsize (gdbarch) == 8 ? 4 : 8); /* display cols
per row. */
int col, byte;
@@ -6533,9 +6533,12 @@ print_gp_register_row (struct ui_file *file, struct frame_info *frame,
break; /* End row: large register. */

/* OK: get the data in raw format. */
- if (!deprecated_frame_register_read (frame, regnum, raw_buffer))
+ value = get_frame_register_value (frame, regnum);
+ if (value_optimized_out (value)
+ || !value_entirely_available (value))
error (_("can't read register %d (%s)"),
regnum, gdbarch_register_name (gdbarch, regnum));
+ raw_buffer = value_contents_all (value);
/* pad small registers */
for (byte = 0;
byte < (mips_abi_regsize (gdbarch)