Steps for diagnosing errors that occur at run time

About this task

Before you begin: If you are diagnosing runtime errors when executing with Language Environment® services, refer to z/OS Language Environment Customization and z/OS Language Environment Debugging Guide.

Perform the following steps to diagnose errors that occur at run time:

Procedure

  1. Specify one or more of the following compiler options, in addition to the options originally specified, to produce the most diagnostic information:
    Option
    Information produced
    AGGREGATE
    (C only). Aggregate layout.
    ATTRIBUTE
    ( C++ only). Cross reference listing with attribute information.
    CHECKOUT
    (C only). Indication of possible programming errors.
    DEBUG
    Instructs the compiler to generate debug information based on the DWARF Version 4 debugging information format, which has been developed by the UNIX International Programming Languages Special Interest Group (SIG), and is an industry standard format.
    EXPMAC
    Macro expansions with the original source.
    FLAG
    Specifies the minimum message severity level that you want returned from the compiler.
    GONUMBER
    Generates line number information that corresponds to input source files.
    INFO
    (C++ only). Indication of possible programming errors.
    INLINE
    Inline Summary and Detailed Call Structure Reports. (Specify with the REPORT suboption.)
    INLRPT
    Generates a report on status of functions that were inlined. The OPTIMIZE option must also be specified.
    LIST
    Listing of the pseudo-assembly listing produced by the compiler.
    OFFSET
    Offset addresses of functions in the listing.
    PPONLY
    Completely expanded C or C++ source code, by activating the preprocessor (PPONLY). The output shows, for example, all the #include and #define directives.
    SHOWINC
    All included text in the listing.
    SOURCE
    Listing of the source file.
    TEST
    For 31-bit only, used to obtain information about the contents of variables at the point of the error, and to enable the use of Debug Tool.
    XREF
    Cross reference listing with reference, definition, and modification information. If you specify ATTRIBUTE, the listing also contains attribute information.

    _______________________________________________________________

  2. If the failure is in a statement that can be isolated, for example, an if, switch, for, while, or do-while statement, try placing the failing statement in the mainline code. If the problem is occurring as a result of a switch statement, make sure that you have "breaks" on all appropriate statements.

    _______________________________________________________________

  3. If you have used the compiler options RENT or NORENT in #pragma options or #pragma variable statements, and compiled your program at OPT(2), you can detect a possible pointer initialization error by compiling your program at OPT(0).

    _______________________________________________________________

  4. Check if you are running IBM® C/370™ Version 1 or Version 2 modules. Some IBM C/370 Version 1 and Version 2 modules may not be compatible with the Language Environment element. In some cases, old and new modules that run separately may not run together. You may need to recompile or relink the old modules, or change their source. z/OS XL C/C++ Compiler and Runtime Migration Guide for the Application Programmer documents these solutions.

    _______________________________________________________________

  5. If IPA Link processed the program:
    1. Ensure that the program functions correctly when compiled NOIPA at the same OPT level.
    2. Subprograms (functions and C++ methods) which are not referenced will be removed unless appropriate "retain" directives are present in the IPA Link control file.
    3. IPA Link may expose existing problems in the program:
      • Ensure that any coalesced global variables which are character strings have sufficient space to contain all characters plus an additional byte for the terminating null.
      • Ensure that there are no dependencies on the order in which data items or subprograms (functions, C++ methods) are generated.
    4. Do the following to check for a code generation problem:
      • Specify a different OPT level during IPA Link processing. If the program executes correctly, contact IBM service and be prepared to supply the relevant source (PPONLY) and object modules.
      • Specify the option NOOPT during IPA Link processing. If the program executes correctly, contact IBM service and be prepared to supply the relevant source (PPONLY) and object modules.

      If the program executes correctly at a different OPT level or NOOPT, perform a binary search for the IPA object file which contains the function for which code is incorrectly generated. Contact IBM service and be prepared to supply the relevant source (PPONLY) and object modules.

    5. Do the following to check for an IPA optimization problem:
      • Specify NOINLINE IPA(LEVEL(1)) during IPA Link processing.

        If the program executes correctly, perform a binary search using INLINE IPA(LEVEL(1)) for the IPA object file which contains the function which is incorrectly optimized. Once you have located the IPA object file with the problem, use noinline directives within the IPA Link control file to determine the functions that are not correctly inlined. Contact IBM service and be prepared to supply the relevant source (PPONLY) and object modules and the IPA Link control file.

        Functions that are inconsistently prototyped may cause problems of this type. Verify that all interfaces are consistent and complete.

      • Specify IPA(LEVEL(0)) during IPA Link processing.

        If the program executes correctly, perform a binary search using INLINE IPA(LEVEL(1)) for the IPA object file which contains the function which is incorrectly optimized. Contact IBM service and be prepared to supply the relevant source (PPONLY) and object modules.

      • Specify IPA(LEVEL(1)) instead of IPA(LEVEL(2))

        If you are linking with IPA Level 2, try linking with Level 1.

Results

At this point, if you still encounter problems that you think are the result of the compilation, contact IBM support.