Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [commit] mep-tdep.c: prologue analyzer update
@ 2007-07-13  0:01 Kevin Buettner
  2007-07-13  3:17 ` Jim Blandy
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Buettner @ 2007-07-13  0:01 UTC (permalink / raw)
  To: gdb-patches

I've just committed the patch below.  It fixes a gdb.base/break.exp
failure when using a gcc-4.x based compiler.  (See the comment in the
patch for a full explanation.)

	* mep-tdep.c (IS_BRA, BRA_DISP): New macros.
	(mep_analyze_prologue): Add case for BRA instruction.

Index: mep-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mep-tdep.c,v
retrieving revision 1.5
diff -u -p -r1.5 mep-tdep.c
--- mep-tdep.c	16 Jun 2007 17:16:25 -0000	1.5
+++ mep-tdep.c	12 Jul 2007 23:52:31 -0000
@@ -1578,6 +1578,10 @@ mep_get_insn (CORE_ADDR pc, long *insn)
 #define MOV_TARGET(i)	      (FIELD (i, 24, 4))
 #define MOV_SOURCE(i)	      (FIELD (i, 20, 4))
 
+/* BRA disp12.align2	      1011_dddd_dddd_ddd0 xxxx_xxxx_xxxx_xxxx */
+#define IS_BRA(i)	      (((i) & 0xf0010000) == 0xb0000000)
+#define BRA_DISP(i)           (SFIELD (i, 17, 11) << 1)
+
 
 /* This structure holds the results of a prologue analysis.  */
 struct mep_prologue
@@ -1806,6 +1810,19 @@ mep_analyze_prologue (CORE_ADDR start_pc
 
           reg[rn] = pv_area_fetch (stack, addr, 4);
         }
+      else if (IS_BRA (insn) && BRA_DISP (insn) > 0)
+	{
+	  /* When a loop appears as the first statement as a function
+	     body, gcc 4.x will use a BRA instruction to branch to the
+	     loop condition checking code.  This BRA instruction is
+	     marked as part of the prologue.  We therefore set next_pc
+	     to this branch target and also stop the prologue scan. 
+	     The instructions at and beyond the branch target should
+	     no longer be associated with the prologue.  */
+	  next_pc = pc + BRA_DISP (insn);
+	  after_last_frame_setup_insn = next_pc;
+	  break;
+	}
       else
         /* We've hit some instruction we don't know how to simulate.
            Strictly speaking, we should set every value we're


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [commit] mep-tdep.c: prologue analyzer update
  2007-07-13  0:01 [commit] mep-tdep.c: prologue analyzer update Kevin Buettner
@ 2007-07-13  3:17 ` Jim Blandy
  2007-07-14  0:17   ` Kevin Buettner
  0 siblings, 1 reply; 3+ messages in thread
From: Jim Blandy @ 2007-07-13  3:17 UTC (permalink / raw)
  To: Kevin Buettner; +Cc: gdb-patches


Kevin Buettner <kevinb@redhat.com> writes:
> I've just committed the patch below.  It fixes a gdb.base/break.exp
> failure when using a gcc-4.x based compiler.  (See the comment in the
> patch for a full explanation.)

The comment might want to mention why we should only do this for
forward branches.  :)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [commit] mep-tdep.c: prologue analyzer update
  2007-07-13  3:17 ` Jim Blandy
@ 2007-07-14  0:17   ` Kevin Buettner
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Buettner @ 2007-07-14  0:17 UTC (permalink / raw)
  To: gdb-patches

> The comment might want to mention why we should only do this for
> forward branches.  :)

Thanks for the feedback!  I've updated the comment as follows...

	* mep-tdep.c (mep_analyze_prologue): Update comment for BRA
	instruction case.

Index: mep-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mep-tdep.c,v
retrieving revision 1.6
diff -u -p -r1.6 mep-tdep.c
--- mep-tdep.c	13 Jul 2007 00:00:15 -0000	1.6
+++ mep-tdep.c	14 Jul 2007 00:14:16 -0000
@@ -1812,13 +1812,24 @@ mep_analyze_prologue (CORE_ADDR start_pc
         }
       else if (IS_BRA (insn) && BRA_DISP (insn) > 0)
 	{
-	  /* When a loop appears as the first statement as a function
+	  /* When a loop appears as the first statement of a function
 	     body, gcc 4.x will use a BRA instruction to branch to the
 	     loop condition checking code.  This BRA instruction is
 	     marked as part of the prologue.  We therefore set next_pc
 	     to this branch target and also stop the prologue scan. 
 	     The instructions at and beyond the branch target should
-	     no longer be associated with the prologue.  */
+	     no longer be associated with the prologue.
+	     
+	     Note that we only consider forward branches here.  We
+	     presume that a forward branch is being used to skip over
+	     a loop body.
+	     
+	     A backwards branch is covered by the default case below.
+	     If we were to encounter a backwards branch, that would
+	     most likely mean that we've scanned through a loop body.
+	     We definitely want to stop the prologue scan when this
+	     happens and that is precisely what is done by the default
+	     case below.  */
 	  next_pc = pc + BRA_DISP (insn);
 	  after_last_frame_setup_insn = next_pc;
 	  break;


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-07-14  0:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-13  0:01 [commit] mep-tdep.c: prologue analyzer update Kevin Buettner
2007-07-13  3:17 ` Jim Blandy
2007-07-14  0:17   ` Kevin Buettner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox