From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27006 invoked by alias); 2 Jan 2013 18:56:42 -0000 Received: (qmail 26998 invoked by uid 22791); 2 Jan 2013 18:56:41 -0000 X-SWARE-Spam-Status: No, hits=-5.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-ob0-f182.google.com (HELO mail-ob0-f182.google.com) (209.85.214.182) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 02 Jan 2013 18:56:36 +0000 Received: by mail-ob0-f182.google.com with SMTP id 16so13019002obc.27 for ; Wed, 02 Jan 2013 10:56:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:x-gm-message-state; bh=2zD9msaBZQGbFBvxztj4Ss5GOGt25VXHqEkwl5BwO8k=; b=pGBtnpMMrZ1V/dSCsl3yn3HMfQe83Pr56sUbf3ebyGDT66SUzNRD2PZ7DWdWUmfkT0 Y6ahb2c+iLCfl2RQIhDjgzzxSgHDYEZ4EI4RkBCcRJed7KjmODVlRLzqocb/ggy3PKJT XUTh8XeSUjjLFvGAZNoyVYiv1j2AqOHYF6BOcDmQpHz8ppYjzIL1v+1wueOCNFfOx8YC tDCSJzJEFcnzaF2jKiXCB7Y1oJhQ+DGf/2qnC0e0KNJu9UayIMXvd/PM4fPQ06ncU8hd aN76cEryT7u9IL+FteSNrmeQKzwIMZmQzs2UlHXVltfAJlGHOdAJ3QX3hy3bzd+RrKL1 osNA== MIME-Version: 1.0 Received: by 10.60.31.131 with SMTP id a3mr25733193oei.93.1357152995840; Wed, 02 Jan 2013 10:56:35 -0800 (PST) Received: by 10.76.87.101 with HTTP; Wed, 2 Jan 2013 10:56:35 -0800 (PST) In-Reply-To: <87fw2j5w4y.fsf@fleche.redhat.com> References: <87fw2j5w4y.fsf@fleche.redhat.com> Date: Wed, 02 Jan 2013 18:56:00 -0000 Message-ID: Subject: Re: can pahole print a struct definition in a given CU? From: Doug Evans To: Tom Tromey Cc: Tristan Su , gdb Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQm7qeaQ2rPNWVdcJj0+tLUTwwmvBCGEJdAqXR+SktHJFIpfqD+Jvzd8dHjaGZO5iFeoiHhQnWVYGg1YTJSyiMnFiSHWPUbxaoeg2tkr08qUESbeGLsT2ixFDCfraP8ygLVbSfdk7aMxuEHxQmgu7/iPBZ/nCMT2gg+H5FY5dJANe9FDRu+fJHQ/B8dnVsXYPZR0mz1F X-IsSubscribed: yes 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: 2013-01/txt/msg00005.txt.bz2 On Wed, Jan 2, 2013 at 10:31 AM, Tom Tromey wrote: >>>>>> "Tristan" == Tristan Su writes: > > Tristan> I found pahole (python api) quite useful but jusst could not have it > Tristan> print a struct in a given compilation unit. > Tristan> With the ptype command: > Tristan> (gdb) ptype S > Tristan> but we can also specify the CU because the struct may have different > Tristan> define in different CUs. > Tristan> (gdb) ptype 'foo.c'::S > > Tristan> Is that possible/easy to make pahole support this? > > I couldn't think of an easy way. Though maybe that is just imagination > failure on my part :) > > If I were doing this I would start by finding a way to expose > evaluate_type to Python, say via a flag to parse_and_eval. > Then I would make pahole use this. I realize we're talking about types here, but there's a general problem here, and there's another approach to choosing object foo from source bar.c. [This doesn't immediately help with the pahole issue here, but it's a thought that occurred to me, so I'm writing it down.] It's seems like what's needed is a handle on the symtab(CU), and then a way to go from there, instead of encoding the symtab in the expression. Since expressions in the source work that way, making things like "p 'bar.c'::foo + 'baz.c'::foo" work seems like excessive generality. [For completeness sake, I realize that works today and we can't break it. Still, I think there's room for improvement.] Thus, what about adding a "context" parameter to parse_and_eval, etc.? And then provide a way to specify that context (e.g., both from the CLI and from Python). We'd still have to support "p 'bar.c'::foo + 'baz.c::foo'", but when, e.g, cut-n-pasting expressions from source we shouldn't have to force the user to insert 'bar.c::' in front of objects that gdb might end up otherwise picking the wrong one for. E.g., something like: (gdb) with-symtab bar.c p foo+baz or whatever.