microsoft / microsoft/vscode-cmake-tools

Debug command not using launch.json file

Open
#3,200 8 comments 2 reactions 0 assignees View on GitHub
enhancement Feature: debug/launch
Dominant language
TypeScript
Stars
1.7k
Forks
546
Avg merge
2d 16h
Merged PRs (30d)
32

Description

### Brief Issue Summary

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](https://i.stack.imgur.com/6zKeF.png).

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](https://i.stack.imgur.com/e9vHF.png).

This is my launch.json file:
```json
{
"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?

### CMake Tools Diagnostics

_No response_

### Debug Log

_No response_

### Additional Information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by comparing the CMake Tools debug button with the VS Code F5 path, using the reported launch.json, tasks.json, and CMakeLists.txt. Trace how the extension selects the debugger path and launch program, then verify the debug command honors the configured .axf executable and run the relevant CMake Tools tests or a matching project.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, vscode
Domain
build-system, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.