TAGS :Viewed: 20 - Published at: a few seconds ago

[ Logpoints in Debugger for Mainframe ]

Have you ever wanted to see a variable value while debugging a COBOL program without having to stop at a breakpoint? Then look no further than our Debugger for Mainframe Visual Studio Code extension, which supports logpoints. A logpoint is attached to a particular line of the code, like a breakpoint, and contains a message which is printed in the debug console when the debug session runs. Unlike a breakpoint, it does not break or stop the program. Logpoints can highlight an issue within a program while it is running, without causing the program to terminate. Let’s go through a specific example. We want to write a logpoint message that will display some text with the value of the variable TASKNUM, so every time the program flow goes through the line with this logpoint, the debugger will print the logpoint message in the debug console. How do we set up such a logpoint. First, find the variable (e.g. TASKNUM) and choose its line. In the gutter you select the line and a breakpoint will be created. Breakpoints have multiple options including logpoint — select the logpoint option and from here you define the message that the logpoint will display consisting of user-defined text with one or more variables. Any variable defined in the curly brackets ({}) will display its value at the state of the program when the message is written. It is important that the message syntax to determine which variables to display are in curly brackets, for example “{TASKNUM}”. Variables are case sensitive, so they need to be the same as defined in the COBOL program. We will use the message “tasknum = {TASKNUM}”, as in the gif below: After we define the log message, we trigger the debug session and observe the result: As you can see when the program goes through the line with the logpoint, it didn’t stop, but instead printed a log message in the console, where the variable in curly brackets was translated into its value at that given program state. In the line after the logpoint, the program stopped at an unconditional breakpoint, and we can confirm the value by looking at the left sidebar, under Variables and Locals, where TASKNUM is listed along with its value. Imagine you have a line in your code where a program goes frequently. To check the variable value every time, you can save time by using logpoints, as opposed to stopping there, finding the value and then resuming the program. Logpoints also allow you to print many variable values at the same time, to see the value of each variable, and to ensure that the values correspond to your expectations and have not been overwritten. And I’m sure you can think of many other ways to make full use of the new logpoints capability. Happy debugging! For more information on the visual studio code Debugger for Mainframe extension, visit Debugging Mainframe COBOL programs with VS Code. To add the extension to your VS Code desktop visit the VSC Marketplace and install the Debugger for Mainframe either as a separate extension or as part of the Code4z package (a complete mainframe developer solution). Stay in touch with us, join us on our Code4z Slack channel!