dtrace4linux / linux

dtrace for linux - kernel driver and userland tools
http://crtags.blogspot.com
1.17k stars 226 forks source link

missing kernel symbols, eg, struct sock #56

Closed brendangregg closed 11 years ago

brendangregg commented 11 years ago

I had this script (tcpretransmit.d) working a while ago on Fedora:

#!/usr/sbin/dtrace -s

#pragma D option quiet

dtrace:::BEGIN { trace("Tracing TCP retransmits... Ctrl-C to end.\n"); }

fbt::tcp_retransmit_skb:entry {
    this->so = (struct sock *)arg0;
    this->d = (unsigned char *)&this->so->__sk_common.skc_daddr;
    printf("%Y: retransmit to %d.%d.%d.%d, by:", walltimestamp,
        this->d[0], this->d[1], this->d[2], this->d[3]);
    stack(99);
}

On Ubuntu 12.04 (3.5 kernel) I get:

root@ubuntu:~/linux# ~/tcpretransmit.d 
dtrace: failed to compile script /home/brendan/tcpretransmit.d: line 9: operator -> cannot be applied to a forward declaration: no struct sock definition is available

I tried adding struct sock to driver/ctf_struct.c, but couldn't get it to work.

I didn't have this problem before, so maybe something isn't getting built properly. The ctf file looks small:

-rw-r--r-- 1 root root 112848 May 28 15:23 build/linux-3.5.0-23-generic.ctf
dtrace4linux commented 11 years ago

The file size agrees with my one (~104k). You can run

$ build/ctdump build/linux-XXX.ctf | grep -w sock

<1546> STRUCT sock (648 bytes) [26072] sock so it should work. Hm. Doesnt work for me tho. I did recently patch ctfconvert to handle zero sized arrays so maybe I broke that. Another one to investigate .. either tomorrow or day after depending on how late I get back. On 28 May 2013 23:29, Brendan Gregg notifications@github.com wrote: > I had this script (tcpretransmit.d) working a while ago on Fedora: > > #!/usr/sbin/dtrace -s > > #pragma D option quiet > > dtrace:::BEGIN { trace("Tracing TCP retransmits... Ctrl-C to end.\n"); } > > fbt::tcp_retransmit_skb:entry { > this->so = (struct sock *)arg0; > this->d = (unsigned char *)&this->so->__sk_common.skc_daddr; > printf("%Y: retransmit to %d.%d.%d.%d, by:", walltimestamp, > this->d[0], this->d[1], this->d[2], this->d[3]); > stack(99); > } > > On Ubuntu 12.04 (3.5 kernel) I get: > > root@ubuntu:~/linux# ~/tcpretransmit.d > dtrace: failed to compile script /home/brendan/tcpretransmit.d: line 9: operator -> cannot be applied to a forward declaration: no struct sock definition is available > > I tried adding struct sock to driver/ctf_struct.c, but couldn't get it to > work. > > I didn't have this problem before, so maybe something isn't getting built > properly. The ctf file looks small: > > -rw-r--r-- 1 root root 112848 May 28 15:23 build/linux-3.5.0-23-generic.ctf > > — > Reply to this email directly or view it on GitHubhttps://github.com/dtrace4linux/linux/issues/56 > .
dtrace4linux commented 11 years ago

Resolved. Am very annoyed at that change/breakage as between Sun and Redhat, someone screwed up. See Changes file for my comments :-)

On 28 May 2013 23:42, Paul Fox paul.d.fox@gmail.com wrote:

The file size agrees with my one (~104k). You can run

$ build/ctdump build/linux-XXX.ctf | grep -w sock

<1546> STRUCT sock (648 bytes) [26072] sock so it should work. Hm. Doesnt work for me tho. I did recently patch ctfconvert to handle zero sized arrays so maybe I broke that. Another one to investigate .. either tomorrow or day after depending on how late I get back. On 28 May 2013 23:29, Brendan Gregg notifications@github.com wrote: > I had this script (tcpretransmit.d) working a while ago on Fedora: > > #!/usr/sbin/dtrace -s > > #pragma D option quiet > > dtrace:::BEGIN { trace("Tracing TCP retransmits... Ctrl-C to end.\n"); } > > fbt::tcp_retransmit_skb:entry { > this->so = (struct sock *)arg0; > this->d = (unsigned char *)&this->so->__sk_common.skc_daddr; > printf("%Y: retransmit to %d.%d.%d.%d, by:", walltimestamp, > this->d[0], this->d[1], this->d[2], this->d[3]); > stack(99); > } > > On Ubuntu 12.04 (3.5 kernel) I get: > > root@ubuntu:~/linux# ~/tcpretransmit.d > dtrace: failed to compile script /home/brendan/tcpretransmit.d: line 9: operator -> cannot be applied to a forward declaration: no struct sock definition is available > > I tried adding struct sock to driver/ctf_struct.c, but couldn't get it to > work. > > I didn't have this problem before, so maybe something isn't getting built > properly. The ctf file looks small: > > -rw-r--r-- 1 root root 112848 May 28 15:23 build/linux-3.5.0-23-generic.ctf > > — > Reply to this email directly or view it on GitHubhttps://github.com/dtrace4linux/linux/issues/56 > .
brendangregg commented 11 years ago

Thanks! This works - my old scripts are working again:


root@ubuntu:~/brendan# ./ext4slower.d 
Tracing ext4 read/write slower than 0 ms
TIME                 PROCESS          D   KB     ms FILE
1970 Jan  1 17:48:52 bash             R    0      0 ls
1970 Jan  1 17:48:52 bash             R    0      0 ls
1970 Jan  1 17:48:52 bash             R    0      0 ls
1970 Jan  1 17:48:52 bash             R    0      0 ld-2.15.so
1970 Jan  1 17:48:52 ls               R    0      0 ld-2.15.so
1970 Jan  1 17:48:52 ls               R    0      0 libselinux.so.1
1970 Jan  1 17:48:52 ls               R    0      0 librt-2.15.so
.....