From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1681 invoked by alias); 1 Oct 2008 22:20:51 -0000 Received: (qmail 1666 invoked by uid 22791); 1 Oct 2008 22:20:50 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-outbound-2.vmware.com (HELO smtp-outbound-2.vmware.com) (65.115.85.73) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 01 Oct 2008 22:20:01 +0000 Received: from mailhost5.vmware.com (mailhost5.vmware.com [10.16.68.131]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id C34592D006; Wed, 1 Oct 2008 15:19:59 -0700 (PDT) Received: from [10.20.92.59] (promb-2s-dhcp59.eng.vmware.com [10.20.92.59]) by mailhost5.vmware.com (Postfix) with ESMTP id BE73BDC110; Wed, 1 Oct 2008 15:19:59 -0700 (PDT) Message-ID: <48E3F758.6070701@vmware.com> Date: Wed, 01 Oct 2008 22:20:00 -0000 From: Michael Snyder User-Agent: Thunderbird 1.5.0.12 (X11/20080411) MIME-Version: 1.0 To: Mukesh Rathor CC: "gdb@sourceware.org" Subject: Re: offset of a struct field (qSymbol) References: In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit 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: 2008-10/txt/msg00011.txt.bz2 Mukesh Rathor wrote: > Hi, > I've written a gdbserver (gdbsx) for xen to debug guests. I'm trying to figure out if there's a way to figure offset of a field from gdbserver. > > Thus, init_mm is a struct, and I can do qSymbol on init_mm, but not init_mm.pgd. I am wondering if there's anyway to do that at present, or get gdb to do "print &(init_mm.pgd) somehow and send me the value. > > thanks a lot, > Mukesh OK, if I understand you, you want to know the offset of a field within a struct. Or perhaps you want the address of a field within a struct, but you can get that by adding the offset to the base address. No, there's nothing presently, but... There is a syntax for gdb to send an expression to the server, and have the server evaluate it. Perhaps we could simply reverse that syntax, so that the server could send an expression to gdb, and have gdb evaluate it and send back the answer? The kind of expression that I usually use to compute a field offset is something like: &(((struct init_mm *) 0).pgd)