gpt4 book ai didi

debugging - gdb 无法在 gdbserver (Rust x64) 上运行 'elf64-x86-64' 格式

转载 作者:行者123 更新时间:2023-12-03 11:27:09 27 4
gpt4 key购买 nike

我正在尝试使用 gdbserver 远程调试 Rust 可执行文件在远程机器上和 gdb在本地机器上。我设置了一个 Vagrant VM (bento/ubuntu-18.04) 并启动了一个 gdbserver :

$ vagrant ssh
$ uname -a

Linux dev 4.15.0-121-generic #123-Ubuntu SMP Mon Oct 5 16:16:40 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

$ gdbserver --version

GNU gdbserver (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc.
gdbserver is free software, covered by the GNU General Public License.
This gdbserver was configured as "x86_64-linux-gnu"

$ cargo run
$ file ./target/debug/my-app

./target/debug/my-app: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=31b1870cf7ef9e35ebe980acedf7eeaad694bb60, with debug_info, not stripped

$ gdbserver localhost:2000 ./target/debug/my-app

Process ./target/debug/my-app created; pid = 3851
Listening on port 2000
在我的本地 macOS 工作站上:
$ uname -a

Darwin XXX 20.1.0 Darwin Kernel Version 20.1.0: Sat Oct 31 00:07:11 PDT 2020; root:xnu-7195.50.7~2/RELEASE_X86_64 x86_64

$ gdb

GNU gdb (GDB) 10.1
Copyright (C) 2020 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 help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) target remote localhost:2000
Remote debugging using localhost:2000
Reading /vagrant/target/debug/my-app from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading /vagrant/target/debug/my-app from remote target...
Reading symbols from target:/vagrant/target/debug/my-app...
warning: I'm sorry, Dave, I can't do that. Symbol format `elf64-x86-64' unknown.
Reading /lib64/ld-linux-x86-64.so.2 from remote target...
Reading /lib64/ld-linux-x86-64.so.2 from remote target...
Reading symbols from target:/lib64/ld-linux-x86-64.so.2...
Error while reading shared library symbols for target:/lib64/ld-linux-x86-64.so.2:
I'm sorry, Dave, I can't do that. Symbol format `elf64-x86-64' unknown.
[1] 16617 abort gdb
这里出了什么问题?

最佳答案

我在 macOS Catalina 上遇到了类似的问题:

GDB failed with message: I'm sorry, Dave, I can't do that.  Symbol format `elf64-x86-64' unknown.
我可以通过从源代码构建并指定正确的目标来解决它:
  • 下载gdb源码,解压,cd进去
  • https://ftp.gnu.org/gnu/gdb/gdb-10.1.tar.xz

  • ./configure --target=amd64-linux
  • make
  • sudo make install
  • (VS Code 可选)添加 "miDebuggerPath": "/usr/local/bin/amd64-linux-gdb"

  • 二进制安装在“/usr/local/bin/amd64-linux-gdb”中,可以用 amd64-linux-gdb在一个终端。
    如果这不起作用,请在构建之前尝试这些建议的修改:
  • https://unix.stackexchange.com/questions/624486/gdb-installed-from-homebrew-on-macos-big-sur-fails-to-load-symbols-from-elf32-i3
  • https://www.cygwin.com/bugzilla/show_bug.cgi?id=26949

  • 更新
    该方法与 Apple clang version 11.0.3 (clang-1103.0.32.29)有时与 Apple clang version 12.0.0 (clang-1200.0.32.28) .

    关于debugging - gdb 无法在 gdbserver (Rust x64) 上运行 'elf64-x86-64' 格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65019289/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com