Camelian Systems COBOL debugger
This extension provides source-level debugging of COBOL programs compiled with the GnuCOBOL COBOL compiler.
June 12, 2020
Bob Dubner
rdubner@symas.com
Basic methodology
COBOL source code is compiled with the GnuCOBOL compiler. Debugging information and a gdb extension are added to the executable by the Camelian cbl-gdb routines. The resulting executable can be debugged directly by the Gnu gdb debugger. That executable can also be debugged on the source-code level with this extension, which provides a VSC Debug Adapter that is aware of the Camelian extensions to gdb that makes source-level debugging possible.
Prerequisites - GnuCOBOL
In order to debug a COBOL program, it must first be compiled with an appropriate version of the GnuCOBOL compiler. The compiler must be the 3.1 version, which has not, at this writing, been formally released.
GnuCOBOL-3.1-dev installation packages for Ubuntu, RedHat, and Windows can be found at Camelian Systems downloads.
Those who prefer to build from source can find GnuCOBOL source code at the SVN repository https://svn.code.sf.net/p/open-cobol/code/branches/gnucobol-3.x The build sequence starts with ./autogen.sh
A more build-ready tarball, with certain system-independent elements pre-built with known-good tools, can be downloaded from here. The build sequence starts with ./configure
.
More information can be found at https://sourceforge.net/projects/open-cobol/
Prerequisites - Camelian cbl-gdb debugging extensions
As part of the compilation process, the cbl-gdb extensions need to be applied before the executable can be debugged using gdb and VSC.
Download and install the appropriate Camelian GnuCOBOL Debugging Extensions package
from Camelian Systems downloads.
Installation
If you didn't install this extension from Microsoft's repositories, then you probably downloaded a file named cbl-gdb-2.1.2.vsix, which is a Visual Studio Code extension package. You have a couple of options for loading the extension into VS code:
-
From inside Visual Studio Code, use the Command Palette
(Ctrl+Shift+P)
to find "Extensions: Load extension from VSIX..." Select that, and point it at the .VSIX file. -
From the command line, execute
code --install-extension cbl-gdb-2.1.2.vsix
Additional extensions
There are a number of COBOL formatting extensions available at Microsoft's Extension Marketplace. We've found that Enterprise COBOL for z/OS
seems to coexist with our Debugging Adapter, and does a reasonable job of formatting the COBOL source code.
Additional configuration of Visual Studio Code.
Use the Command Palette (Ctrl+Shift+P)
To search for Settings
, or navigate to File > Preferences > Settings
from the menu. Select the User
tab, and then User > Features > Debug
. Activate the Allow Breakpoints Anywhere
option.
Getting Started / Troubleshooting Guide
Were you to contact me for help getting this package running on your system, I would go through this series of steps to convince myself all the pieces were working correctly.
Create a simple test program
Create an empty directory; I'm naming it ctest
.
Create a text file CTEST.CBL
000001 IDENTIFICATION DIVISION.
000002 PROGRAM-ID. CTEST.
000003 DATA DIVISION.
000004 WORKING-STORAGE SECTION.
000005 01 D123 PIC 999 VALUE 123.
000006 PROCEDURE DIVISION.
000007 DISPLAY "Simple".
000008 DISPLAY "as".
000009 DISPLAY "one".
000010 DISPLAY "two".
000011 DISPLAY "three".
000012 DISPLAY D123.
000013 GOBACK.
000014 END PROGRAM CTEST.
Verify that GnuCOBOL is the right version:
The shell command cobc --version | head -n 1
should return
cobc (GnuCOBOL) 3.1-dev.0