This is a native VS Code debugger for FreeBASIC.
Press F5 on a .bas file, the extension builds it with fbc -g,
then starts the program under the available native debugger for your platform.
The goal is simple: make FreeBASIC feel like a normal Run and Debug language in
VS Code instead of a language that needs manual task wiring every time.
- Registers a
freebasic-gdbdebugger type. - Builds the active
.basfile withfbcby default. - Lets you override the compiler path when a platform-specific launcher such as
fbc.exe,fbc64,fbc32,fbc64.exe, orfbc32.exeis preferred. - Launches the resulting program with GDB by default, with a run-only fallback when GDB is missing or unusable.
- Exposes breakpoints, continue, pause, stepping, stack frames, locals, and expression evaluation through the Debug Adapter Protocol.
- Parses FreeBASIC compile errors into the Problems panel before debugger launch.
- Writes compiler and debugger status details to the
FreeBASIC Debuggeroutput channel.
- Windows, Linux, and macOS all use GDB for full debugger features.
- If GDB is missing, or if macOS blocks an unsigned GDB through
taskgated, the extension still launches the program in a reduced run-only session without debugger features. - The extension assumes
fbcandgdbare available onPATH. - On Windows, compiler discovery prefers
fbc.exefirst, then falls back tofbc64.exe/fbc32.exewhen needed. - On Windows, the generated output name ends in
.exe. - On Windows, console programs default to an external console window because that is the most reliable way to let a GDB-launched console program interact normally.
- On Linux and macOS, the generated output name has no
.exesuffix. - On Linux and macOS, console programs default to the integrated terminal so the debuggee gets a real TTY.
- If your setup uses a non-default compiler or debugger location, set
compilerPathandgdbPathinlaunch.json.
When you press F5, the extension uses this order:
- A usable
gdb - A run-only session if GDB is missing
- On macOS, a run-only session if
gdbexists but the OS blocks it because it is unsigned
The fallback still compiles and launches your program, but debugging features such as breakpoints, stepping, pause, stack inspection, and watches will be unavailable for that session.
The debugger looks for GDB in this order:
- A bundled debugger inside
tools/gdb - Common platform-specific install paths
- Plain
gdbonPATH
On Windows, the built-in search includes common locations such as:
C:\freebasic\gdb.exeC:\freebasic\bin\gdb.exeC:\msys64\mingw64\bin\gdb.exeC:\msys64\ucrt64\bin\gdb.exeC:\mingw64\bin\gdb.exeC:\w64devkit\bin\gdb.exe
In the common Windows setups, that means you usually do not have to set
gdbPath by hand even if GDB did not ship with FreeBASIC itself.
If we later bundle GDB with the extension, placing it in tools/gdb is enough
for the resolver to prefer it automatically.
- Open a folder containing a FreeBASIC source file in VS Code.
- Press
F5while a.basfile is active. - Choose
FreeBASIC GDBif VS Code asks which debugger to use.
If you want a persistent configuration, create .vscode/launch.json with:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Current FreeBASIC File",
"type": "freebasic-gdb",
"request": "launch",
"sourceFile": "${file}",
"cwd": "${fileDirname}",
"arch": "auto",
"compilerPath": "fbc",
"gdbPath": "gdb",
"compilerArgs": [],
"args": [],
"stopAtEntry": false
}
]
}If program is omitted, the extension derives it from the source file name and
uses the correct platform suffix automatically.
.bi include files are still valid places to set breakpoints when they are used
by the running program, but they are not sensible launch targets on their own.
- It is not a language server.
- It is not a project system.
- It is not trying to replace the mature C/C++ debugging extensions feature for feature.
The job here is narrower: compile the current FreeBASIC file, launch it, show breakpoints, stack frames, locals, watches, and compile errors, and make that workflow feel dependable.
For the common cases you can stay out of launch.json entirely and just set
these in normal VS Code settings:
freebasic.debugger.compilerPathfreebasic.debugger.gdbPathfreebasic.debugger.archfreebasic.debugger.compilerArgsfreebasic.debugger.programArgsfreebasic.debugger.consolefreebasic.debugger.stopAtEntry
- The adapter is intentionally lightweight and currently assumes a single debugged thread in the UI.
- Build and launch now happen after VS Code has finished substituting variables
such as
${file}and${fileDirname}fromlaunch.json. - Complex variable expansion depends on what GDB reports through MI and may be less complete than the mature C/C++ debugger extensions.
- If
fbcorgdbare not onPATH, pointcompilerPathandgdbPathat the exact executables. - If FreeBASIC is missing, the extension stops and explains how to point
compilerPathat a real compiler. - If GDB is missing or unusable, the extension still builds and launches with
F5, but it warns that the session is running without debugger features. - On macOS, the best experience is still a properly codesigned GDB.