Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: David Daney <ddaney@avtrex.com>
To: Nigel Stephens <nigel@mips.com>
Cc: Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
	ths@networkno.de, vagabon.xyz@gmail.com,
	linux-mips@linux-mips.org, ralf@linux-mips.org
Subject: Re: [PATCH] dump_stack() based on prologue code analysis
Date: Fri, 28 Jul 2006 11:32:23 -0700	[thread overview]
Message-ID: <44CA5837.2060502@avtrex.com> (raw)
In-Reply-To: <44CA4AA3.8080700@mips.com>

Nigel Stephens wrote:
> 
> 
> David Daney wrote:
> 
>> Atsushi Nemoto wrote:
>>
>>> On Thu, 27 Jul 2006 20:12:45 +0100, Thiemo Seufer <ths@networkno.de> 
>>> wrote:
>>>
>>>> IOW, binary analysis can't be expected to provide full accuracy, but
>>>> we can live with a reasonable approximation, I think.
>>>
>>>
>>>
>>> Yes, this is a starting point.
>>>
>>> The patch (and current mips get_wchan() implementation) tries to do is
>>> what I used to do to analyze stack dump by hand.
>>>
>>> 1. Determine PC and SP.
>>> 2. Disassemble a function containing the PC address.
>>> 3. If the function is leaf, make use RA for new PC.
>>
>>
>> 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.

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.

But that does not work if you are in a function that has multiple return 
points.  On encountering a j $31 you have no way of telling if you are 
in a leaf function or a non-leaf function with multiple return points.

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.

Thanks,
David Daney.

  reply	other threads:[~2006-07-28 18:32 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-26 14:22 [PATCH] dump_stack() based on prologue code analysis Atsushi Nemoto
2006-07-27 14:33 ` Franck Bui-Huu
2006-07-27 19:03   ` Franck Bui-Huu
2006-07-28  8:16     ` Franck Bui-Huu
2006-07-28 16:08       ` Atsushi Nemoto
2006-07-28 16:01     ` Atsushi Nemoto
2006-07-31  9:15       ` Franck Bui-Huu
2006-07-31 13:39         ` Atsushi Nemoto
2006-07-31 14:32           ` Franck Bui-Huu
2006-07-31 15:33             ` Atsushi Nemoto
2006-07-31 15:51               ` Franck Bui-Huu
2006-07-31 15:59                 ` Atsushi Nemoto
2006-07-28 15:44   ` Atsushi Nemoto
2006-07-31  8:45     ` Franck Bui-Huu
2006-07-27 16:54 ` David Daney
2006-07-27 17:03   ` Thiemo Seufer
2006-07-27 17:27     ` David Daney
2006-07-27 18:51     ` Franck Bui-Huu
2006-07-27 19:12       ` Thiemo Seufer
2006-07-28 14:38         ` Atsushi Nemoto
2006-07-28 17:05           ` David Daney
2006-07-28 17:34             ` Nigel Stephens
2006-07-28 18:32               ` David Daney [this message]
2006-07-28 19:31                 ` Thiemo Seufer
2006-07-29 14:25                 ` Atsushi Nemoto

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=44CA5837.2060502@avtrex.com \
    --to=ddaney@avtrex.com \
    --cc=anemo@mba.ocn.ne.jp \
    --cc=linux-mips@linux-mips.org \
    --cc=nigel@mips.com \
    --cc=ralf@linux-mips.org \
    --cc=ths@networkno.de \
    --cc=vagabon.xyz@gmail.com \
    /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