14.3.4 Working with the Stack

Whenever you run a program that contains any function calls, gawk maintains a stack of all of the function calls leading up to where the program is right now. You can see how you got to where you are, and also move around in the stack to see what the state of things was in the functions that called the one you are in. The commands for doing this are:

backtrace [count]
bt [count]
where [count]

Print a backtrace of all function calls (stack frames), or innermost count frames if count > 0. Print the outermost count frames if count < 0. The backtrace displays the name and arguments to each function, the source file name, and the line number. The alias where for backtrace is provided for longtime GDB users who may be used to that command.

down [count]

Move count (default 1) frames down the stack toward the innermost frame. Then select and print the frame.

frame [n]
f [n]

Select and print stack frame n. Frame 0 is the currently executing, or innermost, frame (function call); frame 1 is the frame that called the innermost one. The highest-numbered frame is the one for the main program. The printed information consists of the frame number, function and argument names, source file, and the source line.

up [count]

Move count (default 1) frames up the stack toward the outermost frame. Then select and print the frame.