This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: problem when run tcp/udp probing script
On Mon, Mar 19, 2012 at 01:25:06PM +0800, ch huang wrote:
> i write the following script ( from book 'Instrumenting the Linux
> Kernel for Analyzing Performance and Functional Problems )
>
> probe udp.recvmsg {
> printf("%s: UDP: Receiving message. Socket %d. Size %d\n", execname(),
> sock, size)
> }
> [...]
> but why the value of socket is negative?
sock is a pointer of type struct sock*.
So it is better to print it as an hex value with:
printf("%s: UDP: Receiving message. Socket ptr 0x%x. Size %d\n", execname(),
sock, size);
When you print is as %d, it is interpreted as an signed long value and so
can also be negative.
If you are interested in the actual struct sock value you can also try pretty
printing it using @cast and adding $ at the end. e.g.
probe tcp.recvmsg {
printf("%s: TCP: Receiving message %s.\n", execname(),
@cast(sock, "struct sock")$)
}
Cheers,
Mark