BPCE SI, BPCE group.
Original Message:
Sent: Tue May 21, 2024 12:50 PM
From: Roy Bae
Subject: Using the IGZXAPI API from a COBOL program
Hello Denis,
Unfortunately, COBOL does not currently provide native ways of getting CAA, DSA, and EP. I have been collecting those needs and will be working on providing some of COBOL runtime library in the near future. In the meantime as you allow to use C, it can be done in the following way
COBOL
IDENTIFICATION DIVISION.
PROGRAM-ID. X1.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 t pic xxx value "123".
01 v pic 999 value 123.
01 dsa1 usage pointer.
01 caa1 usage pointer.
01 ep1 usage pointer.
LINKAGE SECTION.
01 x pic xxx.
PROCEDURE DIVISION.
BEGIN.
call 'GETINFO' using dsa1, caa1, ep1
display "dsa1:" function hex-of(dsa1)
display "caa1:" function hex-of(caa1)
display "ep1:" function hex-of(ep1)
stop run.
END PROGRAM X1.
C:
#pragma linkage(_gdsa,builtin)
#pragma linkage(_gtca,builtin)
#include <errno.h>
#include <stdio.h>
void *__ep_find (const void * dsa_p, int dsa_fmt, void*);
void * /* pointer to prior DSA */
__dsa_prev
(
const void * /* pointer to current DSA */
, int /* backchaining request type:
1 = physical
2 = logical */
, int /* starting DSA format:
0 = up
1 = down */
, void * /* called function returns a pointer
to the fetched data (perhaps
moved into this A/S)
note: if callback function cannot
return the requested data, it must
not return -- i.e. it should
longjump back to the user program
that called __dsa_prev() */
(*) /* optional ptr to user-provided
callback function that fetches
data, possibly from other
address space -- NULL = fetch
data from current A/S */
(
void * /* 1st input parm for callback fcn --
starting address of data to be
fetched (perhaps from other A/S) */
, size_t /* 2nd input parm or callback fcn --
length of data to be fetched
(will not exceed 16 bytes) */
)
, const void * /* pointer to LE CAA -- required if
4th argument is non-NULL.
Note: this may be the address of
CAA in the other A/S */
, int * /* optional ptr to output field
where previous DSA stack format
will be returned -- NULL = don't
pass back stack format */
, void ** /* optional pointer to output field
where address of physical callee
DSA will be placed -- NULL =
don't pass back physical callee
address */
, int * /* optional ptr to output field
where physical callee stack format
will be returned -- NULL = don't
pass back stack format */
);
// NOTE:
// The Vendor Interfaces header file, <edcwccwi.h>,
// is located in member EDCWCCWI of the CEE1.SCEESAMP data set. In order to include <edcwccwi.h> in an application,
// the header file must be copied into a PDS or into a directory in the z/OS® UNIX file system where the C/C++ compiler will find it.
void GETINFO(const void** dsa1, void** caa1, void** ep1){
#define __EDCWCCWI_UP 0
#define __EDCWCCWI_DOWN 1
#define __EDCWCCWI_PHYSICAL 1
#define __EDCWCCWI_LOGICAL 2
*caa1 = _gtca();
*dsa1 = __dsa_prev(_gdsa(), __EDCWCCWI_PHYSICAL, __EDCWCCWI_UP, 0,0,0,0,0);
*ep1 = __ep_find(*dsa1, __EDCWCCWI_UP, NULL);
}
In order to run, statically link COBOL and C programs, and run the COBOL as a main.
Actual output:
dsa1:2736F030
caa1:268201D8
ep1:2680A000
------------------------------
Roy Bae
Original Message:
Sent: Sun May 19, 2024 05:31 AM
From: Denis FALLAI
Subject: Using the IGZXAPI API from a COBOL program
Hi,
I would like to use the IGZXAPI API to develop introspection services for the execution context of a COBOL program, from the COBOL program itself, or from a service subroutine, still in COBOL.
The different functions supported by the IGZXAPI API require providing information that I do not know how to determine from a COBOL program:
- address of the DSA of the COBOL program to query
- address of the Language Environment CAA control block containing the COBOL program to query
- address of the entry point of the COBOL program to query
- some functions also require valuing register R12 with the address of the Language Environment CAA control block containing the COBOL program to be interrogated, or with the value 0.
Regarding getting the address of a program's entry point, I found that using the COBOL statement "SET pointer TO ENTRY program" did not return the actual address of the entry point of the program, but the address of a block of instructions which allows the program to be called.
In summary, is it possible to use the IGZXAPI API from a COBOL program, and in this case how to supply the different zones necessary for the functions of this API without using routines in Assembly language? (The use of C language can be considered).
Thanks.
------------------------------
Denis FALLAI
BPCE SI, BPCE group.
------------------------------