VRPG - Source Level Debugging
By George Farr
the third article describing the new VRPG Client product. The
first article, published in May, presented an overview of VRPG
and its components. The second article, published in July, described
the new operation codes and changes that were made to the ILE
RPG language to allow the language to fully utilize the workstation
Although most VRPG programmers will never write buggy
code, the VRPG environment contains a source level debugger, just
in case! This article will describe the Interactive Presentation
Manager Debugger (IPMD) supplied with the VRPG product to allow
you to debug your RPG source code. This powerful debugger allows
the VRPG programmer to set breakpoints, look at RPG fields and
storage, set trace points on storage, change field representations,
and step through the program. All this is done by simply using
the mouse and not using the traditional way of entering commands
on the command line.
Starting the Debugger
What are the normal application development processes?
Well, in VRPG you first create your screens using the Graphical
User Interface (GUI) builder as we have shown you in previous
articles. You then add RPG source code to the screens. Once this
is all done, you finally build your RPG application using the
'Build' option on the project menu item shown in Figure 1. Once
the project is built, if the need arises to debug it, the next
step will be to run the project under debug using the 'Debug'
option on the project menu as shown in Figure 1.
Figure 1. Starting the VRPG Debugger.
When the debugger starts, two windows will be displayed.
The first window is the debug session control window that displays
all of your project's active objects. This includes the RPG EXE
and DLL that contain your RPG logic. The second window will display
your RPG source code including the line sequence number where
you may add breakpoints. You will note that the first RPG source
line will be highlighted to indicate the position of the executing
program. Once both of these windows are displayed on the screen,
and the first line is highlighted, the debugger at that point
will wait for the next action from the programmer. In other words,
at this point you can add breakpoints, monitor variables, and
basically do any function you wish to do before telling the debugger
to continue executing. When you are ready to run the program you
simply press the letter 'R' and that will run the debugger to
the next breakpoint or to the end of the program.
In the IPMD debugger there are different options
for doing the same task. For example, to continue executing the
program you can press the letter 'R', you can move the mouse to
the green circle on the title bar and press it, or you can select
the Run option.
VRPG Debugger Description
The VRPG debugger is an easy to use tool that will
help the programmer to find and correct any errors in the code.
The VRPG source level debugger is a Presentation Manager application
that allows the programmer to perform these important functions:
Setting line breakpoints
You can easily set or delete breakpoints by double-clicking on
the source line number. The application will stop when it gets
to the source line with the breakpoint. In Figure 2., to the left
of the Source window, you can see 2 highlighted (actually red,
in color) line numbers; these are breakpoints. One is set at line
20 and the other is set at line 36. Also note that line 36 is
black. This signifies the current line that the debugger has halted
on. When execution resumes (by clicking on the green circle or
using the Run menu option), this will be the starting point.
The source level debugger is column sensitive. When you double-click
on the main VRPG columns ( e.g., Factor 1, Factor 2, Result field,
Indicators fields, D specification Name ), the variable contained
within that field will be displayed in the Program Monitor window
of the debugger. This window contains all variables that are
to be monitored. As the value of the variables change in the
program, the value displayed by the Program Monitor will change
as well. The displayed value can be in the default representation,
character or decimal, or you can change the representation to
hexadecimal. All types of data can be monitored; data structures,
arrays and standalone fields. The Program Monitor window can not
only display the value of a field, but can also be used to change
the value of a field. Just type in The new value in the space
beside the field name. In Figure 2., there are displayed many
different types of data. There are date fields, time fields, arrays,
data structures, pointers, standalone fields and indicators.
When arrays and data structures are displayed by name all elements
are displayed. If you explicitly display only a particular element
of an array then only that element will be displayed.
Setting Change Address breakpoints
These breakpoints stop the execution of your program after the
contents of a memory location are changed. To set Change Address
breakpoints, use the Breakpoints menu.
Single stepping the application
The debugger allows you to step through your application line
by line as you watch the value of a variable change. The next
line to be executed will be darkened.
You can display storage and watch it as it is changed. In Figure
2., there is a pointer, PTR, that is set to the address of the
standalone field FIRST. The address of PTR is displayed. This
value is then typed into the Storage window in the first column
labeled "Flat". This causes the storage from that address
to be displayed. As you can see here is contains the value of
the field FIRST. The Storage window can be displayed by clicking
on the spy-glass icon (in the Source window) or by choosing the
Storage option of the Windows menu item.
Figure 2. The VRPG Source Level Debugger..
Customizing Your Debug Session
The IPMD debugger allows you to customize your debug
session. For example, you can set the fonts that you prefer. To
accomplish this, you select 'Options' followed by 'Fonts'. Select
the pull down menu for fonts and then pick the desired font and
press OK. This will change the font in your debug session. Another
example is setting the data representation for specific data type.
For example you can tell the debugger that you want all character
data to be displayed in hexadecimal format. Or all zoned fields
to be displayed in hexadecimal or decimal format. Once you customize
the debugger, you can save this and the debug session thereafter
will use the same settings.
An important part of the development cycle is debugging
the application you are building. The VRPG source level debugger
is an easy to use, graphical debugger that allows you to debug
your VRPG applications quickly. Using the VRPG debugger, you
can display variables, the program source, and storage. As variables
and storage change so does their display. Along with the ability
to set/remove breakpoints and to single step through VRPG code,
you will be able to quickly find and remove the few bugs you will
have in your VRPG code.
In future articles, we will focus on other components
of VRPG such as the LPEX editor and the GUI designer. For more
information on VRPG and other IBM products, surf the IBM home
page (URL http://www.ibm.com).
George Farr has a specialized honors degree in computer
science from York University. He has been a member of the IBM
Toronto Lab since May 1985. He is a frequent speaker at COMMON
and other conferences and has written numerous articles on the
subject of AS/400 languages. He recently co-authored a book on
ILE - 'ILE - A FIRST LOOK'. He is currently the development manager
for the VRPG compiler. George can be reached via e-mail at
Scott Ripley has a computer science degree from the University of New Brunswick. He has been a member of the IBM Toronto Lab since May 1985. He has worked on the run-time for the Ada, C, and VRPG compilers. Scott presently is a member of the VRPG development team. He can be reached via e-mail at email@example.com.