如何在 VSCode 调试器中使用英特尔 C/C++ 经典编译器?
How to use Intel C/C++ Classic Compiler in VSCode debugger?
我正在 Mac 上设置一个 C 环境来为我的 phd 实现一些数字代码。
我正在使用英特尔 C/C++ 经典编译器而不是默认的 clang。
到目前为止,我设法生成了一些调试信息,调用了类似 icc -std=c17 -o code -g code.c
的命令
当我在 VSCode 中调用 运行 和调试选项时,它向我显示了 2 个选项:C++(GDB/LLDB)
和 C++ (Windows)
。当我单击第一个时,它会显示另外 2 个选项:C/C++: clang build and debug active file
或 C/C++: gcc build and debug active file
。它不显示与英特尔经典编译器相关的任何内容。我如何使用此编译器在 VSCode 环境中使用英特尔 C/C++ 经典编译器进行调试?
提前致谢!
根据 documentation,我认为您正在混合编译和调试,从您系统上检测到的编译器列表中选择 C/C++: gcc build and debug active file
只是帮助您生成这样的配置:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": ["-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}"],
"options": {
"cwd": "/usr/bin"
},
"problemMatcher": ["$gcc"],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
]
}
如果您想在 VSCode 中进行调试,您只需将此配置添加到您的 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": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/code",
"args": [],
"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
}
]
}
]
}
我正在 Mac 上设置一个 C 环境来为我的 phd 实现一些数字代码。 我正在使用英特尔 C/C++ 经典编译器而不是默认的 clang。
到目前为止,我设法生成了一些调试信息,调用了类似 icc -std=c17 -o code -g code.c
当我在 VSCode 中调用 运行 和调试选项时,它向我显示了 2 个选项:C++(GDB/LLDB)
和 C++ (Windows)
。当我单击第一个时,它会显示另外 2 个选项:C/C++: clang build and debug active file
或 C/C++: gcc build and debug active file
。它不显示与英特尔经典编译器相关的任何内容。我如何使用此编译器在 VSCode 环境中使用英特尔 C/C++ 经典编译器进行调试?
提前致谢!
根据 documentation,我认为您正在混合编译和调试,从您系统上检测到的编译器列表中选择 C/C++: gcc build and debug active file
只是帮助您生成这样的配置:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": ["-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}"],
"options": {
"cwd": "/usr/bin"
},
"problemMatcher": ["$gcc"],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
]
}
如果您想在 VSCode 中进行调试,您只需将此配置添加到您的 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": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/code",
"args": [],
"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
}
]
}
]
}