Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python gdb可以';不能在Mac Sierra中正确安装_Python_C_Macos_Gdb - Fatal编程技术网

Python gdb可以';不能在Mac Sierra中正确安装

Python gdb可以';不能在Mac Sierra中正确安装,python,c,macos,gdb,Python,C,Macos,Gdb,我尝试了所有我能找到的关于安装gdb的方法,但仍然无法使它工作 以下是我如何安装和运行gdb: 使用brew安装gdb安装gdb 然后它告诉我做以下事情 (3.5)->brew安装gdb 正在更新自制。。。 ==>下载 8.0.1.sierra.瓶子.焦油 已下载:/Users/Natsume/Library/Caches/Homebrew/gdb- 8.0.1.sierra.bottle.tar.gz ==>浇注gdb-8.0.1.sierra.bottle.tar.gz ==>注意事项 gd

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

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

  • 使用
    brew安装gdb安装gdb

  • 然后它告诉我做以下事情

    (3.5)->brew安装gdb 正在更新自制。。。 ==>下载 8.0.1.sierra.瓶子.焦油 已下载:/Users/Natsume/Library/Caches/Homebrew/gdb- 8.0.1.sierra.bottle.tar.gz ==>浇注gdb-8.0.1.sierra.bottle.tar.gz ==>注意事项 gdb需要特殊权限才能访问Mach端口。 您需要对二进制文件进行代码设计。有关说明,请参阅:

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

    echo“关闭外壳设置启动”>~/.gdbinit

  • 我确实完成了这两个步骤。我按照确切的指示完成了代码设计任务

  • 一切进展顺利。但是,当我运行以下代码时,仍然会收到相同的错误消息
  • 我运行了
    gdbpythontest.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
    
    更新 我从上面的链接运行了代码,安装并配置了gdb8.0,但是,我没有一个文件夹作为
    $HOME/opt/usr/local
    ,只有
    /opt/usr/local
    。因此,虽然
    /configure--prefix=$HOME/opt/usr/local
    已运行,但我仍然无法运行
    codesign-f-s“gdb cert”/bin/gdb
    ,因为没有
    $HOME/opt/usr/local

    更新

    正是为了支持上面的链接,我可以安装
    gdb8.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:
    
    (实验3.5)->gdb--args python signal_test.py
    GNU gdb(gdb)8.0
    版权所有(C)2017免费软件基金会。
    许可证GPLv3+:GNU GPL版本3或更高版本
    这是自由软件:您可以自由更改和重新发布它。
    在法律允许的范围内,不存在任何担保。键入“显示复制”
    和“显示保修”了解详细信息。
    此GDB配置为“x86_64-apple-darwin16.7.0”。
    键入“显示配置”以获取配置详细信息。
    有关错误报告说明,请参阅:
    .
    在线查找GDB手册和其他文档资源,网址为:
    .
    要获得帮助,请键入“帮助”。
    键入“apropos word”以搜索与“word”相关的命令。。。
    正在从python读取符号。。。
    警告:`/Users/travis/miniconda3/conda bld/python1494603145199/work/python-3.5.3/Programs/python.o':无法打开以读取符号:没有此类文件或目录。
    (未找到调试符号)…完成。
    Python异常没有名为libpython的模块:
    
    更新 通过构建
    ~/.gdbinit
    可以消除
    没有模块libpython
    的错误;然而,警告或更大的问题仍然存在

    警告:
    /Users/travis/miniconda3/conda bld/python_1494603145199/work/python-3.5.3/Programs/python.o”:无法打开以读取符号:没有此类文件或目录。
    (未找到调试符号)…完成。


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

    请看这里:

    它对我有用;)

    只需一张便条,确保代码签名!注意事项可在此处找到:

    更新:

    有关python的内容,请查看此处

    至于gdb本身

    按照下面的方法进行测试就足够了

    // simple.c
    #include <stdio.h>
    
    int main() {
      printf("Hello\n");
      return 0;
    }
    
    更新-系统完整性保护

    当涉及到某些区域(例如/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
    

    有关的详细信息,请查看此处。

    非常感谢您的快速回复,我将立即进行尝试。我尝试过,但收到错误消息说
    /configure:没有这样的文件或目录
    ,我哪里做错了?我已经更新了以上问题中的详细信息。我完全按照您的代码进行了操作,安装了gdb 8.0,但仍然无法工作,请更新我的最新版本。你知道为什么吗?非常感谢!我会继续努力!顺便说一下,atom gdb调试器似乎又能工作了。我试图用你的链接解决python问题。python链接对我不起作用。问题似乎是
    (实验3.5)->lipo/usr/bin/python-thin x86_64-output/usr/bin/python64致命错误:/Applications/Xcode.app/Contents/Developer/toolschains/XcodeDefault.xtoolschain/usr/bin/lipo:无法创建输出文件:/usr/bin/python64(不允许操作)
    # assuming that gdb is signed
    cc -g -o simple simple.c
    gdb ./simple
    
    # 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