读取符号时gdb seg出错

Str*_*mer 6 c++ memory debugging gdb

尝试使用程序运行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)
Run Code Online (Sandbox Code Playgroud)

我怀疑二进制文件可能太大,无法将gdb加载到内存中.只有在使用-g(调试标志)进行编译时才会出现此错误.这是二进制文件大小的差异:

编译

-release flag: 405 MB

-debug flag: 862 MB

有关此分段错误的其他罪魁祸首的任何想法?或者有没有办法增加gdb允许的内存?这对google来说是一个非常具有挑战性的问题.

Gir*_*rdi 5

gdb 7.9我在on上遇到了同样的问题Ubuntu 15.04 x86_64,我只是使用apt-get install gdb.

我通过编译并安装以前的版本解决了这个问题: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
Run Code Online (Sandbox Code Playgroud)


And*_*rew 2

如果您在不使用 -g 标志的情况下进行编译,则不会在可执行文件中包含调试信息,因此当 gdb 加载时,需要加载的信息要少得多。

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

您可以尝试在 gdb 下运行 gdb,(只需这样做gdb --args gdb /home/user/path/to/program.exe)这不会对您有太大帮助,但可能会让您深入了解 gdb 的问题,然后您可以在此处提交 gdb bug: https: //sourceware.org/bugzilla/ Enter_bug.cgi?product=gdb但这仅在您有良好的重现步骤或来自崩溃的 gdb 的回溯时才值得这样做。

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

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

如果您使用崩溃的 gdb 的回溯来扩展您的问题,那么其他人可能能够为您提供更多有关崩溃原因的见解,但问题肯定在于您的 gdb 版本。