Updated: Inspecting a live Ruby process
Updated the gdb-inspect card with instructions for Ruby 2.4+.
TL;DR live inspection:
# First, find out the PID of your Ruby process (e.g. passenger-status) $ gdb PID (gdb) generate-core-file # generate core.PID file for later inspection (gdb) t a a bt # thread apply all backtrace (gdb) call (void) close(1) # close the existing file descriptors for stdout (gdb) call (void) close(2) # close the existing file descriptors for stderr (gdb) shell tty # we need to figure out the device name for the current TTY: /dev/pts/X # X is an integer, adjust for your shell (gdb) call (int) open("/dev/pts/X", 2, 0) # attach stdout to current TTY (gdb) call (int) open("/dev/pts/X", 2, 0) # attach stderr to current TTY call (void) rb_backtrace() # print the Ruby backtrace to the current shell (gdb) detach # detach from the Ruby process (PID) (gdb) quit # exit gdb