HP 3000 Manuals

PREPARING TO USE DEBUG [ MPE Debug/Stack Dump Reference Manual ] MPE/iX 5.0 Documentation


MPE Debug/Stack Dump Reference Manual

PREPARING TO USE DEBUG 

In order to use DEBUG, it is important to know the memory locations where
your program symbols are stored, the beginning locations of each program
unit, and the offset from these locations of each line of code.  This
information is obtained in several ways depending somewhat on the source
language of your program.

A FORTRAN program should be compiled with the MAP, LABEL, and LOCATION
parameters in the $CONTROL command; COBOL and SPL programs should be
compiled with the MAP parameter.  LABEL provides a label map showing the
offset of each labelled statement, and LOCATION provides the offset of
every statement as part of the source listing.  In an SPL program, this
information is provided automatically in your compilation listing.  The
MAP parameter generates a symbol map that lists all the symbolic names in
your program and the location in the data stack where the data is stored
for each symbol.

Any program to be debugged should be prepared with the PMAP parameter in
order to determine the beginning code location of each program unit and,
if more than one segment is used, the segment number.

For the purposes of this manual, FORTRAN has been chosen as the language
to be used in examples.  An SPL user will find that DEBUG has fewer
complications for his language than it does for FORTRAN and should simply
skip over the descriptions of determining data locations that are
peculiar to the FORTRAN compiler.

Figure 3-1 shows a simple FORTRAN program used to demonstrate use of the
DEBUG commands.  The compilation includes the MAP, LABEL, and LOCATION
parameters.  If you want an octal dump of the program, you can also
include the CODE parameter, but this is usually not necessary.  Figure
3-2 shows the result of preparing the program using the PMAP parameter in
the :PREP command.  (Note that PMAP can be included in :FORTPREP if you
compile and prepare in one operation.)  In both these figures,
significant entries are indicated by numbers keyed to the following
discussion.


NOTE All numbers in the PMAP listing except elapsed time and processor time are octal values; all numbers in the symbol map are octal; in the label map, the labels are decimal, the code offset is octal. DEBUG itself expects octal values unless otherwise indicated.
:FORTRAN DBTEST1 1 2 3 PAGE 0001 HP3210B.00.0 | | | | | | 00001000 $CONTROL MAP,LABEL,LOCATION,USLINIT 00012 00002000 PROGRAM MAIN 00012 00003000 CHARACTER*8 C,C1,C2(3) 00012 00004000 COMMON I4,I5 00012 00006000 DATA C/"DBTEST1"/ 00012 00007000 DATA C1/"MAINPROG"/,C2/"MONE","MTW0","MTHREE"/ 00012 00008000 DATA I6/10000/,I7/700/,I8/800/ 00012 00009000 10 DISPLAY C1,C2 00031 00010000 I1 = -1 00033 00011000 I2 = 1 00035 00012000 I3 = 10 00037 00013000 I4 = 100 00041 00014000 I5 = 1000 00043 00015000 DISPLAY "CALLING SUBROUTINE" 00075 00016000 20 CALL SUBROUT(C1,C2,I1,I2,I3) 00105 00017000 DISPLAY "BACK FROM SUBROUTINE" 00137 00019000 STOP 00140 00019000 END | 4 SYMBOL MAP NAME TYPE STRUCTURE ADD 5 / \ C CHARACTER SIMPLE VAR Q+ %1,I \ C1 CHARACTER SIMPLE VAR Q+ %2,I 6 C2 CHARACTER ARRAY Q+ %2,I / I1 INTEGER SIMPLE VAR Q+ %6 I2 INTEGER SIMPLE VAR Q+ %7 I3 INTEGER SIMPLE VAR Q+ %10 I4 INTEGER SIMPLE VAR %0 COMMON \ 7 I5 INTEGER SIMPLE VAR %1 COMMON / I6 INTEGER SIMPLE VAR Q+ %3,I \ I7 INTEGER SIMPLE VAR Q+ %4,I 6 I8 INTEGER SIMPLE VAR Q+ %5,I / SUBROUT SUBROUTINE COMMON BLOCKS NAME LENGTH COM' 2 LABEL MAP STATEMENT CODE STATEMENT CODE STATEMENT CODE LABEL OFFSET LABEL OFFSET LABEL OFFSET 10 12 0 75 \ / ----------- 8 -------- Figure 3-1. FORTRAN Compilation showing Symbol and Label Maps 4 / \ 00005 00020000 SUBROUTINE SUBROUT(D1,D2,J1,J2,J3) 00005 00021000 CHARACTER*8 D1,D2(3) 00005 00021100 COMMON J4,J5 00005 00022000 D1 = "SUBROUT" 00021 00023000 D2(1) = "SB0NE" 00037 00024000 D2(2) = "SBTWO" 00055 00025000 D2(3) = "SBTHREE" 00074 00026000 30 DISPLAY D1,D2 00113 00027000 J1 = -9 00115 00028000 J2 = 9 00117 00029000 J3 = 90 00121 00030000 J4 = 900 00123 00031000 J5 = 9000 00125 00032000 40 DISPLAY "RETURNING TO MAIN PROGRAM" 00164 00033000 RETURN 00165 00034000 END SYMBOL MAP NAME TYPE STRUCTURE ADDRESS 5 / \ D1 CHARACTER SIMPLE VAR Q- %10,I \ D2 CHARACTER ARRAY Q- %7,I | J1 INTEGER SIMPLE VAR Q- %6,I 6 J2 INTEGER SIMPLE VAR Q- %5,I | J3 INTEGER SIMPLE VAR Q- %4,I / J4 INTEGER SIMPLE VAR %0 COMMON \ 7 J5 INTEGER SIMPLE VAR %1 COMMON / SUBPOUT SUBROUTINE COMMON BLOCKS NAME LENGTH COM' 2 LABEL MAP STATEMENT CODE STATEMENT CODE STATEMENT CODE LABEL OFFSET LABEL OFFSET LABEL OFFSET 30 74 40 125 \ / ------------------ 8 ----------------- **** GLOBAL STATISTICS **** **** NO ERRORS, NO WARNINGS **** TOTAL COMPILATION TIME 0:00:04 TOTAL ELAPSED TIME 0:06:08 END OF COMPILE Figure 3-1. FORTRAN Compilation Showing Symbol and Label Maps (Continued) The key items in Figure 3-1 are: 1 MAP parameter included to produce symbol map of each program unit; in this example, one map for program MAIN and one for subroutine SUBROUT. 2 LABEL parameter included to produce a label map for each program unit. 3 LOCATION parameter included to produce location of each instruction relative to start of code. 4 Location of each instruction relative to start of code. 5 Memory address relative to Q location in data stack of each symbol except those declared COMMON. 6 I indicates the address is indirect; used for all values declared in DATA statements or passed from another program unit. 7 Location of symbol relative to start of common. 8 Location of each labelled instruction relative to start of code. :PREP $OLDPASS,DEPROG1.PMAP --- 1 PROGRAM FILE DBPROG1.PUB.TECHPUBS COMMON ARRAY ALLOCATION NAME ADR LEN COM' 2 31 2 SEG' 3 0 NAME STT CODE ENTRY SEG / SUBROUT 1 0 0 / TFORM' 3 | | ? / FMTINIT' 4 | | ? 4 BLANKFILL' 5 5 6 ? \ SIO' 6 | | ? \ ASIO' 7 | | ? \ MAIN 2 165 172 TERMINATE' 10 ? SEGMENT LENGTH 340 PRIMARY DB 2 INITIAL STACK 1440 CAPABILITY 600 SECONDARY DB 33 INITIAL DL 0 TOTAL CODE 340 TOTAL DB 35 MAXIMUM DATA ? TOTAL RECORDS 6 ELAPSED TIME 00:01:15.845 PROCESSOR TIME 00:00.414 END OF PREPARE Figure 3-2. Result of Preparation With PMAP The key items in Figure 3-2 are: 1 PMAP parameter included to list beginning code locations of each program unit and relative location of common. 2 Location of unlabelled common relative to DB. If used in program, labelled common would follow. 3 Logical segment number of the program file. 4 Program unit entry point; corresponding question mark (?) under heading SEG indicates that the procedure is external to the program. 5 Beginning location of code in the segment (start of code). 6 Location within this segment of entry point to program unit.


MPE/iX 5.0 Documentation