gawk: Debugging Terms
1
1 14.1.2 Debugging Concepts
1 -------------------------
1
1 Before diving in to the details, we need to introduce several important
1 concepts that apply to just about all debuggers. The following list
1 defines terms used throughout the rest of this major node:
1
1 "Stack frame"
1 Programs generally call functions during the course of their
1 execution. One function can call another, or a function can call
1 itself (recursion). You can view the chain of called functions
1 (main program calls A, which calls B, which calls C), as a stack of
1 executing functions: the currently running function is the topmost
1 one on the stack, and when it finishes (returns), the next one down
1 then becomes the active function. Such a stack is termed a "call
1 stack".
1
1 For each function on the call stack, the system maintains a data
1 area that contains the function's parameters, local variables, and
1 return value, as well as any other "bookkeeping" information needed
1 to manage the call stack. This data area is termed a "stack
1 frame".
1
1 'gawk' also follows this model, and gives you access to the call
1 stack and to each stack frame. You can see the call stack, as well
1 as from where each function on the stack was invoked. Commands
1 that print the call stack print information about each stack frame
1 (as detailed later on).
1
1 "Breakpoint"
1 During debugging, you often wish to let the program run until it
1 reaches a certain point, and then continue execution from there one
1 statement (or instruction) at a time. The way to do this is to set
1 a "breakpoint" within the program. A breakpoint is where the
1 execution of the program should break off (stop), so that you can
1 take over control of the program's execution. You can add and
1 remove as many breakpoints as you like.
1
1 "Watchpoint"
1 A watchpoint is similar to a breakpoint. The difference is that
1 breakpoints are oriented around the code: stop when a certain point
1 in the code is reached. A watchpoint, however, specifies that
1 program execution should stop when a _data value_ is changed. This
1 is useful, as sometimes it happens that a variable receives an
1 erroneous value, and it's hard to track down where this happens
1 just by looking at the code. By using a watchpoint, you can stop
1 whenever a variable is assigned to, and usually find the errant
1 code quite quickly.
1