From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15297 invoked by alias); 10 Jun 2009 18:57:24 -0000 Received: (qmail 15289 invoked by uid 22791); 10 Jun 2009 18:57:23 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 10 Jun 2009 18:57:18 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n5AIvEAV004318; Wed, 10 Jun 2009 14:57:14 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n5AIvDKu010499; Wed, 10 Jun 2009 14:57:13 -0400 Received: from opsy.redhat.com (vpn-13-36.rdu.redhat.com [10.11.13.36]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n5AIvCdf022214; Wed, 10 Jun 2009 14:57:13 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 10F8637817A; Wed, 10 Jun 2009 12:57:12 -0600 (MDT) To: Jan Kiszka Cc: gdb@sourceware.org Subject: Re: container_of equivalent in gdb-python script References: <4A2FE5AB.4060707@siemens.com> From: Tom Tromey Reply-To: tromey@redhat.com Date: Wed, 10 Jun 2009 18:57:00 -0000 In-Reply-To: <4A2FE5AB.4060707@siemens.com> (Jan Kiszka's message of "Wed\, 10 Jun 2009 18\:56\:11 +0200") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2009-06/txt/msg00092.txt.bz2 >>>>> "Jan" == Jan Kiszka writes: Jan> I'm at the point where I would apply a standard container_of() Jan> macro in C: convert the list entry into a gdb.Value that Jan> describes the containing object. Jan> Of course, I can implement container_of as a gdb expression, print the Jan> result and drag it in via gdb.history(). Done that already, basically Jan> works. But it is fairly ugly as the print output will flood the screen. I would say that the usual approach would be to reimplement the macro in Python. The Python Value API is reasonably robust and can usually be used for this. If you post the macro definition maybe I could help with that. More details wouldn't hurt, either... are you writing a pretty-printer? A new command? A convenience function? Tom