Debug FreeBASIC with VSCode

General discussion for topics related to the FreeBASIC project or its community.
Post Reply
kankouhin7937
Posts: 31
Joined: Aug 16, 2018 2:00

Debug FreeBASIC with VSCode

Post by kankouhin7937 »

Debug FreeBASIC with VSCode by C/C++ Extension.

Tested with:
FreeBASIC: 1.07.3-win64
MinGW-w64: x86_64-8.1.0-posix-seh-rt_v6-rev0 (GDB only)

tasks.json

Code: Select all

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "FreeBASIC Build",
            "type": "shell",
            "command": "fbc",
            "args": [
                "-g",
                "${fileBasenameNoExtension}.bas"
            ],
            "problemMatcher": [],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}
launch.json

Code: Select all

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "KayaBASIC Run",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/gdb.exe",
            "setupCommands": [
                {
                    "description": "gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "FreeBASIC Build"
        }
    ]
}
Last edited by kankouhin7937 on Jan 22, 2021 8:14, edited 2 times in total.
Xusinboy Bekchanov
Posts: 789
Joined: Jul 26, 2018 18:28

Re: Debug FreeBASIC with VSCode

Post by Xusinboy Bekchanov »

Very good news, now we can do debugging in Linux too.
Thank you for that.
Dinosaur
Posts: 1481
Joined: Jul 24, 2005 1:13
Location: Hervey Bay (.au)

Re: Debug FreeBASIC with VSCode

Post by Dinosaur »

Hi All
now we can do debugging in Linux too
I have been debugging in Linux for a few years now using Gede Debugger (GDB Frontend)
Done so on various Industrial CPU boards and lately on the Beagelbone Black. Both in Linux Mint and Debian 10.
The only original problem with Freebasic was the single comment char ' which when replaced with a double ' ' (not a ") solved the problem.
Some issues with single stepping external functions but I don't debug these, so simply put breakpoints after these statements.

Regards
Xusinboy Bekchanov
Posts: 789
Joined: Jul 26, 2018 18:28

Re: Debug FreeBASIC with VSCode

Post by Xusinboy Bekchanov »

Dinosaur wrote:Hi All
now we can do debugging in Linux too
I have been debugging in Linux for a few years now using Gede Debugger (GDB Frontend)
Done so on various Industrial CPU boards and lately on the Beagelbone Black. Both in Linux Mint and Debian 10.
The only original problem with Freebasic was the single comment char ' which when replaced with a double ' ' (not a ") solved the problem.
Some issues with single stepping external functions but I don't debug these, so simply put breakpoints after these statements.

Regards
I also do debugging in Linux, only in console mode.
badidea
Posts: 2591
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Debug FreeBASIC with VSCode

Post by badidea »

Would would have thought years ago that today you can write BASIC code using an IDE form Microsoft on Linux?
And there is Microsoft Teams for Linux and their Edge browser for Linux. No wine involved, just .deb files from Microsoft.
Xusinboy Bekchanov
Posts: 789
Joined: Jul 26, 2018 18:28

Re: Debug FreeBASIC with VSCode

Post by Xusinboy Bekchanov »

Dinosaur wrote:Hi All
now we can do debugging in Linux too
I have been debugging in Linux for a few years now using Gede Debugger (GDB Frontend)
Done so on various Industrial CPU boards and lately on the Beagelbone Black. Both in Linux Mint and Debian 10.
The only original problem with Freebasic was the single comment char ' which when replaced with a double ' ' (not a ") solved the problem.
Some issues with single stepping external functions but I don't debug these, so simply put breakpoints after these statements.

Regards
Thanks for gede too.
But for some reason, VSCode and Gede instead of variables shows TMP$2020-2109 and vr$47-48 (in Linux).
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: Debug FreeBASIC with VSCode

Post by caseih »

badidea wrote:Would would have thought years ago that today you can write BASIC code using an IDE form Microsoft on Linux?
And there is Microsoft Teams for Linux and their Edge browser for Linux. No wine involved, just .deb files from Microsoft.
Interesting times indeed. Even it the whole works is built from Javascript and running in a dedicated version of Google Chrome! Still not sure how I feel about that.
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: Debug FreeBASIC with VSCode

Post by caseih »

Xusinboy Bekchanov wrote:Thanks for gede too.
But for some reason, VSCode and Gede instead of variables shows TMP$2020-2109 and vr$47-48 (in Linux).
That's because all the FB variables get converted to mangled C variables. The debugger is only able to see the manged names. The original FB names don't make it pass the compiler. I'm not aware of any way to help gdb to convert the names to their original, unmangled forms.
kankouhin7937
Posts: 31
Joined: Aug 16, 2018 2:00

Re: Debug FreeBASIC with VSCode

Post by kankouhin7937 »

Xusinboy Bekchanov wrote:
Dinosaur wrote:Hi All
now we can do debugging in Linux too
I have been debugging in Linux for a few years now using Gede Debugger (GDB Frontend)
Done so on various Industrial CPU boards and lately on the Beagelbone Black. Both in Linux Mint and Debian 10.
The only original problem with Freebasic was the single comment char ' which when replaced with a double ' ' (not a ") solved the problem.
Some issues with single stepping external functions but I don't debug these, so simply put breakpoints after these statements.

Regards
Thanks for gede too.
But for some reason, VSCode and Gede instead of variables shows TMP$2020-2109 and vr$47-48 (in Linux).
compile bas file with -R option will genterate *.c file, you can known the reason.
Xusinboy Bekchanov
Posts: 789
Joined: Jul 26, 2018 18:28

Re: Debug FreeBASIC with VSCode

Post by Xusinboy Bekchanov »

kankouhin7937 wrote:compile bas file with -R option will genterate *.c file, you can known the reason.
I looked at the С code, it turns out that TMP and VR are other auxiliary variables. My created variables with Dim shows normally.
And thanks to References -> Settings -> Features -> Allow Breakpoints Everywhere
Post Reply