Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/144.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用mingw调试stl容器,python脚本问题_Python_C++_Gdb_Mingw_Windows 7 X64 - Fatal编程技术网

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

使用mingw调试stl容器,python脚本问题,python,c++,gdb,mingw,windows-7-x64,Python,C++,Gdb,Mingw,Windows 7 X64,编辑: 好吧,我不会放弃 我试着在代码块中设置它,但这也不起作用: 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

编辑: 好吧,我不会放弃

我试着在代码块中设置它,但这也不起作用:

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
python 2.7.6 32位 用户环境变量:

PYTHONHOME = C:\Python27
PYTHONPATH = C:\Python27\Lib
PATH = c:\mingw\bin
全球环境变量: 包含更多内容,我只发布相关部分:

PATH = C:\Python27\;

编辑: 我刚试过svn的python脚本(svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/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)

MingwGDB7.5.1使用普通GDB7.6中的Python脚本。因此,脚本失败

在我从中复制了syscalls和python文件夹之后

然后尝试了一切,奇迹般地成功了

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\")'"
启动调试器:C:\MinGW\bin\gdb-python27.exe-nx-fullname-quiet
完成
设置断点
用pid:7428连接到程序
调试器名称和版本:GNU gdb(gdb)7.5
附加到进程7428
持续的。。。
在D:\work\ludum dare\src\main.cpp:39
持续的。。。
位于D:\work\ludum-dare\src\main.cpp:41
持续的。。。
位于D:\work\ludum dare\src\componentEntitySystem\componentEntitySystem.cpp:393
>打印文本
$1={static npos=,\u M\u dataplus={={},},\u M\u p=0x24504f4“'ces:getEntitywithComponent(\'position\”)””}
>源C:\MingW\bin\.gdbinit
>打印文本
$2=“'ces:getEntitiesWithComponent(\'position\””)

因此,对于将GDB7.6Python脚本放入MingWGDB7.5.1包的人来说,“干得好”。不是。

您的路径变量如何?我在Python3.3上遇到了问题(在几乎与您相同的环境中),因此我不得不使用2.7.x。我对问题进行了更多的编辑。python33安装对注册表有影响吗?i、 我应该卸载python33吗?我不知道register,但您不需要卸载它。编辑PATH变量,将Python 2.7.x目录放在Python 3.3.x之前。因此,当您在CMD中键入
python
时,必须使用python2.7.x。另外,您确定让Eclipse查找
.gdbinit
,并且调试器是
mingw32-gdb-python
?我不久前写了一篇文章,这可能会有所帮助。当我启动cmd并尝试从我的用户文件夹启动python时,我得到了Python2.7,所以这应该很好。我将EclipseGDB调试器设置指向C:\MinGW\bin\GDB-python27.exe,将GDB命令文件指向:D:\work\ludum dare\.gdbinit指出GDB python是我系统上唯一的一个,而MinGW安装管理器说包名是mingw32-GDB python安装版本:GDB-python-7.5.1-mingw32-bin.tar.lzma我现在将阅读你的博客文章博客帖子没有太大帮助,它基本上说我到目前为止所做的是正确的:/因为我第一次犯了这个错误,一个小的澄清:替换
。\MinGW\share\gdb\{python | syscalls}
。\gdb-7.5.1\gdb\{python | syscalls}
,但保持
。\MinGW\share\gcc-4.8.1\python\libstdcxx\
不变。
register_libstdcxx_printers (None)
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\")'"