This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Extracting Debug (meta data) from executable images?


Siegfried Heintze wrote:

> Neither nm, readelf or objdump enumerate the fields of a struct. It looks
> like dwarfdump would, but libdwarf does not compile with cygwin/gcc 3.4 or
> RedHat8/gcc 3.2.

Did you actually try objdump -g like I said?  Because as far as I can
tell it basically dumps everything that is available in the debug
information, which includes structs.

// foo.c
struct mystruct {
  int myint;
  long mylong;
  float myfloat;
};

int main()
{
  struct mystruct x;
}

$ gcc -g -c foo.c
$ objdump -g foo.o

foo.o:     file format pe-i386

/tmp/debug_test/foo.c:
typedef int32 int;
typedef int8 char;
typedef int32 long int;
typedef uint32 unsigned int;
typedef uint32 long unsigned int;
typedef int64 long long int;
typedef uint64 long long unsigned int;
typedef int16 short int;
typedef uint16 short unsigned int;
typedef int8 signed char;
typedef uint8 unsigned char;
typedef float float;
typedef double double;
typedef float96 long double;
typedef struct %anon1 { /* size 8 */
  int real; /* bitsize 32, bitpos 0 */
  int imag; /* bitsize 32, bitpos 32 */
} complex int;
typedef complex float0 complex float;
typedef complex float0 complex double;
typedef complex float0 complex long double;
typedef void void;
typedef char *__builtin_va_list;
typedef bool32 boolean;
typedef boolean _Bool;
struct mystruct { /* size 12 id 2 */
  int myint; /* bitsize 32, bitpos 0 */
  long int mylong; /* bitsize 32, bitpos 32 */
  float myfloat; /* bitsize 32, bitpos 64 */
};
int main ()
{ /* 0x0 */
  { /* 0x0 */
    struct mystruct /* id 2 */ x /* 0xffffffe8 */;
    /* file /tmp/debug_test/foo.c line 9 addr 0x0 */
    /* file /tmp/debug_test/foo.c line 9 addr 0x25 */
    /* file /tmp/debug_test/foo.c line 11 addr 0x2a */
  } /* 0x2c */
} /* 0x2c */

I'm not suggesting that you use objdump, I'm suggesting that you look at
it's source code and modify it as necessary because it shares the same
code as gdb for reading debug info (the bfd library), without all the
extra cruft of gdb.

> So if I download the source code for GDB, do I compile it on cygwin using
> g++?

You build it like any other program.  If you have to ask, though...

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]