Oracle® Solaris Studio 12.4: Debugging a Program With dbx

Exit Print View

Updated: January 2015
 
 

Looking at the Call Stack

The call stack represents all currently active routines, which are those that have been called but have not yet returned to their respective caller. In the stack, the functions and their arguments are listed in the order in which they were called. A stack trace shows where in the program flow execution stopped and how execution reached this point. It provides the most concise description of your program’s state.

To display a stack trace, use the where command:

(dbx) stop in printf
(dbx) run
(dbx) where
  [1] printf(0x10938, 0x20a84, 0x0, 0x0, 0x0, 0x0), at 0xef763418
=>[2] printit(msg = 0x20a84 "hello world\n"), line 6 in "t.c"
  [3] main(argc = 1, argv = 0xefffe93c), line 13 in "t.c"
(dbx)

For functions that were compiled with the -g option, the argument names and their types are known so accurate values are displayed. For functions without debugging information, hexadecimal numbers are displayed for the arguments. These numbers are not necessarily meaningful. For example, in the stack trace above, frame 1 shows the contents of the SPARC input registers $i0 through $i5.Only the contents of registers $i0 through $i1 are meaningful because only two arguments were passed to printf in the example shown in Stepping Through Your Program.

You can stop in a function that was not compiled with the -g option. When you stop in such a function, dbx searches down the stack for the first frame whose function is compiled with the -g option, in this case printit(), and sets the current scope to it. This is denoted by the arrow symbol (=>).

For more information bout the call stack, see Efficiency Considerations. For more information about the current scope, see Program Scope.