GDB seg读取符号时出错

gdb seg faults when reading symbols

本文关键字:出错 符号 读取 seg GDB      更新时间:2023-10-16

当试图用程序运行gdb时,它在读取符号时出现错误。

当我运行:

gdb /home/user/path/to/program.exe

:

GNU gdb (Ubuntu 7.7-0ubuntu3.1) 7.7
Copyright (C) 2014 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-linux-gnu".
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"...
Reading symbols from /home/user/path/to/program.exe...Segmentation fault (core dumped)

我怀疑二进制文件可能太大,gdb无法加载到内存中。此错误仅在使用-g(调试标志)进行编译时发生。以下是二进制文件大小的差异:

编译

-release flag: 405 MB

-debug flag: 862 MB

对这个分割错误的其他罪魁祸首有什么想法吗?或者是否有一种方法可以增加gdb允许的内存?这对google来说是一个非常具有挑战性的问题。

我在Ubuntu 15.04 x86_64上有同样的问题,我只是使用apt-get install gdb安装了gdb 7.9

我通过编译和安装以前的版本解决了这个问题:gdb 7.5.1

我必须下载一个库(我在这里找到的),我还必须使用一些参数运行./configure(我在这里找到的)。其他的都很简单。

好运。

命令如下:

$ cd
$ sudo apt-get install libncurses5-dev
$ wget ftp://sourceware.org/pub/gdb/releases/gdb-7.5.1.tar.gz
$ tar zxf gdb-7.5.1.tar.gz
$ cd gdb-7.5.1
$ sudo ./configure --disable-werror
$ sudo make
$ sudo make install

如果你编译时没有使用-g标志,那么你就没有在你的可执行文件中包含调试信息,所以当gdb加载时,要加载的信息要少得多。

如果gdb在启动过程中出现段错误,那么这是一个gdb错误,没有可执行文件可以传递给gdb,导致段错误,最坏的情况下你应该得到一些错误消息。

你可以尝试在gdb下运行gdb,(只执行gdb --args gdb /home/user/path/to/program.exe)这不会对你有多大帮助,但可能会让你对gdb的问题有一些了解,然后你可以在这里提交一个gdb错误:https://sourceware.org/bugzilla/enter_bug.cgi?product=gdb但这只有在你有好的步骤来重现,或者从崩溃的gdb中回溯时才值得这样做。

重新安装gdb可能会有帮助,但我对解决问题不抱太大希望,除非你改变你安装的gdb的版本,gdb本身是一个很容易安装的程序,所以很难出错。

您也可以尝试从git构建gdb,这很容易,并且错误可能已经修复,从这里开始:http://www.gnu.org/software/gdb/current/

如果你用一个崩溃的gdb的回溯来扩展你的问题,那么其他人可能能够为你提供更多关于为什么它会崩溃的见解,但责任肯定是你的gdb版本。