I know about strace and ltrace, but that only tells me what system calls and library calls a process is executing, respectively. I would like to know exactly what instructions a process is executing. Either assembly, or some sort of middle ground between C and assembly if that is possible. Assuming the binary hasn't been compiled with debug symbols, so leaning toward the first option as more likely.
Use case: process appears to be hung, no output from strace or ltrace. Determine if process is doing "something". I realize this might be difficult to determine, as I imagine this is analogous to solving the halting problem. However, it might be possible to gather useful data.
Second use case: curiosity. It would be interesting to dump the entire list of assembly instructions to a text list.
My guess is that I can use gdb to do this, but not sure how, as this is less about debugging a program I have written and more about using gdb to check on the health of a running process.
OS is CentOS 6.
Best Answer
You can do this with
gdb
: commandsni
andsi
run a single instruction at time. Commandn
runs the next line of code, for most values of "next". Forn
(and the correspondings
) you have to have compiled so that debugging symbols appear in the executable.This stackoverflow answer gives a couple of methods of doing this more-or-less visually.
The
gdb
command:display/i $pc
shows you the instruction before it executes.display $pc
show the line of code bforen
ors
executes it.