|
||||||||
|
|
![]() |
|
|
|
|
||
|
Am I Debugging You? Hey, Ted: I would like to execute a section of code in a CL program only if I'm in debug mode. Is there a way for my CL program to know whether the job is running in debug? Also, is there a way for a CL program to know whether production files are allowed to be updated during a debugging section? --Joe Your first requirement is easy to handle. Use the Change Debug (CHGDBG) command, specifying *SAME for all parameters. If the command fails, the program is not running in debug mode. Here's an example:
dcl &true *lgl value('1')
dcl &false *lgl value('0')
dcl &debugging *lgl
chgvar &debugging &true
chgdbg
monmsg cpf0000 exec(chgvar &debugging &false)
if &debugging do
dspmodsrc
enddo
call somepgm
If the Start Debug (STRDBG) command was issued, placing the job in debug mode, the program runs the Display Module Source (DSPMODSRC) command, allowing the programmer to set break points before program SOMEPGM runs. Your second question is a little more difficult. There is an API that can tell whether the debugging session permits files in production libraries to be changed. It is an ILE API, which means you can only use it in CL modules, not in OPM CL programs. Moreover, it has a quirk you should be aware. (More about the quirk in a minute.) The API has the name QteRetrieveDebugAttribute. It can tell you whether production files may be updated, whether the debugging session is for the current job or another job, and whether OPM programs may be debugged with the ILE debugger. Here is a snippet from a CL module that calls this API to retrieve two of those values:
dcl &Attr *char 10
dcl &UpdProd *char 10
dcl &OPMSrc *char 10
dcl &Err *char 8 value(x'0000000000000000')
dcl &Debug *char 1 value('1')
CHGVAR VAR(&ATTR) VALUE('*UPDPROD')
CALLPRC PRC('QteRetrieveDebugAttribute') +
PARM(&ATTR &UPDPROD &ERR)
MONMSG MSGID(CPF9541) +
EXEC(CHGVAR VAR(&DEBUG) VALUE('0'))
IF (&Debug *eq '1') do
CHGVAR VAR(&ATTR) VALUE('*OPMSRC ')
CALLPRC PRC('QteRetrieveDebugAttribute') +
PARM(&ATTR &OPMSRC &ERR)
enddo
The first parameter specifies the attribute you wish to retrieve. In your case, the attribute is *UPDPROD. The retrieved attribute comes back in the second parameter. The returned value will be *YES (production files may be updated) or *NO. If the job is not in debug mode, the API returns error CPF9541. This is where the quirk shows itself. I have discovered that QteRetrieveDebugAttribute also returns this message if the job is in debug mode, but the current program is not selected for debug. To learn more about QteRetrieveDebugAttribute, go to IBM's iSeries Information Center. --Ted
|
Editors
Contact the Editors |
| Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved. |