gdb python pretty printer question
S Boucher
stbya@yahoo.com
Wed Sep 28 22:43:00 GMT 2011
I'm trying to use the python pretty printer functionality to to print what are basically sub classes implemented in C.
given the following:
struct base {
int type; /* 1 for S1, 2 for S2, 0 otherwise */
int x,y,z;
}
stuct S1 {
struct base b;
int w;
}
struct S2 {
struct base b;
int q;
}
If the pretty printer lookup notices a type 'struct base' with it's type == 1, then use a custom S1Printer class.
class S1Printer(object):
....
def to_string(self):
v = self.val.cast(gdb.lookup_type("S1"))
return v.__str__()
Problem with that is that when v.__str__() is called to print 'b' from S1, it notices that b is a S1, and we have a recursion...
Any way to prevent the recursion?
More information about the Gdb
mailing list