This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
archer-swagiaal-using-directive patch on static variables inmethods
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Sami Wagiaalla <swagiaal at redhat dot com>
- Cc: archer at sourceware dot org
- Date: Sat, 29 Nov 2008 01:11:02 +0100
- Subject: archer-swagiaal-using-directive patch on static variables inmethods
- References: <20081124002822.GA9859@host0.dyn.jankratochvil.net> <492C6060.60107@redhat.com> <20081126142322.GA29416@host0.dyn.jankratochvil.net> <492DB4FB.8000303@redhat.com>
On Wed, 26 Nov 2008 21:43:39 +0100, Sami Wagiaalla wrote:
> Jan Kratochvil wrote:
>> Otherwise I saw there an unfortunate duplicity:
>> yours 1de38657622396795ce681e64b03fb74e81e6c3d.
>> mine 60eb8684d0d85d0884aca7a2f013e5eb16a51d47
>> from https://bugzilla.redhat.com/show_bug.cgi?id=445912
>>
>> IMO the my one is right as it avoids entries duplicity but I admit I do not
>> analysed if it may harm. If you disagree I can investigate more the pros/cons
>> of both patches.
>
> That is cool, but are there situations were there are legitimate
> duplicate entries? Wouldn't that be a gcc bug ?
(1) Your patch does not work with my testcase gdb.cp/abstract-origin.exp which
should properly see the `problem' static variable in a method:
A::A(int i)
{
static int *problem = new int(i);
f (problem); /* break-here */
}
The problem is you try to create missing DIEs both for DW_AT_specification and
DW_AT_abstract_origin. But DWARF3 (3.3.8.2+3.3.8.3, pages 64-66/267)
describes such DIEs inheritance only for DW_AT_abstract_origin and not
DW_AT_specification.
DW_AT_specification directs attributes inheritance, not DIEs inheritance.
Attributes inheritance is already handled for both DW_AT_specification and
DW_AT_abstract_origin by dwarf2_attr().
Your patch accidentally skips one inheritance layer but in fact the
DW_AT_specification DIEs inheritance is not right there so the attached
proof-of-concept patch `gdb-sami-abstract_origin-no-specification.patch'
just fixes it to make gdb.cp/abstract-origin.exp working.
Tested on CVS HEAD as the other patches at archer-swagiaal-using-directive
modify this inheritance problem which can be IMO solved on its own on the
current upstream GDB tree.
(2) Your patch does not suppress DIEs duplicity from the list of DIEs
inherited by DW_AT_abstract_origin. In DWARF3 3.3.8.2+3.3.8.3 the text
generally talks about the possibility to omit some entries so there is never
allowed to inherit an entry if it is already present among the current DIE
children.
With the same testcase gdb.cp/abstract-origin.exp you may break at
My patch suppressing the duplicities:
`/* break-here */' and compare both patches:
Breakpoint 1, A (this=0x7fffffffd32f, i=42) at ../.././gdb/testsuite/gdb.cp/abstract-origin.cc:30
30 f (problem); /* break-here */
vs. your patch inheriting everything unconditionally:
Breakpoint 1, A (this=<value optimized out>, i=<value optimized out>, this=<value optimized out>, i=<value optimized out>)
at ../.././gdb/testsuite/gdb.cp/abstract-origin.cc:30
30 f (problem); /* break-here */
(In fact I do not see now why there is <value optimized out> but I find enough
the parameters are duplicated.)
Regards,
Jan
Dumps of the testcase for your convenience.
------------------------------------------------------------------------------
/* This testcase is part of GDB, the GNU debugger.
Copyright 2008 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
extern void f (int *);
class A
{
public:
A(int i);
};
A::A(int i)
{
static int *problem = new int(i);
f (problem); /* break-here */
}
void f (int *)
{
}
int
main (void)
{
A a(42);
return 0;
}
------------------------------------------------------------------------------
The section .debug_info contains:
Compilation Unit @ offset 0x0:
Length: 0x148 (32-bit)
Version: 2
Abbrev Offset: 0
Pointer Size: 8
<0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
< c> DW_AT_producer : (indirect string, offset: 0xf): GNU C++ 4.3.2 20081105 (Red Hat 4.3.2-7)
<10> DW_AT_language : 4 (C++)
<11> DW_AT_name : (indirect string, offset: 0x74): ../.././gdb/testsuite/gdb.cp/abstract-origin.cc
<15> DW_AT_comp_dir : (indirect string, offset: 0x3d): /home/jkratoch/redhat/gdb-cvs-clean/gdb/testsuite
<19> DW_AT_low_pc : 0x40073c
<21> DW_AT_high_pc : 0x4008bd
<29> DW_AT_stmt_list : 0x0
<1><2d>: Abbrev Number: 2 (DW_TAG_class_type)
<2e> DW_AT_name : A
<30> DW_AT_byte_size : 1
<31> DW_AT_decl_file : 1
<32> DW_AT_decl_line : 22
<33> DW_AT_sibling : <0x4b>
<2><37>: Abbrev Number: 3 (DW_TAG_subprogram)
<38> DW_AT_external : 1
<39> DW_AT_name : A
<3b> DW_AT_decl_file : 1
<3c> DW_AT_decl_line : 24
<3d> DW_AT_declaration : 1
<3><3e>: Abbrev Number: 4 (DW_TAG_formal_parameter)
<3f> DW_AT_type : <0x4b>
<43> DW_AT_artificial : 1
<3><44>: Abbrev Number: 5 (DW_TAG_formal_parameter)
<45> DW_AT_type : <0x51>
<1><4b>: Abbrev Number: 6 (DW_TAG_pointer_type)
<4c> DW_AT_byte_size : 8
<4d> DW_AT_type : <0x2d>
<1><51>: Abbrev Number: 7 (DW_TAG_base_type)
<52> DW_AT_byte_size : 4
<53> DW_AT_encoding : 5 (signed)
<54> DW_AT_name : int
<1><58>: Abbrev Number: 8 (DW_TAG_subprogram)
<59> DW_AT_external : 1
<5a> DW_AT_name : f
<5c> DW_AT_decl_file : 1
<5d> DW_AT_decl_line : 33
<5e> DW_AT_MIPS_linkage_name: (indirect string, offset: 0x0): _Z1fPi
<62> DW_AT_low_pc : 0x40073c
<6a> DW_AT_high_pc : 0x400746
<72> DW_AT_frame_base : 0x0 (location list)
<76> DW_AT_sibling : <0x83>
<2><7a>: Abbrev Number: 9 (DW_TAG_formal_parameter)
<7b> DW_AT_type : <0x83>
<7f> DW_AT_location : 2 byte block: 91 68 (DW_OP_fbreg: -24)
<1><83>: Abbrev Number: 6 (DW_TAG_pointer_type)
<84> DW_AT_byte_size : 8
<85> DW_AT_type : <0x51>
<1><89>: Abbrev Number: 10 (DW_TAG_subprogram)
<8a> DW_AT_specification: <0x37>
<8e> DW_AT_decl_line : 27
<8f> DW_AT_inline : 0 (not inlined)
<90> DW_AT_sibling : <0xbd>
<2><94>: Abbrev Number: 11 (DW_TAG_formal_parameter)
<95> DW_AT_name : (indirect string, offset: 0x38): this
<99> DW_AT_type : <0xbd>
<9d> DW_AT_artificial : 1
<2><9e>: Abbrev Number: 12 (DW_TAG_formal_parameter)
<9f> DW_AT_name : i
<a1> DW_AT_decl_file : 1
<a2> DW_AT_decl_line : 27
<a3> DW_AT_type : <0x51>
<2><a7>: Abbrev Number: 13 (DW_TAG_variable)
<a8> DW_AT_name : (indirect string, offset: 0x7): problem
<ac> DW_AT_decl_file : 1
<ad> DW_AT_decl_line : 29
<ae> DW_AT_type : <0x83>
<b2> DW_AT_location : 9 byte block: 3 70 d 60 0 0 0 0 0 (DW_OP_addr: 600d70)
<1><bd>: Abbrev Number: 14 (DW_TAG_const_type)
<be> DW_AT_type : <0x4b>
<1><c2>: Abbrev Number: 15 (DW_TAG_subprogram)
<c3> DW_AT_abstract_origin: <0x89>
<c7> DW_AT_low_pc : 0x400746
<cf> DW_AT_high_pc : 0x4007f3
<d7> DW_AT_frame_base : 0x4c (location list)
<db> DW_AT_sibling : <0xf0>
<2><df>: Abbrev Number: 16 (DW_TAG_formal_parameter)
<e0> DW_AT_abstract_origin: <0x94>
<e4> DW_AT_location : 2 byte block: 91 68 (DW_OP_fbreg: -24)
<2><e7>: Abbrev Number: 16 (DW_TAG_formal_parameter)
<e8> DW_AT_abstract_origin: <0x9e>
<ec> DW_AT_location : 2 byte block: 91 64 (DW_OP_fbreg: -28)
<1><f0>: Abbrev Number: 17 (DW_TAG_subprogram)
<f1> DW_AT_external : 1
<f2> DW_AT_name : (indirect string, offset: 0x6f): main
<f6> DW_AT_decl_file : 1
<f7> DW_AT_decl_line : 38
<f8> DW_AT_type : <0x51>
<fc> DW_AT_low_pc : 0x4007f3
<104> DW_AT_high_pc : 0x400810
<10c> DW_AT_frame_base : 0x98 (location list)
<110> DW_AT_sibling : <0x121>
<2><114>: Abbrev Number: 18 (DW_TAG_variable)
<115> DW_AT_name : a
<117> DW_AT_decl_file : 1
<118> DW_AT_decl_line : 40
<119> DW_AT_type : <0x2d>
<11d> DW_AT_location : 2 byte block: 91 6f (DW_OP_fbreg: -17)
<1><121>: Abbrev Number: 19 (DW_TAG_subprogram)
<122> DW_AT_abstract_origin: <0x89>
<126> DW_AT_low_pc : 0x400810
<12e> DW_AT_high_pc : 0x4008bd
<136> DW_AT_frame_base : 0xe4 (location list)
<2><13a>: Abbrev Number: 16 (DW_TAG_formal_parameter)
<13b> DW_AT_abstract_origin: <0x94>
<13f> DW_AT_location : 2 byte block: 91 68 (DW_OP_fbreg: -24)
<2><142>: Abbrev Number: 16 (DW_TAG_formal_parameter)
<143> DW_AT_abstract_origin: <0x9e>
<147> DW_AT_location : 2 byte block: 91 64 (DW_OP_fbreg: -28)
------------------------------------------------------------------------------
--- gdb/dwarf2read.c-sami 2008-11-29 00:42:51.000000000 +0100
+++ gdb/dwarf2read.c 2008-11-29 00:44:21.000000000 +0100
@@ -3046,10 +3046,14 @@ explore_abstract_origin (struct die_info
/* If this die has an abstract origin then explore that as well
it might contain useful information such as import statements. */
+#if 0
abstract_origin = dwarf2_attr (die, DW_AT_specification, cu);
if(abstract_origin == NULL){
+#endif
abstract_origin = dwarf2_attr (die, DW_AT_abstract_origin, cu);
+#if 0
}
+#endif
if(abstract_origin != NULL){
abstract_origin_die = follow_die_ref (die, abstract_origin, &cu);