This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

c/7030: Bad DWARF with volatile + structs


>Number:         7030
>Category:       c
>Synopsis:       Incorrect DWARF
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jun 14 06:06:02 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     James Cownie
>Release:        3.1
>Organization:
>Environment:
System: Linux pc4 2.4.18 #1 Tue Apr 2 10:17:01 BST 2002 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: /home1/GNU/gcc-3.1/configure 
>Description:
This code

struct foo
{
  int ia;
  int ib;
};

struct bah
{
  volatile struct foo fa;
  int fb;
};

int main (int argc, char ** argv)
{
  struct foo f;
  struct bah b;

  f.ia = 999;
  f.ib = -999;

  b.fa = f;

  {
    const struct foo cf = f;
    int i = 0;
  }
}

compiled with -g produces DWARF like this
% readelf -w foo
The section .debug_aranges contains:

  Length:                   28
  Version:                  2
  Offset into .debug_info:  0
  Pointer Size:             4
  Segment Size:             0

    Address  Length
    08048380 63

Contents of the .debug_pubnames section:

  Length:                              23
  Version:                             2
  Offset into .debug_info section:     0
  Size of area in .debug_info section: 339

    Offset	Name
    195		main

The section .debug_info contains:

  Compilation Unit @ 0:
   Length:        335
   Version:       2
   Abbrev Offset: 0
   Pointer Size:  4
 <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
     DW_AT_stmt_list   : 0	
     DW_AT_high_pc     : 0x80483bf 134513599	
     DW_AT_low_pc      : 0x8048380 134513536	
     DW_AT_name        : tx_struct.c	
     DW_AT_comp_dir    : /home1/jim/build/linux_x86/totalview/debugger/src/regress	
     DW_AT_producer    : GNU C 3.1	
     DW_AT_language    : 1	(ANSI C)
 <1><69>: Abbrev Number: 2 (DW_TAG_structure_type)
     DW_AT_sibling     : <90>	
     DW_AT_name        : foo	
     DW_AT_byte_size   : 8	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 2	
 <2><75>: Abbrev Number: 3 (DW_TAG_member)
     DW_AT_name        : ia	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 3	
     DW_AT_type        : <90>	
     DW_AT_data_member_location: 2 byte block: 23 0 	(DW_OP_plus_uconst: 0; )
 <2><82>: Abbrev Number: 3 (DW_TAG_member)
     DW_AT_name        : ib	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 4	
     DW_AT_type        : <90>	
     DW_AT_data_member_location: 2 byte block: 23 4 	(DW_OP_plus_uconst: 4; )
 <1><90>: Abbrev Number: 4 (DW_TAG_base_type)
     DW_AT_name        : int	
     DW_AT_byte_size   : 4	
     DW_AT_encoding    : 5	(signed)
 <1><97>: Abbrev Number: 2 (DW_TAG_structure_type)
     DW_AT_sibling     : <be>	
     DW_AT_name        : bah	
     DW_AT_byte_size   : 12	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 8	
 <2><a3>: Abbrev Number: 3 (DW_TAG_member)
     DW_AT_name        : fa	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 9	
     DW_AT_type        : <be>	
     DW_AT_data_member_location: 2 byte block: 23 0 	(DW_OP_plus_uconst: 0; )
 <2><b0>: Abbrev Number: 3 (DW_TAG_member)
     DW_AT_name        : fb	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 10	
     DW_AT_type        : <90>	
     DW_AT_data_member_location: 2 byte block: 23 8 	(DW_OP_plus_uconst: 8; )
 <1><be>: Abbrev Number: 5 (DW_TAG_volatile_type)
     DW_AT_type        : <69>	
 <1><c3>: Abbrev Number: 6 (DW_TAG_subprogram)
     DW_AT_sibling     : <139>	
     DW_AT_external    : 1	
     DW_AT_name        : main	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 14	
     DW_AT_prototyped  : 1	
     DW_AT_type        : <90>	
     DW_AT_low_pc      : 0x8048380 134513536	
     DW_AT_high_pc     : 0x80483bf 134513599	
     DW_AT_frame_base  : 1 byte block: 55 	(DW_OP_reg5; )
 <2><df>: Abbrev Number: 7 (DW_TAG_formal_parameter)
     DW_AT_name        : argc	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 13	
     DW_AT_type        : <90>	
     DW_AT_location    : 2 byte block: 91 8 	(DW_OP_fbreg: 8; )
 <2><ee>: Abbrev Number: 7 (DW_TAG_formal_parameter)
     DW_AT_name        : argv	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 13	
     DW_AT_type        : <139>	
     DW_AT_location    : 2 byte block: 91 c 	(DW_OP_fbreg: 12; )
 <2><fd>: Abbrev Number: 8 (DW_TAG_variable)
     DW_AT_name        : f	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 15	
     DW_AT_type        : <be>	
     DW_AT_location    : 2 byte block: 91 70 	(DW_OP_fbreg: -16; )
 <2><109>: Abbrev Number: 8 (DW_TAG_variable)
     DW_AT_name        : b	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 16	
     DW_AT_type        : <97>	
     DW_AT_location    : 2 byte block: 91 58 	(DW_OP_fbreg: -40; )
 <2><115>: Abbrev Number: 9 (DW_TAG_lexical_block)
     DW_AT_low_pc      : 0x80483aa 134513578	
     DW_AT_high_pc     : 0x80483bd 134513597	
 <3><11e>: Abbrev Number: 8 (DW_TAG_variable)
     DW_AT_name        : cf	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 24	
     DW_AT_type        : <14d>	
     DW_AT_location    : 2 byte block: 91 50 	(DW_OP_fbreg: -48; )
 <3><12b>: Abbrev Number: 8 (DW_TAG_variable)
     DW_AT_name        : i	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 25	
     DW_AT_type        : <90>	
     DW_AT_location    : 2 byte block: 91 4c 	(DW_OP_fbreg: -52; )
 <1><139>: Abbrev Number: 10 (DW_TAG_pointer_type)
     DW_AT_byte_size   : 4	
     DW_AT_type        : <13f>	
 <1><13f>: Abbrev Number: 10 (DW_TAG_pointer_type)
     DW_AT_byte_size   : 4	
     DW_AT_type        : <145>	
 <1><145>: Abbrev Number: 4 (DW_TAG_base_type)
     DW_AT_name        : char	
     DW_AT_byte_size   : 1	
     DW_AT_encoding    : 6	(signed char)
 <1><14d>: Abbrev Number: 11 (DW_TAG_const_type)
     DW_AT_type        : <be>	

Observe that the type of the variable 'f' iat <fd> is given as type
<be> which is volatile struct foo.

However in the source the type is unadorned struct foo.

>How-To-Repeat:
As above.
>Fix:
	


>Release-Note:
>Audit-Trail:
>Unformatted:


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