HP 3000 Manuals

Using TRANDEBUG [ HP Transact Reference Manual ] MPE/iX 5.0 Documentation


HP Transact Reference Manual

Using TRANDEBUG 

This section provides a tutorial to introduce you to the frequently-used
TRANDEBUG commands.  It will help you become familiar with using
TRANDEBUG. A complete list of TRANDEBUG commands and examples is found in
the "TRANDEBUG Commands" section later in this chapter.

After reading this section, you will know how to perform the following
tasks:

   *   Compile a program with the TRANDEBUG option
   *   Start and end a TRANDEBUG session
   *   View source code in TRANDEBUG
   *   Set breakpoints
   *   Continue program execution from within TRANDEBUG
   *   Display data items
   *   Modify data items
   *   Step through a program.

Compiling with the TRANDEBUG Option 

To use TRANDEBUG, you first compile your Transact/iX program(s) with the
TRANDEBUG option.  Specify this option in addition to any other compiler
options that your application requires.

The following example shows how to compile and link a main program using
the TRANDEBUG option:

     :TRANXLLK MYSOURCE,MYPROG,MYLIST;INFO="TRANDEBUG,NOLIST" 

The compiled output appears as follows:

     PAGE 1 Transact/iX HP30138A.04.02 (c) Copyright HEWLETT-PACKARD CO. 1987
     MON, OCT 26, 1992, 9:42 AM

     COMPILING WITH OPTIONS: CODE,DICT,ERRS,TRANDEBUG

     NUMBER OF ERRORS =   0          NUMBER OF WARNINGS =   0
     PROCESSOR TIME  0:00:02.1       ELAPSED TIME  0:00:03

     END OF COMPILE
     HP Link Editor/XL (HP30315A.00.25) Copyright Hewlett-Packard Co. 1986

     LinkEd> link from=$oldpass;to=myprog

     END OF LINK
     :

If your Transact application includes Transact subprograms, each
subprogram that requires debugging must be compiled with the TRANDEBUG
option.

Starting and Ending TRANDEBUG Sessions 

After you have successfully compiled and linked your program using the
TRANDEBUG option, run your program to start a TRANDEBUG session.  The
following figure shows how TRANDEBUG identifies itself on your screen:

     :RUN MYPROG 

[]
Figure 11-1. The TRANDEBUG Screen To terminate a TRANDEBUG session, type the following at the TRANDEBUG> prompt: TRANDEBUG> ABORT This command forces your program to abort TRANDEBUG, then exit. After you complete your debugging session, you must recompile your program without the TRANDEBUG compiler option. Be careful not to move program files compiled with TRANDEBUG to production. Displaying Source Code in TRANDEBUG TRANDEBUG provides a source code window that lets you view statements in the source code as they execute. This window can be controlled with the WINDOW and PAGE commands. Your program can run with the windows turned on or off. You can change the size of the window and scroll forward and backward through the source code listing independent of the program's execution. To display the source code for the program being debugged, type WINDOW ON at the TRANDEBUG> prompt as follows: TRANDEBUG> WINDOW ON TRANDEBUG immediately displays the source code for the program being debugged in a source code window like this:
[]
Figure 11-2. TRANDEBUG Source Code Window In the example shown, the right arrow (">") marks the current location. It points to the next statement that will be executed. In this example, the current location marker points to the first executable program statement. The current system, segment, and offset are displayed within the source code window. Setting a Breakpoint When you want to stop at a specific location in your program, you can set a breakpoint. With TRANDEBUG, you set a breakpoint by specifying the segment number and p-code offset within a Transact/iX program. If a breakpoint is to be set in the current segment, just specify the p-code offset. Figure 11-3 shows a compiled listing for a program that adds programmers to a TurboIMAGE database. This program is used in the remaining examples in this section. line number downarrow p-code offset 1.000 downarrow SYSTEM PTRAC, 2.000 0000 BASE = PROGB ( ,3), 3.000 0000 SOGMPM = "PTRAC A00.00"; 4.000 0000 5.000 0000 <<PTRAC is a program that adds programmers to >> 6.000 0000 <<a TurboIMAGE database called PROGB. >> 7.000 0000 <<PROGB is opened with exclusive modify access. >> 8.000 0000 9.000 0000 DEFINE(ITEM) 10.000 0000 11.000 0000 PHONE U(4), <<programmer's phone extension #>> 12.000 0000 HEAD = "Phone Number", 13.000 0000 ENTRY = "Enter phone extension number": 14.000 0000 15.000 0000 PROGRAMMER U(30), <<programmer's name>> 16.000 0000 HEAD = "Programmer": 17.000 0000 LNAME U(16) = PROGRAMMER(1), <<last name>> 18.000 0000 ENTRY = "Enter programmer's last name": 19.000 0000 FNAME U(14) = PROGRAMMER(17), <<first name>> 20.000 0000 ENTRY = "Enter programmer's first name"; 21.000 0000 <<end of data item definitions>> 22.000 0000 <<initialize>> 23.000 0000 SET(DELIMITER) ""; 24.000 0001 25.000 0001 $$ADD: <<begin the ADD command>> 26.000 0001 $PROGRAMMER: 27.000 0002 <<add programmer to PROGRAMMERS master data set>> 28.000 0002 29.000 0002 LIST PROGRAMMER: 30.000 0003 PHONE; 31.000 0004 DATA LNAME: 32.000 0005 FNAME: 33.000 0006 PHONE; 34.000 0007 PUT PROGRAMMERS, LIST=(PROGRAMMER:PHONE); 35.000 0011 END; <<end of ADD PROGRAMMER>> 36.000 0012 37.000 0012 END PTRAC; Figure 11-3. Sample Transact Program In Figure 11-3, only the p-code offset is required to set a breakpoint. A segment number is not required since only the current segment is being debugged. To specify a breakpoint at p-code offset 7, type BREAK SET at the TRANDEBUG> prompt: TRANDEBUG> BREAK SET 7 After the breakpoint is set, TRANDEBUG displays the following: BREAKPOINT SET: SYSTEM SEGMENT OFFSET COUNT COMMAND LIST ------------------------------------------------------------ 0. PTRAC 0 7 1 When the breakpoint is reached, TRANDEBUG suspends program execution and displays the TRANDEBUG> prompt. Continuing Program Execution The CONTINUE command resumes the execution of the program being debugged. Once you have set up initial breakpoints during a debugging session, you can resume program execution by typing CONTINUE at the TRANDEBUG> prompt. TRANDEBUG continues execution of your program until a breakpoint is encountered or the program terminates. The following example uses the CONTINUE command for the sample program shown in Figure 11-3: TRANDEBUG> CONTINUE >ADD PROGRAMMER Enter programmer's last name> LORENZ Enter programmer's first name> JAMES Enter phone extension number> 5000 BREAKPOINT ENCOUNTERED, EXECUTION STOPPED: SYSTEM SEGMENT OFFSET ----------------------------------- PTRAC 0 7 TRANDEBUG> Normal program execution resumes after you issue the CONTINUE command. The program continues until a breakpoint is reached when TRANDEBUG will suspend program execution and display the TRANDEBUG> prompt. When Ctrl Y is invoked during a debugging session, program control returns to TRANDEBUG and the TRANDEBUG> prompt. You can then set additional breakpoints and type CONTINUE to resume execution of your program, or issue any other valid TRANDEBUG commands. The following is an example of how Ctrl Y is used: TRANDEBUG> CONTINUE >ADD PROGRAMMER Enter programmer's last name: Ctrl Y TRANDEBUG> BREAK SET 7 TRANDEBUG> CONTINUE Displaying the Values of Data Items To display the value of a data item, you issue the DISPLAY ITEM command at the TRANDEBUG> prompt. When you use this command, you can display the contents of all items in the list and data registers, or specific items. The following example displays all items in the list and data registers: TRANDEBUG> DISPLAY ITEM LIST REGISTER: PROGRAMMER : LORENZ JAMES PHONE : 5000 The following example displays a specific data item: TRANDEBUG> DISPLAY ITEM PROGRAMMER PROGRAMMER : LORENZ JAMES Modifying the Values of Data Items To modify the value of a data item, type MODIFY ITEM followed by the data item name at the TRANDEBUG> prompt. You can modify the contents of the data register, but not the list register. After you issue the MODIFY ITEM command, TRANDEBUG displays the specified data item value and prompts you for the new value. Pressing Return without entering a new value leaves the data item unchanged. The following example modifies the FNAME child data item: TRANDEBUG> MODIFY ITEM FNAME FNAME : < JAMES > := < JIM > TRANDEBUG> DISPLAY ITEM PROGRAMMER PROGRAMMER: : LORENZ JIM TRANDEBUG> Stepping Through a Program The STEP command causes one or more groups of instructions to be executed. It can be used when you want to examine the contents of variables both before and after the groups of instructions are executed. The Transact/iX compiler determines the level of granularity at which you can single-step through a program. TRANDEBUG allows you to single-step through programs at a level that is meaningful to the Transact/iX language. When single-stepping through the LIST and DATA statements, TRANDEBUG returns control to you after each data item is loaded into the list and data registers. When single-stepping through other Transact/iX verbs, TRANDEBUG returns control to you after each statement is executed. The following example uses the STEP command to control program execution. The current location marker points to the LIST PROGRAMMER statement (p-code offset = 2). The user types DISPLAY ITEM at the TRANDEBUG> prompt as shown below:
[]
Program execution is resumed briefly with the STEP 3 command. The name "LORENZ" is entered in response to a program prompt. Control returns to TRANDEBUG after the 3 program instructions are executed. The user then types the DISPLAY ITEM command at the TRANDEBUG> prompt:
[]


MPE/iX 5.0 Documentation