本文介绍了Ubuntu 14.04,gcc 4.8.4:由于Python问题,gdb漂亮打印不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 使用主机libthread_db库/ lib / x86_64- Linux的GNU /的libthread_db.so.1\" 。 
Traceback(最近的最后一次调用):
文件/usr/share/gdb/auto-load/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19-gdb.py ,第63行,在< module>
from libstdcxx.v6.printers import register_libstdcxx_printers
ImportError:没有名为'libstdcxx'的模块

Google发布了这个错误报告:
这个错误报告列表在gdb提示符下使用命令 python print sys.path 。然而,当我尝试在gdb提示符上使用任何python时,会发生以下情况:

 (gdb)python print sys.path 
文件< string>,第1行
打印sys.path
^
SyntaxError:无效语法
执行Python代码时出错。

(gdb)python printHello
文件< string>,第1行
printHellO
^
SyntaxError:invalid语法
执行Python代码时出错。

我使用Ubuntu 14.04 LTS,相关版本信息:

  $ gcc --version 
gcc(Ubuntu 4.8.4-2ubuntu1〜14.04)4.8.4
$ gdb --version
GNU gdb(Ubuntu 7.7.1-0ubuntu5〜14.04.2)7.7.1
$ python --version
Python 2.7.6

显然,我的设置中的某些内容已损坏。它是python,gdb还是其他的东西?

解决方案

我发布这个答案,以便其他人更容易找到它。总结一下,以下是我的工作成果:




ul>
  • 创建〜/ .gdbinit文件

  • 添加 python sys.path.append(/ usr / share / gcc-4.8 / python); 至该文件



  • 我使用Eclipse CDT,正在窗口>​​首选项> GDB> GDB命令文件中使用。


    I'm getting this error when launching a program in gdb:

    Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
    Traceback (most recent call last):
    File "/usr/share/gdb/auto-load/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19-gdb.py", line 63, in <module>
    from libstdcxx.v6.printers import register_libstdcxx_printers
    ImportError: No module named 'libstdcxx'
    

    Google turned up this bug report: http://osdir.com/ml/debian-gcc/2014-02/msg00061.htmlThis bug report list using the command python print sys.path on the gdb prompt. However, when I try to use any python on the gdb prompt, this happens:

    (gdb) python print sys.path
    File "<string>", line 1
    print sys.path
            ^
    SyntaxError: invalid syntax
    Error while executing Python code.
    
    (gdb) python print "Hello"
    File "<string>", line 1
    print "HellO"
                ^
    SyntaxError: invalid syntax
    Error while executing Python code.
    

    I'm using Ubuntu 14.04 LTS, relevant version information:

    $ gcc --version
    gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
    $ gdb --version
    GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
    $ python --version
    Python 2.7.6
    

    Clearly, something in my setup is broken. Is it python, gdb, or something else?

    解决方案

    I'm posting this as an answer so it will be easier for others to find it. The comments from Mark Plotnick and webbertiger are the actual answer.

    To summarize, here is what worked for me:

    • Created a ~/.gdbinit file
    • Added python sys.path.append("/usr/share/gcc-4.8/python"); to that file

    I'm using Eclipse CDT so I checked that this file is being used in window > preferences > GDB > GDB command file.

    这篇关于Ubuntu 14.04,gcc 4.8.4:由于Python问题,gdb漂亮打印不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    10-11 03:45