This is the mail archive of the 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]

[3.4] Fix C structure nesting for dwarf2out

There's a bug in gcc 3.4.x which causes a test like this:

struct a;
struct b {
  struct a *a1;
struct a {
  int b2;
int foo (struct b *b3) { return b3->a1->b2; }

to output DWARF-2 information where struct a's definition is a child of
struct b.  This causes GDB to miss struct a until it has read in a full
symbol table.

The bug was caused by TRANSLATION_UNIT_DECL support; scope_die_for gets one
of these for TYPE_CONTEXT when it expects NULL.  Mark fixed this on the
Solaris 10 branch a couple of months ago, and I'd like to apply the fix to
3.4.  OK?

I don't think the patch is necessary for HEAD; even with -combine, the
context always seems to be NULL by that point.  Geoff and Zack, I've copied
you hoping that one of you can confirm that the test for NULL_TREE is safe
again now... Mark said something about a lowering pass which removes the

Daniel Jacobowitz

2004-09-22  Mark Mitchell  <>

	* gcc/dwarf2out.c (scope_die_for): If the containing scope is a
	TRANSLATION_UNIT_DECL, consider it to be a global.

Index: dwarf2out.c
RCS file: /big/fsf/rsync/gcc-cvs/gcc/gcc/dwarf2out.c,v
retrieving revision 1.478.2.10
retrieving revision 1.478.
diff -u -p -r1.478.2.10 -r1.478.
--- dwarf2out.c	24 Aug 2004 02:07:22 -0000	1.478.2.10
+++ dwarf2out.c	23 Sep 2004 07:27:07 -0000	1.478.
@@ -10215,7 +10215,8 @@ scope_die_for (tree t, dw_die_ref contex
   if (containing_scope && TREE_CODE (containing_scope) == FUNCTION_TYPE)
     containing_scope = NULL_TREE;
-  if (containing_scope == NULL_TREE)
+  if (containing_scope == NULL_TREE 
+      || TREE_CODE (containing_scope) == TRANSLATION_UNIT_DECL)
     scope_die = comp_unit_die;
   else if (TYPE_P (containing_scope))

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