This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
PATCH move arm frame functions to level-2 style gdbarch
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: gdb-patches at sources dot redhat dot com
- Cc: Richard dot Earnshaw at arm dot com
- Date: Mon, 11 Feb 2002 12:48:48 +0000
- Subject: PATCH move arm frame functions to level-2 style gdbarch
- Organization: ARM Ltd.
- Reply-to: Richard dot Earnshaw at arm dot com
This moves the frame functions in the ARM target to being level-2 style
(ie registered in the gdbarch structure).
R.
2002-02-11 Richard Earnshaw <rearnsha@arm.com>
* arm-tdep.c (arm_frameless_function_invocation)
(arm_frame_args_address, arm_frame_locals_address, arm_frame_num_args)
(arm_frame_chain, arm_init_extra_frame_info, arm_frame_saved_pc)
(arm_read_fp, arm_frame_init_saved_regs, arm_push_dummy_frame)
(arm_pop_frame, arm_get_next_pc): Make static.
(arm_gdbarch_init): Register above in gdbarch structure.
(arm_read_fp): Renamed from arm_target_read_fp.
(arm_pc_is_thumb, arm_pc_is_thumb_dummy): Make static.
* config/arm/tm-arm.h (arm_frameless_function_invocation)
(arm_frame_args_address, arm_frame_locals_address, arm_frame_num_args)
(arm_frame_chain, arm_init_extra_frame_info, arm_frame_saved_pc)
(arm_target_read_fp, arm_frame_init_saved_regs, arm_push_dummy_frame)
(arm_pop_frame, arm_get_next_pc, arm_pc_is_thumb)
(arm_pc_is_thumb_dummy): Delete declarations.
(INIT_EXTRA_FRAME_INFO, TARGET_READ_FP, FRAME_CHAIN)
(FRAMELESS_FUNCTION_INVOCATION, FRAME_SAVED_PC, FRAME_ARGS_ADDRESS)
(FRAME_LOCALS_ADDRESS, FRAME_NUM_ARGS, FRAME_ARGS_SKIP)
(FRAME_INIT_SAVED_REGS, PUSH_DUMMY_FRAME, POP_FRAME): Delete.
Index: arm-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/arm-tdep.c,v
retrieving revision 1.37
diff -p -r1.37 arm-tdep.c
*** arm-tdep.c 2002/02/08 18:26:36 1.37
--- arm-tdep.c 2002/02/11 12:33:23
*************** static int caller_is_thumb;
*** 262,268 ****
/* Determine if the program counter specified in MEMADDR is in a Thumb
function. */
! int
arm_pc_is_thumb (CORE_ADDR memaddr)
{
struct minimal_symbol *sym;
--- 262,268 ----
/* Determine if the program counter specified in MEMADDR is in a Thumb
function. */
! static int
arm_pc_is_thumb (CORE_ADDR memaddr)
{
struct minimal_symbol *sym;
*************** arm_pc_is_thumb (CORE_ADDR memaddr)
*** 286,292 ****
/* Determine if the program counter specified in MEMADDR is in a call
dummy being called from a Thumb function. */
! int
arm_pc_is_thumb_dummy (CORE_ADDR memaddr)
{
CORE_ADDR sp = read_sp ();
--- 286,292 ----
/* Determine if the program counter specified in MEMADDR is in a call
dummy being called from a Thumb function. */
! static int
arm_pc_is_thumb_dummy (CORE_ADDR memaddr)
{
CORE_ADDR sp = read_sp ();
*************** arm_saved_pc_after_call (struct frame_in
*** 332,338 ****
frame on the stack associated with it. If it does return zero,
otherwise return 1. */
! int
arm_frameless_function_invocation (struct frame_info *fi)
{
CORE_ADDR func_start, after_prologue;
--- 332,338 ----
frame on the stack associated with it. If it does return zero,
otherwise return 1. */
! static int
arm_frameless_function_invocation (struct frame_info *fi)
{
CORE_ADDR func_start, after_prologue;
*************** arm_frameless_function_invocation (struc
*** 362,382 ****
}
/* The address of the arguments in the frame. */
! CORE_ADDR
arm_frame_args_address (struct frame_info *fi)
{
return fi->frame;
}
/* The address of the local variables in the frame. */
! CORE_ADDR
arm_frame_locals_address (struct frame_info *fi)
{
return fi->frame;
}
/* The number of arguments being passed in the frame. */
! int
arm_frame_num_args (struct frame_info *fi)
{
/* We have no way of knowing. */
--- 362,382 ----
}
/* The address of the arguments in the frame. */
! static CORE_ADDR
arm_frame_args_address (struct frame_info *fi)
{
return fi->frame;
}
/* The address of the local variables in the frame. */
! static CORE_ADDR
arm_frame_locals_address (struct frame_info *fi)
{
return fi->frame;
}
/* The number of arguments being passed in the frame. */
! static int
arm_frame_num_args (struct frame_info *fi)
{
/* We have no way of knowing. */
*************** arm_find_callers_reg (struct frame_info
*** 1010,1034 ****
REGISTER_RAW_SIZE (regnum));
return read_register (regnum);
}
! /* *INDENT-OFF* */
! /* Function: frame_chain
! Given a GDB frame, determine the address of the calling function's frame.
! This will be used to create a new GDB frame struct, and then
! INIT_EXTRA_FRAME_INFO and INIT_FRAME_PC will be called for the new frame.
! For ARM, we save the frame size when we initialize the frame_info.
!
! The original definition of this function was a macro in tm-arm.h:
! { In the case of the ARM, the frame's nominal address is the FP value,
! and 12 bytes before comes the saved previous FP value as a 4-byte word. }
!
! #define FRAME_CHAIN(thisframe) \
! ((thisframe)->pc >= LOWEST_PC ? \
! read_memory_integer ((thisframe)->frame - 12, 4) :\
! 0)
! */
! /* *INDENT-ON* */
! CORE_ADDR
arm_frame_chain (struct frame_info *fi)
{
#if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */
--- 1010,1022 ----
REGISTER_RAW_SIZE (regnum));
return read_register (regnum);
}
! /* Function: frame_chain Given a GDB frame, determine the address of
! the calling function's frame. This will be used to create a new
! GDB frame struct, and then INIT_EXTRA_FRAME_INFO and INIT_FRAME_PC
! will be called for the new frame. For ARM, we save the frame size
! when we initialize the frame_info. */
! static CORE_ADDR
arm_frame_chain (struct frame_info *fi)
{
#if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */
*************** arm_frame_chain (struct frame_info *fi)
*** 1108,1114 ****
this is true, then the frame value for this frame is still in the
fp register. */
! void
arm_init_extra_frame_info (int fromleaf, struct frame_info *fi)
{
int reg;
--- 1096,1102 ----
this is true, then the frame value for this frame is still in the
fp register. */
! static void
arm_init_extra_frame_info (int fromleaf, struct frame_info *fi)
{
int reg;
*************** arm_init_extra_frame_info (int fromleaf,
*** 1240,1246 ****
#define FRAME_SAVED_PC(FRAME) \
ADDR_BITS_REMOVE (read_memory_integer ((FRAME)->frame - 4, 4)) */
! CORE_ADDR
arm_frame_saved_pc (struct frame_info *fi)
{
#if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */
--- 1228,1234 ----
#define FRAME_SAVED_PC(FRAME) \
ADDR_BITS_REMOVE (read_memory_integer ((FRAME)->frame - 4, 4)) */
! static CORE_ADDR
arm_frame_saved_pc (struct frame_info *fi)
{
#if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */
*************** arm_frame_saved_pc (struct frame_info *f
*** 1264,1271 ****
/* Return the frame address. On ARM, it is R11; on Thumb it is R7.
Examine the Program Status Register to decide which state we're in. */
! CORE_ADDR
! arm_target_read_fp (void)
{
if (read_register (PS_REGNUM) & 0x20) /* Bit 5 is Thumb state bit */
return read_register (THUMB_FP_REGNUM); /* R7 if Thumb */
--- 1252,1259 ----
/* Return the frame address. On ARM, it is R11; on Thumb it is R7.
Examine the Program Status Register to decide which state we're in. */
! static CORE_ADDR
! arm_read_fp (void)
{
if (read_register (PS_REGNUM) & 0x20) /* Bit 5 is Thumb state bit */
return read_register (THUMB_FP_REGNUM); /* R7 if Thumb */
*************** arm_target_read_fp (void)
*** 1273,1281 ****
return read_register (FP_REGNUM); /* R11 if ARM */
}
! /* Calculate the frame offsets of the saved registers (ARM version). */
! void
arm_frame_init_saved_regs (struct frame_info *fip)
{
--- 1261,1273 ----
return read_register (FP_REGNUM); /* R11 if ARM */
}
! /* Store into a struct frame_saved_regs the addresses of the saved
! registers of frame described by FRAME_INFO. This includes special
! registers such as PC and FP saved in special ways in the stack
! frame. SP is even more special: the address we return for it IS
! the sp for the next frame. */
! static void
arm_frame_init_saved_regs (struct frame_info *fip)
{
*************** arm_frame_init_saved_regs (struct frame_
*** 1285,1291 ****
arm_init_extra_frame_info (0, fip);
}
! void
arm_push_dummy_frame (void)
{
CORE_ADDR old_sp = read_register (SP_REGNUM);
--- 1277,1285 ----
arm_init_extra_frame_info (0, fip);
}
! /* Push an empty stack frame, to record the current PC, etc. */
!
! static void
arm_push_dummy_frame (void)
{
CORE_ADDR old_sp = read_register (SP_REGNUM);
*************** arm_push_arguments (int nargs, struct va
*** 1545,1551 ****
properly (see arm_init_extra_frame_info), this code works for dummy frames
as well as regular frames. I.e, there's no need to have a special case
for dummy frames. */
! void
arm_pop_frame (void)
{
int regnum;
--- 1539,1545 ----
properly (see arm_init_extra_frame_info), this code works for dummy frames
as well as regular frames. I.e, there's no need to have a special case
for dummy frames. */
! static void
arm_pop_frame (void)
{
int regnum;
*************** thumb_get_next_pc (CORE_ADDR pc)
*** 1797,1803 ****
return nextpc;
}
! CORE_ADDR
arm_get_next_pc (CORE_ADDR pc)
{
unsigned long pc_val;
--- 1791,1797 ----
return nextpc;
}
! static CORE_ADDR
arm_get_next_pc (CORE_ADDR pc)
{
unsigned long pc_val;
*************** arm_gdbarch_init (struct gdbarch_info in
*** 2365,2371 ****
--- 2359,2380 ----
set_gdbarch_get_saved_register (gdbarch, generic_get_saved_register);
set_gdbarch_push_arguments (gdbarch, arm_push_arguments);
+ /* Frame handling. */
set_gdbarch_frame_chain_valid (gdbarch, arm_frame_chain_valid);
+ set_gdbarch_init_extra_frame_info (gdbarch, arm_init_extra_frame_info);
+ set_gdbarch_read_fp (gdbarch, arm_read_fp);
+ set_gdbarch_frame_chain (gdbarch, arm_frame_chain);
+ set_gdbarch_frameless_function_invocation
+ (gdbarch, arm_frameless_function_invocation);
+ set_gdbarch_frame_saved_pc (gdbarch, arm_frame_saved_pc);
+ set_gdbarch_frame_args_address (gdbarch, arm_frame_args_address);
+ set_gdbarch_frame_locals_address (gdbarch, arm_frame_locals_address);
+ set_gdbarch_frame_num_args (gdbarch, arm_frame_num_args);
+ set_gdbarch_frame_args_skip (gdbarch, 0);
+ set_gdbarch_frame_init_saved_regs (gdbarch, arm_frame_init_saved_regs);
+ set_gdbarch_push_dummy_frame (gdbarch, arm_push_dummy_frame);
+ set_gdbarch_pop_frame (gdbarch, arm_pop_frame);
+
return gdbarch;
}
Index: config/arm/tm-arm.h
===================================================================
RCS file: /cvs/src/src/gdb/config/arm/tm-arm.h,v
retrieving revision 1.24
diff -p -r1.24 tm-arm.h
*** tm-arm.h 2002/02/08 18:26:37 1.24
--- tm-arm.h 2002/02/11 12:33:24
*************** extern void convert_to_extended (void *d
*** 307,376 ****
before in the executables list of symbols. */
#define VARIABLES_INSIDE_BLOCK(desc, gcc_p) (!(gcc_p))
-
- extern void arm_init_extra_frame_info (int fromleaf, struct frame_info * fi);
- #define INIT_EXTRA_FRAME_INFO(fromleaf, fi) \
- arm_init_extra_frame_info ((fromleaf), (fi))
-
- /* Return the frame address. On ARM, it is R11; on Thumb it is R7. */
- CORE_ADDR arm_target_read_fp (void);
- #define TARGET_READ_FP() arm_target_read_fp ()
-
- /* Describe the pointer in each stack frame to the previous stack
- frame (its caller). */
-
- /* FRAME_CHAIN takes a frame's nominal address and produces the
- frame's chain-pointer.
-
- However, if FRAME_CHAIN_VALID returns zero,
- it means the given frame is the outermost one and has no caller. */
-
- CORE_ADDR arm_frame_chain (struct frame_info *);
- #define FRAME_CHAIN(thisframe) arm_frame_chain (thisframe)
-
- /* Define other aspects of the stack frame. */
-
- int arm_frameless_function_invocation (struct frame_info *fi);
- #define FRAMELESS_FUNCTION_INVOCATION(FI) arm_frameless_function_invocation(FI)
-
- CORE_ADDR arm_frame_saved_pc (struct frame_info *);
- #define FRAME_SAVED_PC(FI) arm_frame_saved_pc (FI)
-
- CORE_ADDR arm_frame_args_address(struct frame_info *);
- #define FRAME_ARGS_ADDRESS(FI) arm_frame_args_address(FI)
-
- CORE_ADDR arm_frame_locals_address(struct frame_info *);
- #define FRAME_LOCALS_ADDRESS(FI) arm_frame_locals_address(FI)
-
- int arm_frame_num_args(struct frame_info *);
- #define FRAME_NUM_ARGS(FI) arm_frame_num_args(FI)
-
- /* Return number of bytes at start of arglist that are not really args. */
-
- #define FRAME_ARGS_SKIP 0
-
- /* Put here the code to store, into a struct frame_saved_regs, the
- addresses of the saved registers of frame described by FRAME_INFO.
- This includes special registers such as pc and fp saved in special
- ways in the stack frame. sp is even more special: the address we
- return for it IS the sp for the next frame. */
-
- void arm_frame_init_saved_regs (struct frame_info *);
- #define FRAME_INIT_SAVED_REGS(frame_info) \
- arm_frame_init_saved_regs (frame_info);
-
- /* Push an empty stack frame, to record the current PC, etc. */
-
- void arm_push_dummy_frame (void);
-
- #define PUSH_DUMMY_FRAME arm_push_dummy_frame ()
-
- /* Discard from the stack the innermost frame, restoring all registers. */
-
- void arm_pop_frame (void);
-
- #define POP_FRAME arm_pop_frame ()
-
#define CALL_DUMMY_WORDS arm_call_dummy_words
extern LONGEST arm_call_dummy_words[];
--- 307,312 ----
*************** void arm_fix_call_dummy (char *dummy, CO
*** 399,407 ****
#define SOFTWARE_SINGLE_STEP(sig,bpt) arm_software_single_step((sig), (bpt))
void arm_software_single_step (int, int);
- CORE_ADDR arm_get_next_pc (CORE_ADDR pc);
-
-
struct minimal_symbol;
void arm_elf_make_msymbol_special(asymbol *, struct minimal_symbol *);
--- 335,340 ----
*************** void arm_coff_make_msymbol_special(int,
*** 414,425 ****
/* The first 0x20 bytes are the trap vectors. */
#define LOWEST_PC 0x20
-
- /* Function to determine whether MEMADDR is in a Thumb function. */
- extern int arm_pc_is_thumb (bfd_vma memaddr);
-
- /* Function to determine whether MEMADDR is in a call dummy called from
- a Thumb function. */
- extern int arm_pc_is_thumb_dummy (bfd_vma memaddr);
#endif /* TM_ARM_H */
--- 347,351 ----