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. In Visual Studio, open the solution containing the project you want to debug.
  2. Right-click the desired project in the Solution Explorer and choose Properties. The Properties window appears.
  3. Click the Compile tab.
  4. In the Other options field, enter -nodebuginfo.
  5. Click Save in the toolbar to save the updates to the project.

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.

Once an output file is created. Pressing F10 to step into the code debugs the preprocessor file. The debugger 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.