gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 04:09:14 31 4
gpt4 key购买 nike

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

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

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

所以看起来这与 eclipse 搞砸了无关,而是脚本行为不当。


编辑:我刚刚启动了 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 中那样运行。

我猜 pretty-print 在 mingw+eclipse cdt 中坏了


执行以下步骤后:https://stackoverflow.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

版本:Kepler Service Release 1构建 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 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 脚本:我在 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”,现在可以吗?我想 None 来 self 的 .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 包的人来说,“干得好”。不。

关于python - 使用mingw调试STL容器,python脚本问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21376381/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com