首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >gdb无法正确安装在Mac中

gdb无法正确安装在Mac中
EN

Stack Overflow用户
提问于 2017-09-28 07:37:07
回答 1查看 1.4K关注 0票数 0

我试过了我能找到的关于安装gdb的所有东西,但仍然无法使它工作。

下面是我如何安装和运行gdb:

  1. brew install gdb安装gdb
  2. 然后它告诉我执行以下操作 (实验3.5) ->brew安装gdb更新==>下载https://homebrew.bintray.com/bottles/gdb- 8.0.1.sierra.bottle.tar已经下载:/Users/https://homebrew.bintray.com/bottles/gdb-/8.0.1.sierra.bottle.tar/Caches/Homebrew/GDB-2/GDB-GDB-8.0.1.sierra.ptainle.tar.gz ==>警告gdb需要特殊权限才能访问Mach端口。您将需要协同设计二进制文件。关于指示,见: https://sourceware.org/gdb/wiki/BuildingOnDarwin 在10.12 (塞拉利昂)或更高版本的SIP中,您需要运行以下命令: echo "set startup-with-shell off" >> ~/.gdbinit
  3. 我完成了这两步。我按照这里的精确指令完成了codesign任务
  4. 一切进展顺利。但是,当我运行以下代码时,仍然会收到相同的错误消息

我运行了gdb python test.py并收到了以下消息

代码语言:javascript
复制
(experiment3.5)  ->gdb python signal_test.py
GNU gdb (GDB) 8.0.1
Copyright (C) 2017 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-darwin16.7.0".
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 python...
warning: `/Users/travis/miniconda3/conda-bld/python_1494603145199/work/Python-3.5.3/Programs/python.o': can't open to read symbols: No such file or directory.
(no debugging symbols found)...done.
Python Exception <type 'exceptions.ImportError'> No module named libpython:
"/Users/Natsume/Documents/shendusuipian/pytorch/raw_pytorch/60min_intro/signal_test.py" is not a core dump: File format not recognized
  1. 然后我下载了libpython.py,但我不知道该如何处理它。
  2. 我没有上述警告信息中所述的/Users/travis/miniconda3/conda-bld/python_1494603145199/work/Python-3.5.3/Programs/python.o'文件夹

Update我尝试遵循这里的台阶,我直接使用了通过brew install gdb下载的gdb8.01.tar.gz,但是我在下面得到了错误消息。

代码语言:javascript
复制
Focus on one: /Users/Natsume/Desktop/src/gdb/8.0.1
 ->./configure --prefix=$HOME/opt/usr/local
-bash: ./configure: No such file or directory
Focus on one: /Users/Natsume/Desktop/src/gdb/8.0.1
 ->ls
COPYING         README          share
ChangeLog       bin
INSTALL_RECEIPT.json    include
Focus on one: /Users/Natsume/Desktop/src/gdb/8.0.1
 ->

update --我从上面的链接中运行了代码,并安装、配置了gdb8.0,但是,我没有$HOME/opt/usr/local文件夹,而只有/opt/usr/local。因此,虽然./configure --prefix=$HOME/opt/usr/local运行过,但我仍然不能运行codesign -f -s "gdb-cert" <gnat_install_prefix>/bin/gdb,因为没有$HOME/opt/usr/local

更新

对于上面的链接,我可以安装gdb 8.0,但不能运行gfortran

代码语言:javascript
复制
(experiment3.5)  ->gfortran
-bash: gfortran: command not found

我也不能成功地运行gdb python test.py

代码语言:javascript
复制
(experiment3.5)  ->gdb --args python signal_test.py
GNU gdb (GDB) 8.0
Copyright (C) 2017 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-darwin16.7.0".
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 python...
warning: `/Users/travis/miniconda3/conda-bld/python_1494603145199/work/Python-3.5.3/Programs/python.o': can't open to read symbols: No such file or directory.
(no debugging symbols found)...done.
Python Exception <type 'exceptions.ImportError'> No module named libpython:

通过此链接更新来构建~/.gdbinit可以消除No module named libpython的错误,但是仍然存在警告或更大的问题。

警告:/Users/travis/miniconda3/conda-bld/python_1494603145199/work/Python-3.5.3/Programs/python.o': can't open to read symbols: No such file or directory. (no debugging symbols found)...done.

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-09-28 07:40:00

我在这件事上花了不少时间。您需要从源代码编译它。

请看这里:

在macOS塞拉利昂运行GDB

它对我起作用;)

只要一张便条,一定要在密码上签名!注意事项可以在这里找到:调试器的协同设计

更新:

有关python的内容,请看这里的

http://unconj.ca/blog/setting-up-gdb-for-debugging-python-on-os-x.html

对于gdb本身

它应该足够用下面的方式测试它。

代码语言:javascript
复制
// simple.c
#include <stdio.h>

int main() {
  printf("Hello\n");
  return 0;
}

然后

代码语言:javascript
复制
# assuming that gdb is signed
cc -g -o simple simple.c
gdb ./simple

更新-系统完整性保护

当涉及到某些区域(例如/usr/bin)时,您将无法访问那里,因为系统完整性保护是开着的。你需要关掉它:

代码语言:javascript
复制
# You need to boot to Recovery OS in a first place (before you call csrutil)
> csrutil disable

# you can also use another location as output
> lipo /usr/bin/python -thin x86_64 -output ~/python64

当涉及到系统完整性保护的细节时,请看这里。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46463521

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档