public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 4/8] DWARF-5 basic functionality
  2017-02-19 21:28 [PATCH v2 1/8] Code cleanup: Split create_debug_types_hash_table Jan Kratochvil
                   ` (4 preceding siblings ...)
  2017-02-19 21:28 ` [PATCH v2 8/8] DWARF-5: NEWS Jan Kratochvil
@ 2017-02-19 21:28 ` Jan Kratochvil
  2017-02-21 19:18   ` Andreas Arnez
  2017-02-19 21:28 ` [PATCH v2 3/8] Code cleanup: Refactor abbrev_table_read_table cycle Jan Kratochvil
  2017-02-20 20:05 ` [commit] [PATCH v2 1/8] Code cleanup: Split create_debug_types_hash_table Jan Kratochvil
  7 siblings, 1 reply; 24+ messages in thread
From: Jan Kratochvil @ 2017-02-19 21:28 UTC (permalink / raw)
  To: gdb-patches; +Cc: Victor Leschuk

Hi,

this is a kitchen-sink patch for everything that did not fit into its own
patch.

DWO is not yet implemented.

Jan


gdb/ChangeLog
2017-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* defs.h (read_unsigned_leb128): New declaration.
	* dwarf2loc.c (decode_debug_loclists_addresses): New function.
	(decode_debug_loc_dwo_addresses): Update DEBUG_LOC_* to DW_LLE_*.
	(dwarf2_find_location_expression): Call also
	decode_debug_loclists_addresses.  Handle DWARF-5 ULEB128 length.
	* dwarf2loc.h (dwarf2_version): New declaration.
	* dwarf2read.c (struct dwarf2_per_objfile): Add loclists, line_str,
	rnglists.
	(dwarf2_elf_names): Add .debug_loclists, .debug_line_str,
	.debug_rnglists.
	(struct dwop_section_names): Add loclists_dwo.
	(dwop_section_names): Add .debug_loclists.dwo.
	(struct comp_unit_head): Add unit_type, signature, type_offset_in_tu.
	(struct dwarf2_per_cu_data): Add dwarf_version.
	(struct dwo_sections): Add loclists.
	(struct attr_abbrev): Add implicit_const.
	(read_indirect_line_string): New declaration.
	(read_unsigned_leb128): Delete declaration.
	(rcuh_kind): New definition.
	(read_and_check_comp_unit_head): Change parameter
	is_debug_types_section to section_kind.
	(dwarf2_locate_sections): Handle loclists, line_str and rnglists.
	(read_comp_unit_head): Change parameter abfd to section, add parameter
	section_kind.  Handle DWARF-5.
	(error_check_comp_unit_head): Accept also DWARF version 5.
	(read_and_check_comp_unit_head): Change parameter
	is_debug_types_section to section_kind.
	(read_and_check_type_unit_head): Delete function.
	(read_abbrev_offset): Handle DWARF-5.
	(create_debug_type_hash_table): Add parameter section_kind.  Process
	only DW_UT_type.  Use signature and type_offset_in_tu from struct
	comp_unit_head.
	(create_debug_types_hash_table): Update create_debug_type_hash_table
	caller.
	(create_all_type_units): Call create_debug_type_hash_table.
	(read_cutu_die_from_dwo, init_cutu_and_read_dies): Change
	read_and_check_type_unit_head caller to read_and_check_comp_unit_head
	caller.
	(skip_one_die): Handle DW_FORM_implicit_const.
	(dwarf2_rnglists_process): New function.
	(dwarf2_ranges_process): Call dwarf2_rnglists_process for DWARF-5.
	(abbrev_table_read_table): Handle DW_FORM_implicit_const.
	(read_attribute_value): Handle DW_FORM_implicit_const,
	DW_FORM_line_strp.
	(read_attribute): Handle DW_FORM_implicit_const.
	(read_indirect_string_at_offset_from): New function from
	read_indirect_string_at_offset.
	(read_indirect_string_at_offset): Call
	read_indirect_string_at_offset_from.
	(read_indirect_line_string_at_offset): New function.
	(read_indirect_string): New function comment.
	(read_indirect_line_string): New function.
	(read_unsigned_leb128): Make it global.
	(dwarf2_string_attr): Handle DWARF-5.
	(add_include_dir_stub, read_formatted_entries): New functions.
	(dwarf_decode_line_header, dump_die_shallow, cu_debug_loc_section):
	Handle DWARF-5.
	(per_cu_header_read_in): Update read_comp_unit_head caller.
	(dwarf2_version): New function.
	* symfile.h (struct dwarf2_debug_sections): Add loclists, line_str and
	rnglists.
	* xcoffread.c (dwarf2_xcoff_names): Update struct dwarf2_debug_sections
	fields.

gdb/testsuite/ChangeLog
	* gdb.dwarf2/dw2-error.exp (file $testfile): Update expected string.
---
 gdb/defs.h                             |    4 
 gdb/dwarf2loc.c                        |   81 +++
 gdb/dwarf2loc.h                        |    2 
 gdb/dwarf2read.c                       |  779 +++++++++++++++++++++++++++-----
 gdb/symfile.h                          |    3 
 gdb/testsuite/gdb.dwarf2/dw2-error.exp |    2 
 gdb/xcoffread.c                        |    3 
 7 files changed, 734 insertions(+), 140 deletions(-)

diff --git a/gdb/defs.h b/gdb/defs.h
index ff1df91..aa58605 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -648,6 +648,10 @@ extern void store_typed_address (gdb_byte *buf, struct type *type,
 
 extern int watchdog;
 
+/* From dwarf2read.c */
+
+ULONGEST read_unsigned_leb128 (bfd *, const gdb_byte *, unsigned int *);
+
 /* Hooks for alternate command interfaces.  */
 
 /* * The name of the interpreter if specified on the command line.  */
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index c1e02eb..8774af4 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -143,6 +143,57 @@ decode_debug_loc_addresses (const gdb_byte *loc_ptr, const gdb_byte *buf_end,
   return DEBUG_LOC_START_END;
 }
 
+/* Decode the addresses in .debug_loclists entry.
+   A pointer to the next byte to examine is returned in *NEW_PTR.
+   The encoded low,high addresses are return in *LOW,*HIGH.
+   The result indicates the kind of entry found.  */
+
+static enum debug_loc_kind
+decode_debug_loclists_addresses (struct dwarf2_per_cu_data *per_cu,
+				 const gdb_byte *loc_ptr,
+				 const gdb_byte *buf_end,
+				 const gdb_byte **new_ptr,
+				 CORE_ADDR *low, CORE_ADDR *high,
+				 enum bfd_endian byte_order,
+				 unsigned int addr_size,
+				 int signed_addr_p)
+{
+  uint64_t u64;
+
+  if (loc_ptr == buf_end)
+    return DEBUG_LOC_BUFFER_OVERFLOW;
+
+  switch (*loc_ptr++)
+    {
+    case DW_LLE_end_of_list:
+      *new_ptr = loc_ptr;
+      return DEBUG_LOC_END_OF_LIST;
+    case DW_LLE_base_address:
+      if (loc_ptr + addr_size > buf_end)
+	return DEBUG_LOC_BUFFER_OVERFLOW;
+      if (signed_addr_p)
+	*high = extract_signed_integer (loc_ptr, addr_size, byte_order);
+      else
+	*high = extract_unsigned_integer (loc_ptr, addr_size, byte_order);
+      loc_ptr += addr_size;
+      *new_ptr = loc_ptr;
+      return DEBUG_LOC_BASE_ADDRESS;
+    case DW_LLE_offset_pair:
+      loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &u64);
+      if (loc_ptr == NULL)
+	return DEBUG_LOC_BUFFER_OVERFLOW;
+      *low = u64;
+      loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &u64);
+      if (loc_ptr == NULL)
+	return DEBUG_LOC_BUFFER_OVERFLOW;
+      *high = u64;
+      *new_ptr = loc_ptr;
+      return DEBUG_LOC_START_END;
+    default:
+      return DEBUG_LOC_INVALID_ENTRY;
+    }
+}
+
 /* Decode the addresses in .debug_loc.dwo entry.
    A pointer to the next byte to examine is returned in *NEW_PTR.
    The encoded low,high addresses are return in *LOW,*HIGH.
@@ -163,10 +214,10 @@ decode_debug_loc_dwo_addresses (struct dwarf2_per_cu_data *per_cu,
 
   switch (*loc_ptr++)
     {
-    case DEBUG_LOC_END_OF_LIST:
+    case DW_LLE_GNU_end_of_list_entry:
       *new_ptr = loc_ptr;
       return DEBUG_LOC_END_OF_LIST;
-    case DEBUG_LOC_BASE_ADDRESS:
+    case DW_LLE_GNU_base_address_selection_entry:
       *low = 0;
       loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &high_index);
       if (loc_ptr == NULL)
@@ -174,7 +225,7 @@ decode_debug_loc_dwo_addresses (struct dwarf2_per_cu_data *per_cu,
       *high = dwarf2_read_addr_index (per_cu, high_index);
       *new_ptr = loc_ptr;
       return DEBUG_LOC_BASE_ADDRESS;
-    case DEBUG_LOC_START_END:
+    case DW_LLE_GNU_start_end_entry:
       loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &low_index);
       if (loc_ptr == NULL)
 	return DEBUG_LOC_BUFFER_OVERFLOW;
@@ -185,7 +236,7 @@ decode_debug_loc_dwo_addresses (struct dwarf2_per_cu_data *per_cu,
       *high = dwarf2_read_addr_index (per_cu, high_index);
       *new_ptr = loc_ptr;
       return DEBUG_LOC_START_END;
-    case DEBUG_LOC_START_LENGTH:
+    case DW_LLE_GNU_start_length_entry:
       loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &low_index);
       if (loc_ptr == NULL)
 	return DEBUG_LOC_BUFFER_OVERFLOW;
@@ -237,11 +288,17 @@ dwarf2_find_location_expression (struct dwarf2_loclist_baton *baton,
 	kind = decode_debug_loc_dwo_addresses (baton->per_cu,
 					       loc_ptr, buf_end, &new_ptr,
 					       &low, &high, byte_order);
-      else
+      else if (dwarf2_version (baton->per_cu) < 5)
 	kind = decode_debug_loc_addresses (loc_ptr, buf_end, &new_ptr,
 					   &low, &high,
 					   byte_order, addr_size,
 					   signed_addr_p);
+      else
+	kind = decode_debug_loclists_addresses (baton->per_cu,
+						loc_ptr, buf_end, &new_ptr,
+						&low, &high, byte_order,
+						addr_size, signed_addr_p);
+
       loc_ptr = new_ptr;
       switch (kind)
 	{
@@ -277,8 +334,18 @@ dwarf2_find_location_expression (struct dwarf2_loclist_baton *baton,
 	  high += base_address;
 	}
 
-      length = extract_unsigned_integer (loc_ptr, 2, byte_order);
-      loc_ptr += 2;
+      if (dwarf2_version (baton->per_cu) < 5)
+	{
+	  length = extract_unsigned_integer (loc_ptr, 2, byte_order);
+	  loc_ptr += 2;
+	}
+      else
+	{
+	  unsigned int bytes_read;
+
+	  length = read_unsigned_leb128 (NULL, loc_ptr, &bytes_read);
+	  loc_ptr += bytes_read;
+	}
 
       if (low == high && pc == low)
 	{
diff --git a/gdb/dwarf2loc.h b/gdb/dwarf2loc.h
index d6cdbd2..1f3e20e 100644
--- a/gdb/dwarf2loc.h
+++ b/gdb/dwarf2loc.h
@@ -56,6 +56,8 @@ int dwarf2_per_cu_offset_size (struct dwarf2_per_cu_data *cu);
    offset in the parent objfile.  */
 CORE_ADDR dwarf2_per_cu_text_offset (struct dwarf2_per_cu_data *cu);
 
+short dwarf2_version (struct dwarf2_per_cu_data *per_cu);
+
 /* Find a particular location expression from a location list.  */
 const gdb_byte *dwarf2_find_location_expression
   (struct dwarf2_loclist_baton *baton,
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index a987e0e..063f463 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -222,10 +222,13 @@ struct dwarf2_per_objfile
   struct dwarf2_section_info abbrev;
   struct dwarf2_section_info line;
   struct dwarf2_section_info loc;
+  struct dwarf2_section_info loclists;
   struct dwarf2_section_info macinfo;
   struct dwarf2_section_info macro;
   struct dwarf2_section_info str;
+  struct dwarf2_section_info line_str;
   struct dwarf2_section_info ranges;
+  struct dwarf2_section_info rnglists;
   struct dwarf2_section_info addr;
   struct dwarf2_section_info frame;
   struct dwarf2_section_info eh_frame;
@@ -333,10 +336,13 @@ static const struct dwarf2_debug_sections dwarf2_elf_names =
   { ".debug_abbrev", ".zdebug_abbrev" },
   { ".debug_line", ".zdebug_line" },
   { ".debug_loc", ".zdebug_loc" },
+  { ".debug_loclists", ".zdebug_loclists" },
   { ".debug_macinfo", ".zdebug_macinfo" },
   { ".debug_macro", ".zdebug_macro" },
   { ".debug_str", ".zdebug_str" },
+  { ".debug_line_str", ".zdebug_line_str" },
   { ".debug_ranges", ".zdebug_ranges" },
+  { ".debug_rnglists", ".zdebug_rnglists" },
   { ".debug_types", ".zdebug_types" },
   { ".debug_addr", ".zdebug_addr" },
   { ".debug_frame", ".zdebug_frame" },
@@ -353,6 +359,7 @@ static const struct dwop_section_names
   struct dwarf2_section_names info_dwo;
   struct dwarf2_section_names line_dwo;
   struct dwarf2_section_names loc_dwo;
+  struct dwarf2_section_names loclists_dwo;
   struct dwarf2_section_names macinfo_dwo;
   struct dwarf2_section_names macro_dwo;
   struct dwarf2_section_names str_dwo;
@@ -367,6 +374,7 @@ dwop_section_names =
   { ".debug_info.dwo", ".zdebug_info.dwo" },
   { ".debug_line.dwo", ".zdebug_line.dwo" },
   { ".debug_loc.dwo", ".zdebug_loc.dwo" },
+  { ".debug_loclists.dwo", ".zdebug_loclists.dwo" },
   { ".debug_macinfo.dwo", ".zdebug_macinfo.dwo" },
   { ".debug_macro.dwo", ".zdebug_macro.dwo" },
   { ".debug_str.dwo", ".zdebug_str.dwo" },
@@ -394,6 +402,8 @@ struct comp_unit_head
   /* Size of the length field; either 4 or 12.  */
   unsigned int initial_length_size;
 
+  enum dwarf_unit_type unit_type;
+
   /* Offset to the first byte of this compilation unit header in the
      .debug_info section, for resolving relative reference dies.  */
   sect_offset offset;
@@ -401,6 +411,13 @@ struct comp_unit_head
   /* Offset to first die in this cu from the start of the cu.
      This will be the first byte following the compilation unit header.  */
   cu_offset first_die_offset;
+
+  /* 64-bit signature of this type unit - it is valid only for
+     UNIT_TYPE DW_UT_type.  */
+  ULONGEST signature;
+
+  /* For types, offset in the type's DIE of the type defined by this TU.  */
+  cu_offset type_offset_in_tu;
 };
 
 /* Type used for delaying computation of method physnames.
@@ -572,6 +589,9 @@ struct dwarf2_per_cu_data
   sect_offset offset;
   unsigned int length;
 
+  /* DWARF standard version this data has been read from (such as 4 or 5).  */
+  short dwarf_version;
+
   /* Flag indicating this compilation unit will be read in before
      any of the current compilation units are processed.  */
   unsigned int queued : 1;
@@ -756,6 +776,7 @@ struct dwo_sections
   struct dwarf2_section_info abbrev;
   struct dwarf2_section_info line;
   struct dwarf2_section_info loc;
+  struct dwarf2_section_info loclists;
   struct dwarf2_section_info macinfo;
   struct dwarf2_section_info macro;
   struct dwarf2_section_info str;
@@ -1188,6 +1209,9 @@ struct attr_abbrev
   {
     ENUM_BITFIELD(dwarf_attribute) name : 16;
     ENUM_BITFIELD(dwarf_form) form : 16;
+
+    /* It is valid only if FORM is DW_FORM_implicit_const.  */
+    LONGEST implicit_const;
   };
 
 /* Size of abbrev_table.abbrev_hash_table.  */
@@ -1507,9 +1531,11 @@ static const char *read_indirect_string (bfd *, const gdb_byte *,
 					 const struct comp_unit_head *,
 					 unsigned int *);
 
-static const char *read_indirect_string_from_dwz (struct dwz_file *, LONGEST);
+static const char *read_indirect_line_string (bfd *, const gdb_byte *,
+					      const struct comp_unit_head *,
+					      unsigned int *);
 
-static ULONGEST read_unsigned_leb128 (bfd *, const gdb_byte *, unsigned int *);
+static const char *read_indirect_string_from_dwz (struct dwz_file *, LONGEST);
 
 static LONGEST read_signed_leb128 (bfd *, const gdb_byte *, unsigned int *);
 
@@ -1865,11 +1891,14 @@ static void find_file_and_directory (struct die_info *die,
 static char *file_full_name (int file, struct line_header *lh,
 			     const char *comp_dir);
 
+/* Expected enum dwarf_unit_type for read_comp_unit_head.  */
+enum class rcuh_kind { COMPILE, TYPE };
+
 static const gdb_byte *read_and_check_comp_unit_head
   (struct comp_unit_head *header,
    struct dwarf2_section_info *section,
    struct dwarf2_section_info *abbrev_section, const gdb_byte *info_ptr,
-   int is_debug_types_section);
+   rcuh_kind section_kind);
 
 static void init_cutu_and_read_dies
   (struct dwarf2_per_cu_data *this_cu, struct abbrev_table *abbrev_table,
@@ -2224,6 +2253,11 @@ dwarf2_locate_sections (bfd *abfd, asection *sectp, void *vnames)
       dwarf2_per_objfile->loc.s.section = sectp;
       dwarf2_per_objfile->loc.size = bfd_get_section_size (sectp);
     }
+  else if (section_is_p (sectp->name, &names->loclists))
+    {
+      dwarf2_per_objfile->loclists.s.section = sectp;
+      dwarf2_per_objfile->loclists.size = bfd_get_section_size (sectp);
+    }
   else if (section_is_p (sectp->name, &names->macinfo))
     {
       dwarf2_per_objfile->macinfo.s.section = sectp;
@@ -2239,6 +2273,11 @@ dwarf2_locate_sections (bfd *abfd, asection *sectp, void *vnames)
       dwarf2_per_objfile->str.s.section = sectp;
       dwarf2_per_objfile->str.size = bfd_get_section_size (sectp);
     }
+  else if (section_is_p (sectp->name, &names->line_str))
+    {
+      dwarf2_per_objfile->line_str.s.section = sectp;
+      dwarf2_per_objfile->line_str.size = bfd_get_section_size (sectp);
+    }
   else if (section_is_p (sectp->name, &names->addr))
     {
       dwarf2_per_objfile->addr.s.section = sectp;
@@ -2259,6 +2298,11 @@ dwarf2_locate_sections (bfd *abfd, asection *sectp, void *vnames)
       dwarf2_per_objfile->ranges.s.section = sectp;
       dwarf2_per_objfile->ranges.size = bfd_get_section_size (sectp);
     }
+  else if (section_is_p (sectp->name, &names->rnglists))
+    {
+      dwarf2_per_objfile->rnglists.s.section = sectp;
+      dwarf2_per_objfile->rnglists.size = bfd_get_section_size (sectp);
+    }
   else if (section_is_p (sectp->name, &names->types))
     {
       struct dwarf2_section_info type_section;
@@ -4333,15 +4377,20 @@ dwarf2_find_base_address (struct die_info *die, struct dwarf2_cu *cu)
 }
 
 /* Read in the comp unit header information from the debug_info at info_ptr.
+   Use rcuh_kind::COMPILE as the default type if not known by the caller.
    NOTE: This leaves members offset, first_die_offset to be filled in
    by the caller.  */
 
 static const gdb_byte *
 read_comp_unit_head (struct comp_unit_head *cu_header,
-		     const gdb_byte *info_ptr, bfd *abfd)
+		     const gdb_byte *info_ptr,
+		     struct dwarf2_section_info *section,
+		     rcuh_kind section_kind)
 {
   int signed_addr;
   unsigned int bytes_read;
+  const char *filename = get_section_file_name (section);
+  bfd *abfd = get_section_bfd_owner (section);
 
   cu_header->length = read_initial_length (abfd, info_ptr, &bytes_read);
   cu_header->initial_length_size = bytes_read;
@@ -4349,17 +4398,74 @@ read_comp_unit_head (struct comp_unit_head *cu_header,
   info_ptr += bytes_read;
   cu_header->version = read_2_bytes (abfd, info_ptr);
   info_ptr += 2;
+  if (cu_header->version < 5)
+    switch (section_kind)
+      {
+      case rcuh_kind::COMPILE:
+	cu_header->unit_type = DW_UT_compile;
+	break;
+      case rcuh_kind::TYPE:
+	cu_header->unit_type = DW_UT_type;
+	break;
+      default:
+	internal_error (__FILE__, __LINE__,
+			_("read_comp_unit_head: invalid section_kind"));
+      }
+  else
+    {
+      cu_header->unit_type = static_cast<enum dwarf_unit_type>
+						 (read_1_byte (abfd, info_ptr));
+      info_ptr += 1;
+      switch (cu_header->unit_type)
+	{
+	case DW_UT_compile:
+	  if (section_kind != rcuh_kind::COMPILE)
+	    error (_("Dwarf Error: wrong unit_type in compilation unit header "
+		   "(is DW_UT_compile, should be DW_UT_type) [in module %s]"),
+		   filename);
+	  break;
+	case DW_UT_type:
+	  section_kind = rcuh_kind::TYPE;
+	  break;
+	default:
+	  error (_("Dwarf Error: wrong unit_type in compilation unit header "
+		 "(is %d, should be %d or %d) [in module %s]"),
+		 cu_header->unit_type, DW_UT_compile, DW_UT_type, filename);
+	}
+
+      cu_header->addr_size = read_1_byte (abfd, info_ptr);
+      info_ptr += 1;
+    }
   cu_header->abbrev_offset.sect_off = read_offset (abfd, info_ptr, cu_header,
 					     &bytes_read);
   info_ptr += bytes_read;
-  cu_header->addr_size = read_1_byte (abfd, info_ptr);
-  info_ptr += 1;
+  if (cu_header->version < 5)
+    {
+      cu_header->addr_size = read_1_byte (abfd, info_ptr);
+      info_ptr += 1;
+    }
   signed_addr = bfd_get_sign_extend_vma (abfd);
   if (signed_addr < 0)
     internal_error (__FILE__, __LINE__,
 		    _("read_comp_unit_head: dwarf from non elf file"));
   cu_header->signed_addr_p = signed_addr;
 
+  if (section_kind == rcuh_kind::TYPE)
+    {
+      LONGEST type_offset;
+
+      cu_header->signature = read_8_bytes (abfd, info_ptr);
+      info_ptr += 8;
+
+      type_offset = read_offset (abfd, info_ptr, cu_header, &bytes_read);
+      info_ptr += bytes_read;
+      cu_header->type_offset_in_tu.cu_off = type_offset;
+      if (cu_header->type_offset_in_tu.cu_off != type_offset)
+	error (_("Dwarf Error: Too big type_offset in compilation unit "
+	       "header (is %s) [in module %s]"), plongest (type_offset),
+	       filename);
+    }
+
   return info_ptr;
 }
 
@@ -4390,9 +4496,9 @@ error_check_comp_unit_head (struct comp_unit_head *header,
 {
   const char *filename = get_section_file_name (section);
 
-  if (header->version != 2 && header->version != 3 && header->version != 4)
+  if (header->version < 2 || header->version > 5)
     error (_("Dwarf Error: wrong version in compilation unit header "
-	   "(is %d, should be 2, 3, or 4) [in module %s]"), header->version,
+	   "(is %d, should be 2, 3, 4 or 5) [in module %s]"), header->version,
 	   filename);
 
   if (header->abbrev_offset.sect_off
@@ -4421,54 +4527,14 @@ read_and_check_comp_unit_head (struct comp_unit_head *header,
 			       struct dwarf2_section_info *section,
 			       struct dwarf2_section_info *abbrev_section,
 			       const gdb_byte *info_ptr,
-			       int is_debug_types_section)
-{
-  const gdb_byte *beg_of_comp_unit = info_ptr;
-  bfd *abfd = get_section_bfd_owner (section);
-
-  header->offset.sect_off = beg_of_comp_unit - section->buffer;
-
-  info_ptr = read_comp_unit_head (header, info_ptr, abfd);
-
-  /* If we're reading a type unit, skip over the signature and
-     type_offset fields.  */
-  if (is_debug_types_section)
-    info_ptr += 8 /*signature*/ + header->offset_size;
-
-  header->first_die_offset.cu_off = info_ptr - beg_of_comp_unit;
-
-  error_check_comp_unit_head (header, section, abbrev_section);
-
-  return info_ptr;
-}
-
-/* Read in the types comp unit header information from .debug_types entry at
-   types_ptr.  The result is a pointer to one past the end of the header.  */
-
-static const gdb_byte *
-read_and_check_type_unit_head (struct comp_unit_head *header,
-			       struct dwarf2_section_info *section,
-			       struct dwarf2_section_info *abbrev_section,
-			       const gdb_byte *info_ptr,
-			       ULONGEST *signature,
-			       cu_offset *type_offset_in_tu)
+			       rcuh_kind section_kind)
 {
   const gdb_byte *beg_of_comp_unit = info_ptr;
   bfd *abfd = get_section_bfd_owner (section);
 
   header->offset.sect_off = beg_of_comp_unit - section->buffer;
 
-  info_ptr = read_comp_unit_head (header, info_ptr, abfd);
-
-  /* If we're reading a type unit, skip over the signature and
-     type_offset fields.  */
-  if (signature != NULL)
-    *signature = read_8_bytes (abfd, info_ptr);
-  info_ptr += 8;
-  if (type_offset_in_tu != NULL)
-    type_offset_in_tu->cu_off = read_offset_1 (abfd, info_ptr,
-					       header->offset_size);
-  info_ptr += header->offset_size;
+  info_ptr = read_comp_unit_head (header, info_ptr, section, section_kind);
 
   header->first_die_offset.cu_off = info_ptr - beg_of_comp_unit;
 
@@ -4487,12 +4553,22 @@ read_abbrev_offset (struct dwarf2_section_info *section,
   const gdb_byte *info_ptr;
   unsigned int initial_length_size, offset_size;
   sect_offset abbrev_offset;
+  uint16_t version;
 
   dwarf2_read_section (dwarf2_per_objfile->objfile, section);
   info_ptr = section->buffer + offset.sect_off;
   read_initial_length (abfd, info_ptr, &initial_length_size);
   offset_size = initial_length_size == 4 ? 4 : 8;
-  info_ptr += initial_length_size + 2 /*version*/;
+  info_ptr += initial_length_size;
+
+  version = read_2_bytes (abfd, info_ptr);
+  info_ptr += 2;
+  if (version >= 5)
+    {
+      /* Skip unit type and address size.  */
+      info_ptr += 2;
+    }
+
   abbrev_offset.sect_off = read_offset_1 (abfd, info_ptr, offset_size);
   return abbrev_offset;
 }
@@ -4606,11 +4682,13 @@ add_signatured_type_cu_to_table (void **slot, void *datum)
 }
 
 /* A helper for create_debug_types_hash_table.  Read types from SECTION
-   and fill them into TYPES_HTAB.  */
+   and fill them into TYPES_HTAB.  It will process only type units,
+   therefore DW_UT_type.  */
 
 static void
 create_debug_type_hash_table (struct dwo_file *dwo_file,
-			      dwarf2_section_info *section, htab_t &types_htab)
+			      dwarf2_section_info *section, htab_t &types_htab,
+			      rcuh_kind section_kind)
 {
   struct objfile *objfile = dwarf2_per_objfile->objfile;
   struct dwarf2_section_info *abbrev_section;
@@ -4622,8 +4700,8 @@ create_debug_type_hash_table (struct dwo_file *dwo_file,
 		    : &dwarf2_per_objfile->abbrev);
 
   if (dwarf_read_debug)
-    fprintf_unfiltered (gdb_stdlog, "Reading .debug_types%s for %s:\n",
-			dwo_file ? ".dwo" : "",
+    fprintf_unfiltered (gdb_stdlog, "Reading %s for %s:\n",
+			get_section_name (section),
 			get_section_file_name (abbrev_section));
 
   dwarf2_read_section (objfile, section);
@@ -4644,8 +4722,6 @@ create_debug_type_hash_table (struct dwo_file *dwo_file,
   while (info_ptr < end_ptr)
     {
       sect_offset offset;
-      cu_offset type_offset_in_tu;
-      ULONGEST signature;
       struct signatured_type *sig_type;
       struct dwo_unit *dwo_tu;
       void **slot;
@@ -4658,15 +4734,15 @@ create_debug_type_hash_table (struct dwo_file *dwo_file,
       /* We need to read the type's signature in order to build the hash
 	 table, but we don't need anything else just yet.  */
 
-      ptr = read_and_check_type_unit_head (&header, section,
-					   abbrev_section, ptr,
-					   &signature, &type_offset_in_tu);
+      ptr = read_and_check_comp_unit_head (&header, section,
+					   abbrev_section, ptr, section_kind);
 
       length = get_cu_length (&header);
 
       /* Skip dummy type units.  */
       if (ptr >= info_ptr + length
-	  || peek_abbrev_code (abfd, ptr) == 0)
+	  || peek_abbrev_code (abfd, ptr) == 0
+	  || header.unit_type != DW_UT_type)
 	{
 	  info_ptr += length;
 	  continue;
@@ -4686,8 +4762,8 @@ create_debug_type_hash_table (struct dwo_file *dwo_file,
 	  dwo_tu = OBSTACK_ZALLOC (&objfile->objfile_obstack,
 				   struct dwo_unit);
 	  dwo_tu->dwo_file = dwo_file;
-	  dwo_tu->signature = signature;
-	  dwo_tu->type_offset_in_tu = type_offset_in_tu;
+	  dwo_tu->signature = header.signature;
+	  dwo_tu->type_offset_in_tu = header.type_offset_in_tu;
 	  dwo_tu->section = section;
 	  dwo_tu->offset = offset;
 	  dwo_tu->length = length;
@@ -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;
@@ -4735,14 +4811,14 @@ create_debug_type_hash_table (struct dwo_file *dwo_file,
 		     _("debug type entry at offset 0x%x is duplicate to"
 		       " the entry at offset 0x%x, signature %s"),
 		     offset.sect_off, dup_offset.sect_off,
-		     hex_string (signature));
+		     hex_string (header.signature));
 	}
       *slot = dwo_file ? (void *) dwo_tu : (void *) sig_type;
 
       if (dwarf_read_debug > 1)
 	fprintf_unfiltered (gdb_stdlog, "  offset 0x%x, signature %s\n",
 			    offset.sect_off,
-			    hex_string (signature));
+			    hex_string (header.signature));
 
       info_ptr += length;
     }
@@ -4771,7 +4847,8 @@ 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);
+    create_debug_type_hash_table (dwo_file, section, types_htab,
+				  rcuh_kind::TYPE);
 }
 
 /* Create the hash table of all entries in the .debug_types section,
@@ -4785,6 +4862,8 @@ 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)
     {
@@ -5165,22 +5244,18 @@ read_cutu_die_from_dwo (struct dwarf2_per_cu_data *this_cu,
 
   if (this_cu->is_debug_types)
     {
-      ULONGEST header_signature;
-      cu_offset type_offset_in_tu;
       struct signatured_type *sig_type = (struct signatured_type *) this_cu;
 
-      info_ptr = read_and_check_type_unit_head (&cu->header, section,
+      info_ptr = read_and_check_comp_unit_head (&cu->header, section,
 						dwo_abbrev_section,
-						info_ptr,
-						&header_signature,
-						&type_offset_in_tu);
+						info_ptr, rcuh_kind::TYPE);
       /* This is not an assert because it can be caused by bad debug info.  */
-      if (sig_type->signature != header_signature)
+      if (sig_type->signature != cu->header.signature)
 	{
 	  error (_("Dwarf Error: signature mismatch %s vs %s while reading"
 		   " TU at offset 0x%x [in module %s]"),
 		 hex_string (sig_type->signature),
-		 hex_string (header_signature),
+		 hex_string (cu->header.signature),
 		 dwo_unit->offset.sect_off,
 		 bfd_get_filename (abfd));
 	}
@@ -5188,7 +5263,7 @@ read_cutu_die_from_dwo (struct dwarf2_per_cu_data *this_cu,
       /* For DWOs coming from DWP files, we don't know the CU length
 	 nor the type's offset in the TU until now.  */
       dwo_unit->length = get_cu_length (&cu->header);
-      dwo_unit->type_offset_in_tu = type_offset_in_tu;
+      dwo_unit->type_offset_in_tu = cu->header.type_offset_in_tu;
 
       /* Establish the type offset that can be used to lookup the type.
 	 For DWO files, we don't know it until now.  */
@@ -5199,7 +5274,7 @@ read_cutu_die_from_dwo (struct dwarf2_per_cu_data *this_cu,
     {
       info_ptr = read_and_check_comp_unit_head (&cu->header, section,
 						dwo_abbrev_section,
-						info_ptr, 0);
+						info_ptr, rcuh_kind::COMPILE);
       gdb_assert (dwo_unit->offset.sect_off == cu->header.offset.sect_off);
       /* For DWOs coming from DWP files, we don't know the CU length
 	 until now.  */
@@ -5518,20 +5593,16 @@ init_cutu_and_read_dies (struct dwarf2_per_cu_data *this_cu,
     {
       if (this_cu->is_debug_types)
 	{
-	  ULONGEST signature;
-	  cu_offset type_offset_in_tu;
-
-	  info_ptr = read_and_check_type_unit_head (&cu->header, section,
+	  info_ptr = read_and_check_comp_unit_head (&cu->header, section,
 						    abbrev_section, info_ptr,
-						    &signature,
-						    &type_offset_in_tu);
+						    rcuh_kind::TYPE);
 
 	  /* Since per_cu is the first member of struct signatured_type,
 	     we can go from a pointer to one to a pointer to the other.  */
 	  sig_type = (struct signatured_type *) this_cu;
-	  gdb_assert (sig_type->signature == signature);
+	  gdb_assert (sig_type->signature == cu->header.signature);
 	  gdb_assert (sig_type->type_offset_in_tu.cu_off
-		      == type_offset_in_tu.cu_off);
+		      == cu->header.type_offset_in_tu.cu_off);
 	  gdb_assert (this_cu->offset.sect_off == cu->header.offset.sect_off);
 
 	  /* LENGTH has not been set yet for type units if we're
@@ -5541,15 +5612,19 @@ init_cutu_and_read_dies (struct dwarf2_per_cu_data *this_cu,
 	  /* Establish the type offset that can be used to lookup the type.  */
 	  sig_type->type_offset_in_section.sect_off =
 	    this_cu->offset.sect_off + sig_type->type_offset_in_tu.cu_off;
+
+	  this_cu->dwarf_version = cu->header.version;
 	}
       else
 	{
 	  info_ptr = read_and_check_comp_unit_head (&cu->header, section,
 						    abbrev_section,
-						    info_ptr, 0);
+						    info_ptr,
+						    rcuh_kind::COMPILE);
 
 	  gdb_assert (this_cu->offset.sect_off == cu->header.offset.sect_off);
 	  gdb_assert (this_cu->length == get_cu_length (&cu->header));
+	  this_cu->dwarf_version = cu->header.version;
 	}
     }
 
@@ -5711,7 +5786,9 @@ init_cutu_and_read_dies_no_follow (struct dwarf2_per_cu_data *this_cu,
   begin_info_ptr = info_ptr = section->buffer + this_cu->offset.sect_off;
   info_ptr = read_and_check_comp_unit_head (&cu.header, section,
 					    abbrev_section, info_ptr,
-					    this_cu->is_debug_types);
+					    (this_cu->is_debug_types
+					     ? rcuh_kind::TYPE
+					     : rcuh_kind::COMPILE));
 
   this_cu->length = get_cu_length (&cu.header);
 
@@ -7322,6 +7399,7 @@ skip_one_die (const struct die_reader_specs *reader, const gdb_byte *info_ptr,
 	  info_ptr += 1;
 	  break;
 	case DW_FORM_flag_present:
+	case DW_FORM_implicit_const:
 	  break;
 	case DW_FORM_data2:
 	case DW_FORM_ref2:
@@ -11873,13 +11951,188 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
     }
 }
 
-/* Call CALLBACK from DW_AT_ranges attribute value OFFSET.
+/* Call CALLBACK from DW_AT_ranges attribute value OFFSET
+   reading .debug_rnglists.
+   Callback's type should be:
+    void (CORE_ADDR range_beginning, CORE_ADDR range_end)
+   Return 1 if the attributes are present and valid, otherwise, return 0.  */
+
+template <typename Callback>
+static int
+dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu,
+			 Callback &&callback)
+{
+  struct objfile *objfile = cu->objfile;
+  struct gdbarch *gdbarch = get_objfile_arch (objfile);
+  struct comp_unit_head *cu_header = &cu->header;
+  bfd *obfd = objfile->obfd;
+  unsigned int addr_size = cu_header->addr_size;
+  CORE_ADDR mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1));
+  /* Base address selection entry.  */
+  CORE_ADDR base;
+  int found_base;
+  unsigned int dummy;
+  const gdb_byte *buffer;
+  CORE_ADDR low = 0;
+  CORE_ADDR high = 0;
+  CORE_ADDR baseaddr;
+  bool overflow = false;
+
+  found_base = cu->base_known;
+  base = cu->base_address;
+
+  dwarf2_read_section (objfile, &dwarf2_per_objfile->rnglists);
+  if (offset >= dwarf2_per_objfile->rnglists.size)
+    {
+      complaint (&symfile_complaints,
+		 _("Offset %d out of bounds for DW_AT_ranges attribute"),
+		 offset);
+      return 0;
+    }
+  buffer = dwarf2_per_objfile->rnglists.buffer + offset;
+
+  baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+
+  while (1)
+    {
+      CORE_ADDR range_beginning, range_end;
+      const gdb_byte *buf_end = (dwarf2_per_objfile->rnglists.buffer
+				 + dwarf2_per_objfile->rnglists.size);
+      unsigned int bytes_read;
+
+      if (buffer == buf_end)
+	{
+	  overflow = true;
+	  break;
+	}
+      const auto rlet = static_cast<enum dwarf_range_list_entry>(*buffer++);
+      switch (rlet)
+	{
+	case DW_RLE_end_of_list:
+	  break;
+	case DW_RLE_base_address:
+	  if (buffer + cu->header.addr_size > buf_end)
+	    {
+	      overflow = true;
+	      break;
+	    }
+	  base = read_address (obfd, buffer, cu, &bytes_read);
+	  found_base = 1;
+	  buffer += bytes_read;
+	  break;
+	case DW_RLE_start_length:
+	  if (buffer + cu->header.addr_size > buf_end)
+	    {
+	      overflow = true;
+	      break;
+	    }
+	  range_beginning = read_address (obfd, buffer, cu, &bytes_read);
+	  buffer += bytes_read;
+	  range_end = (range_beginning
+		       + read_unsigned_leb128 (obfd, buffer, &bytes_read));
+	  buffer += bytes_read;
+	  if (buffer > buf_end)
+	    {
+	      overflow = true;
+	      break;
+	    }
+	  break;
+	case DW_RLE_offset_pair:
+	  range_beginning = read_unsigned_leb128 (obfd, buffer, &bytes_read);
+	  buffer += bytes_read;
+	  if (buffer > buf_end)
+	    {
+	      overflow = true;
+	      break;
+	    }
+	  range_end = read_unsigned_leb128 (obfd, buffer, &bytes_read);
+	  buffer += bytes_read;
+	  if (buffer > buf_end)
+	    {
+	      overflow = true;
+	      break;
+	    }
+	  break;
+	case DW_RLE_start_end:
+	  if (buffer + 2 * cu->header.addr_size > buf_end)
+	    {
+	      overflow = true;
+	      break;
+	    }
+	  range_beginning = read_address (obfd, buffer, cu, &bytes_read);
+	  buffer += bytes_read;
+	  range_end = read_address (obfd, buffer, cu, &bytes_read);
+	  buffer += bytes_read;
+	  break;
+	default:
+	  complaint (&symfile_complaints,
+		     _("Invalid .debug_rnglists data (no base address)"));
+	  return 0;
+	}
+      if (rlet == DW_RLE_end_of_list || overflow)
+	break;
+      if (rlet == DW_RLE_base_address)
+	continue;
+
+      if (!found_base)
+	{
+	  /* We have no valid base address for the ranges
+	     data.  */
+	  complaint (&symfile_complaints,
+		     _("Invalid .debug_rnglists data (no base address)"));
+	  return 0;
+	}
+
+      if (range_beginning > range_end)
+	{
+	  /* Inverted range entries are invalid.  */
+	  complaint (&symfile_complaints,
+		     _("Invalid .debug_rnglists data (inverted range)"));
+	  return 0;
+	}
+
+      /* Empty range entries have no effect.  */
+      if (range_beginning == range_end)
+	continue;
+
+      range_beginning += base;
+      range_end += base;
+
+      /* A not-uncommon case of bad debug info.
+	 Don't pollute the addrmap with bad data.  */
+      if (range_beginning + baseaddr == 0
+	  && !dwarf2_per_objfile->has_section_at_zero)
+	{
+	  complaint (&symfile_complaints,
+		     _(".debug_rnglists entry has start address of zero"
+		       " [in module %s]"), objfile_name (objfile));
+	  continue;
+	}
+
+      callback (range_beginning, range_end);
+    }
+
+  if (overflow)
+    {
+      complaint (&symfile_complaints,
+		 _("Offset %d is not terminated "
+		   "for DW_AT_ranges attribute"),
+		 offset);
+      return 0;
+    }
+
+  return 1;
+}
+
+/* Call CALLBACK from DW_AT_ranges attribute value OFFSET reading .debug_ranges.
+   Callback's type should be:
+    void (CORE_ADDR range_beginning, CORE_ADDR range_end)
    Return 1 if the attributes are present and valid, otherwise, return 0.  */
 
+template <typename Callback>
 static int
 dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu,
-		       std::function<void (CORE_ADDR range_beginning,
-					   CORE_ADDR range_end)> callback)
+		       Callback &&callback)
 {
   struct objfile *objfile = cu->objfile;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
@@ -11894,6 +12147,9 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu,
   const gdb_byte *buffer;
   CORE_ADDR baseaddr;
 
+  if (cu_header->version >= 5)
+    return dwarf2_rnglists_process (offset, cu, callback);
+
   found_base = cu->base_known;
   base = cu->base_address;
 
@@ -15341,10 +15597,23 @@ abbrev_table_read_table (struct dwarf2_section_info *section,
       /* now read in declarations */
       for (;;)
 	{
+	  LONGEST implicit_const;
+
 	  abbrev_name = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
 	  abbrev_ptr += bytes_read;
 	  abbrev_form = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
 	  abbrev_ptr += bytes_read;
+	  if (abbrev_form == DW_FORM_implicit_const)
+	    {
+	      implicit_const = read_signed_leb128 (abfd, abbrev_ptr,
+						   &bytes_read);
+	      abbrev_ptr += bytes_read;
+	    }
+	  else
+	    {
+	      /* Initialize it due to a false compiler warning.  */
+	      implicit_const = -1;
+	    }
 
 	  if (abbrev_name == 0)
 	    break;
@@ -15360,6 +15629,7 @@ abbrev_table_read_table (struct dwarf2_section_info *section,
 	    = (enum dwarf_attribute) abbrev_name;
 	  cur_attrs[cur_abbrev->num_attrs].form
 	    = (enum dwarf_form) abbrev_form;
+	  cur_attrs[cur_abbrev->num_attrs].implicit_const = implicit_const;
 	  ++cur_abbrev->num_attrs;
 	}
 
@@ -16194,7 +16464,7 @@ fixup_partial_die (struct partial_die_info *part_die,
 static const gdb_byte *
 read_attribute_value (const struct die_reader_specs *reader,
 		      struct attribute *attr, unsigned form,
-		      const gdb_byte *info_ptr)
+		      LONGEST implicit_const, const gdb_byte *info_ptr)
 {
   struct dwarf2_cu *cu = reader->cu;
   struct objfile *objfile = cu->objfile;
@@ -16271,6 +16541,16 @@ read_attribute_value (const struct die_reader_specs *reader,
 	  break;
 	}
       /* FALLTHROUGH */
+    case DW_FORM_line_strp:
+      if (!cu->per_cu->is_dwz)
+	{
+	  DW_STRING (attr) = read_indirect_line_string (abfd, info_ptr,
+							cu_header, &bytes_read);
+	  DW_STRING_IS_CANONICAL (attr) = 0;
+	  info_ptr += bytes_read;
+	  break;
+	}
+      /* FALLTHROUGH */
     case DW_FORM_GNU_strp_alt:
       {
 	struct dwz_file *dwz = dwarf2_get_dwz_file ();
@@ -16350,7 +16630,16 @@ read_attribute_value (const struct die_reader_specs *reader,
     case DW_FORM_indirect:
       form = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
       info_ptr += bytes_read;
-      info_ptr = read_attribute_value (reader, attr, form, info_ptr);
+      if (form == DW_FORM_implicit_const)
+	{
+	  implicit_const = read_signed_leb128 (abfd, info_ptr, &bytes_read);
+	  info_ptr += bytes_read;
+	}
+      info_ptr = read_attribute_value (reader, attr, form, implicit_const,
+				       info_ptr);
+      break;
+    case DW_FORM_implicit_const:
+      DW_SND (attr) = implicit_const;
       break;
     case DW_FORM_GNU_addr_index:
       if (reader->dwo_file == NULL)
@@ -16420,7 +16709,8 @@ read_attribute (const struct die_reader_specs *reader,
 		const gdb_byte *info_ptr)
 {
   attr->name = abbrev->name;
-  return read_attribute_value (reader, attr, abbrev->form, info_ptr);
+  return read_attribute_value (reader, attr, abbrev->form,
+			       abbrev->implicit_const, info_ptr);
 }
 
 /* Read dwarf information from a buffer.  */
@@ -16673,21 +16963,47 @@ read_direct_string (bfd *abfd, const gdb_byte *buf,
   return (const char *) buf;
 }
 
+/* Return pointer to string at section SECT offset STR_OFFSET with error
+   reporting strings FORM_NAME and SECT_NAME.  */
+
 static const char *
-read_indirect_string_at_offset (bfd *abfd, LONGEST str_offset)
-{
-  dwarf2_read_section (dwarf2_per_objfile->objfile, &dwarf2_per_objfile->str);
-  if (dwarf2_per_objfile->str.buffer == NULL)
-    error (_("DW_FORM_strp used without .debug_str section [in module %s]"),
-	   bfd_get_filename (abfd));
-  if (str_offset >= dwarf2_per_objfile->str.size)
-    error (_("DW_FORM_strp pointing outside of "
-	     ".debug_str section [in module %s]"),
-	   bfd_get_filename (abfd));
+read_indirect_string_at_offset_from (bfd *abfd, LONGEST str_offset,
+				     struct dwarf2_section_info *sect,
+				     const char *form_name,
+				     const char *sect_name)
+{
+  dwarf2_read_section (dwarf2_per_objfile->objfile, sect);
+  if (sect->buffer == NULL)
+    error (_("%s used without %s section [in module %s]"),
+	   form_name, sect_name, bfd_get_filename (abfd));
+  if (str_offset >= sect->size)
+    error (_("%s pointing outside of %s section [in module %s]"),
+	   form_name, sect_name, bfd_get_filename (abfd));
   gdb_assert (HOST_CHAR_BIT == 8);
-  if (dwarf2_per_objfile->str.buffer[str_offset] == '\0')
+  if (sect->buffer[str_offset] == '\0')
     return NULL;
-  return (const char *) (dwarf2_per_objfile->str.buffer + str_offset);
+  return (const char *) (sect->buffer + str_offset);
+}
+
+/* Return pointer to string at .debug_str offset STR_OFFSET.  */
+
+static const char *
+read_indirect_string_at_offset (bfd *abfd, LONGEST str_offset)
+{
+  return read_indirect_string_at_offset_from (abfd, str_offset,
+					      &dwarf2_per_objfile->str,
+					      "DW_FORM_strp", ".debug_str");
+}
+
+/* Return pointer to string at .debug_line_str offset STR_OFFSET.  */
+
+static const char *
+read_indirect_line_string_at_offset (bfd *abfd, LONGEST str_offset)
+{
+  return read_indirect_string_at_offset_from (abfd, str_offset,
+					      &dwarf2_per_objfile->line_str,
+					      "DW_FORM_line_strp",
+					      ".debug_line_str");
 }
 
 /* Read a string at offset STR_OFFSET in the .debug_str section from
@@ -16714,6 +17030,10 @@ read_indirect_string_from_dwz (struct dwz_file *dwz, LONGEST str_offset)
   return (const char *) (dwz->str.buffer + str_offset);
 }
 
+/* Return pointer to string at .debug_str offset as read from BUF.
+   BUF is assumed to be in a compilation unit described by CU_HEADER.
+   Return *BYTES_READ_PTR count of bytes read from BUF.  */
+
 static const char *
 read_indirect_string (bfd *abfd, const gdb_byte *buf,
 		      const struct comp_unit_head *cu_header,
@@ -16724,9 +17044,23 @@ read_indirect_string (bfd *abfd, const gdb_byte *buf,
   return read_indirect_string_at_offset (abfd, str_offset);
 }
 
-static ULONGEST
+/* Return pointer to string at .debug_line_str offset as read from BUF.
+   BUF is assumed to be in a compilation unit described by CU_HEADER.
+   Return *BYTES_READ_PTR count of bytes read from BUF.  */
+
+static const char *
+read_indirect_line_string (bfd *abfd, const gdb_byte *buf,
+			   const struct comp_unit_head *cu_header,
+			   unsigned int *bytes_read_ptr)
+{
+  LONGEST str_offset = read_offset (abfd, buf, cu_header, bytes_read_ptr);
+
+  return read_indirect_line_string_at_offset (abfd, str_offset);
+}
+
+ULONGEST
 read_unsigned_leb128 (bfd *abfd, const gdb_byte *buf,
-		      unsigned int *bytes_read_ptr)
+			  unsigned int *bytes_read_ptr)
 {
   ULONGEST result;
   unsigned int num_read;
@@ -17086,8 +17420,8 @@ dwarf2_string_attr (struct die_info *die, unsigned int name, struct dwarf2_cu *c
 
   if (attr != NULL)
     {
-      if (attr->form == DW_FORM_strp || attr->form == DW_FORM_string
-	  || attr->form == DW_FORM_GNU_strp_alt)
+      if (attr->form == DW_FORM_strp || attr->form == DW_FORM_line_strp
+	  || attr->form == DW_FORM_string || attr->form == DW_FORM_GNU_strp_alt)
 	str = DW_STRING (attr);
       else
         complaint (&symfile_complaints,
@@ -17264,6 +17598,141 @@ get_debug_line_section (struct dwarf2_cu *cu)
   return section;
 }
 
+/* Forwarding function for read_formatted_entries.  */
+
+static void
+add_include_dir_stub (struct line_header *lh, const char *name,
+		      unsigned int dir_index, unsigned int mod_time,
+		      unsigned int length)
+{
+  add_include_dir (lh, name);
+}
+
+/* Read directory or file name entry format, starting with byte of
+   format count entries, ULEB128 pairs of entry formats, ULEB128 of
+   entries count and the entries themselves in the described entry
+   format.  */
+
+static void
+read_formatted_entries (bfd *abfd, const gdb_byte **bufp,
+			struct line_header *lh,
+			const struct comp_unit_head *cu_header,
+			void (*callback) (struct line_header *lh,
+					  const char *name,
+					  unsigned int dir_index,
+					  unsigned int mod_time,
+					  unsigned int length))
+{
+  gdb_byte format_count, formati;
+  ULONGEST data_count, datai;
+  const gdb_byte *buf = *bufp;
+  const gdb_byte *format_header_data;
+  int i;
+  unsigned int bytes_read;
+
+  format_count = read_1_byte (abfd, buf);
+  buf += 1;
+  format_header_data = buf;
+  for (formati = 0; formati < format_count; formati++)
+    {
+      read_unsigned_leb128 (abfd, buf, &bytes_read);
+      buf += bytes_read;
+      read_unsigned_leb128 (abfd, buf, &bytes_read);
+      buf += bytes_read;
+    }
+
+  data_count = read_unsigned_leb128 (abfd, buf, &bytes_read);
+  buf += bytes_read;
+  for (datai = 0; datai < data_count; datai++)
+    {
+      const gdb_byte *format = format_header_data;
+      struct file_entry fe;
+
+      memset (&fe, 0, sizeof (fe));
+
+      for (formati = 0; formati < format_count; formati++)
+	{
+	  ULONGEST content_type, form;
+	  const char *string_trash;
+	  const char **stringp = &string_trash;
+	  unsigned int uint_trash, *uintp = &uint_trash;
+
+	  content_type = read_unsigned_leb128 (abfd, format, &bytes_read);
+	  format += bytes_read;
+	  switch (content_type)
+	    {
+	    case DW_LNCT_path:
+	      stringp = &fe.name;
+	      break;
+	    case DW_LNCT_directory_index:
+	      uintp = &fe.dir_index;
+	      break;
+	    case DW_LNCT_timestamp:
+	      uintp = &fe.mod_time;
+	      break;
+	    case DW_LNCT_size:
+	      uintp = &fe.length;
+	      break;
+	    case DW_LNCT_MD5:
+	      break;
+	    default:
+	      complaint (&symfile_complaints,
+			 _("Unknown format content type %s"),
+			 pulongest (content_type));
+	    }
+
+	  form = read_unsigned_leb128 (abfd, format, &bytes_read);
+	  format += bytes_read;
+	  switch (form)
+	    {
+	    case DW_FORM_string:
+	      *stringp = read_direct_string (abfd, buf, &bytes_read);
+	      buf += bytes_read;
+	      break;
+
+	    case DW_FORM_line_strp:
+	      *stringp = read_indirect_line_string (abfd, buf, cu_header, &bytes_read);
+	      buf += bytes_read;
+	      break;
+
+	    case DW_FORM_data1:
+	      *uintp = read_1_byte (abfd, buf);
+	      buf += 1;
+	      break;
+
+	    case DW_FORM_data2:
+	      *uintp = read_2_bytes (abfd, buf);
+	      buf += 2;
+	      break;
+
+	    case DW_FORM_data4:
+	      *uintp = read_4_bytes (abfd, buf);
+	      buf += 4;
+	      break;
+
+	    case DW_FORM_data8:
+	      *uintp = read_8_bytes (abfd, buf);
+	      buf += 8;
+	      break;
+
+	    case DW_FORM_udata:
+	      *uintp = read_unsigned_leb128 (abfd, buf, &bytes_read);
+	      buf += bytes_read;
+	      break;
+
+	    case DW_FORM_block:
+	      /* It is valid only for DW_LNCT_timestamp which is ignored by
+		 current GDB.  */
+	      break;
+	    }
+	}
+
+      callback (lh, fe.name, fe.dir_index, fe.mod_time, fe.length);
+    }
+
+  *bufp = buf;
+}
+
 /* Read the statement program header starting at OFFSET in
    .debug_line, or .debug_line.dwo.  Return a pointer
    to a struct line_header, allocated using xmalloc.
@@ -17333,7 +17802,7 @@ dwarf_decode_line_header (unsigned int offset, struct dwarf2_cu *cu)
   lh->statement_program_end = line_ptr + lh->total_length;
   lh->version = read_2_bytes (abfd, line_ptr);
   line_ptr += 2;
-  if (lh->version > 4)
+  if (lh->version > 5)
     {
       /* This is a version we don't understand.  The format could have
 	 changed in ways we don't handle properly so just punt.  */
@@ -17341,6 +17810,25 @@ dwarf_decode_line_header (unsigned int offset, struct dwarf2_cu *cu)
 		 _("unsupported version in .debug_line section"));
       return NULL;
     }
+  if (lh->version >= 5)
+    {
+      gdb_byte segment_selector_size;
+
+      /* Skip address size.  */
+      read_1_byte (abfd, line_ptr);
+      line_ptr += 1;
+
+      segment_selector_size = read_1_byte (abfd, line_ptr);
+      line_ptr += 1;
+      if (segment_selector_size != 0)
+	{
+	  complaint (&symfile_complaints,
+		     _("unsupported segment selector size %u "
+		       "in .debug_line section"),
+		     segment_selector_size);
+	  return NULL;
+	}
+    }
   lh->header_length = read_offset_1 (abfd, line_ptr, offset_size);
   line_ptr += offset_size;
   lh->minimum_instruction_length = read_1_byte (abfd, line_ptr);
@@ -17378,30 +17866,42 @@ dwarf_decode_line_header (unsigned int offset, struct dwarf2_cu *cu)
       line_ptr += 1;
     }
 
-  /* Read directory table.  */
-  while ((cur_dir = read_direct_string (abfd, line_ptr, &bytes_read)) != NULL)
+  if (lh->version >= 5)
     {
-      line_ptr += bytes_read;
-      add_include_dir (lh, cur_dir);
-    }
-  line_ptr += bytes_read;
+      /* Read directory table.  */
+      read_formatted_entries (abfd, &line_ptr, lh, &cu->header,
+			      add_include_dir_stub);
 
-  /* Read file name table.  */
-  while ((cur_file = read_direct_string (abfd, line_ptr, &bytes_read)) != NULL)
+      /* Read file name table.  */
+      read_formatted_entries (abfd, &line_ptr, lh, &cu->header, add_file_name);
+    }
+  else
     {
-      unsigned int dir_index, mod_time, length;
-
-      line_ptr += bytes_read;
-      dir_index = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
-      line_ptr += bytes_read;
-      mod_time = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
-      line_ptr += bytes_read;
-      length = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+      /* Read directory table.  */
+      while ((cur_dir = read_direct_string (abfd, line_ptr, &bytes_read)) != NULL)
+	{
+	  line_ptr += bytes_read;
+	  add_include_dir (lh, cur_dir);
+	}
       line_ptr += bytes_read;
 
-      add_file_name (lh, cur_file, dir_index, mod_time, length);
+      /* Read file name table.  */
+      while ((cur_file = read_direct_string (abfd, line_ptr, &bytes_read)) != NULL)
+	{
+	  unsigned int dir_index, mod_time, length;
+
+	  line_ptr += bytes_read;
+	  dir_index = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+	  line_ptr += bytes_read;
+	  mod_time = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+	  line_ptr += bytes_read;
+	  length = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+	  line_ptr += bytes_read;
+
+	  add_file_name (lh, cur_file, dir_index, mod_time, length);
+	}
+      line_ptr += bytes_read;
     }
-  line_ptr += bytes_read;
   lh->statement_program_start = line_ptr;
 
   if (line_ptr > (section->buffer + section->size))
@@ -19754,6 +20254,7 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die)
 	  break;
 	case DW_FORM_string:
 	case DW_FORM_strp:
+	case DW_FORM_line_strp:
 	case DW_FORM_GNU_str_index:
 	case DW_FORM_GNU_strp_alt:
 	  fprintf_unfiltered (f, "string: \"%s\" (%s canonicalized)",
@@ -21781,8 +22282,13 @@ static struct dwarf2_section_info *
 cu_debug_loc_section (struct dwarf2_cu *cu)
 {
   if (cu->dwo_unit)
-    return &cu->dwo_unit->dwo_file->sections.loc;
-  return &dwarf2_per_objfile->loc;
+    {
+      struct dwo_sections *sections = &cu->dwo_unit->dwo_file->sections;
+      
+      return cu->header.version >= 5 ? &sections->loclists : &sections->loc;
+    }
+  return (cu->header.version >= 5 ? &dwarf2_per_objfile->loclists
+				  : &dwarf2_per_objfile->loc);
 }
 
 /* A helper function that fills in a dwarf2_loclist_baton.  */
@@ -21900,7 +22406,8 @@ per_cu_header_read_in (struct comp_unit_head *cu_headerp,
   info_ptr = per_cu->section->buffer + per_cu->offset.sect_off;
 
   memset (cu_headerp, 0, sizeof (*cu_headerp));
-  read_comp_unit_head (cu_headerp, info_ptr, per_cu->objfile->obfd);
+  read_comp_unit_head (cu_headerp, info_ptr, per_cu->section,
+		       rcuh_kind::COMPILE);
 
   return cu_headerp;
 }
@@ -21960,6 +22467,14 @@ dwarf2_per_cu_text_offset (struct dwarf2_per_cu_data *per_cu)
   return ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 }
 
+/* Return DWARF version number of PER_CU.  */
+
+short
+dwarf2_version (struct dwarf2_per_cu_data *per_cu)
+{
+  return per_cu->dwarf_version;
+}
+
 /* Locate the .debug_info compilation unit from CU's objfile which contains
    the DIE at OFFSET.  Raises an error on failure.  */
 
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 175ce78..02aee8d 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -600,10 +600,13 @@ struct dwarf2_debug_sections {
   struct dwarf2_section_names abbrev;
   struct dwarf2_section_names line;
   struct dwarf2_section_names loc;
+  struct dwarf2_section_names loclists;
   struct dwarf2_section_names macinfo;
   struct dwarf2_section_names macro;
   struct dwarf2_section_names str;
+  struct dwarf2_section_names line_str;
   struct dwarf2_section_names ranges;
+  struct dwarf2_section_names rnglists;
   struct dwarf2_section_names types;
   struct dwarf2_section_names addr;
   struct dwarf2_section_names frame;
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-error.exp b/gdb/testsuite/gdb.dwarf2/dw2-error.exp
index b102a65..7f69d93 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-error.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-error.exp
@@ -41,7 +41,7 @@ gdb_test_no_output "set breakpoint pending off"
 
 # First test that reading symbols fails.
 gdb_test "file $binfile" \
-    "Reading symbols.*Dwarf Error: wrong version in compilation unit header .is 153, should be 2, 3, or 4.*" \
+    {Reading symbols.*Dwarf Error: wrong unit_type in compilation unit header \(is 0, should be 1 or 2\).*} \
     "file $testfile"
 
 # Now check that we can still break given the minimal symbol.
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index d1122f4..9c4769a 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -159,13 +159,16 @@ static const struct dwarf2_debug_sections dwarf2_xcoff_names = {
   { ".dwabrev", NULL },
   { ".dwline", NULL },
   { ".dwloc", NULL },
+  { NULL, NULL }, /* debug_loclists */
   /* AIX XCOFF defines one, named DWARF section for macro debug information.
      XLC does not generate debug_macinfo for DWARF4 and below.
      The section is assigned to debug_macro for DWARF5 and above. */
   { NULL, NULL },
   { ".dwmac", NULL },
   { ".dwstr", NULL },
+  { NULL, NULL }, /* debug_line_str */
   { ".dwrnges", NULL },
+  { NULL, NULL }, /* debug_rnglists */
   { ".dwpbtyp", NULL },
   { NULL, NULL }, /* debug_addr */
   { ".dwframe", NULL },

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v2 6/8] DWARF-5: Macros
  2017-02-19 21:28 [PATCH v2 1/8] Code cleanup: Split create_debug_types_hash_table Jan Kratochvil
  2017-02-19 21:28 ` [PATCH v2 7/8] DWARF-5: DW_FORM_data16 Jan Kratochvil
@ 2017-02-19 21:28 ` Jan Kratochvil
  2017-02-20 20:08   ` [commit] " Jan Kratochvil
  2017-02-19 21:28 ` [PATCH v2 2/8] Code cleanup: Split dwarf2_ranges_read to a callback Jan Kratochvil
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 24+ messages in thread
From: Jan Kratochvil @ 2017-02-19 21:28 UTC (permalink / raw)
  To: gdb-patches; +Cc: Victor Leschuk

Hi,

DWARF-5 renamed DW_MACRO_GNU_* to DW_MACRO_*.

Jan


gdb/ChangeLog
2017-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf2read.c (read_file_scope): Rename DW_MACRO_GNU_*.
	(dwarf_parse_macro_header): Accept DWARF version 5.
	(dwarf_decode_macro_bytes, dwarf_decode_macros): Rename DW_MACRO_GNU_*.
---
 gdb/dwarf2read.c |   78 ++++++++++++++++++++++++++++--------------------------
 1 file changed, 40 insertions(+), 38 deletions(-)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 403d1e3..1034d7b 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -9312,12 +9312,14 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
      refers to information in the line number info statement program
      header, so we can only read it if we've read the header
      successfully.  */
-  attr = dwarf2_attr (die, DW_AT_GNU_macros, cu);
+  attr = dwarf2_attr (die, DW_AT_macros, cu);
+  if (attr == NULL)
+    attr = dwarf2_attr (die, DW_AT_GNU_macros, cu);
   if (attr && cu->line_header)
     {
       if (dwarf2_attr (die, DW_AT_macro_info, cu))
 	complaint (&symfile_complaints,
-		   _("CU refers to both DW_AT_GNU_macros and DW_AT_macro_info"));
+		   _("CU refers to both DW_AT_macros and DW_AT_macro_info"));
 
       dwarf_decode_macros (cu, DW_UNSND (attr), 1);
     }
@@ -21713,7 +21715,7 @@ dwarf_parse_macro_header (const gdb_byte **opcode_definitions,
       unsigned int version, flags;
 
       version = read_2_bytes (abfd, mac_ptr);
-      if (version != 4)
+      if (version != 4 && version != 5)
 	{
 	  complaint (&symfile_complaints,
 		     _("unrecognized version `%d' in .debug_macro section"),
@@ -21756,7 +21758,7 @@ dwarf_parse_macro_header (const gdb_byte **opcode_definitions,
 }
 
 /* A helper for dwarf_decode_macros that handles the GNU extensions,
-   including DW_MACRO_GNU_transparent_include.  */
+   including DW_MACRO_import.  */
 
 static void
 dwarf_decode_macro_bytes (bfd *abfd,
@@ -21811,12 +21813,12 @@ dwarf_decode_macro_bytes (bfd *abfd,
 	case 0:
 	  break;
 
-        case DW_MACRO_GNU_define:
-        case DW_MACRO_GNU_undef:
-	case DW_MACRO_GNU_define_indirect:
-	case DW_MACRO_GNU_undef_indirect:
-	case DW_MACRO_GNU_define_indirect_alt:
-	case DW_MACRO_GNU_undef_indirect_alt:
+        case DW_MACRO_define:
+        case DW_MACRO_undef:
+	case DW_MACRO_define_strp:
+	case DW_MACRO_undef_strp:
+	case DW_MACRO_define_sup:
+	case DW_MACRO_undef_sup:
           {
             unsigned int bytes_read;
             int line;
@@ -21826,8 +21828,8 @@ dwarf_decode_macro_bytes (bfd *abfd,
 	    line = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
 	    mac_ptr += bytes_read;
 
-	    if (macinfo_type == DW_MACRO_GNU_define
-		|| macinfo_type == DW_MACRO_GNU_undef)
+	    if (macinfo_type == DW_MACRO_define
+		|| macinfo_type == DW_MACRO_undef)
 	      {
 		body = read_direct_string (abfd, mac_ptr, &bytes_read);
 		mac_ptr += bytes_read;
@@ -21839,8 +21841,8 @@ dwarf_decode_macro_bytes (bfd *abfd,
 		str_offset = read_offset_1 (abfd, mac_ptr, offset_size);
 		mac_ptr += offset_size;
 
-		if (macinfo_type == DW_MACRO_GNU_define_indirect_alt
-		    || macinfo_type == DW_MACRO_GNU_undef_indirect_alt
+		if (macinfo_type == DW_MACRO_define_sup
+		    || macinfo_type == DW_MACRO_undef_sup
 		    || section_is_dwz)
 		  {
 		    struct dwz_file *dwz = dwarf2_get_dwz_file ();
@@ -21851,9 +21853,9 @@ dwarf_decode_macro_bytes (bfd *abfd,
 		  body = read_indirect_string_at_offset (abfd, str_offset);
 	      }
 
-	    is_define = (macinfo_type == DW_MACRO_GNU_define
-			 || macinfo_type == DW_MACRO_GNU_define_indirect
-			 || macinfo_type == DW_MACRO_GNU_define_indirect_alt);
+	    is_define = (macinfo_type == DW_MACRO_define
+			 || macinfo_type == DW_MACRO_define_strp
+			 || macinfo_type == DW_MACRO_define_sup);
             if (! current_file)
 	      {
 		/* DWARF violation as no main source is present.  */
@@ -21876,15 +21878,15 @@ dwarf_decode_macro_bytes (bfd *abfd,
 	      parse_macro_definition (current_file, line, body);
 	    else
 	      {
-		gdb_assert (macinfo_type == DW_MACRO_GNU_undef
-			    || macinfo_type == DW_MACRO_GNU_undef_indirect
-			    || macinfo_type == DW_MACRO_GNU_undef_indirect_alt);
+		gdb_assert (macinfo_type == DW_MACRO_undef
+			    || macinfo_type == DW_MACRO_undef_strp
+			    || macinfo_type == DW_MACRO_undef_sup);
 		macro_undef (current_file, line, body);
 	      }
           }
           break;
 
-        case DW_MACRO_GNU_start_file:
+        case DW_MACRO_start_file:
           {
             unsigned int bytes_read;
             int line, file;
@@ -21904,7 +21906,7 @@ dwarf_decode_macro_bytes (bfd *abfd,
 
 	    if (at_commandline)
 	      {
-		/* This DW_MACRO_GNU_start_file was executed in the
+		/* This DW_MACRO_start_file was executed in the
 		   pass one.  */
 		at_commandline = 0;
 	      }
@@ -21913,7 +21915,7 @@ dwarf_decode_macro_bytes (bfd *abfd,
           }
           break;
 
-        case DW_MACRO_GNU_end_file:
+        case DW_MACRO_end_file:
           if (! current_file)
 	    complaint (&symfile_complaints,
 		       _("macro debug info has an unmatched "
@@ -21952,8 +21954,8 @@ dwarf_decode_macro_bytes (bfd *abfd,
             }
           break;
 
-	case DW_MACRO_GNU_transparent_include:
-	case DW_MACRO_GNU_transparent_include_alt:
+	case DW_MACRO_import:
+	case DW_MACRO_import_sup:
 	  {
 	    LONGEST offset;
 	    void **slot;
@@ -21966,7 +21968,7 @@ dwarf_decode_macro_bytes (bfd *abfd,
 	    offset = read_offset_1 (abfd, mac_ptr, offset_size);
 	    mac_ptr += offset_size;
 
-	    if (macinfo_type == DW_MACRO_GNU_transparent_include_alt)
+	    if (macinfo_type == DW_MACRO_import_sup)
 	      {
 		struct dwz_file *dwz = dwarf2_get_dwz_file ();
 
@@ -21986,7 +21988,7 @@ dwarf_decode_macro_bytes (bfd *abfd,
 		/* This has actually happened; see
 		   http://sourceware.org/bugzilla/show_bug.cgi?id=13568.  */
 		complaint (&symfile_complaints,
-			   _("recursive DW_MACRO_GNU_transparent_include in "
+			   _("recursive DW_MACRO_import in "
 			     ".debug_macro section"));
 	      }
 	    else
@@ -22128,8 +22130,8 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
         case 0:
 	  break;
 
-	case DW_MACRO_GNU_define:
-	case DW_MACRO_GNU_undef:
+	case DW_MACRO_define:
+	case DW_MACRO_undef:
 	  /* Only skip the data by MAC_PTR.  */
 	  {
 	    unsigned int bytes_read;
@@ -22141,7 +22143,7 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
 	  }
 	  break;
 
-	case DW_MACRO_GNU_start_file:
+	case DW_MACRO_start_file:
 	  {
 	    unsigned int bytes_read;
 	    int line, file;
@@ -22155,14 +22157,14 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
 	  }
 	  break;
 
-	case DW_MACRO_GNU_end_file:
+	case DW_MACRO_end_file:
 	  /* No data to skip by MAC_PTR.  */
 	  break;
 
-	case DW_MACRO_GNU_define_indirect:
-	case DW_MACRO_GNU_undef_indirect:
-	case DW_MACRO_GNU_define_indirect_alt:
-	case DW_MACRO_GNU_undef_indirect_alt:
+	case DW_MACRO_define_strp:
+	case DW_MACRO_undef_strp:
+	case DW_MACRO_define_sup:
+	case DW_MACRO_undef_sup:
 	  {
 	    unsigned int bytes_read;
 
@@ -22172,10 +22174,10 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
 	  }
 	  break;
 
-	case DW_MACRO_GNU_transparent_include:
-	case DW_MACRO_GNU_transparent_include_alt:
+	case DW_MACRO_import:
+	case DW_MACRO_import_sup:
 	  /* Note that, according to the spec, a transparent include
-	     chain cannot call DW_MACRO_GNU_start_file.  So, we can just
+	     chain cannot call DW_MACRO_start_file.  So, we can just
 	     skip this opcode.  */
 	  mac_ptr += offset_size;
 	  break;

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v2 3/8] Code cleanup: Refactor abbrev_table_read_table cycle
  2017-02-19 21:28 [PATCH v2 1/8] Code cleanup: Split create_debug_types_hash_table Jan Kratochvil
                   ` (5 preceding siblings ...)
  2017-02-19 21:28 ` [PATCH v2 4/8] DWARF-5 basic functionality Jan Kratochvil
@ 2017-02-19 21:28 ` Jan Kratochvil
  2017-02-20 20:06   ` [commit] " Jan Kratochvil
  2017-02-20 20:05 ` [commit] [PATCH v2 1/8] Code cleanup: Split create_debug_types_hash_table Jan Kratochvil
  7 siblings, 1 reply; 24+ messages in thread
From: Jan Kratochvil @ 2017-02-19 21:28 UTC (permalink / raw)
  To: gdb-patches; +Cc: Victor Leschuk

Hi,

I find it as an improvement on its own, it prevents more code duplication in
a future patch.

Jan


gdb/ChangeLog
2017-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf2read.c (abbrev_table_read_table): Read the data only once.
---
 gdb/dwarf2read.c |   21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index e0ede18..a987e0e 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -15339,12 +15339,16 @@ abbrev_table_read_table (struct dwarf2_section_info *section,
       abbrev_ptr += 1;
 
       /* now read in declarations */
-      abbrev_name = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
-      abbrev_ptr += bytes_read;
-      abbrev_form = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
-      abbrev_ptr += bytes_read;
-      while (abbrev_name)
+      for (;;)
 	{
+	  abbrev_name = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+	  abbrev_ptr += bytes_read;
+	  abbrev_form = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+	  abbrev_ptr += bytes_read;
+
+	  if (abbrev_name == 0)
+	    break;
+
 	  if (cur_abbrev->num_attrs == allocated_attrs)
 	    {
 	      allocated_attrs += ATTR_ALLOC_CHUNK;
@@ -15354,12 +15358,9 @@ abbrev_table_read_table (struct dwarf2_section_info *section,
 
 	  cur_attrs[cur_abbrev->num_attrs].name
 	    = (enum dwarf_attribute) abbrev_name;
-	  cur_attrs[cur_abbrev->num_attrs++].form
+	  cur_attrs[cur_abbrev->num_attrs].form
 	    = (enum dwarf_form) abbrev_form;
-	  abbrev_name = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
-	  abbrev_ptr += bytes_read;
-	  abbrev_form = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
-	  abbrev_ptr += bytes_read;
+	  ++cur_abbrev->num_attrs;
 	}
 
       cur_abbrev->attrs =

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v2 8/8] DWARF-5: NEWS
  2017-02-19 21:28 [PATCH v2 1/8] Code cleanup: Split create_debug_types_hash_table Jan Kratochvil
                   ` (3 preceding siblings ...)
  2017-02-19 21:28 ` [PATCH v2 5/8] DWARF-5: call sites Jan Kratochvil
@ 2017-02-19 21:28 ` Jan Kratochvil
  2017-02-20  3:31   ` Eli Zaretskii
  2017-02-20 20:09   ` [commit] " Jan Kratochvil
  2017-02-19 21:28 ` [PATCH v2 4/8] DWARF-5 basic functionality Jan Kratochvil
                   ` (2 subsequent siblings)
  7 siblings, 2 replies; 24+ messages in thread
From: Jan Kratochvil @ 2017-02-19 21:28 UTC (permalink / raw)
  To: gdb-patches; +Cc: Victor Leschuk

Hi,

a NEWS entry.

Jan


gdb/ChangeLog
2017-02-19  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* NEWS (Changes since GDB 7.12): Add DWARF-5.
---
 gdb/NEWS |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/gdb/NEWS b/gdb/NEWS
index d6adc32..76de00e 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -60,6 +60,9 @@
 
 * Target descriptions can now describe registers for sparc32 and sparc64.
 
+* GDB now supports DWARF version 5 (debug information format).
+  Its .debug_names index is not yet supported.
+
 * New native configurations
 
 FreeBSD/mips			mips*-*-freebsd

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v2 5/8] DWARF-5: call sites
  2017-02-19 21:28 [PATCH v2 1/8] Code cleanup: Split create_debug_types_hash_table Jan Kratochvil
                   ` (2 preceding siblings ...)
  2017-02-19 21:28 ` [PATCH v2 2/8] Code cleanup: Split dwarf2_ranges_read to a callback Jan Kratochvil
@ 2017-02-19 21:28 ` Jan Kratochvil
  2017-02-20  3:31   ` Eli Zaretskii
  2017-02-20 20:08   ` [commit] " Jan Kratochvil
  2017-02-19 21:28 ` [PATCH v2 8/8] DWARF-5: NEWS Jan Kratochvil
                   ` (3 subsequent siblings)
  7 siblings, 2 replies; 24+ messages in thread
From: Jan Kratochvil @ 2017-02-19 21:28 UTC (permalink / raw)
  To: gdb-patches; +Cc: Victor Leschuk

Hi,

this patch updates all call sites related DWARF-5 renames.

Jan


gdb/ChangeLog
2017-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* block.c (call_site_for_pc): Rename DW_OP_GNU_*, DW_TAG_GNU_* and
	DW_AT_GNU_*.
	* common/common-exceptions.h (enum errors): Likewise.
	* dwarf2-frame.c (class dwarf_expr_executor): Likewise.
	* dwarf2expr.c (dwarf_block_to_dwarf_reg)
	(dwarf_expr_context::execute_stack_op): Likewise.
	* dwarf2expr.h (struct dwarf_expr_context, struct dwarf_expr_piece):
	Likewise.
	* dwarf2loc.c (dwarf_evaluate_loc_desc::get_base_type)
	(dwarf_evaluate_loc_desc::push_dwarf_reg_entry_value)
	(show_entry_values_debug, call_site_to_target_addr)
	(func_addr_to_tail_call_list, func_verify_no_selftailcall)
	(dwarf_expr_reg_to_entry_parameter, dwarf_entry_parameter_to_value)
	(entry_data_value_free_closure, value_of_dwarf_reg_entry)
	(value_of_dwarf_block_entry, indirect_pieced_value)
	(symbol_needs_eval_context::push_dwarf_reg_entry_value):
	(disassemble_dwarf_expression): Likewise.
	* dwarf2read.c (process_die, inherit_abstract_dies)
	(read_call_site_scope): Likewise.
	* gdbtypes.h (struct func_type, struct call_site_parameter)
	(struct call_site): Likewise.
	* stack.c (read_frame_arg): Likewise.
	* std-operator.def (OP_VAR_ENTRY_VALUE): Likewise.

gdb/doc/ChangeLog
2017-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.texinfo (Print Settings, Tail Call Frames): Rename DW_OP_GNU_*,
	DW_TAG_GNU_* and DW_AT_GNU_*.

gdb/testsuite/ChangeLog
2017-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.arch/amd64-entry-value-param-dwarf5.S: New file.
	* gdb.arch/amd64-entry-value-param-dwarf5.c: New file.
	* gdb.arch/amd64-entry-value-param-dwarf5.exp: New file.
	* gdb.arch/amd64-entry-value.exp: Rename DW_OP_GNU_*, DW_TAG_GNU_* and
	DW_AT_GNU_*.
---
 gdb/block.c                                        |    4 
 gdb/common/common-exceptions.h                     |    2 
 gdb/doc/gdb.texinfo                                |   10 
 gdb/dwarf2-frame.c                                 |    2 
 gdb/dwarf2expr.c                                   |   23 -
 gdb/dwarf2expr.h                                   |   10 
 gdb/dwarf2loc.c                                    |   59 +-
 gdb/dwarf2read.c                                   |   93 ++-
 gdb/gdbtypes.h                                     |   22 -
 gdb/stack.c                                        |    5 
 gdb/std-operator.def                               |    2 
 .../gdb.arch/amd64-entry-value-param-dwarf5.S      |  699 ++++++++++++++++++++
 .../gdb.arch/amd64-entry-value-param-dwarf5.c      |   40 +
 .../gdb.arch/amd64-entry-value-param-dwarf5.exp    |   49 +
 gdb/testsuite/gdb.arch/amd64-entry-value.exp       |    6 
 15 files changed, 926 insertions(+), 100 deletions(-)
 create mode 100644 gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.S
 create mode 100644 gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.c
 create mode 100644 gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.exp

diff --git a/gdb/block.c b/gdb/block.c
index 670a49d..2f44460 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -239,8 +239,8 @@ call_site_for_pc (struct gdbarch *gdbarch, CORE_ADDR pc)
       /* DW_TAG_gnu_call_site will be missing just if GCC could not determine
 	 the call target.  */
       throw_error (NO_ENTRY_VALUE_ERROR,
-		   _("DW_OP_GNU_entry_value resolving cannot find "
-		     "DW_TAG_GNU_call_site %s in %s"),
+		   _("DW_OP_entry_value resolving cannot find "
+		     "DW_TAG_call_site %s in %s"),
 		   paddress (gdbarch, pc),
 		   (msym.minsym == NULL ? "???"
 		    : MSYMBOL_PRINT_NAME (msym.minsym)));
diff --git a/gdb/common/common-exceptions.h b/gdb/common/common-exceptions.h
index c4a2f59..49f309f 100644
--- a/gdb/common/common-exceptions.h
+++ b/gdb/common/common-exceptions.h
@@ -87,7 +87,7 @@ enum errors {
      means the register was not saved in the frame.  */
   OPTIMIZED_OUT_ERROR,
 
-  /* DW_OP_GNU_entry_value resolving failed.  */
+  /* DW_OP_entry_value resolving failed.  */
   NO_ENTRY_VALUE_ERROR,
 
   /* Target throwing an error has been closed.  Current command should be
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index c465dc2..962325b 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -9857,7 +9857,7 @@ this feature will behave in the @code{default} setting the same way as with the
 @code{no} setting.
 
 This functionality is currently supported only by DWARF 2 debugging format and
-the compiler has to produce @samp{DW_TAG_GNU_call_site} tags.  With
+the compiler has to produce @samp{DW_TAG_call_site} tags.  With
 @value{NGCC}, you need to specify @option{-O -g} during compilation, to get
 this information.
 
@@ -12025,7 +12025,7 @@ some cases @value{GDBN} can determine that @code{C} was tail-called from
 return address set up as if @code{B} called @code{C} normally.
 
 This functionality is currently supported only by DWARF 2 debugging format and
-the compiler has to produce @samp{DW_TAG_GNU_call_site} tags.  With
+the compiler has to produce @samp{DW_TAG_call_site} tags.  With
 @value{NGCC}, you need to specify @option{-O -g} during compilation, to get
 this information.
 
@@ -12078,8 +12078,8 @@ static void __attribute__((noinline, noclone)) a (void) @{ x++; @}
 static void __attribute__((noinline, noclone)) c (void) @{ a (); @}
 int main (void) @{ x (); return 0; @}
 
-Breakpoint 1, DW_OP_GNU_entry_value resolving cannot find
-DW_TAG_GNU_call_site 0x40039a in main
+Breakpoint 1, DW_OP_entry_value resolving cannot find
+DW_TAG_call_site 0x40039a in main
 a () at t.c:3
 3	static void __attribute__((noinline, noclone)) a (void) @{ x++; @}
 (gdb) bt
@@ -12155,7 +12155,7 @@ int main (void) @{ a (5); return 0; @}
 
 (gdb) bt
 #0  c (i=i@@entry=0) at t.c:2
-#1  0x0000000000400428 in a (DW_OP_GNU_entry_value resolving has found
+#1  0x0000000000400428 in a (DW_OP_entry_value resolving has found
 function "a" at 0x400420 can call itself via tail calls
 i=<optimized out>) at t.c:6
 #2  0x000000000040036e in main () at t.c:7
diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c
index c5ad0dd..f8dd1df 100644
--- a/gdb/dwarf2-frame.c
+++ b/gdb/dwarf2-frame.c
@@ -361,7 +361,7 @@ class dwarf_expr_executor : public dwarf_expr_context
 				   union call_site_parameter_u kind_u,
 				   int deref_size) OVERRIDE
   {
-    invalid ("DW_OP_GNU_entry_value");
+    invalid ("DW_OP_entry_value");
   }
 
   CORE_ADDR get_object_address () OVERRIDE
diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c
index 6ba4831..fbbb6c4 100644
--- a/gdb/dwarf2expr.c
+++ b/gdb/dwarf2expr.c
@@ -423,7 +423,7 @@ dwarf_block_to_dwarf_reg (const gdb_byte *buf, const gdb_byte *buf_end)
       return *buf - DW_OP_reg0;
     }
 
-  if (*buf == DW_OP_GNU_regval_type)
+  if (*buf == DW_OP_regval_type || *buf == DW_OP_GNU_regval_type)
     {
       buf++;
       buf = gdb_read_uleb128 (buf, buf_end, &dwarf_reg);
@@ -805,12 +805,13 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
 	  dwarf_expr_require_composition (op_ptr, op_end, "DW_OP_stack_value");
 	  goto no_push;
 
+	case DW_OP_implicit_pointer:
 	case DW_OP_GNU_implicit_pointer:
 	  {
 	    int64_t len;
 
 	    if (this->ref_addr_size == -1)
-	      error (_("DWARF-2 expression error: DW_OP_GNU_implicit_pointer "
+	      error (_("DWARF-2 expression error: DW_OP_implicit_pointer "
 		       "is not allowed in frame context"));
 
 	    /* The referred-to DIE of sect_offset kind.  */
@@ -825,7 +826,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
 
 	    this->location = DWARF_VALUE_IMPLICIT_POINTER;
 	    dwarf_expr_require_composition (op_ptr, op_end,
-					    "DW_OP_GNU_implicit_pointer");
+					    "DW_OP_implicit_pointer");
 	  }
 	  break;
 
@@ -963,6 +964,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
 
 	case DW_OP_deref:
 	case DW_OP_deref_size:
+	case DW_OP_deref_type:
 	case DW_OP_GNU_deref_type:
 	  {
 	    int addr_size = (op == DW_OP_deref ? this->addr_size : *op_ptr++);
@@ -972,7 +974,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
 
 	    pop ();
 
-	    if (op == DW_OP_GNU_deref_type)
+	    if (op == DW_OP_deref_type || op == DW_OP_GNU_deref_type)
 	      {
 		cu_offset type_die;
 
@@ -1299,6 +1301,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
 	  }
 	  goto no_push;
 	
+	case DW_OP_entry_value:
 	case DW_OP_GNU_entry_value:
 	  {
 	    uint64_t len;
@@ -1307,7 +1310,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
 
 	    op_ptr = safe_read_uleb128 (op_ptr, op_end, &len);
 	    if (op_ptr + len > op_end)
-	      error (_("DW_OP_GNU_entry_value: too few bytes available."));
+	      error (_("DW_OP_entry_value: too few bytes available."));
 
 	    kind_u.dwarf_reg = dwarf_block_to_dwarf_reg (op_ptr, op_ptr + len);
 	    if (kind_u.dwarf_reg != -1)
@@ -1332,7 +1335,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
 		goto no_push;
 	      }
 
-	    error (_("DWARF-2 expression error: DW_OP_GNU_entry_value is "
+	    error (_("DWARF-2 expression error: DW_OP_entry_value is "
 		     "supported only for single DW_OP_reg* "
 		     "or for DW_OP_breg*(0)+DW_OP_deref*"));
 	  }
@@ -1350,6 +1353,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
 	  }
 	  goto no_push;
 
+	case DW_OP_const_type:
 	case DW_OP_GNU_const_type:
 	  {
 	    cu_offset type_die;
@@ -1368,6 +1372,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
 	  }
 	  break;
 
+	case DW_OP_regval_type:
 	case DW_OP_GNU_regval_type:
 	  {
 	    cu_offset type_die;
@@ -1382,7 +1387,9 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
 	  }
 	  break;
 
+	case DW_OP_convert:
 	case DW_OP_GNU_convert:
+	case DW_OP_reinterpret:
 	case DW_OP_GNU_reinterpret:
 	  {
 	    cu_offset type_die;
@@ -1399,7 +1406,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
 	    result_val = fetch (0);
 	    pop ();
 
-	    if (op == DW_OP_GNU_convert)
+	    if (op == DW_OP_convert || op == DW_OP_GNU_convert)
 	      result_val = value_cast (type, result_val);
 	    else if (type == value_type (result_val))
 	      {
@@ -1407,7 +1414,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
 	      }
 	    else if (TYPE_LENGTH (type)
 		     != TYPE_LENGTH (value_type (result_val)))
-	      error (_("DW_OP_GNU_reinterpret has wrong size"));
+	      error (_("DW_OP_reinterpret has wrong size"));
 	    else
 	      result_val
 		= value_from_contents (type,
diff --git a/gdb/dwarf2expr.h b/gdb/dwarf2expr.h
index 017488c..2df310f 100644
--- a/gdb/dwarf2expr.h
+++ b/gdb/dwarf2expr.h
@@ -164,7 +164,7 @@ struct dwarf_expr_context
   /* Return the PC for the frame.  */
   virtual CORE_ADDR get_frame_pc ()
   {
-    error (_("%s is invalid in this context"), "DW_OP_GNU_implicit_pointer");
+    error (_("%s is invalid in this context"), "DW_OP_implicit_pointer");
   }
 
   /* Return the thread-local storage address for
@@ -187,10 +187,10 @@ struct dwarf_expr_context
     return builtin_type (this->gdbarch)->builtin_int;
   }
 
-  /* Push on DWARF stack an entry evaluated for DW_TAG_GNU_call_site's
+  /* Push on DWARF stack an entry evaluated for DW_TAG_call_site's
      parameter matching KIND and KIND_U at the caller of specified BATON.
-     If DEREF_SIZE is not -1 then use DW_AT_GNU_call_site_data_value instead of
-     DW_AT_GNU_call_site_value.  */
+     If DEREF_SIZE is not -1 then use DW_AT_call_data_value instead of
+     DW_AT_call_value.  */
   virtual void push_dwarf_reg_entry_value (enum call_site_parameter_kind kind,
 					   union call_site_parameter_u kind_u,
 					   int deref_size) = 0;
@@ -248,7 +248,7 @@ struct dwarf_expr_piece
     /* Used for DWARF_VALUE_IMPLICIT_POINTER.  */
     struct
     {
-      /* The referent DIE from DW_OP_GNU_implicit_pointer.  */
+      /* The referent DIE from DW_OP_implicit_pointer.  */
       sect_offset die;
       /* The byte offset into the resulting data.  */
       LONGEST offset;
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 8774af4..4393c1f 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -588,9 +588,9 @@ class dwarf_evaluate_loc_desc : public dwarf_expr_context
   {
     struct type *result = dwarf2_get_die_type (die_offset, per_cu);
     if (result == NULL)
-      error (_("Could not find type for DW_OP_GNU_const_type"));
+      error (_("Could not find type for DW_OP_const_type"));
     if (size != 0 && TYPE_LENGTH (result) != size)
-      error (_("DW_OP_GNU_const_type has different sizes for type and data"));
+      error (_("DW_OP_const_type has different sizes for type and data"));
     return result;
   }
 
@@ -640,7 +640,7 @@ class dwarf_evaluate_loc_desc : public dwarf_expr_context
     /* DEREF_SIZE size is not verified here.  */
     if (data_src == NULL)
       throw_error (NO_ENTRY_VALUE_ERROR,
-		   _("Cannot resolve DW_AT_GNU_call_site_data_value"));
+		   _("Cannot resolve DW_AT_call_data_value"));
 
     scoped_restore save_frame = make_scoped_restore (&this->frame,
 						     caller_frame);
@@ -732,7 +732,7 @@ show_entry_values_debug (struct ui_file *file, int from_tty,
 		    value);
 }
 
-/* Find DW_TAG_GNU_call_site's DW_AT_GNU_call_site_target address.
+/* Find DW_TAG_call_site's DW_AT_call_target address.
    CALLER_FRAME (for registers) can be NULL if it is not known.  This function
    always returns valid address or it throws NO_ENTRY_VALUE_ERROR.  */
 
@@ -757,8 +757,7 @@ call_site_to_target_addr (struct gdbarch *call_site_gdbarch,
 	    
 	    msym = lookup_minimal_symbol_by_pc (call_site->pc - 1);
 	    throw_error (NO_ENTRY_VALUE_ERROR,
-			 _("DW_AT_GNU_call_site_target is not specified "
-			   "at %s in %s"),
+			 _("DW_AT_call_target is not specified at %s in %s"),
 			 paddress (call_site_gdbarch, call_site->pc),
 			 (msym.minsym == NULL ? "???"
 			  : MSYMBOL_PRINT_NAME (msym.minsym)));
@@ -770,7 +769,7 @@ call_site_to_target_addr (struct gdbarch *call_site_gdbarch,
 	    
 	    msym = lookup_minimal_symbol_by_pc (call_site->pc - 1);
 	    throw_error (NO_ENTRY_VALUE_ERROR,
-			 _("DW_AT_GNU_call_site_target DWARF block resolving "
+			 _("DW_AT_call_target DWARF block resolving "
 			   "requires known frame which is currently not "
 			   "available at %s in %s"),
 			 paddress (call_site_gdbarch, call_site->pc),
@@ -783,8 +782,7 @@ call_site_to_target_addr (struct gdbarch *call_site_gdbarch,
 	val = dwarf2_evaluate_loc_desc (caller_core_addr_type, caller_frame,
 					dwarf_block->data, dwarf_block->size,
 					dwarf_block->per_cu);
-	/* DW_AT_GNU_call_site_target is a DWARF expression, not a DWARF
-	   location.  */
+	/* DW_AT_call_target is a DWARF expression, not a DWARF location.  */
 	if (VALUE_LVAL (val) == lval_memory)
 	  return value_address (val);
 	else
@@ -834,7 +832,7 @@ func_addr_to_tail_call_list (struct gdbarch *gdbarch, CORE_ADDR addr)
 
   if (sym == NULL || BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) != addr)
     throw_error (NO_ENTRY_VALUE_ERROR,
-		 _("DW_TAG_GNU_call_site resolving failed to find function "
+		 _("DW_TAG_call_site resolving failed to find function "
 		   "name for address %s"),
 		 paddress (gdbarch, addr));
 
@@ -892,7 +890,7 @@ func_verify_no_selftailcall (struct gdbarch *gdbarch, CORE_ADDR verify_addr)
 	      
 	      msym = lookup_minimal_symbol_by_pc (verify_addr);
 	      throw_error (NO_ENTRY_VALUE_ERROR,
-			   _("DW_OP_GNU_entry_value resolving has found "
+			   _("DW_OP_entry_value resolving has found "
 			     "function \"%s\" at %s can call itself via tail "
 			     "calls"),
 			   (msym.minsym == NULL ? "???"
@@ -1234,7 +1232,7 @@ dwarf_expr_reg_to_entry_parameter (struct frame_info *frame,
       struct gdbarch *caller_gdbarch = frame_unwind_arch (frame);
 
       throw_error (NO_ENTRY_VALUE_ERROR,
-		   _("DW_OP_GNU_entry_value resolving callee gdbarch %s "
+		   _("DW_OP_entry_value resolving callee gdbarch %s "
 		     "(of %s (%s)) does not match caller gdbarch %s"),
 		   gdbarch_bfd_arch_info (gdbarch)->printable_name,
 		   paddress (gdbarch, func_addr),
@@ -1248,7 +1246,7 @@ dwarf_expr_reg_to_entry_parameter (struct frame_info *frame,
       struct bound_minimal_symbol msym
 	= lookup_minimal_symbol_by_pc (func_addr);
 
-      throw_error (NO_ENTRY_VALUE_ERROR, _("DW_OP_GNU_entry_value resolving "
+      throw_error (NO_ENTRY_VALUE_ERROR, _("DW_OP_entry_value resolving "
 					   "requires caller of %s (%s)"),
 		   paddress (gdbarch, func_addr),
 		   (msym.minsym == NULL ? "???"
@@ -1265,7 +1263,7 @@ dwarf_expr_reg_to_entry_parameter (struct frame_info *frame,
       target_msym = lookup_minimal_symbol_by_pc (target_addr).minsym;
       func_msym = lookup_minimal_symbol_by_pc (func_addr).minsym;
       throw_error (NO_ENTRY_VALUE_ERROR,
-		   _("DW_OP_GNU_entry_value resolving expects callee %s at %s "
+		   _("DW_OP_entry_value resolving expects callee %s at %s "
 		     "but the called frame is for %s at %s"),
 		   (target_msym == NULL ? "???"
 					: MSYMBOL_PRINT_NAME (target_msym)),
@@ -1289,10 +1287,10 @@ dwarf_expr_reg_to_entry_parameter (struct frame_info *frame,
       struct minimal_symbol *msym
 	= lookup_minimal_symbol_by_pc (caller_pc).minsym;
 
-      /* DW_TAG_GNU_call_site_parameter will be missing just if GCC could not
+      /* DW_TAG_call_site_parameter will be missing just if GCC could not
 	 determine its value.  */
       throw_error (NO_ENTRY_VALUE_ERROR, _("Cannot find matching parameter "
-					   "at DW_TAG_GNU_call_site %s at %s"),
+					   "at DW_TAG_call_site %s at %s"),
 		   paddress (gdbarch, caller_pc),
 		   msym == NULL ? "???" : MSYMBOL_PRINT_NAME (msym)); 
     }
@@ -1302,8 +1300,8 @@ dwarf_expr_reg_to_entry_parameter (struct frame_info *frame,
 }
 
 /* Return value for PARAMETER matching DEREF_SIZE.  If DEREF_SIZE is -1, return
-   the normal DW_AT_GNU_call_site_value block.  Otherwise return the
-   DW_AT_GNU_call_site_data_value (dereferenced) block.
+   the normal DW_AT_call_value block.  Otherwise return the
+   DW_AT_call_data_value (dereferenced) block.
 
    TYPE and CALLER_FRAME specify how to evaluate the DWARF block into returned
    struct value.
@@ -1327,9 +1325,9 @@ dwarf_entry_parameter_to_value (struct call_site_parameter *parameter,
   /* DEREF_SIZE size is not verified here.  */
   if (data_src == NULL)
     throw_error (NO_ENTRY_VALUE_ERROR,
-		 _("Cannot resolve DW_AT_GNU_call_site_data_value"));
+		 _("Cannot resolve DW_AT_call_data_value"));
 
-  /* DW_AT_GNU_call_site_value is a DWARF expression, not a DWARF
+  /* DW_AT_call_value is a DWARF expression, not a DWARF
      location.  Postprocessing of DWARF_VALUE_MEMORY would lose the type from
      DWARF block.  */
   data = (gdb_byte *) alloca (size + 1);
@@ -1380,7 +1378,7 @@ entry_data_value_free_closure (struct value *v)
 
 /* Vector for methods for an entry value reference where the referenced value
    is stored in the caller.  On the first dereference use
-   DW_AT_GNU_call_site_data_value in the caller.  */
+   DW_AT_call_data_value in the caller.  */
 
 static const struct lval_funcs entry_data_value_funcs =
 {
@@ -1395,7 +1393,7 @@ static const struct lval_funcs entry_data_value_funcs =
 
 /* Read parameter of TYPE at (callee) FRAME's function entry.  KIND and KIND_U
    are used to match DW_AT_location at the caller's
-   DW_TAG_GNU_call_site_parameter.
+   DW_TAG_call_site_parameter.
 
    Function always returns non-NULL value.  It throws NO_ENTRY_VALUE_ERROR if it
    cannot resolve the parameter for any reason.  */
@@ -1419,7 +1417,7 @@ value_of_dwarf_reg_entry (struct type *type, struct frame_info *frame,
 					      type, caller_frame,
 					      caller_per_cu);
 
-  /* Check if DW_AT_GNU_call_site_data_value cannot be used.  If it should be
+  /* Check if DW_AT_call_data_value cannot be used.  If it should be
      used and it is not available do not fall back to OUTER_VAL - dereferencing
      TYPE_CODE_REF with non-entry data value would give current value - not the
      entry value.  */
@@ -1447,7 +1445,7 @@ value_of_dwarf_reg_entry (struct type *type, struct frame_info *frame,
 
 /* Read parameter of TYPE at (callee) FRAME's function entry.  DATA and
    SIZE are DWARF block used to match DW_AT_location at the caller's
-   DW_TAG_GNU_call_site_parameter.
+   DW_TAG_call_site_parameter.
 
    Function always returns non-NULL value.  It throws NO_ENTRY_VALUE_ERROR if it
    cannot resolve the parameter for any reason.  */
@@ -1471,7 +1469,7 @@ value_of_dwarf_block_entry (struct type *type, struct frame_info *frame,
      suppressed during normal operation.  The expression can be arbitrary if
      there is no caller-callee entry value binding expected.  */
   throw_error (NO_ENTRY_VALUE_ERROR,
-	       _("DWARF-2 expression error: DW_OP_GNU_entry_value is supported "
+	       _("DWARF-2 expression error: DW_OP_entry_value is supported "
 		 "only for single DW_OP_reg* or for DW_OP_fbreg(*)"));
 }
 
@@ -2226,7 +2224,7 @@ indirect_pieced_value (struct value *value)
 	return NULL;
 
       if (bit_length != 0)
-	error (_("Invalid use of DW_OP_GNU_implicit_pointer"));
+	error (_("Invalid use of DW_OP_implicit_pointer"));
 
       piece = p;
       break;
@@ -2805,7 +2803,7 @@ class symbol_needs_eval_context : public dwarf_expr_context
     per_cu_dwarf_call (this, die_offset, per_cu);
   }
 
-  /* DW_OP_GNU_entry_value accesses require a caller, therefore a
+  /* DW_OP_entry_value accesses require a caller, therefore a
      frame.  */
 
   void push_dwarf_reg_entry_value (enum call_site_parameter_kind kind,
@@ -4162,6 +4160,7 @@ disassemble_dwarf_expression (struct ui_file *stream,
 	  }
 	  break;
 
+	case DW_OP_implicit_pointer:
 	case DW_OP_GNU_implicit_pointer:
 	  {
 	    ul = extract_unsigned_integer (data, offset_size,
@@ -4176,6 +4175,7 @@ disassemble_dwarf_expression (struct ui_file *stream,
 	  }
 	  break;
 
+	case DW_OP_deref_type:
 	case DW_OP_GNU_deref_type:
 	  {
 	    int addr_size = *data++;
@@ -4192,6 +4192,7 @@ disassemble_dwarf_expression (struct ui_file *stream,
 	  }
 	  break;
 
+	case DW_OP_const_type:
 	case DW_OP_GNU_const_type:
 	  {
 	    cu_offset type_die;
@@ -4206,6 +4207,7 @@ disassemble_dwarf_expression (struct ui_file *stream,
 	  }
 	  break;
 
+	case DW_OP_regval_type:
 	case DW_OP_GNU_regval_type:
 	  {
 	    uint64_t reg;
@@ -4225,7 +4227,9 @@ disassemble_dwarf_expression (struct ui_file *stream,
 	  }
 	  break;
 
+	case DW_OP_convert:
 	case DW_OP_GNU_convert:
+	case DW_OP_reinterpret:
 	case DW_OP_GNU_reinterpret:
 	  {
 	    cu_offset type_die;
@@ -4247,6 +4251,7 @@ disassemble_dwarf_expression (struct ui_file *stream,
 	  }
 	  break;
 
+	case DW_OP_entry_value:
 	case DW_OP_GNU_entry_value:
 	  data = safe_read_uleb128 (data, end, &ul);
 	  fputc_filtered ('\n', stream);
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 063f463..403d1e3 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -8361,6 +8361,7 @@ process_die (struct die_info *die, struct dwarf2_cu *cu)
     case DW_TAG_catch_block:
       read_lexical_block_scope (die, cu);
       break;
+    case DW_TAG_call_site:
     case DW_TAG_GNU_call_site:
       read_call_site_scope (die, cu);
       break;
@@ -11314,11 +11315,12 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu)
       struct dwarf2_cu *child_origin_cu;
 
       /* We are trying to process concrete instance entries:
-	 DW_TAG_GNU_call_site DIEs indeed have a DW_AT_abstract_origin tag, but
+	 DW_TAG_call_site DIEs indeed have a DW_AT_abstract_origin tag, but
 	 it's not relevant to our analysis here. i.e. detecting DIEs that are
 	 present in the abstract instance but not referenced in the concrete
 	 one.  */
-      if (child_die->tag == DW_TAG_GNU_call_site)
+      if (child_die->tag == DW_TAG_call_site
+          || child_die->tag == DW_TAG_GNU_call_site)
 	continue;
 
       /* For each CHILD_DIE, find the corresponding child of
@@ -11653,7 +11655,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
   local_using_directives = newobj->local_using_directives;
 }
 
-/* Read in DW_TAG_GNU_call_site and insert it to CU->call_site_htab.  */
+/* Read in DW_TAG_call_site and insert it to CU->call_site_htab.  */
 
 static void
 read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
@@ -11669,11 +11671,17 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
 
   baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 
-  attr = dwarf2_attr (die, DW_AT_low_pc, cu);
+  attr = dwarf2_attr (die, DW_AT_call_return_pc, cu);
+  if (attr == NULL)
+    {
+      /* This was a pre-DWARF-5 GNU extension alias
+	 for DW_AT_call_return_pc.  */
+      attr = dwarf2_attr (die, DW_AT_low_pc, cu);
+    }
   if (!attr)
     {
       complaint (&symfile_complaints,
-		 _("missing DW_AT_low_pc for DW_TAG_GNU_call_site "
+		 _("missing DW_AT_call_return_pc for DW_TAG_call_site "
 		   "DIE 0x%x [in module %s]"),
 		 die->offset.sect_off, objfile_name (objfile));
       return;
@@ -11690,7 +11698,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
   if (*slot != NULL)
     {
       complaint (&symfile_complaints,
-		 _("Duplicate PC %s for DW_TAG_GNU_call_site "
+		 _("Duplicate PC %s for DW_TAG_call_site "
 		   "DIE 0x%x [in module %s]"),
 		 paddress (gdbarch, pc), die->offset.sect_off,
 		 objfile_name (objfile));
@@ -11703,11 +11711,12 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
   for (child_die = die->child; child_die && child_die->tag;
        child_die = sibling_die (child_die))
     {
-      if (child_die->tag != DW_TAG_GNU_call_site_parameter)
+      if (child_die->tag != DW_TAG_call_site_parameter
+          && child_die->tag != DW_TAG_GNU_call_site_parameter)
 	{
 	  complaint (&symfile_complaints,
-		     _("Tag %d is not DW_TAG_GNU_call_site_parameter in "
-		       "DW_TAG_GNU_call_site child DIE 0x%x [in module %s]"),
+		     _("Tag %d is not DW_TAG_call_site_parameter in "
+		       "DW_TAG_call_site child DIE 0x%x [in module %s]"),
 		     child_die->tag, child_die->offset.sect_off,
 		     objfile_name (objfile));
 	  continue;
@@ -11725,7 +11734,8 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
   memset (call_site, 0, sizeof (*call_site) - sizeof (*call_site->parameter));
   call_site->pc = pc;
 
-  if (dwarf2_flag_true_p (die, DW_AT_GNU_tail_call, cu))
+  if (dwarf2_flag_true_p (die, DW_AT_call_tail_call, cu)
+      || dwarf2_flag_true_p (die, DW_AT_GNU_tail_call, cu))
     {
       struct die_info *func_die;
 
@@ -11735,10 +11745,12 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
 	   && func_die->tag != DW_TAG_subroutine_type;
 	   func_die = func_die->parent);
 
-      /* DW_AT_GNU_all_call_sites is a superset
-	 of DW_AT_GNU_all_tail_call_sites.  */
+      /* DW_AT_call_all_calls is a superset
+	 of DW_AT_call_all_tail_calls.  */
       if (func_die
+          && !dwarf2_flag_true_p (func_die, DW_AT_call_all_calls, cu)
           && !dwarf2_flag_true_p (func_die, DW_AT_GNU_all_call_sites, cu)
+	  && !dwarf2_flag_true_p (func_die, DW_AT_call_all_tail_calls, cu)
 	  && !dwarf2_flag_true_p (func_die, DW_AT_GNU_all_tail_call_sites, cu))
 	{
 	  /* TYPE_TAIL_CALL_LIST is not interesting in functions where it is
@@ -11766,15 +11778,22 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
 	    }
 	  else
 	    complaint (&symfile_complaints,
-		       _("Cannot find function owning DW_TAG_GNU_call_site "
+		       _("Cannot find function owning DW_TAG_call_site "
 			 "DIE 0x%x [in module %s]"),
 		       die->offset.sect_off, objfile_name (objfile));
 	}
     }
 
-  attr = dwarf2_attr (die, DW_AT_GNU_call_site_target, cu);
+  attr = dwarf2_attr (die, DW_AT_call_target, cu);
   if (attr == NULL)
-    attr = dwarf2_attr (die, DW_AT_abstract_origin, cu);
+    attr = dwarf2_attr (die, DW_AT_GNU_call_site_target, cu);
+  if (attr == NULL)
+    attr = dwarf2_attr (die, DW_AT_call_origin, cu);
+  if (attr == NULL)
+    {
+      /* This was a pre-DWARF-5 GNU extension alias for DW_AT_call_origin.  */
+      attr = dwarf2_attr (die, DW_AT_abstract_origin, cu);
+    }
   SET_FIELD_DWARF_BLOCK (call_site->target, NULL);
   if (!attr || (attr_form_is_block (attr) && DW_BLOCK (attr)->size == 0))
     /* Keep NULL DWARF_BLOCK.  */;
@@ -11812,7 +11831,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
 	    target_physname = dwarf2_physname (NULL, target_die, target_cu);
 	  if (target_physname == NULL)
 	    complaint (&symfile_complaints,
-		       _("DW_AT_GNU_call_site_target target DIE has invalid "
+		       _("DW_AT_call_target target DIE has invalid "
 		         "physname, for referencing DIE 0x%x [in module %s]"),
 		       die->offset.sect_off, objfile_name (objfile));
 	  else
@@ -11826,7 +11845,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
 	  if (dwarf2_get_pc_bounds (target_die, &lowpc, NULL, target_cu, NULL)
 	      <= PC_BOUNDS_INVALID)
 	    complaint (&symfile_complaints,
-		       _("DW_AT_GNU_call_site_target target DIE has invalid "
+		       _("DW_AT_call_target target DIE has invalid "
 		         "low pc, for referencing DIE 0x%x [in module %s]"),
 		       die->offset.sect_off, objfile_name (objfile));
 	  else
@@ -11838,7 +11857,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
     }
   else
     complaint (&symfile_complaints,
-	       _("DW_TAG_GNU_call_site DW_AT_GNU_call_site_target is neither "
+	       _("DW_TAG_call_site DW_AT_call_target is neither "
 		 "block nor reference, for DIE 0x%x [in module %s]"),
 	       die->offset.sect_off, objfile_name (objfile));
 
@@ -11851,7 +11870,8 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
       struct call_site_parameter *parameter;
       struct attribute *loc, *origin;
 
-      if (child_die->tag != DW_TAG_GNU_call_site_parameter)
+      if (child_die->tag != DW_TAG_call_site_parameter
+          && child_die->tag != DW_TAG_GNU_call_site_parameter)
 	{
 	  /* Already printed the complaint above.  */
 	  continue;
@@ -11862,10 +11882,16 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
 
       /* DW_AT_location specifies the register number or DW_AT_abstract_origin
 	 specifies DW_TAG_formal_parameter.  Value of the data assumed for the
-	 register is contained in DW_AT_GNU_call_site_value.  */
+	 register is contained in DW_AT_call_value.  */
 
       loc = dwarf2_attr (child_die, DW_AT_location, cu);
-      origin = dwarf2_attr (child_die, DW_AT_abstract_origin, cu);
+      origin = dwarf2_attr (child_die, DW_AT_call_parameter, cu);
+      if (origin == NULL)
+	{
+	  /* This was a pre-DWARF-5 GNU extension alias
+	     for DW_AT_call_parameter.  */
+	  origin = dwarf2_attr (child_die, DW_AT_abstract_origin, cu);
+	}
       if (loc == NULL && origin != NULL && attr_form_is_ref (origin))
 	{
 	  sect_offset offset;
@@ -11878,9 +11904,8 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
 		 binding can be done only inside one CU.  Such referenced DIE
 		 therefore cannot be even moved to DW_TAG_partial_unit.  */
 	      complaint (&symfile_complaints,
-			 _("DW_AT_abstract_origin offset is not in CU for "
-			   "DW_TAG_GNU_call_site child DIE 0x%x "
-			   "[in module %s]"),
+			 _("DW_AT_call_parameter offset is not in CU for "
+			   "DW_TAG_call_site child DIE 0x%x [in module %s]"),
 			 child_die->offset.sect_off, objfile_name (objfile));
 	      continue;
 	    }
@@ -11891,7 +11916,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
 	{
 	  complaint (&symfile_complaints,
 		     _("No DW_FORM_block* DW_AT_location for "
-		       "DW_TAG_GNU_call_site child DIE 0x%x [in module %s]"),
+		       "DW_TAG_call_site child DIE 0x%x [in module %s]"),
 		     child_die->offset.sect_off, objfile_name (objfile));
 	  continue;
 	}
@@ -11910,19 +11935,21 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
 	      complaint (&symfile_complaints,
 			 _("Only single DW_OP_reg or DW_OP_fbreg is supported "
 			   "for DW_FORM_block* DW_AT_location is supported for "
-			   "DW_TAG_GNU_call_site child DIE 0x%x "
+			   "DW_TAG_call_site child DIE 0x%x "
 			   "[in module %s]"),
 			 child_die->offset.sect_off, objfile_name (objfile));
 	      continue;
 	    }
 	}
 
-      attr = dwarf2_attr (child_die, DW_AT_GNU_call_site_value, cu);
+      attr = dwarf2_attr (child_die, DW_AT_call_value, cu);
+      if (attr == NULL)
+	attr = dwarf2_attr (child_die, DW_AT_GNU_call_site_value, cu);
       if (!attr_form_is_block (attr))
 	{
 	  complaint (&symfile_complaints,
-		     _("No DW_FORM_block* DW_AT_GNU_call_site_value for "
-		       "DW_TAG_GNU_call_site child DIE 0x%x [in module %s]"),
+		     _("No DW_FORM_block* DW_AT_call_value for "
+		       "DW_TAG_call_site child DIE 0x%x [in module %s]"),
 		     child_die->offset.sect_off, objfile_name (objfile));
 	  continue;
 	}
@@ -11934,13 +11961,15 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
       parameter->data_value_size = 0;
       call_site->parameter_count++;
 
-      attr = dwarf2_attr (child_die, DW_AT_GNU_call_site_data_value, cu);
+      attr = dwarf2_attr (child_die, DW_AT_call_data_value, cu);
+      if (attr == NULL)
+	attr = dwarf2_attr (child_die, DW_AT_GNU_call_site_data_value, cu);
       if (attr)
 	{
 	  if (!attr_form_is_block (attr))
 	    complaint (&symfile_complaints,
-		       _("No DW_FORM_block* DW_AT_GNU_call_site_data_value for "
-			 "DW_TAG_GNU_call_site child DIE 0x%x [in module %s]"),
+		       _("No DW_FORM_block* DW_AT_call_data_value for "
+			 "DW_TAG_call_site child DIE 0x%x [in module %s]"),
 		       child_die->offset.sect_off, objfile_name (objfile));
 	  else
 	    {
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 5852160..e094ece 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1041,12 +1041,12 @@ struct func_type
 
     unsigned int is_noreturn : 1;
 
-    /* * Only those DW_TAG_GNU_call_site's in this function that have
-       DW_AT_GNU_tail_call set are linked in this list.  Function
+    /* * Only those DW_TAG_call_site's in this function that have
+       DW_AT_call_tail_call set are linked in this list.  Function
        without its tail call list complete
-       (DW_AT_GNU_all_tail_call_sites or its superset
-       DW_AT_GNU_all_call_sites) has TAIL_CALL_LIST NULL, even if some
-       DW_TAG_GNU_call_site's exist in such function. */
+       (DW_AT_call_all_tail_calls or its superset
+       DW_AT_call_all_calls) has TAIL_CALL_LIST NULL, even if some
+       DW_TAG_call_site's exist in such function. */
 
     struct call_site *tail_call_list;
 
@@ -1106,13 +1106,12 @@ struct call_site_parameter
 
   union call_site_parameter_u u;
 
-  /* * DW_TAG_formal_parameter's DW_AT_GNU_call_site_value.  It
-     is never NULL.  */
+  /* * DW_TAG_formal_parameter's DW_AT_call_value.  It is never NULL.  */
 
   const gdb_byte *value;
   size_t value_size;
 
-  /* * DW_TAG_formal_parameter's DW_AT_GNU_call_site_data_value.
+  /* * DW_TAG_formal_parameter's DW_AT_call_data_value.
      It may be NULL if not provided by DWARF.  */
 
   const gdb_byte *data_value;
@@ -1120,8 +1119,7 @@ struct call_site_parameter
 };
 
 /* * A place where a function gets called from, represented by
-   DW_TAG_GNU_call_site.  It can be looked up from
-   symtab->call_site_htab.  */
+   DW_TAG_call_site.  It can be looked up from symtab->call_site_htab.  */
 
 struct call_site
   {
@@ -1135,7 +1133,7 @@ struct call_site
 
     struct call_site *tail_call_next;
 
-    /* * Describe DW_AT_GNU_call_site_target.  Missing attribute uses
+    /* * Describe DW_AT_call_target.  Missing attribute uses
        FIELD_LOC_KIND_DWARF_BLOCK with FIELD_DWARF_BLOCK == NULL.  */
 
     struct call_site_target target;
@@ -1149,7 +1147,7 @@ struct call_site
 
     struct dwarf2_per_cu_data *per_cu;
 
-    /* * Describe DW_TAG_GNU_call_site's DW_TAG_formal_parameter.  */
+    /* * Describe DW_TAG_call_site's DW_TAG_formal_parameter.  */
 
     struct call_site_parameter parameter[1];
   };
diff --git a/gdb/stack.c b/gdb/stack.c
index 6cd4110..aa3a80e 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -407,10 +407,9 @@ read_frame_arg (struct symbol *sym, struct frame_info *frame,
 		  /* Initialize it just to avoid a GCC false warning.  */
 		  struct value *val_deref = NULL, *entryval_deref;
 
-		  /* DW_AT_GNU_call_site_value does match with the current
+		  /* DW_AT_call_value does match with the current
 		     value.  If it is a reference still try to verify if
-		     dereferenced DW_AT_GNU_call_site_data_value does not
-		     differ.  */
+		     dereferenced DW_AT_call_data_value does not differ.  */
 
 		  TRY
 		    {
diff --git a/gdb/std-operator.def b/gdb/std-operator.def
index 5ce39c2..4650726 100644
--- a/gdb/std-operator.def
+++ b/gdb/std-operator.def
@@ -129,7 +129,7 @@ OP (OP_VAR_VALUE)
 /* OP_VAR_ENTRY_VALUE takes one struct symbol * in the following element,
    followed by another OP_VAR_ENTRY_VALUE, making three exp_elements.
    somename@entry may mean parameter value as present at the entry of the
-   current function.  Implemented via DW_OP_GNU_entry_value.  */
+   current function.  Implemented via DW_OP_entry_value.  */
 OP (OP_VAR_ENTRY_VALUE)
 
 /* OP_LAST is followed by an integer in the next exp_element.
diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.S b/gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.S
new file mode 100644
index 0000000..8b8ee94
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.S
@@ -0,0 +1,699 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2012-2017 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* This file is compiled from gdb.arch/amd64-entry-value-param-dwarf5.c
+   using -g -dA -S -O2.  */
+
+	.file	"amd64-entry-value-param-dwarf5.c"
+	.text
+.Ltext0:
+	.p2align 4,,15
+	.type	foo.isra.0.constprop.2, @function
+foo.isra.0.constprop.2:
+.LFB4:
+	/* gdb.arch/amd64-entry-value-param-dwarf5.c:21 */
+.LM1:
+	.cfi_startproc
+.LVL0:
+/* BLOCK 2 freq:10000 seq:0 */
+/* PRED: ENTRY [100.0%]  (FALLTHRU) */
+	/* gdb.arch/amd64-entry-value-param-dwarf5.c:26 */
+.LM2:
+	movl	vv(%rip), %eax
+	addl	$1, %eax
+	movl	%eax, vv(%rip)
+	/* gdb.arch/amd64-entry-value-param-dwarf5.c:27 */
+.LM3:
+	leal	3(%rdi), %eax
+/* SUCC: EXIT [100.0%]  */
+	/* gdb.arch/amd64-entry-value-param-dwarf5.c:28 */
+.LM4:
+	ret
+	.cfi_endproc
+.LFE4:
+	.size	foo.isra.0.constprop.2, .-foo.isra.0.constprop.2
+	.p2align 4,,15
+	.type	bar.constprop.1, @function
+bar.constprop.1:
+.LFB5:
+	/* gdb.arch/amd64-entry-value-param-dwarf5.c:31 */
+.LM5:
+	.cfi_startproc
+/* BLOCK 2 freq:10000 seq:0 */
+/* PRED: ENTRY [100.0%]  (FALLTHRU) */
+.LVL1:
+	/* gdb.arch/amd64-entry-value-param-dwarf5.c:33 */
+.LM6:
+	movl	$10, %edi
+	call	foo.isra.0.constprop.2
+.LVL2:
+	movl	$10, %edi
+	movl	%eax, %edx
+	call	foo.isra.0.constprop.2
+.LVL3:
+	movl	$16, %edi
+	addl	%eax, %edx
+	call	foo.isra.0.constprop.2
+.LVL4:
+	leal	10(%rdx,%rax), %eax
+/* SUCC: EXIT [100.0%]  */
+	/* gdb.arch/amd64-entry-value-param-dwarf5.c:34 */
+.LM7:
+	ret
+	.cfi_endproc
+.LFE5:
+	.size	bar.constprop.1, .-bar.constprop.1
+	.section	.text.startup,"ax",@progbits
+	.p2align 4,,15
+	.globl	main
+	.type	main, @function
+main:
+.LFB2:
+	/* gdb.arch/amd64-entry-value-param-dwarf5.c:38 */
+.LM8:
+	.cfi_startproc
+/* BLOCK 2 freq:10000 seq:0 */
+/* PRED: ENTRY [100.0%]  (FALLTHRU) */
+/* SUCC: EXIT [100.0%]  (ABNORMAL,SIBCALL) */
+	/* gdb.arch/amd64-entry-value-param-dwarf5.c:39 */
+.LM9:
+	jmp	bar.constprop.1
+.LVL5:
+	.cfi_endproc
+.LFE2:
+	.size	main, .-main
+	.comm	vv,4,4
+	.text
+.Letext0:
+	.section	.debug_info,"",@progbits
+.Ldebug_info0:
+	.long	0x199	/* Length of Compilation Unit Info */
+	.value	0x5	/* DWARF version number */
+	.byte	0x1	/* DW_UT_compile */
+	.byte	0x8	/* Pointer Size (in bytes) */
+	.long	.Ldebug_abbrev0	/* Offset Into Abbrev. Section */
+	.uleb128 0xa	/* (DIE (0xc) DW_TAG_compile_unit) */
+	.long	.LASF2	/* DW_AT_producer: "GNU C11 7.0.1 20170218 (experimental) -mtune=generic -march=x86-64 -gdwarf-5 -O2" */
+	.byte	0x1d	/* DW_AT_language */
+	.long	.LASF0	/* DW_AT_name: "gdb.arch/amd64-entry-value-param-dwarf5.c" */
+	.long	.LASF1	/* DW_AT_comp_dir: "" */
+	.long	.LLRL0	/* DW_AT_ranges */
+	.quad	0	/* DW_AT_low_pc */
+	.long	.Ldebug_line0	/* DW_AT_stmt_list */
+	.uleb128 0xb	/* (DIE (0x2a) DW_TAG_variable) */
+	.ascii "vv\0"	/* DW_AT_name */
+	.byte	0x1	/* DW_AT_decl_file (gdb.arch/amd64-entry-value-param-dwarf5.c) */
+	.byte	0x12	/* DW_AT_decl_line */
+	.long	0x45	/* DW_AT_type */
+			/* DW_AT_external */
+	.uleb128 0x9	/* DW_AT_location */
+	.byte	0x3	/* DW_OP_addr */
+	.quad	vv
+	.uleb128 0xc	/* (DIE (0x3e) DW_TAG_base_type) */
+	.byte	0x4	/* DW_AT_byte_size */
+	.byte	0x5	/* DW_AT_encoding */
+	.ascii "int\0"	/* DW_AT_name */
+	.uleb128 0xd	/* (DIE (0x45) DW_TAG_volatile_type) */
+	.long	0x3e	/* DW_AT_type */
+	.uleb128 0xe	/* (DIE (0x4a) DW_TAG_subprogram) */
+			/* DW_AT_external */
+	.long	.LASF3	/* DW_AT_name: "main" */
+	.byte	0x1	/* DW_AT_decl_file (gdb.arch/amd64-entry-value-param-dwarf5.c) */
+	.byte	0x25	/* DW_AT_decl_line */
+			/* DW_AT_prototyped */
+	.long	0x3e	/* DW_AT_type */
+	.quad	.LFB2	/* DW_AT_low_pc */
+	.quad	.LFE2-.LFB2	/* DW_AT_high_pc */
+	.uleb128 0x1	/* DW_AT_frame_base */
+	.byte	0x9c	/* DW_OP_call_frame_cfa */
+			/* DW_AT_call_all_calls */
+	.long	0x79	/* DW_AT_sibling */
+	.uleb128 0xf	/* (DIE (0x6b) DW_TAG_call_site) */
+	.quad	.LVL5	/* DW_AT_call_return_pc */
+			/* DW_AT_call_tail_call */
+	.long	0x125	/* DW_AT_call_origin */
+	.byte	0	/* end of children of DIE 0x4a */
+	.uleb128 0x5	/* (DIE (0x79) DW_TAG_subprogram) */
+	.ascii "bar\0"	/* DW_AT_name */
+			/* DW_AT_decl_file (1, gdb.arch/amd64-entry-value-param-dwarf5.c) */
+	.byte	0x1f	/* DW_AT_decl_line */
+			/* DW_AT_prototyped */
+	.long	0x3e	/* DW_AT_type */
+	.byte	0x1	/* DW_AT_inline */
+	.long	0x91	/* DW_AT_sibling */
+	.uleb128 0x1	/* (DIE (0x88) DW_TAG_formal_parameter) */
+	.ascii "x\0"	/* DW_AT_name */
+			/* DW_AT_decl_file (1, gdb.arch/amd64-entry-value-param-dwarf5.c) */
+	.byte	0x1f	/* DW_AT_decl_line */
+	.long	0x3e	/* DW_AT_type */
+	.byte	0	/* end of children of DIE 0x79 */
+	.uleb128 0x5	/* (DIE (0x91) DW_TAG_subprogram) */
+	.ascii "foo\0"	/* DW_AT_name */
+			/* DW_AT_decl_file (1, gdb.arch/amd64-entry-value-param-dwarf5.c) */
+	.byte	0x15	/* DW_AT_decl_line */
+			/* DW_AT_prototyped */
+	.long	0x3e	/* DW_AT_type */
+	.byte	0	/* DW_AT_inline */
+	.long	0xd1	/* DW_AT_sibling */
+	.uleb128 0x1	/* (DIE (0xa0) DW_TAG_formal_parameter) */
+	.ascii "x\0"	/* DW_AT_name */
+			/* DW_AT_decl_file (1, gdb.arch/amd64-entry-value-param-dwarf5.c) */
+	.byte	0x15	/* DW_AT_decl_line */
+	.long	0x3e	/* DW_AT_type */
+	.uleb128 0x1	/* (DIE (0xa8) DW_TAG_formal_parameter) */
+	.ascii "y\0"	/* DW_AT_name */
+			/* DW_AT_decl_file (1, gdb.arch/amd64-entry-value-param-dwarf5.c) */
+	.byte	0x15	/* DW_AT_decl_line */
+	.long	0x3e	/* DW_AT_type */
+	.uleb128 0x1	/* (DIE (0xb0) DW_TAG_formal_parameter) */
+	.ascii "z\0"	/* DW_AT_name */
+			/* DW_AT_decl_file (1, gdb.arch/amd64-entry-value-param-dwarf5.c) */
+	.byte	0x15	/* DW_AT_decl_line */
+	.long	0x3e	/* DW_AT_type */
+	.uleb128 0x2	/* (DIE (0xb8) DW_TAG_variable) */
+	.ascii "a\0"	/* DW_AT_name */
+			/* DW_AT_decl_file (1, gdb.arch/amd64-entry-value-param-dwarf5.c) */
+	.byte	0x17	/* DW_AT_decl_line */
+	.long	0x3e	/* DW_AT_type */
+	.uleb128 0x2	/* (DIE (0xc0) DW_TAG_variable) */
+	.ascii "b\0"	/* DW_AT_name */
+			/* DW_AT_decl_file (1, gdb.arch/amd64-entry-value-param-dwarf5.c) */
+	.byte	0x18	/* DW_AT_decl_line */
+	.long	0x3e	/* DW_AT_type */
+	.uleb128 0x2	/* (DIE (0xc8) DW_TAG_variable) */
+	.ascii "c\0"	/* DW_AT_name */
+			/* DW_AT_decl_file (1, gdb.arch/amd64-entry-value-param-dwarf5.c) */
+	.byte	0x19	/* DW_AT_decl_line */
+	.long	0x3e	/* DW_AT_type */
+	.byte	0	/* end of children of DIE 0x91 */
+	.uleb128 0x10	/* (DIE (0xd1) DW_TAG_subprogram) */
+	.long	0x91	/* DW_AT_abstract_origin */
+	.quad	.LFB4	/* DW_AT_low_pc */
+	.quad	.LFE4-.LFB4	/* DW_AT_high_pc */
+	.uleb128 0x1	/* DW_AT_frame_base */
+	.byte	0x9c	/* DW_OP_call_frame_cfa */
+			/* DW_AT_call_all_calls */
+	.long	0x125	/* DW_AT_sibling */
+	.uleb128 0x6	/* (DIE (0xec) DW_TAG_formal_parameter) */
+	.long	0xa0	/* DW_AT_abstract_origin */
+	.uleb128 0x1	/* DW_AT_location */
+	.byte	0x55	/* DW_OP_reg5 */
+	.uleb128 0x6	/* (DIE (0xf3) DW_TAG_formal_parameter) */
+	.long	0xa8	/* DW_AT_abstract_origin */
+	.uleb128 0x6	/* DW_AT_location */
+	.byte	0xfa	/* DW_OP_GNU_parameter_ref */
+	.long	0xa8
+	.byte	0x9f	/* DW_OP_stack_value */
+	.uleb128 0x7	/* (DIE (0xff) DW_TAG_variable) */
+	.long	0xb8	/* DW_AT_abstract_origin */
+	.uleb128 0x5	/* DW_AT_location */
+	.byte	0x75	/* DW_OP_breg5 */
+	.sleb128 0
+	.byte	0x31	/* DW_OP_lit1 */
+	.byte	0x24	/* DW_OP_shl */
+	.byte	0x9f	/* DW_OP_stack_value */
+	.uleb128 0x7	/* (DIE (0x10a) DW_TAG_variable) */
+	.long	0xc0	/* DW_AT_abstract_origin */
+	.uleb128 0x8	/* DW_AT_location */
+	.byte	0xfa	/* DW_OP_GNU_parameter_ref */
+	.long	0xa8
+	.byte	0x31	/* DW_OP_lit1 */
+	.byte	0x24	/* DW_OP_shl */
+	.byte	0x9f	/* DW_OP_stack_value */
+	.uleb128 0x11	/* (DIE (0x118) DW_TAG_variable) */
+	.long	0xc8	/* DW_AT_abstract_origin */
+	.byte	0x6	/* DW_AT_const_value */
+	.uleb128 0x8	/* (DIE (0x11e) DW_TAG_formal_parameter) */
+	.long	0xb0	/* DW_AT_abstract_origin */
+	.byte	0x3	/* DW_AT_const_value */
+	.byte	0	/* end of children of DIE 0xd1 */
+	.uleb128 0x12	/* (DIE (0x125) DW_TAG_subprogram) */
+	.long	0x79	/* DW_AT_abstract_origin */
+	.quad	.LFB5	/* DW_AT_low_pc */
+	.quad	.LFE5-.LFB5	/* DW_AT_high_pc */
+	.uleb128 0x1	/* DW_AT_frame_base */
+	.byte	0x9c	/* DW_OP_call_frame_cfa */
+			/* DW_AT_call_all_calls */
+	.uleb128 0x8	/* (DIE (0x13c) DW_TAG_formal_parameter) */
+	.long	0x88	/* DW_AT_abstract_origin */
+	.byte	0xa	/* DW_AT_const_value */
+	.uleb128 0x9	/* (DIE (0x142) DW_TAG_call_site) */
+	.quad	.LVL2	/* DW_AT_call_return_pc */
+	.long	0xd1	/* DW_AT_call_origin */
+	.long	0x161	/* DW_AT_sibling */
+	.uleb128 0x3	/* (DIE (0x153) DW_TAG_call_site_parameter) */
+	.uleb128 0x1	/* DW_AT_location */
+	.byte	0x55	/* DW_OP_reg5 */
+	.uleb128 0x2	/* DW_AT_call_value */
+	.byte	0x75	/* DW_OP_breg5 */
+	.sleb128 0
+	.uleb128 0x4	/* (DIE (0x159) DW_TAG_call_site_parameter) */
+	.long	0xa8	/* DW_AT_call_parameter */
+	.uleb128 0x1	/* DW_AT_call_value */
+	.byte	0x32	/* DW_OP_lit2 */
+	.byte	0	/* end of children of DIE 0x142 */
+	.uleb128 0x9	/* (DIE (0x161) DW_TAG_call_site) */
+	.quad	.LVL3	/* DW_AT_call_return_pc */
+	.long	0xd1	/* DW_AT_call_origin */
+	.long	0x180	/* DW_AT_sibling */
+	.uleb128 0x3	/* (DIE (0x172) DW_TAG_call_site_parameter) */
+	.uleb128 0x1	/* DW_AT_location */
+	.byte	0x55	/* DW_OP_reg5 */
+	.uleb128 0x2	/* DW_AT_call_value */
+	.byte	0x75	/* DW_OP_breg5 */
+	.sleb128 0
+	.uleb128 0x4	/* (DIE (0x178) DW_TAG_call_site_parameter) */
+	.long	0xa8	/* DW_AT_call_parameter */
+	.uleb128 0x1	/* DW_AT_call_value */
+	.byte	0x34	/* DW_OP_lit4 */
+	.byte	0	/* end of children of DIE 0x161 */
+	.uleb128 0x13	/* (DIE (0x180) DW_TAG_call_site) */
+	.quad	.LVL4	/* DW_AT_call_return_pc */
+	.long	0xd1	/* DW_AT_call_origin */
+	.uleb128 0x3	/* (DIE (0x18d) DW_TAG_call_site_parameter) */
+	.uleb128 0x1	/* DW_AT_location */
+	.byte	0x55	/* DW_OP_reg5 */
+	.uleb128 0x2	/* DW_AT_call_value */
+	.byte	0x75	/* DW_OP_breg5 */
+	.sleb128 0
+	.uleb128 0x4	/* (DIE (0x193) DW_TAG_call_site_parameter) */
+	.long	0xa8	/* DW_AT_call_parameter */
+	.uleb128 0x1	/* DW_AT_call_value */
+	.byte	0x3a	/* DW_OP_lit10 */
+	.byte	0	/* end of children of DIE 0x180 */
+	.byte	0	/* end of children of DIE 0x125 */
+	.byte	0	/* end of children of DIE 0xc */
+	.section	.debug_abbrev,"",@progbits
+.Ldebug_abbrev0:
+	.uleb128 0x1	/* (abbrev code) */
+	.uleb128 0x5	/* (TAG: DW_TAG_formal_parameter) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0x8	/* (DW_FORM_string) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0x21	/* (DW_FORM_implicit_const) */
+	.sleb128 1	/* (gdb.arch/amd64-entry-value-param-dwarf5.c) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.byte	0
+	.byte	0
+	.uleb128 0x2	/* (abbrev code) */
+	.uleb128 0x34	/* (TAG: DW_TAG_variable) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0x8	/* (DW_FORM_string) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0x21	/* (DW_FORM_implicit_const) */
+	.sleb128 1	/* (gdb.arch/amd64-entry-value-param-dwarf5.c) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.byte	0
+	.byte	0
+	.uleb128 0x3	/* (abbrev code) */
+	.uleb128 0x49	/* (TAG: DW_TAG_call_site_parameter) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x2	/* (DW_AT_location) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.uleb128 0x7e	/* (DW_AT_call_value) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.byte	0
+	.byte	0
+	.uleb128 0x4	/* (abbrev code) */
+	.uleb128 0x49	/* (TAG: DW_TAG_call_site_parameter) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x80	/* (DW_AT_call_parameter) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x7e	/* (DW_AT_call_value) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.byte	0
+	.byte	0
+	.uleb128 0x5	/* (abbrev code) */
+	.uleb128 0x2e	/* (TAG: DW_TAG_subprogram) */
+	.byte	0x1	/* DW_children_yes */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0x8	/* (DW_FORM_string) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0x21	/* (DW_FORM_implicit_const) */
+	.sleb128 1	/* (gdb.arch/amd64-entry-value-param-dwarf5.c) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x27	/* (DW_AT_prototyped) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x20	/* (DW_AT_inline) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x1	/* (DW_AT_sibling) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.byte	0
+	.byte	0
+	.uleb128 0x6	/* (abbrev code) */
+	.uleb128 0x5	/* (TAG: DW_TAG_formal_parameter) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x31	/* (DW_AT_abstract_origin) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x2	/* (DW_AT_location) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.byte	0
+	.byte	0
+	.uleb128 0x7	/* (abbrev code) */
+	.uleb128 0x34	/* (TAG: DW_TAG_variable) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x31	/* (DW_AT_abstract_origin) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x2	/* (DW_AT_location) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.byte	0
+	.byte	0
+	.uleb128 0x8	/* (abbrev code) */
+	.uleb128 0x5	/* (TAG: DW_TAG_formal_parameter) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x31	/* (DW_AT_abstract_origin) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x1c	/* (DW_AT_const_value) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.byte	0
+	.byte	0
+	.uleb128 0x9	/* (abbrev code) */
+	.uleb128 0x48	/* (TAG: DW_TAG_call_site) */
+	.byte	0x1	/* DW_children_yes */
+	.uleb128 0x7d	/* (DW_AT_call_return_pc) */
+	.uleb128 0x1	/* (DW_FORM_addr) */
+	.uleb128 0x7f	/* (DW_AT_call_origin) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x1	/* (DW_AT_sibling) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.byte	0
+	.byte	0
+	.uleb128 0xa	/* (abbrev code) */
+	.uleb128 0x11	/* (TAG: DW_TAG_compile_unit) */
+	.byte	0x1	/* DW_children_yes */
+	.uleb128 0x25	/* (DW_AT_producer) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x13	/* (DW_AT_language) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0x1f	/* (DW_FORM_line_strp) */
+	.uleb128 0x1b	/* (DW_AT_comp_dir) */
+	.uleb128 0x1f	/* (DW_FORM_line_strp) */
+	.uleb128 0x55	/* (DW_AT_ranges) */
+	.uleb128 0x17	/* (DW_FORM_sec_offset) */
+	.uleb128 0x11	/* (DW_AT_low_pc) */
+	.uleb128 0x1	/* (DW_FORM_addr) */
+	.uleb128 0x10	/* (DW_AT_stmt_list) */
+	.uleb128 0x17	/* (DW_FORM_sec_offset) */
+	.byte	0
+	.byte	0
+	.uleb128 0xb	/* (abbrev code) */
+	.uleb128 0x34	/* (TAG: DW_TAG_variable) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0x8	/* (DW_FORM_string) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x3f	/* (DW_AT_external) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x2	/* (DW_AT_location) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.byte	0
+	.byte	0
+	.uleb128 0xc	/* (abbrev code) */
+	.uleb128 0x24	/* (TAG: DW_TAG_base_type) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0xb	/* (DW_AT_byte_size) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3e	/* (DW_AT_encoding) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0x8	/* (DW_FORM_string) */
+	.byte	0
+	.byte	0
+	.uleb128 0xd	/* (abbrev code) */
+	.uleb128 0x35	/* (TAG: DW_TAG_volatile_type) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.byte	0
+	.byte	0
+	.uleb128 0xe	/* (abbrev code) */
+	.uleb128 0x2e	/* (TAG: DW_TAG_subprogram) */
+	.byte	0x1	/* DW_children_yes */
+	.uleb128 0x3f	/* (DW_AT_external) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x27	/* (DW_AT_prototyped) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x11	/* (DW_AT_low_pc) */
+	.uleb128 0x1	/* (DW_FORM_addr) */
+	.uleb128 0x12	/* (DW_AT_high_pc) */
+	.uleb128 0x7	/* (DW_FORM_data8) */
+	.uleb128 0x40	/* (DW_AT_frame_base) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.uleb128 0x7a	/* (DW_AT_call_all_calls) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x1	/* (DW_AT_sibling) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.byte	0
+	.byte	0
+	.uleb128 0xf	/* (abbrev code) */
+	.uleb128 0x48	/* (TAG: DW_TAG_call_site) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x7d	/* (DW_AT_call_return_pc) */
+	.uleb128 0x1	/* (DW_FORM_addr) */
+	.uleb128 0x82	/* (DW_AT_call_tail_call) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x7f	/* (DW_AT_call_origin) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.byte	0
+	.byte	0
+	.uleb128 0x10	/* (abbrev code) */
+	.uleb128 0x2e	/* (TAG: DW_TAG_subprogram) */
+	.byte	0x1	/* DW_children_yes */
+	.uleb128 0x31	/* (DW_AT_abstract_origin) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x11	/* (DW_AT_low_pc) */
+	.uleb128 0x1	/* (DW_FORM_addr) */
+	.uleb128 0x12	/* (DW_AT_high_pc) */
+	.uleb128 0x7	/* (DW_FORM_data8) */
+	.uleb128 0x40	/* (DW_AT_frame_base) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.uleb128 0x7a	/* (DW_AT_call_all_calls) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x1	/* (DW_AT_sibling) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.byte	0
+	.byte	0
+	.uleb128 0x11	/* (abbrev code) */
+	.uleb128 0x34	/* (TAG: DW_TAG_variable) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x31	/* (DW_AT_abstract_origin) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x1c	/* (DW_AT_const_value) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.byte	0
+	.byte	0
+	.uleb128 0x12	/* (abbrev code) */
+	.uleb128 0x2e	/* (TAG: DW_TAG_subprogram) */
+	.byte	0x1	/* DW_children_yes */
+	.uleb128 0x31	/* (DW_AT_abstract_origin) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x11	/* (DW_AT_low_pc) */
+	.uleb128 0x1	/* (DW_FORM_addr) */
+	.uleb128 0x12	/* (DW_AT_high_pc) */
+	.uleb128 0x7	/* (DW_FORM_data8) */
+	.uleb128 0x40	/* (DW_AT_frame_base) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.uleb128 0x7a	/* (DW_AT_call_all_calls) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.byte	0
+	.byte	0
+	.uleb128 0x13	/* (abbrev code) */
+	.uleb128 0x48	/* (TAG: DW_TAG_call_site) */
+	.byte	0x1	/* DW_children_yes */
+	.uleb128 0x7d	/* (DW_AT_call_return_pc) */
+	.uleb128 0x1	/* (DW_FORM_addr) */
+	.uleb128 0x7f	/* (DW_AT_call_origin) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.byte	0
+	.byte	0
+	.byte	0
+	.section	.debug_aranges,"",@progbits
+	.long	0x3c	/* Length of Address Ranges Info */
+	.value	0x2	/* DWARF Version */
+	.long	.Ldebug_info0	/* Offset of Compilation Unit Info */
+	.byte	0x8	/* Size of Address */
+	.byte	0	/* Size of Segment Descriptor */
+	.value	0	/* Pad to 16 byte boundary */
+	.value	0
+	.quad	.Ltext0	/* Address */
+	.quad	.Letext0-.Ltext0	/* Length */
+	.quad	.LFB2	/* Address */
+	.quad	.LFE2-.LFB2	/* Length */
+	.quad	0
+	.quad	0
+	.section	.debug_rnglists,"",@progbits
+.Ldebug_ranges0:
+	.long	.Ldebug_ranges3-.Ldebug_ranges2	/* Length of Range Lists */
+.Ldebug_ranges2:
+	.value	0x5	/* DWARF Version */
+	.byte	0x8	/* Address Size */
+	.byte	0	/* Segment Size */
+	.long	0	/* Offset Entry Count */
+.LLRL0:
+	.byte	0x7	/* DW_RLE_start_length (*.LLRL0) */
+	.quad	.Ltext0	/* Range begin address (*.LLRL0) */
+	.uleb128 .Letext0-.Ltext0	/* Range length (*.LLRL0) */
+	.byte	0x7	/* DW_RLE_start_length (*.LLRL0) */
+	.quad	.LFB2	/* Range begin address (*.LLRL0) */
+	.uleb128 .LFE2-.LFB2	/* Range length (*.LLRL0) */
+	.byte	0	/* DW_RLE_end_of_list (*.LLRL0) */
+.Ldebug_ranges3:
+	.section	.debug_line,"",@progbits
+.Ldebug_line0:
+	.long	.LELT0-.LSLT0	/* Length of Source Line Info */
+.LSLT0:
+	.value	0x5	/* DWARF Version */
+	.byte	0x8	/* Address Size */
+	.byte	0	/* Segment Size */
+	.long	.LELTP0-.LASLTP0	/* Prolog Length */
+.LASLTP0:
+	.byte	0x1	/* Minimum Instruction Length */
+	.byte	0x1	/* Maximum Operations Per Instruction */
+	.byte	0x1	/* Default is_stmt_start flag */
+	.byte	0xf6	/* Line Base Value (Special Opcodes) */
+	.byte	0xf2	/* Line Range Value (Special Opcodes) */
+	.byte	0xd	/* Special Opcode Base */
+	.byte	0	/* opcode: 0x1 has 0 args */
+	.byte	0x1	/* opcode: 0x2 has 1 args */
+	.byte	0x1	/* opcode: 0x3 has 1 args */
+	.byte	0x1	/* opcode: 0x4 has 1 args */
+	.byte	0x1	/* opcode: 0x5 has 1 args */
+	.byte	0	/* opcode: 0x6 has 0 args */
+	.byte	0	/* opcode: 0x7 has 0 args */
+	.byte	0	/* opcode: 0x8 has 0 args */
+	.byte	0x1	/* opcode: 0x9 has 1 args */
+	.byte	0	/* opcode: 0xa has 0 args */
+	.byte	0	/* opcode: 0xb has 0 args */
+	.byte	0x1	/* opcode: 0xc has 1 args */
+	.byte	0x1	/* Directory entry format count */
+	.uleb128 0x1	/* DW_LNCT_path */
+	.uleb128 0x1f	/* DW_FORM_line_strp */
+	.uleb128 0x2	/* Directories count */
+	.long	.LASF1	/* Directory Entry: 0: "" */
+	.long	.LASF4	/* Directory Entry: 0: "gdb.arch" */
+	.byte	0x2	/* File name entry format count */
+	.uleb128 0x1	/* DW_LNCT_path */
+	.uleb128 0x1f	/* DW_FORM_line_strp */
+	.uleb128 0x2	/* DW_LNCT_directory_index */
+	.uleb128 0xb	/* DW_FORM_data1 */
+	.uleb128 0x2	/* File names count */
+	.long	.LASF0	/* File Entry: 0: "gdb.arch/amd64-entry-value-param-dwarf5.c" */
+	.byte	0
+	.long	.LASF5	/* File Entry: 0: "amd64-entry-value-param-dwarf5.c" */
+	.byte	0x1
+.LELTP0:
+	.byte	0	/* set address *.LM8 */
+	.uleb128 0x9
+	.byte	0x2
+	.quad	.LM8
+	.byte	0x3c	/* line 38 */
+	.byte	0	/* set address *.LM9 */
+	.uleb128 0x9
+	.byte	0x2
+	.quad	.LM9
+	.byte	0x18	/* line 39 */
+	.byte	0	/* set address *.LFE2 */
+	.uleb128 0x9
+	.byte	0x2
+	.quad	.LFE2
+	.byte	0	/* end sequence */
+	.uleb128 0x1
+	.byte	0x1
+	.byte	0	/* set address *.LM1 */
+	.uleb128 0x9
+	.byte	0x2
+	.quad	.LM1
+	.byte	0x2b	/* line 21 */
+	.byte	0	/* set address *.LM2 */
+	.uleb128 0x9
+	.byte	0x2
+	.quad	.LM2
+	.byte	0x1c	/* line 26 */
+	.byte	0	/* set address *.LM3 */
+	.uleb128 0x9
+	.byte	0x2
+	.quad	.LM3
+	.byte	0x18	/* line 27 */
+	.byte	0	/* set address *.LM4 */
+	.uleb128 0x9
+	.byte	0x2
+	.quad	.LM4
+	.byte	0x18	/* line 28 */
+	.byte	0	/* set address *.LM5 */
+	.uleb128 0x9
+	.byte	0x2
+	.quad	.LM5
+	.byte	0x1a	/* line 31 */
+	.byte	0	/* set address *.LM6 */
+	.uleb128 0x9
+	.byte	0x2
+	.quad	.LM6
+	.byte	0x19	/* line 33 */
+	.byte	0	/* set address *.LM7 */
+	.uleb128 0x9
+	.byte	0x2
+	.quad	.LM7
+	.byte	0x18	/* line 34 */
+	.byte	0	/* set address *.Letext0 */
+	.uleb128 0x9
+	.byte	0x2
+	.quad	.Letext0
+	.byte	0	/* end sequence */
+	.uleb128 0x1
+	.byte	0x1
+.LELT0:
+	.section	.debug_str,"MS",@progbits,1
+.LASF2:
+	.string	"GNU C11 7.0.1 20170218 (experimental) -mtune=generic -march=x86-64 -gdwarf-5 -O2"
+.LASF3:
+	.string	"main"
+	.section	.debug_line_str,"MS",@progbits,1
+.LASF5:
+	.string	"amd64-entry-value-param-dwarf5.c"
+.LASF0:
+	.string	"gdb.arch/amd64-entry-value-param-dwarf5.c"
+.LASF1:
+	.string	""
+.LASF4:
+	.string	"gdb.arch"
+	.ident	"GCC: (GNU) 7.0.1 20170218 (experimental)"
+	.section	.note.GNU-stack,"",@progbits
diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.c b/gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.c
new file mode 100644
index 0000000..d677516
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.c
@@ -0,0 +1,40 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2012-2017 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+volatile int vv;
+
+static __attribute__((noinline)) int
+foo (int x, int y, int z)
+{
+  int a = x * 2;
+  int b = y * 2;
+  int c = z * 2;
+  vv++; /* break-here */
+  return x + z;
+}
+
+static __attribute__((noinline)) int
+bar (int x)
+{
+  return foo (x, 2, 3) + foo (x, 4, 3) + foo (x + 6, x, 3) + x;
+}
+
+int
+main (void)
+{
+  return bar (10);
+}
diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.exp b/gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.exp
new file mode 100644
index 0000000..0357ff4
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.exp
@@ -0,0 +1,49 @@
+# Copyright (C) 2012-2017 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+standard_testfile .S .c
+set opts {}
+
+if [info exists COMPILE] {
+    # make check RUNTESTFLAGS="gdb.arch/amd64-entry-value-param-dwarf5.exp COMPILE=1"
+    set srcfile ${srcfile2}
+    lappend opts optimize=-O2 additional_flags=-gdwarf-5
+} elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
+    verbose "Skipping amd64-entry-value-param-dwarf5."
+    return
+}
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
+    return -1
+}
+
+if ![runto_main] {
+    return -1
+}
+
+set srcfile $srcfile2
+gdb_breakpoint [gdb_get_line_number "break-here"]
+
+gdb_continue_to_breakpoint "break-here" ".* break-here .*"
+gdb_test "p y" " = 2"
+gdb_test "p b" " = 4"
+
+gdb_continue_to_breakpoint "break-here" ".* break-here .*"
+gdb_test "p y" " = 4"
+gdb_test "p b" " = 8"
+
+gdb_continue_to_breakpoint "break-here" ".* break-here .*"
+gdb_test "p y" " = 10"
+gdb_test "p b" " = 20"
diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value.exp b/gdb/testsuite/gdb.arch/amd64-entry-value.exp
index ee6bff5..d041b37 100644
--- a/gdb/testsuite/gdb.arch/amd64-entry-value.exp
+++ b/gdb/testsuite/gdb.arch/amd64-entry-value.exp
@@ -159,7 +159,7 @@ gdb_test_no_output "set print entry-values default" "entry_invalid: set print en
 gdb_test "frame" {\(inv=<optimized out>\).*} "entry_invalid: frame: default"
 
 
-# Test @entry values for DW_AT_GNU_call_site_data_value parameters.
+# Test @entry values for DW_AT_call_data_value parameters.
 
 gdb_continue_to_breakpoint "entry_reference: reference"
 
@@ -188,7 +188,7 @@ gdb_test "p regparam@entry" " = \\(int &\\) @$addr: 1" "entry_reference: p regpa
 gdb_test "p &regparam@entry" " = \\(int \\*\\) $addr" "entry_reference: p &regparam@entry"
 gdb_test "p regcopy" " = 1" "entry_reference: p regcopy"
 gdb_test "p nodataparam" " = \\(int &\\) @0x\[0-9a-f\]+: 22" "entry_reference: p nodataparam"
-gdb_test "p nodataparam@entry" "Cannot resolve DW_AT_GNU_call_site_data_value" "entry_reference: p nodataparam@entry"
+gdb_test "p nodataparam@entry" "Cannot resolve DW_AT_call_data_value" "entry_reference: p nodataparam@entry"
 
 
 # Test virtual tail call frames.
@@ -249,5 +249,5 @@ gdb_test "bt" "^bt\r\n#0 +d \\(i=<optimized out>, j=<optimized out>\\)\[^\r\n\]*
 	 "self: bt"
 
 gdb_test_no_output "set debug entry-values 1"
-gdb_test "bt" "DW_OP_GNU_entry_value resolving has found function \"self\\(int\\)\" at 0x\[0-9a-f\]+ can call itself via tail calls\r\n.*" \
+gdb_test "bt" "DW_OP_entry_value resolving has found function \"self\\(int\\)\" at 0x\[0-9a-f\]+ can call itself via tail calls\r\n.*" \
 	 "self: bt debug entry-values"

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v2 2/8] Code cleanup: Split dwarf2_ranges_read to a callback
  2017-02-19 21:28 [PATCH v2 1/8] Code cleanup: Split create_debug_types_hash_table Jan Kratochvil
  2017-02-19 21:28 ` [PATCH v2 7/8] DWARF-5: DW_FORM_data16 Jan Kratochvil
  2017-02-19 21:28 ` [PATCH v2 6/8] DWARF-5: Macros Jan Kratochvil
@ 2017-02-19 21:28 ` Jan Kratochvil
  2017-02-20 20:06   ` [commit] " Jan Kratochvil
  2017-02-19 21:28 ` [PATCH v2 5/8] DWARF-5: call sites Jan Kratochvil
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 24+ messages in thread
From: Jan Kratochvil @ 2017-02-19 21:28 UTC (permalink / raw)
  To: gdb-patches; +Cc: Victor Leschuk

Hi,

DWARF-5 has .debug_rnglists which is somehow similar to .debug_ranges.

This patch converts dwarf2_ranges_read to dwarf2_ranges_process which can work
with both DWARF kinds of range lists through a callback.

It also simplifies dwarf2_record_block_ranges which can benefit from it.

Jan


gdb/ChangeLog
2017-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf2read.c (dwarf2_ranges_process): New function from
	dwarf2_ranges_read.
	(dwarf2_ranges_read, dwarf2_record_block_ranges): Use
	dwarf2_ranges_process.
---
 gdb/dwarf2read.c |  127 ++++++++++++++++++------------------------------------
 1 file changed, 42 insertions(+), 85 deletions(-)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 9e07d20..e0ede18 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -11873,14 +11873,13 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
     }
 }
 
-/* Get low and high pc attributes from DW_AT_ranges attribute value OFFSET.
-   Return 1 if the attributes are present and valid, otherwise, return 0.
-   If RANGES_PST is not NULL we should setup `objfile->psymtabs_addrmap'.  */
+/* Call CALLBACK from DW_AT_ranges attribute value OFFSET.
+   Return 1 if the attributes are present and valid, otherwise, return 0.  */
 
 static int
-dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return,
-		    CORE_ADDR *high_return, struct dwarf2_cu *cu,
-		    struct partial_symtab *ranges_pst)
+dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu,
+		       std::function<void (CORE_ADDR range_beginning,
+					   CORE_ADDR range_end)> callback)
 {
   struct objfile *objfile = cu->objfile;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
@@ -11893,9 +11892,6 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return,
   int found_base;
   unsigned int dummy;
   const gdb_byte *buffer;
-  int low_set;
-  CORE_ADDR low = 0;
-  CORE_ADDR high = 0;
   CORE_ADDR baseaddr;
 
   found_base = cu->base_known;
@@ -11911,8 +11907,6 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return,
     }
   buffer = dwarf2_per_objfile->ranges.buffer + offset;
 
-  low_set = 0;
-
   baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 
   while (1)
@@ -11977,6 +11971,33 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return,
 	  continue;
 	}
 
+      callback (range_beginning, range_end);
+    }
+
+  return 1;
+}
+
+/* Get low and high pc attributes from DW_AT_ranges attribute value OFFSET.
+   Return 1 if the attributes are present and valid, otherwise, return 0.
+   If RANGES_PST is not NULL we should setup `objfile->psymtabs_addrmap'.  */
+
+static int
+dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return,
+		    CORE_ADDR *high_return, struct dwarf2_cu *cu,
+		    struct partial_symtab *ranges_pst)
+{
+  struct objfile *objfile = cu->objfile;
+  struct gdbarch *gdbarch = get_objfile_arch (objfile);
+  const CORE_ADDR baseaddr = ANOFFSET (objfile->section_offsets,
+				       SECT_OFF_TEXT (objfile));
+  int low_set = 0;
+  CORE_ADDR low = 0;
+  CORE_ADDR high = 0;
+  int retval;
+
+  retval = dwarf2_ranges_process (offset, cu,
+    [&] (CORE_ADDR range_beginning, CORE_ADDR range_end)
+    {
       if (ranges_pst != NULL)
 	{
 	  CORE_ADDR lowpc;
@@ -12007,7 +12028,9 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return,
 	  if (range_end > high)
 	    high = range_end;
 	}
-    }
+    });
+  if (!retval)
+    return 0;
 
   if (! low_set)
     /* If the first entry is an end-of-list marker, the range
@@ -12259,79 +12282,13 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block,
       CORE_ADDR base = cu->base_address;
       int base_known = cu->base_known;
 
-      dwarf2_read_section (objfile, &dwarf2_per_objfile->ranges);
-      if (offset >= dwarf2_per_objfile->ranges.size)
-        {
-          complaint (&symfile_complaints,
-                     _("Offset %lu out of bounds for DW_AT_ranges attribute"),
-                     offset);
-          return;
-        }
-      buffer = dwarf2_per_objfile->ranges.buffer + offset;
-
-      for (;;)
-        {
-          unsigned int bytes_read;
-          CORE_ADDR start, end;
-
-          start = read_address (obfd, buffer, cu, &bytes_read);
-          buffer += bytes_read;
-          end = read_address (obfd, buffer, cu, &bytes_read);
-          buffer += bytes_read;
-
-          /* Did we find the end of the range list?  */
-          if (start == 0 && end == 0)
-            break;
-
-          /* Did we find a base address selection entry?  */
-          else if ((start & base_select_mask) == base_select_mask)
-            {
-              base = end;
-              base_known = 1;
-            }
-
-          /* We found an ordinary address range.  */
-          else
-            {
-              if (!base_known)
-                {
-                  complaint (&symfile_complaints,
-			     _("Invalid .debug_ranges data "
-			       "(no base address)"));
-                  return;
-                }
-
-	      if (start > end)
-		{
-		  /* Inverted range entries are invalid.  */
-		  complaint (&symfile_complaints,
-			     _("Invalid .debug_ranges data "
-			       "(inverted range)"));
-		  return;
-		}
-
-	      /* Empty range entries have no effect.  */
-	      if (start == end)
-		continue;
-
-	      start += base + baseaddr;
-	      end += base + baseaddr;
-
-	      /* A not-uncommon case of bad debug info.
-		 Don't pollute the addrmap with bad data.  */
-	      if (start == 0 && !dwarf2_per_objfile->has_section_at_zero)
-		{
-		  complaint (&symfile_complaints,
-			     _(".debug_ranges entry has start address of zero"
-			       " [in module %s]"), objfile_name (objfile));
-		  continue;
-		}
-
-	      start = gdbarch_adjust_dwarf2_addr (gdbarch, start);
-	      end = gdbarch_adjust_dwarf2_addr (gdbarch, end);
-              record_block_range (block, start, end - 1);
-            }
-        }
+      dwarf2_ranges_process (offset, cu,
+	[&] (CORE_ADDR start, CORE_ADDR end)
+	{
+	  start = gdbarch_adjust_dwarf2_addr (gdbarch, start);
+	  end = gdbarch_adjust_dwarf2_addr (gdbarch, end);
+	  record_block_range (block, start, end - 1);
+	});
     }
 }
 

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v2 7/8] DWARF-5: DW_FORM_data16
  2017-02-19 21:28 [PATCH v2 1/8] Code cleanup: Split create_debug_types_hash_table Jan Kratochvil
@ 2017-02-19 21:28 ` Jan Kratochvil
  2017-02-20 20:09   ` [commit] " Jan Kratochvil
  2017-02-19 21:28 ` [PATCH v2 6/8] DWARF-5: Macros Jan Kratochvil
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 24+ messages in thread
From: Jan Kratochvil @ 2017-02-19 21:28 UTC (permalink / raw)
  To: gdb-patches; +Cc: Victor Leschuk

Hi,

DWARF-5 has new form DW_FORM_data16.  The problem is that GDB cannot pass
16-byte constant as a constant value as that would require GDB to use GCC
extension __int128.

Formerly such data was coded as DW_FORM_block* so GDB still decodes
DW_FORM_data16 like DW_FORM_block*.

Jan


gdb/ChangeLog
2017-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf2read.c (skip_one_die, read_attribute_value)
	(dwarf2_const_value_attr, dump_die_shallow)
	(dwarf2_get_attr_constant_value, dwarf2_fetch_constant_bytes)
	(skip_form_bytes, attr_form_is_constant): Handle DW_FORM_data16.

gdb/testsuite/ChangeLog
2017-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.dwarf2/formdata16.c: New file.
	* gdb.dwarf2/formdata16.exp: New file.
	* lib/dwarf.exp (Dwarf): Add DW_FORM_data16.
---
 gdb/dwarf2read.c                        |   25 ++++++++++
 gdb/testsuite/gdb.dwarf2/formdata16.c   |   22 +++++++++
 gdb/testsuite/gdb.dwarf2/formdata16.exp |   77 +++++++++++++++++++++++++++++++
 gdb/testsuite/lib/dwarf.exp             |    4 ++
 4 files changed, 127 insertions(+), 1 deletion(-)
 create mode 100644 gdb/testsuite/gdb.dwarf2/formdata16.c
 create mode 100644 gdb/testsuite/gdb.dwarf2/formdata16.exp

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 1034d7b..7b450ee 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -7414,6 +7414,9 @@ skip_one_die (const struct die_reader_specs *reader, const gdb_byte *info_ptr,
 	case DW_FORM_ref_sig8:
 	  info_ptr += 8;
 	  break;
+	case DW_FORM_data16:
+	  info_ptr += 16;
+	  break;
 	case DW_FORM_string:
 	  read_direct_string (abfd, info_ptr, &bytes_read);
 	  info_ptr += bytes_read;
@@ -16553,6 +16556,13 @@ read_attribute_value (const struct die_reader_specs *reader,
       DW_UNSND (attr) = read_8_bytes (abfd, info_ptr);
       info_ptr += 8;
       break;
+    case DW_FORM_data16:
+      blk = dwarf_alloc_block (cu);
+      blk->size = 16;
+      blk->data = read_n_bytes (abfd, info_ptr, 16);
+      info_ptr += 16;
+      DW_BLOCK (attr) = blk;
+      break;
     case DW_FORM_sec_offset:
       DW_UNSND (attr) = read_offset (abfd, info_ptr, &cu->header, &bytes_read);
       info_ptr += bytes_read;
@@ -19296,6 +19306,7 @@ dwarf2_const_value_attr (const struct attribute *attr, struct type *type,
     case DW_FORM_block4:
     case DW_FORM_block:
     case DW_FORM_exprloc:
+    case DW_FORM_data16:
       blk = DW_BLOCK (attr);
       if (TYPE_LENGTH (type) != blk->size)
 	dwarf2_const_value_length_mismatch_complaint (name, blk->size,
@@ -20250,6 +20261,9 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die)
 	  fprintf_unfiltered (f, "expression: size %s",
 			      pulongest (DW_BLOCK (&die->attrs[i])->size));
 	  break;
+	case DW_FORM_data16:
+	  fprintf_unfiltered (f, "constant of 16 bytes");
+	  break;
 	case DW_FORM_ref_addr:
 	  fprintf_unfiltered (f, "ref address: ");
 	  fputs_filtered (hex_string (DW_UNSND (&die->attrs[i])), f);
@@ -20411,6 +20425,7 @@ dwarf2_get_attr_constant_value (const struct attribute *attr, int default_value)
     return DW_UNSND (attr);
   else
     {
+      /* For DW_FORM_data16 see attr_form_is_constant.  */
       complaint (&symfile_complaints,
 		 _("Attribute value is not a constant (%s)"),
                  dwarf_form_name (attr->form));
@@ -20694,6 +20709,7 @@ dwarf2_fetch_constant_bytes (sect_offset offset,
     case DW_FORM_block4:
     case DW_FORM_block:
     case DW_FORM_exprloc:
+    case DW_FORM_data16:
       result = DW_BLOCK (attr)->data;
       *len = DW_BLOCK (attr)->size;
       break;
@@ -21602,6 +21618,10 @@ skip_form_bytes (bfd *abfd, const gdb_byte *bytes, const gdb_byte *buffer_end,
       bytes += 8;
       break;
 
+    case DW_FORM_data16:
+      bytes += 16;
+      break;
+
     case DW_FORM_string:
       read_direct_string (abfd, bytes, &bytes_read);
       bytes += bytes_read;
@@ -22265,7 +22285,10 @@ attr_form_is_section_offset (const struct attribute *attr)
    (lineptr, loclistptr, macptr or rangelistptr).  The DWARF spec says
    that, if an attribute's can be either a constant or one of the
    section offset classes, DW_FORM_data4 and DW_FORM_data8 should be
-   taken as section offsets, not constants.  */
+   taken as section offsets, not constants.
+
+   DW_FORM_data16 is not considered as dwarf2_get_attr_constant_value
+   cannot handle that.  */
 
 static int
 attr_form_is_constant (const struct attribute *attr)
diff --git a/gdb/testsuite/gdb.dwarf2/formdata16.c b/gdb/testsuite/gdb.dwarf2/formdata16.c
new file mode 100644
index 0000000..956545f
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/formdata16.c
@@ -0,0 +1,22 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2017 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+int
+main ()
+{
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.dwarf2/formdata16.exp b/gdb/testsuite/gdb.dwarf2/formdata16.exp
new file mode 100644
index 0000000..bba2015
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/formdata16.exp
@@ -0,0 +1,77 @@
+# Copyright 2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+load_lib dwarf.exp
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+if {![dwarf2_support]} {
+    return 0  
+}
+
+standard_testfile .c formdata16-dw.S
+
+# We need to know the endianess in order
+# to write some of the debugging info we'd like to generate.
+if [prepare_for_testing "failed to prepare for endianness test" ${testfile} ${srcfile}] {
+    return -1
+}
+
+set endianness "little"
+set test "show endian"
+gdb_test_multiple $test $test {
+    -re "(.* )(big|little)( endian.*)\r\n$gdb_prompt $" {
+	set endianness $expect_out(2,string)
+	pass "endianness"
+    }
+}
+
+set high "0x123456789abcdef0"
+set low "0x0fedcba987654321"
+if { $endianness == "big" } {
+    set pair $high,$low
+} else {
+    set pair $low,$high
+}
+
+# Make some DWARF for the test.
+set asm_file [standard_output_file $srcfile2]
+Dwarf::assemble $asm_file {
+    global pair
+
+    cu { addr_size 4 } {
+ 	compile_unit {} {
+	    declare_labels int_label
+
+	    int_label: DW_TAG_base_type {
+		{DW_AT_byte_size 16 DW_FORM_udata}
+		{DW_AT_encoding @DW_ATE_unsigned}
+		{DW_AT_name "__uint128"}
+	    }
+
+	    DW_TAG_variable {
+		{name xxx}
+		{type :$int_label}
+		{const_value $pair DW_FORM_data16}
+	    }
+	}
+    }
+}
+
+if { [prepare_for_testing "failed to prepare" ${testfile} \
+			  [list $srcfile $asm_file] {nodebug}] } {
+    return -1
+}
+
+gdb_test "p/x xxx" " = 0x123456789abcdef00fedcba987654321"
diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index 149038c..1ccdc5d 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -481,6 +481,10 @@ namespace eval Dwarf {
 		_op .8byte $value
 	    }
 
+	    DW_FORM_data16 {
+		_op .8byte $value
+	    }
+
 	    DW_FORM_strp {
 		variable _strings
 		variable _cu_offset_size

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v2 1/8] Code cleanup: Split create_debug_types_hash_table
@ 2017-02-19 21:28 Jan Kratochvil
  2017-02-19 21:28 ` [PATCH v2 7/8] DWARF-5: DW_FORM_data16 Jan Kratochvil
                   ` (7 more replies)
  0 siblings, 8 replies; 24+ messages in thread
From: Jan Kratochvil @ 2017-02-19 21:28 UTC (permalink / raw)
  To: gdb-patches; +Cc: Victor Leschuk

Hi,

DWARF-5 moved .debug_types into .debug_info and so the types reading code needs
to be reused more (in a future patch).

Jan


gdb/ChangeLog
2017-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf2read.c (create_debug_type_hash_table): New function from
	create_debug_types_hash_table.
	(create_debug_types_hash_table): Call create_debug_type_hash_table.
	(create_all_type_units, open_and_init_dwo_file): Update
	create_debug_types_hash_table callers.
---
 gdb/dwarf2read.c |  256 ++++++++++++++++++++++++++++--------------------------
 1 file changed, 131 insertions(+), 125 deletions(-)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 774ed73..9e07d20 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -4605,27 +4605,17 @@ add_signatured_type_cu_to_table (void **slot, void *datum)
   return 1;
 }
 
-/* Create the hash table of all entries in the .debug_types
-   (or .debug_types.dwo) section(s).
-   If reading a DWO file, then DWO_FILE is a pointer to the DWO file object,
-   otherwise it is NULL.
+/* A helper for create_debug_types_hash_table.  Read types from SECTION
+   and fill them into TYPES_HTAB.  */
 
-   The result is a pointer to the hash table or NULL if there are no types.
-
-   Note: This function processes DWO files only, not DWP files.  */
-
-static htab_t
-create_debug_types_hash_table (struct dwo_file *dwo_file,
-			       VEC (dwarf2_section_info_def) *types)
+static void
+create_debug_type_hash_table (struct dwo_file *dwo_file,
+			      dwarf2_section_info *section, htab_t &types_htab)
 {
   struct objfile *objfile = dwarf2_per_objfile->objfile;
-  htab_t types_htab = NULL;
-  int ix;
-  struct dwarf2_section_info *section;
   struct dwarf2_section_info *abbrev_section;
-
-  if (VEC_empty (dwarf2_section_info_def, types))
-    return NULL;
+  bfd *abfd;
+  const gdb_byte *info_ptr, *end_ptr;
 
   abbrev_section = (dwo_file != NULL
 		    ? &dwo_file->sections.abbrev
@@ -4636,136 +4626,152 @@ create_debug_types_hash_table (struct dwo_file *dwo_file,
 			dwo_file ? ".dwo" : "",
 			get_section_file_name (abbrev_section));
 
-  for (ix = 0;
-       VEC_iterate (dwarf2_section_info_def, types, ix, section);
-       ++ix)
-    {
-      bfd *abfd;
-      const gdb_byte *info_ptr, *end_ptr;
+  dwarf2_read_section (objfile, section);
+  info_ptr = section->buffer;
 
-      dwarf2_read_section (objfile, section);
-      info_ptr = section->buffer;
+  if (info_ptr == NULL)
+    return;
 
-      if (info_ptr == NULL)
-	continue;
+  /* We can't set abfd until now because the section may be empty or
+     not present, in which case the bfd is unknown.  */
+  abfd = get_section_bfd_owner (section);
 
-      /* We can't set abfd until now because the section may be empty or
-	 not present, in which case the bfd is unknown.  */
-      abfd = get_section_bfd_owner (section);
+  /* We don't use init_cutu_and_read_dies_simple, or some such, here
+     because we don't need to read any dies: the signature is in the
+     header.  */
 
-      /* We don't use init_cutu_and_read_dies_simple, or some such, here
-	 because we don't need to read any dies: the signature is in the
-	 header.  */
+  end_ptr = info_ptr + section->size;
+  while (info_ptr < end_ptr)
+    {
+      sect_offset offset;
+      cu_offset type_offset_in_tu;
+      ULONGEST signature;
+      struct signatured_type *sig_type;
+      struct dwo_unit *dwo_tu;
+      void **slot;
+      const gdb_byte *ptr = info_ptr;
+      struct comp_unit_head header;
+      unsigned int length;
 
-      end_ptr = info_ptr + section->size;
-      while (info_ptr < end_ptr)
-	{
-	  sect_offset offset;
-	  cu_offset type_offset_in_tu;
-	  ULONGEST signature;
-	  struct signatured_type *sig_type;
-	  struct dwo_unit *dwo_tu;
-	  void **slot;
-	  const gdb_byte *ptr = info_ptr;
-	  struct comp_unit_head header;
-	  unsigned int length;
+      offset.sect_off = ptr - section->buffer;
 
-	  offset.sect_off = ptr - section->buffer;
+      /* We need to read the type's signature in order to build the hash
+	 table, but we don't need anything else just yet.  */
 
-	  /* We need to read the type's signature in order to build the hash
-	     table, but we don't need anything else just yet.  */
+      ptr = read_and_check_type_unit_head (&header, section,
+					   abbrev_section, ptr,
+					   &signature, &type_offset_in_tu);
 
-	  ptr = read_and_check_type_unit_head (&header, section,
-					       abbrev_section, ptr,
-					       &signature, &type_offset_in_tu);
+      length = get_cu_length (&header);
 
-	  length = get_cu_length (&header);
+      /* Skip dummy type units.  */
+      if (ptr >= info_ptr + length
+	  || peek_abbrev_code (abfd, ptr) == 0)
+	{
+	  info_ptr += length;
+	  continue;
+	}
 
-	  /* Skip dummy type units.  */
-	  if (ptr >= info_ptr + length
-	      || peek_abbrev_code (abfd, ptr) == 0)
-	    {
-	      info_ptr += length;
-	      continue;
-	    }
+      if (types_htab == NULL)
+	{
+	  if (dwo_file)
+	    types_htab = allocate_dwo_unit_table (objfile);
+	  else
+	    types_htab = allocate_signatured_type_table (objfile);
+	}
 
-	  if (types_htab == NULL)
-	    {
-	      if (dwo_file)
-		types_htab = allocate_dwo_unit_table (objfile);
-	      else
-		types_htab = allocate_signatured_type_table (objfile);
-	    }
+      if (dwo_file)
+	{
+	  sig_type = NULL;
+	  dwo_tu = OBSTACK_ZALLOC (&objfile->objfile_obstack,
+				   struct dwo_unit);
+	  dwo_tu->dwo_file = dwo_file;
+	  dwo_tu->signature = signature;
+	  dwo_tu->type_offset_in_tu = type_offset_in_tu;
+	  dwo_tu->section = section;
+	  dwo_tu->offset = offset;
+	  dwo_tu->length = length;
+	}
+      else
+	{
+	  /* N.B.: type_offset is not usable if this type uses a DWO file.
+	     The real type_offset is in the 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->per_cu.objfile = objfile;
+	  sig_type->per_cu.is_debug_types = 1;
+	  sig_type->per_cu.section = section;
+	  sig_type->per_cu.offset = offset;
+	  sig_type->per_cu.length = length;
+	}
+
+      slot = htab_find_slot (types_htab,
+			     dwo_file ? (void*) dwo_tu : (void *) sig_type,
+			     INSERT);
+      gdb_assert (slot != NULL);
+      if (*slot != NULL)
+	{
+	  sect_offset dup_offset;
 
 	  if (dwo_file)
 	    {
-	      sig_type = NULL;
-	      dwo_tu = OBSTACK_ZALLOC (&objfile->objfile_obstack,
-				       struct dwo_unit);
-	      dwo_tu->dwo_file = dwo_file;
-	      dwo_tu->signature = signature;
-	      dwo_tu->type_offset_in_tu = type_offset_in_tu;
-	      dwo_tu->section = section;
-	      dwo_tu->offset = offset;
-	      dwo_tu->length = length;
+	      const struct dwo_unit *dup_tu
+		= (const struct dwo_unit *) *slot;
+
+	      dup_offset = dup_tu->offset;
 	    }
 	  else
 	    {
-	      /* N.B.: type_offset is not usable if this type uses a DWO file.
-		 The real type_offset is in the 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->per_cu.objfile = objfile;
-	      sig_type->per_cu.is_debug_types = 1;
-	      sig_type->per_cu.section = section;
-	      sig_type->per_cu.offset = offset;
-	      sig_type->per_cu.length = length;
+	      const struct signatured_type *dup_tu
+		= (const struct signatured_type *) *slot;
+
+	      dup_offset = dup_tu->per_cu.offset;
 	    }
 
-	  slot = htab_find_slot (types_htab,
-				 dwo_file ? (void*) dwo_tu : (void *) sig_type,
-				 INSERT);
-	  gdb_assert (slot != NULL);
-	  if (*slot != NULL)
-	    {
-	      sect_offset dup_offset;
+	  complaint (&symfile_complaints,
+		     _("debug type entry at offset 0x%x is duplicate to"
+		       " the entry at offset 0x%x, signature %s"),
+		     offset.sect_off, dup_offset.sect_off,
+		     hex_string (signature));
+	}
+      *slot = dwo_file ? (void *) dwo_tu : (void *) sig_type;
 
-	      if (dwo_file)
-		{
-		  const struct dwo_unit *dup_tu
-		    = (const struct dwo_unit *) *slot;
+      if (dwarf_read_debug > 1)
+	fprintf_unfiltered (gdb_stdlog, "  offset 0x%x, signature %s\n",
+			    offset.sect_off,
+			    hex_string (signature));
 
-		  dup_offset = dup_tu->offset;
-		}
-	      else
-		{
-		  const struct signatured_type *dup_tu
-		    = (const struct signatured_type *) *slot;
+      info_ptr += length;
+    }
+}
 
-		  dup_offset = dup_tu->per_cu.offset;
-		}
+/* Create the hash table of all entries in the .debug_types
+   (or .debug_types.dwo) section(s).
+   If reading a DWO file, then DWO_FILE is a pointer to the DWO file object,
+   otherwise it is NULL.
 
-	      complaint (&symfile_complaints,
-			 _("debug type entry at offset 0x%x is duplicate to"
-			   " the entry at offset 0x%x, signature %s"),
-			 offset.sect_off, dup_offset.sect_off,
-			 hex_string (signature));
-	    }
-	  *slot = dwo_file ? (void *) dwo_tu : (void *) sig_type;
+   The result is a pointer to the hash table or NULL if there are no types.
 
-	  if (dwarf_read_debug > 1)
-	    fprintf_unfiltered (gdb_stdlog, "  offset 0x%x, signature %s\n",
-				offset.sect_off,
-				hex_string (signature));
+   Note: This function processes DWO files only, not DWP files.  */
 
-	  info_ptr += length;
-	}
-    }
+static void
+create_debug_types_hash_table (struct dwo_file *dwo_file,
+			       VEC (dwarf2_section_info_def) *types,
+			       htab_t &types_htab)
+{
+  int ix;
+  struct dwarf2_section_info *section;
+
+  if (VEC_empty (dwarf2_section_info_def, types))
+    return;
 
-  return types_htab;
+  for (ix = 0;
+       VEC_iterate (dwarf2_section_info_def, types, ix, section);
+       ++ix)
+    create_debug_type_hash_table (dwo_file, section, types_htab);
 }
 
 /* Create the hash table of all entries in the .debug_types section,
@@ -4776,10 +4782,10 @@ create_debug_types_hash_table (struct dwo_file *dwo_file,
 static int
 create_all_type_units (struct objfile *objfile)
 {
-  htab_t types_htab;
+  htab_t types_htab = NULL;
   struct signatured_type **iter;
 
-  types_htab = create_debug_types_hash_table (NULL, dwarf2_per_objfile->types);
+  create_debug_types_hash_table (NULL, dwarf2_per_objfile->types, types_htab);
   if (types_htab == NULL)
     {
       dwarf2_per_objfile->signatured_types = NULL;
@@ -10615,8 +10621,8 @@ open_and_init_dwo_file (struct dwarf2_per_cu_data *per_cu,
 
   dwo_file->cu = create_dwo_cu (dwo_file);
 
-  dwo_file->tus = create_debug_types_hash_table (dwo_file,
-						 dwo_file->sections.types);
+  create_debug_types_hash_table (dwo_file, dwo_file->sections.types,
+				 dwo_file->tus);
 
   discard_cleanups (cleanups);
 

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 5/8] DWARF-5: call sites
  2017-02-19 21:28 ` [PATCH v2 5/8] DWARF-5: call sites Jan Kratochvil
@ 2017-02-20  3:31   ` Eli Zaretskii
  2017-02-20 20:08   ` [commit] " Jan Kratochvil
  1 sibling, 0 replies; 24+ messages in thread
From: Eli Zaretskii @ 2017-02-20  3:31 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches, vleschuk

> From: Jan Kratochvil <jan.kratochvil@redhat.com>
> Cc: Victor Leschuk <vleschuk@accesssoftek.com>
> Date: Sun, 19 Feb 2017 22:28:32 +0100
> 
> this patch updates all call sites related DWARF-5 renames.

OK for the documentation part.

Thanks.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 8/8] DWARF-5: NEWS
  2017-02-19 21:28 ` [PATCH v2 8/8] DWARF-5: NEWS Jan Kratochvil
@ 2017-02-20  3:31   ` Eli Zaretskii
  2017-02-20 20:09   ` [commit] " Jan Kratochvil
  1 sibling, 0 replies; 24+ messages in thread
From: Eli Zaretskii @ 2017-02-20  3:31 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches, vleschuk

> From: Jan Kratochvil <jan.kratochvil@redhat.com>
> Cc: Victor Leschuk <vleschuk@accesssoftek.com>
> Date: Sun, 19 Feb 2017 22:28:54 +0100
> 
> a NEWS entry.
> 
> Jan
> 
> 
> gdb/ChangeLog
> 2017-02-19  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* NEWS (Changes since GDB 7.12): Add DWARF-5.

OK.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [commit] [PATCH v2 1/8] Code cleanup: Split create_debug_types_hash_table
  2017-02-19 21:28 [PATCH v2 1/8] Code cleanup: Split create_debug_types_hash_table Jan Kratochvil
                   ` (6 preceding siblings ...)
  2017-02-19 21:28 ` [PATCH v2 3/8] Code cleanup: Refactor abbrev_table_read_table cycle Jan Kratochvil
@ 2017-02-20 20:05 ` Jan Kratochvil
  7 siblings, 0 replies; 24+ messages in thread
From: Jan Kratochvil @ 2017-02-20 20:05 UTC (permalink / raw)
  To: gdb-patches; +Cc: Victor Leschuk

On Sun, 19 Feb 2017 22:28:04 +0100, Jan Kratochvil wrote:
> gdb/ChangeLog
> 2017-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* dwarf2read.c (create_debug_type_hash_table): New function from
> 	create_debug_types_hash_table.
> 	(create_debug_types_hash_table): Call create_debug_type_hash_table.
> 	(create_all_type_units, open_and_init_dwo_file): Update
> 	create_debug_types_hash_table callers.

78d4d2c538dd7975f0f130b2df842c4858c01fd3


Jan

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [commit] [PATCH v2 2/8] Code cleanup: Split dwarf2_ranges_read to a callback
  2017-02-19 21:28 ` [PATCH v2 2/8] Code cleanup: Split dwarf2_ranges_read to a callback Jan Kratochvil
@ 2017-02-20 20:06   ` Jan Kratochvil
  0 siblings, 0 replies; 24+ messages in thread
From: Jan Kratochvil @ 2017-02-20 20:06 UTC (permalink / raw)
  To: gdb-patches; +Cc: Victor Leschuk

On Sun, 19 Feb 2017 22:28:11 +0100, Jan Kratochvil wrote:
> gdb/ChangeLog
> 2017-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* dwarf2read.c (dwarf2_ranges_process): New function from
> 	dwarf2_ranges_read.
> 	(dwarf2_ranges_read, dwarf2_record_block_ranges): Use
> 	dwarf2_ranges_process.

5f46c5a54825aabb3f30095c84ac30aff7400ac5


Jan

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [commit] [PATCH v2 3/8] Code cleanup: Refactor abbrev_table_read_table cycle
  2017-02-19 21:28 ` [PATCH v2 3/8] Code cleanup: Refactor abbrev_table_read_table cycle Jan Kratochvil
@ 2017-02-20 20:06   ` Jan Kratochvil
  0 siblings, 0 replies; 24+ messages in thread
From: Jan Kratochvil @ 2017-02-20 20:06 UTC (permalink / raw)
  To: gdb-patches; +Cc: Victor Leschuk

On Sun, 19 Feb 2017 22:28:18 +0100, Jan Kratochvil wrote:
> gdb/ChangeLog
> 2017-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* dwarf2read.c (abbrev_table_read_table): Read the data only once.

22d2f3ab926890490deed2888f6f013031fa6a6e


Jan

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [commit] [PATCH v2 6/8] DWARF-5: Macros
  2017-02-19 21:28 ` [PATCH v2 6/8] DWARF-5: Macros Jan Kratochvil
@ 2017-02-20 20:08   ` Jan Kratochvil
  0 siblings, 0 replies; 24+ messages in thread
From: Jan Kratochvil @ 2017-02-20 20:08 UTC (permalink / raw)
  To: gdb-patches; +Cc: Victor Leschuk

On Sun, 19 Feb 2017 22:28:40 +0100, Jan Kratochvil wrote:
> gdb/ChangeLog
> 2017-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* dwarf2read.c (read_file_scope): Rename DW_MACRO_GNU_*.
> 	(dwarf_parse_macro_header): Accept DWARF version 5.
> 	(dwarf_decode_macro_bytes, dwarf_decode_macros): Rename DW_MACRO_GNU_*.

0af92d6069f5c43f0090b78d4cb8fda7d9861b22


Jan

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [commit] [PATCH v2 5/8] DWARF-5: call sites
  2017-02-19 21:28 ` [PATCH v2 5/8] DWARF-5: call sites Jan Kratochvil
  2017-02-20  3:31   ` Eli Zaretskii
@ 2017-02-20 20:08   ` Jan Kratochvil
  1 sibling, 0 replies; 24+ messages in thread
From: Jan Kratochvil @ 2017-02-20 20:08 UTC (permalink / raw)
  To: gdb-patches; +Cc: Victor Leschuk

On Sun, 19 Feb 2017 22:28:32 +0100, Jan Kratochvil wrote:
> gdb/ChangeLog
> 2017-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* block.c (call_site_for_pc): Rename DW_OP_GNU_*, DW_TAG_GNU_* and
> 	DW_AT_GNU_*.
> 	* common/common-exceptions.h (enum errors): Likewise.
> 	* dwarf2-frame.c (class dwarf_expr_executor): Likewise.
> 	* dwarf2expr.c (dwarf_block_to_dwarf_reg)
> 	(dwarf_expr_context::execute_stack_op): Likewise.
> 	* dwarf2expr.h (struct dwarf_expr_context, struct dwarf_expr_piece):
> 	Likewise.
> 	* dwarf2loc.c (dwarf_evaluate_loc_desc::get_base_type)
> 	(dwarf_evaluate_loc_desc::push_dwarf_reg_entry_value)
> 	(show_entry_values_debug, call_site_to_target_addr)
> 	(func_addr_to_tail_call_list, func_verify_no_selftailcall)
> 	(dwarf_expr_reg_to_entry_parameter, dwarf_entry_parameter_to_value)
> 	(entry_data_value_free_closure, value_of_dwarf_reg_entry)
> 	(value_of_dwarf_block_entry, indirect_pieced_value)
> 	(symbol_needs_eval_context::push_dwarf_reg_entry_value):
> 	(disassemble_dwarf_expression): Likewise.
> 	* dwarf2read.c (process_die, inherit_abstract_dies)
> 	(read_call_site_scope): Likewise.
> 	* gdbtypes.h (struct func_type, struct call_site_parameter)
> 	(struct call_site): Likewise.
> 	* stack.c (read_frame_arg): Likewise.
> 	* std-operator.def (OP_VAR_ENTRY_VALUE): Likewise.
> 
> gdb/doc/ChangeLog
> 2017-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* gdb.texinfo (Print Settings, Tail Call Frames): Rename DW_OP_GNU_*,
> 	DW_TAG_GNU_* and DW_AT_GNU_*.
> 
> gdb/testsuite/ChangeLog
> 2017-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* gdb.arch/amd64-entry-value-param-dwarf5.S: New file.
> 	* gdb.arch/amd64-entry-value-param-dwarf5.c: New file.
> 	* gdb.arch/amd64-entry-value-param-dwarf5.exp: New file.
> 	* gdb.arch/amd64-entry-value.exp: Rename DW_OP_GNU_*, DW_TAG_GNU_* and
> 	DW_AT_GNU_*.

216f72a1ed20a8c9cdaea74e03be24601a1ed974


Jan

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [commit] [PATCH v2 7/8] DWARF-5: DW_FORM_data16
  2017-02-19 21:28 ` [PATCH v2 7/8] DWARF-5: DW_FORM_data16 Jan Kratochvil
@ 2017-02-20 20:09   ` Jan Kratochvil
  0 siblings, 0 replies; 24+ messages in thread
From: Jan Kratochvil @ 2017-02-20 20:09 UTC (permalink / raw)
  To: gdb-patches; +Cc: Victor Leschuk

On Sun, 19 Feb 2017 22:28:47 +0100, Jan Kratochvil wrote:
> gdb/ChangeLog
> 2017-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* dwarf2read.c (skip_one_die, read_attribute_value)
> 	(dwarf2_const_value_attr, dump_die_shallow)
> 	(dwarf2_get_attr_constant_value, dwarf2_fetch_constant_bytes)
> 	(skip_form_bytes, attr_form_is_constant): Handle DW_FORM_data16.
> 
> gdb/testsuite/ChangeLog
> 2017-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* gdb.dwarf2/formdata16.c: New file.
> 	* gdb.dwarf2/formdata16.exp: New file.
> 	* lib/dwarf.exp (Dwarf): Add DW_FORM_data16.

0224619f6085908935f689b87e1ac4e460bb1e71


Jan

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [commit] [PATCH v2 8/8] DWARF-5: NEWS
  2017-02-19 21:28 ` [PATCH v2 8/8] DWARF-5: NEWS Jan Kratochvil
  2017-02-20  3:31   ` Eli Zaretskii
@ 2017-02-20 20:09   ` Jan Kratochvil
  1 sibling, 0 replies; 24+ messages in thread
From: Jan Kratochvil @ 2017-02-20 20:09 UTC (permalink / raw)
  To: gdb-patches; +Cc: Victor Leschuk

On Sun, 19 Feb 2017 22:28:54 +0100, Jan Kratochvil wrote:
> gdb/ChangeLog
> 2017-02-19  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* NEWS (Changes since GDB 7.12): Add DWARF-5.

0ae60b631e1648880d326c4a9986d5d522b6ae8a


Jan

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 4/8] DWARF-5 basic functionality
  2017-02-19 21:28 ` [PATCH v2 4/8] DWARF-5 basic functionality Jan Kratochvil
@ 2017-02-21 19:18   ` Andreas Arnez
  2017-02-22 14:29     ` Jan Kratochvil
  0 siblings, 1 reply; 24+ messages in thread
From: Andreas Arnez @ 2017-02-21 19:18 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches, Victor Leschuk

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)
     {

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 4/8] DWARF-5 basic functionality
  2017-02-21 19:18   ` Andreas Arnez
@ 2017-02-22 14:29     ` Jan Kratochvil
  2017-02-22 17:38       ` Andreas Arnez
  0 siblings, 1 reply; 24+ messages in thread
From: Jan Kratochvil @ 2017-02-22 14:29 UTC (permalink / raw)
  To: Andreas Arnez; +Cc: gdb-patches, Victor Leschuk

On Tue, 21 Feb 2017 20:18:36 +0100, Andreas Arnez wrote:
> 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]

What compiler/version/options do you use?  I have tried now
	gcc-4.8.5-11.el7.x86_64
	CFLAGS=-O3 CXXFLAGS=-O3 ./configure;make

While I get some warnings/errors none of them is in dwarf2read.c.

I do not want to patch it without reproducibility of the warnings.


> 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?).

Yes, I hope so.


> 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?

Yes.  Otherwise GDB would not read definitions of classes during
	-gdwarf-5 -fdebug-types-section
as then DW_UT_type are located inside .debug_info.


> When doing so (see untested patch below),

No, that breaks: -gdwarf-5 -fdebug-types-section


Jan

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 4/8] DWARF-5 basic functionality
  2017-02-22 14:29     ` Jan Kratochvil
@ 2017-02-22 17:38       ` Andreas Arnez
  2017-02-22 18:32         ` Jan Kratochvil
  0 siblings, 1 reply; 24+ messages in thread
From: Andreas Arnez @ 2017-02-22 17:38 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches, Victor Leschuk

On Wed, Feb 22 2017, Jan Kratochvil wrote:

> What compiler/version/options do you use?  I have tried now
> 	gcc-4.8.5-11.el7.x86_64
> 	CFLAGS=-O3 CXXFLAGS=-O3 ./configure;make

I saw the warning with an upstream GCC I recently built myself for
s390x.  Today I retried with a fresh version from GCC git, with the same
result: gcc (GCC) 7.0.1 20170222 (experimental)

> While I get some warnings/errors none of them is in dwarf2read.c.
>
> I do not want to patch it without reproducibility of the warnings.

Sure.  Unfortunately the maybe-uninitialized warnings highly depend on
compiler version, platform, optimization level, etc.  Since this is a
false positive, I don't necessarily propose a change in this case.

[...]

>> 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?
>
> Yes.  Otherwise GDB would not read definitions of classes during
> 	-gdwarf-5 -fdebug-types-section
> as then DW_UT_type are located inside .debug_info.

Ah, I see; thanks for explanation.  Seems I was misled by the function
description that mentions "all entries in the .debug_types section", but
fails to mention the .debug_info section.

I also stumbled upon the fact that read_comp_unit_head performs the
conditional initialization under "if (section_kind == rcuh_kind::TYPE)"
instead of checking for the appropriate unit type.  This works because
section_kind is adjusted accordingly above, but it might be clearer
otherwise.

--
Andreas

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 4/8] DWARF-5 basic functionality
  2017-02-22 17:38       ` Andreas Arnez
@ 2017-02-22 18:32         ` Jan Kratochvil
  2017-02-23 16:59           ` Andreas Arnez
  0 siblings, 1 reply; 24+ messages in thread
From: Jan Kratochvil @ 2017-02-22 18:32 UTC (permalink / raw)
  To: Andreas Arnez; +Cc: gdb-patches, Victor Leschuk

On Wed, 22 Feb 2017 18:38:11 +0100, Andreas Arnez wrote:
> On Wed, Feb 22 2017, Jan Kratochvil wrote:
> 
> > What compiler/version/options do you use?  I have tried now
> > 	gcc-4.8.5-11.el7.x86_64
> > 	CFLAGS=-O3 CXXFLAGS=-O3 ./configure;make
> 
> I saw the warning with an upstream GCC I recently built myself for
> s390x.  Today I retried with a fresh version from GCC git, with the same
> result: gcc (GCC) 7.0.1 20170222 (experimental)

g++ (GCC) 7.0.1 20170218 (experimental)
~/redhat/gcchead-root/bin/g++  -m64 -g3 -pipe -Wall -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -fno-diagnostics-show-caret    -I. -I. -I./common -I./config -DLOCALEDIR="\"/usr/local/share/locale\"" -DHAVE_CONFIG_H -I./../include/opcode -I./../opcodes/.. -I./../readline/.. -I./../zlib -I../bfd -I./../bfd -I./../include -I../libdecnumber -I./../libdecnumber  -I./gnulib/import -Ibuild-gnulib/import   -DTUI=1  -I/usr/include/python3.5m -I/usr/include/python3.5m -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-compare -Wno-write-strings -Wno-narrowing -Wformat-nonliteral -Werror -c -o dwarf2read.o -MT dwarf2read.o -MMD -MP -MF .deps/dwarf2read.Tpo dwarf2read.c -O3

But on x86_64.  I can try building trunk GCC on s390x but do you really have
the warnings unreproducible on x86_64?


> Sure.  Unfortunately the maybe-uninitialized warnings highly depend on
> compiler version, platform, optimization level, etc.  Since this is a
> false positive, I don't necessarily propose a change in this case.

Also there are already many warnings just with RHEL-7.3 x86_64 GCC for
example.


Jan

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 4/8] DWARF-5 basic functionality
  2017-02-22 18:32         ` Jan Kratochvil
@ 2017-02-23 16:59           ` Andreas Arnez
  2017-02-24 12:57             ` [patch] DWARF-5: Initialization due to a false compiler warning [Re: [PATCH v2 4/8] DWARF-5 basic functionality] Jan Kratochvil
  0 siblings, 1 reply; 24+ messages in thread
From: Andreas Arnez @ 2017-02-23 16:59 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches, Victor Leschuk

On Wed, Feb 22 2017, Jan Kratochvil wrote:

> On Wed, 22 Feb 2017 18:38:11 +0100, Andreas Arnez wrote:
>> On Wed, Feb 22 2017, Jan Kratochvil wrote:
>> 
>> > What compiler/version/options do you use?  I have tried now
>> > 	gcc-4.8.5-11.el7.x86_64
>> > 	CFLAGS=-O3 CXXFLAGS=-O3 ./configure;make
>> 
>> I saw the warning with an upstream GCC I recently built myself for
>> s390x.  Today I retried with a fresh version from GCC git, with the same
>> result: gcc (GCC) 7.0.1 20170222 (experimental)
>
> g++ (GCC) 7.0.1 20170218 (experimental)
> ~/redhat/gcchead-root/bin/g++ -m64 -g3 -pipe -Wall -fexceptions
> -fstack-protector-strong --param=ssp-buffer-size=4
> -fno-diagnostics-show-caret -I. -I. -I./common -I./config
> -DLOCALEDIR="\"/usr/local/share/locale\"" -DHAVE_CONFIG_H
> -I./../include/opcode -I./../opcodes/.. -I./../readline/.. -I./../zlib
> -I../bfd -I./../bfd -I./../include -I../libdecnumber -I./../libdecnumber
> -I./gnulib/import -Ibuild-gnulib/import -DTUI=1 -I/usr/include/python3.5m
> -I/usr/include/python3.5m -Wall -Wpointer-arith -Wno-unused -Wunused-value
> -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body
> -Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-compare
> -Wno-write-strings -Wno-narrowing -Wformat-nonliteral -Werror -c -o
> dwarf2read.o -MT dwarf2read.o -MMD -MP -MF .deps/dwarf2read.Tpo
> dwarf2read.c -O3
>
> But on x86_64.  I can try building trunk GCC on s390x but do you
> really have the warnings unreproducible on x86_64?

I don't know why you don't see the warnings.  I had not tested with
upstream GCC on x86_64 before.  Now I have, and the same warnings appear
there.  Both on s390x and x86_64 it basically looks the same:

g++ -O3 -g -I. -I. -I./common -I./config
-DLOCALEDIR="\"/home/arnez/install/share/locale\"" -DHAVE_CONFIG_H
-I./../include/opcode -I./../opcodes/.. -I./../readline/.. -I./../zlib
-I../bfd -I./../bfd -I./../include -I../libdecnumber -I./../libdecnumber
-I./gnulib/import -Ibuild-gnulib/import -DTUI=1 -I/usr/include/python2.7
-I/usr/include/python2.7 -Wall -Wpointer-arith -Wno-unused
-Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts
-Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable
-Wno-sign-compare -Wno-write-strings -Wno-narrowing -Wformat-nonliteral
-c -o dwarf2read.o -MT dwarf2read.o -MMD -MP -MF .deps/dwarf2read.Tpo
dwarf2read.c

dwarf2read.c: In function ‘void create_debug_type_hash_table(dwo_file*,
dwarf2_section_info*, htab*&, rcuh_kind)’: dwarf2read.c:4766:30:
warning: ‘header.comp_unit_head::type_offset_in_tu.cu_offset::cu_off’
may be used uninitialized in this function [-Wmaybe-uninitialized]
    dwo_tu->type_offset_in_tu = header.type_offset_in_tu;
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
dwarf2read.c:4819:21: warning: ‘header.comp_unit_head::signature’ may be
used uninitialized in this function [-Wmaybe-uninitialized]
  fprintf_unfiltered (gdb_stdlog, "  offset 0x%x, signature %s\n",
  ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        offset.sect_off,
        ~~~~~~~~~~~~~~~~
        hex_string (header.signature));
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--
Andreas

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [patch] DWARF-5: Initialization due to a false compiler warning  [Re: [PATCH v2 4/8] DWARF-5 basic functionality]
  2017-02-23 16:59           ` Andreas Arnez
@ 2017-02-24 12:57             ` Jan Kratochvil
  2017-02-26 15:56               ` [commit] " Jan Kratochvil
  0 siblings, 1 reply; 24+ messages in thread
From: Jan Kratochvil @ 2017-02-24 12:57 UTC (permalink / raw)
  To: Andreas Arnez; +Cc: gdb-patches, Victor Leschuk

[-- Attachment #1: Type: text/plain, Size: 655 bytes --]

Hi,

I finally get the warnings:

dwarf2read.c: In function ‘void create_debug_type_hash_table(dwo_file*, dwarf2_section_info*, htab*&, rcuh_kind)’:
dwarf2read.c:4776:32: error: ‘header.comp_unit_head::type_offset_in_tu.cu_offset::cu_off’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
dwarf2read.c:4816:21: error: ‘header.comp_unit_head::signature’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
cc1plus: all warnings being treated as errors

Even with system gcc-6.3.1-1.fc25.x86_64.  I do not know why I had it
unreproducible before.

OK for check-in?


Jan

[-- Attachment #2: 1 --]
[-- Type: text/plain, Size: 706 bytes --]

gdb/ChangeLog
2017-02-24  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf2read.c (create_debug_type_hash_table): Initialize
	header.signature and header.type_offset_in_tu.

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index f119750..40b99d9 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -4728,6 +4728,10 @@ create_debug_type_hash_table (struct dwo_file *dwo_file,
 
       offset.sect_off = ptr - section->buffer;
 
+      /* Initialize it due to a false compiler warning.  */
+      header.signature = -1;
+      header.type_offset_in_tu.cu_off = -1;
+
       /* We need to read the type's signature in order to build the hash
 	 table, but we don't need anything else just yet.  */
 

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [commit] [patch] DWARF-5: Initialization due to a false compiler warning  [Re: [PATCH v2 4/8] DWARF-5 basic functionality]
  2017-02-24 12:57             ` [patch] DWARF-5: Initialization due to a false compiler warning [Re: [PATCH v2 4/8] DWARF-5 basic functionality] Jan Kratochvil
@ 2017-02-26 15:56               ` Jan Kratochvil
  0 siblings, 0 replies; 24+ messages in thread
From: Jan Kratochvil @ 2017-02-26 15:56 UTC (permalink / raw)
  To: Andreas Arnez; +Cc: gdb-patches, Victor Leschuk

On Fri, 24 Feb 2017 13:57:41 +0100, Jan Kratochvil wrote:
> gdb/ChangeLog
> 2017-02-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* dwarf2read.c (create_debug_type_hash_table): Initialize
> 	header.signature and header.type_offset_in_tu.

a49dd8dd482da6a8131752f8312a06aa6599063c


Jan

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2017-02-26 15:56 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-19 21:28 [PATCH v2 1/8] Code cleanup: Split create_debug_types_hash_table Jan Kratochvil
2017-02-19 21:28 ` [PATCH v2 7/8] DWARF-5: DW_FORM_data16 Jan Kratochvil
2017-02-20 20:09   ` [commit] " Jan Kratochvil
2017-02-19 21:28 ` [PATCH v2 6/8] DWARF-5: Macros Jan Kratochvil
2017-02-20 20:08   ` [commit] " Jan Kratochvil
2017-02-19 21:28 ` [PATCH v2 2/8] Code cleanup: Split dwarf2_ranges_read to a callback Jan Kratochvil
2017-02-20 20:06   ` [commit] " Jan Kratochvil
2017-02-19 21:28 ` [PATCH v2 5/8] DWARF-5: call sites Jan Kratochvil
2017-02-20  3:31   ` Eli Zaretskii
2017-02-20 20:08   ` [commit] " Jan Kratochvil
2017-02-19 21:28 ` [PATCH v2 8/8] DWARF-5: NEWS Jan Kratochvil
2017-02-20  3:31   ` Eli Zaretskii
2017-02-20 20:09   ` [commit] " Jan Kratochvil
2017-02-19 21:28 ` [PATCH v2 4/8] DWARF-5 basic functionality Jan Kratochvil
2017-02-21 19:18   ` Andreas Arnez
2017-02-22 14:29     ` Jan Kratochvil
2017-02-22 17:38       ` Andreas Arnez
2017-02-22 18:32         ` Jan Kratochvil
2017-02-23 16:59           ` Andreas Arnez
2017-02-24 12:57             ` [patch] DWARF-5: Initialization due to a false compiler warning [Re: [PATCH v2 4/8] DWARF-5 basic functionality] Jan Kratochvil
2017-02-26 15:56               ` [commit] " Jan Kratochvil
2017-02-19 21:28 ` [PATCH v2 3/8] Code cleanup: Refactor abbrev_table_read_table cycle Jan Kratochvil
2017-02-20 20:06   ` [commit] " Jan Kratochvil
2017-02-20 20:05 ` [commit] [PATCH v2 1/8] Code cleanup: Split create_debug_types_hash_table Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).