This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: How can I access ULONG_MAX constant without using -g option?
- From: David Smith <dsmith at redhat dot com>
- To: Tetsuo Handa <penguin-kernel at I-love dot SAKURA dot ne dot jp>, fche at redhat dot com
- Cc: systemtap at sourceware dot org
- Date: Thu, 08 May 2014 11:51:36 -0500
- Subject: Re: How can I access ULONG_MAX constant without using -g option?
- Authentication-results: sourceware.org; auth=none
- References: <201405061502 dot JDC34371 dot FFVOSFQtOOHMJL at I-love dot SAKURA dot ne dot jp> <y0moazaisop dot fsf at fche dot csb> <201405072313 dot JHA93652 dot VOOFJtLFOQSHMF at I-love dot SAKURA dot ne dot jp>
On 05/07/2014 09:13 AM, Tetsuo Handa wrote:
> Frank Ch. Eigler wrote:
>>> [...]
>>> # stap -e 'probe begin { printf("current=%lx\n", task_current()); exit(); }'
>>> current=ffffffffc1681aa0
>>> In the example output above, current=c1681aa0 is the expected value on i686.
>>
>> To an extent, this is expected from use of signed pointer types. They
>> are sign-extended when widened. Is there some operational impact from
>> the upper 32-bits being set in your script, or just an aesthetic
>> preference?
I think I'm in agreement with Tetsuo here. A pointer is an unsigned
long. Systemtap pretending otherwise is mistaken.
> Also, it sounds inconsistent to me that
> function task_current:long ()
> function task_parent:long(task:long)
> function pid2task:long (pid:long)
> which returns address of "struct task_struct" as "long" returns addresses of
> different width.
>
> # stap -e 'probe begin { task = task_current();
> printf("current=%lx\nparent=%lx\ninit=%lx\n", task, task_parent(task),
> pid2task(1)); exit(); } '
> current=fffffffff5c7b550
> parent=c1581000
> init=fffffffff7081aa0
That certainly seems wrong to me.
> I think that returning 32-bits address on 32-bits kernel like
>
> current=f5c7b550
> parent=c1581000
> init=f7081aa0
>
> is the expected result which can be done by making changes shown below.
>
> --- task.stp
> +++ task.stp
> @@ -29,7 +29,7 @@
> * more task-specific data.
> */
> function task_current:long () %{ /* pure */
> - STAP_RETVALUE = (long)current;
> + STAP_RETVALUE = (unsigned long)current;
> %}
>
> /**
> @@ -110,7 +110,7 @@ function pid2task:long (pid:long) %{ /*
> #endif /* 2.6.24 */
> #endif /* 2.6.31 */
> rcu_read_unlock();
> - STAP_RETVALUE = (long)t;
> + STAP_RETVALUE = (unsigned long)t;
> %}
>
> /**
>
Frank, unless you are set against this change I'd like to check this in.
--
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)