Skip to content

Instantly share code, notes, and snippets.

@karmatr0n
Last active July 31, 2023 22:45
Show Gist options
  • Save karmatr0n/d728c94e8f9998c36c6b83c0a388a0fc to your computer and use it in GitHub Desktop.
Save karmatr0n/d728c94e8f9998c36c6b83c0a388a0fc to your computer and use it in GitHub Desktop.
Ruby Debug Gem Notes.md

Ruby Debug Gem Notes

Debug control

  • show_cmds
  • whereami
  • l or list
  • list 22-28 # Range of lines requested
  • show_source "Class or Class#method"
  • info # Instance variables, local variables, etc
  • step # go for next line/point of execution after the breakpoint (line by line)
  • continue # go for next breakpoint or end of program
  • next # next step inside the same code, no deeper like step
  • break # list all breakpoints or set additional breakpoints
  • break 22 # set breakpoint at line 22
  • break /path/file.rb:22
  • break Class#method
  • continue # go for next breakpoint or end of program

Backtracing

  • bt or backtrace # List the stack trace // all frames. all things that happened before hitting the breakpoint
  • up # move up the stack trace
  • down # move down the stack trace
  • frame 2 # move to frame 2
  • list # list inside frame to show code
  • info locals # show local variables

Help

  • help <cmd>
  • help

Invoking the debugger

  • debug # Inside irb invoke debug to start debugging
  • binding.b
  • binding.break
  • debugger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment