offset of a struct field (qSymbol)

Michael Snyder msnyder@vmware.com
Wed Oct 1 22:20:00 GMT 2008


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)



More information about the Gdb mailing list