Bug 10820 - stap -L should take varaible location list into account
Summary: stap -L should take varaible location list into account
Status: RESOLVED FIXED
Alias: None
Product: systemtap
Classification: Unclassified
Component: translator (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-21 11:38 UTC by Mark Wielaard
Modified: 2009-10-29 01:41 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
patch and example (898 bytes, patch)
2009-10-28 08:08 UTC, Wenji Huang
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Wielaard 2009-10-21 11:38:20 UTC
Sometimes you believe a variable is available with -L, but then it turns out the
location list for that variable doesn't actually cover the address that we will
place the probe on.

For example:

$ stap -L 'kernel.function("tc_fill_tclass")'
kernel.function("tc_fill_tclass@net/sched/sch_api.c:990") $skb:struct sk_buff*
$q:struct Qdisc* $cl:long unsigned int $pid:u32 $seq:u32 $flags:u16 $event:int
$tcm:struct tcmsg* $nlh:struct nlmsghdr* $b:unsigned char* $d:struct gnet_dump
$cl_ops:struct Qdisc_class_ops*

But then when we try to actually query $tcm we get:
semantic error: not accessible at this address (0xffffffff80239505): identifier
'$tcm' at <input>:1:96
         source: probe kernel.function("tc_fill_tclass").return {
printf("pid=%d, cl=%d, tcm=%p.\n", $pid, $cl, $tcm-) }

Which is indeed correct, the location list for tcm says:

     0048393a ffffffff802395a2 ffffffff80239643 (DW_OP_reg6)
     0048393a ffffffff802396aa ffffffff80239719 (DW_OP_reg6)

So it isn't available at the (function entry) probe address.
Comment 1 Wenji Huang 2009-10-28 08:08:42 UTC
Created attachment 4332 [details]
patch and example

With this patch,

$ stap -L 'kernel.function("tc_fill_tclass")'
kernel.function("tc_fill_tclass@net/sched/sch_api.c:1435") $skb:struct sk_buff*
$q:struct Qdisc* $cl:long unsigned int $pid:u32 $seq:u32 $flags:u16 $event:int
$nlh:struct nlmsghdr* $b:unsigned char* $cl_ops:struct Qdisc_class_ops const*

We can see $tcm and $d are eliminated. And to access the listed variables,
$ stap -p4 -e 'probe
kernel.function("tc_fill_tclass"){print($skb+$q+$cl+$pid+$seq+$flags+$event+$nlh+$b+$cl_ops)}'

stap_16232.ko
Comment 2 Frank Ch. Eigler 2009-10-28 16:49:11 UTC
Looks good to me, please commit, unless jistone has objections.
Comment 3 Josh Stone 2009-10-28 18:16:44 UTC
Looks fine to me too, thanks!
Comment 4 Wenji Huang 2009-10-29 00:34:37 UTC
commit	f10534c6a2a958609b7bc76390d50c17a36250d3
Comment 5 Frank Ch. Eigler 2009-10-29 01:41:24 UTC
thanks!