Skip to Main Content
Hands-On System Programming with Linux
book

Hands-On System Programming with Linux

by Kaiwan N. Billimoria, Tigran Aivazian
October 2018
Beginner content levelBeginner
794 pages
19h 23m
English
Packt Publishing
Content preview from Hands-On System Programming with Linux

Register dumping

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux System Programming Techniques

Linux System Programming Techniques

Jack-Benny Persson
Linux Device Drivers, Second Edition

Linux Device Drivers, Second Edition

Jonathan Corbet, Alessandro Rubini

Publisher Resources

ISBN: 9781788998475Supplemental Content