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

DTrace: printf debugging for seventh-level wizards

609c52819f220e49667a53cc0a82bfa7?s=47 Shawn Moore
January 14, 2012

DTrace: printf debugging for seventh-level wizards

609c52819f220e49667a53cc0a82bfa7?s=128

Shawn Moore

January 14, 2012
Tweet

Transcript

  1. @sartak DTRACE printf debugging for seventh-level wizards 12೥1݄14೔౔༵೔

  2. ME ME ME ME ME ME ME Shawn M Moore

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

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

    additional privileges You may already have DTrace and not even know it. 12೥1݄14೔౔༵೔
  5. 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೔౔༵೔
  6. SAFE! ɾNo unwanted side effects ɾVery low overhead ɾDo it

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

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

    level) The metal (low level) 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” 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” Event(Probe Description) 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” Predicate 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” Action 12೥1݄14೔౔༵೔
  13. 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೔౔༵೔
  14. DTrace instrumentation points ɾKernel function calls/returns (syscalls too) ɾPerl function

    calls/returns ɾSQL execution ɾthreads ɾsignals ɾmany more PROBES 12೥1݄14೔౔༵೔
  15. THE COOL DEMO HEY, FORGETFUL! DEMO THE GPG THING 12೥1݄14೔౔༵೔

  16. PROFILER Devel::NYTProf kicks ass 12೥1݄14೔౔༵೔

  17. PROFILER But there’s more than one way to do it

    12೥1݄14೔౔༵೔
  18. PROFILER DEMO: syscalls intuit_method 12೥1݄14೔౔༵೔

  19. XCode’s profiler uses DTrace 12೥1݄14೔౔༵೔

  20. 12೥1݄14೔౔༵೔

  21. TRANSLATION “I am comfortable being ignorant and helpless” 12೥1݄14೔౔༵೔

  22. 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೔౔༵೔
  23. DEBUGGER Failed test 'gpg: error reading key: ެ։伴͕ݟ͔ͭΓ·ͤΜ' doesn't match

    '(?-xism:public key not found)' 12೥1݄14೔౔༵೔
  24. DEBUGGER ެ։伴͕ݟ͔ͭΓ·ͤΜ isn’t part of RT’s Japanese i18n 12೥1݄14೔౔༵೔

  25. DEBUGGER ެ։伴͕ݟ͔ͭΓ·ͤΜ possibly from GPG’s i18n? 12೥1݄14೔౔༵೔

  26. DEBUGGER gpg-2.0.18 $ ack -a ެ։伴͕ݟ͔ͭΓ·ͤΜ gpg-2.0.18 $ 12೥1݄14೔౔༵೔

  27. 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೔౔༵೔
  28. DEBUGGER probably a mis-set $LANG, $LC_ALL? 12೥1݄14೔౔༵೔

  29. DEBUGGER Ͱ΋ LC_ALL=en gpg LC_ALL=ja gpg LC_ALL= gpg opensnoop 12೥1݄14೔౔༵೔

  30. DEBUGGER Without DTrace, woulda had to add print statements to

    GPG itself 12೥1݄14೔౔༵೔
  31. DEBUGGER then compiled it 12೥1݄14೔౔༵೔

  32. DEBUGGER then installed it 12೥1݄14೔౔༵೔

  33. DEBUGGER then repeated a couple of times because I’m a

    “throw everything til something sticks” kinda guy 12೥1݄14೔౔༵೔
  34. DEBUGGER then cleaned up after all that hot mess 12೥1݄14೔౔༵೔

  35. DEBUGGER DTrace is great for debugging interactions between programs 12೥1݄14೔౔༵೔

  36. DEBUGGER DTrace is great for debugging interactions between YOUR BEAUTIFUL

    CODE and THE IDIOTS 12೥1݄14೔౔༵೔
  37. Perl ɾ5.10.0+: sub-entry, sub-return ɾ5.15.1+: phase-change (${^GLOBAL_PHASE}) ɹ ɾFuture?: string

    eval, etc. perldoc perldtrace 12೥1݄14೔౔༵೔
  38. 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೔౔༵೔
  39. QUESTIONS? ೔ຊޠͰ΋̤̠Ͱ͢ʂ slides: http://twitter.com/sartak 12೥1݄14೔౔༵೔