/* Target-dependent code for Renesas Super-H, for GDB.
- Copyright (C) 1993-2017 Free Software Foundation, Inc.
+ Copyright (C) 1993-2020 Free Software Foundation, Inc.
This file is part of GDB.
#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"
not displace any of the other arguments passed in via registers R4
to R7. */
-/* Helper function to justify value in register according to endianess. */
+/* Helper function to justify value in register according to endianness. */
static const gdb_byte *
sh_justify_value_in_reg (struct gdbarch *gdbarch, struct value *val, int len)
{
}
/* Helper functions for getting the float arguments right. Registers usage
- depends on the ABI and the endianess. The comments should enlighten how
+ depends on the ABI and the endianness. The comments should enlighten how
it's intended to work. */
/* This array stores which of the float arg registers are already in use. */
/* Otherwise non-struct types are not treated as float. */
if (TYPE_CODE (type) != TYPE_CODE_STRUCT)
return 0;
- /* Otherwise structs with more than one memeber are not treated as float. */
+ /* Otherwise structs with more than one member are not treated as float. */
if (TYPE_NFIELDS (type) != 1)
return 0;
/* Otherwise if the type of that member is float, the whole type is
struct regcache *regcache,
CORE_ADDR bp_addr, int nargs,
struct value **args,
- CORE_ADDR sp, int struct_return,
+ CORE_ADDR sp, function_call_return_method return_method,
CORE_ADDR struct_addr)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
}
}
- if (struct_return)
+ if (return_method == return_method_struct)
{
if (sh_is_renesas_calling_convention (func_type))
/* If the function uses the Renesas ABI, subtract another 4 bytes from
struct regcache *regcache,
CORE_ADDR bp_addr,
int nargs, struct value **args,
- CORE_ADDR sp, int struct_return,
+ CORE_ADDR sp,
+ function_call_return_method return_method,
CORE_ADDR struct_addr)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
}
}
- if (struct_return)
+ if (return_method == return_method_struct)
{
if (sh_is_renesas_calling_convention (func_type))
/* If the function uses the Renesas ABI, subtract another 4 bytes from
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);
{
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"));
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);
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);
{
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);
}
}
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);
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)
}
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");
}
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"));
}
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)
{
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;
}
}
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;
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. */
2, base_regnum, temp_buffer);
if (status == REG_VALID)
{
- /* We must pay attention to the endiannes. */
+ /* We must pay attention to the endianness. */
sh_register_convert_to_virtual (gdbarch, reg_nr,
register_type (gdbarch, reg_nr),
temp_buffer, buffer);
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)
{
gdb_byte temp_buffer[4 * 2];
base_regnum = dr_reg_base_num (gdbarch, reg_nr);
- /* We must pay attention to the endiannes. */
+ /* We must pay attention to the endianness. */
sh_register_convert_to_raw (gdbarch, register_type (gdbarch, reg_nr),
reg_nr, buffer, temp_buffer);
/* 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));
/* 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));
default_frame_sniffer
};
-static CORE_ADDR
-sh_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame)
-{
- return frame_unwind_register_unsigned (next_frame,
- gdbarch_sp_regnum (gdbarch));
-}
-
-static CORE_ADDR
-sh_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
-{
- return frame_unwind_register_unsigned (next_frame,
- gdbarch_pc_regnum (gdbarch));
-}
-
-static struct frame_id
-sh_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
-{
- CORE_ADDR sp = get_frame_register_unsigned (this_frame,
- gdbarch_sp_regnum (gdbarch));
- return frame_id_build (sp, get_frame_pc (this_frame));
-}
-
static CORE_ADDR
sh_frame_base_address (struct frame_info *this_frame, void **this_cache)
{
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
{
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);
}
}
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
{
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);
}
}
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
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)
set_gdbarch_believe_pcc_promotion (gdbarch, 1);
set_gdbarch_frame_align (gdbarch, sh_frame_align);
- set_gdbarch_unwind_sp (gdbarch, sh_unwind_sp);
- set_gdbarch_unwind_pc (gdbarch, sh_unwind_pc);
- set_gdbarch_dummy_id (gdbarch, sh_dummy_id);
frame_base_set_default (gdbarch, &sh_frame_base);
set_gdbarch_stack_frame_destroyed_p (gdbarch, sh_stack_frame_destroyed_p);
}
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)
{