[PATCH] PR debug/43325
Dodji Seketeli
dodji@redhat.com
Wed Mar 31 09:58:00 GMT 2010
Hello,
In this example,
int
f()
{
int i = 42; //#1
{
extern int i; //#2
return i;
}
}
we fail to emit debug info for the (re)declaration of 'i' in #2.
The debugger subsequently fails to show 'i' as belonging to the
innermost lexical block.
The patch below allows "redeclarations" debug info when they happen
inside functions.
Tested on x86_64-unknown-linux-gnu against trunk.
Dodji
commit 339891ac1997036eac6897fb302f776e206e10a7
Author: Dodji Seketeli <dodji@redhat.com>
Date: Thu Mar 25 20:50:17 2010 +0100
Fix for PR debug/43325
gcc/ChangeLog:
PR debug/43325
* dwarf2out.c (gen_variable_die): Allow debug info for variable
re-declaration when it happens in a function.
gcc/testsuite/ChangeLog:
PR debug/43325
* g++.dg/debug/dwarf2/redeclaration-1.C: New test case.
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 84a5fe7..6f8ee95 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -18238,9 +18238,9 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die)
/* If the compiler emitted a definition for the DECL declaration
and if we already emitted a DIE for it, don't emit a second
- DIE for it again. */
- if (old_die
- && declaration)
+ DIE for it again. Allow re-declarations of DECLs that are
+ inside functions, though. */
+ if (old_die && declaration && !local_scope_p (context_die))
return;
/* For static data members, the declaration in the class is supposed
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/redeclaration-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/redeclaration-1.C
new file mode 100644
index 0000000..8aaff8e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/redeclaration-1.C
@@ -0,0 +1,18 @@
+// Origin: PR debug/43325
+// { dg-options "-g -dA" }
+// { dg-do compile }
+
+// { dg-final { scan-assembler-times "\[^\n\r\]*\\(DIE \[^\n\r\]*DW_TAG_lexical_block\\)\[\n\r\]{1,2}\[^\n\r\]*DW_AT_low_pc\[\n\r\]{1,2}\[^\n\r\]*DW_AT_high_pc\[\n\r\]{1,2}\[^\n\r\]*\\(DIE \[^\n\r\]*DW_TAG_variable\\)\[\n\r\]{1,2}\[^\n\r\]*DW_AT_name" 2 } }
+
+namespace S
+{
+ int
+ f()
+ {
+ int i = 42;
+ {
+ extern int i;
+ return i;
+ }
+ }
+}
More information about the Gcc-patches
mailing list