This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Re: Fix Sparc GDB regression


 In message <20020405102303.C17835@devserv.devel.redhat.com>, Jakub Jelinek 
writ
es:
 > > There turns out to be a test that specifically triggers this case in
 > > the GDB testsuite.  Basically it amounts to a function which calls
 > > abort(), the test lets the abort() happen, and verifies that the
 > > backtrace looks sane.  In the bogus backtrace, the function calling
 > > abort() did not even get mentioned.
Yup.  I believe I wrote the test a long long time ago as I ran into the
problem on the PA :-)

 > > This is likely to confuse not only GDB, as any Sparc backtrace
 > > mechanism is going to fall victim to this.
Yup.


 > Wouldn't it be better to really check if the last real instruction
 > (or dbr sequence) is a call? I'm afraid you'll emit nop even for
 > func1:
 >     ...
 >     b .L123
 >      do_something
 > func2:
 > 
 > > 2002-04-05  David S. Miller  <davem@redhat.com>
 > > 
 > > 	* config/sparc/sparc.c (sparc_nonflat_function_epilogue): If we
 > > 	are not going to emit return instructions, emit at least a nop
 > > 	for the sake of sane backtraces.
On the PA we always emit the nop for a CALL followed by a null epilogue,
even if the CALL had its delay slot filled.   On the PA the return 
points to the first instruction to execute after the call.  Emitting the
nop ensures the address in the return register points to an address in
the same function as the call instruction.

Based on David's comments the sparc uses ra+8, so avoiding the nop in
the case of a filled delay slot may make sense.


FWIW, here's the code we use on the PA -- INSN is the result of get_last_insn()

  /* Get the last real insn.  */
  if (GET_CODE (insn) == NOTE)
    insn = prev_real_insn (insn);

  /* If it is a sequence, then look inside.  */
  if (insn && GET_CODE (insn) == INSN && GET_CODE (PATTERN (insn)) == SEQUENCE)
    insn = XVECEXP (PATTERN (insn), 0, 0);

  /* If insn is a CALL_INSN, then it must be a call to a volatile
     function (otherwise there would be epilogue insns).  */
  if (insn && GET_CODE (insn) == CALL_INSN)
    fputs ("\tnop\n", file);


jeff


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