【问题标题】:Configure debug setting for PETSc in VScode在 VScode 中为 PETSc 配置调试设置
【发布时间】:2021-05-29 08:14:54
【问题描述】:

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

最好的问候

【问题讨论】:

    标签: petsc


    【解决方案1】:

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

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

    不胜感激。

    最好的问候

    【讨论】:

    • 谁能帮我解决这个问题?
    猜你喜欢
    • 1970-01-01
    • 2021-10-23
    • 1970-01-01
    • 2019-07-19
    • 1970-01-01
    • 2017-02-18
    • 1970-01-01
    • 2011-12-14
    • 2020-06-18
    相关资源
    最近更新 更多