/* Target dependent code for CRIS, for GDB, the GNU debugger.
- Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
+
+ Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+
Contributed by Axis Communications AB.
Written by Hendrik Ruijter, Stefan Andersson, and Orjan Friberg.
#include "solib.h" /* Support for shared libraries. */
#include "solib-svr4.h" /* For struct link_map_offsets. */
#include "gdb_string.h"
+#include "dis-asm.h"
enum cris_num_regs
return (gdbarch_tdep (current_gdbarch)->cris_mode);
}
-static const char *
-cris_abi (void)
-{
- return (gdbarch_tdep (current_gdbarch)->cris_abi);
-}
-
-/* For saving call-clobbered contents in R9 when returning structs. */
-static CORE_ADDR struct_return_address;
-
struct frame_extra_info
{
CORE_ADDR return_pc;
/* Additional functions in order to handle opcodes. */
-static int
-cris_get_wide_opcode (unsigned short insn)
-{
- return ((insn & 0x03E0) >> 5);
-}
-
-static int
-cris_get_short_size (unsigned short insn)
-{
- return ((insn & 0x0010) >> 4);
-}
-
static int
cris_get_quick_value (unsigned short insn)
{
return (value & 0x3F);
}
-static int
-cris_get_asr_quick_shift_steps (unsigned short insn)
-{
- return (insn & 0x1F);
-}
-
static int
cris_get_clear_size (unsigned short insn)
{
static struct gdbarch *cris_gdbarch_init (struct gdbarch_info,
struct gdbarch_list *);
-static int cris_delayed_get_disassembler (bfd_vma, disassemble_info *);
-
static void cris_dump_tdep (struct gdbarch *, struct ui_file *);
static void cris_version_update (char *ignore_args, int from_tty,
/* We only want to know the end of the prologue when fi->saved_regs == 0.
When the saved registers are allocated full information is required. */
- if (get_frame_saved_regs (fi))
+ if (deprecated_get_frame_saved_regs (fi))
{
for (regno = 0; regno < NUM_REGS; regno++)
- get_frame_saved_regs (fi)[regno] = 0;
+ deprecated_get_frame_saved_regs (fi)[regno] = 0;
}
/* Find the prologue instructions. */
/* We only want to know the end of the prologue when
fi->saved_regs == 0. */
- if (!get_frame_saved_regs (fi))
+ if (!deprecated_get_frame_saved_regs (fi))
return ip;
if (have_fp)
{
- get_frame_saved_regs (fi)[DEPRECATED_FP_REGNUM] = get_frame_base (fi);
+ deprecated_get_frame_saved_regs (fi)[DEPRECATED_FP_REGNUM] = get_frame_base (fi);
/* Calculate the addresses. */
for (regno = regsave; regno >= 0; regno--)
{
- get_frame_saved_regs (fi)[regno] = get_frame_base (fi) - val;
+ deprecated_get_frame_saved_regs (fi)[regno] = get_frame_base (fi) - val;
val -= 4;
}
if (get_frame_extra_info (fi)->leaf_function)
{
/* Set the register SP to contain the stack pointer of
the caller. */
- get_frame_saved_regs (fi)[SP_REGNUM] = get_frame_base (fi) + 4;
+ deprecated_get_frame_saved_regs (fi)[SP_REGNUM] = get_frame_base (fi) + 4;
}
else
{
/* Set the register SP to contain the stack pointer of
the caller. */
- get_frame_saved_regs (fi)[SP_REGNUM] = get_frame_base (fi) + 8;
+ deprecated_get_frame_saved_regs (fi)[SP_REGNUM] = get_frame_base (fi) + 8;
/* Set the register SRP to contain the return address of
the caller. */
- get_frame_saved_regs (fi)[SRP_REGNUM] = get_frame_base (fi) + 4;
+ deprecated_get_frame_saved_regs (fi)[SRP_REGNUM] = get_frame_base (fi) + 4;
}
}
return ip;
return cris_skip_prologue_main (pc, 0);
}
-/* As cris_skip_prologue, but stops as soon as it knows that the function
- has a frame. Its result is equal to its input pc if the function is
- frameless, unequal otherwise. */
-
-static CORE_ADDR
-cris_skip_prologue_frameless_p (CORE_ADDR pc)
-{
- return cris_skip_prologue_main (pc, 1);
-}
-
/* Given a PC value corresponding to the start of a function, return the PC
of the first instruction after the function prologue. */
int len = TYPE_LENGTH (type);
if (len <= DEPRECATED_REGISTER_SIZE)
- deprecated_write_register_bytes (REGISTER_BYTE (RET_REGNUM), valbuf, len);
+ deprecated_write_register_bytes (DEPRECATED_REGISTER_BYTE (RET_REGNUM), valbuf, len);
else
internal_error (__FILE__, __LINE__, "cris_abi_original_store_return_value: type length too large.");
}
if (len <= 2 * DEPRECATED_REGISTER_SIZE)
{
/* Note that this works since R10 and R11 are consecutive registers. */
- deprecated_write_register_bytes (REGISTER_BYTE (RET_REGNUM), valbuf,
- len);
+ deprecated_write_register_bytes (DEPRECATED_REGISTER_BYTE (RET_REGNUM),
+ valbuf, len);
}
else
internal_error (__FILE__, __LINE__, "cris_abi_v2_store_return_value: type length too large.");
int len = TYPE_LENGTH (type);
if (len <= DEPRECATED_REGISTER_SIZE)
- memcpy (valbuf, regbuf + REGISTER_BYTE (RET_REGNUM), len);
+ memcpy (valbuf, regbuf + DEPRECATED_REGISTER_BYTE (RET_REGNUM), len);
else
internal_error (__FILE__, __LINE__, "cris_abi_original_extract_return_value: type length too large");
}
int len = TYPE_LENGTH (type);
if (len <= 2 * DEPRECATED_REGISTER_SIZE)
- memcpy (valbuf, regbuf + REGISTER_BYTE (RET_REGNUM), len);
+ memcpy (valbuf, regbuf + DEPRECATED_REGISTER_BYTE (RET_REGNUM), len);
else
internal_error (__FILE__, __LINE__, "cris_abi_v2_extract_return_value: type length too large");
}
/* Store the address of the place in which to copy the structure the
- subroutine will return. In the CRIS ABI, R9 is used in order to pass
- the address of the allocated area where a structure return value must
- be stored. R9 is call-clobbered, which means we must save it here for
- later use. */
+ subroutine will return. In the CRIS ABI, R9 is used in order to
+ pass the address of the allocated area where a structure return
+ value must be stored. */
static void
cris_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
{
write_register (STR_REGNUM, addr);
- struct_return_address = addr;
-}
-
-/* Extract from regbuf the address where a function should return a
- structure value. It's not there in the CRIS ABI, so we must do it another
- way. */
-
-static CORE_ADDR
-cris_extract_struct_value_address (char *regbuf)
-{
- return struct_return_address;
}
/* Returns 1 if the given type will be passed by pointer rather than
get_frame_base (fi));
/* Examine the entire prologue. */
- register int frameless_p = 0;
+ int frameless_p = 0;
/* Has this frame's registers already been initialized? */
- if (get_frame_saved_regs (fi))
+ if (deprecated_get_frame_saved_regs (fi))
return;
frame_saved_regs_zalloc (fi);
/* I don't see this ever happening, considering the context in which
cris_frame_init_saved_regs is called (always when we're not in
a dummy frame). */
- memcpy (get_frame_saved_regs (fi), dummy_regs, SIZEOF_FRAME_SAVED_REGS);
+ memcpy (deprecated_get_frame_saved_regs (fi), dummy_regs, SIZEOF_FRAME_SAVED_REGS);
}
else
{
/* Check fromleaf/frameless_function_invocation. (FIXME) */
- if (get_frame_saved_regs (fi)[SRP_REGNUM] != 0)
+ if (deprecated_get_frame_saved_regs (fi)[SRP_REGNUM] != 0)
{
/* SRP was saved on the stack; non-leaf function. */
get_frame_extra_info (fi)->return_pc =
- read_memory_integer (get_frame_saved_regs (fi)[SRP_REGNUM],
- REGISTER_RAW_SIZE (SRP_REGNUM));
+ read_memory_integer (deprecated_get_frame_saved_regs (fi)[SRP_REGNUM],
+ DEPRECATED_REGISTER_RAW_SIZE (SRP_REGNUM));
}
else
{
{
return get_frame_base (fi);
}
- else if (!inside_entry_file (get_frame_pc (fi)))
+ else if (!deprecated_inside_entry_file (get_frame_pc (fi)))
{
return read_memory_unsigned_integer (get_frame_base (fi), 4);
}
static void
cris_pop_frame (void)
{
- register struct frame_info *fi = get_current_frame ();
- register int regno;
- register int stack_offset = 0;
+ struct frame_info *fi = get_current_frame ();
+ int regno;
+ int stack_offset = 0;
if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (fi),
get_frame_base (fi),
after SP was saved. */
for (regno = 0; regno < DEPRECATED_FP_REGNUM; regno++)
{
- if (get_frame_saved_regs (fi)[regno])
+ if (deprecated_get_frame_saved_regs (fi)[regno])
{
write_register (regno,
- read_memory_integer (get_frame_saved_regs (fi)[regno], 4));
+ read_memory_integer (deprecated_get_frame_saved_regs (fi)[regno], 4));
}
}
- if (get_frame_saved_regs (fi)[DEPRECATED_FP_REGNUM])
+ if (deprecated_get_frame_saved_regs (fi)[DEPRECATED_FP_REGNUM])
{
/* Pop the frame pointer (R8). It was pushed before SP
was saved. */
write_register (DEPRECATED_FP_REGNUM,
- read_memory_integer (get_frame_saved_regs (fi)[DEPRECATED_FP_REGNUM], 4));
+ read_memory_integer (deprecated_get_frame_saved_regs (fi)[DEPRECATED_FP_REGNUM], 4));
stack_offset += 4;
/* Not a leaf function. */
- if (get_frame_saved_regs (fi)[SRP_REGNUM])
+ if (deprecated_get_frame_saved_regs (fi)[SRP_REGNUM])
{
/* SRP was pushed before SP was saved. */
stack_offset += 4;
}
/* Restore the SP and adjust for R8 and (possibly) SRP. */
- write_register (SP_REGNUM, get_frame_saved_regs (fi)[DEPRECATED_FP_REGNUM] + stack_offset);
+ write_register (SP_REGNUM, deprecated_get_frame_saved_regs (fi)[DEPRECATED_FP_REGNUM] + stack_offset);
}
else
{
inst_env->disable_interrupt = 0;
}
-/* Handles the pop instruction to a general register.
- POP is a assembler macro for MOVE.D [SP+], Rd. */
-
-static void
-reg_pop_op (unsigned short inst, inst_env_type *inst_env)
-{
- /* POP can't have a prefix. */
- if (inst_env->prefix_found)
- {
- inst_env->invalid = 1;
- return;
- }
- if (cris_get_operand2 (inst) == REG_PC)
- {
- /* It's invalid to change the PC in a delay slot. */
- if (inst_env->slot_needed)
- {
- inst_env->invalid = 1;
- return;
- }
- inst_env->reg[REG_PC] =
- read_memory_unsigned_integer (inst_env->reg[REG_SP], 4);
- }
- inst_env->slot_needed = 0;
- inst_env->prefix_found = 0;
- inst_env->xflag_found = 0;
- inst_env->disable_interrupt = 0;
-}
-
-/* Handles moves from register to memory. */
-
-static void
-move_reg_to_mem_index_inc_op (unsigned short inst, inst_env_type *inst_env)
-{
- /* Check if we have a prefix. */
- if (inst_env->prefix_found)
- {
- /* The only thing that can change the PC is an assign. */
- check_assign (inst, inst_env);
- }
- else if ((cris_get_operand1 (inst) == REG_PC)
- && (cris_get_mode (inst) == AUTOINC_MODE))
- {
- /* It's invalid to change the PC in a delay slot. */
- if (inst_env->slot_needed)
- {
- inst_env->invalid = 1;
- return;
- }
- process_autoincrement (cris_get_size (inst), inst, inst_env);
- }
- inst_env->slot_needed = 0;
- inst_env->prefix_found = 0;
- inst_env->xflag_found = 0;
- inst_env->disable_interrupt = 0;
-}
-
/* Handles the intructions that's not yet implemented, by setting
inst_env->invalid to true. */
exec_bfd has been set. */
static int
-cris_delayed_get_disassembler (bfd_vma addr, disassemble_info *info)
+cris_delayed_get_disassembler (bfd_vma addr, struct disassemble_info *info)
{
- int (*print_insn) (bfd_vma addr, disassemble_info *info);
+ int (*print_insn) (bfd_vma addr, struct disassemble_info *info);
/* FIXME: cagney/2003-08-27: It should be possible to select a CRIS
disassembler, even when there is no BFD. Does something like
"gdb; target remote; disassmeble *0x123" work? */
the set command passed as a parameter. The clone operation will
include (BUG?) any ``set'' command callback, if present.
Commands like ``info set'' call all the ``show'' command
- callbacks. Unfortunatly, for ``show'' commands cloned from
+ callbacks. Unfortunately, for ``show'' commands cloned from
``set'', this includes callbacks belonging to ``set'' commands.
Making this worse, this only occures if add_show_from_set() is
called after add_cmd_sfunc() (BUG?). */
the set command passed as a parameter. The clone operation will
include (BUG?) any ``set'' command callback, if present.
Commands like ``info set'' call all the ``show'' command
- callbacks. Unfortunatly, for ``show'' commands cloned from
+ callbacks. Unfortunately, for ``show'' commands cloned from
``set'', this includes callbacks belonging to ``set'' commands.
Making this worse, this only occures if add_show_from_set() is
called after add_cmd_sfunc() (BUG?). */
the set command passed as a parameter. The clone operation will
include (BUG?) any ``set'' command callback, if present.
Commands like ``info set'' call all the ``show'' command
- callbacks. Unfortunatly, for ``show'' commands cloned from
+ callbacks. Unfortunately, for ``show'' commands cloned from
``set'', this includes callbacks belonging to ``set'' commands.
Making this worse, this only occures if add_show_from_set() is
called after add_cmd_sfunc() (BUG?). */
/* NOTE: cagney/2002-12-06: This can be deleted when this arch is
ready to unwind the PC first (see frame.c:get_prev_frame()). */
- set_gdbarch_deprecated_init_frame_pc (gdbarch, init_frame_pc_default);
+ set_gdbarch_deprecated_init_frame_pc (gdbarch, deprecated_init_frame_pc_default);
tdep->cris_version = cris_version;
tdep->cris_mode = cris_mode;
cris_abi_original_store_return_value);
set_gdbarch_deprecated_extract_return_value
(gdbarch, cris_abi_original_extract_return_value);
- set_gdbarch_reg_struct_has_addr
+ set_gdbarch_deprecated_reg_struct_has_addr
(gdbarch, cris_abi_original_reg_struct_has_addr);
}
else if (tdep->cris_abi == CRIS_ABI_V2)
set_gdbarch_deprecated_store_return_value (gdbarch, cris_abi_v2_store_return_value);
set_gdbarch_deprecated_extract_return_value
(gdbarch, cris_abi_v2_extract_return_value);
- set_gdbarch_reg_struct_has_addr (gdbarch,
- cris_abi_v2_reg_struct_has_addr);
+ set_gdbarch_deprecated_reg_struct_has_addr
+ (gdbarch, cris_abi_v2_reg_struct_has_addr);
}
else
internal_error (__FILE__, __LINE__, "cris_gdbarch_init: unknown CRIS ABI");
set_gdbarch_register_name (gdbarch, cris_register_name);
- /* Length of ordinary registers used in push_word and a few other places.
- REGISTER_RAW_SIZE is the real way to know how big a register is. */
+ /* Length of ordinary registers used in push_word and a few other
+ places. DEPRECATED_REGISTER_RAW_SIZE is the real way to know how
+ big a register is. */
set_gdbarch_deprecated_register_size (gdbarch, 4);
/* NEW */
/* The length of the registers in the actual machine representation. */
set_gdbarch_deprecated_register_raw_size (gdbarch, cris_register_size);
- /* The largest value REGISTER_RAW_SIZE can have. */
+ /* The largest value DEPRECATED_REGISTER_RAW_SIZE can have. */
set_gdbarch_deprecated_max_register_raw_size (gdbarch, 32);
/* The length of the registers in the program's representation. */
set_gdbarch_deprecated_register_virtual_size (gdbarch, cris_register_size);
- /* The largest value REGISTER_VIRTUAL_SIZE can have. */
+ /* The largest value DEPRECATED_REGISTER_VIRTUAL_SIZE can have. */
set_gdbarch_deprecated_max_register_virtual_size (gdbarch, 32);
set_gdbarch_deprecated_register_virtual_type (gdbarch, cris_register_virtual_type);
set_gdbarch_deprecated_pop_frame (gdbarch, cris_pop_frame);
set_gdbarch_deprecated_store_struct_return (gdbarch, cris_store_struct_return);
- set_gdbarch_deprecated_extract_struct_value_address
- (gdbarch, cris_extract_struct_value_address);
set_gdbarch_use_struct_convention (gdbarch, always_use_struct_convention);
set_gdbarch_deprecated_frame_init_saved_regs (gdbarch, cris_frame_init_saved_regs);
set_gdbarch_deprecated_init_extra_frame_info (gdbarch, cris_init_extra_frame_info);
set_gdbarch_skip_prologue (gdbarch, cris_skip_prologue);
- set_gdbarch_prologue_frameless_p (gdbarch, generic_prologue_frameless_p);
/* The stack grows downward. */
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
set_gdbarch_breakpoint_from_pc (gdbarch, cris_breakpoint_from_pc);
- /* The PC must not be decremented after a breakpoint. (The breakpoint
- handler takes care of that.) */
- set_gdbarch_decr_pc_after_break (gdbarch, 0);
-
- /* Offset from address of function to start of its code. */
- set_gdbarch_function_start_offset (gdbarch, 0);
-
- /* The number of bytes at the start of arglist that are not really args,
- 0 in the CRIS ABI. */
- set_gdbarch_frame_args_skip (gdbarch, 0);
set_gdbarch_frameless_function_invocation
(gdbarch, cris_frameless_function_invocation);
set_gdbarch_deprecated_frame_chain (gdbarch, cris_frame_chain);