lover - Core contributor for Ruby Kafka client. - Author of Ruby Jard, a debugger for Ruby. - (Ex) Engineering Manager at Employment Hero. - Contact me at https://github.com/nguyenquangminh0711/
structure. - Each instruction contains low-level execution used by RubyVM + Discrete values + Local variables + Arguments + Catch table (for raising, throwing) - Each instruction also contains reflection information: + File, line, code range that creates that instruction + Trace events
by line. - Each line consists of one or more than 1 instructions. - Control frames are persisted during program execution. - A control frame’s context is persisted too.
the VM, called TracePoint. - Each instruction is masked with some flags called trace events. - *Before* Ruby executes any instruction, it checks the flags, and call registered hooks.
have their own breakpoints and control flow managements. - They register the tracepoints with Ruby - When the tracepoint stops at an event - Start a REPL session to receive user input if necessary - Read, evaluate, and print result - Continue if flow control commands received
costs a lot of mental effort to think about - All the current debuggers help you debug, but not with pleasure: - You have to fit the current context, remember the current lines, current variables - You have to type a lot, go back and forth to examine your variables, and source code - Jumping between control frames is available, but extremely unfriendly - Sometimes, you have have no idea what your debugger is leading you. - Sometimes, you struggle with inspecting a nested of nested of nested array, and forgot where are you now. - Or, well, you have a visualized mindset, and annoyed that information keeps hiding from you
over and over again, but found no matches for me. - RubyMine, VSCode provide some better experiences, but still, a lot of features are missing, and no way it can compare with debugging in terminal. - So, I build a debugger myself to solve this.
Ruby - It provides modular visual interfaces to show relevant information about your debugging program, usability, and highly friendly to developers, especially new-comers. - They help you reduce the commands you need to type, the mental efforts wasted trying to navigate and grab the information you need. - As a result, you can now focus more on the debug flow.
on the screen. - Advanced flow control - Support keybinding - Support rich customization - Ignore unwanted jumps (go deep into Gem) - Support catching exception - Support watch variable - Support mouse and scrolling - Tools to inspect and explore variables - Multi-thread debugging https://asciinema.org/a/UpcIkky3FQnZPuKMa6TqPlM9G
parse into AST, compile into yarv instructions, and feed instructions into RubyVM. - RubyVM executes instruction by instruction, push/pop control frames when open/close a scope, and manipulate environment stack. - RubyVM provides a hook system called TracePoint. - Ruby debuggers implement its magic based on TracePoint and REPL. - Ruby Jard looks cool. Let’s download it at rubyjard.org