|
New features in the release 1.3
Breakpoint directives
General description
Breakpoints are powerful in order to stop the execution in special line of code. In some situations the program is compiled and launched without the PaxDebugger window. For example, if a piece of code (procedure) is compiled and executed inside an event.
So, it is not always possible to open the debugger window and insert a breakpoint.
In order to let the user to still use the capability of breakpoint, it has been introduced a new feature, that is, the breakpoint directive.
It is a comment line like the follows:
// %STOP_ON_NEXT_LINE%
The special word used is a sort of pre-run directive which is interpreted by the component.
For each occurrence of breakpoint directives, the PaxDebugger component searches in the source code the first executable line and insert automatically a breakpoint.
Then paxDebugger executes the code and, if reaches the above line, pauses the program and open automatically open the debugger window.
Add/Remove directive
Breakpoint directives can be inserted by hand-write it as a comment line or by using the "Run|Add Breakpoint Directive" menu option.
To delete a breakpoint directive simply delete the line of code.
HINT
If you want to temporarily remove a breakpoint directive, change the keyword in a similar one (i.e. write STOP_ NO _NEXT_LINE instead of STOP_ ON _NEXT_LINE. Then, if you want to insert again the directive, you can simply rewrite the directive in the right manner.
Console Window
During development, it is possibile to insert many breakpoint directives. This surely help the project debugging. Upon delivery of the project it is necessary to remove all the breakpoint directives, or the user will be really tired to wait the application result while this latter is paused in a breakpoint.
To see all the breakpoint directives, open the breakpoint console from "Project|View Breakpoint Directives".
This windows has been developed in order to help the programmer to handle the Breakpoint directive. In this window is possible to:
add new directives;
delete the selected directive
refresh breakpoint directive list
delete all breakpoint directives
Auto-open debugger
Sometimes could happen (expecially when there are Breakpoint directives inside the code) that the debugger is not visible when the execution reaches a breakpoint.
The reason of this can be:
the paxDebugger window lies under other windows and is completely covered;
the paxDebugger window is not opened.
This could leads to user misunderstand because the application is paused but the user is not aware of this. In order to avoid this problem, PaxDebugger is delivered with the following build in functionality:
when reach the first breakpoint the execution is paused (ssPaused)
if the PaxDebugger is not visible then it will be showed
in any case PaxDebugger will be put on top of the screen.
Watch list
In PaxDebugger is possible to insert and delete variable names for which it is required to watch the value.
In the watch tab of paxDebugger is located a list box where is possible to insert (Ins key) and delete (Del key) variables. The paxDebugger will the displays the variable values.
View Definition
When the project grows up and reach many modules and hundreds of lines of code, the management of the script began a little bit difficult.
One of the most frequently used requirement is to inspect a function implementation when this function is used inside another function. Let's describe this scenario with an example.
I'm watching the following procedure:
Procedure SaveData;
Begin
If not DataChanged then
Print 'No changes done'
Else If not DataVerification then
Print 'Data verification failed'
Else begin
.
End;
End;
Note the use of the "DataChanged" and "DataVerification" function inside the "SaveData" procedure.
While reading this code I would like to see also the "DataChanged" code. Two possibilities:
Search the word "DataChanged"; in the Search panel find the procedure definition and double click on this occurrence in order to skip in the start of the procedure definition
Right click on the word "DataChanged" and select the context menu item "View Definition". All the rest is accomplished by paDebugger.
PaxDebugger saves in private memory all the time the "View definition" is used. So that the user can travel through the code by using "Next Position" and "Prior Position".
Here is how it works:
for each usage of "View definition" the component add a record in the local stack
If used "Prior Position" the component jump in the line of code relative to the position which precedes the current. For example, suppose we use "View definition" three times and jump from A to B and finally to C. The usage of "Prior position" from position C leads to position B; if you use again "Prior position" you will reach the start position A. In this case (position A) the option will be disabled.
"Next Position" is the opposite of "Prior Position" and can be used to navigate through the code. Suppose, in the example above to be in position B. If used "Next Position" you will reach position C. Of course, if there is no following position, the option will be disabled.
Bookmarks
PaxDebugger implements code bookmarks. The bookmark available inside PaxDebugger are general to the application and not local to the current module. In addition there is no bookmark number (how many times do you remember the bookmark number you need?): the bookmark are characterized by the module name and the code line. In addition the component displays the bookmark with a portion of the code line where they are defined.
Bookmark functionalities are available in the context menu inside the editor region. Right click in the line of code you wish to add the bookmark and paxDebugger will add a bookmark for you. If you right click again in the same line of code the component will remove the bookmark.
In order to reach a previously inserted breakpoint, paxDebugger gives three different possibilities:
Select the breakpoint from a list of all breakpoint defined in the project
Select the breakpoint from a list of all breakpoint defined in the project except the breakpoint defined in the current module
Select the breakpoint from a list of all breakpoint defined in the current module
All the three possibilities are available in the popup menu of the Editor area.
The first option is the most frequently used. But if you have lots of breakpoint in the project and you are sure that the code where you want to jump resides in the same module, then you could use the third option which will show only the breakpoint defined in the current module and so it will be simpler to select the right one.
Search and replace in all project
The search and replace functionality has been extended in order to search and replace words in all project. Now in the Search and Replace window is available another option under "Scope" panel, that is "All Modules". If selected the replace will be applied to all the modules of the current project.
Modify variable value
The Watch panel has been improved by implementing the possibility to change the value of variables.
Here is the steps to use in order to change a variable value:
- select the Watches panel
- write the variable name in the "Evaluate expression" edit box and then type "Enter"
- the current value will be displayed in the "Evaluate result" edit box
- Now write the new value and then click on the "Modify Value" button
Double click on error
When a compilation error occur, PaxDebugger reports this in the error panel and show the error line in the Editor panel.
If the user looses the position for whatever reason, double click to the error panel allow PaxDebugger to reposition the cursor in the error line.
Load/save compiled
The current version of PaxDebugger allows to save a compiled version of the project. This is such a "deploy" process: during development, it is common to use all Debugger functionalities. When the project is ready maybe could be a better idea to save it as compiled.
Upon execution, the project can be load from the compiled file and then executed. This usage allows to save execution time.
PaxDebugger component publishes two new procedures for this task:
function SaveCompiledToFile(const FileName: string; ForceOverwrite: boolean = TRUE): Boolean. Save current compiled project in "FileName". Remember to compile the project before to save it.
Function LoadCompiledFromFile(Const FileName: string): Boolean . Load an entire compiled project. Remember that before to run you must compile it. This compilation is very fast.
Tab Indentation
In PaxDebugger is possible to indent the source code by using both Delphi and Visual Studio Syntax. While writing code, you can use the Tab and Shift + Tab to indent code respectively right and left. By default the tab intentation takes 2 characters. If you prefer a different indentation you can change from the editor option page.
It is also available the block indentation functionality. to block indent/unindent, use the follows:
- Ctrl + Shift + I (Delphi like) or Tab (VS like) for right intentation
- Ctrl + Shift + u (Delphi like) or Shift + Tab (VS like) for left indentation (unindent).
Debug of functions
For technical reasons, current PaxDebugger version is unable to debug functions in the following special case:
It is a function
The return value is used (assigned to a variable or used in expressions, like the "if" condition)
The function definition follows the line of code which uses it.
In these situation PaxDebugger works well, i.e. compile and run without error. The only problem is that is not possible to insert breakpoint inside that function and also, during step-by-step debugging, is not possible to "Trace into" (F7) the function.
We are working to solve this problem. In the meantime, to overcome this bug, please, move the function definition before the one which uses it.
|