This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
gdb python pretty printer question
- From: S Boucher <stbya at yahoo dot com>
- To: "gdb at sourceware dot org" <gdb at sourceware dot org>
- Date: Wed, 28 Sep 2011 15:43:36 -0700 (PDT)
- Subject: gdb python pretty printer question
- Reply-to: S Boucher <stbya at yahoo dot com>
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?