Bug 77931 - PASS->FAIL: gdb.cp/namespace.exp: print ina
Summary: PASS->FAIL: gdb.cp/namespace.exp: print ina
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 7.0
: P3 normal
Target Milestone: ---
Assignee: Richard Biener
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-11 09:30 UTC by Thomas Preud'homme
Modified: 2016-10-12 07:37 UTC (History)
1 user (show)

See Also:
Host:
Target: arm-none-eabi
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-10-11 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Preud'homme 2016-10-11 09:30:24 UTC
Hi,

I've tracked the following GDB tests regression on arm-none-eabi targets to r240855. Keeping all components (gas, ld, gdb) fixed except for GCC confirmed GCC is the source of the regression.

PASS->FAIL: gdb.cp/namespace.exp: print ina
PASS->FAIL: gdb.cp/namespace.exp: ptype ina
PASS->FAIL: gdb.cp/rtti.exp: print *e2

All three fail with the following error:

No symbol "ina" in current context. (respectively e2 for the last testcase). I can see that indeed after the commit there is less debug info in namespace.cc (in particular the bits about ina is removed).

Please let me know what dump would help you debug the issue.

Best regards.
Comment 1 Richard Biener 2016-10-11 09:41:37 UTC
Ok, we're hitting /* Ugh */ which shouldn't really happen.  BLOCK_VARS should
be a sub-chain of gimple_bind_vars.  It looks like BLOCK_VARS in this case
has a common sub-chain with gimple_bind_vars instead...

  /* Scrap DECL_CHAIN up to BLOCK_VARS to ease GC after we no longer
     need gimple_bind_vars.  */
  tree next;
  tree end = NULL_TREE;
  if (gimple_bind_block (stmt))
    end = BLOCK_VARS (gimple_bind_block (stmt));
  for (tree var = gimple_bind_vars (stmt); var != end; var = next)
    {
      /* Ugh, something is violating the constraint that BLOCK_VARS
         is a sub-chain of gimple_bind_vars.  */
      if (! var)
        break;
      next = DECL_CHAIN (var);
      DECL_CHAIN (var) = NULL_TREE;
    }

and we have

gimple_bind_vars: c1D.2424 varD.2425 inaD.2426 yD.2460 clD.2462 
BLOCK_VARS: <<< Unknown tree: imported_decl >>> <<< Unknown tree: imported_decl >>> c1D.2424 varD.2425 inaD.2426 yD.2460 clD.2462
Comment 2 Richard Biener 2016-10-11 09:51:21 UTC
It's that way in the original BIND_EXPR already.  So it looks like we need to handle this gracefully :/

Index: gcc/gimple-low.c
===================================================================
--- gcc/gimple-low.c    (revision 240964)
+++ gcc/gimple-low.c    (working copy)
@@ -420,18 +420,24 @@ lower_gimple_bind (gimple_stmt_iterator
   /* Scrap DECL_CHAIN up to BLOCK_VARS to ease GC after we no longer
      need gimple_bind_vars.  */
   tree next;
-  tree end = NULL_TREE;
+  /* BLOCK_VARS and gimple_bind_vars share a common sub-chain.  Find
+     it by marking all BLOCK_VARS.  */
   if (gimple_bind_block (stmt))
-    end = BLOCK_VARS (gimple_bind_block (stmt));
-  for (tree var = gimple_bind_vars (stmt); var != end; var = next)
+    for (tree t = BLOCK_VARS (gimple_bind_block (stmt)); t; t = DECL_CHAIN (t))
+      {
+       gcc_checking_assert (! TREE_VISITED (t));
+       TREE_VISITED (t) = 1;
+      }
+  for (tree var = gimple_bind_vars (stmt);
+       var && ! TREE_VISITED (var); var = next)
     {
-      /* Ugh, something is violating the constraint that BLOCK_VARS
-         is a sub-chain of gimple_bind_vars.  */
-      if (! var)
-       break;
       next = DECL_CHAIN (var);
       DECL_CHAIN (var) = NULL_TREE;
     }
+  /* Unmark BLOCK_VARS.  */
+  if (gimple_bind_block (stmt))
+    for (tree t = BLOCK_VARS (gimple_bind_block (stmt)); t; t = DECL_CHAIN (t))
+      TREE_VISITED (t) = 0;
 
   lower_sequence (gimple_bind_body_ptr (stmt), data);
 

fixes it.
Comment 3 Thomas Preud'homme 2016-10-11 09:57:46 UTC
Confirmed, this patch fixes the issue. Thanks!
Comment 4 Richard Biener 2016-10-11 12:53:17 UTC
Author: rguenth
Date: Tue Oct 11 12:52:44 2016
New Revision: 240991

URL: https://gcc.gnu.org/viewcvs?rev=240991&root=gcc&view=rev
Log:
2016-10-11  Richard Biener  <rguenther@suse.de>

	PR debug/77931
	* gimple-low.c (lower_gimple_bind): Handle arbitrary common
	sub-chains of BLOCK_VARS and gimple_bind_vars.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/gimple-low.c
Comment 5 Richard Biener 2016-10-12 07:37:48 UTC
Fixed.