Debugging Internal Macro Code for a PL/I Program

If you are serious user of PL/I macro language or maintaining a program that uses of macros extensively to generate code, you may be required to debug at the level of the generated source, just as you may for EXEC CICS, EXEC DLI, or EXEC SQL. In these instances, use these techniques to step through every line of generated code, examining and changing variable values to understand what is happening in your program. This is particularly useful for discovering macro behavior that you do not understand or expect. By debugging at the generated code level, you can work out exactly what is happening.

Code that is actually present in the macro code is not part of PL/I source file. However, the macro code is available in the preprocessed file. To debug code that is actually present in the in the macro you must debug the preprocessed file.

You can create a preprocessed output file for the source file you are debugging and debug the output file. To do this, you must:

To set the -nodebuginfo compiler option for the project

  1. Open the project containing the application you want to debug.
  2. In the Application Explorer view, right-click on the project and choose Micro Focus > Project Settings > PL/I Compile Settings > Macro Preprocessor. The Macro Preprocessor page appears in the Properties Window.
  3. Select the Use Macro Preprocessor check box if it is not selected.
  4. In the No debug information (-nodebuginfo) field, select Yes from the Value list.
  5. Click OK to save your changes.
  6. Rebuild the project. This creates the output file used to debug the macro code.

To enable Macro preprocessor output for a project

Use this procedure to create the output file for the source file you want to debug. Preprocessor output files have a .pp file extension.

  1. Click the Pre-Processors tab.
  2. Under the Preprocessor (Macro) group, set the value for Macro preprocessor output to Yes.
  1. Open the solution containing the project you want to debug.
  2. In the Application Explorer view, right-click on the project and choose Micro Focus > Project Settings > PL/I Compile Settings > Macro Preprocessor. The Macro Preprocessor page appears in the Properties Window.
  3. Under Common macro preprocessor options > Additional options, enter -pp outputfile, where outputfile is a name you specify for the output file.

    If you do not specify an output file, the input filename is used. See the help topic Macro Preprocessor options for more information.

  4. Click OK to save your changes.
  5. Rebuild the project. This creates the output file used to debug the macro code.

Once an output file is created. Pressing F10 to debug step into the code debugs the preprocessor file. The CodeWatch debugging window shows the preprocessor file as the source being debugged. This output file contains the infused macro code.

For example, for a program file that contains a statement with macro calls:

    x = x + 1; x = x + 2;

    $PGMSG(ADD10);   
    $PGMSG(ADD20);

The output file includes the infused code for the macro calls.

    x = x + 1; x = x + 2;

      DO;
              /* Tracing Block for: ADD10 */
              put skip list (PreExecution: ADD10");
              call ADD10(x);
              put skip list (Complete: ADD10");
              put skip;
            END;
      DO;
              /* Tracing Block for: ADD20 */
              put skip list (PreExecution: ADD20");
              call ADD20(x);
              put skip list (Complete: ADD20");
              put skip;
            END;

You can step into this code and debug it as you would with any other code.