使用mingw调试stl容器,python脚本出现问题

编辑:
好的,我不会放弃.

我试图在代码块中进行设置,但是效果也不佳:

Starting debugger: C:\MinGW\bin\gdb-python27.exe -nx -fullname  -quiet 
done
Setting breakpoints
Attaching to program with pid: 7760
Debugger name and version: GNU gdb (GDB) 7.5
Attaching to process 7760
> source C:\MinGW\bin\.gdbinit
Traceback (most recent call last):
  File "<string>", line 5, in <module>
  File "C:\MinGW\share\gcc-4.8.1\python\libstdcxx\v6\printers.py", line 917, in register_libstdcxx_printers
    register_type_printers(obj)
  File "C:\MinGW\share\gcc-4.8.1\python\libstdcxx\v6\printers.py", line 855, in register_type_printers
    add_one_type_printer(obj, 'basic_string', pfx + 'string')
  File "C:\MinGW\share\gcc-4.8.1\python\libstdcxx\v6\printers.py", line 846, in add_one_type_printer
    gdb.types.register_type_printer(obj, printer)
  File "c:\mingw\share\gdb/python\gdb\types.py", line 179, in register_type_printer
    locus.type_printers.insert(0, printer)
AttributeError: 'module' object has no attribute 'type_printers'
C:\MinGW\bin\.gdbinit:7: Error in sourced command file:
Error while executing Python code.
Error while executing Python code.
> python print sys.version
2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)]
> show version
GNU gdb (GDB) 7.5
Copyright (C) 2012 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 "i686-pc-mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Debugger name and version: GNU gdb (GDB) 7.5

所以看起来这与日食无关,但脚本行为异常.

编辑:
我刚刚启动了msys,导航到了eclipse可能执行的相同路径(2-environment-cd D:/ work / ludum-dare / Debug),设置了相同的参数(5-enable-pretty-printing除外,因为gdb-python没有似乎知道该设置)并最终获取.gdbinit.完全没有错误.

有谁知道如何在我单击“调试”时找出正在尝试运行的Eclipse?

我还尝试了“标准创建过程启动器”,起初运行很顺利,但是在跟踪控制台中向上滚动时,我看到它只是跳过了python文件中遇到的错误.

编辑:我只是意识到不设置5-enable-pretty-printing不会在printers.py中设置_use_gdb_pp,因此无论如何它都不会以与eclipse中相同的方式运行.

我想mingw eclipse cdt中的漂亮打印坏了

在执行以下步骤之后:https://*.com/a/14266862/3239702
我在Eclipse中面临以下输出:

610,711 2-environment-cd D:/work/ludum-dare/Debug
610,715 2^done
610,715 (gdb) 
610,716 3-gdb-set breakpoint pending on
610,725 3^done
610,725 (gdb) 
610,726 4-gdb-set detach-on-fork on
610,735 4^done
610,735 (gdb) 
610,736 5-enable-pretty-printing
610,745 5^done
610,745 (gdb) 
610,746 6-gdb-set python print-stack none
610,755 6^done
610,755 (gdb) 
610,756 7-gdb-set print object on
610,765 7^done
610,765 (gdb) 
610,766 8-gdb-set print sevenbit-strings on
610,775 8^done
610,775 (gdb) 
610,776 9-gdb-set host-charset UTF-8
610,785 9^done
610,785 (gdb) 
610,786 10-gdb-set target-charset WINDOWS-1252
610,795 10^done
610,795 (gdb) 
610,795 11-gdb-set target-wide-charset UTF-16
610,805 11^done
610,805 (gdb) 
610,822 12source D:\work\ludum-dare\.gdbinit
610,825 &"source D:\\work\\ludum-dare\\.gdbinit\n"
610,896 &"Traceback (most recent call last):\n"
610,896 &"  File \"<string>\", line 4, in <module>\n"
610,896 &"  File \"C:/MinGW/share/gcc-4.8.1/python\\libstdcxx\\v6\\printers.py\", line 917, in regis\
ter_libstdcxx_printers\n"
610,915 &"    register_type_printers(obj)\n"
610,915 &"  File \"C:/MinGW/share/gcc-4.8.1/python\\libstdcxx\\v6\\printers.py\", line 855, in regis\
ter_type_printers\n"
610,917 &"    add_one_type_printer(obj, 'basic_string', pfx + 'string')\n"
610,917 &"  File \"C:/MinGW/share/gcc-4.8.1/python\\libstdcxx\\v6\\printers.py\", line 846, in add_o\
ne_type_printer\n"
610,918 &"    gdb.types.register_type_printer(obj, printer)\n"
610,918 &"  File \"c:\\mingw\\share\\gdb/python\\gdb\\types.py\", line 176, in register_type_printer\
\n"
610,928 &"    locus.type_printers.insert(0, printer)\n"
610,928 &"AttributeError: 'module' object has no attribute 'type_printers'\n"
610,928 &"D:\\work\\ludum-dare\\.gdbinit:6: Error in sourced command file:\n"
610,928 &"Error while executing Python code.\n"
610,928 12^error,msg="D:\\work\\ludum-dare\\.gdbinit:6: Error in sourced command file:\nError while \
executing Python code."
610,929 (gdb) 

我在网上搜索了其他有此问题的人,但看起来我中奖了.我有:
面向C/C++开发人员的Eclipse IDE

版本:开普勒服务版本1
Build ID:20130919-0819

我的mingw安装程序已全部更新,并且从以下位置安装了gdb-python27:

gdb-python-7.5.1-mingw32-bin.tar.lzma

python 2.7.6 32位
用户环境变量:

PYTHONHOME = C:\Python27
PYTHONPATH = C:\Python27\Lib
PATH = c:\mingw\bin

全局环境变量:
包含更多内容,我只发布相关部分:

PATH = C:\Python27\;

编辑:
我只是尝试了svn(svn://gcc.gnu.org/svn/gcc/trunk/libstdc -v3 / python)中的python脚本,因此我相应地更改了.gdbinit中的路径.
“ gdb traces”控制台中的输出几乎相同,除了几行不同,但这些行中的错误是相同的,所以我认为只是进行了一些重构或类似的操作.

还有我的.gdbinit文件.在svn结帐之前,使用注释行而不是第4行:

python
import sys
# sys.path.insert(0, 'C:/MinGW/share/gcc-4.8.1/python')
sys.path.insert(0, 'D:/work/libstdc++-v3/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end

编辑:
尝试调试printers.py脚本:
我向register_libstdcxx_printers函数添加了一些打印:

def register_libstdcxx_printers (obj):
    "Register libstdc++ pretty-printers with objfile Obj."
    global _use_gdb_pp
    global libstdcxx_printer
    print("initialy obj: " + str(obj))
    print("_use_gdb_pp: " + str(_use_gdb_pp))
    if _use_gdb_pp:
        gdb.printing.register_pretty_printer(obj, libstdcxx_printer)
    else:
        if obj is None:
            obj = gdb
        obj.pretty_printers.append(libstdcxx_printer)
    print("after gdb.printing.register_pretty_printer(obj, libstdcxx_printer): obj: " + str(obj))
    register_type_printers(obj)

输出是:

559,740 ~"initialy obj: None\n"
559,740 ~"_use_gdb_pp: True\n"
559,740 ~"after gdb.printing.register_pretty_printer(obj, libstdcxx_printer): obj: None\n"

我真的不能怪它没有在None上找不到属性’type_printers’,现在可以吗?
我想没有来自我的.gdbinit的第6行:

register_libstdcxx_printers (None)

解决方法:

MinGW GDB 7.5.1使用标准GDB 7.6中的Python脚本.因此,脚本将失败.

在我将syscalls和python文件夹复制出来之后

http://ftp.gnu.org/gnu/gdb/gdb-7.5.1.tar.gz

并再次尝试了一切,奇迹般地奏效了.

Starting debugger: C:\MinGW\bin\gdb-python27.exe -nx -fullname  -quiet 
done
Setting breakpoints
Attaching to program with pid: 7428
Debugger name and version: GNU gdb (GDB) 7.5
Attaching to process 7428
Continuing...
At D:\work\ludum-dare\src\main.cpp:39
Continuing...
At D:\work\ludum-dare\src\main.cpp:41
Continuing...
At D:\work\ludum-dare\src\componentEntitySystem\componentEntitySystem.cpp:393
> print funcText
$1 = {static npos = <optimized out>, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x24504f4 "'ces:getEntitiesWithComponent(\"position\")'"}}
> source C:\MingW\bin\.gdbinit
> print funcText
$2 = "'ces:getEntitiesWithComponent(\"position\")'"

因此,对将gdb 7.6 python脚本放入MinGW GDB 7.5.1程序包中的人来说,“工作很不错”.不.

上一篇:c-模板专业化导致与Windows上的MinGW链接错误,而不是Linux上的GCC


下一篇:第二周作业2019.9.26