简体   繁体   English

读取符号时gdb seg出错

[英]gdb seg faults when reading symbols

When trying to run gdb with a program, it seg faults while reading symbols. 尝试使用程序运行gdb时,它会在读取符号时出错。

When I run: 当我跑:

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

I get: 我明白了:

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)

I suspect that the binary might be too large for gdb to load into memory. 我怀疑二进制文件可能太大,无法将gdb加载到内存中。 This error only occurs when I compile with -g (debug flag). 只有在使用-g(调试标志)进行编译时才会出现此错误。 Here's the difference in size of the binaries: 这是二进制文件大小的差异:

Compiled with 编译

-release flag: 405 MB

-debug flag: 862 MB

Any ideas on other culprits of this segmentation fault? 有关此分段错误的其他罪魁祸首的任何想法? Or is there a way to increase the memory allowed for gdb? 或者有没有办法增加gdb允许的内存? This turns out to be a very challenging problem to google. 这对google来说是一个非常具有挑战性的问题。

I was having the same problem with gdb 7.9 on Ubuntu 15.04 x86_64 , which I had installed simply using apt-get install gdb . 我在Ubuntu 15.04 x86_64上遇到了与gdb 7.9相同的问题,我刚刚使用apt-get install gdb

I solved the problem by compiling and installing a previous version: gdb 7.5.1 . 我通过编译和安装以前的版本解决了这个问题: gdb 7.5.1

I had to download a library (which I found out here ) and I also had to run ./configure using some arguments (which I found out here ). 我必须下载一个库(我在这里找到),我还必须使用一些参数运行./configure (我在这里找到)。 Everything else is straightforward. 其他一切都很简单。

Good luck. 祝好运。

Here are the commands: 以下是命令:

$ 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

If you compile without the -g flag then you are not including debugging information in your executable, so when gdb loads there's much less information to load in. 如果您在没有-g标志的情况下进行编译,那么您不会在可执行文件中包含调试信息,因此当gdb加载时,加载的信息要少得多。

If gdb segfaults during start up then this is a gdb bug, there's no executable that you should be able to pass to gdb that should cause a segfault, at worst you should get some error message. 如果在启动期间gdb段错误,则这是一个gdb错误,没有可执行文件,你应该能够传递给应该导致段错误的gdb,最坏的情况是你应该得到一些错误消息。

You could try running gdb under gdb, (just do gdb --args gdb /home/user/path/to/program.exe ) this will not help you much, but might give some insight into what is wrong with gdb, you could then file a gdb bug here: https://sourceware.org/bugzilla/enter_bug.cgi?product=gdb but this is only worth doing if you either have good steps to reproduce, or a backtrace from a crashed gdb. 您可以尝试在gdb下运行gdb,(只需要执行gdb --args gdb /home/user/path/to/program.exe )这对您没有多大帮助,但可能会对gdb的问题有所了解,你可以然后在这里提交一个gdb错误: https//sourceware.org/bugzilla/enter_bug.cgi? product = gdb但是如果你有很好的重现步骤,或者从崩溃的gdb中回溯,这个值得做。

Reinstalling gdb might help, but I wouldn't hold much hope of that solving the problem, unless you change the version of gdb you install, gdb itself is a pretty easy program to install, so pretty hard to get wrong. 重新安装gdb可能会有所帮助,但我不太希望解决这个问题,除非你改变你安装的gdb版本,gdb本身是一个非常容易安装的程序,所以很难出错。

You could also try building gdb from git, it's pretty easy, and the bug might have already been fixed, start from here: http://www.gnu.org/software/gdb/current/ 你也可以尝试从git构建gdb,这很容易,并且bug可能已经修复,从这里开始: http//www.gnu.org/software/gdb/current/

If you extend your question with a backtrace from a crashed gdb then others might be able to offer you more of an insight into why this is crashing, but the blame is definitely with your version of gdb. 如果你使用崩溃的gdb中的回溯扩展你的问题,那么其他人可能能够让你更深入地了解崩溃的原因,但是责任肯定是你的gdb版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM