【问题标题】:gdb can't be properly installed in Mac Sierragdb 无法在 Mac Sierra 中正确安装
【发布时间】:2018-03-09 20:46:05
【问题描述】:

我尝试了所有关于安装 gdb 的方法,但仍然无法正常工作。

这是我安装和运行 gdb 的方法:

  1. brew install gdb安装gdb

  2. 然后它告诉我执行以下操作

    (experiment3.5) ->brew install gdb 正在更新自制... ==> 正在下载https://homebrew.bintray.com/bottles/gdb- 8.0.1.sierra.bottle.tar 已经下载:/Users/Natsume/Library/Caches/Homebrew/gdb- 8.0.1.sierra.bottle.tar.gz ==> 倒 gdb-8.0.1.sierra.bottle.tar.gz ==> 警告 gdb 需要特殊权限才能访问 Mach 端口。 您将需要对二进制文件进行代码签名。有关说明,请参阅:
    https://sourceware.org/gdb/wiki/BuildingOnDarwin

    在 10.12 (Sierra) 或更高版本的 SIP 上,您需要运行以下命令:

    echo "set startup-with-shell off" >> ~/.gdbinit

  3. 我确实完成了这两个步骤。我按照确切的说明完成了协同设计任务here

  4. 一切顺利。但是,当我运行以下代码时,我仍然收到相同的错误消息

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

(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' 文件夹

更新 我曾尝试关注the steps here,我直接使用通过brew install gdb 下载的gdb8.01.tar.gz,但我收到以下错误消息。

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
 ->

更新 我从上面的链接运行代码,并安装、配置了 gdb8.0,但是,我没有$HOME/opt/usr/local 的文件夹,而只有/opt/usr/local。所以虽然./configure --prefix=$HOME/opt/usr/local跑通了,但是codesign -f -s "gdb-cert" &lt;gnat_install_prefix&gt;/bin/gdb还是跑不掉,因为没有$HOME/opt/usr/local

更新

完全按照上面的链接,我可以安装gdb 8.0,但我不能运行gfortran

(experiment3.5)  ->gfortran
-bash: gfortran: command not found

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

(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:

更新 通过this link构建~/.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.

【问题讨论】:

    标签: python c macos gdb


    【解决方案1】:

    我在这个上花了很长时间。您需要从源代码编译它。

    看这里:

    Running GDB in macOS sierra

    它对我有用;)

    只需一个注释,请确保对其进行代码签名!注释可以在这里找到:Codesigning the Debugger

    更新:

    对于 python 的东西,看看这里

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

    至于 gdb 本身

    按照以下方式测试应该足够了

    // simple.c
    #include <stdio.h>
    
    int main() {
      printf("Hello\n");
      return 0;
    }
    

    然后

    # assuming that gdb is signed
    cc -g -o simple simple.c
    gdb ./simple
    

    更新 - 系统完整性保护

    当涉及到某些区域(例如 /usr/bin)时,由于系统完整性保护已开启,您将无法访问那里。您需要将其关闭:

    # 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
    

    这里有System Integrity Protection的详细信息。

    【讨论】:

    • 非常感谢您的快速回复,我现在试试
    • 我试过但收到错误消息说./configure: no such file or dir,我哪里做错了?我已经更新了上述问题中的详细信息
    • 我完全按照您的代码安装了 gdb 8.0,但仍然无法正常工作,请更新我的最新版本。你知道为什么吗?
    • 非常感谢!我会继续努力的!顺便说一句,atom gdb 调试器似乎又可以工作了。我正在尝试使用您的链接解决 python 问题。
    • python 链接对我不起作用。问题似乎是(experiment3.5) -&gt;lipo /usr/bin/python -thin x86_64 -output /usr/bin/python64 fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: can't create output file: /usr/bin/python64 (Operation not permitted)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-06
    • 2017-05-24
    • 2019-07-25
    • 1970-01-01
    • 1970-01-01
    • 2017-10-13
    • 1970-01-01
    相关资源
    最近更新 更多