CBL_GET_PROGRAM_INFO (PL/I)

Returns information for a named program, or a program in the current call stack.

For COBOL, the CBL_GET_PROGRAM_INFO uses the save area defined for a COBOL program. The COBOL run-time system loads both .int and .gnt, providing access to the relevant save area for these types of programs.

A native object code program, however, may be in a state where it has been loaded by the COBOL run-time system, but not yet called. Until called, there is no save area and as such CBL_GET_PROGRAM_INFO could not be used on a native object code program (shared object, dynamic link library or executable).

To resolve this, you can embed a predefined structure into the program's resulting objects based on the compiler (COBOL or PL/I). That structure should contain a known symbol so the run time can easily locate the structure during execution. If the native object code program is loaded, but not yet executed, or if the object is a PL/I object, then this symbol can be located and program information can be extracted from the embedded structure.

The compiler creates the following structure for object code programs:

struct
{
    unsigned int version;
    unsigned int flags;
    union
    {
        void * p_savarea;
        Unsigned int PLI_attributes;
    }x;
} _mFinfo_<NAME>;

/* PLI_attributes bit values        */
#define PLI_AMODE24           0x00000001
#define PLI_AMODE31           0x00000002
#define PLI_EBCDIC            0x00000004
#define RESERVED1             0x000000F8
#define LANGUAGE              0x00000700
#define LANGUAGE_SPECIFIC     0x01FFF800
#define PLI_LENDIAN           0x00000800
#define PLI_FUTURE            0x01FFF000
#define RESERVED2             0xFE000000

Where:

<NAME> The name of the main entry point or program
version The version of the structure (initially set to 1)
flags

0 = COBOL program

1 = PL/I program

p_savarea The pointer to the COBOL program's savarea.
PLI_attributes The returned PL/I attributes

The _mFinfo_<NAME> symbol must be made visible so the run time can locate it when necessary. In the COBOL run time, CBL_GET_PROGRAM_INFO works as normal except when the named program is found but no save area exists. When this happens, if the _mFinfo_<NAME> symbol is found, the associated structure is deciphered depending on version and flags. For COBOL, a pointer to the program's save area (p_savarea) allows you to access and return all relevant information for the given program. For PL/I, the relevant program information is extracted and returned from the PLI_attributes data item.

For PL/I, CBL_GET_PROGRAM_INFO return the program's attributes as it does for a COBOL program. The PL/I program returned bit meanings are:

Bit 0
0 Program not compiled using the AMODE"24" Compiler directive.
1 Program compiled using the AMODE"24" Compiler directive .
Bit 1
0 Program not compiled using the AMODE"31" Compiler directive.
1 Program compiled using the AMODE"31" Compiler directive .
Bit 2
0 Program compiled using the CHARSET(ASCII) Compiler directive.
1 Program compiled using the CHARSET(EBCDIC) Compiler directive.
Bit 3-5
Reserved for future use.
Bit 6
0 Program not compiled using the DATA(24) Compiler directive.
1 Program compiled using the DATA(24) Compiler directive.
Bit 7
0 Program not compiled using the DATA-CONTEXT Compiler directive.
1 Program compiled using the DATA-CONTEXT Compiler directive.
Bit 8-10
0 Language is unknown.
1 PL/I.
2 through 7 Reserved.
Bit 11
Language-specific flag.
0 PL/I-specific (little-endian).
1 PL/I-specific (big-endian).
Bit 12-24
Language-specific flags.
Bit 25
0 Program is not an application controller.
1 Program is an application controller.
Bit 26
Reserved for future use.
Bit 27
0 Program is not a .390 assembler program.
1 Program is a .390 assembler program.
Bit 28-30
Reserved for future use.
Bit 31
Set for PL/I programs.
0 COBOL.
1 Non-COBOL.

The CBL_GET_PROGRAM_INFO routine modifies bits 8-10 to set the PL/I language and set bit 31 to indicate non-COBOL. The rest of the data item returns as is. Bits 3-7, and 25-30 are reserved to not conflict with existing programs that do not correctly check bit 31.

Getting program information on the current program and then iterating up the stack to retrieve caller program information is not supported for PL/I programs in the stack.