From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10115 invoked by alias); 10 Jun 2009 20:37:04 -0000 Received: (qmail 10105 invoked by uid 22791); 10 Jun 2009 20:37:03 -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 20:36:54 +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 n5AKaqZ3028902; Wed, 10 Jun 2009 16:36:52 -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 n5AKapKH027379; Wed, 10 Jun 2009 16:36:51 -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 n5AKaoi2006257; Wed, 10 Jun 2009 16:36:51 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id F1EB9486A3; Wed, 10 Jun 2009 14:36:49 -0600 (MDT) To: Jan Kiszka Cc: gdb@sourceware.org Subject: Re: container_of equivalent in gdb-python script References: <4A2FE5AB.4060707@siemens.com> <4A30133F.9000909@web.de> From: Tom Tromey Reply-To: tromey@redhat.com Date: Wed, 10 Jun 2009 20:37:00 -0000 In-Reply-To: <4A30133F.9000909@web.de> (Jan Kiszka's message of "Wed\, 10 Jun 2009 22\:10\:39 +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/msg00095.txt.bz2 >>>>> "Jan" == Jan Kiszka writes: Jan> I meanwhile discovered (reading testcases and python-*.c) Jan> gdb.lookup_type() and Value.cast() to make this real. But you see, I Jan> still need an ugly synthetic Value object which must have a non-'None' Jan> address to do this calculation. Is there a cleaner, more generic way? Yeah, I think the missing piece is "gdb.parse_and_eval", which is on the archer python branch, but which we haven't pushed upstream into gdb CVS yet. This takes an expression (a string), parses it, evaluates it, and returns a Value. It is very convenient when implementing your own gdb commands. I don't think there's any particular problem with submitting this, just somebody finding the time. Tom