This is the mail archive of the gdb-prs@sources.redhat.com mailing list for the GDB 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: c++/1234: local variables in destructor ignored


The following reply was made to PR c++/1234; it has been noted by GNATS.

From: Daniel Jacobowitz <drow@mvista.com>
To: Michael Vanier <mvanier@cs.caltech.edu>
Cc: jimb@redhat.com, gdb-gnats@sources.redhat.com
Subject: Re: c++/1234: local variables in destructor ignored
Date: Wed, 4 Jun 2003 21:51:48 -0400

 Hmm, this is probably related to a similar problem in constructors: see
 debug/10156 for GCC.
 
 On Thu, Jun 05, 2003 at 01:28:00AM -0000, Michael Vanier wrote:
 > The following reply was made to PR c++/1234; it has been noted by GNATS.
 > 
 > From: Michael Vanier <mvanier@cs.caltech.edu>
 > To: jimb@redhat.com
 > Cc: gdb-gnats@sources.redhat.com
 > Subject: Re: c++/1234: local variables in destructor ignored
 > Date: Wed, 4 Jun 2003 18:25:52 -0700
 > 
 >  Jim,
 >  
 >  Thanks for looking at this so quickly.  I believe you are correct; at
 >  least, my output matches yours pretty closely (though the numbers are
 >  different).  I've submitted it at the end for your perusal.
 >  
 >  What's the procedure here?  Do I send in a bug report to gcc/g++ or can
 >  you forward this one?  I don't really understand the Dwarf format, so I may
 >  not be able to explain it as well...
 >  
 >  Mike
 >  
 >  
 >  > From: Jim Blandy <jimb@redhat.com>
 >  > Date: 04 Jun 2003 19:00:15 -0500
 >  > 
 >  > I think this is a compiler bug.  It looks to me like the debugging
 >  > info generated by the compiler doesn't tell GDB what it needs to know
 >  > to be able to print local variables in the destructor.
 >  > 
 >  > Michael, could you look at the debugging info in your program, and
 >  > verify that it's as I describe here?  If so, then I think this is a
 >  > G++ bug, not a GDB bug.
 >  > 
 >  >     $ cat foo.cc
 >  >     class Test {
 >  >     private:
 >  >         int *data;
 >  >     public:
 >  >         Test();
 >  >        ~Test();
 >  >     };
 >  > 
 >  >     Test::Test() {
 >  >         data = new int[1000];
 >  >     }
 >  > 
 >  >     Test::~Test() {
 >  >         int *t = data;
 >  >         delete [] t;
 >  >     }
 >  > 
 >  > 
 >  >     int main() {
 >  >         Test s;
 >  > 
 >  >         return 0;
 >  >     }
 >  > 
 >  >     $ $Gcc33B/g++ -g foo.cc -o foo
 >  >     $ readelf -wi foo > foo.wi~
 >  > 
 >  > Now foo.wi~, which contains the Dwarf debugging info in human-readable
 >  > form.  The info for ~Test we see is this:
 >  > 
 >  >  <1><c57>: Abbrev Number: 2 (DW_TAG_structure_type)
 >  >      DW_AT_sibling     : <cd5>	
 >  >      DW_AT_name        : (indirect string, offset: 0x9c1): Test	
 >  >      DW_AT_byte_size   : 4	
 >  >      DW_AT_decl_file   : 1	
 >  >      DW_AT_decl_line   : 1	
 >  >  ...
 >  >  <2><cbe>: Abbrev Number: 9 (DW_TAG_subprogram)
 >  >      DW_AT_external    : 1	
 >  >      DW_AT_name        : (indirect string, offset: 0x9c0): ~Test	
 >  >      DW_AT_decl_file   : 1	
 >  >      DW_AT_decl_line   : 6	
 >  >      DW_AT_declaration : 1	
 >  >  <3><cc7>: Abbrev Number: 5 (DW_TAG_formal_parameter)
 >  >      DW_AT_type        : <ce8>	
 >  >      DW_AT_artificial  : 1	
 >  >  <3><ccd>: Abbrev Number: 5 (DW_TAG_formal_parameter)
 >  >      DW_AT_type        : <cdb>	
 >  >      DW_AT_artificial  : 1	
 >  > 
 >  > This is for the declaration of ~Test inside the class declaration.
 >  > It's just a declaration; the following subtree is the definition:
 >  > 
 >  >  <1><d4c>: Abbrev Number: 14 (DW_TAG_subprogram)
 >  >      DW_AT_sibling     : <d75>	
 >  >      DW_AT_specification: <cbe>	
 >  >      DW_AT_decl_line   : 13	
 >  >      DW_AT_inline      : 2	(declared as inline but ignored)
 >  >  <2><d57>: Abbrev Number: 15 (DW_TAG_formal_parameter)
 >  >      DW_AT_name        : (indirect string, offset: 0x98a): this	
 >  >      DW_AT_type        : <d0f>	
 >  >      DW_AT_artificial  : 1	
 >  >  <2><d61>: Abbrev Number: 15 (DW_TAG_formal_parameter)
 >  >      DW_AT_name        : (indirect string, offset: 0x9c6): __in_chrg	
 >  >      DW_AT_type        : <d75>	
 >  >      DW_AT_artificial  : 1	
 >  >  <2><d6b>: Abbrev Number: 18 (DW_TAG_variable)
 >  >      DW_AT_name        : t	
 >  >      DW_AT_decl_file   : 1	
 >  >      DW_AT_decl_line   : 14	
 >  >      DW_AT_type        : <cd5>	
 >  > 
 >  > It has a DW_AT_specification attribute pointing to the declaration
 >  > die, <cbe>.  It does have an entry for 't'.
 >  > 
 >  > But what's missing here are DW_AT_low_pc and DW_AT_high_pc entries,
 >  > like those present on the other DW_AT_subprogram entries.  Without
 >  > that, GDB has no idea that this debugging information applies to the
 >  > code addresses for Test::~Test().
 >  > 
 >  > The entry for 't' is also lacking a DW_AT_location attribute, so even
 >  > if GDB knew the addreses for Test::~Test (), it wouldn't be able to
 >  > find 't'.
 >  > 
 >  
 >  My output for the same file as above (saved as foo.cc):
 >  
 >  The section .debug_info contains:
 >  
 >    Compilation Unit @ 0:
 >     Length:        429
 >     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     : 0x8048519 134513945	
 >       DW_AT_low_pc      : 0x8048458 134513752	
 >       DW_AT_name        : (indirect string, offset: 0x5): foo.cc	
 >       DW_AT_comp_dir    : (indirect string, offset: 0x2c): /home/mvanier/tmp/cs11	
 >       DW_AT_producer    : (indirect string, offset: 0xc): GNU C++ 3.3 (Debian)	
 >       DW_AT_language    : 4	(C++)
 >   <1><25>: Abbrev Number: 2 (DW_TAG_structure_type)
 >       DW_AT_sibling     : <a3>	
 >       DW_AT_name        : (indirect string, offset: 0x27): Test	
 >       DW_AT_byte_size   : 4	
 >       DW_AT_decl_file   : 1	
 >       DW_AT_decl_line   : 1	
 >   <2><31>: Abbrev Number: 3 (DW_TAG_member)
 >       DW_AT_name        : (indirect string, offset: 0x57): data	
 >       DW_AT_decl_file   : 1	
 >       DW_AT_decl_line   : 3	
 >       DW_AT_type        : <a3>	
 >       DW_AT_data_member_location: 2 byte block: 23 0 	(DW_OP_plus_uconst: 0)
 >       DW_AT_accessibility: 3	(private)
 >   <2><40>: Abbrev Number: 4 (DW_TAG_subprogram)
 >       DW_AT_sibling     : <60>	
 >       DW_AT_external    : 1	
 >       DW_AT_name        : (indirect string, offset: 0x4d): operator=	
 >       DW_AT_MIPS_linkage_name: (indirect string, offset: 0x5c): _ZN4TestaSERKS_	
 >       DW_AT_type        : <b0>	
 >       DW_AT_artificial  : 1	
 >       DW_AT_declaration : 1	
 >   <3><54>: Abbrev Number: 5 (DW_TAG_formal_parameter)
 >       DW_AT_type        : <b6>	
 >       DW_AT_artificial  : 1	
 >   <3><5a>: Abbrev Number: 6 (DW_TAG_formal_parameter)
 >       DW_AT_type        : <bc>	
 >   <2><60>: Abbrev Number: 7 (DW_TAG_subprogram)
 >       DW_AT_sibling     : <78>	
 >       DW_AT_external    : 1	
 >       DW_AT_name        : (indirect string, offset: 0x27): Test	
 >       DW_AT_artificial  : 1	
 >       DW_AT_declaration : 1	
 >   <3><6c>: Abbrev Number: 5 (DW_TAG_formal_parameter)
 >       DW_AT_type        : <b6>	
 >       DW_AT_artificial  : 1	
 >   <3><72>: Abbrev Number: 6 (DW_TAG_formal_parameter)
 >       DW_AT_type        : <bc>	
 >   <2><78>: Abbrev Number: 8 (DW_TAG_subprogram)
 >       DW_AT_sibling     : <8c>	
 >       DW_AT_external    : 1	
 >       DW_AT_name        : (indirect string, offset: 0x27): Test	
 >       DW_AT_decl_file   : 1	
 >       DW_AT_decl_line   : 5	
 >       DW_AT_declaration : 1	
 >   <3><85>: Abbrev Number: 5 (DW_TAG_formal_parameter)
 >       DW_AT_type        : <b6>	
 >       DW_AT_artificial  : 1	
 >   <2><8c>: Abbrev Number: 9 (DW_TAG_subprogram)
 >       DW_AT_external    : 1	
 >       DW_AT_name        : (indirect string, offset: 0x26): ~Test	
 >       DW_AT_decl_file   : 1	
 >       DW_AT_decl_line   : 6	
 >       DW_AT_declaration : 1	
 >   <3><95>: Abbrev Number: 5 (DW_TAG_formal_parameter)
 >       DW_AT_type        : <b6>	
 >       DW_AT_artificial  : 1	
 >   <3><9b>: Abbrev Number: 5 (DW_TAG_formal_parameter)
 >       DW_AT_type        : <a9>	
 >       DW_AT_artificial  : 1	
 >   <1><a3>: Abbrev Number: 10 (DW_TAG_pointer_type)
 >       DW_AT_byte_size   : 4	
 >       DW_AT_type        : <a9>	
 >   <1><a9>: Abbrev Number: 11 (DW_TAG_base_type)
 >       DW_AT_name        : int	
 >       DW_AT_byte_size   : 4	
 >       DW_AT_encoding    : 5	(signed)
 >   <1><b0>: Abbrev Number: 12 (DW_TAG_reference_type)
 >       DW_AT_byte_size   : 4	
 >       DW_AT_type        : <25>	
 >   <1><b6>: Abbrev Number: 10 (DW_TAG_pointer_type)
 >       DW_AT_byte_size   : 4	
 >       DW_AT_type        : <25>	
 >   <1><bc>: Abbrev Number: 12 (DW_TAG_reference_type)
 >       DW_AT_byte_size   : 4	
 >       DW_AT_type        : <c2>	
 >   <1><c2>: Abbrev Number: 13 (DW_TAG_const_type)
 >       DW_AT_type        : <25>	
 >   <1><c7>: Abbrev Number: 14 (DW_TAG_subprogram)
 >       DW_AT_sibling     : <dd>	
 >       DW_AT_specification: <78>	
 >       DW_AT_decl_line   : 9	
 >       DW_AT_inline      : 2	(declared as inline but ignored)
 >   <2><d2>: Abbrev Number: 15 (DW_TAG_formal_parameter)
 >       DW_AT_name        : (indirect string, offset: 0x0): this	
 >       DW_AT_type        : <dd>	
 >       DW_AT_artificial  : 1	
 >   <1><dd>: Abbrev Number: 13 (DW_TAG_const_type)
 >       DW_AT_type        : <b6>	
 >   <1><e2>: Abbrev Number: 16 (DW_TAG_subprogram)
 >       DW_AT_sibling     : <fe>	
 >       DW_AT_abstract_origin: <c7>	
 >       DW_AT_low_pc      : 0x8048458 134513752	
 >       DW_AT_high_pc     : 0x8048479 134513785	
 >       DW_AT_frame_base  : 1 byte block: 55 	(DW_OP_reg5)
 >   <2><f5>: Abbrev Number: 17 (DW_TAG_formal_parameter)
 >       DW_AT_abstract_origin: <d2>	
 >       DW_AT_location    : 2 byte block: 91 8 	(DW_OP_fbreg: 8)
 >   <1><fe>: Abbrev Number: 16 (DW_TAG_subprogram)
 >       DW_AT_sibling     : <11a>	
 >       DW_AT_abstract_origin: <c7>	
 >       DW_AT_low_pc      : 0x804847a 134513786	
 >       DW_AT_high_pc     : 0x804849b 134513819	
 >       DW_AT_frame_base  : 1 byte block: 55 	(DW_OP_reg5)
 >   <2><111>: Abbrev Number: 17 (DW_TAG_formal_parameter)
 >       DW_AT_abstract_origin: <d2>	
 >       DW_AT_location    : 2 byte block: 91 8 	(DW_OP_fbreg: 8)
 >   <1><11a>: Abbrev Number: 14 (DW_TAG_subprogram)
 >       DW_AT_sibling     : <143>	
 >       DW_AT_specification: <8c>	
 >       DW_AT_decl_line   : 13	
 >       DW_AT_inline      : 2	(declared as inline but ignored)
 >   <2><125>: Abbrev Number: 15 (DW_TAG_formal_parameter)
 >       DW_AT_name        : (indirect string, offset: 0x0): this	
 >       DW_AT_type        : <dd>	
 >       DW_AT_artificial  : 1	
 >   <2><12f>: Abbrev Number: 15 (DW_TAG_formal_parameter)
 >       DW_AT_name        : (indirect string, offset: 0x43): __in_chrg	
 >       DW_AT_type        : <143>	
 >       DW_AT_artificial  : 1	
 >   <2><139>: Abbrev Number: 18 (DW_TAG_variable)
 >       DW_AT_name        : t	
 >       DW_AT_decl_file   : 1	
 >       DW_AT_decl_line   : 14	
 >       DW_AT_type        : <a3>	
 >   <1><143>: Abbrev Number: 13 (DW_TAG_const_type)
 >       DW_AT_type        : <a9>	
 >   <1><148>: Abbrev Number: 16 (DW_TAG_subprogram)
 >       DW_AT_sibling     : <16c>	
 >       DW_AT_abstract_origin: <11a>	
 >       DW_AT_low_pc      : 0x804849c 134513820	
 >       DW_AT_high_pc     : 0x80484c0 134513856	
 >       DW_AT_frame_base  : 1 byte block: 55 	(DW_OP_reg5)
 >   <2><15b>: Abbrev Number: 17 (DW_TAG_formal_parameter)
 >       DW_AT_abstract_origin: <125>	
 >       DW_AT_location    : 2 byte block: 91 8 	(DW_OP_fbreg: 8)
 >   <2><163>: Abbrev Number: 19 (DW_TAG_variable)
 >       DW_AT_abstract_origin: <139>	
 >       DW_AT_location    : 2 byte block: 91 7c 	(DW_OP_fbreg: -4)
 >   <1><16c>: Abbrev Number: 16 (DW_TAG_subprogram)
 >       DW_AT_sibling     : <18d>	
 >       DW_AT_abstract_origin: <11a>	
 >       DW_AT_low_pc      : 0x80484c0 134513856	
 >       DW_AT_high_pc     : 0x80484e4 134513892	
 >       DW_AT_frame_base  : 1 byte block: 55 	(DW_OP_reg5)
 >   <2><17f>: Abbrev Number: 17 (DW_TAG_formal_parameter)
 >       DW_AT_abstract_origin: <125>	
 >       DW_AT_location    : 2 byte block: 91 8 	(DW_OP_fbreg: 8)
 >   <2><187>: Abbrev Number: 20 (DW_TAG_variable)
 >       DW_AT_abstract_origin: <139>	
 >   <1><18d>: Abbrev Number: 21 (DW_TAG_subprogram)
 >       DW_AT_external    : 1	
 >       DW_AT_name        : (indirect string, offset: 0x21): main	
 >       DW_AT_decl_file   : 1	
 >       DW_AT_decl_line   : 19	
 >       DW_AT_type        : <a9>	
 >       DW_AT_low_pc      : 0x80484e4 134513892	
 >       DW_AT_high_pc     : 0x8048519 134513945	
 >       DW_AT_frame_base  : 1 byte block: 55 	(DW_OP_reg5)
 >   <2><1a3>: Abbrev Number: 22 (DW_TAG_variable)
 >       DW_AT_name        : s	
 >       DW_AT_decl_file   : 1	
 >       DW_AT_decl_line   : 20	
 >       DW_AT_type        : <25>	
 >       DW_AT_location    : 2 byte block: 91 68 	(DW_OP_fbreg: -24)
 >  
 >  End of output.
 >  
 > 
 
 -- 
 Daniel Jacobowitz
 MontaVista Software                         Debian GNU/Linux Developer


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