Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Ruby Debugger API
Search
Dennis Ushakov
November 23, 2013
Technology
130
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Ruby Debugger API
Ruby Debugger API overview with
Dennis Ushakov
November 23, 2013
More Decks by Dennis Ushakov
See All by Dennis Ushakov
Ruby Debugger Internals
denofevil
1
77
RubyMine and RubyMotion
denofevil
0
53
RubyMotion #JetBrainsDay
denofevil
0
45
Get More from RubyMotion with RubyMine
denofevil
0
55
Fighting Code Smells #FrozenRails
denofevil
0
63
Other Decks in Technology
See All in Technology
AI駆動開発の時代になったのでトヨタ生産方式から見直す
terurou
7
6k
ソフトウェア ファクトリー - 再現性のあるソフトウェアの工場づくり / Software factory
iktakahiro
6
4.9k
アウトプット初心者、半年間のふりかえり
4o1sobblue
0
430
Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
1
580
事業成長とデータ活用を止めないためのマネジメントへ挑戦
hiracky16
0
390
大型犬好きによるPugの紹介
yamanoku
1
160
QA4AI 2026-Oct 生成AI時代の品質保証
tokuty
1
860
子育てエンジニアの可処分時間が減っても成長を諦めない戦い方
sudoakiy
6
4.6k
go-sqletch
moznion
0
140
"優秀な誰か"の下位互換にならないために
yut0naga1_fa
1
1.8k
分析AIエージェントを育てる、動く環境を育てる
codatum
1
1.1k
Tofu-Controller lightning talk @ Containerday 2026
gionn
0
100
Featured
See All Featured
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
570
Speed Design
sergeychernyshev
33
2.2k
Heart Work Chapter 1 - Part 1
lfama
PRO
10
37k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
850
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
490
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Navigating Team Friction
lara
192
16k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
280
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3.1k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k
Six Lessons from altMBA
skipperchong
29
4.5k
Transcript
Ruby Debugger API Dennis Ushakov or how I stopped worrying
and wrote debugger core
Sample Program MAGIC_NUMBER = 10000000 ! def is_anybody_out_there? "Is anybody
out there?" end ! def hardcore_action MAGIC_NUMBER.times { is_anybody_out_there? } end
Sample Program MAGIC_NUMBER = 10000000 ! def is_anybody_out_there? "Is anybody
out there?" end ! def hardcore_action MAGIC_NUMBER.times { is_anybody_out_there? } end 3.45s
set_trace_func set_trace_func proc { |event,file,line,id,binding,classname| }
Event Types • line • call & return • c-call
& c-return • class & end • raise • b-call & b-return — Ruby 2.0 • thread-begin & thread-end — Ruby 2.0
Binding • Kernel.binding • execution context (variables, methods)
Sample Output line debug_bench.rb:22 call debug_bench.rb:10 hardcore_action Object line
debug_bench.rb:11 hardcore_action Object c-call debug_bench.rb:11 times Integer line debug_bench.rb:11 hardcore_action Object call debug_bench.rb:6 is_anybody_out_there? Object line debug_bench.rb:7 is_anybody_out_there? Object return debug_bench.rb:8 is_anybody_out_there? Object c-return debug_bench.rb:11 times Integer return debug_bench.rb:12 hardcore_action Object line debug_bench.rb:23
Sample Output line debug_bench.rb:22 call debug_bench.rb:10 hardcore_action Object line
debug_bench.rb:11 hardcore_action Object c-call debug_bench.rb:11 times Integer line debug_bench.rb:11 hardcore_action Object call debug_bench.rb:6 is_anybody_out_there? Object line debug_bench.rb:7 is_anybody_out_there? Object return debug_bench.rb:8 is_anybody_out_there? Object c-return debug_bench.rb:11 times Integer return debug_bench.rb:12 hardcore_action Object line debug_bench.rb:23 61.73s
set_trace_func set_trace_func proc { |event,file,line,id,binding,classname| }
set_trace_func set_trace_func proc { |event,file,line,id,binding,classname| } 58.33s
rb_add_event_hook void rb_add_event_hook( rb_event_hook_func_t func, rb_event_flag_t events, VALUE data );
event_hook gem • If there’s a C API there should
be a wrapper gem for it • Well, no
event_hook gem • With empty processing Ruby method 31.46s •
With empty processing C method 6.48s
Ruby 2.0: moar API • TracePoint • debug_inspector
Ruby 2.0: TracePoint trace = TracePoint.new(*events) do |tp| end trace.enable
Ruby 2.0: TracePoint trace = TracePoint.new do |tp| end trace.enable
18.27s
Ruby 2.0: TracePoint trace = TracePoint.new do |tp| tp.binding end
trace.enable 70.20s
Performance summary • run 3.45s • set_trace_func 61.73s • binding
58.33s • rb_add_event_hook • Ruby callback 31.46s • C callback 6.48s • TracePoint 18.27s
Under the hood • Everyone is using rb_add_event_hook
Ruby 2.0: debug_inspector VALUE rb_debug_inspector_open( rb_debug_inspector_func_t func, void *data );
debug_inspector gem • If there’s a C API there should
be a wrapper gem for it that’s obsolete • Well, no
debug_inspector gem RubyVM::DebugInspector.open { |dc| locations = dc.backtrace_locations locations.size.times do
|i| p dc.frame_binding(i) p dc.frame_iseq(i) p dc.frame_class(i) end }
Usages • set_trace_func • ruby -r debug.rb • rb_add_event_hook •
ruby-debug-base/debugger • rcov
Usages • TracePoint + DebugInspector • debase • byebug •
binding_of_caller
What seems to be the problem, officer?
line te.rb:9 call te.rb:5 m1 9 if m1 line te.rb:5
m1 10 1 return te.rb:5 m1 11 elsif m2 call te.rb:6 m2 12 2 line te.rb:6 m2 13 end return te.rb:6 m2 line te.rb:12 Catch me if you can
That’s it
en_Dal
[email protected]
denofevil
JRuby • org.jruby.runtime.EventHook • public boolean isInterestedInEvent(RubyEvent event) • public
void eventHandler( ThreadContext tCtx, String event, String file, int line, String methodName, IRubyObject klass )