#include "arch-utils.h"
#include "floatformat.h"
+#include "solib-svr4.h"
+
#undef XMALLOC
#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
static void sh_print_register (int regnum);
void (*sh_show_regs) (void);
-
+int (*print_sh_insn) (bfd_vma, disassemble_info*);
/* Define other aspects of the stack frame.
we keep a copy of the worked out return pc lying around, since it
/* Extract from an array REGBUF containing the (raw) register state
the address in which a function should return its structure value,
as a CORE_ADDR (or an expression that can be used as one). */
-CORE_ADDR
-static sh_extract_struct_value_address (regbuf)
- char *regbuf;
+static CORE_ADDR
+sh_extract_struct_value_address (char *regbuf)
{
return (extract_address ((regbuf), REGISTER_RAW_SIZE (0)));
}
to R7. */
static CORE_ADDR
-sh_push_arguments (int nargs, value_ptr *args, CORE_ADDR sp,
- unsigned char struct_return, CORE_ADDR struct_addr)
+sh_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
+ int struct_return, CORE_ADDR struct_addr)
{
int stack_offset, stack_alloc;
int argreg;
sh_sh4_register_byte (int reg_nr)
{
if (reg_nr >= gdbarch_tdep (current_gdbarch)->DR0_REGNUM
- && reg_nr <= gdbarch_tdep (current_gdbarch)->DR14_REGNUM)
+ && reg_nr <= gdbarch_tdep (current_gdbarch)->DR_LAST_REGNUM)
return (dr_reg_base_num (reg_nr) * 4);
else if (reg_nr >= gdbarch_tdep (current_gdbarch)->FV0_REGNUM
- && reg_nr <= gdbarch_tdep (current_gdbarch)->FV12_REGNUM)
+ && reg_nr <= gdbarch_tdep (current_gdbarch)->FV_LAST_REGNUM)
return (fv_reg_base_num (reg_nr) * 4);
else
return (reg_nr * 4);
sh_sh4_register_raw_size (int reg_nr)
{
if (reg_nr >= gdbarch_tdep (current_gdbarch)->DR0_REGNUM
- && reg_nr <= gdbarch_tdep (current_gdbarch)->DR14_REGNUM)
+ && reg_nr <= gdbarch_tdep (current_gdbarch)->DR_LAST_REGNUM)
return 8;
else if (reg_nr >= gdbarch_tdep (current_gdbarch)->FV0_REGNUM
- && reg_nr <= gdbarch_tdep (current_gdbarch)->FV12_REGNUM)
+ && reg_nr <= gdbarch_tdep (current_gdbarch)->FV_LAST_REGNUM)
return 16;
else
return 4;
sh_sh3e_register_virtual_type (int reg_nr)
{
if ((reg_nr >= FP0_REGNUM
- && (reg_nr <= gdbarch_tdep (current_gdbarch)->FP15_REGNUM))
+ && (reg_nr <= gdbarch_tdep (current_gdbarch)->FP_LAST_REGNUM))
|| (reg_nr == gdbarch_tdep (current_gdbarch)->FPUL_REGNUM))
return builtin_type_float;
else
sh_sh4_register_virtual_type (int reg_nr)
{
if ((reg_nr >= FP0_REGNUM
- && (reg_nr <= gdbarch_tdep (current_gdbarch)->FP15_REGNUM))
+ && (reg_nr <= gdbarch_tdep (current_gdbarch)->FP_LAST_REGNUM))
|| (reg_nr == gdbarch_tdep (current_gdbarch)->FPUL_REGNUM))
return builtin_type_float;
else if (reg_nr >= gdbarch_tdep (current_gdbarch)->DR0_REGNUM
- && reg_nr <= gdbarch_tdep (current_gdbarch)->DR14_REGNUM)
+ && reg_nr <= gdbarch_tdep (current_gdbarch)->DR_LAST_REGNUM)
return builtin_type_double;
else if (reg_nr >= gdbarch_tdep (current_gdbarch)->FV0_REGNUM
- && reg_nr <= gdbarch_tdep (current_gdbarch)->FV12_REGNUM)
+ && reg_nr <= gdbarch_tdep (current_gdbarch)->FV_LAST_REGNUM)
return sh_sh4_build_float_register_type (3);
else
return builtin_type_int;
{
if (TARGET_BYTE_ORDER == LITTLE_ENDIAN)
return (gdbarch_tdep (current_gdbarch)->DR0_REGNUM <= nr
- && nr <= gdbarch_tdep (current_gdbarch)->DR14_REGNUM);
+ && nr <= gdbarch_tdep (current_gdbarch)->DR_LAST_REGNUM);
else
return 0;
}
char *from, char *to)
{
if (regnum >= gdbarch_tdep (current_gdbarch)->DR0_REGNUM
- && regnum <= gdbarch_tdep (current_gdbarch)->DR14_REGNUM)
+ && regnum <= gdbarch_tdep (current_gdbarch)->DR_LAST_REGNUM)
{
DOUBLEST val;
floatformat_to_doublest (&floatformat_ieee_double_littlebyte_bigword, from, &val);
char *from, char *to)
{
if (regnum >= gdbarch_tdep (current_gdbarch)->DR0_REGNUM
- && regnum <= gdbarch_tdep (current_gdbarch)->DR14_REGNUM)
+ && regnum <= gdbarch_tdep (current_gdbarch)->DR_LAST_REGNUM)
{
DOUBLEST val = extract_floating (from, TYPE_LENGTH(type));
floatformat_from_doublest (&floatformat_ieee_double_littlebyte_bigword, &val, to);
if (!register_cached (reg_nr))
{
if (reg_nr >= gdbarch_tdep (current_gdbarch)->DR0_REGNUM
- && reg_nr <= gdbarch_tdep (current_gdbarch)->DR14_REGNUM)
+ && reg_nr <= gdbarch_tdep (current_gdbarch)->DR_LAST_REGNUM)
{
base_regnum = dr_reg_base_num (reg_nr);
target_fetch_registers (base_regnum + portion);
}
else if (reg_nr >= gdbarch_tdep (current_gdbarch)->FV0_REGNUM
- && reg_nr <= gdbarch_tdep (current_gdbarch)->FV12_REGNUM)
+ && reg_nr <= gdbarch_tdep (current_gdbarch)->FV_LAST_REGNUM)
{
base_regnum = fv_reg_base_num (reg_nr);
int base_regnum, portion;
if (reg_nr >= gdbarch_tdep (current_gdbarch)->DR0_REGNUM
- && reg_nr <= gdbarch_tdep (current_gdbarch)->DR14_REGNUM)
+ && reg_nr <= gdbarch_tdep (current_gdbarch)->DR_LAST_REGNUM)
{
base_regnum = dr_reg_base_num (reg_nr);
}
}
else if (reg_nr >= gdbarch_tdep (current_gdbarch)->FV0_REGNUM
- && reg_nr <= gdbarch_tdep (current_gdbarch)->FV12_REGNUM)
+ && reg_nr <= gdbarch_tdep (current_gdbarch)->FV_LAST_REGNUM)
{
base_regnum = fv_reg_base_num (reg_nr);
sh_do_pseudo_register (int regnum)
{
if (regnum < NUM_REGS || regnum >= NUM_REGS + NUM_PSEUDO_REGS)
- internal_error ("Invalid pasudo register number %d\n", regnum);
+ internal_error ("Invalid pseudo register number %d\n", regnum);
else if (regnum >= NUM_REGS &&
regnum < gdbarch_tdep (current_gdbarch)->FV0_REGNUM)
do_dr_register_info (regnum);
else if (regnum >= gdbarch_tdep (current_gdbarch)->FV0_REGNUM &&
- regnum <= gdbarch_tdep (current_gdbarch)->FV12_REGNUM)
+ regnum <= gdbarch_tdep (current_gdbarch)->FV_LAST_REGNUM)
do_fv_register_info (regnum);
}
regnum ++;
}
else
- regnum += (gdbarch_tdep (current_gdbarch)->FP15_REGNUM - FP0_REGNUM); /* skip FP regs */
+ regnum += (gdbarch_tdep (current_gdbarch)->FP_LAST_REGNUM - FP0_REGNUM); /* skip FP regs */
}
else
{
}
}
+#ifdef SVR4_SHARED_LIBS
+
+/* Fetch (and possibly build) an appropriate link_map_offsets structure
+ for native i386 linux targets using the struct offsets defined in
+ link.h (but without actual reference to that file).
+
+ This makes it possible to access i386-linux shared libraries from
+ a gdb that was not built on an i386-linux host (for cross debugging).
+ */
+
+struct link_map_offsets *
+sh_linux_svr4_fetch_link_map_offsets (void)
+{
+ static struct link_map_offsets lmo;
+ static struct link_map_offsets *lmp = 0;
+
+ if (lmp == 0)
+ {
+ lmp = &lmo;
+
+ lmo.r_debug_size = 8; /* 20 not actual size but all we need */
+
+ lmo.r_map_offset = 4;
+ lmo.r_map_size = 4;
+
+ lmo.link_map_size = 20; /* 552 not actual size but all we need */
+
+ lmo.l_addr_offset = 0;
+ lmo.l_addr_size = 4;
+
+ lmo.l_name_offset = 4;
+ lmo.l_name_size = 4;
+
+ lmo.l_next_offset = 12;
+ lmo.l_next_size = 4;
+
+ lmo.l_prev_offset = 16;
+ lmo.l_prev_size = 4;
+ }
+
+ return lmp;
+}
+#endif /* SVR4_SHARED_LIBS */
+
static gdbarch_init_ftype sh_gdbarch_init;
static struct gdbarch *
tdep->FPUL_REGNUM = -1;
tdep->FPSCR_REGNUM = -1;
tdep->DSR_REGNUM = -1;
- tdep->FP15_REGNUM = -1;
+ tdep->FP_LAST_REGNUM = -1;
tdep->A0G_REGNUM = -1;
tdep->A0_REGNUM = -1;
tdep->A1G_REGNUM = -1;
tdep->SSR_REGNUM = -1;
tdep->SPC_REGNUM = -1;
tdep->DR0_REGNUM = -1;
- tdep->DR2_REGNUM = -1;
- tdep->DR4_REGNUM = -1;
- tdep->DR6_REGNUM = -1;
- tdep->DR8_REGNUM = -1;
- tdep->DR10_REGNUM = -1;
- tdep->DR12_REGNUM = -1;
- tdep->DR14_REGNUM = -1;
+ tdep->DR_LAST_REGNUM = -1;
tdep->FV0_REGNUM = -1;
- tdep->FV4_REGNUM = -1;
- tdep->FV8_REGNUM = -1;
- tdep->FV12_REGNUM = -1;
+ tdep->FV_LAST_REGNUM = -1;
set_gdbarch_fp0_regnum (gdbarch, -1);
set_gdbarch_num_pseudo_regs (gdbarch, 0);
set_gdbarch_max_register_raw_size (gdbarch, 4);
set_gdbarch_max_register_virtual_size (gdbarch, 4);
+ print_sh_insn = gdb_print_insn_sh;
switch (info.bfd_arch_info->mach)
{
set_gdbarch_fp0_regnum (gdbarch, 25);
tdep->FPUL_REGNUM = 23;
tdep->FPSCR_REGNUM = 24;
- tdep->FP15_REGNUM = 40;
+ tdep->FP_LAST_REGNUM = 40;
tdep->SSR_REGNUM = 41;
tdep->SPC_REGNUM = 42;
break;
set_gdbarch_register_convertible (gdbarch, sh_sh4_register_convertible);
tdep->FPUL_REGNUM = 23;
tdep->FPSCR_REGNUM = 24;
- tdep->FP15_REGNUM = 40;
+ tdep->FP_LAST_REGNUM = 40;
tdep->SSR_REGNUM = 41;
tdep->SPC_REGNUM = 42;
tdep->DR0_REGNUM = 59;
- tdep->DR2_REGNUM = 60;
- tdep->DR4_REGNUM = 61;
- tdep->DR6_REGNUM = 62;
- tdep->DR8_REGNUM = 63;
- tdep->DR10_REGNUM = 64;
- tdep->DR12_REGNUM = 65;
- tdep->DR14_REGNUM = 66;
+ tdep->DR_LAST_REGNUM = 66;
tdep->FV0_REGNUM = 67;
- tdep->FV4_REGNUM = 68;
- tdep->FV8_REGNUM = 69;
- tdep->FV12_REGNUM = 70;
+ tdep->FV_LAST_REGNUM = 70;
break;
default:
sh_register_name = sh_generic_register_name;
struct cmd_list_element *c;
register_gdbarch_init (bfd_arch_sh, sh_gdbarch_init);
- tm_print_insn = gdb_print_insn_sh;
+ tm_print_insn = print_sh_insn;
add_com ("regs", class_vars, sh_show_regs_command, "Print all registers");
}