Chapter 18. Stack Tracebacks

We’ve spent enough time talking about stacks. Now let’s see the theory put to actual use. We will start by using the little C program below, which we will run under adb.

Example 18-1. little.c

main () 
{
  fred (1, 2, 3); 
} 

int fred (a, b, c) 
int a, b, c; 
{} 

In little.c, shown above, the main() routine calls the fred() routine, passing it three integer values. The fred() routine does nothing except return to the main() routine.

Using adb, let’s first look at the SPARC assembly instructions for main().

Example 18-1. Viewing little’s main routine via adb

Hiya...  cc -o little little.c 
Hiya...  adb little -
main,20?ai main: main: save %sp, -0x60, %sp main+4: mov 0x1, %l0 main+8: mov 0x2, %l1 main+0xc: mov 0x3, %l2 main+0x10: ...

Get Panic! UNIX® System Crash Dump Analysis now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.