4.12.5 Use LANSA Debug Mode
Once LANSA debug mode has been turned on it can be used to aid in the location and correction of logic errors in the RDML commands that define what processing a function should perform.
To illustrate the use of LANSA debugging mode a process called EXAMPLE that has one function called ADDRECS is used. Function ADDRECS is to be debugged.
The RDML commands that define function ADDRECS follow and are used to add records to a name and address file named DEMNAME:
|
Debugging the RDML commands in ADDRECS is described in detail in the following steps.
Step 1
Turn LANSA debugging mode on. This has already been described.
Step 2
Select the option to use process EXAMPLE. This is exactly the same as electing to use process EXAMPLE in the normal way. This results in the menu associated with process EXAMPLE being displayed. Function ADDRECS is the first entry on the menu.
|
Step 3
Elect to use function ADDRECS from the display in Step 2. This is exactly the same as electing to use function ADDRECS in the normal way. The resulting display is the first "interruption" to the normal flow of events.
.......................................................
: F@DEBUG02 Add Records to the Name and Address file :
: :
: Select DEBUG option and press Enter :
: :
: _ 1.DEBUG Interactively :
: 2.TRACE All/Selective statements :
: 3.COUNT statements :
: :
: F3=Exit :
: :
:.....................................................:
This screen states that function ADDRECS is in debug mode and requests for the debug option to be selected. The DEBUG options have been previously described in this chapter.
If Options 1 or 2 were selected then the following displays will be shown requesting the relevant selections to be made. If Option 3 was selected then the function will immediately start to execute and act as if it is not in DEBUG mode i.e. no DEBUG interaction.
Step 4
For Options 1 and 2 only, the resulting display is the second "interruption" to the normal flow of events.
|
This screen states that function ADDRECS is in debug mode and requests that the RDML commands that are to be halted before execution are selected.
Note: On this screen it is possible to:
- Find a particular sequence number. To do this, enter the sequence number required in the 'Position at Seq' field and press enter. If the sequence number entered is beyond the range of sequence number, the last sequence number will be displayed.
- Find forwards. To find a particular string of characters enter them into the 'Find' field and select command key 16. If the string is found, the cursor will position on the first character. Please note that words split over lines will not be found.
- Find backwards. To find a particular string of characters in the RDML prior to where the cursor is currently, enter them into the 'Find' field and select command key 17. If the string is found, the cursor will position on the first character. Please note that words split over lines will not be found.
- Select all RDML lines. To select all the available RDML statements for breakpoint, use command key 20. The Select Variables screen will then be displayed.
- When RDML statements are selected, they will automatically be retained, along with any selected variables. When the function is run again under debug mode, the previous RDML statements selected will be indicated as selected. This will occur within the duration of a job. The retained breakpoints will be lost after signing off and also if the function is recompiled since they were selected.
In this case statement 6 has been chosen. DEBUG will stop the function just before executing statement 6. (i.e. just before attempting to insert a new record into the name and address file).
Step 5
For Options 1 and 2 only, the resulting display is the third "interruption" to the normal flow of events.
|
This screen states that function ADDRECS is in debug mode and requests that the Function variables (if any) that are to be Displayed or printed at an execution halt is to be selected.
Note: On this screen it is possible to:
- search for a variable. To do this, enter the required variable name into the 'Search for Variable' field and press Enter.
- Select all variables. To select all the available variables for display at breakpoint, use command key 20. The next screen will then be displayed.
If no RDML commands were selected in Step 4 then this display will not be shown.
In this case the Function variables DEMAD1, DEMAD2 and DEMNAC have been chosen to be displayed/printed at execution halt, in this example the variables will be displayed/printed just prior to the execution of statement 6.
Step 6
Function ADDRECS now begins to execute. Statements 3 and 4 are executed. When statement 5 is executed the normal display results.
|
Into this screen, details of a new name and address are entered.
Step 7
When Enter is pressed in the preceding step function ADDRECS completes execution of statement 5. However, since debug is on it should halt before executing statement 6. If Option 1 from Step 3 was selected then the following debug display results otherwise the function continues processing.
|
Some points to note about this display are:
- The statement about to be executed is indicated at the top of the screen and is highlighted. It is possible to roll through the top display of three RDML lines to show statements which come before and after the current statement.
- The bottom half of the screen displays all the fields that were selected from Step 5. Shown are the LANSA field name, the RPG field name, the description, Value of the fields (in Character, Zone and Decimal formats), type and length. If the LANSA field name is more than 6 characters long it will be different to the RPG field name. LANSA internally renames fields that are more than 6 characters long so that the RPG program will compile.
- The "Search for Variable" allows input for a variable name to be searched for against the list of variables that were requested to be displayed from Step 5. The Search if found will position the Cursor against that variable or in the case of a Generic search the cursor will be positioned against the first variable meeting the Generic search criteria.
- The "Act" column allows a number of actions to be taken on any of the fields displayed. These are:
D |
Display the contents of the field. |
H |
Display the contents of the field in hexadecimal form. |
P |
Print the contents of the field. |
C |
Change the contents of the field. |
- The function key "F10=Services" allows the various Debug service options to be actioned from a POP UP style services menu. This will be explained in Step 8.
- The function key "F11=Step Next" allows the execution of the current statement and then halt at the next statement to be executed.
- The function key "F15=Vars Y/N" allows the display to be shown with:
- variables and only three lines of RDML or
- without variables but a full screen of RDML lines.
- The function key "F19=Hex Yes/No" allows the display to be shown with hex values or without hex values.
When enter is pressed on this screen and assuming that no extra statements were added to halt execution via the "Edit Services Menu", the function ADDRECS will execute statement 6 and statement 7 which causes statement 4 to be executed again. When statement 5 is executed the display described in Step 6 will result again.
So the function continues to execute - stopping whenever requested to display or change the contents of fields.
Step 8
If Function key 10 is used the "Edit Services" Menu will be displayed.
|
The various options are:
- Review/Change Debug statements.
This allows the review of statements that have been selected to halt the function to either add further statements or remove current statements. This process and the resulting display is identical to Step 4.
- Remove ALL Debug statements.
This will automatically remove all statements that have been selected from Step 4 which will allow the function to continue processing without being halted.
- Review/Change Variables to display.
This allows the review of Function variables that have been selected to be displayed at selected debug statements. This process and resulting display is identical to Step 5.
- Terminate Function.
This allows the function to be terminated and return control to the current process menu. Function key 3 will Exit from the "Services Menu" and return to the display as in Step 7.
The "Edit Services" menu is only ever available when the debug mode is on, debug option is DEBUG Interactively and when the function is at a debug statement halt.
Step 9
The final step in this example is to turn debug mode off and to display or print the Debug TRACE or COUNT report if selected.