delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/12/08/10:38:56

X-Spam-Check-By: sourceware.org
Message-ID: <43985387.52343579@dessent.net>
Date: Thu, 08 Dec 2005 07:38:47 -0800
From: Brian Dessent <brian AT dessent DOT net>
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Extracting Debug (meta data) from executable images?
References: <30499572 DOT 1134019067348 DOT JavaMail DOT SYSTEM AT CCC-NOVA1>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019