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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Shawn Moore
January 14, 2012
Programming
1.3k
2
Share
DTrace: printf debugging for seventh-level wizards
Shawn Moore
January 14, 2012
More Decks by Shawn Moore
See All by Shawn Moore
Right the First Time
sartak
0
530
Lifting Moose
sartak
0
680
Kindergarten Code
sartak
0
150
How to be Fluent in Japanese
sartak
0
210
DTrace War Stories
sartak
1
190
Moose Role Usage Patterns
sartak
5
6k
git-status-tackle
sartak
5
400
Extending Moose for Applications
sartak
1
390
API Design
sartak
4
990
Other Decks in Programming
See All in Programming
PHP で mp3 プレイヤーを実装しよう
m3m0r7
PRO
0
290
検索設計から 推論設計への重心移動と Recall-First Retrieval
po3rin
3
970
Lightning-Fast Method Calls with Ruby 4.1 ZJIT / RubyKaigi 2026
k0kubun
3
1.1k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyKaigi 2026, Hakodate, Japan
marcoroth
0
180
GitHubCopilotCLIをはじめよう.pdf
htkym
0
230
AI時代のPhpStorm最新事情 #phpcon_odawara
yusuke
0
190
forteeの改修から振り返るPHPerKaigi 2026
muno92
PRO
3
290
Server-Side Kotlin LT大会 vol.18 [Kotlin-lspの最新情報と Neovimのlsp設定例]
yasunori0418
1
180
How Swift's Type System Guides AI Agents
koher
0
290
AIを導入する前にやるべきこと
negima
2
120
一度始めたらやめられない開発効率向上術 / Findy あなたのdotfilesを教えて!
k0kubun
4
3k
How We Benchmarked Quarkus: Patterns and anti-patterns
hollycummins
1
150
Featured
See All Featured
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
380
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Technical Leadership for Architectural Decision Making
baasie
3
330
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
270
How to Talk to Developers About Accessibility
jct
2
180
GitHub's CSS Performance
jonrohan
1032
470k
Believing is Seeing
oripsolob
1
110
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
770
Paper Plane
katiecoart
PRO
1
49k
Site-Speed That Sticks
csswizardry
13
1.2k
Building Applications with DynamoDB
mza
96
7k
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༵