public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: "jlebon at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: systemtap@sourceware.org
Subject: [Bug translator/1133] support .callees probe pattern extension
Date: Fri, 31 Jan 2014 15:23:00 -0000	[thread overview]
Message-ID: <bug-1133-6586-p0KaAddv8B@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-1133-6586@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=1133

--- Comment #8 from Jonathan Lebon <jlebon at redhat dot com> ---
(In reply to Jonathan Lebon from comment #6)
> I forgot to add also that for now, .callee simply places probes on callees'
> entry points, which means that they will trigger regardless of who the
> caller actually is. The future DW_AT_call_site_pc attribute should allow us
> to painlessly place probe points on the call site itself rather than at
> entry.
> 
> As a workaround for now, we could implement a tapset function e.g.
> is_caller("wanted_caller") to do this. Not sure how precise this would be,
> or whether it needs to be built into the probe, or something users would add
> explicitly (maybe we could add a more general
> .function("func").from("parent") form to which .callee would degenerate).

I've implemented this by adding a condition expression to the probe points
created which check if it's the right caller:

$ cd temp
$ cat truecallee.c 
// gcc -o truecallee truecallee.c -g -O

__attribute__((noinline))
int foo(int a, int b) {
   return a + b;
}

__attribute__((noinline))
int bar(int a, int b) {
   return foo(a*b, a-b);
}

int main(int argc, char** argv) {
   int a = argc;
   a = foo(a, a);
   a = bar(a, a);
   return a;
}

$ gcc -o truecallee truecallee.c -g -O
$ stap -L 'process("truecallee").function("main").callee("foo")'
process("/home/yyz/jlebon/codebase/systemtap/systemtap/temp/truecallee").function("foo@/home/yyz/jlebon/codebase/systemtap/systemtap/temp/truecallee.c:4")
if ((ustack(1)) == (0x40050b)) $a:int $b:int
$ stap -L 'process("truecallee").function("bar").callee("foo")'
process("/home/yyz/jlebon/codebase/systemtap/systemtap/temp/truecallee").function("foo@/home/yyz/jlebon/codebase/systemtap/systemtap/temp/truecallee.c:4")
if ((ustack(1)) == (0x400502)) $a:int $b:int
$ 
$ stap -we 'probe process.function("bar").callee("foo") { println("This is the
foo() call from bar(), not main()"); printf("My parent function is: %s\n",
usymname(ustack(1))); exit() }' -c ./truecallee
This is the foo() call from bar(), not main()
My parent function is: bar
$ 

It seems to work OK for now, but further testing is needed (esp. for inlines
and tail calls).

-- 
You are receiving this mail because:
You are the assignee for the bug.

  parent reply	other threads:[~2014-01-31 15:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-1133-6586@http.sourceware.org/bugzilla/>
2012-01-14 17:12 ` mjw at redhat dot com
2012-01-17 17:03 ` brolley at redhat dot com
2014-01-24 19:10 ` jlebon at redhat dot com
2014-01-28 21:00 ` jlebon at redhat dot com
2014-01-28 21:27 ` jlebon at redhat dot com
2014-01-30 15:50 ` jlebon at redhat dot com
2014-01-31 15:23 ` jlebon at redhat dot com [this message]
2014-02-05 18:44 ` jlebon at redhat dot com
2014-02-19 16:07 ` jlebon at redhat dot com
2014-02-19 16:34 ` jlebon at redhat dot com
     [not found] <20050728165308.1133.graydon@redhat.com>
2006-11-09 16:53 ` fche at redhat dot com

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=bug-1133-6586-p0KaAddv8B@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=systemtap@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).