I still love VIM but I’ve got use to using VSCode for doing my Fullstack development, so I figured I use VSCode integrated debugger on Linux. I mean GDB console or DDD is so old school, VSCode is so much better!!!
If you’re using Linux with the KDE Windows manager I have a workaround on how to get VSCode working with GDB below.
To get started with setting up VSCode with GDB, simply click on the “Debugger” ICON shown along the left (it may be on your right side).
Next click on the “Debug” button along the top, this will create a file called “launch.json” under your project folder.
Change the JSON property “program” to be the path to your executable.
In my case, I have something like this,
You can also variables, since I have a build folder under my project I could change the above to:
I just hard-coded the absolute path to the executable “bits” that I want to debug. Make sure to put the value in quotes.
If you’re using Gnome or have an Xterm installed you’re good to go! If however you’re like me using KDE, you will get an error message saying:
“Unable to start debugging. No terminal is available to launch the debugger. Please install Gnome Terminal or XTerm.”
This is a bug with VSCode as it’s looking for either Gnome terminal or Xterm, but on KDE it’s called konsole. Well we can’t wait around for Microsoft to fix the bug, we got to get stuff done yesterday!!!
The fix is easy, open up a terminal and type the following commands.
sudo ln -s ./konsole xterm
What we just did is create a symbolic link from xterm to konsole, this fools VSCode and keeps it happy.
Now hit the “Debug” button already and watch it work…..sweeet!!!!
You should see a terminal window popup and GDB running inside VSCode (remember to do a debug build and set your breakpoints).
Happy Debugging :D