LoginSignup
2
1

More than 3 years have passed since last update.

VS Code C/C++のデバッグでブレークできない時の対処法(macOS Catalina)

Last updated at Posted at 2019-11-30

VS Code C/C++のデバッグでハマった

macOS CatalinaでVS Codeを使ってC/C++のデバッグをしようとしたら、ブレークポイント設定してもちゃんと停止してくれなかったので、その時の対処法をメモしておく。

デバッグ環境

Microsoft C/C++ for Visual Studio Code Extension

問題

  1. ブレークポイントを貼る
    スクリーンショット 2019-11-30 22.28.57.png

  2. debug開始する
    スクリーンショット 2019-11-30 22.31.29.png

  3. ブレークで停止せずにプログラムが終了する

DEBUG CONSOLE
=thread-selected,id="1"
@"hello world\r\n"
The program '/Users/MyHome/gitlab/pazdora/a.out' has exited with code 0 (0x00000000).

解決方法

以下に対処法があった
GitHub : Can't debug on macOS Catalina (LLDB) #3829
macOS Catalinaでのバグらしいが、EXTENSIONSのCodeLLDB使えばOKとのことらしい。

設定

  1. EXTENSIONSのCodeLLDBをインストールする
    スクリーンショット 2019-11-30 22.18.50.png

  2. launch.jsonの"type"を"cppdbg" -> "lldb"に変える

launch.json
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(lldb) 起動",
-           "type": "cppdbg",
+           "type": "lldb,
            "request": "launch",
            "targetArchitecture": "x86_64",
            "program": "${workspaceFolder}/a.out",
            "args": [],
            "stopAtEntry":true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "lldb"
        }
    ]
}

確認

  1. Buildする(cmd + shift + b)
  2. Debugモード(cmd + shift + d)
  3. 上記と同じようにブレーク貼ってrun
  4. ブレークできることを確認 スクリーンショット 2019-11-30 22.41.36.png
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1