DTrace: 最強な魔法使いのprintfのようなデバッガ
by
Shawn Moore
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
@sartak DTRACE printf debugging for seventh-level wizards ࠷ڧͳຐ๏͍ͷprintfͷΑ͏ͳσόοΨ 1110݄15༵
Slide 2
Slide 2 text
ࣗݾհ ɹShawn M Mooreɹ ˏsartak Mooseʹ͍͔͞͞ߩݙ͠Α͏ͱ͢Δ ϘετϯʹॅΜͰ͍Δ ձࣾ: Infinity Interactive 1110݄15༵
Slide 3
Slide 3 text
ॻ͍ͨϞʔδϡϧ MooseX::Role::Parameterized Any::Moose cpandoc Carp::REPL Path::Dispatcher App::Nopaste (CPAN: SARTAK) ଞʹɺΘͳ͍ͷํ͕͍͍ͬͯଟ͘ͷϞʔδϡϧ 1110݄15༵
Slide 4
Slide 4 text
DTRACE 1110݄15༵
Slide 5
Slide 5 text
ࠓɺίϯϐϡʔλ͕ԿΛͯ͠Δͷʁ ࣭: ͑: DTraceͰΔ͜ͱʹͳΕΔ ਖ਼ͳ͑: ͍͍ͨͯɺχίχίͰಲೣΛ؍ͯΔ 1110݄15༵
Slide 6
Slide 6 text
iotop ͔ͯ͠͠ɺΒͣʹ͢ͰʹDTraceΛ͍ͬͯͨʂ $ iotop dtrace: failed to initialize dtrace: DTrace requires additional privileges 1110݄15༵
Slide 7
Slide 7 text
OS X & Solaris(શ෦). Linux(͔͠Εͳ͍) ϓϩϑΝΠϥʔ (NYTProfΑΓਂ͘) σόοΨʔ ΧʔωϧϞʔδϡϧ (DTraceΛOSʹϙʔτ͠ͳͯ͘ɺ OSΛDTraceʹϙʔτ͢Δͬͯ) DTRACE 1110݄15༵
Slide 8
Slide 8 text
XCodeͷϓϩϑΝΠϥDTraceΛ͏ 1110݄15༵
Slide 9
Slide 9 text
dtruss iotop opensnoop iosnoop pidpersec man -k dtrace 1110݄15༵
Slide 10
Slide 10 text
DTraceͱ৮ ɾΧʔωϧ (syscallؚΜͩ) ͷؔΛݺͼɺฦ͠ ɾPerlͷؔΛݺͼɺΓ ɾSQL࣮ߦ ɾthreads ɾsignals ɾଞͷΠϕϯτ͕ଟ͍ ϓϩʔϒ 1110݄15༵
Slide 11
Slide 11 text
ϓϩάϥϜՄೳ dtrace -n ' syscall::open:entry /strstr(copyinstr(arg0), "corpus") != NULL/ { printf("%s %s",execname,copyinstr(arg0)); }' ʮcorpusʯͱ͍͏ϑΝΠϧΛ։͘ϓϩηεΛදࣔ ͕͜ͷεΫϦϓτΛॻ͍ͯͬͨ 1110݄15༵
Slide 12
Slide 12 text
ϓϩάϥϜՄೳ dtrace -n ' syscall::open:entry /strstr(copyinstr(arg0), "corpus") != NULL/ { printf("%s %s",execname,copyinstr(arg0)); }' ʮcorpusʯͱ͍͏ϑΝΠϧΛ։͘ϓϩηεΛදࣔ ͕͜ͷεΫϦϓτΛॻ͍ͯͬͨ Πϕϯτ(ϓϩʔϒͷهड़) 1110݄15༵
Slide 13
Slide 13 text
ϓϩάϥϜՄೳ dtrace -n ' syscall::open:entry /strstr(copyinstr(arg0), "corpus") != NULL/ { printf("%s %s",execname,copyinstr(arg0)); }' ʮcorpusʯͱ͍͏ϑΝΠϧΛ։͘ϓϩηεΛදࣔ ͕͜ͷεΫϦϓτΛॻ͍ͯͬͨ ड़ޠ 1110݄15༵
Slide 14
Slide 14 text
ϓϩάϥϜՄೳ dtrace -n ' syscall::open:entry /strstr(copyinstr(arg0), "corpus") != NULL/ { printf("%s %s",execname,copyinstr(arg0)); }' ʮcorpusʯͱ͍͏ϑΝΠϧΛ։͘ϓϩηεΛදࣔ ͕͜ͷεΫϦϓτΛॻ͍ͯͬͨ ΞΫγϣϯ 1110݄15༵
Slide 15
Slide 15 text
ϓϩάϥϜՄೳ dtrace -n ' syscall::open:entry /strstr(copyinstr(arg0), "corpus") != NULL/ { printf("%s %s",execname,copyinstr(arg0)); }' ʮcorpusʯͱ͍͏ϑΝΠϧΛ։͘ϓϩηεΛදࣔ ͕͜ͷεΫϦϓτΛॻ͍ͯͬͨ 1110݄15༵
Slide 16
Slide 16 text
σόοΨʔ Request Tracker (rt.cpan.orgͱ͔)Ͱ mod_perlͷςετΛࣦഊͯͨ͠ɻ ͷίϯϐϡʔλ͚ͩͰɻ ͨͿΜຊޠ͔ͩΒɻ 1110݄15༵
Slide 17
Slide 17 text
σόοΨʔ Failed test 'gpg: error reading key: ެ։伴͕ݟ͔ͭΓ·ͤΜ' doesn't match '(?-xism:public key not found)' 1110݄15༵
Slide 18
Slide 18 text
σόοΨʔ RTຊޠ൛͕͋Δ͚Ͳɺ ʮެ։伴͕ݟ͔ͭΓ·ͤΜʯͱ͍͏༁͕ɾɾɾͳ͔ͬͨʂʁ 1110݄15༵
Slide 19
Slide 19 text
σόοΨʔ ͋ʂͦͷจGPG͔Βདྷ͔ͨͳɾɾɾ 1110݄15༵
Slide 20
Slide 20 text
σόοΨʔ gpg-2.0.18 $ ack -a ެ։伴͕ݟ͔ͭΓ·ͤΜ gpg-2.0.18 $ 1110݄15༵
Slide 21
Slide 21 text
σόοΨʔ 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 $ 1110݄15༵
Slide 22
Slide 22 text
σόοΨʔ ͜ͷࣦഊmod_perl͚͔ͩͩΒɺڥม͕ؒҧ͏ͩΖ͏ $LANGɺ$LC_ALL 1110݄15༵
Slide 23
Slide 23 text
σόοΨʔ LC_ALL=en gpg LC_ALL=ja gpg LC_ALL= gpg opensnoop 1110݄15༵
Slide 24
Slide 24 text
σόοΨʔ DTraceΛΘͳ͍Ͱɺ GPGͷࣗମʹprintΛଟ͘Ճ͢Δඞཁ 1110݄15༵
Slide 25
Slide 25 text
DTraceΛ͏ؾͳ͍ͥɻ ͳͥͳΒɺࠓ͜ͷΞϓϦͷ͍ཧ༝Λௐ͍͕ͨɺ ͋ΒΏΔΞϓϦͷ͍ཧ༝Λݚڀ͢ΔઐՈʹੜ֔Λ͛ͨ͘͞͞ͳ͍Μͩɻ (༁૬ͰͨΒΊͰ͢ɺΰϝϯͳʂ) 1110݄15༵
Slide 26
Slide 26 text
͑͑͑͑͑ʁ ੑೳղੳ͕Լखʹଓ͚͍͔ͨʁ ͋ΒΏΔΞϓϦΛߴԽʹग़དྷͳ͍ʁ ͦͷϘιϘιͰDTraceΛࢍͩͱࢥ͏ 1110݄15༵
Slide 27
Slide 27 text
ҙʂ DTraceͷݴޠɺʮifʯ͕ͳ͍ʂ ΘΓʹɺड़ޠΛ͍·͠ΐ͏Ͷ ß 1110݄15༵
Slide 28
Slide 28 text
ҙʂ probe { if (ok) { x; } else { y; } } probe /ok/ { x; } probe /!ok/ { y; } ͳͥͳΒɺDTrace͕ҋຐज़Λ͏ͩΖ͏ 1110݄15༵
Slide 29
Slide 29 text
Perl ɾ5.10.0Ҏ߱: sub-entry, sub-return ɾ5.15.1Ҏ߱: phase-change (${^GLOBAL_PHASE}) ɹ ɾকདྷʁ: string eval perldoc perldtrace 1110݄15༵
Slide 30
Slide 30 text
Perl ɾ5.10.0Ҏ߱: sub-entry, sub-return ɾ5.15.1Ҏ߱: phase-change ɹ ɾকདྷʁ: string eval ͷ࠷ॳPerlʹύονʂ ؆୯ͩͬͨʂ perldtrace 1110݄15༵
Slide 31
Slide 31 text
͍ͤͪ͝ΐ͏ ͋Γ͕ͱ͏ ͍͟͝·ͨ͠ 1110݄15༵
Slide 32
Slide 32 text
one more thing . . . 1110݄15༵
Slide 33
Slide 33 text
օͷݸਓͷεϙϯαʔ ຊʹ ͋Γ͕ͱ͏͍͟͝·͢ 1110݄15༵
Slide 34
Slide 34 text
࣭͋Γ·ͤΜ͔ʁ ຊޠͰ̤̠Ͱ͢ʂ slides: http://twitter.com/sartak 1110݄15༵