Skip to content

Instantly share code, notes, and snippets.

@sonots
Last active January 4, 2018 16:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save sonots/fc18309e874ae36dd9814c8917cb3bf9 to your computer and use it in GitHub Desktop.
gdb with ruby

bundle exec gdb とやると環境変数が渡って楽

$ bundle exec gdb ruby
gdb> run test.rb

コマンドラインで ruby への引数も渡したいときは --args オプションが使える。 ちなみに man gdb には出てこないが、gdb --help には出てくるオプション。

$ bundle exec gdb --args ruby test.rb
gdb> run

また、こんな .gdbinit を作って食わせておくと、ruby_debug_breakpoint(); 関数を呼び出したところで止まって便利

set breakpoint pending on
b ruby_debug_breakpoint
set $_exitcode = -999
run
if $_exitcode != -999
  quit
end
$ bundle exec gdb -x .gdbinit --args ruby test.rb
(勝手に run までされる)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment