使用GDB调试GPGPU-SIM(导出调试控制台)

使用调试控制台来对GPGPU-SIM进行调试

上一篇文章说明了如何在命令行中使用gdb来调试由makefile实现编译GPGPU-SIM,这篇文章介绍一下如何调出调试控制台来调试(毕竟用命令行调试也太难受了)

  1. 先创建一个调试文件(launch.json和task.json)
    在这里插入图片描述
    它会蹦到一个launch.json文件里,让你添加相应调试的信息
    它会蹦到一个launch.json文件里,让你添加相应调试的信息

  2. 修改launch.json文件

// {
//     // 使用 IntelliSense 了解相关属性。 
//     // 悬停以查看现有属性的描述。
//     // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
//     "version": "0.2.0",
//     "configurations": [
        
//     ]
// }
{
    // 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) 启动",
            "type": "cppdbg",
            "request": "launch",
            "program": "/home/sherlockfeng/gpgpu-sim_distribution-master/demo_program/demo",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath":"/usr/bin/gdb",
            "miDebuggerArgs": "-q -ex quit; wait() { fg >/dev/null; }; /usr/bin/gdb -q --interpreter=mi",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "将反汇编风格设置为 Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }
        
    ]
}

这是我的launch.json文件的内容,program里填写的是你的要调试的可执行文件,所以你必须先得到这个文件,所以这个文件是通过你在命令行中输入编译的指令得到的

1. source setup_environment debug
2. make
3. nvcc --cudart shared -o demo p2.cu

这是编译时在命令行输入的顺序(按照GPGPU-SIM的项目地址操作就行,具体细节操作可以看我的上一篇文章)

还需要注意的是,launch.json文件里有一行是"miDebuggerPath":"/usr/bin/gdb",这里填写的是你gdb在你工作区中的地址,可以在命令行中输入whereis gdb获得

  1. 修改task.json文件
{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: gcc 生成活动文件",
            "command": "/usr/bin/g++",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "调试器生成的任务。"
        }
    ]
}
  1. 在你的要运行的源文件(.cu文件里)点断点
    在这里插入图片描述
  2. 点击调试
    在这里插入图片描述
  3. 成功调试
    在这里插入图片描述
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值