Sitemap

Adding intellisense and remote gdb debugging in Visual studio Code

4 min readJun 4, 2025
Press enter or click to view image in full size
Happy coder, debugging.

Navigating the C/C++ source code and using the debugger in visual studio code is very useful and fairly easy to set up. As I constantly forget the details I wrote this article.

This example uses a qnx system but works just as well with i.e. gdbserver. In qnx we use, pdebug whichs is similar to gdbserver.

You must also install this extension: ms-vscode.cpptools

If you use cmake to build your application, you can add this when configuring the project

-DCMAKE_EXPORT_COMPILE_COMMANDS=ON

This will create compile_commands.json. You should then create something similar to this in .vscode/c_cpp_properties.json

 .vscode/c_cpp_properties.json
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++14",
"intelliSenseMode": "linux-clang-x64",
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
}
],
"version": 4
}

Now you should see {} in the status bar.

Intellisense working

After this you should be able to navigate your sourcecode with ctrl-click and goto definitio in context menu. To find the location of the database files do:

Check the C/C++ Extension Diagnostics

  • Open the Command Palette (Ctrl+Shift+P), run C/C++: Log Diagnostics, and look for the “IntelliSense cache path or database path” entry.

My configuration Current database path: /home/olof/.cache/vscode-cpptools/a45f1befxcef65893c8fcad2604d75/.browse.VC.db

Setting up the debugger

On the target you might have to turn of the firewall.

pfctl -d

Then, we will first see if we can connect with the command line,

qnx> pdebug 8100

Make sure we are listening,

qnx> netstat | grep 8100
tcp 0 0 *.8100 *.* LISTEN

# ~/qnx700/host/linux/x86_64/usr/bin/ntoaarch64-gdb app-to-debug
(gdb) target qnx 192.168.1.1:8100

Note that normally (no qnx) you would use # target remote192.168.3.1:8100

Remote debugging using 192.168.1.1:8100
Remote target is little-endian

That worked just fine.

Upload and run app on target

Here are some useful qnx specific comands:

(gdb) upload client_1600_1296 /root/app-to-debug
(gdb) set nto-executable /root/app-to-debug
(gdb) set args -arg 1

I normally do not setup the debugger to run in the visual studio code IDE. But something like this could work.

{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ gdbserver: Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/test-app",
"args": [
"-arg",
"1"
],
"cwd": "${workspaceFolder}",
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/home/olof/qnx700/host/linux/x86_64/usr/bin/ntoaarch64-gdb",
"miDebuggerServerAddress": "192.168.1.1:8100",
"miDebuggerArgs": "",
"setupCommands": [
{ "description": "Enable pretty-printing", "text": "-enable-pretty-printing", "ignoreFailures": true }
]
}
]
}
Add configuration

Yoy can also try this button to add configuration.

This configuration should work for a normal gdbserver however we will try the qnx toolkit. Note that this works best with QNX 8.0 or later

Press enter or click to view image in full size
qnx toolkit

Now we can use this instead,

{
"version": "2.0.0",
"configurations": [
{
"type": "qnx-gdb",
"request": "launch",
"name": "qnx launch",
"gdb": "gdb",
"program": "${workspaceFolder}/build/test-app",
"remotePath": "${workspaceFolderBasename}",
"qnxtarget": "default",
"upload": true,
"preLaunchTask": "${defaultBuildTask}"
},
{
"type": "qnx-gdb",
"request": "attach",
"name": "qnx attach",
"gdb": "gdb",
"program": "${command:qnx.autodetectBinary}",
"remotePath": "${workspaceFolderBasename}",
"qnxtarget": "default"
}
]
}

As I was not using qnx 8.0 , I did not get this to work.

Using gdbserver

Normally you will not QNX, but this will work for any linux system. Here we use on an arm based system.

On the target,

./gdbserver :1234 ./TestProgram 

This config works,

 {
"version": "0.2.0",
"configurations": [

{
"name": "C/C++ gdbserver: Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/TestProgram",
"args": [
"-arg",
"1"
],
"cwd": "${workspaceFolder}",
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb-multiarch",
"miDebuggerServerAddress": "192.168.1.42:1234",
"stopAtEntry": true,
"miDebuggerArgs": "",
"setupCommands": [
{ "description": "Enable pretty-printing", "text": "-enable-pretty-printing", "ignoreFailures": true }
]
]
}

This can improve your debugging experience and gives you something similar to this.

Running gdb in the IDE

--

--

No responses yet