From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11228 invoked by alias); 10 Jun 2009 22:13:14 -0000 Received: (qmail 11216 invoked by uid 22791); 10 Jun 2009 22:13:13 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from fmmailgate02.web.de (HELO fmmailgate02.web.de) (217.72.192.227) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 10 Jun 2009 22:13:07 +0000 Received: from smtp05.web.de (fmsmtp05.dlan.cinetic.de [172.20.4.166]) by fmmailgate02.web.de (Postfix) with ESMTP id 6822A1028E5BB; Thu, 11 Jun 2009 00:13:04 +0200 (CEST) Received: from [88.64.26.191] (helo=[192.168.1.10]) by smtp05.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #277) id 1MEW2a-0002z9-00; Thu, 11 Jun 2009 00:13:04 +0200 Message-ID: <4A302FEB.1060509@web.de> Date: Wed, 10 Jun 2009 22:13:00 -0000 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Tom Tromey 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> In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig313D3B78A5B1FA582BE16F1E" X-Sender: jan.kiszka@web.de 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/msg00101.txt.bz2 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig313D3B78A5B1FA582BE16F1E Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-length: 762 Tom Tromey wrote: >>>>>> "Jan" =3D=3D Jan Kiszka writes: >=20 > Daniel> It's typical to do this the same way folks do in C: Create a null > Daniel> pointer of the right type. >=20 > Jan> You can't do that with the current upstream python interface, but the > Jan> parse_and_eval solves this nicely. >=20 > Actually, for constants you can: >=20 > (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 Yeah, seen this (in the testsuite). But such objects neither have addresses, nor do they help with non-constant objects I'm interested in. >=20 > Whoops, this seems to be undocumented. Not the only piece... :) Jan --------------enig313D3B78A5B1FA582BE16F1E Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" Content-length: 257 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkowL+8ACgkQniDOoMHTA+mb7gCghFa4n5RyBhcCW5fS9uLaOpy/ OvEAn2UARdRDtQirDMZSzKdx6LSkQxWD =4tdE -----END PGP SIGNATURE----- --------------enig313D3B78A5B1FA582BE16F1E--