解决ubuntu20.04中VSCode无法调试C语言的问题

系统环境:

ubuntu20.04

Visual Studio Code Version 1.60.2

lauch.json配置如下:

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

settings.json配置如下:

{
    "files.associations": {
        "array": "c",
        "atomic": "c",
        "*.tcc": "c",
        "cctype": "c",
        "chrono": "c",
        "clocale": "c",
        "cmath": "c",
        "condition_variable": "c",
        "cstdarg": "c",
        "cstdint": "c",
        "cstdio": "c",
        "cstdlib": "c",
        "cstring": "c",
        "ctime": "c",
        "cwchar": "c",
        "cwctype": "c",
        "deque": "c",
        "unordered_map": "c",
        "unordered_set": "c",
        "vector": "c",
        "exception": "c",
        "fstream": "c",
        "functional": "c",
        "initializer_list": "c",
        "iomanip": "c",
        "iosfwd": "c",
        "iostream": "c",
        "istream": "c",
        "limits": "c",
        "mutex": "c",
        "new": "c",
        "ostream": "c",
        "numeric": "c",
        "ratio": "c",
        "sstream": "c",
        "stdexcept": "c",
        "streambuf": "c",
        "system_error": "c",
        "thread": "c",
        "cinttypes": "c",
        "tuple": "c",
        "type_traits": "c",
        "utility": "c",
        "typeinfo": "c",
        "cstddef": "c",
        "algorithm": "c",
        "iterator": "c",
        "map": "c",
        "memory": "c",
        "memory_resource": "c",
        "optional": "c",
        "random": "c",
        "string": "c",
        "string_view": "c",
        "bit": "c",
        "stdlib.h": "c",
        "pehfeatureprecess.h": "c",
        "stat.h": "c",
        "types.h": "c",
        "stdint.h": "c"
    }
}

tasks.json配置如下:

{
     "version": "2.0.0",
     "tasks": [
        {
        "label": "build",
        "type": "shell",
        "command":"gcc",
        "args": ["${file}", "-o", "${fileBasenameNoExtension}.out", "-g"]
        }
     ]    
}

原因是task.json配置中我少加了一个“-g”,把-g去掉就不能调试了,程序直接运行完了,打断点也没用。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值