From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17385 invoked by alias); 10 Jun 2009 21:42:30 -0000 Received: (qmail 17371 invoked by uid 22791); 10 Jun 2009 21:42:29 -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 21:42:22 +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 n5ALgKEX010685; Wed, 10 Jun 2009 17:42:20 -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 n5ALgJAu023008; Wed, 10 Jun 2009 17:42:19 -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 n5ALgIMV016665; Wed, 10 Jun 2009 17:42:19 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id E3A0E486A3; Wed, 10 Jun 2009 15:42:12 -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> <20090610204201.GA17154@caradoc.them.org> <4A30269D.7070504@web.de> From: Tom Tromey Reply-To: Tom Tromey Date: Wed, 10 Jun 2009 21:42:00 -0000 In-Reply-To: <4A30269D.7070504@web.de> (Jan Kiszka's message of "Wed\, 10 Jun 2009 23\:33\:17 +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/msg00100.txt.bz2 >>>>> "Jan" == Jan Kiszka writes: Daniel> It's typical to do this the same way folks do in C: Create a null Daniel> pointer of the right type. Jan> You can't do that with the current upstream python interface, but the Jan> parse_and_eval solves this nicely. Actually, for constants you can: (gdb) python print gdb.Value(0) 0 (gdb) python print type(gdb.Value(0)) (gdb) python print gdb.Value(0).cast(gdb.lookup_type('char').pointer()) 0x0 Whoops, this seems to be undocumented. Tom