Delphi Debug Tips

Source: Internet
Author: User

Debugging Techniques for Delphi Development
1. Set debug options
Delphi Main Menu. Project, Options, or click the Project Options button in the project manager. Show Project Options, select Complier

<1> Check debug information: Embedding debug information into the DCU unit file will increase the compiled DCU file, but will not affect the size and execution speed of the last generated exe. Also activate the Find Error command in the Search menu.
When the file contains debug information and gets a run-time error (run-time error), log the 16 binary address provided by Delphi, and enter in "Search", "Find Error", Delphi will recompile the program and stay on the command line that generated the error.

<2>local symbols: Determines whether the debugger can see the local variables defined in the implementation.

<3>reference infoj option/definition only option
Whether to generate reference information for object identifiers in the application. Information and object codes exist in the DCU file and can be viewed using the Object Browser. If the definition only option is selected simultaneously, the compiler generates information that defines the location of the identifier, enabling the Refenrence page of the Object Browser to be activated. If not selected, the DCU file is smaller.

Editor commands
{$D} Debug Information
{$L} Local Information
{$Y} Symbol Information
{$C} Assertions

2. Using the internal debugger

<1> Command Line Parameters
Set in "Run", "Parameters"

<2> Breakpoints

Conditional breakpoint
Causes a source code breakpoint to be valid only if a condition is met.
Open the Breakpoint List dialog box in the View->[debug windows]-> "breakpoints", right-click the breakpoint and select Properties from the pop-up menu. Open the Source Breakpoint Properties dialog box, enter the criteria in the condition, click the button "Advanced" in the dialog box, and you can set more options, "Ignore subsequent Exceptions" Causes the debugger to not break when it encounters the next breakpoint; Handle subsequent Exception is selected to restore the default performance when the debugger encounters the next breakpoint.
You can also use the "Run" and "Add Breakpoint" settings.

Data breakpoints
The program hangs only when the memory of a particular address is modified. "Run", "Add Breakpoint", "Data Breakpoint" command added, or in the Breakpoint List dialog box, right-click, select Add Data breakpoint. Enter the start address and length of the monitored memory area (in bytes)

Address Breakpoint
A program hangs when code for a particular address executes. Typically set in the CPU window.

Module load Address
Suspends the program when a module is loaded. "Run", "Add breakpoint"

Breakpoint Group
With a breakpoint group, any breakpoint can be set to make other breakpoints valid or invalid, and a breakpoint algorithm can be used to find special errors.

3. Single Step execution

"Step over" (F8 function Key), "Trace into" (F7 function Key), "Run to Cursor" (F4 function key)
Temporarily suspends program pause.
Ctrl+f5 "Add Watch", Ctrl+f7 "Evaluate/modify"

4. Other tools

<1>debug Inspector is suitable for viewing composite data composed of many data, such as classes and records. You can modify the value of the data by clicking the ellipsis button.
<2> Calculate and modify Evaluate/modify, you can change the value of a variable, but you cannot access functions and variables outside the domain.
<3> access the call stack, "View", "Debug Windows," called Stacks, where you can see the invocation of functions and procedures and the arguments passed to them.
<4> View threads, if the application is running multi-threaded, you can view the status of threads through "view" "Debug Windows" "Threads", you can view the source code of a thread, select the front thread. (ctrl+alt+t)
<5> Event Log
Record what happened during debugging. View "Debug Windows" (ctrl+alt+v), you can configure the event log feature in the "Tools" Debugger Options Dialog box "Debugger" option group or the local menu of the event log. The logged events include: Process start, terminate, module load breakpoint, Windows message to the application, and output using OutputDebugString ().
<6> Module View
Gets all the modules that are loaded into the application process. (ctrl+alt+m)
Within the procedure, function, and event, the shift+ctrl+ upward arrow key jumps to the corresponding definition of the procedure, function, and event. Conversely, at the definition of a procedure, function, or event, a shift+ctrl+ downward arrow key jumps to a specific procedure, function, event interior
CTRL + SHIFT + C: Write a statement or fill in the function.
Such as:
Procedure TT.  A (aa:string); function declaration
Ann: Ctrl + SHIFT + C will write
Procedure TT. A (aa:string);
Begin
End

Shift+ctrl+e Display EXPLORER

CRTL + SHIFT + N (n=1,2,3,4 ...)
Defining bookmarks
CRTL + N (n=1,2,3,4 ...)
Jump to Bookmark N

ALT + left mouse button to block the code, remove the alignment of the duplicate code is very useful.
Ctrl+b the Buffer List window.
Ctrl+i the same tab key.
Ctrl+m with the ENTER key.
CTRL + N with the Enter key, but the cursor position remains unchanged.
Ctrl+t Delete one word to the right of the cursor.
Ctrl+y Delete the line where the cursor is located.

Ctrl+shift+↑ the cursor in the function body, move the cursor quickly to the current function declaration.
Ctrl+shift+↓ the cursor moves the cursor quickly to the function definition line when the function is declared.
Ctrl+shift+c a procedure or function is declared, the name, begin, end of the process or function is generated directly;
The ctrl+shift+e cursor toggles between the edit window and the Explorer window.
Ctrl+shift+j Popup The Delphi Statement Prompt window, select the desired statement will automatically complete a statement.
Ctrl+shift+t adds a to-do comment at the cursor line.
Ctrl+shift+y Delete the text between the cursor and the end of the bank.

CTRL+F3 Call Stack window.
Ctrl+f4 equals the close item in the File menu.

CTRL + mouse wheel to accelerate scrolling.

Shift+f8 the CPU window when debugging.
SHIFT+F10 Equals right mouse button (Windows shortcut key).

ALT+F4 closes the source program files that are open in all edit boxes, but does not close the project.


Ctrl+enter locating to a cell file
Shitf+ Arrow Selection
If you hold down the ALT +shitf+ arrow at the same time and then make a selection, it is an area selection, not a row selection, a pasted
The time is also inserted paste.
F9 Run
CTRL + F9 Compilation
F8 Step Over (stepper debugging does not enter sub-process)
F7 Trace into (stepping debug simultaneously tracks into sub-process)
F11,F12 Switch Editor,inspector,form DESIGNER.
Ctrl+alt+f11 Popup project Manager
Ctrl+f Popup Find dialog box
Ctrl+r Pop-up Replace dialog box
CTRL + SHITF+C class procedure Code completion (as long as you define a procedure or a function header in the definition section to automatically generate
Implement part of the rack;
But how does the Delphi jump lattice? In fact there is a way, is ctrl+k,i backwards, ctrl+k,u forward.
Sometimes repeatedly input what things are not very complex? Ctrl+shift+r recording keyboard macros, for example, what I often do is:
DOWN ARROW-down arrow-home-enter-ctrl+v, and then type once ctrl+shift+r recording is complete, after which you can use
Ctrl+shift+p, repeating macros, or saving a few things.
In addition, it is extremely useful to have a very useful quick key in Deliphi
This is ctrl+j; column: In the process you enter IFB and then press Ctrl+j you go back to see the effect, maybe you will be big
Take a fright. This is code Insight.

Ctrl+shift+u//block indent/anti-indent
Ctrl+shift+i

To cancel a bookmark: At the bookmark N, press SHIFT + CTRL + N at a time

Ctrl+e a kind of search very good, the rest of you have been told to play


Hold down CTRL and click Objects, procedures, and functions to go to its definition prototype, even if it is a unit in the Delphi VCL source code.


Alt+f4 close Delphi [:D]

Ctrl+k+o,ctrl+k+n the selected whole block of code to lowercase or uppercase
Ctrl+f Find
Ctrl+l continue to find

In inspector, you can switch properties pages and events pages with Ctrl+tab
Ctrl+enter can enter the corresponding settings, as in the Preperties page of the font press Ctrl+enter
Press Ctrl+enter in events to enter the corresponding Code Editor


Ctrl+shift+i: 2-Grid simultaneous push
Ctrl+shift+u: Back at the same time 2 grid [/red]

There is a trick, I often use, I do not know people often not used
ALT + Select text with the mouse
or ALT + SHIFT to select text with arrow keys
Try it before you try! [:D]


Put a Tedit control on the form, and then write "Edit1." In the code, wait a minute, and you'll see a hint.
In "Edit1." To use this hint feature before writing, press and hold the Windows key and press the blank key.
(only Windows keyboards can use this feature!) )


Ctrl+space and Input method conflict, the input method has no Input method shortcut key from Ctrl+space to the other key combination
On the line, I changed to a ctrl+shift+space.
Then in the unit, such as the input fo this is pressed Ctrl+space will appear a series of variables with the beginning of the FO, function.

Ctrl+backspace back to delete a word. It seems to be. So far.

In the Object Inspector window, press the TAB key to move the cursor to the property name area, and then type the beginning of the property name
Letters can be quickly positioned to this property

------------------------------------------------------------------------


The following shortcut keys refer to the operation of a component on a form table:
Shortcut key 1:
"Ctrl+up" ~ Move up the current component (exact);
"Ctrl+left" ~ Move the current component to the left (exact);
"Ctrl+down" ~ Move the current component down (exact);
"Ctrl+right" ~ Move the current component to the right (exact);
Note:
The above quick connect key plus Shift to combine (such as "ctrl+shift+right") can achieve rough adjustment;
Shortcut key 2:
"Shift+up" ~ Reduces the height of the current component;
"Shift+left" ~ Reduces the width of the current component;
"Shift+down" ~ Increase the height of the current component;
"Shift+right" ~ Increase the width of the current component;
Note:
The above up,left refers to the direction of the key;


The following shortcut keys refer to the operation on the object viewer:
Shortcut Key 3:
"F11" ~ Switch to Object Viewer (Note: If you press F11 continuously, the implementation will switch between object observer, form table, code Editor);
"Ctrl+down" ~ drop down the list of components for the current form;
"Ctrl+enter" ~ Edit Band ... The value of the property (such as the font tfont of the component);
"Alt+down" ~ drop-down component current attribute menu queue (e.g. align->alnone,alleft,alright, etc.);
"Ctrl+tab" ~ Switch between the list of attributes and the list of events;


Third, the menu shortcut key:
Shortcut key 4:
"F12", "Shift+f12", "ctrl+f12", etc. in the Delphi menu has been defined here do not have to wordy.

Skills:
How do I select a form that is covered by a component (such as the Align property of a component is alclient)?
Method One, press the ESC key, one layer after the next selection, until the form is selected as the current component;
Method two, press SHIFT while clicking the left mouse button, one step can be selected (recommended);
Method Three, press F11 to select the Object Observer, then switch to the attribute list, and then use the above shortcut key 3 "Ctrl+down"

Ctrl+up Move the selected component up (fine-tuning); Ctrl+left Move the selected component to the left (fine-tuning);
Ctrl+down Move the selected component down (fine-tuning); Ctrl+right Move the selected component to the right (fine-tuning);
Shift+up reduce the height of the selected component; Shift+left reduce the width of the selected component;
Shift+down increase the height of the selected component; Shift+right increase the width of the selected component;

CTRL + Drag to select another control on top of a control without selecting it itself!

List of shortcuts in Delphi (fully official version)
1.shift+ the left mouse button to select any control, select the form after pressing the button (the same as the ESC effect when the control is selected)
2.shift+f8 the CPU window when debugging.
3.SHIFT+F10 Equals right mouse button (Windows shortcut key).
4.shitf+ Arrow Selection
5.shift +f12 Quick Find form and open
6.f7 (stepping debugging simultaneously tracks into the sub-process)
7.f8 (Stepping Debug does not enter sub-process)
8.f9 Run
9.F12 switching Editor,form
10.alt+f4 Close the Open source program files in all edit boxes without closing the project
11.alt+ the left mouse button can block the code, used to remove the alignment of the duplicate code is very useful
12.CTRL+F9 compiling
13.ctrl+shift+n (n=1,2,3,4 ...) Defining bookmarks
14.ctrl+n (n=1,2,3,4 ...) Jump to Bookmark N
15.CTRL +shift+n at Bookmark N, press again to cancel bookmark
16.ctrl+pageup moves the cursor to the first line of the screen without scrolling
17.ctrl+pagedown moves the cursor to the last line of the screen without scrolling
18.ctrl+↓ Scroll down the screen, the cursor following the scroll does not go out of the screen
19.ctrl+↑ scrolling up the screen, the cursor following the scroll does not go out of the screen
20.ctrl+home move the cursor to the file header
21.ctrl+end move the cursor to the end of the file
22.ctrl+b Buffer List Window
23.ctrl+i with TAB key
24.ctrl+j (Pop-up the Delphi Statement Prompt window, select the desired statement will automatically complete a statement) code template
25.ctrl+m with the ENTER key.
26.ctrl+n with the ENTER key, but the cursor position remains the same
27.ctrl+t Delete a word to the right of the cursor
28.ctrl+y Delete cursor in the row
29.ctrl+c replication
30.ctrl+v paste
31.ctrl+x Cut
32.ctrl+z Restore (undo)
33.ctrl+s Save
34.ctrl+f Find
35.ctrl+l continue to find
36.ctrl+r replacement
37.ctrl+enter locating to a cell file
38.CTRL+F3 pop-up Call Stack window
39.ctrl+f4 equals the close item in the File menu
40.ctrl+backspace back to delete a word until it encounters a separator
41.ctrl+ Mouse wheel speed scrolling
42.ctrl+o+u Toggle the case of the selection block (note release O and press U,ctrl to hold)
43.ctrl+k+o Toggle Selection Block Lowercase (note loosen K and press O,ctrl to hold)
44.ctrl+k+n Toggle Selection block to uppercase (note release K and press N,ctrl to hold)
45.ctrl+shift+g Insert GUID
46.ctrl+shift+t Add to-do comment at cursor line
47.ctrl+shift+y Delete the text after the cursor to the end of the bank
48.ctrl+shift+c write a statement or fill in a function, perfect!!!
49.ctrl+shift+e Display Explorer
50.ctrl+tab Switch Properties page and Events page in Inspector
51.ctrl+shift+u code whole block left 2 spaces position
52.ctrl+shift+i code block right shift 2 spaces position
53.ctrl+shift+↑ in process, function, event, can jump to the corresponding process, function, thing
The definition of a piece (switch back and forth between interface and implementation)
54.ctrl+shift+↓ in the definition of procedure, function, event, can jump to concrete process, function, event interior (IBID.)
55.Tab in the Object Inspector window, press the TAB key to move the cursor to the property name area, and then type the beginning of the property name
Letters can be quickly positioned to this property
56.ctrl+alt after pressing Ctrl+alt, the mouse can select the code in a rectangular block,
and can be copied and pasted than it
57.shift+↓, ↑, →, ← Change the size of the selected control in 1 pixel units
58.ctrl+↓, ↑, →, ← Change the selected control position in 1 pixel units
59.ctrl+e Quick selection (oh, try it, it's fun)
---------the Gexperts---------
60.CTRL+ALT+C Comment Block
61.ctrl+alt+u Canceling comment blocks
62.ctrl+alt+h Build Header (more detailed settings in the Editor Experts property page of the Gexperts configuration)
63.ctrl+alt+o Select a statement between the corresponding delimiters
64.ctrl+alt+v jumps back and forth between the corresponding delimiters (conflicts with existing shortcut keys, please change)
---------the Gexperts---------

Ctrl+alt+[left Arrow] Quickly selects the method in Gexpert for all code between the begin and its corresponding end.
Alt + F11 Select a unit in the window that appears to automatically uses the unit you just selected in the implementation section of the current unit

Delphi Debug Tips

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.