360 Using IBM Application Development Tools for z/OS and OS/390
17.1 Preparing a C or C++ program for debugging
Preparations for this book were done with C/C++ for z/OS V1 R2 and Debug Tool 4.1. The
rest of this section (4.1) assumes this environment.
The TEST option is used by the C/C++ compiler option to enable debugging for a Batch
compile, a TSO compile, or a compile with the Debug Tool Utilities (DTU). The TEST option
has many suboptions, but for optimal debugging, we recommend that you always take the
default. A sample compile of the C IVP program is shown Example 17-1.
Example 17-1 Sample compile
//REDBK1A JOB ,
// MSGLEVEL=(2,0),CLASS=A,
// NOTIFY=REDBK1,REGION=1024M
//ORDER JCLLIB ORDER=(CBC.SCCNPRC)
//*-----------------------------------------------------------------
//* Compile C with z1.2 compiler for use with Debug Tool
//*-----------------------------------------------------------------
//COMPILE EXEC EDCCB,
// INFILE='CBC.SCCNSAM(CCNYIV1)',
// OUTFILE='REDBK1.DEV.LOAD(CIVP),DISP=SHR',
// CPARM='OPTFILE(DD:OPTIONS)'
//* GPARM='@@@@@@@ VERIFICATION SUCCESSFUL @@@@@@@'
//COMPILE.OPTIONS DD *
TEST
/*
For UNIX System Services (USS) compiles with the c89/c++/cc/cxx utilities, the -g option
should be used to enable debugging instead of the TEST option. The USS compile utilities
may choose to ignore the TEST option but -g is honored. The following USS command will
compile the C++ IVP program and link it into a PDSE:
cxx -+ -g -o "//'redbk1.dev.load(cppivp)'" "//'cbc.sccnsam(ccnyiv2)'"
Or if the IVP source was available in uss as cppivp.C:
cxx -g -o "//'redbk1.dev.load(cppivp)'" cppivp.C
The debug information for C/C++ is currently stored inside the executable and can increase
the size of the executable significantly. There are some applications that may become too
large to BIND when compiled for debugging. In that situation it is recommended that a subset
of the source files be compiled for debugging, or the application be reworked to use DLLs.
In general we find that it is easiest to add the appropriate extra option to your standard
development build method rather than using the DTU compile facility. However, the examples
used in this chapter are all small enough that any compile method will work.
Note: Refer to the appropriate Debug Tool users guide to for the most up-to-date
information on which options to use to compile for debugging with C/C++.
Get Using IBM Application Development Tools for z/OS and OS/390 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.