使用mingw调试stl容器,与python脚本问题 [英] debugging stl containers using mingw, issue with python script

查看:601
本文介绍了使用mingw调试stl容器,与python脚本问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:
ok,我不会放弃。



我试图在代码块中设置,但是不能很好地工作:

 启动调试器:C:\MinGW\bin\gdb-python27.exe -nx -fullname -quiet 
done
设置断点
使用pid:7760附加到程序
调试器名称和版本:GNU gdb(GDB)7.5
附加到进程7760
>源C:\MinGW\bin\.gdbinit
跟踪(最近最后一次调用):
在< module>中的文件< string>
文件C:\MinGW\share\gcc-4.8.1\python\libstdcxx\v6\printers.py,第917行,在register_libstdcxx_printers
中register_type_printers(obj)
文件C:\MinGW\share\gcc-4.8.1\python\libstdcxx\v6\printers.py,行855,在register_type_printers中
add_one_type_printer(obj, 'basic_string',pfx +'string')
文件C:\MinGW\share\gcc-4.8.1\python\libstdcxx\v6\printers.py,第846行,在add_one_type_printer
gdb.types.register_type_printer(obj,printer)
文件c:\mingw\share\gdb / python\gdb\types.py,第179行,在register_type_printer
locus.type_printers.insert(0,printer)
AttributeError:'module'object没有属性'type_printers'
C:\MinGW\bin\.gdbinit:7:错误in sourced command file:
执行Python代码时出错。
执行Python代码时出错。
> python print sys.version
2.7.6(默认,2013年11月10日,19:24:18)[MSC v.1500 32位(Intel)]
>显示版本
GNU gdb(GDB)7.5
版权所有(C)2012自由软件基金会,
许可GPLv3 +:GNU GPL第3版或更高版本< http://gnu.org/ licenses / gpl.html>
这是免费软件:您可以自由更改和重新分配。
在法律允许的范围内,没有任何保证。有关详细信息,请键入显示复制
和显示保修。
此GDB配置为i686-pc-mingw32。
有关错误报告说明,请参阅:
< http://www.gnu.org/software/gdb/bugs/>
调试器名称和版本:GNU gdb(GDB)7.5

与eclipse乱七八糟的事情无关,但脚本行为不端。






编辑:
i msys,导航到相同的路径eclipse suposedly(2-environment-cd D:/ work / ludum-dare / Debug),设置相同的参数(除了5-enable-pretty-printing因为gdb-python似乎不知道设置)和最终来源.gdbinit它甚至没有wince这样做。没有错误。



有没有人知道当我点击debug时eclipse试图运行什么?



此外,我只是尝试了标准的创建过程启动器,它开始顺利,但在跟踪控制台中滚动,我看到它只是跳过在python文件中遇到的错误。






编辑:我刚刚意识到,没有设置5-enable-pretty-printing不在printers.py中设置_use_gdb_pp,所以它不会运行相同的方式在eclipse无论如何。



我想漂亮的打印在mingw + eclipse cdt中被打破了






按照以下步骤操作: http://stackoverflow.com/a/14266862/3239702
i am facing eclipse中的以下输出:

  610,711 2-environment-cd D:/ work / ludum-dare / Debug 
610,715 2 ^ done
610,715(gdb)
610,716 3-gdb-set断点挂起
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打印对象
610,765 7 ^ done
610,765(gdb)
610,766 8-gdb-set打印
上的七位字符串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\\\

610,896& traceback(last recent call last):\\\

610,896&File \< string> \,第4行在< module> \\\

610,896 &File \C:/MinGW/share/gcc-4.8.1/python\\libstdcxx\\v6\\printers.py\,第917行,在regis \
ter_libstdcxx_printers\ n
610,915&register_type_printers(obj)\\\

610,915&File \C:/MinGW/share/gcc-4.8.1/python \\libstdcxx\\v6\\printers.py\,第855行,在regis \
ter_type_printers\\\

610,917&add_one_type_printer(obj, basic_string',pfx +'string')\\\

610,917&File \C:/MinGW/share/gcc-4.8.1/python\\libstdcxx\\v6\\ \\\printers.py\,第846行,位于add_o\
ne_type_printer\\\

610,918&gdb.types.register_type_printer(obj,printer)\\\

610,918&File \c:\\\\\share\\gdb/python\\gdb\\\\\\\\\\\\\\\\\\\\ \
\\\

610,928&locus.type_printers.insert(0,printer)\\\

610,928&AttributeError:'module'object has no attribute' type_printers'\
610,928&D:\\work\\ludum-dare\\.gdbinit:6:源命令文件中出错:\\\

610,928&执行Python代码时出错。\\\

610,928 12 ^ error,msg =D:\\work\\ludum-dare\\.gdbinit:6:源命令文件中出错:\\\
Error while \
执行Python代码。
610,929(gdb)

我已在网上搜索其他有这个问题的人,它看起来像我得到了累积奖金。我得到:
用于C / C ++开发人员的Eclipse IDE



版本:Kepler Service Release 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 \; 






编辑:
i刚刚试过python脚本从svn(svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python)当然我改变了.gdbinit中的路径相应。
gdb traces控制台中的输出大部分是相同的,除了一些行号不同,但是这些行中的错误是相同的,所以我认为只是有一些重构或类似的东西on。



还有我的.gdbinit文件。在svn checkout之前,使用注释的行代替第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脚本:
i向register_libstdcxx_printers函数添加了一些打印:

  def register_libstdcxx_printers(obj):
注册libstdc ++ pretty-printers with objfile Obj。
全局_use_gdb_pp
全局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:
如果obj为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〜 :None\\\

559,740〜_use_gdb_pp:True\\\

559,740〜after gdb.printing.register_pretty_printer(obj,libstdcxx_printer):obj:None\\\

我无法真正归咎于没有找到属性'type_printers'无,现在可以吗?
i假设None来自我的.gdbinit中的第6行:

  register_libstdcxx_printers(None)


解决方案

MinGW GDB 7.5.1使用普通GDB 7.6中的Python脚本。



http://ftp.gnu.org/gnu/gdb/gdb-7.5.1.tar.gzrel =nofollow> http://ftp.gnu.org/gnu/gdb/gdb-7.5.1。 tar.gz



并尝试了一切,奇迹般的工作。

 启动调试器:C:\MinGW\bin\gdb-python27.exe -nx -fullname -quiet 
done
设置断点
使用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
> 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\)'}}
&源C:\MingW\bin\.gdbinit
> print funcText
$ 2 ='ces:getEntitiesWithComponent(\position\)'

所以,好工作的人把gdb 7.6 python脚本到MinGW GDB 7.5.1包。 NOT。


edit: ok, i wont give up.

i tried to set this up in codeblocks, but that doesnt work well either:

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

so it looks as if this has nothing to do with eclipse messing things up, but the script misbehaving.


edit: i just fired up msys, navigated to the same path eclipse suposedly does (2-environment-cd D:/work/ludum-dare/Debug), set the same parameters (except 5-enable-pretty-printing since gdb-python doesnt seem to know that setting) and finally sourced .gdbinit It didnt even wince at doing that. no errors at all.

does anyone know how to find out what eclipse is trying to run when i click on debug?

Also i just tried the "standard create process launcher" which at first went smoothly, but scrolling up in the traces console, i saw it simply skips over the errors encountered in the python file.


edit: i just realized that not setting 5-enable-pretty-printing doesnt set _use_gdb_pp in printers.py, so it wont run the same way as in eclipse anyhow.

I guess pretty printing is broken in mingw+eclipse cdt


after following these steps: http://stackoverflow.com/a/14266862/3239702 i am facing the following output in 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) 

i have searched the web for other people who have this problem but it looks like i got the jackpot. i got: Eclipse IDE for C/C++ Developers

Version: Kepler Service Release 1 Build id: 20130919-0819


my mingw installer is all updated, and gdb-python27 is installed from:

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

python 2.7.6 32bit User Environment Variables:

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

Global Environment Variables: contains much more, i only post the relevant part:

PATH = C:\Python27\;


edit: i just tried the python scripts from svn ( svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python ) of course i changed the path in my .gdbinit accordingly. the output in the "gdb traces" console is mostly the same, except for a couple of line numbers which differ, but the errors in those lines are identical, so i supose there just was some refactoring or something like that going on.

and also my .gdbinit file as it is now. before the svn checkout, the commented line was used instead of line 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


edit: tried to debug that printers.py script: i added some prints to the register_libstdcxx_printers function:

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)

the output of this is:

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"

i cant really blame it to not find the attribute 'type_printers' on None, now can i? i suppose that None comes from line 6 in my .gdbinit :

register_libstdcxx_printers (None)

解决方案

MinGW GDB 7.5.1 uses Python Scripts from normal GDB 7.6. Therefore the Scripts fail.

After i copied the syscalls and python folders out of

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

and tried everything again, it miraculously worked.

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\")'"

So, "nice job" to the person who put the gdb 7.6 python scripts into the MinGW GDB 7.5.1 package. NOT.

这篇关于使用mingw调试stl容器,与python脚本问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆