This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: Systemtap puzzle
- From: "Frank Ch. Eigler" <fche at redhat dot com>
- To: Max Matveev <makc at redhat dot com>
- Cc: systemtap at sourceware dot org
- Date: Mon, 6 Aug 2012 07:31:25 -0400
- Subject: Re: Systemtap puzzle
- References: <20511.43230.209518.385114@regina.usersys.redhat.com>
Hi, Max -
makc wrote:
> [...] I'm getting correct values in .return probe if I push
> the pointer into a function and I'm getting zeros if I look at the
> values directly, e.g:
>
> [root@rebecca ~]# stap e1000e.stap
> direct ffff81000ce47cd8: speed 0, duplex 0
> func ffff81000ce47cd8: speed 1000, duplex 1
>
> the script is very simple
>
> function get_speed(cmd:long)
> {
> printf("func %x: speed %d, duplex %d\n", cmd,
> @cast(cmd, "struct ethtool_cmd")->speed,
> @cast(cmd, "struct ethtool_cmd")->duplex);
> }
> probe module("e1000").function("e1000_get_settings").return {
> printf("direct %x: speed %d, duplex %d\n", $ecmd,
> $ecmd->speed, $ecmd->duplex);
> get_speed($ecmd);
> }
The difference may be what is saved at function entry time. You're in
a .return probe, so $ecmd expressions are snapshots from the
function's entry time. So the probe-module printf may simply be
printing the entry-time fields of that struct; the function OTOH is
printing the return-time values (since only $ecmd is saved for that
call, not $ecmd-casted-dereferenced).
You might try using the more formal @entry($ecmd) vs
@entry($ecmd->field) syntax to help spell out the magic you want.
> This is systemtap 1.1-3.el5.
(That's rather old; @entry() arrived in 1.3; stap 1.6 has been
released within rhel5, and it'll likely be updated soon.)
- FChE