This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How can I access ULONG_MAX constant without using -g option?


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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]