【问题标题】:Using gcov in VSCode在 VSCode 中使用 gcov
【发布时间】:2020-06-18 16:30:40
【问题描述】:

我尝试通过 VSCode 使用 gcov,但遇到了问题。我配置了一个构建任务以使用覆盖信息进行编译:

{
            "type": "shell",
            "label": "Coverage build",
            "command": "C:\\MinGW\\bin\\gcc.exe",
            "args": [
                "-Wall",
                "-Werror",
                "-Wvla",
                "-pedantic",
                "-Wextra",
                "-Wfloat-equal",
                "-ftest-coverage",
                "-fprofile-arcs",
                "-fprofile-arcs",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "C:\\MinGW\\bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build"
        }

没有编译错误,但.gcno 和.gcda 文件由于某种原因放在./MinGW/bin 中——而不是在主文件目录中。

如何解决这个问题?因为这就是为什么我不能在工作目录中使用 gcov 并且我不想打开其他终端窗口只是为了解决这个问题。

【问题讨论】:

  • 您可以使用 -fprofile-dir 标志在您提供的路径中提供生成 .gcda 文件的路径。至于 .gcno 没有这样的标志可用。

标签: c visual-studio-code mingw gcov


【解决方案1】:

可能是任务工作目录的配置问题。

尝试替换:

            "options": {
                "cwd": "C:\\MinGW\\bin"
            },

与:

            "options": {
                "cwd": "${workspaceFolder}"
            },

或与您的 Visual Studio Code 项目相关的内容。

【讨论】:

    猜你喜欢
    • 2023-04-02
    • 2012-11-22
    • 2011-03-14
    • 2015-08-01
    • 2010-09-29
    • 2015-01-25
    • 2018-11-16
    • 2019-06-07
    • 2020-08-25
    相关资源
    最近更新 更多