Debugging a Program With dbx

Tracing Calls

Sometimes a program stops with a core dump, and you need to know the sequence of calls that brought it there. This sequence is called a stack trace.

The where command shows where in the program flow execution stopped and how execution reached this point--a stack trace of the called routines.

ShowTrace.f is a program contrived to get a core dump a few levels deep in the call sequence--to show a stack trace.


Note the reverse order:

MAIN called calc
calc called calcb.

Execution stopped, line 23

calcB called from calc, line 9

calc called from MAIN, line 3
demo% f77 -silent -g ShowTrace.f 
demo% a.out
*** TERMINATING a.out
*** Received signal 11 (SIGSEGV)
Segmentation Fault (core dumped)
quil 174% dbx a.out
Reading symbolic information for a.out
...
(dbx) run
Running: a.out 
(process id 1089)
signal SEGV (no mapping at the fault address) in calcb at line 23 in file "ShowTrace.f"
   23                   v(j) = (i * 10)
(dbx) where -V
=>[1] calcb(v = ARRAY , m = 2), line 23 in "ShowTrace.f"
  [2] calc(a = ARRAY , m = 2, d = 0), line 9 in "ShowTrace.f"
  [3] MAIN(), line 3 in "ShowTrace.f"
(dbx)

Show the sequence of calls, starting at where the execution stopped: