[2/11] Add IA64_MAX_REGISTER_SIZE
Commit Message
Max size set to 128bits, which I determined using regformats/reg-ia64.dat
Tested on a --enable-targets=all build using make check with board files
unix and native-gdbserver.
I do not have an IA64 machine to test on.
Ok to commit?
Alan.
2017-04-04 Alan Hayward <alan.hayward@arm.com>
* ia64-tdep.c (ia64_register_to_value): Use IA64_MAX_REGISTER_SIZE
(ia64_value_to_register): Likewise.
(examine_prologue): Likewise.
(ia64_sigtramp_frame_prev_register): Likewise.
(ia64_access_reg): Likewise.
(ia64_access_rse_reg): Likewise.
(ia64_libunwind_frame_prev_register): Likewise.
(ia64_extract_return_value): Likewise.
(ia64_store_return_value): Likewise.
(ia64_push_dummy_call): Likewise.
* ia64-tdep.h: Add IA64_MAX_REGISTER_SIZE
Comments
Alan Hayward <Alan.Hayward@arm.com> writes:
Hi Alan,
We have to define such macro if we have no other ways to remove
MAX_REGISTER_SIZE. AFAIK, there are some ways to remove many usages of
MAX_REGISTER_SIZE.
> @@ -1516,7 +1516,7 @@ examine_prologue (CORE_ADDR pc, CORE_ADDR lim_pc,
> else if (qp == 0 && rN == 2
> && ((rM == fp_reg && fp_reg != 0) || rM == 12))
> {
> - gdb_byte buf[MAX_REGISTER_SIZE];
> + gdb_byte buf[IA64_MAX_REGISTER_SIZE];
> CORE_ADDR saved_sp = 0;
> /* adds r2, spilloffset, rFramePointer
> or
"buf" is used in the code below,
get_frame_register (this_frame, sp_regnum, buf);
saved_sp = extract_unsigned_integer (buf, 8, byte_order);
why don't we use get_frame_register_unsigned, so the "buf" can be
removed completely.
saved_sp = get_frame_register_unsigned (this_frame, sp_regnum);
> @@ -2289,7 +2289,7 @@ static struct value *
> ia64_sigtramp_frame_prev_register (struct frame_info *this_frame,
> void **this_cache, int regnum)
> {
> - gdb_byte buf[MAX_REGISTER_SIZE];
> + gdb_byte buf[IA64_MAX_REGISTER_SIZE];
>
"buf" is used in the code below,
read_memory (addr, buf, register_size (gdbarch, IA64_IP_REGNUM));
pc = extract_unsigned_integer (buf, 8, byte_order);
so it is for IP register. Its size is 8-byte, so we can move "buf"
here,
gdb_byte buf[8];
read_memory (addr, buf, register_size (gdbarch, IA64_IP_REGNUM));
pc = extract_unsigned_integer (buf, sizeof (buf), byte_order);
> struct gdbarch *gdbarch = get_frame_arch (this_frame);
> enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> @@ -2495,7 +2495,7 @@ ia64_access_reg (unw_addr_space_t as, unw_regnum_t uw_regnum, unw_word_t *val,
> struct gdbarch *gdbarch = get_frame_arch (this_frame);
> enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> long new_sof, old_sof;
> - gdb_byte buf[MAX_REGISTER_SIZE];
> + gdb_byte buf[IA64_MAX_REGISTER_SIZE];
>
Use get_frame_register_{,un}signed, so we can remove "buf" completely.
> /* We never call any libunwind routines that need to write registers. */
> gdb_assert (!write);
> @@ -2575,7 +2575,7 @@ ia64_access_rse_reg (unw_addr_space_t as, unw_regnum_t uw_regnum,
> struct gdbarch *gdbarch = get_regcache_arch (regcache);
> enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> long new_sof, old_sof;
> - gdb_byte buf[MAX_REGISTER_SIZE];
> + gdb_byte buf[IA64_MAX_REGISTER_SIZE];
>
"buf" is used
regcache_cooked_read (regcache, IA64_IP_REGNUM, buf);
ip = extract_unsigned_integer (buf, 8, byte_order);
so we can use regcache_cooked_read_unsigned,
regcache_cooked_read_unsigned (regcache, IA64_IP_REGNUM, &ip);
> /* We never call any libunwind routines that need to write registers. */
> gdb_assert (!write);
> @@ -2982,7 +2982,7 @@ ia64_libunwind_frame_prev_register (struct frame_info *this_frame,
> {
> int rrb_pr = 0;
> ULONGEST cfm;
> - gdb_byte buf[MAX_REGISTER_SIZE];
> + gdb_byte buf[IA64_MAX_REGISTER_SIZE];
>
Use get_frame_register_unsigned.
> /* Fetch predicate register rename base from current frame
> marker for this frame. */
The only leftover of MAX_REGISTER_SIZE is about floating type
conversion, in ia64_register_to_value, ia64_push_dummy_call, etc. Then,
we can define an macro for the size of floating types, and replace
MAX_REGISTER_SIZE with it.
@@ -199,6 +199,9 @@
#define IA64_NAT32_REGNUM (IA64_NAT0_REGNUM + 32)
#define IA64_NAT127_REGNUM (IA64_NAT0_REGNUM + 127)
+/* Big enough to hold the size of the largest register in bytes. */
+#define IA64_MAX_REGISTER_SIZE 16
+
struct frame_info;
struct regcache;
@@ -1227,7 +1227,7 @@ ia64_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[IA64_MAX_REGISTER_SIZE];
/* Convert to TYPE. */
if (!get_frame_register_bytes (frame, regnum, 0,
@@ -1245,7 +1245,7 @@ ia64_value_to_register (struct frame_info *frame, int regnum,
struct type *valtype, const gdb_byte *in)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
- gdb_byte out[MAX_REGISTER_SIZE];
+ gdb_byte out[IA64_MAX_REGISTER_SIZE];
convert_typed_floating (in, valtype, out, ia64_ext_type (gdbarch));
put_frame_register (frame, regnum, out);
}
@@ -1516,7 +1516,7 @@ examine_prologue (CORE_ADDR pc, CORE_ADDR lim_pc,
else if (qp == 0 && rN == 2
&& ((rM == fp_reg && fp_reg != 0) || rM == 12))
{
- gdb_byte buf[MAX_REGISTER_SIZE];
+ gdb_byte buf[IA64_MAX_REGISTER_SIZE];
CORE_ADDR saved_sp = 0;
/* adds r2, spilloffset, rFramePointer
or
@@ -2289,7 +2289,7 @@ static struct value *
ia64_sigtramp_frame_prev_register (struct frame_info *this_frame,
void **this_cache, int regnum)
{
- gdb_byte buf[MAX_REGISTER_SIZE];
+ gdb_byte buf[IA64_MAX_REGISTER_SIZE];
struct gdbarch *gdbarch = get_frame_arch (this_frame);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -2495,7 +2495,7 @@ ia64_access_reg (unw_addr_space_t as, unw_regnum_t uw_regnum, unw_word_t *val,
struct gdbarch *gdbarch = get_frame_arch (this_frame);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
long new_sof, old_sof;
- gdb_byte buf[MAX_REGISTER_SIZE];
+ gdb_byte buf[IA64_MAX_REGISTER_SIZE];
/* We never call any libunwind routines that need to write registers. */
gdb_assert (!write);
@@ -2575,7 +2575,7 @@ ia64_access_rse_reg (unw_addr_space_t as, unw_regnum_t uw_regnum,
struct gdbarch *gdbarch = get_regcache_arch (regcache);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
long new_sof, old_sof;
- gdb_byte buf[MAX_REGISTER_SIZE];
+ gdb_byte buf[IA64_MAX_REGISTER_SIZE];
/* We never call any libunwind routines that need to write registers. */
gdb_assert (!write);
@@ -2982,7 +2982,7 @@ ia64_libunwind_frame_prev_register (struct frame_info *this_frame,
{
int rrb_pr = 0;
ULONGEST cfm;
- gdb_byte buf[MAX_REGISTER_SIZE];
+ gdb_byte buf[IA64_MAX_REGISTER_SIZE];
/* Fetch predicate register rename base from current frame
marker for this frame. */
@@ -3229,7 +3229,7 @@ ia64_extract_return_value (struct type *type, struct regcache *regcache,
float_elt_type = is_float_or_hfa_type (type);
if (float_elt_type != NULL)
{
- gdb_byte from[MAX_REGISTER_SIZE];
+ gdb_byte from[IA64_MAX_REGISTER_SIZE];
int offset = 0;
int regnum = IA64_FR8_REGNUM;
int n = TYPE_LENGTH (type) / TYPE_LENGTH (float_elt_type);
@@ -3294,7 +3294,7 @@ ia64_store_return_value (struct type *type, struct regcache *regcache,
float_elt_type = is_float_or_hfa_type (type);
if (float_elt_type != NULL)
{
- gdb_byte to[MAX_REGISTER_SIZE];
+ gdb_byte to[IA64_MAX_REGISTER_SIZE];
int offset = 0;
int regnum = IA64_FR8_REGNUM;
int n = TYPE_LENGTH (type) / TYPE_LENGTH (float_elt_type);
@@ -3856,7 +3856,7 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
len = TYPE_LENGTH (type);
while (len > 0 && floatreg < IA64_FR16_REGNUM)
{
- gdb_byte to[MAX_REGISTER_SIZE];
+ gdb_byte to[IA64_MAX_REGISTER_SIZE];
convert_typed_floating (value_contents (arg) + argoffset,
float_elt_type, to,
ia64_ext_type (gdbarch));