LoginSignup
8
7

More than 1 year has passed since last update.

[VSCode]macOSでC/C++のデバッグができなくなった時の対処法

Last updated at Posted at 2019-10-28

デバッグができない

かなしい😢

エラーメッセージは様々

Unable to create 'launch.json' file inside the '.vscode' folder (Cannot read property 'length' of undefined).
だとか
いざデバッガが走り出してもBreakpointでストップしないだとか
ここにとりあえずの対処法がありました

解決法

  • VSCodeの拡張CodeLLDBを入れる
  • 以下のコマンドを実行
mkdir .vscode
touch .vscode/launch.json
touch .vscode/tasks.json
  • jsonファイルをそれぞれ編集
tasks.json
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "clang++ build active file",
      "type": "shell",
      "command": "clang++",
      "args": ["${fileBasename}", "-o", "${fileBasenameNoExtension}.out", "-g"],
      "group": {
        "kind": "build",
        "isDefault": true
      }
    }
  ]
}
launch.json
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "clang++ build and debug active file",
      "type": "lldb",
      "request": "launch",
      "program": "${fileDirname}/${fileBasenameNoExtension}.out",
      "args": [],
      "cwd": "${workspaceFolder}",
      "preLaunchTask": "clang++ build active file"
    }
  ]
}
  • ⌘ + Shift + bでコンパイル
  • あとは通常通り

おわりに

根本的原因等誰かわかりましたら教えてください...

追記

「macOS Catalinaへの更新時にデバッグできなくなった時の対処法」としていましたが、未だにこの問題があるようなのでタイトルを更新しました。

8
7
1

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
8
7