简体   繁体   中英

Unable to debug C++ in Visual Code on Mac OS X

My environment:

$ clang++ --version
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Visual Studio information:

Version: 1.43.1
Commit: fe22a9645b44368865c0ba92e2fb881ff1afce94
Date: 2020-03-18T07:01:41.240Z
Electron: 7.1.11
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 18.7.0

launch.json :

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "MyProject",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/diffusion/run",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "setupCommands": [
                {
                    "text": "-enable-pretty-printing"
                }
            ]
        }
    ]
}

I am able to run/compile C++ file fine. I can even run GDB like so:

$ sudo gdb diffusion/run
GNU gdb (GDB) 8.3.1
Reading symbols from diffusion/run...
Reading symbols from /Users/me/project/diffusion/run.dSYM/Contents/Resources/DWARF/run...
(gdb) break color
Breakpoint 1 at 0x1000024d6: file diffusion/render.cpp, line 21.
(gdb) condition 1 depth==1

gdb requires sudo since otherwise Mac OSX makes you do some scary code-signing stuff , but otherwise works fine.

The issue is, when I launch (hit F5 ), I see the following:

Unable to start debugging. GDB exited unexpectedly with exit code 134 (0x86).

And debugging fails. How do I set this up correctly to debug C++ code in VSCode?

Have you ever tried to disable csrutil? AFAIK, gdb tries to write some temp things like as if it is running in POSIX like os, but, by default, macOS has restricted root folders to be written by apps, so it might not be able to. I had a similar problem I have disabled csrutil and it has gone. You could try the same.

Good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM