public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* Question on checking the stack
@ 2005-10-13 10:44 Bryce
  2005-10-13 15:46 ` Frank Ch. Eigler
  0 siblings, 1 reply; 4+ messages in thread
From: Bryce @ 2005-10-13 10:44 UTC (permalink / raw)
  To: systemtap

Setting up a probe for a function is great and all but is there a way to 
test how we entered the routine?
 eg
  0xc024d991 : generic_make_request+0xa/0x24b
  0xc0145d20 : find_get_page+0x37/0x42
and
 0xc024d991 : generic_make_request+0xa/0x24b
 0xc024dc17 : submit_bio+0x45/0xcb

I'm not interested in  EVERY time we trace into a function, only when 
we've come from a different routine
is there something along the lines of this idea available?

probe kernel.function("generic_make_request") {
    if (stack(1) == "submit_bio" ) { // where stack(1) was the last 
routine  and stack(2) was 2nd last etc
         do_test/display
    }
}

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

* Re: Question on checking the stack
  2005-10-13 10:44 Question on checking the stack Bryce
@ 2005-10-13 15:46 ` Frank Ch. Eigler
  2005-10-13 15:58   ` Bryce
  0 siblings, 1 reply; 4+ messages in thread
From: Frank Ch. Eigler @ 2005-10-13 15:46 UTC (permalink / raw)
  To: Bryce; +Cc: systemtap


Bryce <philip.copeland@oracle.com> writes:

> Setting up a probe for a function is great and all but is there a way
> to test how we entered the routine?
> [...]

Just about all the essentials are in there somewhere, just
not in a convenient-to-use form.

> probe kernel.function("generic_make_request") {
>     if (stack(1) == "submit_bio" ) { // where stack(1) was the last
> routine  and stack(2) was 2nd last etc
>          do_test/display
>     }
> }

The tapset/context.stp file would need two new functions such as these:

  caller:string(n:long) - returns the nth substring as if from backtrace()
  addr2symbol:string(n:long) - address-to-symbol lookup, which is exactly
                               one stage of print_stack()

- FChE

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

* Re: Question on checking the stack
  2005-10-13 15:46 ` Frank Ch. Eigler
@ 2005-10-13 15:58   ` Bryce
  2005-10-13 17:01     ` Frank Ch. Eigler
  0 siblings, 1 reply; 4+ messages in thread
From: Bryce @ 2005-10-13 15:58 UTC (permalink / raw)
  Cc: systemtap

Frank Ch. Eigler wrote:

>Bryce <philip.copeland@oracle.com> writes:
>
>  
>
>>Setting up a probe for a function is great and all but is there a way
>>to test how we entered the routine?
>>[...]
>>    
>>
>
>Just about all the essentials are in there somewhere, just
>not in a convenient-to-use form.
>
>  
>
>>probe kernel.function("generic_make_request") {
>>    if (stack(1) == "submit_bio" ) { // where stack(1) was the last
>>routine  and stack(2) was 2nd last etc
>>         do_test/display
>>    }
>>}
>>    
>>
>
>The tapset/context.stp file would need two new functions such as these:
>
>  caller:string(n:long) - returns the nth substring as if from backtrace()
>  addr2symbol:string(n:long) - address-to-symbol lookup, which is exactly
>                               one stage of print_stack()
>
>- FChE
>  
>

*nod* Just Sebastiaens hack has the unfortunate problem of needing to 
know in advance what all the exit addresses from a routine and combing 
the stack looking for a string match is probably rather slow if it 
happens often enough.

Cheers

Phil
=--=


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

* Re: Question on checking the stack
  2005-10-13 15:58   ` Bryce
@ 2005-10-13 17:01     ` Frank Ch. Eigler
  0 siblings, 0 replies; 4+ messages in thread
From: Frank Ch. Eigler @ 2005-10-13 17:01 UTC (permalink / raw)
  To: Bryce; +Cc: systemtap

Bryce <philip.copeland@oracle.com> writes:

> [...]
> >>probe kernel.function("generic_make_request") {
> >>    if (stack(1) == "submit_bio" ) { // where stack(1) was the last
> >>routine  and stack(2) was 2nd last etc
> >>         do_test/display
> >>    }
> >>}
> >>[...]

> *nod* Just Sebastiaens hack has the unfortunate problem of needing
> to know in advance what all the exit addresses from a routine and
> combing the stack looking for a string match is probably rather slow
> if it happens often enough.

If one is stuck with the general approach of PC testing at the callee,
then one could micro-optimize the lookup a little more.  For example,
one could return a numeric PC value for "stack(1)", like GCC's
__builtin_return_address(1).  Such numbers would need to be converted
to symbol strings only once, since a yes/no judgement could be
memoized.

- FChE

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

end of thread, other threads:[~2005-10-13 17:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-13 10:44 Question on checking the stack Bryce
2005-10-13 15:46 ` Frank Ch. Eigler
2005-10-13 15:58   ` Bryce
2005-10-13 17:01     ` Frank Ch. Eigler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).