X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fsparc64-tdep.c;h=3cd6109f90a7d3977127e190fe82bedd6eaf659a;hb=25b41d01eaa6f8f68491ef2eb65ca403907269f7;hp=d1b04d7d01a08ff01afe90faffb99157d2de8a8c;hpb=df4df182b49ab6808495f557d3727b8dfd4b98da;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c index d1b04d7d01..3cd6109f90 100644 --- a/gdb/sparc64-tdep.c +++ b/gdb/sparc64-tdep.c @@ -1,6 +1,6 @@ /* Target-dependent code for UltraSPARC. - Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 + Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of GDB. @@ -103,7 +103,11 @@ sparc64_floating_p (const struct type *type) return 0; } -/* Check whether TYPE is "Structure or Union". */ +/* Check whether TYPE is "Structure or Union". + + In terms of Ada subprogram calls, arrays are treated the same as + struct and union types. So this function also returns non-zero + for array types. */ static int sparc64_structure_or_union_p (const struct type *type) @@ -112,6 +116,7 @@ sparc64_structure_or_union_p (const struct type *type) { case TYPE_CODE_STRUCT: case TYPE_CODE_UNION: + case TYPE_CODE_ARRAY: return 1; default: break; @@ -121,61 +126,89 @@ sparc64_structure_or_union_p (const struct type *type) } -/* Type for %pstate. */ -struct type *sparc64_pstate_type; +/* Construct types for ISA-specific registers. */ -/* Type for %fsr. */ -struct type *sparc64_fsr_type; +static struct type * +sparc64_pstate_type (struct gdbarch *gdbarch) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); -/* Type for %fprs. */ -struct type *sparc64_fprs_type; + if (!tdep->sparc64_pstate_type) + { + struct type *type; + + type = arch_flags_type (gdbarch, "builtin_type_sparc64_pstate", 8); + append_flags_type_flag (type, 0, "AG"); + append_flags_type_flag (type, 1, "IE"); + append_flags_type_flag (type, 2, "PRIV"); + append_flags_type_flag (type, 3, "AM"); + append_flags_type_flag (type, 4, "PEF"); + append_flags_type_flag (type, 5, "RED"); + append_flags_type_flag (type, 8, "TLE"); + append_flags_type_flag (type, 9, "CLE"); + append_flags_type_flag (type, 10, "PID0"); + append_flags_type_flag (type, 11, "PID1"); + + tdep->sparc64_pstate_type = type; + } -/* Construct types for ISA-specific registers. */ + return tdep->sparc64_pstate_type; +} -static void -sparc64_init_types (void) +static struct type * +sparc64_fsr_type (struct gdbarch *gdbarch) { - struct type *type; - - type = init_flags_type ("builtin_type_sparc64_pstate", 8); - append_flags_type_flag (type, 0, "AG"); - append_flags_type_flag (type, 1, "IE"); - append_flags_type_flag (type, 2, "PRIV"); - append_flags_type_flag (type, 3, "AM"); - append_flags_type_flag (type, 4, "PEF"); - append_flags_type_flag (type, 5, "RED"); - append_flags_type_flag (type, 8, "TLE"); - append_flags_type_flag (type, 9, "CLE"); - append_flags_type_flag (type, 10, "PID0"); - append_flags_type_flag (type, 11, "PID1"); - sparc64_pstate_type = type; - - type = init_flags_type ("builtin_type_sparc64_fsr", 8); - append_flags_type_flag (type, 0, "NXA"); - append_flags_type_flag (type, 1, "DZA"); - append_flags_type_flag (type, 2, "UFA"); - append_flags_type_flag (type, 3, "OFA"); - append_flags_type_flag (type, 4, "NVA"); - append_flags_type_flag (type, 5, "NXC"); - append_flags_type_flag (type, 6, "DZC"); - append_flags_type_flag (type, 7, "UFC"); - append_flags_type_flag (type, 8, "OFC"); - append_flags_type_flag (type, 9, "NVC"); - append_flags_type_flag (type, 22, "NS"); - append_flags_type_flag (type, 23, "NXM"); - append_flags_type_flag (type, 24, "DZM"); - append_flags_type_flag (type, 25, "UFM"); - append_flags_type_flag (type, 26, "OFM"); - append_flags_type_flag (type, 27, "NVM"); - sparc64_fsr_type = type; - - type = init_flags_type ("builtin_type_sparc64_fprs", 8); - append_flags_type_flag (type, 0, "DL"); - append_flags_type_flag (type, 1, "DU"); - append_flags_type_flag (type, 2, "FEF"); - sparc64_fprs_type = type; + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + if (!tdep->sparc64_fsr_type) + { + struct type *type; + + type = arch_flags_type (gdbarch, "builtin_type_sparc64_fsr", 8); + append_flags_type_flag (type, 0, "NXA"); + append_flags_type_flag (type, 1, "DZA"); + append_flags_type_flag (type, 2, "UFA"); + append_flags_type_flag (type, 3, "OFA"); + append_flags_type_flag (type, 4, "NVA"); + append_flags_type_flag (type, 5, "NXC"); + append_flags_type_flag (type, 6, "DZC"); + append_flags_type_flag (type, 7, "UFC"); + append_flags_type_flag (type, 8, "OFC"); + append_flags_type_flag (type, 9, "NVC"); + append_flags_type_flag (type, 22, "NS"); + append_flags_type_flag (type, 23, "NXM"); + append_flags_type_flag (type, 24, "DZM"); + append_flags_type_flag (type, 25, "UFM"); + append_flags_type_flag (type, 26, "OFM"); + append_flags_type_flag (type, 27, "NVM"); + + tdep->sparc64_fsr_type = type; + } + + return tdep->sparc64_fsr_type; } +static struct type * +sparc64_fprs_type (struct gdbarch *gdbarch) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + if (!tdep->sparc64_fprs_type) + { + struct type *type; + + type = arch_flags_type (gdbarch, "builtin_type_sparc64_fprs", 8); + append_flags_type_flag (type, 0, "DL"); + append_flags_type_flag (type, 1, "DU"); + append_flags_type_flag (type, 2, "FEF"); + + tdep->sparc64_fprs_type = type; + } + + return tdep->sparc64_fprs_type; +} + + /* Register information. */ static const char *sparc64_register_names[] = @@ -261,9 +294,9 @@ sparc64_register_type (struct gdbarch *gdbarch, int regnum) if (regnum == SPARC64_STATE_REGNUM) return builtin_type (gdbarch)->builtin_int64; if (regnum == SPARC64_FSR_REGNUM) - return sparc64_fsr_type; + return sparc64_fsr_type (gdbarch); if (regnum == SPARC64_FPRS_REGNUM) - return sparc64_fprs_type; + return sparc64_fprs_type (gdbarch); /* "Although Y is a 64-bit register, its high-order 32 bits are reserved and always read as 0." */ if (regnum == SPARC64_Y_REGNUM) @@ -274,7 +307,7 @@ sparc64_register_type (struct gdbarch *gdbarch, int regnum) if (regnum == SPARC64_CWP_REGNUM) return builtin_type (gdbarch)->builtin_int64; if (regnum == SPARC64_PSTATE_REGNUM) - return sparc64_pstate_type; + return sparc64_pstate_type (gdbarch); if (regnum == SPARC64_ASI_REGNUM) return builtin_type (gdbarch)->builtin_int64; if (regnum == SPARC64_CCR_REGNUM) @@ -292,6 +325,7 @@ sparc64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache, int regnum, gdb_byte *buf) { + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); gdb_assert (regnum >= SPARC64_NUM_REGS); if (regnum >= SPARC64_D0_REGNUM && regnum <= SPARC64_D30_REGNUM) @@ -342,7 +376,7 @@ sparc64_pseudo_register_read (struct gdbarch *gdbarch, state = (state >> 32) & ((1 << 8) - 1); break; } - store_unsigned_integer (buf, 8, state); + store_unsigned_integer (buf, 8, byte_order, state); } } @@ -351,6 +385,7 @@ sparc64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, int regnum, const gdb_byte *buf) { + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); gdb_assert (regnum >= SPARC64_NUM_REGS); if (regnum >= SPARC64_D0_REGNUM && regnum <= SPARC64_D30_REGNUM) @@ -386,7 +421,7 @@ sparc64_pseudo_register_write (struct gdbarch *gdbarch, ULONGEST state, bits; regcache_raw_read_unsigned (regcache, SPARC64_STATE_REGNUM, &state); - bits = extract_unsigned_integer (buf, 8); + bits = extract_unsigned_integer (buf, 8, byte_order); switch (regnum) { case SPARC64_CWP_REGNUM: @@ -458,6 +493,7 @@ static struct value * sparc64_frame_prev_register (struct frame_info *this_frame, void **this_cache, int regnum) { + struct gdbarch *gdbarch = get_frame_arch (this_frame); struct sparc_frame_cache *cache = sparc64_frame_cache (this_frame, this_cache); @@ -472,7 +508,7 @@ sparc64_frame_prev_register (struct frame_info *this_frame, void **this_cache, /* Handle StackGhost. */ { - ULONGEST wcookie = sparc_fetch_wcookie (); + ULONGEST wcookie = sparc_fetch_wcookie (gdbarch); if (wcookie != 0 && !cache->frameless_p && regnum == SPARC_I7_REGNUM) { @@ -1138,7 +1174,9 @@ sparc64_supply_gregset (const struct sparc_gregset *gregset, struct regcache *regcache, int regnum, const void *gregs) { - int sparc32 = (gdbarch_ptr_bit (get_regcache_arch (regcache)) == 32); + struct gdbarch *gdbarch = get_regcache_arch (regcache); + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + int sparc32 = (gdbarch_ptr_bit (gdbarch) == 32); const gdb_byte *regs = gregs; int i; @@ -1150,10 +1188,10 @@ sparc64_supply_gregset (const struct sparc_gregset *gregset, ULONGEST tstate, psr; gdb_byte buf[4]; - tstate = extract_unsigned_integer (regs + offset, 8); + tstate = extract_unsigned_integer (regs + offset, 8, byte_order); psr = ((tstate & TSTATE_CWP) | PSR_S | ((tstate & TSTATE_ICC) >> 12) | ((tstate & TSTATE_XCC) >> 20) | PSR_V8PLUS); - store_unsigned_integer (buf, 4, psr); + store_unsigned_integer (buf, 4, byte_order, psr); regcache_raw_supply (regcache, SPARC32_PSR_REGNUM, buf); } @@ -1252,7 +1290,9 @@ sparc64_collect_gregset (const struct sparc_gregset *gregset, const struct regcache *regcache, int regnum, void *gregs) { - int sparc32 = (gdbarch_ptr_bit (get_regcache_arch (regcache)) == 32); + struct gdbarch *gdbarch = get_regcache_arch (regcache); + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + int sparc32 = (gdbarch_ptr_bit (gdbarch) == 32); gdb_byte *regs = gregs; int i; @@ -1264,13 +1304,13 @@ sparc64_collect_gregset (const struct sparc_gregset *gregset, ULONGEST tstate, psr; gdb_byte buf[8]; - tstate = extract_unsigned_integer (regs + offset, 8); + tstate = extract_unsigned_integer (regs + offset, 8, byte_order); regcache_raw_collect (regcache, SPARC32_PSR_REGNUM, buf); - psr = extract_unsigned_integer (buf, 4); + psr = extract_unsigned_integer (buf, 4, byte_order); tstate |= (psr & PSR_ICC) << 12; if ((psr & (PSR_VERS | PSR_IMPL)) == PSR_V8PLUS) tstate |= (psr & PSR_XCC) << 20; - store_unsigned_integer (buf, 8, tstate); + store_unsigned_integer (buf, 8, byte_order, tstate); memcpy (regs + offset, buf, 8); } @@ -1425,13 +1465,3 @@ sparc64_collect_fpregset (const struct regcache *regcache, } } - -/* Provide a prototype to silence -Wmissing-prototypes. */ -void _initialize_sparc64_tdep (void); - -void -_initialize_sparc64_tdep (void) -{ - /* Initialize the UltraSPARC-specific register types. */ - sparc64_init_types(); -}