在 VScode 中为 PETSc 配置调试设置

问题描述

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

最好的问候

解决方法

目前我使用 /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"
}

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

希望得到一些帮助。

最好的问候

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...