Debugging a live/stuck Ruby process is a well-known subject.
The way it’s generally exposed is simply a series of instructions and their outcome; given the expectation, this is fine of course, however, when I saw that a manual copy/paste operation was required, I decided to… step in (pun intended 😂).
This article adds only a few concepts, operatively speaking, but it clarifies all the concept involved, and employs neat approaches to accomplish the task. I will also employ several goodies available to Linux systems.
- A brief overview of debugging a process, and ptrace
- Using pgrep
- A brief overview of file descriptors
- Putting together Ruby and GDB (with fancy grep!)
- Basic GDB usage
- The procedure
- Safety of messing with file descriptors
- Other GDB/Ruby tools