VS Code 上的简单 GDB C++调试失败,并显示 NullReferenceException
Simple GDB C++ debugging on VS Code fails with a NullReferenceException
我的源代码file.cpp
:
#include <iostream>
using namespace std;
int main()
{
int x = 1;
int y = 2;
cout << x + y << endl;
return 0;
}
我使用 g++ -g file.cpp
编译它,然后我的launch.json
文件是这样的:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
我的目录结构是:
- workspaceFolder
- .vscode
- launch.json
- a.out
- file.cpp
当我单击"调试"选项卡中的绿色"开始调试"箭头时,我在调试控制台中收到此错误:
Stopping due to fatal error: NullReferenceException: Object reference not set to an instance of an object
我做错了什么? 我已经查看了每个教程和调试C++似乎适用于所有教程和调试,除了我的情况。我还安装了C/C++(Microsoft)扩展,并且正在运行Ubuntu 64位。
我遇到了同样的问题,不知道为什么,但是在launch.json
中设置"externalConsole"
来false
对我来说是有好处的。
此问题已在 15 天前在 Microsoft/vscode-cpptools 上报告,自 v1.30.0 以来一直存在,并且应该在最新的内部版本中修复。
相关文章:
- 图片不显示,关闭时出错 --> 调试断言失败!表达式:is_block_type_valid(标头>_block_use)
- 使用已删除的函数进行编译失败,并显示 uclibc
- DirectShow 在 Win7/Win10 上失败并显示黑框和0x80070005
- boost::p rogram_options - 验证失败时,显示用户在错误消息中输入的值
- C++获取线失败,并显示"Success" :-(
- 卡萨布兰卡test_runner失败,并显示 std::bad_alloc
- 仅当ASSERT_STREQ失败时显示差异
- azure-iot-sdk-c API IoTHubClient_LL_DoWork()失败并显示大量错误
- SecKeyCreateFromData 在 10.9 上失败,并显示 -2147415792
- WinSock c++ inet_ntop始终显示 204.204.204.204(并且 accept() 没有失败)
- std::tie 在从函数调用传递值时失败,并显示"无法绑定非常量左值引用"
- SDL_Init失败并显示'SDL_Error: Failed to connect to the Mir Server'
- CreateGraphicsPipelineState 失败并显示E_INVALIDARG
- JNI 失败并显示'Error occurred during initialization of VM'
- C++ 为什么不使用已删除的函数时编译器失败并显示错误代码 C2280
- glBufferData 失败,并显示: "Array object is not active."
- VS Code 上的简单 GDB C++调试失败,并显示 NullReferenceException
- vcpkg 安装失败,并显示"SSL 连接错误"
- sprintf_s() 失败并显示错误"debug assertion failed"
- unlink() 在检查存在后立即失败并显示"No such file or directory"