GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
cobol

cobol: Fix CBL_GET_PROGRAM_INFO function 2 logic

Corrects the behavior of CBL_GET_PROGRAM_INFO function 2 in libcobol to match documentation.

This commit fixes a flaw in the CBL_GET_PROGRAM_INFO function 2 implementation within libgcobol. The previous logic incorrectly assumed function 2 only returned status and program name for the handle it was associated with. The documentation clarifies that function 2 must return information from the caller program and update the handle. The corrected logic now adheres to this, enabling correct retrieval of call stack information across program calls, ensuring that the handle is updated with information from the calling program in each step.

In Details

The getlastprog function in libgcobol's CBL_GET_PROGRAM_INFO implementation incorrectly handled function 2. It assumed function 2's output was limited to the cblte-gpi-handle's current program. However, the documentation specifies that function 2 must return information about the *caller* program and update cblte-gpi-handle to point to that caller. This commit rectifies getlastprog, callstack, and related status functions to correctly implement this caller-centric information retrieval and handle update mechanism, aligning with the expected behavior for debugging and introspecti…

For Context
CBL_GET_PROGRAM_INFO
A function in the COBOL runtime environment used to retrieve information about programs, their call stacks, and execution status.
libgcobol
The GNU COBOL runtime library, which provides support for running COBOL programs compiled by GCC.
handle
A value that represents a specific object or resource, used to access it. In this context, cblte-gpi-handle likely refers to a handle for program information retrieval.
call stack
A data structure that keeps track of active subroutines or function calls. When a function is called, its return address and local variables are pushed onto the stack; when it returns, they are popped.
Filed Under: cobolruntimedebuggingintrospection