I'm trying to write a simple python extension for GDB that outputs to a file whenever a breakpoint is hit. According to the documentation, "The gdb.Breakpoint class can be sub-classed" (see http://sourceware.org/gdb/onlinedocs/gdb/Breakpoints-In-Python.html)
However when I try the following code I get the error "TypeError: Error when calling the metaclass bases. type 'gdb.Breakpoint' is not an acceptable base type"
class MyBreakpoint(gdb.Breakpoint):
def stop (self):
print "break"
return False
I'm running Ubuntu 11.04 and gdb 7.2. Any help or links to better documentation would be appreciated. Thanks!
My exact steps:
$ 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)
The appropriate gdb 7.2 documentation is here:
http://sourceware.org/gdb/download/onlinedocs/gdb/Breakpoints-In-Python.html#Breakpoints-In-Python
I'm assuming EmployedRussian is using a relatively recent gdb 7.2 (7.2.90 or something equivalent which seems to contain these patches)
this is not really an official release of 7.2 and in many ways is more like a 7.3 pre-release, having been created just about 2 weeks before 7.3 branched (the new feature cut off of gdb 7.3).
so that it worked on his is merely that gdb uses a 'branch 7.3 before release', rather than 'branch 7.3 after 7.2 release' model.
so to do this with 7.2 you might have to resort to
break foo
commands
python print "break"
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With