10

使用VSC调试开源项目 – iproute2

 9 months ago
source link: https://www.taterli.com/9510/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

使用VSC调试开源项目 – iproute2

使用VSC调试开源项目 – iproute2

使用VSC阅读代码有非常舒服的感觉,如果能再加上调试,那就更爽了,而很多开源项目本身也比较大,直接阅读代码还是有点困难的,所以最好还是上调试,调试也很简单,无非是调用gdb,所以先新建一个简单的任务tasks.json,用来指代编译过程,具体根据项目而定.

{
    "tasks": [
        {
            "type": "shell",
            "label": "Makefile",
            "command": "make",
            "problemMatcher": [],
        }
    ],
    "version": "2.0.0"
}

接着创建launch.json,来指代要调试的内容,比如假设我这里要看的是iproute2中的ip -6 address命令,那么就写下来.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/ip/ip",
            "args": ["-6","address"],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "Makefile"
        }
    ]
}

最后按F5,顺利进入调试.

image-6-1024x516.png

可以说非常简单了.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK