public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Easy way to get type info out of STABS?
@ 2005-04-30  7:27 Justin McCann
  2005-05-02 18:37 ` Ian Lance Taylor
  0 siblings, 1 reply; 2+ messages in thread
From: Justin McCann @ 2005-04-30  7:27 UTC (permalink / raw)
  To: binutils, gdb


I'm looking for an easy-to-use API to get the type
information out of a Sparc ELF-32 executable with full
debugging symbols. I've read through all of the STABS
documentation I could find, as well as the GDB and
libbfd docs and source code; I've also looked at Sun's
gelf and libelf. 

I could write my own STABS parser, but I'm lazy and
believe in code reuse. I figure there has to be one
that isn't totally dependent on four dozen other
include files. Anyone have any suggestions?

What I'm aiming for is something that I can use to
make an API along the lines of:
  char *lookupfieldname(typenumber, offset)

So, given the type of a variable and an offset to a
field within that variable (some arbitrary nesting
deep) I need to determine what the field name is that
corresponds to that offset.

For example:
  struct {
     int a;
     struct {
           int b;
           int q;
     } foo;
  } myvar;

For the address &(myvar) + 8, I'd like to be able to
say that it is "myvar.foo.q".

Anyone know of a library that has all the info in an
easy-enough place to put that together?

Thanks in advance,
   Justin



		
__________________________________ 
Do you Yahoo!? 
Make Yahoo! your home page 
http://www.yahoo.com/r/hs

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

* Re: Easy way to get type info out of STABS?
  2005-04-30  7:27 Easy way to get type info out of STABS? Justin McCann
@ 2005-05-02 18:37 ` Ian Lance Taylor
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2005-05-02 18:37 UTC (permalink / raw)
  To: Justin McCann; +Cc: binutils, gdb

Justin McCann <jneilm@yahoo.com> writes:

> I'm looking for an easy-to-use API to get the type
> information out of a Sparc ELF-32 executable with full
> debugging symbols. I've read through all of the STABS
> documentation I could find, as well as the GDB and
> libbfd docs and source code; I've also looked at Sun's
> gelf and libelf. 

Look at the debugging library which objdump and objcopy use.  The
interface is binutils/debug.h.  Look at read_debugging_info in
binutils/rddbg.c to get debugging information for a file.  Then call,
e.g., debug_find_tagged_type to get the struct you want, call
debug_get_fields to get the fields, and call debug_get_field_bitpos on
each field to get the bit position within the struct.

Ian

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

end of thread, other threads:[~2005-05-02 18:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-30  7:27 Easy way to get type info out of STABS? Justin McCann
2005-05-02 18:37 ` Ian Lance Taylor

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).