発生している問題
下記コードのmap<int, int> ma;にbreakpointを置きデバックを始め、map<int, int> ma;の位置で止まった際にデバックのコマンドが効かなくなる(step overやstep inなどのコマンドが機能しない)ことです。
解決までに時間がかかりそうなので、やってきたことを書いてこうと思います。
環境
visual stdio code 1.46.0
Mac OS 10.15.4
clang:Apple clang version 11.0.3 (clang-1103.0.32.29)
コード
# include <iostream>
# include <map>
using namespace std;
int main()
{
map<int, int> ma;
return 0;
}
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": "clang++ - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "lldb",
"preLaunchTask": "clang++ build active file"
}
]
}
自分が考えたこと
# include <iostream>
# include <map>
# include <list>
# include <vector>
using namespace std;
int main()
{
int i;
cin >> i;
vector<int> v(i);
std::list<int> lst;
map<int, int> ma;
cout << "Hello" << endl;
return 0;
}
のように、map以外の型でも試してみました。
上記のtestコードでcin >> i;の行にブレークポイントを置いた時でも同じ挙動を確認しました。
上記のコードでmap<int, int> ma;をコメントアウトしたところ問題なくデバックできたためmap<int, int> ma;のみに問題があると考えています。
また、clang++ -std=c++17でビルドをし実行ファイルを起動しても問題がなかったことからデバックに問題があると考えています。
clang++ -std=c++11でも問題ありませんでした。
やったこと(20/7/5)
・lldbが使えるか確認
terminal上からlldbを使ってデバックができるか確認してみた。
->できた。
・c_cpp_properties.jsonファイルを作ってみた。
->変わらなかった。
c_cpp_properties.json
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
・lldb-miが確認できない。
詳細に書くと、findコマンドでlldb-miを検索しても見つからないのに、問題が起きている状態でアクティビティモニタをみるとlldb-miが起動してる。
launch.jsonでも指定してるのlldbだし、なんでlldb-miが起動してるのかわからない。
mapを使ってない他のコードでdebugをしてみて確認してみたらlldb-miが起動してたから、実際使ってるのはlldb-mi?
codelldbを入れてみた20/7/9 (->使えるか不明)
参照
codelldbを入れてみて
ここにあるlaunch.jsonやtasks.jsonを作ったり公式ドキュメントのlaunch.jsonを作ったりしてみたが、codelldbのデバックがうまくいかない。
unable to find excutable for ~を怒られる。
lldb-miを調べた方が解決に近いと考えたので、放置。
次回やること
lldb-miがどうなってるか確認
暇な時に追記していきます。