public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* structure offset to structure name conversion.
@ 2011-10-27 19:29 James Courtier-Dutton
  2011-10-27 20:30 ` Ian Lance Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: James Courtier-Dutton @ 2011-10-27 19:29 UTC (permalink / raw)
  To: gcc

Hi,

If I have a structure e.g.
struct test_s {
    int32_t var1;
    int32_t var2;
    uint64_t var3;
    int var4;
} test;

If I have an offset value of 8, I wish to do a lookup and get to:
test.var3

Is there some part of gcc that I could use to parse .h files and
produce a table for me of offset against each variable in the
structure to permit this sort of lookup?

Kind Regards

James

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: structure offset to structure name conversion.
  2011-10-27 19:29 structure offset to structure name conversion James Courtier-Dutton
@ 2011-10-27 20:30 ` Ian Lance Taylor
  2011-10-27 21:32   ` Paul_Koning
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Lance Taylor @ 2011-10-27 20:30 UTC (permalink / raw)
  To: James Courtier-Dutton; +Cc: gcc

James Courtier-Dutton <james.dutton@gmail.com> writes:

> If I have a structure e.g.
> struct test_s {
>     int32_t var1;
>     int32_t var2;
>     uint64_t var3;
>     int var4;
> } test;
>
> If I have an offset value of 8, I wish to do a lookup and get to:
> test.var3
>
> Is there some part of gcc that I could use to parse .h files and
> produce a table for me of offset against each variable in the
> structure to permit this sort of lookup?

This message would be more appropriate on the mailing list
gcc-help@gcc.gnu.org.  Please take any followups to gcc-help.  Thanks.

I'm not aware of anything quite like that, no.  I think the closest you
could get easily would be to examine the debugging information.  E.g.,
you could compile with -gstabs and run objdump -g.  You would still have
to parse the objdump -g output, but at least the offset is there.

Ian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: structure offset to structure name conversion.
  2011-10-27 20:30 ` Ian Lance Taylor
@ 2011-10-27 21:32   ` Paul_Koning
  0 siblings, 0 replies; 3+ messages in thread
From: Paul_Koning @ 2011-10-27 21:32 UTC (permalink / raw)
  To: james.dutton; +Cc: gcc

> If I have a structure e.g.
> struct test_s {
>     int32_t var1;
>     int32_t var2;
>     uint64_t var3;
>     int var4;
> } test;
>
> If I have an offset value of 8, I wish to do a lookup and get to:
> test.var3
>
> Is there some part of gcc that I could use to parse .h files and 
> produce a table for me of offset against each variable in the 
> structure to permit this sort of lookup?

GDB can do this, of course.  There is also a utility "pahole" that reads debug data from an object file or executable file and produces that information.  See your favorite search engine.

	paul

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-10-27 19:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-27 19:29 structure offset to structure name conversion James Courtier-Dutton
2011-10-27 20:30 ` Ian Lance Taylor
2011-10-27 21:32   ` Paul_Koning

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).