linux-mips
[Top] [All Lists]

Re: [PATCH] dump_stack() based on prologue code analysis

To: ddaney@avtrex.com
Subject: Re: [PATCH] dump_stack() based on prologue code analysis
From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Date: Sat, 29 Jul 2006 23:25:23 +0900 (JST)
Cc: nigel@mips.com, ths@networkno.de, vagabon.xyz@gmail.com, linux-mips@linux-mips.org, ralf@linux-mips.org
In-reply-to: <44CA5837.2060502@avtrex.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <44CA43EC.9010904@avtrex.com> <44CA4AA3.8080700@mips.com> <44CA5837.2060502@avtrex.com>
Sender: linux-mips-bounce@linux-mips.org
On Fri, 28 Jul 2006 11:32:23 -0700, David Daney <ddaney@avtrex.com> wrote:
> >> This was always the tricky part for me.  How do you know if the 
> >> function is a leaf?
> > 
> > I think that if you cannot find a store instruction which saves RA to 
> > the stack -- either because it's a real leaf and there is no such store, 
> > or because the PC hasn't yet reached the store instruction -- then in 
> > both cases it can be treated as a leaf.

Right.

> Presumably you are walking the code back from the PC until you find the 
> prolog.  How would you tell if you had gone past the beginning of a leaf 
> function?  If you find a j $31 you might assume that it was the end of 
> the previous function.

I think you are misunderstanding here.

What the get_frame_info() doing is just searching "sw $ra, ofs($sp)"
and "addiu sp,sp,-imm" instructions from beginning of the function.
We can obtain the start address and size of the function by
kallsyms_lookup().  This is why those stuff depend on CONFIG_KALLSYMS.

> I may be missing something here, if you know of a failure-proof manner 
> to detect leaf functions I would appreciate hearing what it is.

I have no good idea to do it without CONFIG_KALL_SYMS.
I suppose there is no silver bullet here...

---
Atsushi Nemoto

<Prev in Thread] Current Thread [Next in Thread>