From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30236 invoked by alias); 10 Jun 2009 16:56:22 -0000 Received: (qmail 30226 invoked by uid 22791); 10 Jun 2009 16:56:21 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=BAYES_05 X-Spam-Check-By: sourceware.org Received: from lizzard.sbs.de (HELO lizzard.sbs.de) (194.138.37.39) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 10 Jun 2009 16:56:15 +0000 Received: from mail1.sbs.de (localhost [127.0.0.1]) by lizzard.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id n5AGuBF0019770 for ; Wed, 10 Jun 2009 18:56:11 +0200 Received: from [139.25.109.167] (mchn012c.mchp.siemens.de [139.25.109.167] (may be forged)) by mail1.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id n5AGuBF2020756 for ; Wed, 10 Jun 2009 18:56:11 +0200 Message-ID: <4A2FE5AB.4060707@siemens.com> Date: Wed, 10 Jun 2009 16:56: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: gdb@sourceware.org Subject: container_of equivalent in gdb-python script Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit 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/msg00090.txt.bz2 Hi, I'm currently getting my feet wet with gdb's great python extension. My first exercise is to walk a linked list of objects in a C inferior (namely 'modules' of the Linux kernel) and evaluate the elements. I'm at the point where I would apply a standard container_of() macro in C: convert the list entry into a gdb.Value that describes the containing object. Of course, I can implement container_of as a gdb expression, print the result and drag it in via gdb.history(). Done that already, basically works. But it is fairly ugly as the print output will flood the screen. I'm probably overseeing some obvious path in the python extension, any pointers welcome! Thanks, Jan -- Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux