0

I am trying to create a project to program a Tiva C Series board using VS Code and CMake.

So far, I've managed to make it kinda work, since it builds, flashes and even lets me debug it. However, it was based on sketchy launch.json and tasks.json files and I was not happy with it. So now I'm trying to make it work properly with the CMakeTools extension in a way that I can start the debugger through the button on the bottom navbar provided by the extension. The problem is that it does not seem to use my launch.json file, so when it launches it uses the wrong debugger path and executable (which were properly pointed by the launch.json file).

My project currently look like this: my project structure.

It basically consists of a src folder containing my source code, a CMakeLists.txt file, a cmake folder containing the toolchain configuration, a linker file for the Tiva, a .vscode folder containing the launch.json and tasks.json files and the build output directory generated by CMake.

As of right now, if I click on the build command on the CMakeTools extension navbar it builds correctly and flashes to the Tiva using a custom target command in my CMake. But when I click on the debug button it does not launch properly, instead it gives me this output.

This is my launch.json file:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debugger Tiva",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/build/projeto.axf",
            "targetArchitecture": "ARM",
            "args": [],
            "stopAtEntry": true,    
            "cwd": "${workspaceFolder}",
            "environment": [],
            "MIMode": "gdb",
            "miDebuggerServerAddress": "localhost:3333",
            "externalConsole": false,
            "miDebuggerPath": "C:/ProgramData/chocolatey/lib/gcc-arm-embedded/tools/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-gdb.exe",
            "preLaunchTask": "Launch OpenOCD",
            "postDebugTask": "Kill OpenOCD"
        }
    ]
}

As can be seen in this launch.json, the path I wanted to get the debugger from is C:/ProgramData/chocolatey/lib/gcc-arm-embedded/tools/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-gdb.exe, but in the picture in the output it shows that it tried to use C:/ProgramData/chocolatey/bin/arm-none-eabi-gdb.exe (which does work so it's fine, I guess). And the biggest problem is apparently it is looking for the launch program as C:/Users/Lucas Yukio/Documents/Projetos Tiva/teste display/build/projeto which is missing the .axf extension at the end.

When I launch the debugger using the f5 keyboard shortcut it launches properly, so my best idea is that the extension is not using the launch.json file I made. Is it correct? And if so, how do I fix it?

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
  • 1
    Welcome to Stack Overflow! Here we tend to have question posts describing only problems, that is why I edited out your apologies at the start and at the end of the post. Otherwise your post looks quite good. It could be better, however, to include error message on "output" image directly into the post (as **text**). Note, that on Stack Overflow we treat any *off-site* information (links) as *optional*: visiting those links could give more hints about the problem, but reading the question post only should be sufficient to understand that problem. – Tsyvarev Jun 04 '23 at 18:48

1 Answers1

0

This very small "Debug button" (icon of bug) on task bar comes from vscode-cmake-tools extension and is described here, it offers only a "quick debug" feature and if you want to use it instead of hitting F5 key you need to customize "launch.json" file. Documentation suggests to use

"program": "${command:cmake.launchTargetPath}",

to make executable file visible for vscode-cmake-tools extension.

I suggest to put up with the limited functionality of VSCode plugins which are made with the philosophy of "do one thing but do it well". Use the vscode-cmake-tools plugin for building and use another plugin for debugging. Not sure if it supports Tiva micro-controllers, but I recommend you cortex-debug plugin

Pierwiastek
  • 134
  • 9
  • The problem is that I've already made a launch.json and have even tried to add this line suggested by the documentation. However it does not seem to catch on that launch.json file. – Lucas Yotsui Jun 05 '23 at 11:49
  • I do understand, the best place to ask for help with that question is plugin Github repo issues https://github.com/microsoft/vscode-cmake-tools/issues – Pierwiastek Jun 06 '23 at 08:38