From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8850 invoked by alias); 28 Sep 2011 22:43:51 -0000 Received: (qmail 8842 invoked by uid 22791); 28 Sep 2011 22:43:50 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from nm30.bullet.mail.bf1.yahoo.com (HELO nm30.bullet.mail.bf1.yahoo.com) (98.139.212.189) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Wed, 28 Sep 2011 22:43:37 +0000 Received: from [98.139.212.148] by nm30.bullet.mail.bf1.yahoo.com with NNFMP; 28 Sep 2011 22:43:36 -0000 Received: from [98.139.212.228] by tm5.bullet.mail.bf1.yahoo.com with NNFMP; 28 Sep 2011 22:43:36 -0000 Received: from [127.0.0.1] by omp1037.mail.bf1.yahoo.com with NNFMP; 28 Sep 2011 22:43:36 -0000 Received: (qmail 18818 invoked by uid 60001); 28 Sep 2011 22:43:36 -0000 Received: from [209.5.112.166] by web161610.mail.bf1.yahoo.com via HTTP; Wed, 28 Sep 2011 15:43:36 PDT Message-ID: <1317249816.13778.YahooMailNeo@web161610.mail.bf1.yahoo.com> Date: Wed, 28 Sep 2011 22:43:00 -0000 From: S Boucher Reply-To: S Boucher Subject: gdb python pretty printer question To: "gdb@sourceware.org" MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2011-09/txt/msg00127.txt.bz2 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 { =A0int type; /* 1 for S1, 2 for S2, 0 otherwise */ int x,y,z; } stuct S1 { =A0struct base b; =A0int w; } struct S2 { struct base b; int q; } If the pretty printer lookup notices a type 'struct base' with it's type = =3D=3D 1, then use a custom S1Printer class. class S1Printer(object): =A0 .... =A0=A0=A0 def to_string(self): =A0=A0=A0=A0=A0=A0=A0=A0 v =3D self.val.cast(gdb.lookup_type("S1")) =A0=A0=A0=A0=A0=A0=A0 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?