[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

OpenVMS Debugger Manual


Previous Contents Index

C.13.2 Constructs in Language and Address Expressions

Supported constructs in language and address expressions for PL/I follow:

Symbol Construct
( ) Subscripting
. (period) Structure component selection
-> Pointer dereferencing

C.13.3 Data Types

Supported PL/I data types follow:

PL/I Data Type Operating System Data Type Name
FIXED BINARY Byte- (B), Word- (W), or Longword- (L) Integer
FIXED DECIMAL Packed Decimal (P)
FLOAT BIN/DEC F_Floating (F)
FLOAT BIN/ DEC D_Floating (D)
FLOAT BIN/DEC G_Floating (G)
BIT Bit (V)
BIT Bit Unaligned (VU)
CHARACTER ASCII Text (T)
CHARACTER VARYING Varying Text (VT)
FILE (None)
Labels (None)
Pointers (None)
Arrays (None)
Structures (None)

C.13.4 Static and Nonstatic Variables

Variables of the following storage classes are allocated statically:

STATIC
EXTERNAL
GLOBALDEF
GLOBALREF

Variables of the following storage classes are allocated nonstatically (on the stack or in registers):

AUTOMATIC
BASED
CONTROLLED
DEFINED
PARAMETER

C.13.5 Examining and Manipulating Data

The following subtopics give examples of the EXAMINE command with PL/I data types. They also highlight aspects of debugger support that are specific to PL/I.

C.13.5.1 EXAMINE Command Examples

The following examples show use of the EXAMINE command with a few selected PL/I data types.

  • Examine the value of a variable declared as FIXED DECIMAL (10,5):


    DBG> EXAMINE X
    PROG4\X:    540.02700
    
  • Examine the value of a structure variable:


    DBG> EXAMINE PART
    MAIN_PROG\INVENTORY_PROG\PART 
        ITEM:       "WF-1247" 
        PRICE:        49.95 
        IN_STOCK:     24
    
  • Examine the value of a pictured variable (note that the debugger displays the value in quotation marks):


    DBG> EXAMINE Q
    MAIN\Q:    "666.3330"
    
  • Examine the value of a pointer (which is the virtual address of the variable it accesses) and display the value in hexadecimal radix instead of decimal (the default):


    DBG> EXAMINE/HEXADECIMAL P
    PROG4\SAMPLE.P:  0000B2A4
    
  • Examine the value of a variable with the BASED attribute; in this case, the variable X has been declared as BASED(PTR), with PTR its pointer:


    DBG> EXAMINE X
    PROG\X:    "A"
    
  • Examine the value of a variable X declared as BASED with a variable PTR declared as POINTER; here, PTR is associated with X by the following line of PL/I code (instead of X having been declared as BASED(PTR) as in the preceding example):


    ALLOCATE X SET (PTR); 
    

    In this case, you examine the value of X as follows:


    DBG> EXAMINE PTR->X
    PROG6\PTR->X:    "A"
    

C.13.5.2 Notes on Debugger Support

Note the following points about debugger support for PL/I.

You cannot use the DEPOSIT command with entry or label variables or formats, or with entire arrays or structures. You cannot use the EXAMINE command with entry or label variables or formats; instead, use the EVALUATE/ADDRESS command.

You cannot use the EXAMINE command to determine the values or attributes of global literals (such as GLOBALDEF VALUE literals) because they are static expressions. Instead, use the EVALUATE command.

You cannot use the EXAMINE, EVALUATE, and DEPOSIT commands with compile-time variables and procedures. However, you can use EVALUATE and DEPOSIT (but not EXAMINE) with a compile-time constant, as long as the constant is the source and not the destination.

Note that an uninitialized automatic variable does not have valid contents until after a value has been assigned to it. If you examine it before that point, the value displayed is unpredictable.

You can deposit a value into a pointer variable either by depositing another pointer's value into it, thus making symbolic reference to both pointers, or by depositing a virtual address into it. (You can find out the virtual address of a variable by using the EVALUATE/ADDRESS command, and then deposit that address into the pointer.) When you examine a pointer, the debugger displays its value in the form of the virtual address of the variable that the pointer points to.

The debugger treats all numeric constants of the form n or n.n in PL/I language expressions as packed decimal constants, not integer or floating-point constants, in order to conform to PL/I language rules. The internal representation of 10 is therefore 0C01 hexadecimal, not 0A hexadecimal.

You can enter floating-point constants using the syntax nEn or n.nEn.

There is no PL/I syntax for entering constants whose internal representation is Longword Integer. This limitation is not normally significant when debugging, since the debugger supports the PL/I type conversion rules. However, it is possible to enter integer constants by using the debugger's %HEX, %OCT, and %BIN operators, because nondecimal radix constants are assumed to be FIXED BINARY. For example, the EVALUATE/HEXADECIMAL 53 + %HEX 0 command displays 00000035.

C.14 Language UNKNOWN

The following subtopics describe debugger support for language UNKNOWN.

C.14.1 Operators in Language Expressions

Supported operators in language expressions for language UNKNOWN follow:

Kind Symbol Function
Prefix + Unary plus
Prefix - Unary minus (negation)
Infix + Addition
Infix - Subtraction
Infix * Multiplication
Infix / Division
Infix & Concatenation
Infix // Concatenation
Infix = Equal to
Infix <> Not equal to
Infix /= Not equal to
Infix > Greater than
Infix >= Greater than or equal to
Infix < Less than
Infix <= Less than or equal to
Infix EQL Equal to
Infix NEQ Not equal to
Infix GTR Greater than
Infix GEQ Greater than or equal to
Infix LSS Less than
Infix LEQ Less than or equal to
Prefix NOT Logical NOT
Infix AND Logical AND
Infix OR Logical OR
Infix XOR Exclusive OR
Infix EQV Equivalence

C.14.2 Constructs in Language and Address Expressions

Supported constructs in language and address expressions for language UNKNOWN follow:
Symbol Construct
[ ] Subscripting
( ) Subscripting
. (period) Record component selection
^ (circumflex) Pointer dereferencing

C.14.3 Predefined Symbols

Supported predefined symbols for language UNKNOWN follow:

Symbol Meaning
TRUE Boolean True
FALSE Boolean False
NIL Nil pointer

C.14.4 Data Types

When the language is set to UNKNOWN, the debugger understands all data types accepted by other languages except a few very language-specific types, such as picture types and file types. In UNKNOWN language expressions, the debugger accepts most scalar OpenVMS calling standard data types.

  • For language UNKNOWN, the debugger accepts the dot-notation for record component selection. For example, if C is a component of a record B which in turn is a component of a record A, then C can be referenced as A.B.C. Subscripts can be attached to any array components; for example, if B is an array, then C can be referenced as A.B[2,3].C.
  • For language UNKNOWN, the debugger accepts brackets and parentheses for subscripts. For example, A[2,3] and A(2,3) are equivalent.


Appendix D
EIGHTQUEENS.C

This appendix contains the source code for the programs used in many figures of Chapter 8, Chapter 9, and Chapter 10, EIGHTQUEENS.C AND 8QUEENS.C. These programs are presented here only to assist in understanding the procedures described in those chapters.

D.1 EIGHTQUEENS.C

Example D-1 contains EIGHTQUEENS.C, the single-module program that solves the eightqueens problem.

Example D-1 Single-Module Program EIGHTQUEENS.C

extern void setqueen(); 
extern void removequeen(); 
extern void trycol(); 
extern void print(); 
    int a[8];     /* a : array[1..8]  of boolean */ 
    int b[16];    /* b : array[2..16] of boolean */ 
    int c[15];    /* c : array[-7..7] of boolean */ 
    int x[8]; 
 
/* Solve eight-queens problem */ 
main() 
{ 
    int i; 
    for (i=0; i <=7; i++) 
 a[i] = 1; 
    for (i=0; i <=15; i++) 
 b[i] = 1; 
    for (i=0; i <=14; i++) 
 c[i] = 1; 
    trycol( 0 ); 
} /* End main */ 
 
void trycol( j ) 
    int j; 
{ 
    int m; 
    int safe; 
    m = -1; 
    while (m++ < 7) 
       { 
       safe = (a[m] ==1) && (b[m + j] == 1) && (c[m - j + 7] ==1); 
       if (safe) 
            { 
     setqueen(m, j); 
     x[j] = m + 1; 
     if (j < 7) 
  trycol(j + 1); 
     else 
  print(); 
     removequeen(m, j); 
     } 
       } 
} /* End trycol */ 
 
void setqueen(m, j) 
    int m; 
    int j; 
{ 
    a[m] = 0; 
    b[m + j] = 0; 
    c[m - j + 7] = 0; 
} /* End setqueen */ 
 
void removequeen(m, j) 
    int m; 
    int j; 
{ 
    a[m] = 1; 
    b[m + j] = 1; 
    c[m - j + 7] = 1; 
} /* End removequeen */ 
 
void print() 
{ 
    int k; 
    for (k=0; k<=7; k++) 
 { 
 printf(" %d", x[k]); 
 } 
    printf("\n"); 
} /* End print */ 

D.2 8QUEENS.C

8QUEENS.C is the multiple-module program that solves the eightqueens problem. This program consists of two modules, 8QUEENS.C (Example D-2) and 8QUEENS_SUB.C (Example D-3).

Example D-2 Main Module 8QUEENS.C

extern void trycol(); 
    int a[8];     /* a : array[1..8]  of boolean */ 
    int b[16];    /* b : array[2..16] of boolean */ 
    int c[15];    /* c : array[-7..7] of boolean */ 
    int x[8]; 
 
main()    /* Solve eight-queens problem */ 
{ 
    int i; 
    for (i=0; i <=7; i++) 
 a[i] = 1; 
    for (i=0; i <=15; i++) 
 b[i] = 1; 
    for (i=0; i <=14; i++) 
 c[i] = 1; 
    trycol(0); 
    printf(" Solved eight-queens problem!\n"); 
} /* End main */ 

Example D-3 Submodule 8QUEENS_SUB.C

extern int a[8]; 
extern int b[16]; 
extern int c[15]; 
extern void setqueen(); 
extern void removequeen(); 
extern void print(); 
 
    int x[8]; 
 
void trycol( j ) 
    int j; 
{ 
    int m; 
    int safe; 
    m = -1; 
    while (m++ < 7) 
       { 
       safe = (a[m] ==1) && (b[m + j] == 1) && (c[m - j + 7] ==1); 
       if (safe) 
            { 
            setqueen(m, j); 
            x[j] = m + 1; 
            if (j < 7) 
                trycol(j + 1); 
            else 
                print(); 
            removequeen(m, j); 
            } 
       } 
}       /* End trycol */ 
 
void setqueen(m, j) 
    int m; 
    int j; 
{ 
    a[m] = 0; 
    b[m + j] = 0; 
    c[m - j + 7] = 0; 
}       /* End setqueen */ 
 
void removequeen(m, j) 
    int m; 
    int j; 
{ 
    a[m] = 1; 
    b[m + j] = 1; 
    c[m - j + 7] = 1; 
}       /* End removequeen */ 
 
void print() 
{ 
    int k; 
    for (k=0; k<=7; k++) 
        { 
        printf(" %d", x[k]); 
        } 
    printf("\n"); 
}       /* End print */ 


Index Contents