Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Don Bowman <don@sandvine.com>
To: 'Greg McGary' <greg@mcgary.org>, Don Bowman <don@sandvine.com>
Cc: 'Daniel Jacobowitz' <drow@mvista.com>,
	gdb@sources.redhat.com,  echristo@redhat.com
Subject: RE: MIPS stack tracing
Date: Sat, 02 Feb 2002 11:26:00 -0000	[thread overview]
Message-ID: <FE045D4D9F7AED4CBFF1B3B813C853371BC1C8@mail.sandvine.com> (raw)


> Greg McGary <greg@mcgary.org> writes:
> 
> > The gist of it is, walk backwards until you find 'jr ra',
> > then walk forwards to the first non-null instruction. That's
> > the start of a function. Look for a [d]addiu to the sp, that's
> > the stack adjustment, look for a [d]addiu to the fp, that's
> > the frame. Look for a s[w|d] of ra to the stack.
> > Continue on up the stack.
> > 
> > However, gcc 3.0 is breaking the rules. It emits multiple
> > 'jr ra' per function. Unfortunately, this appears to be
> > rather tough to fix. The upshot is that the beginning of
> > a function can't be reliably found, and it all falls apart
> > from there. Prior to gcc 3.0 it was fine.
> 
> [ Cc'd to Eric Christopher who has a hand in the MIPS GCC backend, and
>   with whom I briefly discussed this very issue a couple weeks ago. ]
> 
> Hmm...  GCC emitted multiple returns for MIPS long before 3.0.
> I recall first observing it in early 1998, and it had probably
> done it before.  Maybe GCC 3.0 does it more often?
> 
> Anyway, I had the same gripe about multiple returns breaking the ABI,
> but since then I have had second thoughts that perhaps this isn't a
> real problem.  I haven't looked at MIPS code recently, so don't know
> for certain if my reasoning here is correct.  Since you have had your
> nose buried in the code, you can tell me if my argument makes sense:
> 
> If a function has a frame, it never has multiple returns.  It always
> branches to the epilogue where the call frame is torn down.  So, if a
> function has multiple returns, that means it is frameless,
> i.e. there's no prologue or epilogue.  Say you scan backward within a
> frameless function.  You might hit an interior `jr $ra' or the one
> that terminates the previous function.  When you then scan forward,
> you'll find no stack adjustment and no store of $ra in any case.  In
> call cases, you get the same answer: this function has no frame.
> Therefore, multiple returns are harmless since they give no false
> information about the call frame.

I've personally never observed multiple returns prior to 3.0, but perhaps 
I had some optimisation disabled which caused it.

I don't think you're correct about the no-multiple returns when there's
a frame. Here's a snippet of assembly from a function of mine.
As you can see, the stack is adjusted by 64 at the top. There
is an interior return which deadjusts the stack, and there's more
further down in the function.

 <osiSemaphore::Init(osiSemaphoreType)>:
0080102d        move    v0,a0
24470004        addiu   a3,v0,4
27bdffc0        addiu   sp,sp,-64
00a0402d        move    t0,a1
  ...
afa00030        sw      zero,48(sp)
dfbf0038        ld      ra,56(sp)
03e00008        jr      ra
27bd0040        addiu   sp,sp,64
00000000        nop
0c000000        jal     0 <osiSemaphore::Init(osiSemaphoreType)>
  ...

I've been debugging through gdb for a day or so now, I think 
I'm on to something. It appears that find_proc_desc is switching
to the heuristic approach even though I have a symbol table.
It sucessfully find the symbols, but given a PC, can't find
the symbol that its in. This may be due to the sign-extension
on the addresses (eg ffffffff80000000). I'm hoping to get a
fix for gdb today and send in a patch.

--don


             reply	other threads:[~2002-02-02 19:26 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-02 11:26 Don Bowman [this message]
2002-02-02 12:11 ` Stan Shebs
  -- strict thread matches above, loose matches on Subject: below --
2002-02-07  6:56 Don Bowman
2002-02-07  7:30 ` Daniel Jacobowitz
2002-02-06  9:40 Don Bowman
2002-02-06 16:45 ` Daniel Jacobowitz
2002-02-04  9:22 David Anderson
2002-02-03 15:49 Don Bowman
2002-02-03 12:29 Don Bowman
2002-02-03 12:29 ` Daniel Jacobowitz
2002-02-03 12:29   ` Andrew Cagney
2002-02-03 12:13     ` Daniel Jacobowitz
2002-02-03 12:29       ` Andrew Cagney
2002-02-02 12:14 Don Bowman
2002-02-02 14:45 ` Daniel Jacobowitz
2002-02-02 10:58 David Anderson
2002-02-02  9:57 David Anderson
2002-02-01 10:15 Don Bowman
2002-02-01 11:32 ` Daniel Jacobowitz
2002-02-02 11:16 ` Greg McGary
2002-01-31 14:27 Don Bowman
2002-02-01  9:37 ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=FE045D4D9F7AED4CBFF1B3B813C853371BC1C8@mail.sandvine.com \
    --to=don@sandvine.com \
    --cc=drow@mvista.com \
    --cc=echristo@redhat.com \
    --cc=gdb@sources.redhat.com \
    --cc=greg@mcgary.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox