What is the best way to debug gnucobol on windows?
Only debugger I managed to get working was this one in VSCode https://github.com/OlegKunitsyn/gnucobol-debug , but the overall gnucobol support in VSCode seems a little lackluster so wanted to know if there is some other better debugging option?
Any detailed instructions / guide would be helpful
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
A general option outside of vscode is a program that is based on this very vscode extension (so also GDB via mi with internal parsing of the C files) - early testers are welcome: https://github.com/marcsosduma/cobgdb
In general I really like another GDB option which "just works everywhere GDB works" and is the very best option if you are already familiar with GDB: https://cobolworx.com/pages/cbl-gdb-kb/cbl-gdb-walkthrough.html
This consists of two parts - one is "cobcd" which uses GnuCOBOL to generate everything, then kicks in and adds an internal symbol table (as a big string) and removes all C line references, the other part is a GDB extension "cobcd.py" which reads this symbol table and works with GDB commands added.
It also comes with an optional vscode extension (but I personally found that not to provide what I've expected and that it worked better with "simple" programs - but I haven't used that for a while, so maybe that became better).
If you are from the future you likely want to check out SuperBOL studio - not ready when you are from the present.
Another option which works completely without GDB is the Gix Debugger, so far you'd need to install the Gix IDE to use that (works with GCC and MSVC binaries). I haven't checked that in depth but everything I've seen looked quite well.
And then there's of course the "batch programming technique" - add DISPLAYs / EXHIBIT at some places and inspect what's happening this way - but really: a good debugger like GDB is much better.
👍
1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
that promises to emulate the native debuggers of the most used compilers, for example ANIM by MICROFOCUS (and also RealDBUG by Realia COBOL which I have used a lot).
Below is a link that can demonstrate how ANIM by MICROFOCUS works. Very simple and essential to use.
@dilodilo I used ANIM as a template for my WINZOS debugger.
It is for Windows only. It is for conventional COBOL only (no free form).
Importantly it retains break points for subsequent debugging sessions.
My debugger is concerned with COBOL execution. Akin to Animator - it is COBOL centric
None of the Visual Studio / Eclipse / GDB clutter
Akin to MF, compile a program with "ANIM ON"
An Example below:
The .MP4 is a video depicting animating a program with multiple execution options.
Hi Ralph, your works are truly very impressive.
I ask you for clarification as it is not clear whether it is possible to animate and debug also programs that interact with the user.
When the program displays a screen and waits for an action from the user who can type a data or press a key or can use the mouse.
See at https://www.youtube.com/watch?v=nGgh26Vg_1s for a sample.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The IDE has a custom built GnuCOBOL source level debugger with hooks into libdwarf, and some nifty ESQL features along with templates for HTTP/REST API server building and other cool extras for GnuCOBOL developments.
Have good,
Blue
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have been using cbl-gdb and it is included in the binaries that i build and put in my drop box for distribution.
I have encountered some freezing issues with GDB itself on Windows 10, but all things considered cbl-gdb is a great addition to enable debugging of GNUCOBOL programs.
If you are interested check Arnold Tremley's website
and look for the section
"(UPDATED 2023-07-30) MSYS2 64-bit MinGW GnuCOBOL 3.2 for Windows"
These downloads are each about 96 megabytes. They both have the debugger support. If you don't already have 7-Zip for expanding them, that is also open-source software available from:
Hi all,
downloaded the version with the cbl-gdb.
It works with OpenCOBOLIDE.
But now what is the path to follow to use this debugger?
Where can I find the documentation to use it?
or better a step-by-step example of how to start and run a debug session of a GnuCOBOL program?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2023-09-18
In the cbl-gdb of 32-bit version does not display the variables. Or this version is not correct.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, could you please create an account on SourceForge and login with that account. It allows us help in a more timely manner in that the posts from Anonymous have to wait for a moderator to approve them, posts from a registered user are available immediately.
Are you using the 32 bit version posted above ? Can you post the output from the "cobcrun --info" command ?
did you compile your cobol program using "cobcd -x yourpgm.cbl" or something similar ?
also a screen shot of your gdb session where you are entering the "cp or cprint" command.
if we can't resolve it via this discussion, perhaps we could meet on Skype or JITSI or Google Meet so that we could do a screen sharing call to walk thru the issues you are encountering...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
C:\gnucobol32\bin>cobenv
Setup GnuCOBOL environment - MinGW
environment saved
environment set
C:\Users\user>cobcrun --info
libcob (GnuCOBOL) 3.1.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
License LGPLv3+: GNU LGPL version 3 or later http://gnu.org/licenses/lgpl.html
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart
Built Feb 04 2022 11:20:12
Packaged Dec 23 2020 12:04:58 UTC
build information
build environment : i686-w64-mingw32
CC : gcc
C version : (MinGW) "11.2.0"
CPPFLAGS : -D__USE_MINGW_ANSI_STDIO=1
-ID:/a/msys64/mingw32/include -I/mingw32/include
CFLAGS : -march=pentium4 -mtune=generic -O2 -pipe -pipe
-finline-functions -fsigned-char -Wall
-Wwrite-strings -Wmissing-prototypes
-Wno-format-y2k
LD : D:/a/msys64/mingw32/i686-w64-mingw32/bin/ld.exe
LDFLAGS : -pipe -Wl,--dynamicbase,--nxcompat,--no-seh
GnuCOBOL information
COB_MODULE_EXT : dll
dynamic loading : system
64bit-mode : no
BINARY-C-LONG : 4 bytes
endianness : little-endian
native EBCDIC : no
variable file format : 0
sequential file handler : built-in
indexed file handler : BDB, version 6.0.19
mathematical library : GMP, version 6.2.1
XML library : libxml2, version 2.9.12
JSON library : cJSON, version 1.7.15
extended screen I/O : ncursesw, version 6.3.20211021 (CHTYPE=32, WIDE=1)
mouse support : unknown
C:>cd users
C:\Users>cd user
C:\Users\user>cobcd -x SOH.cbl
SOH.cbl:18: warning: line not terminated by a newline [-Wothers]
C:\Users\user>gdb soh
GNU gdb (GDB) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "i686-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see: https://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at: http://www.gnu.org/software/gdb/documentation/.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from soh...
CloadWorker warning: entry in COB_LIBRARY_PATH skipped, is not a path: C:\gnucobol32\lib\gnucobol
Function "cob_accept" not defined.
Registering the CBL-GDB debugger [Version 4.28]. Help is available for
cprint cwatch cbreak ctbreak ccondition add-symbol-file-cobol cstart cnext
cup cup-silently cdown cdown-silently cfinish
finish-out-of-line-perform finish-module until-cobol list-section local-backtrace cbacktrace auto-step
(gdb) list 1,30
1 IDENTIFICATION DIVISION.
2 PROGRAM-ID. SOH.
3
4 DATA DIVISION.
5 WORKING-STORAGE SECTION.
6 77 HEADER PICTURE X(64) VALUE SPACE.
7 77 ONE PICTURE 9999 VALUE 0.
8 77 TWO PICTURE 9999 VALUE 0.
9 77 THREE PICTURE 9999 VALUE 0.
10
11 PROCEDURE DIVISION.
12 MOVE "Demonstration of addition" to HEADER.
13 DISPLAY HEADER.
14 MOVE 1 TO ONE.
15 MOVE 2 TO TWO.
16 ADD ONE TO TWO GIVING THREE.
17 DISPLAY ONE " plus " TWO " equals " THREE.
18 END PROGRAM SOH.
(gdb) break 15
Breakpoint 1 at 0x401736: file C:/Users/SOH.cbl, line 15.
(gdb) run
Starting program: C:\Users\user\soh.exe [New Thread 3476.0x3550] [New Thread 3476.0x43ec] [New Thread 3476.0x24f0]
Demonstration of addition
Thread 1 hit Breakpoint 1, SOH_ (entry=0) at C:/Users/SOH.cbl:15
15 MOVE 2 TO TWO.
(gdb) frame
0 SOH_ (entry=0) at C:/Users/SOH.cbl:15
15 MOVE 2 TO TWO.
(gdb) cprint ONE
77 ONE : 0001
(gdb) cprint TWO
77 TWO : 0000
(gdb)
77 TWO : 0000
(gdb) cprint TWO
77 TWO : 0000
(gdb) frame
0 SOH_ (entry=0) at C:/Users/SOH.cbl:15
15 MOVE 2 TO TWO.
(gdb) next
16 ADD ONE TO TWO GIVING THREE.
(gdb) cprint TWO
77 TWO : 0002
(gdb)
77 TWO : 0002
(gdb)
77 TWO : 0002
(gdb)
(gdb) exit
A debugging session is active.
Inferior 1 [process 3476] will be killed.
Quit anyway? (y or n) y
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
it looks like you have it working at least enough for a start...
it appears that you are using an old version of the gnucobol compiler, 3.1.2
I would advise you to get the most current release of gnucobol 3.2
C:\Users\user>cobcrun --info
libcob (GnuCOBOL) 3.1.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
License LGPLv3+: GNU LGPL version 3 or later http://gnu.org/licenses/lgpl.html
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart
Built Feb 04 2022 11:20:12
Packaged Dec 23 2020 12:04:58 UTC
the current version is 3.2 check the packaged date below on mine...
F:\AA-minGW32-static>cobcrun --info
libcob (GnuCOBOL) 3.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
License LGPLv3+: GNU LGPL version 3 or later https://gnu.org/licenses/lgpl.html
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart
Built Sep 16 2023 12:49:53
Packaged Jul 28 2023 16:58:47 UTC
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Also another good idea is to read up and possibly bookmark a couple of GDB documentation / help websites. This is one that I've used but there are many, GOOGLE search is your friend...
Big Dan the Blogging Man, has a number of posts about GNUCOBOL. The following is one about the COBOLWORX DEBUGGER for use with GNUCOBOL. I think that it is worth looking at.
the first step that I did was to determine where I wanted to put the .gdbinit file used for initialization of GDB. I chose to put it into the directory where I do almost all of my testing rather than in the same library as the GNUCOBOL runtime library. The reason for this is that I switch between different versions of GNUCOBOL for testing, so my testing directory is a more stable location.
the second step is to compile your GNUCOBOL programs with cobcd instead of cobc...
then start GDB from the windows command console...
if your program interacts with a console or window, then issue the command "set new-console on". This creates a new window in GDB which your program will access separately from the GDB windows.
next use the GDB "file" command to load your application program.
next use the "cstart" command to start your program.
I've just started using GDB, I find it both useful and a bit frustrating as steping into the GNUCOBOL runtime can be intimidating in that you are in the realm of C code. However for displaying COBOL variables the "cprint" command works pretty well.
If you run into issues, you can alway create a post on the discussion page here...
PS... Simon is very knowledgeable about cbl-gdb and gdb itself...
Chuck Haatvedt
👍
1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Considered to put the following into your gdbinit for or execute it when needed
skip-rfunccob_*
This will prevent to ever "step" into any GnuCOBOL internal realms.
If you interrupt your program or attach to a rubbing program you can always use the
cup 0
command to get to the most current COBOL frame.
Instead of the
file
command I'd suggest to start gdb by telling it what to use, which would be one of
gdbyourmaingdb-p1245#pidtoattachtogdb--argscobcrunyourprogoption1"option no. 2"#startingwithoptions,wouldthesameifyoudon't use cobcrun but main programs
then set a breakpoint where you want to
cbreak prob.cob:567
cbreak PROG # the name of the program-id with matching case
What is the best way to debug gnucobol on windows?
Only debugger I managed to get working was this one in VSCode https://github.com/OlegKunitsyn/gnucobol-debug , but the overall gnucobol support in VSCode seems a little lackluster so wanted to know if there is some other better debugging option?
Any detailed instructions / guide would be helpful
A general option outside of vscode is a program that is based on this very vscode extension (so also GDB via mi with internal parsing of the C files) - early testers are welcome: https://github.com/marcsosduma/cobgdb
In general I really like another GDB option which "just works everywhere GDB works" and is the very best option if you are already familiar with GDB: https://cobolworx.com/pages/cbl-gdb-kb/cbl-gdb-walkthrough.html
This consists of two parts - one is "cobcd" which uses GnuCOBOL to generate everything, then kicks in and adds an internal symbol table (as a big string) and removes all C line references, the other part is a GDB extension "cobcd.py" which reads this symbol table and works with GDB commands added.
It also comes with an optional vscode extension (but I personally found that not to provide what I've expected and that it worked better with "simple" programs - but I haven't used that for a while, so maybe that became better).
If you are from the future you likely want to check out SuperBOL studio - not ready when you are from the present.
Another option which works completely without GDB is the Gix Debugger, so far you'd need to install the Gix IDE to use that (works with GCC and MSVC binaries). I haven't checked that in depth but everything I've seen looked quite well.
And then there's of course the "batch programming technique" - add
DISPLAYs /EXHIBITat some places and inspect what's happening this way - but really: a good debugger like GDB is much better.Thanks, I will check these out!
I am enthusiastic about a debugger
https://github.com/marcsosduma/cobgdb
that promises to emulate the native debuggers of the most used compilers, for example ANIM by MICROFOCUS (and also RealDBUG by Realia COBOL which I have used a lot).
Below is a link that can demonstrate how ANIM by MICROFOCUS works. Very simple and essential to use.
https://www.youtube.com/watch?v=nGgh26Vg_1s
I would like to contribute to the testing but I don't know how to get in touch with the developer.
@dilodilo I used ANIM as a template for my WINZOS debugger.
It is for Windows only. It is for conventional COBOL only (no free form).
Importantly it retains break points for subsequent debugging sessions.
My debugger is concerned with COBOL execution. Akin to Animator - it is COBOL centric
None of the Visual Studio / Eclipse / GDB clutter
Akin to MF, compile a program with "ANIM ON"
An Example below:
The .MP4 is a video depicting animating a program with multiple execution options.
Ralph
Last edit: Ralph Linkletter 2023-09-17
Hi Ralph, your works are truly very impressive.
I ask you for clarification as it is not clear whether it is possible to animate and debug also programs that interact with the user.
When the program displays a screen and waits for an action from the user who can type a data or press a key or can use the mouse.
See at https://www.youtube.com/watch?v=nGgh26Vg_1s for a sample.
You might want to look at Gix-IDE by Marco Ridoni, Kunal.
https://github.com/mridoni/gix/
The IDE has a custom built GnuCOBOL source level debugger with hooks into libdwarf, and some nifty ESQL features along with templates for HTTP/REST API server building and other cool extras for GnuCOBOL developments.
Have good,
Blue
I have been using cbl-gdb and it is included in the binaries that i build and put in my drop box for distribution.
I have encountered some freezing issues with GDB itself on Windows 10, but all things considered cbl-gdb is a great addition to enable debugging of GNUCOBOL programs.
If you are interested check Arnold Tremley's website
and look for the section
"(UPDATED 2023-07-30) MSYS2 64-bit MinGW GnuCOBOL 3.2 for Windows"
https://www.arnoldtrembley.com/GnuCOBOL.htm
Chuck Haatvedt
Here are direct download links for that binary version of the compiler (built by Chuck Haatvedt), and also a 32-bit version:
https://www.arnoldtrembley.com/GC32M-BDB-x64.7z
https://www.arnoldtrembley.com/GC32M-BDB-x32.7z
These downloads are each about 96 megabytes. They both have the debugger support. If you don't already have 7-Zip for expanding them, that is also open-source software available from:
https://7-zip.org/
Hi all,
downloaded the version with the cbl-gdb.
It works with OpenCOBOLIDE.
But now what is the path to follow to use this debugger?
Where can I find the documentation to use it?
or better a step-by-step example of how to start and run a debug session of a GnuCOBOL program?
In the cbl-gdb of 32-bit version does not display the variables. Or this version is not correct.
Hello, could you please create an account on SourceForge and login with that account. It allows us help in a more timely manner in that the posts from Anonymous have to wait for a moderator to approve them, posts from a registered user are available immediately.
Are you using the 32 bit version posted above ? Can you post the output from the "cobcrun --info" command ?
did you compile your cobol program using "cobcd -x yourpgm.cbl" or something similar ?
also a screen shot of your gdb session where you are entering the "cp or cprint" command.
if we can't resolve it via this discussion, perhaps we could meet on Skype or JITSI or Google Meet so that we could do a screen sharing call to walk thru the issues you are encountering...
Thanks you for your reply.
Sorry. It seems to be Ok.
C:\Users\user>cd C:\gnucobol32\bin
C:\gnucobol32\bin>dir env
Datenträger in Laufwerk C: ist SYSTEM
Volumeseriennummer: 4444-CFE3
Verzeichnis von C:\gnucobol32\bin
03.06.2022 22:32 4’683 cobenv.cmd
03.06.2022 22:32 4’510 cobenv.sh
03.06.2022 22:32 121’972 envsubst.exe
3 Datei(en), 131’165 Bytes
0 Verzeichnis(se), 23’135’633’408 Bytes frei
C:\gnucobol32\bin>cobenv
Setup GnuCOBOL environment - MinGW
environment saved
environment set
C:\Users\user>cobcrun --info
libcob (GnuCOBOL) 3.1.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
License LGPLv3+: GNU LGPL version 3 or later http://gnu.org/licenses/lgpl.html
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart
Built Feb 04 2022 11:20:12
Packaged Dec 23 2020 12:04:58 UTC
build information
build environment : i686-w64-mingw32
CC : gcc
C version : (MinGW) "11.2.0"
CPPFLAGS : -D__USE_MINGW_ANSI_STDIO=1
-ID:/a/msys64/mingw32/include -I/mingw32/include
CFLAGS : -march=pentium4 -mtune=generic -O2 -pipe -pipe
-finline-functions -fsigned-char -Wall
-Wwrite-strings -Wmissing-prototypes
-Wno-format-y2k
LD : D:/a/msys64/mingw32/i686-w64-mingw32/bin/ld.exe
LDFLAGS : -pipe -Wl,--dynamicbase,--nxcompat,--no-seh
GnuCOBOL information
COB_MODULE_EXT : dll
dynamic loading : system
64bit-mode : no
BINARY-C-LONG : 4 bytes
endianness : little-endian
native EBCDIC : no
variable file format : 0
sequential file handler : built-in
indexed file handler : BDB, version 6.0.19
mathematical library : GMP, version 6.2.1
XML library : libxml2, version 2.9.12
JSON library : cJSON, version 1.7.15
extended screen I/O : ncursesw, version 6.3.20211021 (CHTYPE=32, WIDE=1)
mouse support : unknown
C:>cd users
C:\Users>cd user
C:\Users\user>cobcd -x SOH.cbl
SOH.cbl:18: warning: line not terminated by a newline [-Wothers]
C:\Users\user>gdb soh
GNU gdb (GDB) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "i686-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
https://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from soh...
CloadWorker warning: entry in COB_LIBRARY_PATH skipped, is not a path: C:\gnucobol32\lib\gnucobol
Function "cob_accept" not defined.
Registering the CBL-GDB debugger [Version 4.28]. Help is available for
cprint cwatch cbreak ctbreak ccondition add-symbol-file-cobol cstart cnext
cup cup-silently cdown cdown-silently cfinish
finish-out-of-line-perform finish-module until-cobol list-section local-backtrace cbacktrace auto-step
(gdb) list 1,30
1 IDENTIFICATION DIVISION.
2 PROGRAM-ID. SOH.
3
4 DATA DIVISION.
5 WORKING-STORAGE SECTION.
6 77 HEADER PICTURE X(64) VALUE SPACE.
7 77 ONE PICTURE 9999 VALUE 0.
8 77 TWO PICTURE 9999 VALUE 0.
9 77 THREE PICTURE 9999 VALUE 0.
10
11 PROCEDURE DIVISION.
12 MOVE "Demonstration of addition" to HEADER.
13 DISPLAY HEADER.
14 MOVE 1 TO ONE.
15 MOVE 2 TO TWO.
16 ADD ONE TO TWO GIVING THREE.
17 DISPLAY ONE " plus " TWO " equals " THREE.
18 END PROGRAM SOH.
(gdb) break 15
Breakpoint 1 at 0x401736: file C:/Users/SOH.cbl, line 15.
(gdb) run
Starting program: C:\Users\user\soh.exe
[New Thread 3476.0x3550]
[New Thread 3476.0x43ec]
[New Thread 3476.0x24f0]
Demonstration of addition
Thread 1 hit Breakpoint 1, SOH_ (entry=0) at C:/Users/SOH.cbl:15
15 MOVE 2 TO TWO.
(gdb) frame
0 SOH_ (entry=0) at C:/Users/SOH.cbl:15
15 MOVE 2 TO TWO.
(gdb) cprint ONE
77 ONE : 0001
(gdb) cprint TWO
77 TWO : 0000
(gdb)
77 TWO : 0000
(gdb) cprint TWO
77 TWO : 0000
(gdb) frame
0 SOH_ (entry=0) at C:/Users/SOH.cbl:15
15 MOVE 2 TO TWO.
(gdb) next
16 ADD ONE TO TWO GIVING THREE.
(gdb) cprint TWO
77 TWO : 0002
(gdb)
77 TWO : 0002
(gdb)
77 TWO : 0002
(gdb)
(gdb) exit
A debugging session is active.
Quit anyway? (y or n) y
beggy,
it looks like you have it working at least enough for a start...
it appears that you are using an old version of the gnucobol compiler, 3.1.2
I would advise you to get the most current release of gnucobol 3.2
the current version is 3.2 check the packaged date below on mine...
F:\AA-minGW32-static>cobcrun --info
libcob (GnuCOBOL) 3.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
License LGPLv3+: GNU LGPL version 3 or later https://gnu.org/licenses/lgpl.html
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart
Built Sep 16 2023 12:49:53
Packaged Jul 28 2023 16:58:47 UTC
Eugenio,
Before starting, visit the https://cobolworx.com/pages/resources.html website and read thru the documentation for cbl-gdb
Also another good idea is to read up and possibly bookmark a couple of GDB documentation / help websites. This is one that I've used but there are many, GOOGLE search is your friend...
https://www.tutorialspoint.com/gnu_debugger/gdb_quick_guide.htm
Big Dan the Blogging Man, has a number of posts about GNUCOBOL. The following is one about the COBOLWORX DEBUGGER for use with GNUCOBOL. I think that it is worth looking at.
https://bigdanzblog.wordpress.com/2020/09/03/cobolworx-gnucobol-and-debugger/
the first step that I did was to determine where I wanted to put the .gdbinit file used for initialization of GDB. I chose to put it into the directory where I do almost all of my testing rather than in the same library as the GNUCOBOL runtime library. The reason for this is that I switch between different versions of GNUCOBOL for testing, so my testing directory is a more stable location.
the second step is to compile your GNUCOBOL programs with cobcd instead of cobc...
then start GDB from the windows command console...
if your program interacts with a console or window, then issue the command "set new-console on". This creates a new window in GDB which your program will access separately from the GDB windows.
next use the GDB "file" command to load your application program.
next use the "cstart" command to start your program.
I've just started using GDB, I find it both useful and a bit frustrating as steping into the GNUCOBOL runtime can be intimidating in that you are in the realm of C code. However for displaying COBOL variables the "cprint" command works pretty well.
If you run into issues, you can alway create a post on the discussion page here...
PS... Simon is very knowledgeable about cbl-gdb and gdb itself...
Considered to put the following into your gdbinit for or execute it when needed
This will prevent to ever "step" into any GnuCOBOL internal realms.
If you interrupt your program or attach to a rubbing program you can always use the
command to get to the most current COBOL frame.
Instead of the
command I'd suggest to start gdb by telling it what to use, which would be one of
then set a breakpoint where you want to
then
Simon