我正在嘗試爲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