X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fsh-tdep.c;h=fe64cf979a01d0d1036a73635347c9edaf7cf02c;hb=e98ee8c458f3a8405eb93e71b00f801b4bbe3635;hp=51a846b0d7df5f492df0d22d5841eeaed8c86e5b;hpb=cd6c3b4ffc4ea6f56f12581419e2eed885441beb;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c index 51a846b0d7..fe64cf979a 100644 --- a/gdb/sh-tdep.c +++ b/gdb/sh-tdep.c @@ -1,6 +1,6 @@ /* Target-dependent code for Renesas Super-H, for GDB. - Copyright (C) 1993-2016 Free Software Foundation, Inc. + Copyright (C) 1993-2018 Free Software Foundation, Inc. This file is part of GDB. @@ -33,16 +33,14 @@ #include "dis-asm.h" #include "inferior.h" #include "arch-utils.h" -#include "floatformat.h" #include "regcache.h" -#include "doublest.h" +#include "target-float.h" #include "osabi.h" #include "reggroups.h" #include "regset.h" #include "objfiles.h" #include "sh-tdep.h" -#include "sh64-tdep.h" #include "elf-bfd.h" #include "solib-svr4.h" @@ -111,7 +109,7 @@ sh_is_renesas_calling_convention (struct type *func_type) static const char * sh_sh_register_name (struct gdbarch *gdbarch, int reg_nr) { - static char *register_names[] = { + static const char *register_names[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "pc", "pr", "gbr", "vbr", "mach", "macl", "sr", @@ -133,7 +131,7 @@ sh_sh_register_name (struct gdbarch *gdbarch, int reg_nr) static const char * sh_sh3_register_name (struct gdbarch *gdbarch, int reg_nr) { - static char *register_names[] = { + static const char *register_names[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "pc", "pr", "gbr", "vbr", "mach", "macl", "sr", @@ -155,7 +153,7 @@ sh_sh3_register_name (struct gdbarch *gdbarch, int reg_nr) static const char * sh_sh3e_register_name (struct gdbarch *gdbarch, int reg_nr) { - static char *register_names[] = { + static const char *register_names[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "pc", "pr", "gbr", "vbr", "mach", "macl", "sr", @@ -177,7 +175,7 @@ sh_sh3e_register_name (struct gdbarch *gdbarch, int reg_nr) static const char * sh_sh2e_register_name (struct gdbarch *gdbarch, int reg_nr) { - static char *register_names[] = { + static const char *register_names[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "pc", "pr", "gbr", "vbr", "mach", "macl", "sr", @@ -199,7 +197,7 @@ sh_sh2e_register_name (struct gdbarch *gdbarch, int reg_nr) static const char * sh_sh2a_register_name (struct gdbarch *gdbarch, int reg_nr) { - static char *register_names[] = { + static const char *register_names[] = { /* general registers 0-15 */ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", @@ -239,7 +237,7 @@ sh_sh2a_register_name (struct gdbarch *gdbarch, int reg_nr) static const char * sh_sh2a_nofpu_register_name (struct gdbarch *gdbarch, int reg_nr) { - static char *register_names[] = { + static const char *register_names[] = { /* general registers 0-15 */ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", @@ -279,7 +277,7 @@ sh_sh2a_nofpu_register_name (struct gdbarch *gdbarch, int reg_nr) static const char * sh_sh_dsp_register_name (struct gdbarch *gdbarch, int reg_nr) { - static char *register_names[] = { + static const char *register_names[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "pc", "pr", "gbr", "vbr", "mach", "macl", "sr", @@ -301,7 +299,7 @@ sh_sh_dsp_register_name (struct gdbarch *gdbarch, int reg_nr) static const char * sh_sh3_dsp_register_name (struct gdbarch *gdbarch, int reg_nr) { - static char *register_names[] = { + static const char *register_names[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "pc", "pr", "gbr", "vbr", "mach", "macl", "sr", @@ -324,7 +322,7 @@ sh_sh3_dsp_register_name (struct gdbarch *gdbarch, int reg_nr) static const char * sh_sh4_register_name (struct gdbarch *gdbarch, int reg_nr) { - static char *register_names[] = { + static const char *register_names[] = { /* general registers 0-15 */ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", @@ -362,7 +360,7 @@ sh_sh4_register_name (struct gdbarch *gdbarch, int reg_nr) static const char * sh_sh4_nofpu_register_name (struct gdbarch *gdbarch, int reg_nr) { - static char *register_names[] = { + static const char *register_names[] = { /* general registers 0-15 */ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", @@ -398,7 +396,7 @@ sh_sh4_nofpu_register_name (struct gdbarch *gdbarch, int reg_nr) static const char * sh_sh4al_dsp_register_name (struct gdbarch *gdbarch, int reg_nr) { - static char *register_names[] = { + static const char *register_names[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "pc", "pr", "gbr", "vbr", "mach", "macl", "sr", @@ -454,8 +452,6 @@ sh_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size) } } -GDBARCH_BREAKPOINT_FROM_PC (sh) - /* Prologue looks like mov.l r14,@-r15 sts.l pr,@-r15 @@ -1313,7 +1309,7 @@ static void sh_extract_return_value_nofpu (struct type *type, struct regcache *regcache, gdb_byte *valbuf) { - struct gdbarch *gdbarch = get_regcache_arch (regcache); + struct gdbarch *gdbarch = regcache->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); int len = TYPE_LENGTH (type); @@ -1328,7 +1324,7 @@ sh_extract_return_value_nofpu (struct type *type, struct regcache *regcache, { int i, regnum = R0_REGNUM; for (i = 0; i < len; i += 4) - regcache_raw_read (regcache, regnum++, valbuf + i); + regcache->raw_read (regnum++, valbuf + i); } else error (_("bad size for return value")); @@ -1338,17 +1334,17 @@ static void sh_extract_return_value_fpu (struct type *type, struct regcache *regcache, gdb_byte *valbuf) { - struct gdbarch *gdbarch = get_regcache_arch (regcache); + struct gdbarch *gdbarch = regcache->arch (); if (sh_treat_as_flt_p (type)) { int len = TYPE_LENGTH (type); int i, regnum = gdbarch_fp0_regnum (gdbarch); for (i = 0; i < len; i += 4) if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE) - regcache_raw_read (regcache, regnum++, + regcache->raw_read (regnum++, valbuf + len - 4 - i); else - regcache_raw_read (regcache, regnum++, valbuf + i); + regcache->raw_read (regnum++, valbuf + i); } else sh_extract_return_value_nofpu (type, regcache, valbuf); @@ -1364,7 +1360,7 @@ static void sh_store_return_value_nofpu (struct type *type, struct regcache *regcache, const gdb_byte *valbuf) { - struct gdbarch *gdbarch = get_regcache_arch (regcache); + struct gdbarch *gdbarch = regcache->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); ULONGEST val; int len = TYPE_LENGTH (type); @@ -1378,7 +1374,7 @@ sh_store_return_value_nofpu (struct type *type, struct regcache *regcache, { int i, regnum = R0_REGNUM; for (i = 0; i < len; i += 4) - regcache_raw_write (regcache, regnum++, valbuf + i); + regcache->raw_write (regnum++, valbuf + i); } } @@ -1386,17 +1382,17 @@ static void sh_store_return_value_fpu (struct type *type, struct regcache *regcache, const gdb_byte *valbuf) { - struct gdbarch *gdbarch = get_regcache_arch (regcache); + struct gdbarch *gdbarch = regcache->arch (); if (sh_treat_as_flt_p (type)) { int len = TYPE_LENGTH (type); int i, regnum = gdbarch_fp0_regnum (gdbarch); for (i = 0; i < len; i += 4) if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE) - regcache_raw_write (regcache, regnum++, + regcache->raw_write (regnum++, valbuf + len - 4 - i); else - regcache_raw_write (regcache, regnum++, valbuf + i); + regcache->raw_write (regnum++, valbuf + i); } else sh_store_return_value_nofpu (type, regcache, valbuf); @@ -1554,6 +1550,19 @@ sh_register_reggroup_p (struct gdbarch *gdbarch, int regnum, The other pseudo registers (the FVs) also don't pose a problem because they are stored as 4 individual FP elements. */ +static struct type * +sh_littlebyte_bigword_type (struct gdbarch *gdbarch) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + if (tdep->sh_littlebyte_bigword_type == NULL) + tdep->sh_littlebyte_bigword_type + = arch_float_type (gdbarch, -1, "builtin_type_sh_littlebyte_bigword", + floatformats_ieee_double_littlebyte_bigword); + + return tdep->sh_littlebyte_bigword_type; +} + static void sh_register_convert_to_virtual (struct gdbarch *gdbarch, int regnum, struct type *type, gdb_byte *from, gdb_byte *to) @@ -1566,12 +1575,8 @@ sh_register_convert_to_virtual (struct gdbarch *gdbarch, int regnum, } if (regnum >= DR0_REGNUM && regnum <= DR_LAST_REGNUM) - { - DOUBLEST val; - floatformat_to_doublest (&floatformat_ieee_double_littlebyte_bigword, - from, &val); - store_typed_floating (to, type, val); - } + target_float_convert (from, sh_littlebyte_bigword_type (gdbarch), + to, type); else error ("sh_register_convert_to_virtual called with non DR register number"); @@ -1589,11 +1594,8 @@ sh_register_convert_to_raw (struct gdbarch *gdbarch, struct type *type, } if (regnum >= DR0_REGNUM && regnum <= DR_LAST_REGNUM) - { - DOUBLEST val = extract_typed_floating (from, type); - floatformat_from_doublest (&floatformat_ieee_double_littlebyte_bigword, - &val, to); - } + target_float_convert (from, type, + to, sh_littlebyte_bigword_type (gdbarch)); else error (_("sh_register_convert_to_raw called with non DR register number")); } @@ -1625,7 +1627,7 @@ dr_reg_base_num (struct gdbarch *gdbarch, int dr_regnum) static enum register_status pseudo_register_read_portions (struct gdbarch *gdbarch, - struct regcache *regcache, + readable_regcache *regcache, int portions, int base_regnum, gdb_byte *buffer) { @@ -1637,7 +1639,7 @@ pseudo_register_read_portions (struct gdbarch *gdbarch, gdb_byte *b; b = buffer + register_size (gdbarch, base_regnum) * portion; - status = regcache_raw_read (regcache, base_regnum + portion, b); + status = regcache->raw_read (base_regnum + portion, b); if (status != REG_VALID) return status; } @@ -1646,17 +1648,18 @@ pseudo_register_read_portions (struct gdbarch *gdbarch, } static enum register_status -sh_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache, +sh_pseudo_register_read (struct gdbarch *gdbarch, readable_regcache *regcache, int reg_nr, gdb_byte *buffer) { int base_regnum; - gdb_byte temp_buffer[MAX_REGISTER_SIZE]; enum register_status status; if (reg_nr == PSEUDO_BANK_REGNUM) - return regcache_raw_read (regcache, BANK_REGNUM, buffer); + return regcache->raw_read (BANK_REGNUM, buffer); else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM) { + /* Enough space for two float registers. */ + gdb_byte temp_buffer[4 * 2]; base_regnum = dr_reg_base_num (gdbarch, reg_nr); /* Build the value in the provided buffer. */ @@ -1689,7 +1692,6 @@ sh_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, int reg_nr, const gdb_byte *buffer) { int base_regnum, portion; - gdb_byte temp_buffer[MAX_REGISTER_SIZE]; if (reg_nr == PSEUDO_BANK_REGNUM) { @@ -1699,12 +1701,14 @@ sh_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, so that a re-read happens next time it's necessary. */ int bregnum; - regcache_raw_write (regcache, BANK_REGNUM, buffer); + regcache->raw_write (BANK_REGNUM, buffer); for (bregnum = R0_BANK0_REGNUM; bregnum < MACLB_REGNUM; ++bregnum) - regcache_invalidate (regcache, bregnum); + regcache->invalidate (bregnum); } else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM) { + /* Enough space for two float registers. */ + gdb_byte temp_buffer[4 * 2]; base_regnum = dr_reg_base_num (gdbarch, reg_nr); /* We must pay attention to the endiannes. */ @@ -1713,7 +1717,7 @@ sh_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, /* Write the real regs for which this one is an alias. */ for (portion = 0; portion < 2; portion++) - regcache_raw_write (regcache, base_regnum + portion, + regcache->raw_write (base_regnum + portion, (temp_buffer + register_size (gdbarch, base_regnum) * portion)); @@ -1724,7 +1728,7 @@ sh_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, /* Write the real regs for which this one is an alias. */ for (portion = 0; portion < 4; portion++) - regcache_raw_write (regcache, base_regnum + portion, + regcache->raw_write (base_regnum + portion, (buffer + register_size (gdbarch, base_regnum) * portion)); @@ -2160,7 +2164,7 @@ sh_corefile_supply_regset (const struct regset *regset, struct regcache *regcache, int regnum, const void *regs, size_t len) { - struct gdbarch *gdbarch = get_regcache_arch (regcache); + struct gdbarch *gdbarch = regcache->arch (); struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); const struct sh_corefile_regmap *regmap = (regset == &sh_corefile_gregset ? tdep->core_gregmap @@ -2171,8 +2175,8 @@ sh_corefile_supply_regset (const struct regset *regset, { if ((regnum == -1 || regnum == regmap[i].regnum) && regmap[i].offset + 4 <= len) - regcache_raw_supply (regcache, regmap[i].regnum, - (char *)regs + regmap[i].offset); + regcache->raw_supply + (regmap[i].regnum, (char *) regs + regmap[i].offset); } } @@ -2186,7 +2190,7 @@ sh_corefile_collect_regset (const struct regset *regset, const struct regcache *regcache, int regnum, void *regs, size_t len) { - struct gdbarch *gdbarch = get_regcache_arch (regcache); + struct gdbarch *gdbarch = regcache->arch (); struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); const struct sh_corefile_regmap *regmap = (regset == &sh_corefile_gregset ? tdep->core_gregmap @@ -2197,7 +2201,7 @@ sh_corefile_collect_regset (const struct regset *regset, { if ((regnum == -1 || regnum == regmap[i].regnum) && regmap[i].offset + 4 <= len) - regcache_raw_collect (regcache, regmap[i].regnum, + regcache->raw_collect (regmap[i].regnum, (char *)regs + regmap[i].offset); } } @@ -2228,10 +2232,12 @@ sh_iterate_over_regset_sections (struct gdbarch *gdbarch, struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); if (tdep->core_gregmap != NULL) - cb (".reg", tdep->sizeof_gregset, &sh_corefile_gregset, NULL, cb_data); + cb (".reg", tdep->sizeof_gregset, tdep->sizeof_gregset, + &sh_corefile_gregset, NULL, cb_data); if (tdep->core_fpregmap != NULL) - cb (".reg2", tdep->sizeof_fpregset, &sh_corefile_fpregset, NULL, cb_data); + cb (".reg2", tdep->sizeof_fpregset, tdep->sizeof_fpregset, + &sh_corefile_fpregset, NULL, cb_data); } /* This is the implementation of gdbarch method @@ -2252,10 +2258,6 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) struct gdbarch *gdbarch; struct gdbarch_tdep *tdep; - /* SH5 is handled entirely in sh64-tdep.c. */ - if (info.bfd_arch_info->mach == bfd_mach_sh5) - return sh64_gdbarch_init (info, arches); - /* If there is already a candidate, use it. */ arches = gdbarch_list_lookup_by_info (arches, &info); if (arches != NULL) @@ -2270,6 +2272,10 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_int_bit (gdbarch, 4 * TARGET_CHAR_BIT); set_gdbarch_long_bit (gdbarch, 4 * TARGET_CHAR_BIT); set_gdbarch_long_long_bit (gdbarch, 8 * TARGET_CHAR_BIT); + + set_gdbarch_wchar_bit (gdbarch, 2 * TARGET_CHAR_BIT); + set_gdbarch_wchar_signed (gdbarch, 0); + set_gdbarch_float_bit (gdbarch, 4 * TARGET_CHAR_BIT); set_gdbarch_double_bit (gdbarch, 8 * TARGET_CHAR_BIT); set_gdbarch_long_double_bit (gdbarch, 8 * TARGET_CHAR_BIT); @@ -2284,9 +2290,9 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_register_type (gdbarch, sh_default_register_type); set_gdbarch_register_reggroup_p (gdbarch, sh_register_reggroup_p); - SET_GDBARCH_BREAKPOINT_MANIPULATION (sh); + set_gdbarch_breakpoint_kind_from_pc (gdbarch, sh_breakpoint_kind_from_pc); + set_gdbarch_sw_breakpoint_from_kind (gdbarch, sh_sw_breakpoint_from_kind); - set_gdbarch_print_insn (gdbarch, print_insn_sh); set_gdbarch_register_sim_regno (gdbarch, legacy_register_sim_regno); set_gdbarch_return_value (gdbarch, sh_return_value_nofpu); @@ -2427,21 +2433,19 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) } static void -show_sh_command (char *args, int from_tty) +show_sh_command (const char *args, int from_tty) { help_list (showshcmdlist, "show sh ", all_commands, gdb_stdout); } static void -set_sh_command (char *args, int from_tty) +set_sh_command (const char *args, int from_tty) { printf_unfiltered ("\"set sh\" must be followed by an appropriate subcommand.\n"); help_list (setshcmdlist, "set sh ", all_commands, gdb_stdout); } -extern initialize_file_ftype _initialize_sh_tdep; /* -Wmissing-prototypes */ - void _initialize_sh_tdep (void) {