在 VScode 中为 PETSc 配置调试设置

时间:2021-05-29 08:14:54

标签: petsc

这将是一个漫长的过程,但我想知道社区中是否有人拥有在 VScode 中运行 PETSc 的 .json 设置(用于调试)。

最好的问候

1 个答案:

答案 0 :(得分:0)

目前我使用 /petsc/src/snes/tutorials 中的示例 19 作为案例。

我制作了一个makefile:

 touch makefile

里面我放了:

include ${PETSC_DIR}/lib/petsc/conf/variables
include ${PETSC_DIR}/lib/petsc/conf/rules

example19: example19.o chkopts
    -${CLINKER} -o example19 example19.o ${PETSC_LIB}
        ${RM} example19.o

在 vscode 的 .json 文件中

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": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "preLaunchTask": "run petsc makefile",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

tasks.json

{
    "tasks": [
        {
            "type": "shell",
            "label": "run petsc makefile",
            "command": "make",
            "args": [
                "${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}",
                "env": {"PETSC_DEB":  "/home/pc/petsc"}
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
        }
    ],
    "version": "2.0.0"
}

这将创建可执行文件并运行脚本。但我无法附加调试器。

希望得到一些帮助。

最好的问候