Difference between revisions of "Debugging and Testing Techniques"
Yvonnemilne (Talk | contribs) |
Yvonnemilne (Talk | contribs) (→Summary) |
||
(11 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
==Debugging and Testing Techniques== | ==Debugging and Testing Techniques== | ||
− | ===Using the debug() | + | ===Using the debug() Function=== |
The [[DEBUG()|debug()]] function allows debugging information messages to be written to a text file in the currently set [[DB_DEBUGDIR]] directory. | The [[DEBUG()|debug()]] function allows debugging information messages to be written to a text file in the currently set [[DB_DEBUGDIR]] directory. | ||
Line 7: | Line 7: | ||
</pre> | </pre> | ||
− | The text file is named ''debug'' + process ID + ''.txt''. A copy of the latest debug file can also be found in the file ''debug.txt''. The setting [[SET DEBUG|set debug]] enables (on) or disables (off) the logging of the messages. | + | The text file is named '''debug''' + ''process ID'' + '''.txt'''. A copy of the latest debug file can also be found in the file '''debug.txt'''. The setting [[SET DEBUG|set debug]] enables (on) or disables (off) the logging of the messages. |
<code lang="recital"> | <code lang="recital"> | ||
Line 28: | Line 28: | ||
{| class="wikitable" | {| class="wikitable" | ||
− | ! | + | !width="30%"|Button |
+ | !width="70%"|Option | ||
|- | |- | ||
|Debug||Suspends program execution and starts the Debugger. The Debug option is only available if the program is being run uncompiled. | |Debug||Suspends program execution and starts the Debugger. The Debug option is only available if the program is being run uncompiled. | ||
Line 41: | Line 42: | ||
===Dumping Variables to an External Text File=== | ===Dumping Variables to an External Text File=== | ||
+ | The [[LIST MEMORY|list memory]] command can be used to list all current memory variables, including arrays and objects, to a text file. | ||
+ | |||
+ | <pre> | ||
+ | list memory to file <filename as character> | ||
+ | </pre> | ||
+ | |||
+ | Other current status information can be [[Display and List|output]] in a similar way: | ||
+ | |||
+ | * [[LIST STATUS|list status]] - list status information, including data, settings and keys | ||
+ | * [[LIST CALLS|list calls]] - list call stack for the current program, procedure or function | ||
+ | * [[LIST PROCEDURE|list procedure]] - list names of active procedures and functions | ||
+ | * [[LIST CLASSES|list classes]] - list active system, user-defined, class library and API classes | ||
+ | |||
===Using the Workbench Debugger=== | ===Using the Workbench Debugger=== | ||
The [[DEBUG|debug]] command displays a pop-up debugger allowing the specified program to be monitored during execution. | The [[DEBUG|debug]] command displays a pop-up debugger allowing the specified program to be monitored during execution. | ||
Line 51: | Line 65: | ||
{| class="wikitable" | {| class="wikitable" | ||
− | ! | + | !width="30%"|OPERATION |
+ | !width="70%"|Displays DEBUG operation: STEP, BREAKPOINT or WATCHPOINT. | ||
|- | |- | ||
|PROGRAM||Displays the name of the current procedure or program. | |PROGRAM||Displays the name of the current procedure or program. | ||
Line 64: | Line 79: | ||
{| class="wikitable" | {| class="wikitable" | ||
− | ! | + | !width="30%"|BUTTON |
+ | !width="70%"|EFFECT | ||
|- | |- | ||
|Step||Step through a line at a time. | |Step||Step through a line at a time. | ||
Line 105: | Line 121: | ||
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. | 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. | ||
− | |||
− |
Latest revision as of 14:16, 27 July 2010
Contents
Debugging and Testing Techniques
Using the debug() Function
The debug() function allows debugging information messages to be written to a text file in the currently set DB_DEBUGDIR directory.
logical = debug(message as character)
The text file is named debug + process ID + .txt. A copy of the latest debug file can also be found in the file debug.txt. The setting set debug enables (on) or disables (off) the logging of the messages.
set debug on // app1.prg debug("program started by: " + user()) //... debug("option chosen: " + m_opt)
Using the assert Command
The assert command is used for program debugging purposes: to display a message box with options when a condition evaluates to False (.F.).
assert <condition as logical> [message <message as character>]
The message box 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 issues set asserts off, causing subsequent asserts to be ignored. |
Dumping Variables to an External Text File
The list memory command can be used to list all current memory variables, including arrays and objects, to a text file.
list memory to file <filename as character>
Other current status information can be output in a similar way:
- list status - list status information, including data, settings and keys
- list calls - list call stack for the current program, procedure or function
- list procedure - list names of active procedures and functions
- list classes - list active system, user-defined, class library and API classes
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 DEBUG operation: 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.