LLVM基础学习:使用VSCode+GDB 调试 out-of-tree 的 LLVM Pass 的配置
作者:互联网
使用VSCode+GDB 调试 out-of-tree 的 LLVM Pass 的配置
时间:20220620,版本:V0.1
作者:robotech_erx
使用GDB调试文件比较多的项目还是很累的。
尝试了GDBGui等前端,还是感觉VScode,Eclipse这些成熟的IDE作为前端更好。
VScode调试 LLVM Pass 的配置:
1.设置llvm的包含路径:
C++的配置文件.vscode/c_cpp_properties.json
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/home/WorkTable/llvm1301/include/**" # 就是这里
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
2.配置.vscode/launch.json
生成launch.json的时候选择(gdb)launch模板。
主要是两个配置:
"program" :被调试的程序,这里是opt程序
"args":参数,就是把上个文章里的参数填到这里了。
{
// 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": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "/home/jack/worktable/llvm1301/bin/opt", #这里
"args": [ "-enable-new-pm=0","-load","/home/path/to/libHelloWorld.so","-legacy-hello-world","/home/path/to/input_for_hello.ll","-o","/dev/null"], #这里
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
3.下断点。
在源码里下好断点,F5就行了。没有opt的源码不重要,GDB会自动定位到有的那部分,然后断下来。
注意:
"args":参数,不要整个参数放到一个字符串里,会出错。
"args": [ "-enable-new-pm=0 -load /home/xxx/libHelloWorld.so -legacy-hello-world /home/xxx/input_for_hello.ll -o /dev/null"],
opt会报错:
opt: for the --enable-new-pm option: '0 -load /home/xxx/libHelloWorld.so -legacy-hello-world /home/xxx/input_for_hello.ll -o /dev/null' is invalid value for boolean argument! Try 0 or 1
0 以及后面的都识别了一个。写成json的格式也不行,像上面那样才行。
标签:opt,LLVM,VSCode,tree,GDB,gdb,home,hello 来源: https://www.cnblogs.com/robotech/p/16394617.html