Development and Pipeline

Development and Pipeline

Development and Pipeline

Connecting mainframe application developers to discuss efficiently creating and maintaining z/OS applications

 View Only

Debugging a Go program with z/OS Debugger

By Violaine Batthish posted Wed November 03, 2021 04:56 PM

  
z/OS Debugger 15.0.3 now supports debugging Go programs on z/OS compiled with IBM Open Enterprise SDK for Go 1.16To enjoy this feature, you must ensure that you have updated the z/OS Debugger SVC to the 15.0.3 version, or you will see the following message:


Getting Started

To run our Go on z/OS program, I'll use a z/OS Unix shell, and define some environment variables before starting:
  1. From the Remote Systems view, right-click on the z/OS Unix shells item for the desired connection, and on the pop-up menu, select Launch Shell:
  2. Once the shell opens, enter the following commands:
    • export GOMAXPROCS=1   This forces the Go on z/OS program to run in a single thread.  This is a limitation of z/OS Debugger for this release.
    • export _CEE_RUNOPTS='TEST(ERROR,VADSCP1047,,DBMDT:*)' This is the Language Environment (LE) runtime options.  Its more complicated than the previous variable, so lets unpack it:
      • TEST(ERROR,VADSCP1047,,DBMDT:*)  This is the TEST runtime option that controls the behaviour of the debugger and tells the debugger that it needs to be triggered.
        • ERROR Specifies that only the following conditions cause the debugger to gain control without a user-defined breakpoint:
          • An attention interrupt
          • Program termination
          • A predefined Language Environment condition of Severity 2 or above
        • VADSCP1047 is needed so that the debugger displays square brackets properly in the Variables view and with hovers.
        • DBMDT tells the debugger to route the debug session to the current user via RSE (this option requires that the user be signed in via RSE).  Alternately, you can use the TCIPIP option.
          For more details, see Syntax of the TEST runtime option
  3. Now all that's left is to call my Go on z/OS program:
    After a moment or two, the debug session should start.

Working with the debug session

When the debug session begins, the Go runtime is in the stack in the Debug view, and the source appears:

(that's because the Go runtime is debuggable!)

In order to debug what I am most interested in, I'll begin by creating an entry breakpoint for my program:
  1. From the Breakpoints view, right-click and select Add Breakpoint>Entry...
  2. In the Entry Breakpoint wizard, I select main for the Object, and select main.main for Function or Entry Point:
  3. I then click Finish and the breakpoint is added.

I then hit the Resume button and wait until the debugger stops.  I can now see the call stack with my program in it:

And I can see my program source, I can go and add a breakpoint at a more interesting place by double clicking on the line I want:


I can now use the step buttons:


but instead I will resume again.  Now when the debugger stops, I can click on the Variables view to view the local variables, and expand them as needed:


And I can hover in the editor over any desired variable:


And even change the value.  To change the value in the variables view, I just click on the value column, type a new value, and press Enter.  The variables are then refreshed:

Once I am done with my debug session, I can either resume (and run to completion) or I can terminate the debug session via the terminate button.
For more information, see Debugging programs compiled with IBM Open Enterprise SDK for Go.

Happy Debugging!

0 comments
40 views

Permalink