12th Chapter-Exception Handling and program debugging (III.) (2)

Source: Internet
Author: User
Tags exception handling variables scalar valid

12.4.4.1 Watch Expression

The Watch List window (Watch list windows) Displays the value of the current watch expression in the program's run.

Select view| Watches can open the Watch List window.

The most convenient way to add a watch expression from the Code editor is:

1. Select an expression to monitor;

2. Select Add Watch from the Code Editor Accelerator menu to add an expression to the Watch List window.

You can also generate a watch expression using the following methods:

1. Open the Monitoring Properties dialog box (Watch Properties Dialog box) in one of the following ways:

Select run| in Main Menu ADD Watch

At the cursor, select Add Watch from the Code Editor Accelerator menu

Press Ctrl-f5

Double-click a watch expression in the Watch List window

Select an expression from the Watch List window and choose Edit from the Accelerator menu

2. Enter or select a monitored expression in the expression Drop-down list box of the Monitoring Properties dialog box;

3. Set the display format and enabling state of the expression.

Similar to breakpoints, you can use the accelerator menu to lose, recover, or delete watch expressions.

12.4.4.2 Calculation/Modification expression

Select run| Evaluate/modify can open the Calculation/Modify dialog box. When you click the Evaluate button, the value of an expression in the expression edit box is displayed in the result field.

Any valid expression (including the object's properties) can be entered or selected in expression, but not included;

1. An expression containing local or static variables that cannot be referenced by the current execution point;

2. function or procedure call.

An expression in expression can be used to specify its display format with a specific format character. The format characters and their functions are shown in the following table.

Table 12.8 format characters and their functions

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Format character feature

─────────────────────────────────

$,H,X displays a scalar in hexadecimal format

D displays a scalar in decimal format

C put the ASCII code at 0. 31 special words are shown as ASCII graphics

Fn displays floating-point numbers with n valid digits

M to display memory dump values of one variable in 16-way

P displays pointers in segments and offset formats. Both parts are four-bit hexadecimal values

R displays the records, the object's domain name, and the value (for example, X:5,y:2)

S displays a string (including special characters) in ASCII code. Used to modify memory dump values

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Modifying the value of an expression is often used to verify the correctness of the error solution. Enter or select the expression you want to modify in the expression edit box, and click the Evaluate button to observe the current value of the expression. Then enter or select a new value in the Modify, and click the button to confirm and update the data item. This modification only affects the specific program running.

Modifying the value of an expression, especially pointer variables and array subscripts, can cause unpredictable consequences. So be particularly careful in your use.

12.4.4.3 Display function call

Select view| The call stack can display the Stack window (call stack windows). The top of the Stack window lists the most recent function calls to the application.

Using the Stack window, you can exit the currently tracked function, and you can use the Accelerator menu item to display or edit the source code at a particular function call.

12.5 Other Debugging Tools

Delphi's built-in debugger, although powerful, is not up to all tasks. Also, because the built-in debugger causes subtle changes in the program environment in execution, it can affect how the error occurs. For this we need to use other debugging tools to accomplish our task. These debugging tools include Turbo Debugger, Winsight, Winspector, and browser. Browser will be introduced specifically in the next section.

12.5.1 Turbo Debugger

Turbo Debugger is the introduction of the third generation of language debugger Borland, although it has not yet launched a full support for the new version of Delphi, but also basic to the General Delphi program debugging.

Turbo debugger is performed in character mode, but it is a real Windows program that uses only character-based interfaces. Since Turbo Debugger is a special program that prepares to control other programs, it is not possible to use the usual Windows task switching features such as ALT + TAB.

The operation of the Turbo debugger is mostly the same as or similar to the built-in debugger. Using file| The Open menu loads the file you want to debug to start a debugging process.

Using the Turbo debugger, debug symbol information must be stored in an executable file. The specific operation is described in (12 4.1.1).

The Turbo debugger has many new features compared to the built-in debugger.

First, it provides a lot of control over low-level hardware information. Full access to the CPU's registers, flags, and system memory. Users can track remote pointers to memory locations and check their contents directly. The Turbo debugger can be tracked into the code, even if the source code is not available.

Turbo Debugger supports the special features of many windows. It tracks Windows messages, lets users view the program's local heap and global heap, and can browse through all the list of code units that comprise a program, including DLLs.

In addition Turbo Debugger support remote execution capability. You can control another machine by using a serial link or by configuring the Turbo debugger on a network that supports NetBIOS. In this mode, one machine displays the debugger screen, and another machine shows the program being tracked. This allows you to step through the program on one screen and monitor the results on another screen.

12.5.2 Winsight

Winsight is a debugging tool for viewing Windows objects and tracking the sending and receiving of messages. The winsight icon can be found in the Delphi program group.

The Winsight interface is divided into two parts, the Object tree window above, and the Message tracking window below. As shown in Figure 12.9.

In practical applications, users may be interested in only a subset of the messages, but they do not want them flooded with unwanted information. To do this, the user can open the Message menu and choose Selected Windows. Hold down the SHIFT key and click on objects of interest in the Object Tree window, and any messages for the selected object are displayed in the Message Tracking window.

If the user only wants to track certain message classes, open the Message menu and select options to filter the messages using the check box shown in Figure 12.10.

Summary of 12.6.6

The core of this chapter is how to enhance the robustness of programs and improve development efficiency. To this end we first examined the Delphi exception handling mechanism, and then introduced a number of program debugging tools, when you are about to end the basic learning, these content is you step into the development of large applications, the ranks of the senior programmers of the necessary weapons.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.