Created On:  10 May 2010

Problem:

CodeWatch will retain a lock on the application program DLL file if the program is allowed to run to completion, with or without raising an error condition.

Resolution:

When executing an Open Pl/1 application program under the control of CodeWatch, a lock is placed on the program DLL file, which will not be released unless the CodeWatch user quits from CodeWatch before the program terminates. Especially in the case of the program raising an unexpected error condition, it may not be possible to manually quit CodeWatch before the program terminates, resulting in an instance of CWGUI.exe left executing, with a lock held on the application program DLL. This in turn prevents both relinking of the DLL, and starting another CodeWatch debugging session.

This situation can be avoided using a combination of error handling structure and CodeWatch commands.

1) Code an error "on unit" of the form: ON ERROR CALL ERRTRAP; Where ERRTRAP is an internal procedure containing your error handling and/or diagnostic statements. You can give this procedure any name you like – just replace “ERRTRAP” in the following step with the name of your internal procedure. If you have other possible error exit points for specific trappable conditions (e.g. CONVERSION, UNDEFINED FILE, etc.), convert these to also use internal procedures, instead of the more usual BEGIN blocks.

2) In the CodeWatch control file, PLIDEBUG.DAT, add the following commands after your SHLIB and ENV definitions for the program:

    BR %EXIT [DET;Q]; BR ERRTRAP\\%EXIT [DET;Q]

This will cause CodeWatch to halt execution at both normal and error exit points, and then detach itself from the application program, release the lock on the DLL, and terminate cleanly. Add as many "<procname>\\%EXIT [DET;Q]" commands as appropriate.

N.B. This technique has no effect if the job is manually cancelled, or cancelled by JES due to a system error (e.g. job timeout, addressing error, etc.).