can't print a target pointer string field

Josh Stone jistone@redhat.com
Sat Sep 8 01:03:00 GMT 2012


On 09/07/2012 05:26 PM, Jeff Haran wrote:
> struct net_device
> {
>         ...
>         char                    name[IFNAMSIZ];
>         ...
> };
> 
> So skb->dev->name looks like a string to me.
> 
> Why the reported type mismatch? And how can I display the name field, if that's possible?

We treat char[] the same as char*, and when you read any pointer in stap
it's carried around as a long (int64_t).  That's why it won't match the
%s, but %d/%x/%p would all be fine.

To use it as a stap string, it must be converted, for instance by
calling kernel_string($skb->dev->name).  If you're on at least stap 1.3,
you can use the pretty-print suffix ($skb->dev->name$).

Both of those assume there's always a \0 terminator.  If that name might
sometimes fill the whole IFNAMSIZ without a \0, then you'll need to use
kernel_string_n() explicitly.


Josh



More information about the Systemtap mailing list