Debug FreeBASIC with VSCode

For other topics related to the FreeBASIC project or its community.
kankouhin7937
Posts: 31
Joined: Aug 16, 2018 2:00

Debug FreeBASIC with VSCode

Postby kankouhin7937 » Jan 22, 2021 5:06

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: 389
Joined: Jul 26, 2018 18:28

Re: Debug FreeBASIC with VSCode

Postby Xusinboy Bekchanov » Jan 22, 2021 6:06

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

Re: Debug FreeBASIC with VSCode

Postby Dinosaur » Jan 22, 2021 23:56

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: 389
Joined: Jul 26, 2018 18:28

Re: Debug FreeBASIC with VSCode

Postby Xusinboy Bekchanov » Jan 23, 2021 1:03

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: 2281
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Debug FreeBASIC with VSCode

Postby badidea » Jan 23, 2021 1:09

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: 389
Joined: Jul 26, 2018 18:28

Re: Debug FreeBASIC with VSCode

Postby Xusinboy Bekchanov » Jan 23, 2021 2:19

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: 1649
Joined: Feb 26, 2007 5:32

Re: Debug FreeBASIC with VSCode

Postby caseih » Jan 23, 2021 2:59

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: 1649
Joined: Feb 26, 2007 5:32

Re: Debug FreeBASIC with VSCode

Postby caseih » Jan 23, 2021 3:02

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

Postby kankouhin7937 » Jan 24, 2021 8:03

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: 389
Joined: Jul 26, 2018 18:28

Re: Debug FreeBASIC with VSCode

Postby Xusinboy Bekchanov » Jan 24, 2021 9:01

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

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 6 guests