Is this z/OS? I hope so ...
You say:
I need this for determining from where a high-usage subroutine is being called
unnecessarily in a large main program
(many called modules with multiple levels of CALL, but no recursion).
are these modules separate load modules which are dynamically called
and is the name of the load module (which may be identical to the
program-ID) sufficient?
If so, there is no need to rely on the program name which is stored
somewhere in the EPA signature (PPA1 block).
It is then possible to simply retrieve the EPA from the save area chain
and check, to which
load module this entry point belongs, using the OS control blocks CDE
and XTLST,
which is IMO a well-known method (and has no dependency on compiler releases
or even programming languages).
I wrote some dump analysis tools for customers, and they always do both
methods,
just in case that some "free style" ASSEMBLER programs in the chain
don't mark the
entry points in some of the known ways. Then we still have the name of
the load module
(and maybe the offset of the entry point, if it is non-zero).
HTH, kind regards
Bernd
Am 02.05.2023 um 19:08 schrieb Schmitt, Michael:
I wrote an assembler subprogram that gets the name of the caller of the caller, i.e.
if A > B > asm, it returns A. Or any number of levels up that you want. It
works for static and dynamic calls, for both Language Environment compatible and
non-LE programs.*
The logic to get the program name is non-trivial. For example, in an LE
compatible program it depends on if the Program Prolog Area is in FASTLINK
format or not.
I don't think this is possible to do in straight COBOL, because how would you
get access to the registers for the save area chain? But maybe there's an LE
service that could help.
Let me know if you're interested in the assembler program.
* assuming the program follows standard conventions for the program id
signature string.
-----Original Message-----
From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> On Behalf Of
Farley, Peter
Sent: Tuesday, May 2, 2023 11:23 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: COBOL question: How to dynamically get the name of the routine that
called you
This is an Enterprise COBOL V5/6 question. No earlier compiler versions are
involved.
Is it possible for a called COBOL program to dynamically determine the name of
the calling COBOL program (i.e., the PROGRAM-ID value)? I have been reading
the LE Vendor Interfaces manual but I have yet to figure out now to use any of
the documented services or control blocks to get the name of the caller.
I need this for determining from where a high-usage subroutine is being called
unnecessarily in a large main program (many called modules with multiple levels
of CALL, but no recursion). The subroutine unfortunately is NOT passed the
name of the caller in the LINKAGE parameters (that would have been too easy . .
. ).
Any RTFM pointers or process to follow to get the caller's name would be
appreciated. I am willing to set up an assembler stub routine to capture the
data if it cannot be done directly from the COBOL called subroutine.
Peter
--
This message and any attachments are intended only for the use of the addressee
and may contain information that is privileged and confidential. If the reader
of the message is not the intended recipient or an authorized representative of
the intended recipient, you are hereby notified that any dissemination of this
communication is strictly prohibited. If you have received this communication
in error, please notify us immediately by e-mail and delete the message and any
attachments from your system.
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN