ste*_*n_g 4 python scripting gdb extending
我正在尝试为GDB编写一个简单的python扩展,只要遇到断点就会输出到文件.根据文档,"gdb.Breakpoint类可以被分类"(参见http://sourceware.org/gdb/onlinedocs/gdb/Breakpoints-In-Python.html)
但是,当我尝试以下代码时,我得到错误"TypeError:调用元类库时出错.类型'gdb.Breakpoint'不是可接受的基类型"
class MyBreakpoint(gdb.Breakpoint):
def stop (self):
print "break"
return False
Run Code Online (Sandbox Code Playgroud)
我正在运行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)
Run Code Online (Sandbox Code Playgroud)
适当的gdb 7.2文档在这里:
http://sourceware.org/gdb/download/onlinedocs/gdb/Breakpoints-In-Python.html#Breakpoints-In-Python
我假设EmployedRussian正在使用一个相对较新的gdb 7.2(7.2.90或类似的东西,似乎包含这些补丁)
这不是7.2的正式版本,在许多方面更像是7.3预发布,在7.3分支之前创建了大约2周(新功能中断了gdb 7.3).
所以它对他起作用的仅仅是gdb在发布之前使用'分支7.3',而不是'7.2发布之后的分支7.3'模型.
所以用7.2来做到这一点你可能不得不诉诸
break foo
commands
python print "break"
end
Run Code Online (Sandbox Code Playgroud)