我正在尝试为GDB编写一个简单的python扩展,只要命中断点就输出到文件。根据该文件,“该gdb.Breakpoint类可以子类化”(见http://sourceware.org/gdb/onlinedocs/gdb/Breakpoints-In-Python.html)尝试在编写PythonGDB扩展时创建gdb.Breakpoint的子类时出错
然而,当我尝试下面的代码我得到的错误“类型错误:调用元类基地时,错误类型“GDB。断点'不是可接受的基类型“
class MyBreakpoint(gdb.Breakpoint):
def stop (self):
print "break"
return False
我正在运行Ubuntu 11.04和gdb 7.2。任何帮助或链接到更好的文档,将不胜感激。谢谢!
我的具体步骤:
$ gdb
GNU gdb (Ubuntu/Linaro 7.2-1ubuntu11) 7.2
Copyright (C) 2010 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-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) source t.py
Traceback (most recent call last):
File "t.py", line 3, in <module>
class MyBreakpoint(gdb.Breakpoint):
TypeError: Error when calling the metaclass bases
type 'gdb.Breakpoint' is not an acceptable base type
(gdb)
是的,我没有意识到我的GDB-7.2已经合并了这些补丁,但它确实如此。当我建立“香草”7.2时,我得到了和OP一样的错误。 – 2011-05-01 02:48:07
是的,我设法建立了7.2.90,它工作。谢谢! – 2011-05-01 18:41:39