This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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]

Re: [PATCH v2 4/8] DWARF-5 basic functionality


On Sun, Feb 19 2017, Jan Kratochvil wrote:

[...]

> diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
> index a987e0e..063f463 100644
> --- a/gdb/dwarf2read.c
> +++ b/gdb/dwarf2read.c

[...]

> @@ -4699,8 +4775,8 @@ create_debug_type_hash_table (struct dwo_file *dwo_file,
>  	  dwo_tu = NULL;
>  	  sig_type = OBSTACK_ZALLOC (&objfile->objfile_obstack,
>  				     struct signatured_type);
> -	  sig_type->signature = signature;
> -	  sig_type->type_offset_in_tu = type_offset_in_tu;
> +	  sig_type->signature = header.signature;
> +	  sig_type->type_offset_in_tu = header.type_offset_in_tu;
>  	  sig_type->per_cu.objfile = objfile;
>  	  sig_type->per_cu.is_debug_types = 1;
>  	  sig_type->per_cu.section = section;

When I compile with "-O3", GCC now yields warnings for the two changed
lines above:

  [...] warning: ‘header.comp_unit_head::type_offset_in_tu.cu_offset::cu_off’
  may be used uninitialized in this function [-Wmaybe-uninitialized]
      sig_type->type_offset_in_tu = header.type_offset_in_tu;
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~

  [...] warning: ‘header.comp_unit_head::signature’ may be used
  uninitialized in this function [-Wmaybe-uninitialized]
      sig_type->signature = header.signature;
      ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~

I *think* GCC is wrong.  From what I understand, we can only get here if
header.unit_type == DW_UT_type, and then these fields should have been
initialized in read_comp_unit_head before (right?).  But then I wonder
about the effect of the call to create_debug_type_hash_table in
create_all_type_units:

  create_debug_type_hash_table (NULL, &dwarf2_per_objfile->info, types_htab,
				rcuh_kind::COMPILE);

Is that needed?  If not, can we drop section_kind as a parameter to
create_debug_type_hash_table?  When doing so (see untested patch below),
the warnings go away.

--
Andreas

-- >8 --
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 8a6e1f3..94f5bac 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -4687,8 +4687,7 @@ add_signatured_type_cu_to_table (void **slot, void *datum)
 
 static void
 create_debug_type_hash_table (struct dwo_file *dwo_file,
-			      dwarf2_section_info *section, htab_t &types_htab,
-			      rcuh_kind section_kind)
+			      dwarf2_section_info *section, htab_t &types_htab)
 {
   struct objfile *objfile = dwarf2_per_objfile->objfile;
   struct dwarf2_section_info *abbrev_section;
@@ -4735,7 +4734,8 @@ create_debug_type_hash_table (struct dwo_file *dwo_file,
 	 table, but we don't need anything else just yet.  */
 
       ptr = read_and_check_comp_unit_head (&header, section,
-					   abbrev_section, ptr, section_kind);
+					   abbrev_section, ptr,
+					   rcuh_kind::TYPE);
 
       length = get_cu_length (&header);
 
@@ -4847,8 +4847,7 @@ create_debug_types_hash_table (struct dwo_file *dwo_file,
   for (ix = 0;
        VEC_iterate (dwarf2_section_info_def, types, ix, section);
        ++ix)
-    create_debug_type_hash_table (dwo_file, section, types_htab,
-				  rcuh_kind::TYPE);
+    create_debug_type_hash_table (dwo_file, section, types_htab);
 }
 
 /* Create the hash table of all entries in the .debug_types section,
@@ -4862,8 +4861,6 @@ create_all_type_units (struct objfile *objfile)
   htab_t types_htab = NULL;
   struct signatured_type **iter;
 
-  create_debug_type_hash_table (NULL, &dwarf2_per_objfile->info, types_htab,
-				rcuh_kind::COMPILE);
   create_debug_types_hash_table (NULL, dwarf2_per_objfile->types, types_htab);
   if (types_htab == NULL)
     {


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