我试过了我能找到的关于安装gdb的所有东西,但仍然无法使它工作。
下面是我如何安装和运行gdb:
brew install gdb安装gdbecho "set startup-with-shell off" >> ~/.gdbinit我运行了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 recognizedlibpython.py,但我不知道该如何处理它。/Users/travis/miniconda3/conda-bld/python_1494603145199/work/Python-3.5.3/Programs/python.o'文件夹Update我尝试遵循这里的台阶,我直接使用了通过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
->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,
(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:通过此链接更新来构建~/.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.
发布于 2017-09-28 07:40:00
我在这件事上花了不少时间。您需要从源代码编译它。
请看这里:
在macOS塞拉利昂运行GDB
它对我起作用;)
只要一张便条,一定要在密码上签名!注意事项可以在这里找到:调试器的协同设计
更新:
有关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当涉及到系统完整性保护的细节时,请看这里。
https://stackoverflow.com/questions/46463521
复制相似问题