/* Target-dependent code for the Fujitsu FR-V, for GDB, the GNU Debugger.
- Copyright 2002, 2003, 2004 Free Software Foundation, Inc.
+
+ Copyright 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GDB.
#include "elf-bfd.h"
#include "elf/frv.h"
#include "osabi.h"
+#include "infcall.h"
#include "frv-tdep.h"
extern void _initialize_frv_tdep (void);
/* Register names. */
char **register_names;
-
- /* Given NEXT_FRAME, determine the address of register REGNO saved in
- the calling sigtramp frame. */
- CORE_ADDR (*sigcontext_reg_addr) (struct frame_info *next_frame, int regno,
- CORE_ADDR *);
};
#define CURRENT_VARIANT (gdbarch_tdep (current_gdbarch))
return gdbarch_tdep (gdbarch)->frv_abi;
}
-/* Set sigcontext_reg_addr. */
-void
-frv_set_sigcontext_reg_addr (struct gdbarch *gdbarch,
- CORE_ADDR (*sigcontext_reg_addr)
- (struct frame_info *, int, CORE_ADDR *))
-{
- gdbarch_tdep (gdbarch)->sigcontext_reg_addr = sigcontext_reg_addr;
-}
-
/* Fetch the interpreter and executable loadmap addresses (for shared
library support) for the FDPIC ABI. Return 0 if successful, -1 if
not. (E.g, -1 will be returned if the ABI isn't the FDPIC ABI.) */
for (r = acc0_regnum; r <= acc7_regnum; r++)
{
char *buf;
- xasprintf (&buf, "acc%d", r - acc0_regnum);
+ buf = xstrprintf ("acc%d", r - acc0_regnum);
var->register_names[r] = buf;
}
for (r = accg0_regnum; r <= accg7_regnum; r++)
{
char *buf;
- xasprintf (&buf, "accg%d", r - accg0_regnum);
+ buf = xstrprintf ("accg%d", r - accg0_regnum);
var->register_names[r] = buf;
}
return SIM_FRV_SPR0_REGNUM + spr_reg_offset;
}
- internal_error (__FILE__, __LINE__, "Bad register number %d", reg);
+ internal_error (__FILE__, __LINE__, _("Bad register number %d"), reg);
}
static const unsigned char *
char instr[frv_instr_size];
int status;
- status = read_memory_nobpt (addr, instr, sizeof instr);
+ status = deprecated_read_memory_nobpt (addr, instr, sizeof instr);
if (status != 0)
break;
store_unsigned_integer ((bfd_byte *) valbuf + 4, 4, regval);
}
else
- internal_error (__FILE__, __LINE__, "Illegal return value length: %d", len);
+ internal_error (__FILE__, __LINE__, _("Illegal return value length: %d"), len);
}
static CORE_ADDR
write_register (struct_return_regnum, addr);
}
-static int
-frv_frameless_function_invocation (struct frame_info *frame)
-{
- return legacy_frameless_look_for_prologue (frame);
-}
-
static CORE_ADDR
frv_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp)
{
{
CORE_ADDR descr;
char valbuf[4];
+ CORE_ADDR start_addr;
+
+ /* If we can't find the function in the symbol table, then we assume
+ that the function address is already in descriptor form. */
+ if (!find_pc_partial_function (entry_point, NULL, &start_addr, NULL)
+ || entry_point != start_addr)
+ return entry_point;
descr = frv_fdpic_find_canonical_descriptor (entry_point);
}
static CORE_ADDR
-frv_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
struct regcache *regcache, CORE_ADDR bp_addr,
int nargs, struct value **args, CORE_ADDR sp,
int struct_return, CORE_ADDR struct_addr)
int stack_space;
int stack_offset;
enum frv_abi abi = frv_abi (gdbarch);
+ CORE_ADDR func_addr = find_function_addr (function, NULL);
#if 0
printf("Push %d args at sp = %x, struct_return=%d (%x)\n",
stack_space = 0;
for (argnum = 0; argnum < nargs; ++argnum)
- stack_space += align_up (TYPE_LENGTH (VALUE_TYPE (args[argnum])), 4);
+ stack_space += align_up (TYPE_LENGTH (value_type (args[argnum])), 4);
stack_space -= (6 * 4);
if (stack_space > 0)
for (argnum = 0; argnum < nargs; ++argnum)
{
arg = args[argnum];
- arg_type = check_typedef (VALUE_TYPE (arg));
+ arg_type = check_typedef (value_type (arg));
len = TYPE_LENGTH (arg_type);
typecode = TYPE_CODE (arg_type);
store_unsigned_integer
(valbuf, 4,
find_func_descr (gdbarch,
- extract_unsigned_integer (VALUE_CONTENTS (arg),
+ extract_unsigned_integer (value_contents (arg),
4)));
typecode = TYPE_CODE_PTR;
len = 4;
}
else
{
- val = (char *) VALUE_CONTENTS (arg);
+ val = (char *) value_contents (arg);
}
while (len > 0)
}
else
internal_error (__FILE__, __LINE__,
- "Don't know how to return a %d-byte value.", len);
+ _("Don't know how to return a %d-byte value."), len);
}
}
-CORE_ADDR
-frv_stopped_data_address (void)
+int
+frv_stopped_data_address (CORE_ADDR *addr_p)
{
CORE_ADDR brr, dbar0, dbar1, dbar2, dbar3;
dbar3 = read_register (dbar3_regnum);
if (brr & (1<<11))
- return dbar0;
+ *addr_p = dbar0;
else if (brr & (1<<10))
- return dbar1;
+ *addr_p = dbar1;
else if (brr & (1<<9))
- return dbar2;
+ *addr_p = dbar2;
else if (brr & (1<<8))
- return dbar3;
+ *addr_p = dbar3;
else
return 0;
+
+ return 1;
+}
+
+int
+frv_have_stopped_data_address (void)
+{
+ CORE_ADDR addr = 0;
+ return frv_stopped_data_address (&addr);
}
static CORE_ADDR
{
struct frv_unwind_cache *info
= frv_frame_unwind_cache (next_frame, this_prologue_cache);
- trad_frame_prev_register (next_frame, info->saved_regs, regnum,
- optimizedp, lvalp, addrp, realnump, bufferp);
+ trad_frame_get_prev_register (next_frame, info->saved_regs, regnum,
+ optimizedp, lvalp, addrp, realnump, bufferp);
}
static const struct frame_unwind frv_frame_unwind = {
frame_pc_unwind (next_frame));
}
-/* Signal trampolines. */
-
-static struct frv_unwind_cache *
-frv_sigtramp_frame_cache (struct frame_info *next_frame, void **this_cache)
-{
- struct frv_unwind_cache *cache;
- struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
- CORE_ADDR addr;
- char buf[4];
- int regno;
- CORE_ADDR sc_addr_cache_val = 0;
-
- if (*this_cache)
- return *this_cache;
-
- cache = FRAME_OBSTACK_ZALLOC (struct frv_unwind_cache);
- cache->saved_regs = trad_frame_alloc_saved_regs (next_frame);
-
- frame_unwind_register (next_frame, sp_regnum, buf);
- cache->base = extract_unsigned_integer (buf, sizeof buf);
-
- for (regno = 0; regno < frv_num_regs; regno++)
- {
- cache->saved_regs[regno].addr
- = tdep->sigcontext_reg_addr (next_frame, regno, &sc_addr_cache_val);
- }
-
-
- if (cache->saved_regs[sp_regnum].addr != -1
- && target_read_memory (cache->saved_regs[sp_regnum].addr,
- buf, sizeof buf) == 0)
- {
- cache->prev_sp = extract_unsigned_integer (buf, sizeof buf);
-
- /* Now that we've bothered to read it out of memory, save the
- prev frame's SP value in the cache. */
- trad_frame_set_value (cache->saved_regs, sp_regnum, cache->prev_sp);
- }
- else
- {
- warning ("Can't read SP value from sigtramp frame");
- }
-
- *this_cache = cache;
- return cache;
-}
-
-static void
-frv_sigtramp_frame_this_id (struct frame_info *next_frame, void **this_cache,
- struct frame_id *this_id)
-{
- struct frv_unwind_cache *cache =
- frv_sigtramp_frame_cache (next_frame, this_cache);
-
- (*this_id) = frame_id_build (cache->base, frame_pc_unwind (next_frame));
-}
-
-static void
-frv_sigtramp_frame_prev_register (struct frame_info *next_frame,
- void **this_cache,
- int regnum, int *optimizedp,
- enum lval_type *lvalp, CORE_ADDR *addrp,
- int *realnump, void *valuep)
-{
- /* Make sure we've initialized the cache. */
- frv_sigtramp_frame_cache (next_frame, this_cache);
-
- frv_frame_prev_register (next_frame, this_cache, regnum,
- optimizedp, lvalp, addrp, realnump, valuep);
-}
-
-static const struct frame_unwind frv_sigtramp_frame_unwind =
-{
- SIGTRAMP_FRAME,
- frv_sigtramp_frame_this_id,
- frv_sigtramp_frame_prev_register
-};
-
-static const struct frame_unwind *
-frv_sigtramp_frame_sniffer (struct frame_info *next_frame)
-{
- CORE_ADDR pc = frame_pc_unwind (next_frame);
- char *name;
-
- /* We shouldn't even bother to try if the OSABI didn't register
- a sigcontext_reg_addr handler. */
- if (!gdbarch_tdep (current_gdbarch)->sigcontext_reg_addr)
- return NULL;
-
- find_pc_partial_function (pc, &name, NULL, NULL);
- if (DEPRECATED_PC_IN_SIGTRAMP (pc, name))
- return &frv_sigtramp_frame_unwind;
-
- return NULL;
-}
-
static struct gdbarch *
frv_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
set_gdbarch_breakpoint_from_pc (gdbarch, frv_breakpoint_from_pc);
set_gdbarch_adjust_breakpoint_address (gdbarch, frv_gdbarch_adjust_breakpoint_address);
- set_gdbarch_deprecated_frameless_function_invocation (gdbarch, frv_frameless_function_invocation);
-
- set_gdbarch_use_struct_convention (gdbarch, always_use_struct_convention);
+ set_gdbarch_deprecated_use_struct_convention (gdbarch, always_use_struct_convention);
set_gdbarch_extract_return_value (gdbarch, frv_extract_return_value);
set_gdbarch_deprecated_store_struct_return (gdbarch, frv_store_struct_return);
/* Hook in ABI-specific overrides, if they have been registered. */
gdbarch_init_osabi (info, gdbarch);
- /* Set the sigtramp frame sniffer. */
- frame_unwind_append_sniffer (gdbarch, frv_sigtramp_frame_sniffer);
-
/* Set the fallback (prologue based) frame sniffer. */
frame_unwind_append_sniffer (gdbarch, frv_frame_sniffer);
+ /* Enable TLS support. */
+ set_gdbarch_fetch_tls_load_module_address (gdbarch,
+ frv_fetch_objfile_link_map);
+
return gdbarch;
}