X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gdb%2Fxtensa-tdep.c;h=efa0bcb1dc3ba05cd037874aa2431d060873aa3f;hb=d7a11d1383a2d0cdffc8c08e46b0cf5a66b3ce28;hp=a1ecf5f56a429a28dae3470fe3e17f483a17235f;hpb=849d0ba802323fe05e3039ed5b22957db2c85a67;p=external%2Fbinutils.git diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c index a1ecf5f..efa0bcb 100644 --- a/gdb/xtensa-tdep.c +++ b/gdb/xtensa-tdep.c @@ -1,6 +1,6 @@ /* Target-dependent code for the Xtensa port of GDB, the GNU debugger. - Copyright (C) 2003-2018 Free Software Foundation, Inc. + Copyright (C) 2003-2019 Free Software Foundation, Inc. This file is part of GDB. @@ -234,9 +234,7 @@ xtensa_find_register_by_name (struct gdbarch *gdbarch, const char *name) { int i; - for (i = 0; i < gdbarch_num_regs (gdbarch) - + gdbarch_num_pseudo_regs (gdbarch); - i++) + for (i = 0; i < gdbarch_num_cooked_regs (gdbarch); i++) if (strcasecmp (gdbarch_tdep (gdbarch)->regmap[i].name, name) == 0) return i; @@ -249,8 +247,7 @@ static const char * xtensa_register_name (struct gdbarch *gdbarch, int regnum) { /* Return the name stored in the register map. */ - if (regnum >= 0 && regnum < gdbarch_num_regs (gdbarch) - + gdbarch_num_pseudo_regs (gdbarch)) + if (regnum >= 0 && regnum < gdbarch_num_cooked_regs (gdbarch)) return gdbarch_tdep (gdbarch)->regmap[regnum].name; internal_error (__FILE__, __LINE__, _("invalid register %d"), regnum); @@ -276,8 +273,7 @@ xtensa_register_type (struct gdbarch *gdbarch, int regnum) return builtin_type (gdbarch)->builtin_data_ptr; /* Return the stored type for all other registers. */ - else if (regnum >= 0 && regnum < gdbarch_num_regs (gdbarch) - + gdbarch_num_pseudo_regs (gdbarch)) + else if (regnum >= 0 && regnum < gdbarch_num_cooked_regs (gdbarch)) { xtensa_register_t* reg = &tdep->regmap[regnum]; @@ -319,15 +315,14 @@ xtensa_register_type (struct gdbarch *gdbarch, int regnum) if (tp == NULL) { - char *name = xstrprintf ("int%d", size * 8); + std::string name = string_printf ("int%d", size * 8); tp = XNEW (struct ctype_cache); tp->next = tdep->type_entries; tdep->type_entries = tp; tp->size = size; tp->virtual_type - = arch_integer_type (gdbarch, size * 8, 1, name); - xfree (name); + = arch_integer_type (gdbarch, size * 8, 1, name.c_str ()); } reg->ctype = tp->virtual_type; @@ -353,9 +348,7 @@ xtensa_reg_to_regnum (struct gdbarch *gdbarch, int regnum) if (regnum >= 0 && regnum < 16) return gdbarch_tdep (gdbarch)->a0_base + regnum; - for (i = 0; - i < gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch); - i++) + for (i = 0; i < gdbarch_num_cooked_regs (gdbarch); i++) if (regnum == gdbarch_tdep (gdbarch)->regmap[i].target_number) return i; @@ -586,9 +579,7 @@ xtensa_pseudo_register_read (struct gdbarch *gdbarch, return REG_VALID; } /* Pseudo registers. */ - else if (regnum >= 0 - && regnum < gdbarch_num_regs (gdbarch) - + gdbarch_num_pseudo_regs (gdbarch)) + else if (regnum >= 0 && regnum < gdbarch_num_cooked_regs (gdbarch)) { xtensa_register_t *reg = &gdbarch_tdep (gdbarch)->regmap[regnum]; xtensa_register_type_t type = reg->type; @@ -661,7 +652,7 @@ xtensa_pseudo_register_write (struct gdbarch *gdbarch, /* We can always write 'core' registers. Note: We might have converted Ax->ARy. */ if (regnum >= 0 && regnum < gdbarch_num_regs (gdbarch)) - regcache_raw_write (regcache, regnum, buffer); + regcache->raw_write (regnum, buffer); /* We have to find out how to deal with priveleged registers. Let's treat them as pseudo-registers, but we cannot read/write them. */ @@ -671,9 +662,7 @@ xtensa_pseudo_register_write (struct gdbarch *gdbarch, return; } /* Pseudo registers. */ - else if (regnum >= 0 - && regnum < gdbarch_num_regs (gdbarch) - + gdbarch_num_pseudo_regs (gdbarch)) + else if (regnum >= 0 && regnum < gdbarch_num_cooked_regs (gdbarch)) { xtensa_register_t *reg = &gdbarch_tdep (gdbarch)->regmap[regnum]; xtensa_register_type_t type = reg->type; @@ -718,7 +707,7 @@ xtensa_pseudo_register_write (struct gdbarch *gdbarch, } /* Assume that we can write the register. */ - regcache_raw_write (regcache, regnum, buffer); + regcache->raw_write (regnum, buffer); } else internal_error (__FILE__, __LINE__, @@ -848,38 +837,37 @@ xtensa_supply_gregset (const struct regset *regset, DEBUGTRACE ("xtensa_supply_gregset (..., regnum==%d, ...)\n", regnum); if (regnum == gdbarch_pc_regnum (gdbarch) || regnum == -1) - regcache_raw_supply (rc, gdbarch_pc_regnum (gdbarch), (char *) ®s->pc); + rc->raw_supply (gdbarch_pc_regnum (gdbarch), (char *) ®s->pc); if (regnum == gdbarch_ps_regnum (gdbarch) || regnum == -1) - regcache_raw_supply (rc, gdbarch_ps_regnum (gdbarch), (char *) ®s->ps); + rc->raw_supply (gdbarch_ps_regnum (gdbarch), (char *) ®s->ps); if (regnum == gdbarch_tdep (gdbarch)->wb_regnum || regnum == -1) - regcache_raw_supply (rc, gdbarch_tdep (gdbarch)->wb_regnum, - (char *) ®s->windowbase); + rc->raw_supply (gdbarch_tdep (gdbarch)->wb_regnum, + (char *) ®s->windowbase); if (regnum == gdbarch_tdep (gdbarch)->ws_regnum || regnum == -1) - regcache_raw_supply (rc, gdbarch_tdep (gdbarch)->ws_regnum, - (char *) ®s->windowstart); + rc->raw_supply (gdbarch_tdep (gdbarch)->ws_regnum, + (char *) ®s->windowstart); if (regnum == gdbarch_tdep (gdbarch)->lbeg_regnum || regnum == -1) - regcache_raw_supply (rc, gdbarch_tdep (gdbarch)->lbeg_regnum, - (char *) ®s->lbeg); + rc->raw_supply (gdbarch_tdep (gdbarch)->lbeg_regnum, + (char *) ®s->lbeg); if (regnum == gdbarch_tdep (gdbarch)->lend_regnum || regnum == -1) - regcache_raw_supply (rc, gdbarch_tdep (gdbarch)->lend_regnum, - (char *) ®s->lend); + rc->raw_supply (gdbarch_tdep (gdbarch)->lend_regnum, + (char *) ®s->lend); if (regnum == gdbarch_tdep (gdbarch)->lcount_regnum || regnum == -1) - regcache_raw_supply (rc, gdbarch_tdep (gdbarch)->lcount_regnum, - (char *) ®s->lcount); + rc->raw_supply (gdbarch_tdep (gdbarch)->lcount_regnum, + (char *) ®s->lcount); if (regnum == gdbarch_tdep (gdbarch)->sar_regnum || regnum == -1) - regcache_raw_supply (rc, gdbarch_tdep (gdbarch)->sar_regnum, - (char *) ®s->sar); + rc->raw_supply (gdbarch_tdep (gdbarch)->sar_regnum, + (char *) ®s->sar); if (regnum >=gdbarch_tdep (gdbarch)->ar_base && regnum < gdbarch_tdep (gdbarch)->ar_base + gdbarch_tdep (gdbarch)->num_aregs) - regcache_raw_supply (rc, regnum, - (char *) ®s->ar[regnum - gdbarch_tdep - (gdbarch)->ar_base]); + rc->raw_supply + (regnum, (char *) ®s->ar[regnum - gdbarch_tdep (gdbarch)->ar_base]); else if (regnum == -1) { for (i = 0; i < gdbarch_tdep (gdbarch)->num_aregs; ++i) - regcache_raw_supply (rc, gdbarch_tdep (gdbarch)->ar_base + i, - (char *) ®s->ar[i]); + rc->raw_supply (gdbarch_tdep (gdbarch)->ar_base + i, + (char *) ®s->ar[i]); } } @@ -904,8 +892,8 @@ xtensa_iterate_over_regset_sections (struct gdbarch *gdbarch, { DEBUGTRACE ("xtensa_iterate_over_regset_sections\n"); - cb (".reg", sizeof (xtensa_elf_gregset_t), &xtensa_gregset, - NULL, cb_data); + cb (".reg", sizeof (xtensa_elf_gregset_t), sizeof (xtensa_elf_gregset_t), + &xtensa_gregset, NULL, cb_data); } @@ -1596,9 +1584,9 @@ xtensa_extract_return_value (struct type *type, for (; len > 0; len -= 4, areg++, valbuf += 4) { if (len < 4) - regcache_raw_read_part (regcache, areg, offset, len, valbuf); + regcache->raw_read_part (areg, offset, len, valbuf); else - regcache_raw_read (regcache, areg, valbuf); + regcache->raw_read (areg, valbuf); } } @@ -1627,8 +1615,8 @@ xtensa_store_return_value (struct type *type, if (len > (callsize > 8 ? 8 : 16)) internal_error (__FILE__, __LINE__, - _("unimplemented for this length: %d"), - TYPE_LENGTH (type)); + _("unimplemented for this length: %s"), + pulongest (TYPE_LENGTH (type))); areg = arreg_number (gdbarch, gdbarch_tdep (gdbarch)->a0_base + 2 + callsize, wb); @@ -1646,9 +1634,9 @@ xtensa_store_return_value (struct type *type, for (; len > 0; len -= 4, areg++, valbuf += 4) { if (len < 4) - regcache_raw_write_part (regcache, areg, offset, len, valbuf); + regcache->raw_write_part (areg, offset, len, valbuf); else - regcache_raw_write (regcache, areg, valbuf); + regcache->raw_write (areg, valbuf); } } @@ -1697,11 +1685,10 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, int nargs, struct value **args, CORE_ADDR sp, - int struct_return, + function_call_return_method return_method, CORE_ADDR struct_addr) { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - int i; int size, onstack_size; gdb_byte *buf = (gdb_byte *) alloca (16); CORE_ADDR ra, ps; @@ -1727,19 +1714,18 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, if (xtensa_debug_level > 3) { - int i; DEBUGINFO ("[xtensa_push_dummy_call] nargs = %d\n", nargs); - DEBUGINFO ("[xtensa_push_dummy_call] sp=0x%x, struct_return=%d, " + DEBUGINFO ("[xtensa_push_dummy_call] sp=0x%x, return_method=%d, " "struct_addr=0x%x\n", - (int) sp, (int) struct_return, (int) struct_addr); + (int) sp, (int) return_method, (int) struct_addr); - for (i = 0; i < nargs; i++) + for (int i = 0; i < nargs; i++) { struct value *arg = args[i]; struct type *arg_type = check_typedef (value_type (arg)); - fprintf_unfiltered (gdb_stdlog, "%2d: %s %3d ", i, + fprintf_unfiltered (gdb_stdlog, "%2d: %s %3s ", i, host_address_to_string (arg), - TYPE_LENGTH (arg_type)); + pulongest (TYPE_LENGTH (arg_type))); switch (TYPE_CODE (arg_type)) { case TYPE_CODE_INT: @@ -1764,12 +1750,11 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, size = 0; onstack_size = 0; - i = 0; - if (struct_return) + if (return_method == return_method_struct) size = REGISTER_SIZE; - for (i = 0; i < nargs; i++) + for (int i = 0; i < nargs; i++) { struct argument_info *info = &arg_info[i]; struct value *arg = args[i]; @@ -1843,13 +1828,13 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, /* Second Loop: Load arguments. */ - if (struct_return) + if (return_method == return_method_struct) { store_unsigned_integer (buf, REGISTER_SIZE, byte_order, struct_addr); - regcache_cooked_write (regcache, ARG_1ST (gdbarch), buf); + regcache->cooked_write (ARG_1ST (gdbarch), buf); } - for (i = 0; i < nargs; i++) + for (int i = 0; i < nargs; i++) { struct argument_info *info = &arg_info[i]; @@ -1888,7 +1873,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, v = v >> ((REGISTER_SIZE - n) * TARGET_CHAR_BIT); store_unsigned_integer (buf, REGISTER_SIZE, byte_order, v); - regcache_cooked_write (regcache, r, buf); + regcache->cooked_write (r, buf); cp += REGISTER_SIZE; n -= REGISTER_SIZE; @@ -1897,7 +1882,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, else while (n > 0) { - regcache_cooked_write (regcache, r, cp); + regcache->cooked_write (r, cp); cp += REGISTER_SIZE; n -= REGISTER_SIZE; @@ -1928,7 +1913,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, to modify WINDOWSTART register to make it look like there is only one register window corresponding to WINDOWEBASE. */ - regcache_raw_read (regcache, gdbarch_tdep (gdbarch)->wb_regnum, buf); + regcache->raw_read (gdbarch_tdep (gdbarch)->wb_regnum, buf); regcache_cooked_write_unsigned (regcache, gdbarch_tdep (gdbarch)->ws_regnum, 1 << extract_unsigned_integer (buf, 4, byte_order)); @@ -3145,16 +3130,12 @@ xtensa_derive_tdep (struct gdbarch_tdep *tdep) max_size = rmap->byte_size; if (rmap->mask != 0 && tdep->num_regs == 0) tdep->num_regs = n; - /* Find out out how to deal with priveleged registers. - - if ((rmap->flags & XTENSA_REGISTER_FLAGS_PRIVILEGED) != 0 - && tdep->num_nopriv_regs == 0) - tdep->num_nopriv_regs = n; - */ if ((rmap->flags & XTENSA_REGISTER_FLAGS_PRIVILEGED) != 0 - && tdep->num_regs == 0) - tdep->num_regs = n; + && tdep->num_nopriv_regs == 0) + tdep->num_nopriv_regs = n; } + if (tdep->num_regs == 0) + tdep->num_regs = tdep->num_nopriv_regs; /* Number of pseudo registers. */ tdep->num_pseudo_regs = n - tdep->num_regs;