栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

用于调试stdlib变量的Python漂亮打印机无法正常工作

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

用于调试stdlib变量的Python漂亮打印机无法正常工作

.gdbinit
的内容似乎不正确,或者没有运行。

确保添加的路径对于您的机器是正确的,并且gdbinit文件正在运行。

由于您遇到了该错误,因此只需要向python添加正确的路径即可。

这是一个示例跟踪,它首先不起作用,然后在更正路径后才起作用:

$ cat hello.cc #include <string>using namespace std;int main() {    string mystring = "my string here";    return 0;}$ g++ hello.cc -g -o hello.elf$ gdb hello.elf --quietReading symbols from hello.elf...done.(gdb) b hello.cc:6Breakpoint 1 at 0x400863: file hello.cc, line 6.(gdb) rStarting program: /tmp/x/hello.elf 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_printersimportError: No module named 'libstdcxx'Breakpoint 1, main () at hello.cc:66       return 0;(gdb) p mystring$1 = {static npos = <optimised out>, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},     _M_p = 0x602028 "my string here"}}(gdb) python>import sys>sys.path.insert(0, '/usr/share/gcc-4.8/python/')>end(gdb) rThe program being debugged has been started already.Start it from the beginning? (y or n) yStarting program: /tmp/x/hello.elfBreakpoint 1, main () at hello.cc:66       return 0;(gdb) p mystring$2 = "my string here"(gdb)

以上示例的版本信息:

$ g++ --versiong++ (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4Copyright (C) 2013 Free Software Foundation, Inc.This is free software; see the source for copying conditions.  There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.$ gdb --versionGNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1Copyright (C) 2014 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-linux-gnu".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".

使用Eclipse CDT时

使用Eclipse CDT时,您需要手动指定gdbinit文件。Eclipse CDT使用该

--nx
标志启动GDB
,这将阻止GDB
.gdbinit
自动拾取任何文件。您应该在启动配置中指定CDT合适的初始化文件:

此外,您可以在“首选项”中为新的启动配置更改默认的启动gdbinit,如下图所示:



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/634386.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号