PL/I programs containing EXEC SQL, EXEC CICS, or EXEC DLI statements can use the preprocessor -optexec option with the plitest parameter. This causes the preprocessor to inject a PL/I macro into the code. The macro invokes the debugger through an infused PLITEST() call. This is done automatically and does not require editing a side file such as PLIDEBUG.DAT. It also does not require knowledge of explicit CodeWatch commands.
However, this debugging method cannot be used for batch programs that do not have EXEC language capability, or for IMS-based programs that use PLITDLI instead of EXEC DLI.
For these types of programs, you can use a technique similar to that used by the EXEC preprocessor, but in the PL/I Macro preprocessor, to automatically generate a PLITEST() call.
%if ATTACHDEBUGGER %then %do; DCL JAVAUI FIXED BIN(31) NATIVE VALUE(1); CALL PLITEST("shlib " || procedurename() || ".dll;" || "env " || procedurename() || ";br STARTDEBUG;" || "br %exit [det;q];c", " ", JAVAUI); STARTDEBUG:; %end;
This code causes a debugger to automatically attach itself during program execution, and stop on the STARTDEBUG label.
–deb -macro -define attachdebugger
In the code sample, the %if..%do condition is functionally similar to $IF in COBOL or #ifdef in C. The sample as a whole is a functional equivalent to CBL_DEBUGBREAK, with the added capability of being ably to specify any additional CodeWatch commands, such as setting breakpoints, to be executed upon startup.