4.5.3 Selecting a frame (‘up’, ‘down’, ‘frame’)

Commands for listing source code in your script work on whichever stack frame is selected at the moment. Here are the commands for selecting a stack frame; all of them finish by printing a brief description of the stack frame just selected.

up [n]

Move n frames up the stack. For positive numbers n, this advances toward the outermost frame, to higher frame numbers, to frames that have existed longer. Using a negative n is the same as issuing a down command of the absolute value of the n. Using zero for n does no frame adjustment, but since the current position is redisplayed, it may trigger a resynchronization if there is a front end also watching over things.

n defaults to one. You may abbreviate up as u.

down [n]

Move n frames down the stack. For positive numbers n, this advances toward the innermost frame, to lower frame numbers, to frames that were created more recently. Using a negative n is the same as issuing a up command of the absolute value of the n. Using zero for n does no frame adjustment, but since the current position is redisplayed, it may trigger a resynchronization if there is a front end also watching over things.

n defaults to one. You may abbreviate down as do.

All of these commands end by printing two lines of output describing the frame. The first line shows the frame number, the function name, the arguments, and the source file and line number of execution in that frame. The second line shows the text of that source line.

For example:

bashdb<8> up
19:	sourced_fn
bashdb<8> T
##0 in file `./bashtest-sourced' at line 8
->1 sourced_fn() called from file `bashtest-sourced' at line 19
##2 source() called from file `bashdb-test1' at line 23
##3 fn2() called from file `bashdb-test1' at line 33
##4 fn1() called from file `bashdb-test1' at line 42
##5 main() called from file `bashdb-test1' at line 0

After such a printout, the list command with no arguments prints ten lines centered on the point of execution in the frame. See Printing source lines.

frame args

The frame command allows you to move from one stack frame to another, and to print the stack frame you select. args is the the stack frame number; frame 0 then will always show the current and most recent stack frame.

If a negative number is given, counting is from the other end of the stack frame, so frame -1 shows the least-recent, outermost or most “main” stack frame.

Without an argument, frame prints the current stack frame. Since the current position is redisplayed, it may trigger a resynchronization if there is a front end also watching over things.