Bug 819967

Summary: caller() doesn't work in systemtap
Product: Red Hat Enterprise Linux 6 Reporter: Michael S. Tsirkin <mst>
Component: systemtapAssignee: Frank Ch. Eigler <fche>
Status: CLOSED ERRATA QA Contact: Martin Cermak <mcermak>
Severity: low Docs Contact:
Priority: unspecified    
Version: 6.3CC: dsmith, mbenitez, mcermak, mjw, pmuller, scox
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: systemtap-2.3-1.el6 Doc Type: Bug Fix
Doc Text:
Cause: The systemtap translator wasn't always including the proper code to be able to use the 'caller()' function. Consequence: Some uses of the systemtap 'caller()' function can cause compile errors. Fix: Modify systemtap to make sure that when the 'caller()' function is used the proper runtime code gets included. Result: Use of the systemtap 'caller()' function does not cause compile errors.
Story Points: ---
Clone Of:
: 1013202 (view as bug list) Environment:
Last Closed: 2013-11-21 11:44:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Michael S. Tsirkin 2012-05-08 18:33:16 UTC
Description of problem:
using caller() in systemtap scripts does not work.
I think it worked in rhel5 but not sure.

Version-Release number of selected component (if applicable):
systemtap-1.7-3.el6.x86_64


How reproducible:

always

Steps to Reproduce:
1.create a script test.stp:
probe kernel.function("netif_receive_skb@net/core/dev.c"){ printf("netif_receive_skb %x from %s\n", $skb->ip_summed, caller());  }

2. run stap test.stp
  
Actual results:
fails with:
/tmp/stapkxUVo5/stap_40abae8a2d169ccb615c8254b8f81199_3385_src.c: In function ‘function_caller_addr’:
/tmp/stapkxUVo5/stap_40abae8a2d169ccb615c8254b8f81199_3385_src.c:564: error: dereferencing pointer to incomplete type
make[1]: *** [/tmp/stapkxUVo5/stap_40abae8a2d169ccb615c8254b8f81199_3385_src.o] Error 1
make: *** [_module_/tmp/stapkxUVo5] Error 2
WARNING: make exited with status: 2
Pass 4: compilation failed.  Try again with another '--vp 0001' option.



Expected results:
prints
netif_receive_skb X from <caller>
for each received packet

Additional info:

Comment 1 Frank Ch. Eigler 2012-05-08 18:39:01 UTC
upstream commit #4107dbc2c885 corrects this.

Comment 2 Michael S. Tsirkin 2012-05-08 18:43:54 UTC
additional info:
adding a userspace probe:
probe process("gcc").function("main").return { printf("%s\n", backtrace());}
as a work around
makes it not fail but it still does not work:

netif_receive_skb 1 from 0x0 0x0


instead of from <function name>

Comment 3 Michael S. Tsirkin 2012-05-08 18:51:49 UTC
here's a workaround avoiding caller():

function caller_n(n) {
     f = backtrace ()
     sym = tokenize(f, " ")
     for (i=1; i<n; i++)
        sym = tokenize("", " ")
     return sym
}

probe module("tun").function("tun_net_xmit@drivers/net/tun.c")  { printf("tun_net_xmit %x from %s\n", $skb->ip_summed, symdata(strtol(caller_n(1),16))); }  
probe kernel.function("dev_hard_start_xmit@net/core/dev.c"){ printf("dev_queue_start_xmit %x from %s\n", $skb->ip_summed, symdata(strtol(caller_n(1),16)));  }
probe kernel.function("netif_receive_skb@net/core/dev.c"){ printf("netif_receive_skb %x from %s\n", $skb->ip_summed, symdata(strtol(caller_n(1),16)));  }

Comment 5 Mark Wielaard 2012-05-08 18:56:05 UTC
Upstream commit makes the stap script compile again:

commit 4107dbc2c88536c3374a68948c7344af8c8e75aa
Author: Mark Wielaard <mjw>
Date:   Tue May 8 19:59:07 2012 +0200

    PR14079 - caller() pass-4 error if no uretprobes in script
    
    caller() is odd in that it tries to do both kernel and user caller.
    There is no ucaller(). Move it into its own tapset and include the
    right uprobes related structures.
    
    * runtime/uprobes-inc.h: New include file to be included in ...
    * runtime/stack.c: here and ...
    * tapset/context-caller.stp: here. New tapset, with just the caller context
      function, removed from ...
    * tapset/context-unwind.stp: here.
    * doc/SystemTap_Tapset_Reference/tapsets.tmpl: Also include context-caller.s

Comment 6 Mark Wielaard 2012-05-08 18:59:13 UTC
> makes it not fail but it still does not work:
>
> netif_receive_skb 1 from 0x0 0x0

That was because caller() only works for return probes. And this was a call probe.

Comment 10 RHEL Program Management 2012-07-10 08:38:19 UTC
This request was not resolved in time for the current release.
Red Hat invites you to ask your support representative to
propose this request, if still desired, for consideration in
the next release of Red Hat Enterprise Linux.

Comment 11 RHEL Program Management 2012-07-11 01:51:40 UTC
This request was erroneously removed from consideration in Red Hat Enterprise Linux 6.4, which is currently under development.  This request will be evaluated for inclusion in Red Hat Enterprise Linux 6.4.

Comment 12 Frank Ch. Eigler 2012-08-10 22:39:11 UTC
Resetting to devel_ack?, to wait for PR6580 (inclusion of caller_* in the tapset).

Comment 13 Frank Ch. Eigler 2012-10-18 15:21:28 UTC
upstream systemtap-2.0 includes full PR6580 goodness.

Comment 22 errata-xmlrpc 2013-11-21 11:44:13 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-1630.html