Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
DTrace: printf debugging for seventh-level wizards
Search
Shawn Moore
January 14, 2012
Programming
2
1.3k
DTrace: printf debugging for seventh-level wizards
Shawn Moore
January 14, 2012
Tweet
Share
More Decks by Shawn Moore
See All by Shawn Moore
Right the First Time
sartak
0
430
Lifting Moose
sartak
0
510
Kindergarten Code
sartak
0
81
How to be Fluent in Japanese
sartak
0
140
DTrace War Stories
sartak
1
120
Moose Role Usage Patterns
sartak
5
5.8k
git-status-tackle
sartak
5
330
Extending Moose for Applications
sartak
1
350
API Design
sartak
4
960
Other Decks in Programming
See All in Programming
Jakarta EE meets AI
ivargrimstad
0
590
카카오페이는 어떻게 수천만 결제를 처리할까? 우아한 결제 분산락 노하우
kakao
PRO
0
110
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
280
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
470
Enabling DevOps and Team Topologies Through Architecture: Architecting for Fast Flow
cer
PRO
0
310
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
230
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
初めてDefinitelyTypedにPRを出した話
syumai
0
400
subpath importsで始めるモック生活
10tera
0
300
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
860
受け取る人から提供する人になるということ
little_rubyist
0
230
OSSで起業してもうすぐ10年 / Open Source Conference 2024 Shimane
furukawayasuto
0
100
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Being A Developer After 40
akosma
86
590k
4 Signs Your Business is Dying
shpigford
180
21k
Producing Creativity
orderedlist
PRO
341
39k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
720
The Cult of Friendly URLs
andyhume
78
6k
Building Your Own Lightsaber
phodgson
103
6.1k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Transcript
@sartak DTRACE printf debugging for seventh-level wizards 121݄14༵
ME ME ME ME ME ME ME Shawn M Moore
@sartak I’m Bawstin’ Moose-lover Infinity Interactive 121݄14༵
What’s my computer doing right now? Q: A: Find out
with DTrace 121݄14༵
iotop $ iotop dtrace: failed to initialize dtrace: DTrace requires
additional privileges You may already have DTrace and not even know it. 121݄14༵
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 121݄14༵
SAFE! ɾNo unwanted side effects ɾVery low overhead ɾDo it
in production! 121݄14༵
σϞ pidpersec iotop execsnoop opensnoop dtruss plockstat iosnoop Global (high
level) The metal (low level) 121݄14༵
σϞ pidpersec iotop execsnoop opensnoop dtruss plockstat iosnoop Global (high
level) The metal (low level) 121݄14༵
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” 121݄14༵
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) 121݄14༵
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 121݄14༵
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 121݄14༵
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” 121݄14༵
DTrace instrumentation points ɾKernel function calls/returns (syscalls too) ɾPerl function
calls/returns ɾSQL execution ɾthreads ɾsignals ɾmany more PROBES 121݄14༵
THE COOL DEMO HEY, FORGETFUL! DEMO THE GPG THING 121݄14༵
PROFILER Devel::NYTProf kicks ass 121݄14༵
PROFILER But there’s more than one way to do it
121݄14༵
PROFILER DEMO: syscalls intuit_method 121݄14༵
XCode’s profiler uses DTrace 121݄14༵
121݄14༵
TRANSLATION “I am comfortable being ignorant and helpless” 121݄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. 121݄14༵
DEBUGGER Failed test 'gpg: error reading key: ެ։伴͕ݟ͔ͭΓ·ͤΜ' doesn't match
'(?-xism:public key not found)' 121݄14༵
DEBUGGER ެ։伴͕ݟ͔ͭΓ·ͤΜ isn’t part of RT’s Japanese i18n 121݄14༵
DEBUGGER ެ։伴͕ݟ͔ͭΓ·ͤΜ possibly from GPG’s i18n? 121݄14༵
DEBUGGER gpg-2.0.18 $ ack -a ެ։伴͕ݟ͔ͭΓ·ͤΜ gpg-2.0.18 $ 121݄14༵
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 $ 121݄14༵
DEBUGGER probably a mis-set $LANG, $LC_ALL? 121݄14༵
DEBUGGER Ͱ LC_ALL=en gpg LC_ALL=ja gpg LC_ALL= gpg opensnoop 121݄14༵
DEBUGGER Without DTrace, woulda had to add print statements to
GPG itself 121݄14༵
DEBUGGER then compiled it 121݄14༵
DEBUGGER then installed it 121݄14༵
DEBUGGER then repeated a couple of times because I’m a
“throw everything til something sticks” kinda guy 121݄14༵
DEBUGGER then cleaned up after all that hot mess 121݄14༵
DEBUGGER DTrace is great for debugging interactions between programs 121݄14༵
DEBUGGER DTrace is great for debugging interactions between YOUR BEAUTIFUL
CODE and THE IDIOTS 121݄14༵
Perl ɾ5.10.0+: sub-entry, sub-return ɾ5.15.1+: phase-change (${^GLOBAL_PHASE}) ɹ ɾFuture?: string
eval, etc. perldoc perldtrace 121݄14༵
Perl ɾ5.10.0Ҏ߱: sub-entry, sub-return ɾ5.15.1Ҏ߱: phase-change ɹ ɾকདྷʁ: string eval
My first Perl patch! Was simple! perldtrace 121݄14༵
QUESTIONS? ຊޠͰ̤̠Ͱ͢ʂ slides: http://twitter.com/sartak 121݄14༵