Skip to content

Instantly share code, notes, and snippets.

@anselm-helbig
Created September 7, 2012 15:18
Show Gist options
  • Select an option

  • Save anselm-helbig/3667085 to your computer and use it in GitHub Desktop.

Select an option

Save anselm-helbig/3667085 to your computer and use it in GitHub Desktop.
Get a backtrace from a hanging ruby process
Say you have one process in an endless loop. You know its process id:
ruby -e 'puts $$; loop {}'
=> 30360, hangs
You can attach to this process with gdb now and make it print a backtrace to stdout:
gdb -p 30360
GNU gdb (GDB) 7.5
Copyright (C) 2012 Free Software Foundation, Inc.
[...]
(gdb) call rb_backtrace()
(gdb) detach
Detaching from program: /usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby, process 30360
(gdb) quit
Might come in handy from time to time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment