Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: "Erik Niessen" <erik.niessen@gmail.com>
To: "Erik Niessen" <erik.niessen@gmail.com>, gdb@sourceware.org
Subject: Re: inconsistency in printing out the value of an unsigned short in gdb
Date: Thu, 27 Sep 2007 11:27:00 -0000	[thread overview]
Message-ID: <f21fe8a50709270341u36027f27l70f9cbca5bd97085@mail.gmail.com> (raw)
In-Reply-To: <20070926212800.GC17502@caradoc.them.org>

[-- Attachment #1: Type: text/plain, Size: 659 bytes --]

I ran the readelf -wi on my executable. The output file is attached.
Looking at this debug info all the 3 variables are of type short
unsigned int 2 byte size.
So it looks that the debug info generated by the compiler is correct?

Cheers,
Erik


On 9/26/07, Daniel Jacobowitz <drow@false.org> wrote:
> On Wed, Sep 26, 2007 at 09:35:55AM +0200, Erik Niessen wrote:
> > Hi Daniel,
> >
> > Thanks for your fast reply. I tried with different versions of g++
> > (3.4.6, 4.0, 4.0.4) they all have the same problem.
> > Is there a way how I can check the produced debug info for example via objdump?
>
> Try readelf -wi.
>
> --
> Daniel Jacobowitz
> CodeSourcery
>

[-- Attachment #2: constants++.txt --]
[-- Type: text/plain, Size: 8870 bytes --]

The section .debug_info contains:

  Compilation Unit @ offset 0x0:
   Length:        118
   Version:       2
   Abbrev Offset: 0
   Pointer Size:  4
 <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
     DW_AT_stmt_list   : 0	
     DW_AT_low_pc      : 0x8048378	
     DW_AT_high_pc     : 0x804839a	
     DW_AT_name        : ../sysdeps/i386/elf/start.S	
     DW_AT_comp_dir    : /build/buildd/glibc-2.3.6/build-tree/glibc-2.3.6/csu	
     DW_AT_producer    : GNU AS 2.16.91	
     DW_AT_language    : 32769	(MIPS assembler)
  Compilation Unit @ offset 0x7a:
   Length:        141
   Version:       2
   Abbrev Offset: 20
   Pointer Size:  4
 <0><85>: Abbrev Number: 1 (DW_TAG_compile_unit)
     DW_AT_stmt_list   : 0x5b	
     DW_AT_high_pc     : 0x804839c	
     DW_AT_low_pc      : 0x804839c	
     DW_AT_producer    : (indirect string, offset: 0x62): GNU C 3.4.6 (Ubuntu 3.4.6-1ubuntu2)	
     DW_AT_language    : 1	(ANSI C)
     DW_AT_name        : (indirect string, offset: 0x0): init.c	
     DW_AT_comp_dir    : (indirect string, offset: 0x11): /build/buildd/glibc-2.3.6/build-tree/glibc-2.3.6/csu	
 <1><9f>: Abbrev Number: 2 (DW_TAG_base_type)
     DW_AT_name        : (indirect string, offset: 0x90): unsigned int	
     DW_AT_byte_size   : 4	
     DW_AT_encoding    : 7	(unsigned)
 <1><a6>: Abbrev Number: 2 (DW_TAG_base_type)
     DW_AT_name        : (indirect string, offset: 0x54): unsigned char	
     DW_AT_byte_size   : 1	
     DW_AT_encoding    : 8	(unsigned char)
 <1><ad>: Abbrev Number: 2 (DW_TAG_base_type)
     DW_AT_name        : (indirect string, offset: 0x9d): short unsigned int	
     DW_AT_byte_size   : 2	
     DW_AT_encoding    : 7	(unsigned)
 <1><b4>: Abbrev Number: 2 (DW_TAG_base_type)
     DW_AT_name        : (indirect string, offset: 0x8b): long unsigned int	
     DW_AT_byte_size   : 4	
     DW_AT_encoding    : 7	(unsigned)
 <1><bb>: Abbrev Number: 2 (DW_TAG_base_type)
     DW_AT_name        : (indirect string, offset: 0x56): signed char	
     DW_AT_byte_size   : 1	
     DW_AT_encoding    : 6	(signed char)
 <1><c2>: Abbrev Number: 2 (DW_TAG_base_type)
     DW_AT_name        : (indirect string, offset: 0x7): short int	
     DW_AT_byte_size   : 2	
     DW_AT_encoding    : 5	(signed)
 <1><c9>: Abbrev Number: 3 (DW_TAG_base_type)
     DW_AT_name        : int	
     DW_AT_byte_size   : 4	
     DW_AT_encoding    : 5	(signed)
 <1><d0>: Abbrev Number: 2 (DW_TAG_base_type)
     DW_AT_name        : (indirect string, offset: 0x46): long long int	
     DW_AT_byte_size   : 8	
     DW_AT_encoding    : 5	(signed)
 <1><d7>: Abbrev Number: 2 (DW_TAG_base_type)
     DW_AT_name        : (indirect string, offset: 0x86): long long unsigned int	
     DW_AT_byte_size   : 8	
     DW_AT_encoding    : 7	(unsigned)
 <1><de>: Abbrev Number: 2 (DW_TAG_base_type)
     DW_AT_name        : (indirect string, offset: 0x4b): long int	
     DW_AT_byte_size   : 4	
     DW_AT_encoding    : 5	(signed)
 <1><e5>: Abbrev Number: 2 (DW_TAG_base_type)
     DW_AT_name        : (indirect string, offset: 0x90): unsigned int	
     DW_AT_byte_size   : 4	
     DW_AT_encoding    : 7	(unsigned)
 <1><ec>: Abbrev Number: 2 (DW_TAG_base_type)
     DW_AT_name        : (indirect string, offset: 0x5d): char	
     DW_AT_byte_size   : 1	
     DW_AT_encoding    : 6	(signed char)
 <1><f3>: Abbrev Number: 4 (DW_TAG_variable)
     DW_AT_name        : (indirect string, offset: 0xb0): _IO_stdin_used	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 25	
     DW_AT_type        : <105>	
     DW_AT_external    : 1	
     DW_AT_location    : 5 byte block: 3 68 85 4 8 	(DW_OP_addr: 8048568)
 <1><105>: Abbrev Number: 5 (DW_TAG_const_type)
     DW_AT_type        : <c9>	
  Compilation Unit @ offset 0x10b:
   Length:        140
   Version:       2
   Abbrev Offset: 86
   Pointer Size:  4
 <0><116>: Abbrev Number: 1 (DW_TAG_compile_unit)
     DW_AT_stmt_list   : 0x82	
     DW_AT_name        : /build/buildd/glibc-2.3.6/build-tree/i386-libc/csu/crti.S	
     DW_AT_comp_dir    : /build/buildd/glibc-2.3.6/build-tree/glibc-2.3.6/csu	
     DW_AT_producer    : GNU AS 2.16.91	
     DW_AT_language    : 32769	(MIPS assembler)
  Compilation Unit @ offset 0x19b:
   Length:        414
   Version:       2
   Abbrev Offset: 102
   Pointer Size:  4
 <0><1a6>: Abbrev Number: 1 (DW_TAG_compile_unit)
     DW_AT_stmt_list   : 0x12f	
     DW_AT_high_pc     : 0x804847e	
     DW_AT_low_pc      : 0x804841c	
     DW_AT_producer    : GNU C++ 3.4.6 (Ubuntu 3.4.6-1ubuntu2)	
     DW_AT_language    : 4	(C++)
     DW_AT_name        : constants.c	
     DW_AT_comp_dir    : /home/nly99047/sigma/gdb	
 <1><1ff>: Abbrev Number: 2 (DW_TAG_base_type)
     DW_AT_name        : (indirect string, offset: 0xbf): unsigned int	
     DW_AT_byte_size   : 4	
     DW_AT_encoding    : 7	(unsigned)
 <1><206>: Abbrev Number: 3 (DW_TAG_base_type)
     DW_AT_name        : unsigned char	
     DW_AT_byte_size   : 1	
     DW_AT_encoding    : 8	(unsigned char)
 <1><217>: Abbrev Number: 3 (DW_TAG_base_type)
     DW_AT_name        : short unsigned int	
     DW_AT_byte_size   : 2	
     DW_AT_encoding    : 7	(unsigned)
 <1><22d>: Abbrev Number: 3 (DW_TAG_base_type)
     DW_AT_name        : long unsigned int	
     DW_AT_byte_size   : 4	
     DW_AT_encoding    : 7	(unsigned)
 <1><242>: Abbrev Number: 3 (DW_TAG_base_type)
     DW_AT_name        : signed char	
     DW_AT_byte_size   : 1	
     DW_AT_encoding    : 6	(signed char)
 <1><251>: Abbrev Number: 3 (DW_TAG_base_type)
     DW_AT_name        : short int	
     DW_AT_byte_size   : 2	
     DW_AT_encoding    : 5	(signed)
 <1><25e>: Abbrev Number: 3 (DW_TAG_base_type)
     DW_AT_name        : int	
     DW_AT_byte_size   : 4	
     DW_AT_encoding    : 5	(signed)
 <1><265>: Abbrev Number: 3 (DW_TAG_base_type)
     DW_AT_name        : long long int	
     DW_AT_byte_size   : 8	
     DW_AT_encoding    : 5	(signed)
 <1><276>: Abbrev Number: 3 (DW_TAG_base_type)
     DW_AT_name        : long long unsigned int	
     DW_AT_byte_size   : 8	
     DW_AT_encoding    : 7	(unsigned)
 <1><290>: Abbrev Number: 3 (DW_TAG_base_type)
     DW_AT_name        : long int	
     DW_AT_byte_size   : 4	
     DW_AT_encoding    : 5	(signed)
 <1><29c>: Abbrev Number: 2 (DW_TAG_base_type)
     DW_AT_name        : (indirect string, offset: 0xbf): unsigned int	
     DW_AT_byte_size   : 4	
     DW_AT_encoding    : 7	(unsigned)
 <1><2a3>: Abbrev Number: 3 (DW_TAG_base_type)
     DW_AT_name        : char	
     DW_AT_byte_size   : 1	
     DW_AT_encoding    : 6	(signed char)
 <1><2ab>: Abbrev Number: 4 (DW_TAG_typedef)
     DW_AT_name        : UInt16	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 4	
     DW_AT_type        : <217>	
 <1><2b9>: Abbrev Number: 5 (DW_TAG_subprogram)
     DW_AT_external    : 1	
     DW_AT_name        : main	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 12	
     DW_AT_type        : <25e>	
     DW_AT_low_pc      : 0x804841c	
     DW_AT_high_pc     : 0x804847e	
     DW_AT_frame_base  : 1 byte block: 55 	(DW_OP_reg5)
 <1><2d0>: Abbrev Number: 6 (DW_TAG_namespace)
     DW_AT_sibling     : <311>	
     DW_AT_name        : ::	
     DW_AT_decl_file   : 2	
     DW_AT_decl_line   : 0	
 <2><2da>: Abbrev Number: 7 (DW_TAG_variable)
     DW_AT_name        : c_uint16	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 5	
     DW_AT_type        : <311>	
     DW_AT_declaration : 1	
     DW_AT_const_value : 254	
 <2><2ec>: Abbrev Number: 8 (DW_TAG_variable)
     DW_AT_name        : g_uint16	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 6	
     DW_AT_type        : <2ab>	
     DW_AT_external    : 1	
     DW_AT_declaration : 1	
 <2><2fe>: Abbrev Number: 7 (DW_TAG_variable)
     DW_AT_name        : c_ushort	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 8	
     DW_AT_type        : <32c>	
     DW_AT_declaration : 1	
     DW_AT_const_value : 254	
 <1><311>: Abbrev Number: 9 (DW_TAG_const_type)
     DW_AT_type        : <2ab>	
 <1><316>: Abbrev Number: 10 (DW_TAG_variable)
     DW_AT_specification: <2da>	
     DW_AT_location    : 5 byte block: 3 96 85 4 8 	(DW_OP_addr: 8048596)
 <1><321>: Abbrev Number: 10 (DW_TAG_variable)
     DW_AT_specification: <2ec>	
     DW_AT_location    : 5 byte block: 3 8 97 4 8 	(DW_OP_addr: 8049708)
 <1><32c>: Abbrev Number: 9 (DW_TAG_const_type)
     DW_AT_type        : <217>	
 <1><331>: Abbrev Number: 10 (DW_TAG_variable)
     DW_AT_specification: <2fe>	
     DW_AT_location    : 5 byte block: 3 98 85 4 8 	(DW_OP_addr: 8048598)
  Compilation Unit @ offset 0x33d:
   Length:        140
   Version:       2
   Abbrev Offset: 241
   Pointer Size:  4
 <0><348>: Abbrev Number: 1 (DW_TAG_compile_unit)
     DW_AT_stmt_list   : 0x181	
     DW_AT_name        : /build/buildd/glibc-2.3.6/build-tree/i386-libc/csu/crtn.S	
     DW_AT_comp_dir    : /build/buildd/glibc-2.3.6/build-tree/glibc-2.3.6/csu	
     DW_AT_producer    : GNU AS 2.16.91	
     DW_AT_language    : 32769	(MIPS assembler)


  reply	other threads:[~2007-09-27 10:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-25 14:19 Erik Niessen
2007-09-25 15:57 ` Daniel Jacobowitz
2007-09-26  8:33   ` Erik Niessen
2007-09-26 21:38     ` Daniel Jacobowitz
2007-09-27 11:27       ` Erik Niessen [this message]
2007-09-27 12:15         ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f21fe8a50709270341u36027f27l70f9cbca5bd97085@mail.gmail.com \
    --to=erik.niessen@gmail.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox