OlegKunitsyn/gnucobol-debug

[HELP] Debugging program

Reultor opened this issue · 20 comments

Hi,

I'm trying to debug a program in local with VSCode but i have an error message...

launch.json :

image

Error message :

image

Can you please give me any suggestions?

Best regards

Note gccpath don't work with a real path, i already try with a real one

There is no gccpath configuration in this extension, only gdbpath and cobcpath. You should be able to see that with the intellisense and also directly in https://github.com/OlegKunitsyn/gnucobol-debug/blob/master/package.json.

GnuCOBOL itself uses COB_CC, so you could try to set it to the full path name of gcc.

The possibly much easier solution is to create a cobc.cmd, place it in the bin folder of yours and use its full name as cobcpath; which would look like the following:

@echo off
set mypath=%~dp0
%mypath%\cobenv.cmd
cobc.exe %*

This also has then benefit that you can drop every env entry above.
Side note: I highly suggest to use .exe (or .cmd) in gdbpath and cobcpath.

Thx for the reply.

I try to change launch.json like that :

image

and still not working :

image

I have this strange message when i try run it in cmd :

image

If i use a .cmd with gdbpath, cobcpath and COB_CC, it's working :

image

But if i open a different cmd and try to display it doesn't :

image

So i don't think VSCode will be able to get my env variable

The point is: create a cobc.cmd with the content as noted above and use this as cobcpath in your launch config - I see no reason that this won't work.

Oh i see !

I think it work better now but still an error :

beginning
image

ending
image

launch.json :

image

cobenv.cmd :

image

My folder :

image

I don't want to offend you, but can you please stop posting images where text works? Text is much better, just select it then context menu "copy" then paste it here after pressing the code tag <> (or [ctrl]+[e], or manually "fancing" it).
And I can skim through text easily without opening a browser and people can actually find it, and I can easily suggest a better configuration without typing all from your screen...

This aside: the content of cobc.cmd is not what I've suggested, see above.
Additional you'd have gdbpath setup in your launch config and the target takes the executable (so full path to the .exe)

I don't want to offend you, but can you please stop posting images where text works? Text is much better, just select it then context menu "copy" then paste it here after pressing the code tag <> (or [ctrl]+[e], or manually "fancing" it). And I can skim through text easily without opening a browser and people can actually find it, and I can easily suggest a better configuration without typing all from your screen...

Oh yes sorry, first time i try post here.

launch.json :

{ "version": "0.2.0", "configurations": [ { "name": "COBOL debugger launch", "type": "gdb", "request": "launch", "cobcargs": ["-x"], "cobcpath": "D:/gnucobol-3.2-dev-MinGW-binaries/bin/cobc.cmd", "cwd":"D:/testCobol", "target": "D:/testCobol/essai.cbl", "verbose": true, } ], "inputs": [ { "id": "pid", "type": "promptString", "description": "PID to attach" } ] }

cobc.cmd :

@echo off set mypath=%~dp0 %mypath%\cobenv.cmd echo %* cobc.exe %* exit

cobenv.cmd :

@echo OFF SET COB_CC=D:\gnucobol-3.2-dev-MinGW-binaries\bin\gcc.exe SET gdbpath=D:\gnucobol-3.2-dev-MinGW-binaries\bin\gdb.exe SET cobcpath=D:\gnucobol-3.2-dev-MinGW-binaries\bin\cobc.exe exit

Is that what you was thinking of ?

Still same error :

stdin: 1-gdb-set target-async on stdin: 2-gdb-set print repeats 1000 stdin: 3-gdb-set args stdin: 4-environment-directory "D:\\testCobol" stdin: 5-file-exec-and-symbols "D:\\testCobol\\essai.exe" Could not start debugger process Error: spawn gdb ENOENT stdin: 6-gdb-exit

Is that what you was thinking of ?

Nearly - there is a cobenv.cmd in the MSYS2 distribution, you can just use that. If you have the distribution but strangely not that command file you can get it from https://raw.githubusercontent.com/msys2/MINGW-packages/master/mingw-w64-gnucobol/cobenv.cmd .

As said above the target attribute in your launch.json should (at least according to the docs) be "target": "D:/testCobol/essai.exe", otherwise GDB won't find that (but strangely it does, so the documentation may be wrong).

Just for information, i'm not admin on my computer.
So i can't install or download what i want...

I used this link to download direct binaries of gnucobol :

https://sourceforge.net/projects/gnucobol/files/gnucobol/nightly_snapshots/

ready-to-use-binaries for Win32
Includes GCC 9.2.0, GMP 6.1.2, Berkeley DB 4.5.20, cJSON 1.7.13, PDCurses for Win32 4.2.0 with mouse support.

MinGW ready-to-use-binaries gnucobol-3.2-dev

I change my cobenv by the one you link me and the target in launch.json

But still same error

Ah, when using this one just call set_env.cmd instead of cobenv.cmd.

If this does not work then:

  • close all vscode instances
  • double click set_env.cmd (will start a command prompt window)
  • start vscode from this command prompt window
  • open your workspace/file/... as before
  • change launch.json removing any cobcpath and gdbpath options
  • run debug

This way the extension just finds cobc.exe, gdb.exe and everything is setup up-front.

Oh nice, didn't see this one, i try :

close all vscode instances
double click set_env.cmd (will start a command prompt window)
start vscode from this command prompt window
open your workspace/file/... as before
change launch.json removing any cobcpath and gdbpath options
run debug

First try with :

"target": "D:/testCobol/essai.exe",

but have way to much error, see WithExe.txt

second try with :

"target": "D:/testCobol/essai.cbl",

look better, see WithCbl.txt

but nothing happen in vscode

The second one says "everything passed fine" (so both the doc of the target attribute is wrong and the behavior is different from every other debugging extension...).
You'd likely want to set a breakpoint (either click in the gutter when in debug view or add with clicking on the "+" in the breakpoint window before starting the debug session, it is just over too fast for you to recognize :-)

My breackpoint is set but still nothing happen :

image

Hm, is this breakpoint in your debug console mentioned?
The WithCbl.txt has only

GDB -> App: {"token":5,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
clearBreakPoints
stdin: 6-break-delete
stdout: 6^done
(gdb)
GDB -> App: {"token":6,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
addBreakPoint
stdin: 7-exec-run
stdout: =thread-group-started,id="i1",pid="23156"

If this is still the case then there's a bug in this extension and because there are no auto commands or similar in this would leave you only with one workaround:
add CONTINUE AFTER 10 SECONDS to the program start, then start the debugging session and while the program sleeps press "pause" (if this doesn't work, then try to set the breakpoint then) - or use an "attach" configuration.

Hm, is this breakpoint in your debug console mentioned?
The WithCbl.txt has only

I don't know i see the same think as you :

GDB -> App: {"token":4,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["source-path","D:\\testCobol;$cdir;$cwd"]]}} stdout: 5^done (gdb) GDB -> App: {"token":5,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}} clearBreakPoints stdin: 6-break-delete stdout: 6^done (gdb) GDB -> App: {"token":6,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}} addBreakPoint stdin: 7-exec-run

add CONTINUE AFTER 10 SECONDS to the program start, then start the debugging session and while the program sleeps press "pause" (if this doesn't work, then try to set the breakpoint then) - or use an "attach" configuration.

I change my program like that :

PROCEDURE DIVISION. * * -------------> NIVEAU 001 * *<debut_procedure\> SKLT ENTREE-PROGRAMME. CONTINUE AFTER 10 SECONDS PERFORM DEBUT-PROGRAMME PERFORM TRAITEMENTS .

Run the debug session, i see the program sleeping but i can't stop it, i try the key PAUSE and F6 on my keyboard but nothing happen.

I'm a beginner with VS Code, i don't know how to add "attach" configuration

Run the debug session, i see the program sleeping but i can't stop it, i try the key PAUSE and F6 on my keyboard but nothing happen.

then that's an error in the extension. Can you please open a separate issue for that posting your launch.json and debug console output while doing so?

... as the experience above was not that good and the attach configuration looks weird (has target executable, which likely is a source file again, and also executable arguments, which are irrelevant for attach and has the whole cobc setup) we may should declare "doesn't works that well with Win32 on the same computer" and wait for @OlegKunitsyn to kick in and fix this.
You may have more success with using a similar setup but with the docker option (that seems to work quite well given some posts here)... or switch to another extension which should work much better (I could point out more details if you want to go that route).

In any case: please create the issue for "pausing execution does not work".

You may have more success with using a similar setup but with the docker option (that seems to work quite well given some posts here)... or switch to another extension which should work much better (I could point out more details if you want to go that route).

Yeah but i'm already border line with this experimenting, i don't think i can create Docker on my computer without trigger my policy compagny ^^'

What at the over extension you have in mind ?
My goal is to use gnucobol + VSCode extension for debug COBOL program without mainframe environnement

What at the over extension you have in mind ?

https://cobolworx.com/pages/windows.html and https://cobolworx.com/pages/vsix.html - sadly the downloads are currently down, which I'll report to the site owner, so here are necessary parts and steps to use them:

  • either get a newer python-enabled gdb or a complete new package from https://www.arnoldtrembley.com/GC312-BDB-M64-rename-7z-to-exe.7z (can be extracted using 7zip, otherwise you'd need to rename it to .exe and double click on it)
  • disable or uninstall this extension
  • install extension cbl-gdb-4.2.3.zip
  • add to your installation in the bin folder: cobcd-mingw64.zip (this one has the cobenv.cmd)
  • compile in vscode from your terminal using cobcd -x essai.cbl
  • delete launch.json
  • start debugging creating a new launch configuration from the cbl-gdb template

If you have questions on this other extension then this page is the wrong to discuss it, but you may want to use stackoverflow or https://sourceforge.net/p/gnucobol/discussion/help/

Ok thx for all ! :)

I will try this, when i can.

I close this issue.