Navigation  without Java Scripts

Visual Prolog Debugger

Introduction

Debugging is the process of finding errors in programs. Some have estimated that correcting errors in program takes about 90% of the total development time. This proves that good tools for debugging is very important.

The debugger allows inspection of variables, facts and callstack, as well as setting breakpoints and stepping through the source code.

Debugging an Application

The first thing to do is to turn on the generation of the debugger information in the compiler options dialog.

Turning on the "Generate Debug Information" checkbox will force the compiler to generate .DEB files in the .OBJ directory. These .DEB files are used by the debugger to locate Source, Variables, Facts etc. during execution of the program.

When Visual Prolog is installed by the setup Program, the setup program will install an icon for the debugger. The debugger is an executable placed under BIN\WIN\32\VIPDEBUG.EXE. There is currently only a WIN32 version of the debugger that can run under Win95 and Windows NT.

Debugging is normally started from inside the Visual Development Environment, by activating the menu Project->Debug, or pushing the corresponding button in the toolbar.

When a program has been loaded into the debugger, the starting point and several other informations can be viewed (which modules has been loaded, which of them can be debugged, etc.) from the Message-window in the bottom of the screen.

 

The program can be started, using the Run-menu or the buttons in the panel.

The Modules View

When the debugger is started and a program is loaded, the program is displayed in the Modules Window and the structure of the files can be examined by the explore tree.

 

In this View it is possible to double click on the files, the project consists of, and double click on the individual predicates. The result will be that a source code window opens up at the selected position.

Note that to be able to see the source code, the program must be written in Visual Prolog. All other programs can though be seen directly in assembler in the disassembly-window.

It isn’t possible to edit code in the PDC-debugger, because it is stand-alone. The most convenient way to correct errors is probably to find the correspondent predicates in both the debugger and Visual Prolog.

Source Code View

The menu command View->Source at Current position, sets a cursor to a position of current instruction pointer.

 The source code-windows can be opened from almost any menu entry in the Debugger.

 

The code will appear in white color at the locations where it is possible to set breakpoints.

With the right mousebutton or the Edit, it is possible to copy sourcecode to the clipboard (Copy command), find text (Search command), goto a specific position or line (Go to Line number and Go to position, respectively). The absolute position in the code can be found, by Show Position.

The Run Menu

The Run menu is used to control execution of the program to be debugged.

Run (F9) Issuing the command will start execution of the application. This is normally used in conjunction with setting of breakpoints.
Break Program When a program is running under the debugger, it is possible to break the program to go into the debugger. Then it is possible to inspect the call stack to see what the program is actually doing - or to set a break point where to catch the execution.
Trace Into This is used to step through the source code call by call.
Step Over This is used to skip the execution of a given predicate call.
Run to Cursor This works at setting a breakpoint at the current source position and then doing Run.

Setting Breakpoints

Setting of breakpoints is very important to isolate errors or to verify that parts of a program executes correctly. When a source window is open, it is possible to right click on the line. This will bring up a menu, from where a breakpoint can be set. When RUN(F9) is chosen the program will execute only to this point.

 More control over breakpoints can be achieved, by using the Breakpoints-Window. This window can be opened by choosing Breakpoints from the View-menu.

 

In this list, all breakpoints can be seen and their status can be changed. A status change is removal or toggle. Both are done with the right mousebutton. The first removes the breakpoint, the latter switches between enabled/disabled. With the menu point Go to Code, it is possible to go to the source file, where this breakpoint is placed. Another very useful possibility in the right mouse menu is the breakpoint control, which is done by choosing Properties.

 

Here it is possible to se how many times, this breakpoint is reached (in the Counterrectangle), and control, if it is reached XX times, then it is eliminated (in the Current Count).

Another possibility is use to the menu entry "Run->Run to cursor" (F4). Place the cursor an appropriate place in the source code, and activate the command.

Variables View

During execution it is possible to inspect the variables values by opening View->Local Variables

Also, when the mouse cursor is pointed at some variable in the source code, it is possible after a short while to see the value of this variable. This can be a handy way to inspect the values without opening the Variables View.

Viewing Facts

An important issue in correcting Prolog programs is to ensure, that the correct facts has been asserted. The facts of the program can be viewd in the Facts-windows. This window is selected by choosing FACTS from the View menu.

Call Stack

Call Stack window shows a list of predicates that have been already called in a debugging program. Double click on a predicate shows the code where a call to a selected predicate occurred.

Untitled.gif (5888 bytes)

Trap Points Window

Trap Points window shows a list of trap points of debugging program. Double click on a trap point shows a code where this point is placed.

Backtrack Points Window

Backtrack Points window shows a list of backtrack points of debugging program. Double click on a backtrack point shows a code where this point is placed.

Machine Level Views

It is possible to view assemblercodes directly in PDC Debugger, see the register or memory contents.

The main purpose of these is when inspecting non Prolog code.

Debugger Options

The options are found under View->Options.

Show Startup Code

Allows debugging of a program code before a call to Goal.

Scanning Call Stack from Goal

If checked then Call Stack window will only contain calls that occurred after a call to Goal.

Save Breakpoints

Allows to save breakpoints for a current project in debugger ".ini" file.

Do not show Assembler if possible

References to assembler code and assembler code itself are not shown as much as possible.

Gray source lines that contain no code

Lines of source code of a program are grayed where breakpoint can not be set.

Fonts

Allows to change fonts for windows of a debugger.