This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH gdb/arm make frame macros into functions



This patch converts most of the FRAME_ related macros that still contained 
in-line code into functions.  I've also taken the opportunity to move some 
related comments from the include file to the relevant places in the C 
code.

Committed as obvious.

R.

2002-02-01  Richard Earnshaw  <reanrsha@arm.com>

	* arm-tdep.c (arm_frameless_function_invocation): Add some comments.
	(arm_frame_args_address, arm_frame_locals_address): New functions.
	(arm_frame_num_args): New function.
	* config/tm-arm.h (FRAME_ARGS_ADDRESS): Call arm_frame_args_address.
	(FRAME_LOCALS_ADDRESS): Call arm_frame_locals_address.
	(FRMA_NUM_ARGS): Call arm_frame_num_args.


Index: arm-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/arm-tdep.c,v
retrieving revision 1.30
diff -p -r1.30 arm-tdep.c
*** arm-tdep.c	2002/01/30 16:35:51	1.30
--- arm-tdep.c	2002/02/01 13:30:45
*************** arm_saved_pc_after_call (struct frame_in
*** 297,308 ****
--- 297,324 ----
    return ADDR_BITS_REMOVE (read_register (LR_REGNUM));
  }
  
+ /* Determine whether the function invocation represented by FI has a
+    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;
    int frameless;
  
+   /* Sometimes we have functions that do a little setup (like saving the
+      vN registers with the stmdb instruction, but DO NOT set up a frame.
+      The symbol table will report this as a prologue.  However, it is
+      important not to try to parse these partial frames as frames, or we
+      will get really confused.
+ 
+      So I will demand 3 instructions between the start & end of the
+      prologue before I call it a real prologue, i.e. at least
+ 	mov ip, sp,
+ 	stmdb sp!, {}
+ 	sub sp, ip, #4.  */
+ 
    func_start = (get_pc_function_start ((fi)->pc) + FUNCTION_START_OFFSET);
    after_prologue = SKIP_PROLOGUE (func_start);
  
*************** arm_frameless_function_invocation (struc
*** 312,317 ****
--- 328,355 ----
  
    frameless = (after_prologue < func_start + 12);
    return frameless;
+ }
+ 
+ /* 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.  */
+   return -1;
  }
  
  /* A typical Thumb prologue looks like this:
Index: config/arm/tm-arm.h
===================================================================
RCS file: /cvs/src/src/gdb/config/arm/tm-arm.h,v
retrieving revision 1.19
diff -p -r1.19 tm-arm.h
*** tm-arm.h	2002/01/30 16:35:51	1.19
--- tm-arm.h	2002/02/01 13:30:49
*************** CORE_ADDR arm_target_read_fp (void);
*** 330,378 ****
     However, if FRAME_CHAIN_VALID returns zero,
     it means the given frame is the outermost one and has no caller.  */
  
  #define FRAME_CHAIN(thisframe) arm_frame_chain (thisframe)
- extern CORE_ADDR arm_frame_chain (struct frame_info *);
  
! extern int arm_frame_chain_valid (CORE_ADDR, struct frame_info *);
  #define FRAME_CHAIN_VALID(chain, thisframe) \
       arm_frame_chain_valid (chain, thisframe)
  
  /* Define other aspects of the stack frame.  */
  
! /* A macro that tells us whether the function invocation represented
!    by FI does not have a frame on the stack associated with it.  If it
!    does not, FRAMELESS is set to 1, else 0.
! 
!    Sometimes we have functions that do a little setup (like saving the
!    vN registers with the stmdb instruction, but DO NOT set up a frame.
!    The symbol table will report this as a prologue.  However, it is
!    important not to try to parse these partial frames as frames, or we
!    will get really confused.
! 
!    So I will demand 3 instructions between the start & end of the
!    prologue before I call it a real prologue, i.e. at least
!          mov ip, sp,
! 	 stmdb sp!, {}
! 	 sub sp, ip, #4. */
! 
! extern int arm_frameless_function_invocation (struct frame_info *fi);
! #define FRAMELESS_FUNCTION_INVOCATION(FI) \
! (arm_frameless_function_invocation (FI))
      
! /* Saved Pc.  */
  
! #define FRAME_SAVED_PC(FRAME)	arm_frame_saved_pc (FRAME)
! extern CORE_ADDR arm_frame_saved_pc (struct frame_info *);
  
! #define FRAME_ARGS_ADDRESS(fi) (fi->frame)
  
! #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
  
- /* Return number of args passed to a frame.
-    Can return -1, meaning no way to tell.  */
- 
- #define FRAME_NUM_ARGS(fi) (-1)
- 
  /* Return number of bytes at start of arglist that are not really args. */
  
  #define FRAME_ARGS_SKIP 0
--- 330,359 ----
     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)
  
! int arm_frame_chain_valid (CORE_ADDR, struct frame_info *);
  #define FRAME_CHAIN_VALID(chain, thisframe) \
       arm_frame_chain_valid (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
*************** void arm_frame_init_saved_regs (struct f
*** 389,398 ****
  
  /* Things needed for making the inferior call functions.  */
  
  #define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \
!      sp = arm_push_arguments ((nargs), (args), (sp), (struct_return), (struct_addr))
! extern CORE_ADDR arm_push_arguments (int, struct value **, CORE_ADDR, int,
! 				     CORE_ADDR);
  
  /* Push an empty stack frame, to record the current PC, etc.  */
  
--- 370,378 ----
  
  /* Things needed for making the inferior call functions.  */
  
+ CORE_ADDR arm_push_arguments (int, struct value **, CORE_ADDR, int, CORE_ADDR);
  #define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \
!      arm_push_arguments ((nargs), (args), (sp), (struct_return), (struct_addr))
  
  /* Push an empty stack frame, to record the current PC, etc.  */
  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]