This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gdb python pretty printer question


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?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]