简体   繁体   English

使用gdb针对C模块进行Python源调试

[英]Python source debugging with gdb for a C Module

So I'm getting a SIGSEGV signal from my Python C Module. 因此,我从Python C模块收到了SIGSEGV信号。 The module has been tested/built in Windows and now I'm attempting to use it under Linux (Linux Mint 17 64-bit). 该模块已在Windows中测试/构建,现在我正尝试在Linux(Linux Mint 17 64位)下使用它。 I'm very new to gdb but is there a way to get it to show Python's Source code? 我对gdb还是很陌生,但是有办法让它显示Python的源代码吗?

Program received signal SIGSEGV, Segmentation fault.
PyErr_SetObject (exception=0xae3818, value=0x7ffff7e229f0) at ../Python/errors.c:70
70      ../Python/errors.c: No such file or directory.

stack trace (Filtered): 堆栈跟踪(已过滤):

(gdb) bt
#0  PyErr_SetObject (exception=0xae3818, value=0x7ffff7e229f0) at ../Python/errors.c:70
#1  0x000000000043675f in PyErr_SetString (exception=0xae3818, string=<optimized out>) at ../Python/errors.c:147
...

List of installed packages: 已安装软件包的列表:

> dpkg-query -l |grep python3
ii  libpython3-dbg:amd64                        3.4.0-0ubuntu2                                     amd64        debug build of the Python 3 Interpreter (version 3.4)
ii  libpython3-dev:amd64                        3.4.0-0ubuntu2                                     amd64        header files and a static library for Python (default)
ii  libpython3-stdlib:amd64                     3.4.0-0ubuntu2                                     amd64        interactive high-level object-oriented language (default python3 version)
ii  libpython3.4:amd64                          3.4.0-2ubuntu1                                     amd64        Shared Python runtime library (version 3.4)
ii  libpython3.4-dbg:amd64                      3.4.0-2ubuntu1                                     amd64        Debug Build of the Python Interpreter (version 3.4)
ii  libpython3.4-dev:amd64                      3.4.0-2ubuntu1                                     amd64        Header files and a static library for Python (v3.4)
ii  libpython3.4-minimal:amd64                  3.4.0-2ubuntu1                                     amd64        Minimal subset of the Python language (version 3.4)
ii  libpython3.4-stdlib:amd64                   3.4.0-2ubuntu1                                     amd64        Interactive high-level object-oriented language (standard library, version 3.4)
ii  python3                                     3.4.0-0ubuntu2                                     amd64        interactive high-level object-oriented language (default python3 version)
ii  python3-apt                                 0.9.3.5                                            amd64        Python 3 interface to libapt-pkg
ii  python3-aptdaemon                           1.1.1-1ubuntu5.1                                   all          Python 3 module for the server and client of aptdaemon
ii  python3-aptdaemon.gtk3widgets               1.1.1-1ubuntu5.1                                   all          Python 3 GTK+ 3 widgets to run an aptdaemon client
ii  python3-aptdaemon.pkcompat                  1.1.1-1ubuntu5.1                                   all          PackageKit compatibilty for AptDaemon
ii  python3-cairo                               1.10.0+dfsg-3ubuntu2                               amd64        Python 3 bindings for the Cairo vector graphics library
ii  python3-chardet                             2.0.1-1                                            all          universal encoding detector
ii  python3-commandnotfound                     0.3ubuntu12                                        all          Python 3 bindings for command-not-found.
ii  python3-dbg                                 3.4.0-0ubuntu2                                     amd64        debug build of the Python 3 Interpreter (version 3.4)
ii  python3-dbus                                1.2.0-2build2                                      amd64        simple interprocess messaging system (Python 3 interface)
ii  python3-dbus.mainloop.qt                    4.10.4+dfsg-1ubuntu1                               amd64        D-Bus Support for PyQt4 with Python 3
ii  python3-debian                              0.1.21+nmu2ubuntu2                                 all          Python 3 modules to work with Debian-related data formats
ii  python3-defer                               1.0.6-2build1                                      all          Small framework for asynchronous programming (Python 3)
ii  python3-dev                                 3.4.0-0ubuntu2                                     amd64        header files and a static library for Python (default)
ii  python3-gdbm:amd64                          3.4.0-0ubuntu1                                     amd64        GNU dbm database support for Python 3.x
ii  python3-gi                                  3.12.0-1ubuntu1                                    amd64        Python 3 bindings for gobject-introspection libraries
ii  python3-gi-cairo                            3.12.0-1ubuntu1                                    amd64        Python 3 Cairo bindings for the GObject library
ii  python3-icu                                 1.5-2ubuntu4                                       amd64        Python 3 extension wrapping the ICU C++ API
ii  python3-minimal                             3.4.0-0ubuntu2                                     amd64        minimal subset of the Python language (default python3 version)
ii  python3-pkg-resources                       3.3-1ubuntu1                                       all          Package Discovery and Resource Access using pkg_resources
ii  python3-problem-report                      2.14.1-0ubuntu3.5                                  all          Python 3 library to handle problem reports
ii  python3-pyicu                               1.5-2ubuntu4                                       amd64        dummy transitional package for PyICU Python 3 extension
ii  python3-six                                 1.5.2-1                                            all          Python 2 and 3 compatibility library (Python 3 interface)
ii  python3-xkit                                0.5.0ubuntu2                                       all          library for the manipulation of xorg.conf files (Python 3)
ii  python3.4                                   3.4.0-2ubuntu1                                     amd64        Interactive high-level object-oriented language (version 3.4)
ii  python3.4-dbg                               3.4.0-2ubuntu1                                     amd64        Debug Build of the Python Interpreter (version 3.4)
ii  python3.4-dev                               3.4.0-2ubuntu1                                     amd64        Header files and a static library for Python (v3.4)
ii  python3.4-minimal                           3.4.0-2ubuntu1                                     amd64        Minimal subset of the Python language (version 3.4)

If you want gdb to show you the code in a file, you need to tell it where to look for the file. 如果希望gdb向您显示文件中的代码,则需要告诉它在哪里查找文件。

You can do this using the directory command followed by the path to the source files. 您可以使用directory命令执行此操作,后跟源文件的路径。

More info here 更多信息在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用GDB进行Python内存调试 - Python memory debugging with GDB Python:使用gdb进行调试(在OSX上) - Python: debugging with gdb (on OSX) 错误调试玩具示例 c++ 库 Python 与 GDB (与加载共享库有关的 GDB 问题?) - Error Debugging toy example c++ Library for Python with GDB (GDB problem relating to loading shared libraries?) Linux内核调试:“ Python异常 <class 'gdb.error'> 尝试在gdb中使用帮助程序脚本时,没有名为module_core的成员。 - Linux Kernel Debugging: “Python Exception <class 'gdb.error'> There is no member named module_core.” when trying to use helper scripts in gdb GDB Python 支持,ImportError 没有名为 gdb 的模块 - GDB Python support, ImportError no module named gdb 在GDB,C ++中调试OpenCV矩阵 - Debugging OpenCV matrices in GDB, C++ 调试:使用 gdb 单步调试 Python 脚本? - Debugging: stepping through Python script using gdb? 如何在调试 python C 扩展时设置断点并执行其他 gdb 命令 - how to set a breakpoint and execute other gdb commands while debugging python C extension 如何在调试 C 程序时将 gdb 值转换为 python 数字 object - How to convert a gdb Value to a python numeral object while debugging C program 调试c ++程序时出现GDB cv :: Mat python对象问题 - GDB cv::Mat python object issue when debugging a c++ program
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM