Difference between revisions of "Debugging and Testing Techniques"
Yvonnemilne (Talk | contribs) (→Using the Workbench Debugger) |
Yvonnemilne (Talk | contribs) (→Using the assert() function) |
||
Line 1: | Line 1: | ||
==Debugging and Testing Techniques== | ==Debugging and Testing Techniques== | ||
===Using the debug() function=== | ===Using the debug() function=== | ||
− | ===Using the assert | + | ===Using the assert Command=== |
+ | The ASSERT command is used for program debugging purposes: to display a message dialog with options when a condition evaluates to False (.F.). The condition is specified in <expL>. An optional message can be specified using the MESSAGE <expC> clause. If no message is specified; the default message is: | ||
+ | |||
+ | |||
+ | <pre>Assertion failed on line <#> of | ||
+ | procedure <prg>.</pre> | ||
+ | |||
+ | |||
+ | The dialog has four buttons, offering the following options: | ||
+ | |||
+ | |||
+ | {| class="wikitable" | ||
+ | !Button||Option | ||
+ | |- | ||
+ | |Debug||Suspends program execution and starts the Debugger. The Debug option is only available if the program is being run uncompiled. | ||
+ | |- | ||
+ | |Cancel||Stops program execution. | ||
+ | |- | ||
+ | |Ignore||Continues program execution. | ||
+ | |- | ||
+ | |Ignore All||Continues program execution and issue SET ASSERTS OFF, causing subsequent asserts to be ignored. | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | |||
+ | If [[SET ASSERTS|set asserts]] is off, the default, asserts are ignored. | ||
+ | |||
===Dumping Variables to an External Text File=== | ===Dumping Variables to an External Text File=== | ||
===Using the Workbench Debugger=== | ===Using the Workbench Debugger=== |
Revision as of 10:03, 27 July 2010
Contents
Debugging and Testing Techniques
Using the debug() function
Using the assert Command
The ASSERT command is used for program debugging purposes: to display a message dialog with options when a condition evaluates to False (.F.). The condition is specified in <expL>. An optional message can be specified using the MESSAGE <expC> clause. If no message is specified; the default message is:
Assertion failed on line <#> of procedure <prg>.
The dialog has four buttons, offering the following options:
Button | Option |
---|---|
Debug | Suspends program execution and starts the Debugger. The Debug option is only available if the program is being run uncompiled. |
Cancel | Stops program execution. |
Ignore | Continues program execution. |
Ignore All | Continues program execution and issue SET ASSERTS OFF, causing subsequent asserts to be ignored. |
If set asserts is off, the default, asserts are ignored.
Dumping Variables to an External Text File
Using the Workbench Debugger
The debug command displays a pop-up debugger allowing the specified program to be monitored during execution.
debug <filename as character>
The debugger consists of four lines of information about the current program and eighteen push buttons. Program information consists of the following lines:
OPERATION | Displays one of the following DEBUG operations: STEP, BREAKPOINT or WATCHPOINT. |
---|---|
PROGRAM | Displays the name of the current procedure or program. |
LINE# | Displays the current line number. |
COMMAND | Displays the next program line to be executed. |
The eighteen push buttons are used to access information about the current environment and to specify memory variables and conditions to monitor during program execution. The pop-up debugger provides the following push buttons:
BUTTON | EFFECT |
---|---|
Step | Step through a line at a time. |
Suspend | Suspend the program to go to the interactive prompt, RESUME to restart. |
Cancel | Cancel program execution and create error.mem. |
Memory | Display currently declared memory variables. |
Status | Display currently open tables (and their indexes, current record, etc.). |
Calls | Show program/procedure call stack. |
Watch | Set a watch point. When Executing the program, execution will stop when the specified memory variable's value changes. |
Break | Set a break point. When Executing the program, execution will stop when the specified condition becomes true. |
History | Show command history trace. |
Execute | Run program without stepping until watch point or break point reached. |
Wpclear | Clear all watch points. |
Bpclear | Clear all break points. |
Bpmark | Mark the current line as a break point. |
Bpdrop | Clear a particular break point. |
Wpdrop | Clear a particular watch point. |
Bpshow | Show all break points. |
Wpshow | Show all watch points. |
Quit | Exit the program and debugger. |
Use the [UP], [DOWN], [LEFT], and [RIGHT] arrow keys to navigate the push buttons, and press the [RETURN] key to select a button. You may also type the accelerator key to select a button. The accelerator keys are the highlighted letters in the label of each push button.