问题
我正在尝试使用rust-gdb调试this Rust program,但我似乎无法让GDB正常工作:
/home/a/tmp/foo(HEAD)
09/19/2021 09:57:23.114 AM> rust-gdb -q target/debug/foo
Reading symbols from target/debug/foo...
(gdb) b hello
Breakpoint 1 at 0x7a44: file src/main.rs, line 2.
(gdb) run
Starting program: /home/a/tmp/foo/target/debug/foo
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x7a44
(gdb)我还尝试使用b src/main.rs:2设置断点,并且只运行gdb而不是Rust包装器rust-gdb,这两种方法都会产生相同的结果。我做得对吗?
系统信息
/home/a/tmp/foo(HEAD)
09/19/2021 09:07:48.200 AM> uname -a
Linux a 5.13.15_1 #1 SMP Fri Sep 10 16:52:33 UTC 2021 x86_64 GNU/Linux
/home/a/tmp/foo(HEAD)
09/19/2021 09:07:51.291 AM> rustc --version
rustc 1.55.0 (c8dfcfe04 2021-09-06)
/home/a/tmp/foo(HEAD)
09/19/2021 09:07:53.955 AM> gdb --version
GNU gdb (GDB) 10.2
Copyright (C) 2021 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.发布于 2021-09-19 15:58:53
我设法通过卸载已安装的gdb (从Nixpkgs存储库获得)并将其替换为Void Linux musl存储库中的gdb来使其正常工作。我怀疑来自Nixpkgs的gdb是用glibc构建的,并且与编译后的Rust程序不兼容,后者被编译为使用musl。通常,我使用的Bedrock用户空间允许我一起使用由不同的C库构建的程序,但在这种情况下,我想我需要GDB使用与它试图调试的东西相同的C库。
https://stackoverflow.com/questions/69236846
复制相似问题