Intercepting files when debugging C and C++ programs
Several considerations must be kept in mind when using the SET
INTERCEPT command to intercept files while you are debugging
a C application.
For CICS® only: SET
INTERCEPT is not supported for CICS.
- If you intercept I/O for a C standard stream, this implicitly intercepts I/O for the corresponding IOStreams' standard stream.
- If you intercept I/O for a file, by name, and define an IOStream object associated with the same file, IOStream I/O to that file will be intercepted.
SET INTERCEPT command
during a debug session: stdout,stderr, andstdin(lowercase only)- any valid
fopen()file specifier.
The behavior of I/O interception across system() call
boundaries is global. This implies that the setting of INTERCEPT
ON for xx in Program A is also in effect for Program B (when
Program A system() calls to Program B). Correspondingly,
setting INTERCEPT OFF for xx in Program B turns off
interception in Program A when Program B returns to A. This is also
true if a file is intercepted in Program B and returns to Program
A. This model applies to disk files, memory files, and standard streams.
fopen statement. The output to
and input from the z/OS® Debugger log
file behaves like terminal I/O, with the following considerations:
- Intercepted input behaves as though the terminal was opened for record I/O. Intercepted input is truncated if the data is longer than the record size and the truncated data is not available to subsequent reads.
- Intercepted output is not truncated. Data is split across multiple lines.
- Some situations causing an error with the real file might not cause an error when the file is intercepted (for example, truncation errors do not occur). Files expecting specific error conditions do not make good candidates for interception.
- Only sequential I/O can be performed on an intercepted stream,
but file positioning functions are tolerated and the real file position
is not changed.
fseek,rewind,ftell,fgetpos, andfsetposdo not cause an error, but have no effect. - The logical record length of an intercepted stream reflects the logical record length of the real file.
- When an unintercepted memory file is opened, the record format is always fixed and the open mode is always binary. These attributes are reflected in the intercepted stream.
- Files opened to the terminal for write are flushed before an input operation occurs from the terminal. This is not supported for intercepted files.
- When an
fclose()occurs orINTERCEPTis setOFFfor a file that was intercepted, the data is flushed to the session log file before the file is closed or theSET INTERCEPT OFFcommand is processed. - When an
fopen()occurs for an intercepted file, an open occurs on the real file before the interception takes effect. If thefopen()fails, no interception occurs for that file and any assumptions about the real file, such as the ddname allocation and data set defaults, take effect. - The behavior of the
ASISsuboption on thefopen()statement is not supported for intercepted files. - When the
clrmemf()function is invoked and memory files have been intercepted, the buffers are flushed to the session log file before the files are removed. - If the
fldata()function is invoked for an intercepted file, the characteristics of the real file are returned. - If
stderris intercepted, the interception overrides the Language Environment® message file (the default destination forstderr). A subsequentSET INTERCEPT OFFcommand returnsstderrto itsMSGFILEdestination. - If a file is opened with a ddname, interception occurs only if
the ddname is specified on the
INTERCEPTcommand. Intercepting the underlying file name does not cause interception of the stream. - User prefix qualifications are included in MVS data set names entered in the
INTERCEPTcommand, using the same rules as defined for thefopen()function. - If library functions are invoked when z/OS Debugger is waiting
for input for an intercepted file (for example, if you interactively
enter
fwrite(..)when z/OS Debugger is waiting for input), subsequent behavior is undefined. - I/O intercepts remain in effect for the entire debug session,
unless you terminate them by selecting
SET INTERCEPT OFF.
- 1>&2
- If
stderris the target of the interception command,stdoutis also intercepted. Ifstdoutis the target of theINTERCEPTcommand,stderris not intercepted. WhenINTERCEPTis setOFFforstdout, the stream is redirected tostderr. - 2>&1
- If
stdoutis the target of theINTERCEPTcommand,stderris also intercepted. Ifstderris the target of theINTERCEPTcommand,stdoutis not intercepted. WhenINTERCEPTis setOFFforstderr, the stream is redirected tostdoutagain. - 1>file.name
stdoutis redirected to file.name. For interception ofstdoutto occur,stdoutor file.name can be specified on the interception request. This also applies to 1>>file.name- 2>file.name
stderris redirected tofile.name. For interception ofstderrto occur,stderror file.name can be specified on the interception request. This also applies to 2>>file.name- 2>&1 1>file.name
stderris redirected tostdout, and both are redirected to file.name. Iffile.nameis specified on the interception command, bothstderrandstdoutare intercepted. If you specifystderrorstdouton theINTERCEPTcommand, the behavior follows rule 1b above.- 1>&2 2>file.name
stdoutis redirected tostderr, and both are redirected to file.name. If you specify file.name on theINTERCEPTcommand, bothstderrandstdoutare intercepted. If you specifystdoutorstderron theINTERCEPTcommand, the behavior follows rule 1a above.
- 2>&1 2>file.name
- Behavior of
stderris undefined. - 1>&2 1>file.name
- Behavior of
stdoutis undefined.
Refer to the following topics for more information related to the material discussed in this topic.
- Related references
- z/OS XL C/C++ Programming Guide