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
Ruby Debugger API
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
76
RubyMine and RubyMotion
denofevil
0
52
RubyMotion #JetBrainsDay
denofevil
0
44
Get More from RubyMotion with RubyMine
denofevil
0
52
Fighting Code Smells #FrozenRails
denofevil
0
62
Other Decks in Technology
See All in Technology
Eight Engineering Unit 紹介資料
sansan33
PRO
3
8.2k
案件に一番詳しいAIを Amazon Bedrock AgentCore で作る ― 知見が知見を生むチームへ / Compounding Knowledge with AgentCore
yusukeshimizu
1
150
JavaScript 研修 (2026)
recruitengineers
PRO
2
650
AI-DLC実践録_フルサイクル開発への挑戦
miyuc
0
290
ガバメント AI 源内を地方自治体は活用できるのか可能性と課題、期待について
takeda_h
2
460
SO-101×VLAによる3色キューブのピック&プレース
abeja
0
220
モバイルアプリ開発概論2026
recruitengineers
PRO
6
670
トークンマネジメントでAIにとって働きやすい環境を実現する
hikaruegashira
0
120
[potatotips #96] Give Your AI Agent the Flutter Playbook
korodroid
0
110
35分でわかるEffective Platform Engineering
nwiizo
5
500
DatadogのBits Chatが開発組織にもたらしたもの / What Bits Chat Has Brought Us
sms_tech
1
290
つくって納得、つかって実感! 大規模言語モデルことはじめ ver2.0
recruitengineers
PRO
5
2k
Featured
See All Featured
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.8k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
480
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
390
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
410
Become a Pro
speakerdeck
PRO
31
6.2k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
250
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.6k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
700
The SEO identity crisis: Don't let AI make you average
varn
0
530
The agentic SEO stack - context over prompts
schlessera
0
870
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 )