Upgrade to Pro — share decks privately, control downloads, hide ads and more …

DTrace: printf debugging for seventh-level wizards

Shawn Moore
January 14, 2012

DTrace: printf debugging for seventh-level wizards

Shawn Moore

January 14, 2012
Tweet

More Decks by Shawn Moore

Other Decks in Programming

Transcript

  1. ME ME ME ME ME ME ME Shawn M Moore

    @sartak I’m Bawstin’ Moose-lover Infinity Interactive 12೥1݄14೔౔༵೔
  2. What’s my computer doing right now? Q: A: Find out

    with DTrace 12೥1݄14೔౔༵೔
  3. iotop $ iotop dtrace: failed to initialize dtrace: DTrace requires

    additional privileges You may already have DTrace and not even know it. 12೥1݄14೔౔༵೔
  4. Solaris & OS X (complete) Linux (partial) Profiler (Different and

    deeper than NYTProf) Debugger Kernel module “You don’t port DTrace to an OS, you port an OS to DTrace” DTRACE 12೥1݄14೔౔༵೔
  5. SAFE! ɾNo unwanted side effects ɾVery low overhead ɾDo it

    in production! 12೥1݄14೔౔༵೔
  6. σϞ pidpersec iotop execsnoop opensnoop dtruss plockstat iosnoop Global (high

    level) The metal (low level) 12೥1݄14೔౔༵೔
  7. σϞ pidpersec iotop execsnoop opensnoop dtruss plockstat iosnoop Global (high

    level) The metal (low level) 12೥1݄14೔౔༵೔
  8. PROGRAMMABILITY dtrace -n ' syscall::open:entry /strstr(copyinstr(arg0), "corpus") != NULL/ {

    printf("%s %s",execname,copyinstr(arg0)); }' Show processes that open a file whose name includes “corpus” 12೥1݄14೔౔༵೔
  9. PROGRAMMABILITY dtrace -n ' syscall::open:entry /strstr(copyinstr(arg0), "corpus") != NULL/ {

    printf("%s %s",execname,copyinstr(arg0)); }' Show processes that open a file whose name includes “corpus” Event(Probe Description) 12೥1݄14೔౔༵೔
  10. PROGRAMMABILITY dtrace -n ' syscall::open:entry /strstr(copyinstr(arg0), "corpus") != NULL/ {

    printf("%s %s",execname,copyinstr(arg0)); }' Show processes that open a file whose name includes “corpus” Predicate 12೥1݄14೔౔༵೔
  11. PROGRAMMABILITY dtrace -n ' syscall::open:entry /strstr(copyinstr(arg0), "corpus") != NULL/ {

    printf("%s %s",execname,copyinstr(arg0)); }' Show processes that open a file whose name includes “corpus” Action 12೥1݄14೔౔༵೔
  12. PROGRAMMABILITY dtrace -n ' syscall::open:entry /strstr(copyinstr(arg0), "corpus") != NULL/ {

    printf("%s %s",execname,copyinstr(arg0)); }' Show processes that open a file whose name includes “corpus” 12೥1݄14೔౔༵೔
  13. DTrace instrumentation points ɾKernel function calls/returns (syscalls too) ɾPerl function

    calls/returns ɾSQL execution ɾthreads ɾsignals ɾmany more PROBES 12೥1݄14೔౔༵೔
  14. DEBUGGER Request Tracker (e.g. rt.cpan.org) was failing tests on mod_perl.

    On only my computer. Probably because of all the Japanese. 12೥1݄14೔౔༵೔
  15. DEBUGGER Failed test 'gpg: error reading key: ެ։伴͕ݟ͔ͭΓ·ͤΜ' doesn't match

    '(?-xism:public key not found)' 12೥1݄14೔౔༵೔
  16. DEBUGGER gpg-2.0.18 $ echo "ެ։伴͕ݟ͔ͭΓ·ͤΜ" | iconv -f UTF-8 -t

    EUCJP | xargs ack -ao | iconv -f EUCJP -t UTF-8 Binary file po/ja.gmo matches po/ja.po:2965:ެ։伴͕ݟ͔ͭΓ·ͤΜ po/ja.po:6525:ެ։伴͕ݟ͔ͭΓ·ͤΜ po/ja.po:8311:ެ։伴͕ݟ͔ͭΓ·ͤΜ gpg-2.0.18 $ 12೥1݄14೔౔༵೔
  17. DEBUGGER then repeated a couple of times because I’m a

    “throw everything til something sticks” kinda guy 12೥1݄14೔౔༵೔
  18. Perl ɾ5.10.0Ҏ߱: sub-entry, sub-return ɾ5.15.1Ҏ߱: phase-change ɹ ɾকདྷʁ: string eval౳

    My first Perl patch! Was simple! perldtrace 12೥1݄14೔౔༵೔