简体   繁体   English

如何在 VSCode 调试器中使用英特尔 C/C++ 经典编译器?

[英]How to use Intel C/C++ Classic Compiler in VSCode debugger?

I'm setting up a C environment on a Mac to implement some numerical codes for my phd.我正在 Mac 上设置一个 C 环境来为我的 phd 实现一些数字代码。 I'm using the Intel C/C++ Classic compiler instead of the default clang.我使用的是英特尔 C/C++ 经典编译器,而不是默认的 clang。

So far, I manage to generate some debugging information evoking a command like icc -std=c17 -o code -g code.c到目前为止,我设法生成了一些调试信息,调用了icc -std=c17 -o code -g code.c这样的命令

When I call the Run and Debug option in VSCode it show 2 options to me: C++(GDB/LLDB) and C++ (Windows) .当我在 VSCode 中调用“运行和调试”选项时,它向我显示了 2 个选项: C++(GDB/LLDB)C++ (Windows) When I click the first one it shows 2 more options: C/C++: clang build and debug active file or C/C++: gcc build and debug active file .当我单击第一个时,它会显示另外 2 个选项: C/C++: clang build and debug active fileC/C++: gcc build and debug active file It does not show anything related to the Intel Classic Compiler.它不显示与英特尔经典编译器相关的任何内容。 How do I use this compiler to debug with Intel C/C++ Classic compiler inside the VSCode environment?如何使用此编译器在 VSCode 环境中使用英特尔 C/C++ 经典编译器进行调试?

Thanks in advance!提前致谢!

I think you are mixing compiling and debugging up, according to the documentation , choosing C/C++: gcc build and debug active file from the list of detected compilers on your system is just helping you to generate some configuration like this:我认为您正在混合编译和调试,根据文档,从系统上检测到的编译器列表中选择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."
    }
  ]
}

If you want to debug in VSCode, what you need to do is simply adding this configuration to your launch.json :如果你想在 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
                }
            ]
        }
    ]
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM