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

Peeking at the stack

We can take a peek into the process stack (technically, the stack of main()) in different ways. Here, we show two possibilities:

  • Automatically via the gstack(1) utility
  • Manually with the GDB debugger

Peek at the usermode stack, first, via gstack(1):

WARNING! Ubuntu users, you might face an issue here. At the time of writing (Ubuntu 18.04), gstack does not seem to be available for Ubuntu (and its alternative, pstack, does not work well either!). Please use the second method (via GDB), as follows.

As a quick example, we look up the stack of bash (the parameter is the PID of the process):

$ gstack 14654#0  0x00007f3539ece7ea in waitpid () from /lib64/libc.so.6#1  0x000056474b4b41d9 in waitchld.isra ()#2 0x000056474b4b595d ...
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