• <legend id='dYVBg'><style id='dYVBg'><dir id='dYVBg'><q id='dYVBg'></q></dir></style></legend>

    <small id='dYVBg'></small><noframes id='dYVBg'>

      <tfoot id='dYVBg'></tfoot>

      • <bdo id='dYVBg'></bdo><ul id='dYVBg'></ul>

      1. <i id='dYVBg'><tr id='dYVBg'><dt id='dYVBg'><q id='dYVBg'><span id='dYVBg'><b id='dYVBg'><form id='dYVBg'><ins id='dYVBg'></ins><ul id='dYVBg'></ul><sub id='dYVBg'></sub></form><legend id='dYVBg'></legend><bdo id='dYVBg'><pre id='dYVBg'><center id='dYVBg'></center></pre></bdo></b><th id='dYVBg'></th></span></q></dt></tr></i><div id='dYVBg'><tfoot id='dYVBg'></tfoot><dl id='dYVBg'><fieldset id='dYVBg'></fieldset></dl></div>
      2. 如何在 virtualenv 中使用 gdb python 调试扩展

        时间:2023-08-29

        <legend id='OehHv'><style id='OehHv'><dir id='OehHv'><q id='OehHv'></q></dir></style></legend>
        • <i id='OehHv'><tr id='OehHv'><dt id='OehHv'><q id='OehHv'><span id='OehHv'><b id='OehHv'><form id='OehHv'><ins id='OehHv'></ins><ul id='OehHv'></ul><sub id='OehHv'></sub></form><legend id='OehHv'></legend><bdo id='OehHv'><pre id='OehHv'><center id='OehHv'></center></pre></bdo></b><th id='OehHv'></th></span></q></dt></tr></i><div id='OehHv'><tfoot id='OehHv'></tfoot><dl id='OehHv'><fieldset id='OehHv'></fieldset></dl></div>
            <tfoot id='OehHv'></tfoot>

              <small id='OehHv'></small><noframes id='OehHv'>

                • <bdo id='OehHv'></bdo><ul id='OehHv'></ul>
                    <tbody id='OehHv'></tbody>
                • 本文介绍了如何在 virtualenv 中使用 gdb python 调试扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在运行 ubuntu,并安装了 python-dbg 包.尝试直接使用已安装的版本时,一切正常:

                  I'm running ubuntu, and installed the python-dbg package. When trying to use the installed version directly everything works great:

                  $ gdb python2.7-dbg
                  GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
                  ---x snipped x---
                  Reading symbols from /usr/bin/python2.7-dbg...done.
                  (gdb) r
                  Starting program: /usr/bin/python2.7-dbg
                  [Thread debugging using libthread_db enabled]
                  Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
                  Python 2.7.3 (default, Feb 27 2014, 19:39:25)
                  [GCC 4.6.3] on linux2
                  Type "help", "copyright", "credits" or "license" for more information.
                  >>>
                  Program received signal SIGINT, Interrupt.
                  0x00007ffff6997743 in __select_nocancel () at ../sysdeps/unix/syscall-template.S:82
                  82      ../sysdeps/unix/syscall-template.S: No such file or directory.
                  (gdb) py-bt (<--- works, just has nothing to do)
                  (gdb)
                  

                  所以,我一直在使用包的二进制 python2.7-dbg 构建一个 virtualenv(因为某些库需要重新编译),使用这个命令行:

                  So, I've been building a virtualenv using the package's binary python2.7-dbg (since some libraries need recompiling), using this command line:

                  ~$ virtualenv ved -p /usr/bin/python2.7-dbg
                  

                  一切正常,但是当我在 virtualenv 中使用 gdb 时,至少 python 漂亮的打印机停止工作:

                  Its all working fine, but when I'm using gdb inside the virtualenv, atleast the python pretty printers stop working:

                  ~$ . ved/bin/activate
                  (ved)~$ gdb python
                  GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
                  ---x snipped x---
                  Reading symbols from /home/itai/ved/bin/python...done.
                  (gdb) r
                  Starting program: /home/itai/ved/bin/python
                  [Thread debugging using libthread_db enabled]
                  Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
                  Python 2.7.3 (default, Feb 27 2014, 19:39:25)
                  [GCC 4.6.3] on linux2
                  Type "help", "copyright", "credits" or "license" for more information.
                  >>>
                  Program received signal SIGINT, Interrupt.
                  0x00007ffff6997743 in __select_nocancel () at ../sysdeps/unix/syscall-template.S:82
                  82      ../sysdeps/unix/syscall-template.S: No such file or directory.
                  (gdb) py-bt
                  Undefined command: "py-bt".  Try "help". (<---- PROBLEM)
                  (gdb)
                  

                  我的 virtualenv 中是否缺少某些内容?

                  Am I missing something within my virtualenv?

                  推荐答案

                  我已经通过在 gdb 上使用 strace 解决了这个问题,grepping "open" 系统调用.

                  I've solved the problem by using strace on gdb, grepping the "open" syscalls.

                  gdb 似乎在它猜测的几个路径中搜索 python-gdb.py(根据 python 二进制文件),每当找不到该文件时,它就会默默地失败.

                  It seems that gdb makes a search for python-gdb.py in several paths it guesses (according to the python binary), and whenever the file is not found it just fails silently.

                  最终解决问题的方法是将 /usr/lib/debug/usr/bin/python2.7-gdb.py 链接到 env 的 bin 目录中.链接的名称应该是 <python 二进制名称>-gdb.py,在我的例子中是 python2.7-dbg-gdb.py (...).

                  Eventually the way to solve the problem is to link /usr/lib/debug/usr/bin/python2.7-gdb.py into the env's bin directory. The name of the link should be <python binary name>-gdb.py, being in my case python2.7-dbg-gdb.py (...).

                  在那之后,一切似乎都正常了.

                  After that, everything seems to work.

                  这篇关于如何在 virtualenv 中使用 gdb python 调试扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在 Windows 上调试 Python 的 C 扩展 下一篇:如何为 Windows 获取预构建的 *debug* 版本的 Python 库(例如 Python27_d.dll)

                  相关文章

                      <bdo id='J2BLo'></bdo><ul id='J2BLo'></ul>
                    <tfoot id='J2BLo'></tfoot>
                  1. <legend id='J2BLo'><style id='J2BLo'><dir id='J2BLo'><q id='J2BLo'></q></dir></style></legend>

                    <small id='J2BLo'></small><noframes id='J2BLo'>

                    1. <i id='J2BLo'><tr id='J2BLo'><dt id='J2BLo'><q id='J2BLo'><span id='J2BLo'><b id='J2BLo'><form id='J2BLo'><ins id='J2BLo'></ins><ul id='J2BLo'></ul><sub id='J2BLo'></sub></form><legend id='J2BLo'></legend><bdo id='J2BLo'><pre id='J2BLo'><center id='J2BLo'></center></pre></bdo></b><th id='J2BLo'></th></span></q></dt></tr></i><div id='J2BLo'><tfoot id='J2BLo'></tfoot><dl id='J2BLo'><fieldset id='J2BLo'></fieldset></dl></div>