GDB不工作:无法插入断点1。无法在地址上访问内存[...]
我正在尝试使用WSL中的GDB设置VSCODE将VSCODE设置为调试C ++程序。但是我在WSL 1(Ubuntu 22.04 LTS)上遇到了GDB的问题。每当我尝试设置断点并运行程序时,我都会收到以下错误:
Starting program: /mnt/d/Informatics/vscode/test/a.out
warning: opening /proc/PID/mem file for lwp 7674.7674 failed: No such file or directory (2)
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x10e0
程序的内容无关紧要,总是会遇到错误。代码是使用以下行编译的:
g++ -Wall -pedantic-errors -O2 -std=c++23 -ggdb3 -fdiagnostics-color=always /mnt/d/Informatics/vscode/test/*.cpp
GDB版本:GNU GDB(Ubuntu 12.0.90-0ubuntu1)12.0.90
G ++版本:12.0.1
(也尝试了11.2.0
- 无差异),
带有Mingw的G ++和GDB,这不存在,因此这应该意味着意味着我没有错误地使用GDB调试器。
编辑:尝试从源中提出的评论中建议的GDB 11.2,但这并未解决问题。唯一的区别是它不会显示/proc/pid/mem
现在警告。
Starting program: /mnt/d/Informatics/vscode/test/a.out
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x10e0
编辑2:从源及其起作用的GDB 10.2编辑,问题没有出现。我不知道为什么它不适用于10.2上方的任何版本。是GDB错误还是WSL错误?
I'm trying to setup my vscode to debug C++ programs using gdb from WSL. But I faced problem with gdb on my WSL 1 (Ubuntu 22.04 LTS). Whenever I try set a breakpoint and run a program, I get the following error:
Starting program: /mnt/d/Informatics/vscode/test/a.out
warning: opening /proc/PID/mem file for lwp 7674.7674 failed: No such file or directory (2)
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x10e0
The contents of the program don't matter, always getting the error. Code is compiled using the following line:
g++ -Wall -pedantic-errors -O2 -std=c++23 -ggdb3 -fdiagnostics-color=always /mnt/d/Informatics/vscode/test/*.cpp
gdb version: GNU gdb (Ubuntu 12.0.90-0ubuntu1) 12.0.90
g++ version: 12.0.1
(also tried with 11.2.0
- no difference)
On windows with g++ and gdb from MinGW the problem doesn't exist, so this should mean I'm not using the gdb debugger wrong.
Edit: tried compiling gdb 11.2 from source as suggested in comments, but this did not fix the problem. Only difference is that it's not showing /proc/PID/mem
warning now.
Starting program: /mnt/d/Informatics/vscode/test/a.out
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x10e0
Edit 2: Compiled gdb 10.2 from source and it works, the problem does not appear. I don't know why it doesn't work with any version above 10.2. Is it gdb bug or WSL bug?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
修复了较新的版本:在Ubuntu 23.04(WSL)上的GDB 13.1中,一切似乎都很好。
Fixed in newer versions: everything seems to work fine in gdb 13.1 on Ubuntu 23.04 (WSL).