[6/11] Add ALPHA_MAX_REGISTER_SIZE
Commit Message
> On 11 Apr 2017, at 10:16, Yao Qi <qiyaoltc@gmail.com> wrote:
>
> Alan Hayward <Alan.Hayward@arm.com> writes:
>
>> diff --git a/gdb/alpha-tdep.h b/gdb/alpha-tdep.h
>> index ab46ba56bef1ffb1cea541c506ffed6a5ae9b556..316d94d0bb53e9bc7943d406bf81f7d597437ff3 100644
>> --- a/gdb/alpha-tdep.h
>> +++ b/gdb/alpha-tdep.h
>> @@ -26,6 +26,9 @@ struct regcache;
>> real way to know how big a register is. */
>> #define ALPHA_REGISTER_SIZE 8
>>
>> +/* Big enough to hold the size of the largest register in bytes. */
>> +#define ALPHA_MAX_REGISTER_SIZE 8
>> +
>
>> --- a/gdb/alpha-tdep.c
>> +++ b/gdb/alpha-tdep.c
>> @@ -244,7 +244,7 @@ alpha_register_to_value (struct frame_info *frame, int regnum,
>> int *optimizedp, int *unavailablep)
>> {
>> struct gdbarch *gdbarch = get_frame_arch (frame);
>> - gdb_byte in[MAX_REGISTER_SIZE];
>> + gdb_byte in[ALPHA_MAX_REGISTER_SIZE];
>>
>> /* Convert to TYPE. */
>> if (!get_frame_register_bytes (frame, regnum, 0,
>
> We can use get_frame_register_value, so "in" can be removed.
>
>> @@ -266,7 +266,7 @@ static void
>> alpha_value_to_register (struct frame_info *frame, int regnum,
>> struct type *valtype, const gdb_byte *in)
>> {
>> - gdb_byte out[MAX_REGISTER_SIZE];
>> + gdb_byte out[ALPHA_MAX_REGISTER_SIZE];
>
> Why don't you use ALPHA_REGISTER_SIZE?
Hmmm... yes. Not sure why I ignored that!
>
> --
> Yao (齐尧)
Updated changes below.
I don't have a ALPHA machine to test on.
Tested on a --enable-targets=all build using make check with board files
unix and native-gdbserver.
Ok to commit?
Alan.
2017-04-12 Alan Hayward <alan.hayward@arm.com>
* alpha-tdep.c (alpha_register_to_value): Use get_frame_register_value.
(alpha_value_to_register): Use ALPHA_REGISTER_SIZE.
@@ -244,17 +244,23 @@ alpha_register_to_value (struct frame_info *frame, int regnum,
int *optimizedp, int *unavailablep)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
- gdb_byte in[MAX_REGISTER_SIZE];
+ struct value *value;
/* Convert to TYPE. */
- if (!get_frame_register_bytes (frame, regnum, 0,
- register_size (gdbarch, regnum),
- in, optimizedp, unavailablep))
+
+ value = get_frame_register_value (frame, regnum);
+
+ gdb_assert (value != NULL);
+
+ *optimizedp = value_optimized_out (value);
+ *unavailablep = !value_entirely_available (value);
+
+ if (*optimizedp || *unavailablep)
return 0;
if (TYPE_LENGTH (valtype) == 4)
{
- alpha_sts (gdbarch, out, in);
+ alpha_sts (gdbarch, out, value_contents (value));
*optimizedp = *unavailablep = 0;
return 1;
}
@@ -266,7 +272,7 @@ static void
alpha_value_to_register (struct frame_info *frame, int regnum,
struct type *valtype, const gdb_byte *in)
{
- gdb_byte out[MAX_REGISTER_SIZE];
+ gdb_byte out[ALPHA_REGISTER_SIZE];
switch (TYPE_LENGTH (valtype))
{