Visual studio code 当我尝试简单地调试时,gdb在开始时冻结;helloworld.cpp“;在Mac上使用VSCode

Visual studio code 当我尝试简单地调试时,gdb在开始时冻结;helloworld.cpp“;在Mac上使用VSCode,visual-studio-code,gdb,Visual Studio Code,Gdb,MacOS版本为10.15 Catalina,VSCode版本为1.50.1,gdb版本为9.2 下面是launch.json文件: { "version": "0.2.0", "configurations": [ { "name": "test - Build and debug active file", "typ

MacOS版本为10.15 Catalina,VSCode版本为1.50.1,gdb版本为9.2

下面是launch.json文件:

    {
    "version": "0.2.0",
    "configurations": [
      {
        "name": "test - Build and debug active file",
        "type": "cppdbg",
        "request": "launch",
        "targetArchitecture": "x64",
        "program": "${fileDirname}/${fileBasenameNoExtension}",
        "args": [],
        "stopAtEntry": true,
        "cwd": "${fileDirname}",
        "environment": [],
        "externalConsole": true,
        "MIMode": "gdb",
        "miDebuggerPath": "/usr/local/bin/gdb",
        "logging": { "engineLogging": true },
        "preLaunchTask": "test build active file",
        "setupCommands": [
          {
              "description": "Enable pretty-printing for gdb",
              "text": "-enable-pretty-printing",
              "ignoreFailures": true
          }]
      }
    ]
  }
    {
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "test build active file",
            "command": "g++",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}
下面是tasks.json文件:

    {
    "version": "0.2.0",
    "configurations": [
      {
        "name": "test - Build and debug active file",
        "type": "cppdbg",
        "request": "launch",
        "targetArchitecture": "x64",
        "program": "${fileDirname}/${fileBasenameNoExtension}",
        "args": [],
        "stopAtEntry": true,
        "cwd": "${fileDirname}",
        "environment": [],
        "externalConsole": true,
        "MIMode": "gdb",
        "miDebuggerPath": "/usr/local/bin/gdb",
        "logging": { "engineLogging": true },
        "preLaunchTask": "test build active file",
        "setupCommands": [
          {
              "description": "Enable pretty-printing for gdb",
              "text": "-enable-pretty-printing",
              "ignoreFailures": true
          }]
      }
    ]
  }
    {
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "test build active file",
            "command": "g++",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}
我可以使用终端进行调试,所以gdb和“helloworld.out”很好; 我可以使用具有相同launch.json文件的lldb进行调试,因此我的设置看起来也不错; 但当我开始用gdb调试时,它冻结了,下面是日志:

1: (133) LaunchOptions<LocalLaunchOptions xmlns='http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014'
1: (151) LaunchOptions  ExePath='/Users/Justin/Temp/TestGDB/hello'
1: (151) LaunchOptions  WorkingDirectory='/Users/Justin/Temp/TestGDB'
1: (151) LaunchOptions  TargetArchitecture='x64'
1: (151) LaunchOptions  ExeArguments=''
1: (151) LaunchOptions  MIMode='gdb'
1: (151) LaunchOptions  MIDebuggerPath='/usr/local/bin/gdb'
1: (151) LaunchOptions  WaitDynamicLibLoad='false'
1: (151) LaunchOptions  ExternalConsole='true'
1: (151) LaunchOptions>
1: (151) LaunchOptions    <SetupCommands>
1: (151) LaunchOptions        <Command IgnoreFailures='true' Description='Enable pretty-printing for gdb'>-enable-pretty-printing</Command>
1: (152) LaunchOptions    </SetupCommands>
1: (152) LaunchOptions</LocalLaunchOptions>
1: (261) codeSign-stderr: Executable=/usr/local/bin/gdb
1: (265) Starting: "/usr/local/bin/gdb" --interpreter=mi
1: (277) DebuggerPid=1454
1: (374) ->=thread-group-added,id="i1"
1: (375) ->~"GNU gdb (GDB) 8.3\n"
1: (375) ->~"Copyright (C) 2019 Free Software Foundation, Inc.\n"
1: (375) ->~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law."
1: (375) ->~"\nType \"show copying\" and \"show warranty\" for details.\n"
1: (376) ->~"This GDB was configured as \"x86_64-apple-darwin19.6.0\".\n"
1: (376) ->~"Type \"show configuration\" for configuration details.\n"
1: (376) ->~"For bug reporting instructions, please see:\n"
1: (376) ->~"<http://www.gnu.org/software/gdb/bugs/>.\n"
1: (376) ->~"Find the GDB manual and other documentation resources online at:\n    <http://www.gnu.org/software/gdb/documentation/>."
1: (376) ->~"\n\n"
1: (376) ->~"For help, type \"help\".\n"
1: (376) ->~"Type \"apropos word\" to search for commands related to \"word\".\n"
1: (376) ->(gdb)
1: (380) <-1001-gdb-set target-async on
1: (380) ->1001^done
1: (380) ->(gdb)
1: (381) 1001: elapsed time 2
1: (388) <-1002-enable-pretty-printing
1: (388) ->1002^done
1: (388) ->(gdb)
1: (388) 1002: elapsed time 0
1: (388) <-1003-interpreter-exec console "set pagination off"
1: (388) ->=cmd-param-changed,param="pagination",value="off"
1: (388) ->1003^done
1: (388) ->(gdb)
1: (388) 1003: elapsed time 0
1: (389) <-1004-gdb-set auto-solib-add on
1: (389) ->1004^done
1: (389) ->(gdb)
1: (389) 1004: elapsed time 0
1: (389) <-1005-gdb-set solib-search-path /Users/Justin/Temp/TestGDB:
1: (389) ->1005^done
1: (389) ->(gdb)
1: (389) 1005: elapsed time 0
1: (389) <-1006-environment-cd /Users/Justin/Temp/TestGDB
1: (389) ->1006^done
1: (389) ->(gdb)
1: (389) 1006: elapsed time 0
1: (390) <-1007-file-exec-and-symbols /Users/Justin/Temp/TestGDB/hello
1: (393) ->1007^done
1: (393) ->(gdb)
1: (393) 1007: elapsed time 3
1: (395) <-1008-interpreter-exec console "show architecture"
1: (395) ->~"The target architecture is set automatically (currently i386:x86-64)\n"
1: (395) ->1008^done
1: (395) ->(gdb)
1: (395) 1008: elapsed time 0
1: (396) <-1009-break-insert -f main
1: (396) ->1009^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000100003e02",func="main(int, char const**)",file="/Users/Justin/Temp/TestGDB/hello.cpp",fullname="/Users/Justin/Temp/TestGDB/hello.cpp",line="7",thread-groups=["i1"],times="0",original-location="main"}
1: (396) ->(gdb)
1: (399) 1009: elapsed time 3
1: (404) Send Event AD7EngineCreateEvent
1: (405) Send Event AD7ProgramCreateEvent
1: (438) <-1010-break-insert -f hello.cpp:7
1: (438) ->1010^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x0000000100003e02",func="main(int, char const**)",file="/Users/Justin/Temp/TestGDB/hello.cpp",fullname="/Users/Justin/Temp/TestGDB/hello.cpp",line="7",thread-groups=["i1"],times="0",original-location="hello.cpp:7"}
1: (439) ->(gdb)
1: (439) 1010: elapsed time 0
1: (445) <-1011-symbol-list-lines /Users/Justin/Temp/TestGDB/hello.cpp
1: (445) ->1011^done,lines=[{pc="0x0000000100003df3",line="6"},{pc="0x0000000100003e02",line="7"},{pc="0x0000000100003e1b",line="7"},{pc="0x0000000100003e2d",line="8"},{pc="0x0000000100003e46",line="8"},{pc="0x0000000100003e58",line="9"},{pc="0x0000000100003e71",line="9"},{pc="0x0000000100003e83",line="10"},{pc="0x0000000100003e88",line="11"},{pc="0x0000000100003e8a",line="11"},{pc="0x0000000100003e98",line="11"},{pc="0x0000000100003ea7",line="0"},{pc="0x0000000100003ed0",line="11"},{pc="0x0000000100003ed3",line="11"},{pc="0x0000000100003ed7",line="11"},{pc="0x0000000100003ee8",line="0"}]
1: (445) ->(gdb)
1: (446) 1011: elapsed time 1
1: (450) Send Event AD7BreakpointBoundEvent
1: (523) Send Event AD7LoadCompleteEvent
=thread-group-added,id="i1"
GNU gdb (GDB) 8.3
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin19.6.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
=cmd-param-changed,param="pagination",value="off"
1: (527) <-1012-exec-run
1: (529) ->=thread-group-started,id="i1",pid="1456"
1: (535) ->=thread-created,id="1",group-id="i1"
1: (535) ->~"[New Thread 0xc03 of process 1456]\n"
1: (539) <-1013-thread-info 1
[New Thread 0xc03 of process 1456]
1:(133)启动选项
1:(151)启动选项
1:(151)启动选项-启用漂亮打印
1:(152)启动选项
1:(152)启动选项
1:(261)代码设计标准:可执行文件=/usr/local/bin/gdb
1:(265)开始:“/usr/local/bin/gdb”--解释器=mi
1:(277)调试PID=1454
1:(374)->=已添加线程组,id=“i1”
1:(375)->~“GNU gdb(gdb)8.3\n”
1(375)->“版权(C)2019免费软件基金会,公司”
1:(375)->~“许可证GPLv3+:GNU GPL版本3或更高版本\n这是免费软件:您可以自由更改和重新发布。\n在法律允许的范围内,不提供任何担保。”
1:(375)->~“\n键入“显示复制”和“显示保修”以了解详细信息。\n”
1:(376)->~“此GDB配置为\“x86\u 64-apple-darwin19.6.0\”\n
1:(376)->~“键入\“显示配置\”以获取配置详细信息。\n”
1:(376)->~“有关错误报告说明,请参阅:\n”
1:(376)->~“\n”
1:(376)->~“联机查找GDB手册和其他文档资源,网址为:\n。”
1:(376)->~“\n\n”
1:(376)->~“有关帮助,请键入\“帮助\\n”
1:(376)->~“键入\“apropos word\”以搜索与\“word\”相关的命令\n”
1:(376)->(gdb)
1:(380)1001^完成
1:(380)->(gdb)
1:(381)1001:经过的时间2
1:(388)1002^完成
1:(388)->(gdb)
1:(388)1002:经过的时间0
1:(388)=cmd param已更改,param=“分页”,value=“关闭”
1:(388)->1003^完成
1:(388)->(gdb)
1:(388)1003:经过的时间0
1:(389)1004^完成
1:(389)->(gdb)
1:(389)1004:经过的时间0
1:(389)1005^完成
1:(389)->(gdb)
1:(389)1005:运行时间0
1:(389)1006^完成
1:(389)->(gdb)
1:(389)1006:运行时间0
1:(390)1007^完成
1:(393)->(gdb)
1:(393)1007:经过的时间3
1:(395)~“自动设置目标体系结构(当前为i386:x86-64)\n”
1:(395)->1008^完成
1:(395)->(gdb)
1:(395)1008:经过的时间0
1:(396)1009^done,bkpt={number=“1”,type=“breakpoint”,disp=“keep”,enabled=“y”,addr=“0x0000000100003e02”,func=“main(int,char const**)”,file=“/Users/Justin/Temp/TestGDB/hello.cpp”,fullname=“/Users/Justin/Temp/TestGDB/hello.cpp”,line=“7”,线程组=[“i1”],times=“0”,original location=“main”}”
1:(396)->(gdb)
1:(399)1009:经过的时间3
1:(404)发送事件AD7EngineCreateEvent
1:(405)发送事件AD7ProgramCreateEvent
1:(438)1010^done,bkpt={number=“2”,type=“breakpoint”,disp=“keep”,enabled=“y”,addr=“0x0000000100003e02”,func=“main(int,char const**)”,file=“/Users/Justin/Temp/TestGDB/hello.cpp”,fullname=“/Users/Justin/Temp/TestGDB/hello.cpp”,line=“7”,线程组=[“i1”],times=“0”,original location=“hello.cpp:7”}
1:(439)->(gdb)
1:(439)1010:经过的时间0
1:(445)1011^完成,行=[{pc=“0x0000000100003df3”,line=“6”},{pc=“0x0000000100003e02”,line=“7”},{pc=“0x0000000100003e1b”,line=“7”},{pc=“0x0000000100003e2d”,line=“8”},{pc=“0x0000000100003e46”,line=“8”},{pc=“0000000100003e58”,line=“9”},{pc=“0x0000000100003e71”,line=“9”{pc=“0x0000000100003e83,{pc=“0x0000000100003e88”{=“0x0000000100003e8a”,line=“11”},{pc=“0x0000000100003e98”,line=“11”},{pc=“0x0000000100003ea7”,line=“0”},{pc=“0x0000000100003ed0”,line=“11”},{pc=“0x0000000100003ed3”,line=“11”},{pc=“0x0000000100003ed7”,line=“11”},{pc=“0x0000000100003ee8”,line=“0”}]
1:(445)->(gdb)
1:(446)1011:经过的时间1
1:(450)发送事件AD7BreakpointBoundEvent
1:(523)发送事件AD7LoadCompleteEvent
=已添加线程组,id=“i1”
GNU gdb(gdb)8.3
版权所有(C)2019免费软件基金会。
许可证GPLv3+:GNU GPL版本3或更高版本
这是自由软件:您可以自由更改和重新发布它。
在法律允许的范围内,不存在任何担保。
有关详细信息,请键入“显示复制”和“显示保修”。
此GDB配置为“x86_64-apple-darwin19.6.0”。
键入“显示配置”以获取配置详细信息。
有关错误报告说明,请参阅:
.
在线查找GDB手册和其他文档资源,网址为:
.
要获得帮助,请键入“帮助”。
键入“apropos word”搜索与“word”相关的命令。
=cmd param changed,param=“分页”,value=“关闭”
1:(527)=线程组已启动,id=“i1”,pid=“1456”
1:(535)->=创建的线程,id=“1”,组id=“i1”
1:(535)->~“[进程1456的新线程0xc03]\n”

1:(539)我试过GDB8.3,同样的问题