This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: offset of a struct field (qSymbol)
- From: Michael Snyder <msnyder at vmware dot com>
- To: Mukesh Rathor <todfod at hotmail dot com>
- Cc: "gdb at sourceware dot org" <gdb at sourceware dot org>
- Date: Wed, 01 Oct 2008 15:19:04 -0700
- Subject: Re: offset of a struct field (qSymbol)
- References: <BAY144-W3E14B48A02AE2C2C2DE6EDD420@phx.gbl>
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)