[5/7] Simplify DWARF file name caching

Message ID 20210705170200.2160320-6-tom@tromey.com
State New
Headers show
Series
  • Fix dup-psym.exp with DWARF index
Related show

Commit Message

Tom Tromey July 5, 2021, 5:01 p.m.
The DWARF index file name caching code only records when a line table
has been read and the reading failed.  However, the code would be
simpler if it recorded any attempt, which is what this patch
implements.
---
 gdb/dwarf2/read.c | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

-- 
2.26.3

Comments

H.J. Lu via Gdb-patches July 5, 2021, 11:39 p.m. | #1
On Mon, Jul 05, 2021 at 11:01:58AM -0600, Tom Tromey wrote:
> The DWARF index file name caching code only records when a line table

> has been read and the reading failed.  However, the code would be

> simpler if it recorded any attempt, which is what this patch

> implements.

> ---

>  gdb/dwarf2/read.c | 24 +++++++-----------------

>  1 file changed, 7 insertions(+), 17 deletions(-)

> 

> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c

> index 0703ede6647..f2cca03fff3 100644

> --- a/gdb/dwarf2/read.c

> +++ b/gdb/dwarf2/read.c

> @@ -1989,9 +1989,9 @@ struct dwarf2_per_cu_quick_data

>       expand_symtabs_matching.  */

>    unsigned int mark : 1;

>  

> -  /* True if we've tried to read the file table and found there isn't one.

> -     There will be no point in trying to read it again next time.  */

> -  unsigned int no_file_data : 1;

> +  /* True if we've tried to read the file table.  There will be no

> +     point in trying to read it again next time.  */

> +  unsigned int files_read : 1;

>  };

>  


Hi,

I guess the type could be changed from unsigned int to bool.

Lancelot.
Tom Tromey July 17, 2021, 5:02 p.m. | #2
>>>>> "Lancelot" == Lancelot SIX <lsix@lancelotsix.com> writes:


>> +  /* True if we've tried to read the file table.  There will be no

>> +     point in trying to read it again next time.  */

>> +  unsigned int files_read : 1;

>> };

>> 


Lancelot> Hi,

Lancelot> I guess the type could be changed from unsigned int to bool.

I made this change.

Tom

Patch

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 0703ede6647..f2cca03fff3 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1989,9 +1989,9 @@  struct dwarf2_per_cu_quick_data
      expand_symtabs_matching.  */
   unsigned int mark : 1;
 
-  /* True if we've tried to read the file table and found there isn't one.
-     There will be no point in trying to read it again next time.  */
-  unsigned int no_file_data : 1;
+  /* True if we've tried to read the file table.  There will be no
+     point in trying to read it again next time.  */
+  unsigned int files_read : 1;
 };
 
 /* A subclass of psymbol_functions that arranges to read the DWARF
@@ -2897,13 +2897,11 @@  dw2_get_file_names_reader (const struct die_reader_specs *reader,
 
   gdb_assert (! this_cu->is_debug_types);
 
+  this_cu->v.quick->files_read = 1;
   /* Our callers never want to match partial units -- instead they
      will match the enclosing full CU.  */
   if (comp_unit_die->tag == DW_TAG_partial_unit)
-    {
-      this_cu->v.quick->no_file_data = 1;
-      return;
-    }
+    return;
 
   lh_cu = this_cu;
   slot = NULL;
@@ -2933,10 +2931,7 @@  dw2_get_file_names_reader (const struct die_reader_specs *reader,
       lh = dwarf_decode_line_header (line_offset, cu);
     }
   if (lh == NULL)
-    {
-      lh_cu->v.quick->no_file_data = 1;
-      return;
-    }
+    return;
 
   qfn = XOBNEW (&per_objfile->per_bfd->obstack, struct quick_file_names);
   qfn->hash.dwo_unit = cu->dwo_unit;
@@ -2976,18 +2971,13 @@  dw2_get_file_names (dwarf2_per_cu_data *this_cu,
   /* Nor type unit groups.  */
   gdb_assert (! this_cu->type_unit_group_p ());
 
-  if (this_cu->v.quick->file_names != NULL)
+  if (this_cu->v.quick->files_read)
     return this_cu->v.quick->file_names;
-  /* If we know there is no line data, no point in looking again.  */
-  if (this_cu->v.quick->no_file_data)
-    return NULL;
 
   cutu_reader reader (this_cu, per_objfile);
   if (!reader.dummy_p)
     dw2_get_file_names_reader (&reader, reader.comp_unit_die);
 
-  if (this_cu->v.quick->no_file_data)
-    return NULL;
   return this_cu->v.quick->file_names;
 }