gpt4 book ai didi

python - gdb 无法在 Mac Sierra 中正确安装

转载 作者:行者123 更新时间:2023-11-30 14:54:49 25 4
gpt4 key购买 nike

我尝试了所有能找到的关于安装 gdb 的方法,但仍然无法使其工作。

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

  1. 使用 brew install gdb 安装 gdb

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

    (experiment3.5) ->brew 安装 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
  • 然后我确实下载了libpython.py ,但我不知道该怎么办。
  • 我没有这样的文件夹/Users/travis/miniconda3/conda-bld/python_1494603145199/work/Python-3.5.3/Programs/python.o'如上面警告消息中所述
  • 更新我试图关注the steps here ,我直接用了gdb8.01.tar.gz通过brew install gdb下载,但我在下面收到错误消息。

    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" <gnat_install_prefix>/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 build ~/.gdbinit可以摆脱 No module named libpython 的错误已解决;但是,警告或更大的问题仍然存在

    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.

    最佳答案

    我在这个问题上花了相当多的时间。您需要从源代码编译它。

    看这里:

    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的详细信息请看这里.

    关于python - gdb 无法在 Mac Sierra 中正确安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46463521/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com