question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

launch.json selects the incorrect debugger executable.

See original GitHub issue

Brief Issue Summary

On my computer I have many different GCC installations, I have many LLVM installations etc…

When using the launch.json example here, the incorrect dbgExe is selected.

Expected:

Expected behaviour, Cmake Tools select the correct debugger, the same one used if launched using the CMake Tools dedicated debug button.

Apparent Behavior:

The resulting error is this: image

However the compiler is this:

[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: C:/utils/bin/mingw64/bin/clang.exe - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: C:/utils/bin/mingw64/bin/clang++.exe - skipped

Platform and Versions

  • Operating System: Windows
  • CMake Version: cmake version 3.19.0-rc3
  • VSCode Version: 1.55.2
  • CMake Tools Extension Version: 1.7.7
  • Compiler/Toolchain: Clang 11.1.0

Other Notes/Information

I use clang from winlibs: http://www.winlibs.com/

My exact configuration in launch.json:

        {
            "name": "Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${command:cmake.launchTargetPath}",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [
                {
                    "name": "PATH",
                    "value": "$PATH:${command:cmake.getLaunchTargetDirectory}"
                }
            ],
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
seppeoncommented, May 11, 2021

Fair enough, in that case is there anything like: ${command:cmake.debuggerPath}

That can be used to work around the difference?

0reactions
WardenGnawcommented, May 10, 2021

The difference is because the type": "cppdbg" in launch.json uses the debug adapter from Microsoft C/C++ Extension. It only uses the values defined in the launch.json. It will try its best to fill in the missing files, E.g. miDebuggerPath based on PATH.

The CMake extension extends on top of the Microsoft C/C++ Extension and their debug button provides the additional configuration fields to C/C++ Extension Debug Adapter.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configure launch.json for C/C++ debugging in Visual Studio ...
Specifies the full path to the executable the debugger will launch or attach to. The debugger requires this location in order to load...
Read more >
[Debug] Wrong launch configuration is selected when trying to ...
Wrong launch configuration is selected for debugging when trying to launch a compound configuration if launch.json become opened in the editor.
Read more >
vscode debug setting in launch.json with custom executable ...
1 Answer 1 · Delete "program" from launch.json. · Press Ctrl+Shift+P · Search "Python: Select Interpreter" · Select pipenv interpreter path.
Read more >
launch.vs.json schema reference (C++) - Microsoft Learn
Describes the schema elements for the `launch.vs.json` file. ... executable file in Solution Explorer and choose Debug and Launch Settings.
Read more >
VS Code | Build, Run and Debug in C++ - GeeksforGeeks
Then choose “g++.exe – Build and debug active file”. It refers to g++ GNU C++ compiler. After this a Launch.json file will appear, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found