kread() and NULL pointers
Stone, Joshua I
joshua.i.stone@intel.com
Mon Jul 16 23:52:00 GMT 2007
Mike Mason wrote:
> So should the following generate an error? It doesn't. It just prints
> "ptr = 0" and exits.
>
> function test_addr:long () %{
> void *nullptr = NULL;
> THIS->__retvalue = (long) kread(&(nullptr));
-----------------------------------------^
You're reading the address *of* your pointer, not the address in the
pointer. Thus kread() is dereferencing an address on the stack, and the
value there is NULL. Drop the '&', and change nullptr to a type that's
meaningful to dereference (e.g., long*), and you'll get your error.
The "&(xxx)" pattern you see everywhere is because usually the "xxx" is
a struct value, and so you pass kread() a pointer to that value.
Josh
More information about the Systemtap
mailing list