Delphi breakpoint debugging - primary

 

The so-called breakpoint, is to set a mark on a line of program code, program execution will pause here to take over control of the program by the debugger. Using Breakpoints with the use of [Runto Cursor] command is somewhat similar, it is to execute the line after a pause. Difference is that the program may be provided and a plurality of breakpoints can be set to a break condition.
 
Breakpoints are usually provided in the region of questionable. Before breakpoint is encountered, the program runs at full speed. After a breakpoint is encountered, the program temporarily stops running, since you can single-step or trace the program.
 
A source code breakpoints
 
To set a breakpoint in the source code editor, there are the following four operating mode.
 
( 1) Move the cursor to set a breakpoint on a line, press F5.
 
( 2) with the left mouse button to click the left-most row of the breakpoint.
 
( 3) Right-click the line to set a breakpoint in the pop-up menu, select [Debug] command, then select [ToggleBreakpoint].
 
( 4) Run] [menu] [Add Breakpoint command, then select [SourceBreakpoint], Delphi opens] [Add Source Breakpoint dialog box, as shown in the source code breakpoints in Fig.
 
[Filename] box for entering the name of the source file breakpoint (including the path).
 
[Line number] box to enter the line number of the breakpoint.
 
[Condition] frame for setting conditions effective to break, usually a boolean expression. Boolean expressions can contain function calls, as long as the function returns a Boolean value.
 
When the program reaches this breakpoint, the value of the Boolean expression is first calculated. If the value is True, the breakpoint is effective, the program will be suspended. If the value is False, the breakpoint is invalid, the program will continue.
 
[] Pass count after box is used to specify how many times a breakpoint after breakpoint effective. For example, in one set a breakpoint For loop, will encounter this breakpoint at each cycle. But each time the breakpoint is encountered in the program will not pause, because there need to go through a certain number of breakpoints to be effective.
 
[Group] block for grouping the breakpoint. You can enter a new group name in this box, you can select an existing group name. Once the number of break into groups, can be used separately Disable Group] [command] and [Enable Group command is disabled as a group or allow them to be also assigned to a series of operations set the breakpoint.
 
Note: Set the breakpoint line must be executable lines of code. If the breakpoint on the line of comment lines, blank lines, variable declarations, debugger breakpoints considered invalid.
 
By default, the row of the breakpoint with a red and white display, and a small red circle in the binding region. FIG source code breakpoints in Fig.
 
 
                      Source code breakpoint 1
 
                      Source code breakpoints 2
 
When the mouse to point to this small circle, a prompt will pop up window that displays the number of passes and conditional breakpoints.
 
Second, the machine instruction break
Delphi allowed to set breakpoints for a certain machine instructions. When the program execution to the instruction, it will be suspended (you must execute to the breakpoint setting). To set the machine instruction breakpoints are the following ways.
 
( 1) in the CPU window with the left mouse button click on a region binding instructions.
 
( 2) select a CPU instruction window, and then press F5.
 
( 3) Right-click a command in the pop-up menu, select [Toggle breakpoint] command in your CPU window.
 
( 4) Add Breakpoint [] [] Run command menu, then select [Address Breakpoint], pop-up dialog box [Add Address Breakpoint] FIG breakpoint machine 1 shown in FIG.
 
                  Machine Breakpoint 1
 
Third, data breakpoints
 
Delphi is able to monitor the wrong target. If an address memory is rewritten, the program will be suspended by the debugger takes control, the same as if a breakpoint is encountered.
 
To set breakpoints that can be used [Run] Add Breakpoint menu [order], select [Data Breakpoint], [appear] Add Data Breakpoint dialog box, data breakpoints in FIG. 1 FIG.
 
[Address] box is used to specify the memory address to be monitored. You can type a variable name.
 
[Length] block specifies the length of data (number of bytes). If you type the [Address] box is a variable name, the [Length]
 
 
 
FIG Data Breakpoint 1] [Add Data Breakpoint dialog box may be left blank, because Delphi automatically calculate the length of the variable.
 
[Condition] frame for setting conditions effective to break, usually a boolean expression.
 
[] Pass count after box is used to specify how many times a breakpoint after breakpoint effective.
 
[Group] block for grouping the breakpoint. It is noted that, when the end of this commissioning, all data breakpoints will be prohibited. The next time debugging, if you also want to use these data breakpoints, you need to make them effective.
 
 
Fourth, the module breakpoint
 
To the first load monitoring module may be used [Run] Add Breakpoint menu [order], select [Module Load Breakpoint], [appear] Add Module dialog, as shown in FIG breakpoint module 1 shown in FIG.
Module breakpoint 1
In [Module  specifies a frame to be monitored Name] module or DLL is usually BPL. You can also click
 
[Browser] button to locate a module. Later, when the module is first loaded into memory, the program will be suspended by the debugger takes control, the same as if a breakpoint is encountered.
 
Fifth, specify the behavior of a breakpoint is encountered
In general, when a breakpoint is encountered, the program will be suspended. However,
 
Delphi, in addition to the program is suspended, you can also specify a different behavior. To specify the behavior when a breakpoint is encountered, you can set breakpoints when.
 
Use [Run] menu [Add Breakpoint] command, and then choose a type of breakpoint, Delphi will open the [Add Breakpoint] dialog box. Then, click [Advanced] button, pop-up [Add Breakpoint] dialog box, as shown in the breakpoint behavior.
 
If you select [ Break] checkbox when a breakpoint is encountered, the program will be suspended. This is the default behavior.
 
If you select [Ignore subsequent exceptions] checkbox will ignore the exception after the current process is triggered, that is, when an exception is encountered debugger will not stop. The box with the following [Handlesubsequent exceptions] checkbox in pairs, so that a piece of code can ignore the exception.
 
If you select [Handle subsequent exceptions] check box, and after the processing of the current process triggered by abnormal, that is, when the debugger encounters] [Debugger Options dialog box, specify exceptions will stop.
 
 
 
                   Specifies the behavior when a breakpoint is encountered
 
 
[The Log the Message] box to let the user specify a message. When a breakpoint is encountered, it will record the message.
 
[] Eval expression box to allow the user to specify an expression. Log result if the following [] check box is selected, when a breakpoint is encountered, will evaluate the expression and record the results.
 
[] Enable group block allows a group of valid breakpoint.
 
[Disablegroup] box to disallow a group of breakpoints. If a break is specified multiple behavior, when a breakpoint is encountered, it will be followed by the implementation of these acts.
 
Sixth, the breakpoint list window
If you define a lot of breakpoints, the breakpoint or not in the current editor window, you can find a list of breakpoints Breakpoints window and locate it in the source code.
 
Use [View] menu [Debug Windows] command, then select [Breakpoints], Delphi breakpoint list window will open, as shown in Figure breakpoint list.
 
             Breakpoints list
 
For source code breakpoint, the breakpoint list window will break where the source file name, line number, condition and the number of passes display.
 
For machine instruction breakpoint, the breakpoint list window displays the name of the source file of the breakpoint, a row number is incremented hexadecimal offset is the offset from the instruction source line starting machine instructions The number of bytes. However, sometimes, a machine instruction does not necessarily correspond to a source line, this time, the line number is not displayed.
 
For a data breakpoint, the breakpoint list window displays the name or address and data length.
 
Delphi breakpoint list window there are two columns, one for each of the behavior of breakpoints and the group name belongs. To locate the line in the source code where the breakpoint, or positioning machine instruction breakpoint in the CPU window, you can right-click a breakpoint in the pop-up menu, select the breakpoint list window with [View Source] or [Edit Source] command. If you select [ViewSource] command, the cursor will be positioned on looking breakpoint, the breakpoint list window but is still currently active window in order to continue to find additional breakpoints in the Breakpoints list window. If you select [EditSource] command, code editor will be the currently active window, so you can edit the source code.
 
Seven, remove breakpoints
 
Remove Breakpoint not delete a row or instruction breakpoint, but canceled the definition of breakpoints, program execution does not pause here.
 
If you only want to remove a breakpoint, following several operations mode.
 
( 1) Right-click a breakpoint in the pop-up menu, select [Delete] command in your breakpoint list window.
 
( 2) select a breakpoint breakpoint list window, and then press the Delete key or key press Ctrl + D.
 
( 3) Right-click the breakpoint in the code editor or using CPU window, the pop-up menu, select [Debug] command, then select [Toggle Breakpoint].
 
( 4) in the code editor window CPU or the cursor on the breakpoint, press F5. ( 5) in the CPU with the code editor window or the left mouse button click the leftmost breakpoint. If you want to delete all breakpoints, you can click the right mouse button in the breakpoint list window, the pop-up menu, select [DeleteAll] command.
 
————————————————
 
Original link: HTTPS: //blog.csdn.net/sushengmiyan/article/details/8674989

Guess you like

Origin www.cnblogs.com/fansizhe/p/12635576.html