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
Defly
Search
Andrew Liu
August 27, 2011
Programming
0
310
Defly
A debug tool for Ruby
Andrew Liu
August 27, 2011
Tweet
Share
More Decks by Andrew Liu
See All by Andrew Liu
Facebook Graph API
eggegg
7
630
HTTP
eggegg
17
1.4k
Version Control System - Git
eggegg
4
640
Introduction to Ruby
eggegg
3
560
Other Decks in Programming
See All in Programming
useSyncExternalStoreを使いまくる
ssssota
6
1.3k
PSR-15 はあなたのための ものではない? - phpcon2024
myamagishi
0
170
rails statsで大解剖 🔍 “B/43流” のRailsの育て方を歴史とともに振り返ります
shoheimitani
2
950
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
490
Mermaid x AST x 生成AI = コードとドキュメントの完全同期への道
shibuyamizuho
0
170
Recoilを剥がしている話
kirik
5
7k
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
900
命名をリントする
chiroruxx
1
430
わたしの星のままで一番星になる ~ 出産を機にSIerからEC事業会社に転職した話 ~
kimura_m_29
0
190
どうして手を動かすよりもチーム内のコードレビューを優先するべきなのか
okashoi
3
340
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
120
Scalaから始めるOpenFeature入門 / Scalaわいわい勉強会 #4
arthur1
1
340
Featured
See All Featured
We Have a Design System, Now What?
morganepeng
51
7.3k
A Modern Web Designer's Workflow
chriscoyier
693
190k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
Documentation Writing (for coders)
carmenintech
66
4.5k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Speed Design
sergeychernyshev
25
670
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Gamification - CAS2011
davidbonilla
80
5.1k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Being A Developer After 40
akosma
87
590k
Transcript
Defly Debugging and Tracing Tool for Ruby http://github.com/eggegg/defly
Andrew Liu 劉彥廷 • College Student • Intern @ Cardinalblue
• eggegg @ github • Ruby, iOS, Android •
[email protected]
gem install defly
Defly is for... • Trace method calls • Trace instance
variables • Better error messages • Inspect the point of error
class Warrior attr_accessor :hp, :mp def sleep self.hp += 10
self.mp += 2 end end
class Warrior attr_accessor :hp, :mp def sleep puts "BEFORE: #{@hp},
#{@mp}" self.hp += 10 puts "AFTER ADDING HP: #{@hp}, #{@mp}" self.mp += 2 puts "AFTER ADDING MP: #{@hp}, #{@mp}" end end
class Warrior attr_accessor :hp, :mp def sleep self.hp += 10
self.mp += 2 end end require 'defly' Warrior.debug! Warrior.new.trace([:hp, :hp=, :mp, :mp=, :sleep], [:@hp, :@mp]) do |warrior| warrior.hp = 10 warrior.mp = 20 warrior.sleep end
Tracing hp, hp=, mp, mp=, sleep on Warrior instance Tracing
@hp, @mp on Warrior instance <<<<< Warrior#hp=(10) # (irb):14:in `block in irb_binding' @hp = 10 # undefined @mp = nil # undefined >>>>> 10 <<<<< Warrior#mp=(20) # (irb):15:in `block in irb_binding' @mp = 20 # undefined >>>>> 20 <<<<< Warrior#sleep() # (irb):16:in `block in irb_binding' <<<<< Warrior#hp() # (irb):7:in `sleep' >>>>> 10 <<<<< Warrior#hp=(20) # (irb):7:in `sleep' @hp = 20 # 10 -> 20 >>>>> 20 <<<<< Warrior#mp() # (irb):8:in `sleep' >>>>> 20 <<<<< Warrior#mp=(22) # (irb):8:in `sleep' @mp = 22 # 20 -> 22 >>>>> 22 >>>>> 22
NoMethodError debugging = nil debugging.is_annoying irb(main):001:0> require 'bug' NoMethodError: undefined
method `is_annoying' for nil:NilClass from /Users/eggegg/bug.rb:2:in `<top (required)>' ... bug.rb irb Where is the bug???
irb(main):003:0> require 'defly' => true irb(main):004:0> require 'bug' NoMethodError: undefined
method `is_annoying' for nil:NilClass bug.rb:2> debugging.<<is_annoying>> from /Users/andrewliu/bug.rb:2:in `<top (required)>'
Inspecting Errors class Rocket def launch! @reason = "Bugs invasion"
raise "Engine Fail" end end Rocket.debug! rocket = Rocket.new rocket.watch_error "Engine Fail" rocket.launch!
>>>>> Error received: "Engine Fail" >>>>> #<Rocket:0(0)>> @reason => "Bugs
invasion" #<Rocket:0(0)>> Ruby shell (Rib by godfat) to inspect errors!
Thanks! Any Question?