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]

[RFA] Recognize various saves in arm_scan_prologue



This adds to arm_scan_prologue the same insns that my previous
patch added to arm_skip_prologue.  Trying to keep 'em in sync...

2002-04-23  Michael Snyder  <msnyder@redhat.com>

	* arm-tdep.c (arm_scan_prologue): Move "mov ip, sp" into the 
	loop.  Add handling for "str lr, [sp, #-4]!" and for saves
	of argument regs ("str r(0123), [r11, #-nn"]).

Index: arm-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/arm-tdep.c,v
retrieving revision 1.52
diff -p -r1.52 arm-tdep.c
*** arm-tdep.c	23 Apr 2002 18:10:06 -0000	1.52
--- arm-tdep.c	24 Apr 2002 00:17:12 -0000
*************** arm_scan_prologue (struct frame_info *fi
*** 843,865 ****
       traceback.
  
       In the APCS, the prologue should start with  "mov ip, sp" so
!      if we don't see this as the first insn, we will stop.  [Note:
!      This doesn't seem to be true any longer, so it's now an optional
!      part of the prologue.  - Kevin Buettner, 2001-11-20]  */
  
!   sp_offset = fp_offset = 0;
  
!   if (read_memory_unsigned_integer (prologue_start, 4)
!       == 0xe1a0c00d)		/* mov ip, sp */
!     current_pc = prologue_start + 4;
!   else
!     current_pc = prologue_start;
  
!   for (; current_pc < prologue_end; current_pc += 4)
      {
        unsigned int insn = read_memory_unsigned_integer (current_pc, 4);
  
!       if ((insn & 0xffff0000) == 0xe92d0000)
  	/* stmfd sp!, {..., fp, ip, lr, pc}
  	   or
  	   stmfd sp!, {a1, a2, a3, a4}  */
--- 843,876 ----
       traceback.
  
       In the APCS, the prologue should start with  "mov ip, sp" so
!      if we don't see this as the first insn, we will stop.  
  
!      [Note: This doesn't seem to be true any longer, so it's now an
!      optional part of the prologue.  - Kevin Buettner, 2001-11-20]
! 
!      [Note further: The "mov ip,sp" only seems to be missing in
!      frameless functions at optimization level "-O2" or above,
!      in which case it is often (but not always) replaced by
!      "str lr, [sp, #-4]!".  - Michael Snyder, 2002-04-23]   */
  
!   sp_offset = fp_offset = 0;
  
!   for (current_pc = prologue_start; 
!        current_pc < prologue_end; 
!        current_pc += 4)
      {
        unsigned int insn = read_memory_unsigned_integer (current_pc, 4);
  
!       if (insn == 0xe1a0c00d)           /* mov ip, sp */
! 	{
! 	  continue;
! 	}
!       else if (insn == 0xe52de004)      /* str lr, [sp, #-4]! */
! 	{
! 	  /* Function is frameless: extra_info defaults OK?  */
! 	  continue;
! 	}
!       else if ((insn & 0xffff0000) == 0xe92d0000)
  	/* stmfd sp!, {..., fp, ip, lr, pc}
  	   or
  	   stmfd sp!, {a1, a2, a3, a4}  */
*************** arm_scan_prologue (struct frame_info *fi
*** 873,878 ****
--- 884,894 ----
  		sp_offset -= 4;
  		fi->saved_regs[regno] = sp_offset;
  	      }
+ 	}
+       else if ((insn & 0xffffcfc0) == 0xe50b0000)       /* str rx, [r11, -n] */
+ 	{
+ 	  /* No need to add this to saved_regs -- it's just an arg reg.  */
+ 	  continue;
  	}
        else if ((insn & 0xfffff000) == 0xe24cb000)	/* sub fp, ip #n */
  	{


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