gdb在启动过程中,用代码127退出 [英] gdb During startup program exited with code 127

查看:289
本文介绍了gdb在启动过程中,用代码127退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望在Linux Debian中使用gdb作为调试器。试图运行一个二进制文件我得到这个:

 (gdb)r 
启动程序:/ usr / local / sbin / test
/ bin / bash:/ usr / local / sbin / test:没有这样的文件或目录
启动程序在代码127中退出。
(gdb)

我想这应该是初级的。但我搜索了很多,最常见的答案是:
$ b $

  $ export SHELL = / bin / bash 

这没有帮助。我也尝试更改PATH以执行二进制文件,尝试从不同的目录运行...仍然是相同的。



请帮助我吗?

解决方案


/ bin / bash:/ usr / local / sbin /测试:没有这样的文件或目录


有两种常见原因:


  1. 文件 / usr / local / sbin / test 不存在

  2. 该文件确实存在,是一个动态链接的可执行文件,它指定的ELF解释程序不存在。

对于#1,答案显而易见:您需要一个文件来进行调试。



对于#2,您可以找出文件需要的ELF解释器: p>

  readelf -l / usr / local / sbin / test | grep解释器

您可能有一个指向 / lib /在没有安装32位运行时支持的64位系统上使用ld-linux.so.2 。根据您使用的发行版本,像 sudo apt-get install libc6:i386 应该有所斩获。


Wanted to use gdb as a debugger in Linux Debian. Trying to run a binary I get this:

(gdb) r
Starting program: /usr/local/sbin/test 
/bin/bash: /usr/local/sbin/test: No such file or directory
During startup program exited with code 127.
(gdb) 

I guess it's supposed to be elementary. But I googled a lot and most common answer is

$ export SHELL=/bin/bash

This doesn't help. I also tried to change PATH for binaries execution, tried to run from different directory... Still the same.

Could you please help me with that?

解决方案

/bin/bash: /usr/local/sbin/test: No such file or directory

There are two common causes of this:

  1. the file /usr/local/sbin/test doesn't exist
  2. the file does exist, is a dynamically linked executable, and the ELF interpreter that it specifies does not exist.

For #1, the answer is obvious: you need a file to debug.

For #2, you can find out which ELF interpreter the file requires like so:

readelf -l /usr/local/sbin/test | grep interpreter

You likely have a 32-bit binary pointing to /lib/ld-linux.so.2 on a 64-bit system without 32-bit runtime support installed. Depending on the distribution you are using, something like sudo apt-get install libc6:i386 should do the trick.

这篇关于gdb在启动过程中,用代码127退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆