As mentioned, the dump_regs function prints out CPU register values; here are a few things to note regarding this:
- It's very CPU-specific (the example case shown as follows works only for the x86_64 CPUs).
- To actually gain access to the CPU registers, we make use of the undocumented third parameter to the signal handler function (note: when used with SA_SIGINFO), the so-called user context pointer. It is possible to interpret it (as we demonstrate here), but, of course, as it's not officially visible via the glibc system call (or other) interfaces, you cannot rely on this functionality. Use with caution (and a lot of testing).
Having said that, let's check out the code:
/* arch - x86[_64] - specific! */static inline void ...