This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: Is this a bug from function kernel_int?
On Sun, Jan 20, 2019 at 3:49 AM Yue Cao <yuecao1990@gmail.com> wrote:
>
> Hi there,
>
> Recently I find systemtap generates a wrong result when I use kernel_int to
> print out the int value from the pointer. In my case, systemtap prints out
> a huge value (18446744072649393666) with kernel_int. As you can see, this
> value is larger than 2^32 (the maximal value for int). However, when I use
> kernel_long, the result is within 2^32. The new value (3234809346) actually
> is equal to what I expected by using kernel_int. I have tried multiple
> times and the results are same. I wonder is it a bug. Could anyone tell me
> how to fix it?
You are confusing an 'int' with a 32-bit value. Depending on the
architecture, they aren't the same. Typically on a 64-bit platform,
the C language type 'int' is a 64-bit value. Typically on a 32-bit
platform, the C language type 'int' is a 32-bit value.
If you are sure you want a 32-bit value, you can call the __int32()
function on a value. (Although note that the '__' prefix means that is
really an internal function by convention.)
So, depending on your architecture, kernel_int() returning a 64-bit
value could be a bug or could be the expected behavior.
--
David Smith
Associate Manager
Red Hat