[binutils-gdb] Revert "[gdb/symtab] Fix infinite recursion in dwarf2_cu::get_builder()"

Tom de Vries vries@sourceware.org
Wed May 12 14:03:09 GMT 2021


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3db19b2d7241efde4ca9a7b0e6f33b0929f0cf03

commit 3db19b2d7241efde4ca9a7b0e6f33b0929f0cf03
Author: Tom de Vries <tdevries@suse.de>
Date:   Wed May 12 16:03:02 2021 +0200

    Revert "[gdb/symtab] Fix infinite recursion in dwarf2_cu::get_builder()"
    
    This reverts commit 4cf88725da1cb503be04d3237354105ec170bc86.
    
    It causes the following regression:
    ...
    $ cat shadow.cc
    namespace A {}
    
    int
    main()
    {
      using namespace A;
      return 0;
    }
    $ g++-10 -g shadow.cc -flto -o shadow
    $ ./gdb -q -batch ./shadow  -ex "b main"
    Aborted (core dumped)
    ...

Diff:
---
 gdb/ChangeLog       |  9 ---------
 gdb/doc/ChangeLog   |  5 -----
 gdb/doc/gdb.texinfo |  4 ++--
 gdb/dwarf2/read.c   | 25 +++++++++++++++++++++++--
 4 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 8ef5eb6c833..d564621f4c6 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -209,15 +209,6 @@
 
 	* Re-format all Python files using black.
 
-2021-05-07  Tom de Vries  <tdevries@suse.de>
-
-	PR symtab/26327
-	* dwarf2/read.c (struct dwarf2_cu): Remove ancestor.
-	(dwarf2_cu::get_builder): Remove ancestor-related code.
-	(new_symbol): Remove code supporting pre-4.1 gcc that show arguments
-	of inlined functions as locals.
-	(follow_die_offset, follow_die_sig_1): Remove setting of ancestor.
-
 2021-05-07  Andrew Burgess  <andrew.burgess@embecosm.com>
 
 	* guile/guile-internal.h (gdbscm_safe_source_script): Change
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 290ad485521..9990cd90485 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -29,11 +29,6 @@
 	* python.texinfo (Python Commands): Document 'set debug
 	py-breakpoint' and 'show debug py-breakpoint'.
 
-2021-05-07  Tom de Vries  <tdevries@suse.de>
-
-	PR symtab/26327
-	* gdb.texinfo (Inline Functions): Update.
-
 2021-05-06  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
 
 	* gdb.texinfo (GDB/MI Breakpoint Commands): Mention the
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index f4d7085da58..56f37eb2288 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -13842,8 +13842,8 @@ when using @sc{dwarf 2}.  Versions of @value{NGCC} before 4.1
 do not emit two required attributes (@samp{DW_AT_call_file} and
 @samp{DW_AT_call_line}); @value{GDBN} does not display inlined
 function calls with earlier versions of @value{NGCC}.  It instead
-displays local variables of inlined functions as local variables in
-the caller.
+displays the arguments and local variables of inlined functions as
+local variables in the caller.
 
 The body of an inlined function is directly included at its call site;
 unlike a non-inlined function, there are no instructions devoted to
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 280f56c31e0..ac786abf6d2 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -684,6 +684,10 @@ public:
 
   struct partial_die_info *find_partial_die (sect_offset sect_off);
 
+  /* If this CU was inherited by another CU (via specification,
+     abstract_origin, etc), this is the ancestor CU.  */
+  dwarf2_cu *ancestor;
+
   /* Get the buildsym_compunit for this CU.  */
   buildsym_compunit *get_builder ()
   {
@@ -691,6 +695,10 @@ public:
     if (m_builder != nullptr)
       return m_builder.get ();
 
+    /* Otherwise, search ancestors for a valid builder.  */
+    if (ancestor != nullptr)
+      return ancestor->get_builder ();
+
     return nullptr;
   }
 };
@@ -22037,7 +22045,15 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	  break;
 	case DW_TAG_formal_parameter:
 	  {
-	    SYMBOL_IS_ARGUMENT (sym) = 1;
+	    /* If we are inside a function, mark this as an argument.  If
+	       not, we might be looking at an argument to an inlined function
+	       when we do not have enough information to show inlined frames;
+	       pretend it's a local variable in that case so that the user can
+	       still see it.  */
+	    struct context_stack *curr
+	      = cu->get_builder ()->get_current_context_stack ();
+	    if (curr != nullptr && curr->name != nullptr)
+	      SYMBOL_IS_ARGUMENT (sym) = 1;
 	    attr = dwarf2_attr (die, DW_AT_location, cu);
 	    if (attr != nullptr)
 	      {
@@ -23373,6 +23389,9 @@ follow_die_offset (sect_offset sect_off, int offset_in_dwz,
   *ref_cu = target_cu;
   temp_die.sect_off = sect_off;
 
+  if (target_cu != cu)
+    target_cu->ancestor = cu;
+
   return (struct die_info *) htab_find_with_hash (target_cu->die_hash,
 						  &temp_die,
 						  to_underlying (sect_off));
@@ -23722,7 +23741,7 @@ follow_die_sig_1 (struct die_info *src_die, struct signatured_type *sig_type,
 		  struct dwarf2_cu **ref_cu)
 {
   struct die_info temp_die;
-  struct dwarf2_cu *sig_cu;
+  struct dwarf2_cu *sig_cu, *cu = *ref_cu;
   struct die_info *die;
   dwarf2_per_objfile *per_objfile = (*ref_cu)->per_objfile;
 
@@ -23758,6 +23777,8 @@ follow_die_sig_1 (struct die_info *src_die, struct signatured_type *sig_type,
 	}
 
       *ref_cu = sig_cu;
+      if (sig_cu != cu)
+	sig_cu->ancestor = cu;
 
       return die;
     }


More information about the Gdb-cvs mailing list