public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/8] Rename read_unsigned_leb128 to gdb_read_unsigned_leb128
@ 2017-02-12 20:23 Jan Kratochvil
  2017-02-12 20:23 ` [PATCH 7/8] DWARF-5: Macros Jan Kratochvil
                   ` (7 more replies)
  0 siblings, 8 replies; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-12 20:23 UTC (permalink / raw)
  To: gdb-patches; +Cc: Victor Leschuk

Hi,

read_unsigned_leb128 needs to be used outside of dwarf2read.c, removing its
static qualifier.  But then it would clash with bfd/libbfd.c
read_unsigned_leb128 global function of the same name.

Jan


gdb/ChangeLog
2017-01-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf2read.c (read_unsigned_leb128): Rename to ...
	(gdb_read_unsigned_leb128): ... here, update all cases.
---
 gdb/dwarf2read.c |  103 ++++++++++++++++++++++++++++--------------------------
 1 file changed, 54 insertions(+), 49 deletions(-)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 774ed73..bf381a7 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -1509,7 +1509,8 @@ static const char *read_indirect_string (bfd *, const gdb_byte *,
 
 static const char *read_indirect_string_from_dwz (struct dwz_file *, LONGEST);
 
-static ULONGEST read_unsigned_leb128 (bfd *, const gdb_byte *, unsigned int *);
+static ULONGEST gdb_read_unsigned_leb128 (bfd *, const gdb_byte *,
+					  unsigned int *);
 
 static LONGEST read_signed_leb128 (bfd *, const gdb_byte *, unsigned int *);
 
@@ -7195,7 +7196,7 @@ peek_abbrev_code (bfd *abfd, const gdb_byte *info_ptr)
 {
   unsigned int bytes_read;
 
-  return read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
+  return gdb_read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
 }
 
 /* Read the initial uleb128 in the die at INFO_PTR in compilation unit CU.
@@ -7211,7 +7212,7 @@ peek_die_abbrev (const gdb_byte *info_ptr, unsigned int *bytes_read,
   unsigned int abbrev_number;
   struct abbrev_info *abbrev;
 
-  abbrev_number = read_unsigned_leb128 (abfd, info_ptr, bytes_read);
+  abbrev_number = gdb_read_unsigned_leb128 (abfd, info_ptr, bytes_read);
 
   if (abbrev_number == 0)
     return NULL;
@@ -7341,7 +7342,7 @@ skip_one_die (const struct die_reader_specs *reader, const gdb_byte *info_ptr,
 	  break;
 	case DW_FORM_exprloc:
 	case DW_FORM_block:
-	  info_ptr += read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
+	  info_ptr += gdb_read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
 	  info_ptr += bytes_read;
 	  break;
 	case DW_FORM_block1:
@@ -7361,7 +7362,7 @@ skip_one_die (const struct die_reader_specs *reader, const gdb_byte *info_ptr,
 	  info_ptr = safe_skip_leb128 (info_ptr, buffer_end);
 	  break;
 	case DW_FORM_indirect:
-	  form = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
+	  form = gdb_read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
 	  info_ptr += bytes_read;
 	  /* We need to continue parsing from here, so just go back to
 	     the top.  */
@@ -15212,7 +15213,7 @@ read_full_die_1 (const struct die_reader_specs *reader,
   bfd *abfd = reader->abfd;
 
   offset.sect_off = info_ptr - reader->buffer;
-  abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
+  abbrev_number = gdb_read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
   info_ptr += bytes_read;
   if (!abbrev_number)
     {
@@ -15356,7 +15357,7 @@ abbrev_table_read_table (struct dwarf2_section_info *section,
 
   dwarf2_read_section (objfile, section);
   abbrev_ptr = section->buffer + offset.sect_off;
-  abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+  abbrev_number = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
   abbrev_ptr += bytes_read;
 
   allocated_attrs = ATTR_ALLOC_CHUNK;
@@ -15369,16 +15370,17 @@ abbrev_table_read_table (struct dwarf2_section_info *section,
 
       /* read in abbrev header */
       cur_abbrev->number = abbrev_number;
-      cur_abbrev->tag
-	= (enum dwarf_tag) read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+      cur_abbrev->tag = (enum dwarf_tag) gdb_read_unsigned_leb128 (abfd,
+								   abbrev_ptr,
+								   &bytes_read);
       abbrev_ptr += bytes_read;
       cur_abbrev->has_children = read_1_byte (abfd, abbrev_ptr);
       abbrev_ptr += 1;
 
       /* now read in declarations */
-      abbrev_name = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+      abbrev_name = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
       abbrev_ptr += bytes_read;
-      abbrev_form = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+      abbrev_form = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
       abbrev_ptr += bytes_read;
       while (abbrev_name)
 	{
@@ -15393,9 +15395,9 @@ 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;
-	  abbrev_name = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+	  abbrev_name = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
 	  abbrev_ptr += bytes_read;
-	  abbrev_form = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+	  abbrev_form = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
 	  abbrev_ptr += bytes_read;
 	}
 
@@ -15416,7 +15418,7 @@ abbrev_table_read_table (struct dwarf2_section_info *section,
          table is reached.  */
       if ((unsigned int) (abbrev_ptr - section->buffer) >= section->size)
 	break;
-      abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+      abbrev_number = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
       abbrev_ptr += bytes_read;
       if (abbrev_table_lookup_abbrev (abbrev_table, abbrev_number) != NULL)
 	break;
@@ -16321,7 +16323,7 @@ read_attribute_value (const struct die_reader_specs *reader,
     case DW_FORM_exprloc:
     case DW_FORM_block:
       blk = dwarf_alloc_block (cu);
-      blk->size = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
+      blk->size = gdb_read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
       info_ptr += bytes_read;
       blk->data = read_n_bytes (abfd, info_ptr, blk->size);
       info_ptr += blk->size;
@@ -16351,7 +16353,7 @@ read_attribute_value (const struct die_reader_specs *reader,
       info_ptr += bytes_read;
       break;
     case DW_FORM_udata:
-      DW_UNSND (attr) = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
+      DW_UNSND (attr) = gdb_read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
       info_ptr += bytes_read;
       break;
     case DW_FORM_ref1:
@@ -16380,11 +16382,12 @@ read_attribute_value (const struct die_reader_specs *reader,
       break;
     case DW_FORM_ref_udata:
       DW_UNSND (attr) = (cu->header.offset.sect_off
-			 + read_unsigned_leb128 (abfd, info_ptr, &bytes_read));
+			 + gdb_read_unsigned_leb128 (abfd, info_ptr,
+						     &bytes_read));
       info_ptr += bytes_read;
       break;
     case DW_FORM_indirect:
-      form = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
+      form = gdb_read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
       info_ptr += bytes_read;
       info_ptr = read_attribute_value (reader, attr, form, info_ptr);
       break;
@@ -16411,7 +16414,7 @@ read_attribute_value (const struct die_reader_specs *reader,
 	}
       {
 	ULONGEST str_index =
-	  read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
+	  gdb_read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
 
 	DW_STRING (attr) = read_str_index (reader, str_index);
 	DW_STRING_IS_CANONICAL (attr) = 0;
@@ -16761,8 +16764,8 @@ read_indirect_string (bfd *abfd, const gdb_byte *buf,
 }
 
 static ULONGEST
-read_unsigned_leb128 (bfd *abfd, const gdb_byte *buf,
-		      unsigned int *bytes_read_ptr)
+gdb_read_unsigned_leb128 (bfd *abfd, const gdb_byte *buf,
+			  unsigned int *bytes_read_ptr)
 {
   ULONGEST result;
   unsigned int num_read;
@@ -16859,7 +16862,8 @@ read_addr_index_from_leb128 (struct dwarf2_cu *cu, const gdb_byte *info_ptr,
 			     unsigned int *bytes_read)
 {
   bfd *abfd = cu->objfile->obfd;
-  unsigned int addr_index = read_unsigned_leb128 (abfd, info_ptr, bytes_read);
+  unsigned int addr_index = gdb_read_unsigned_leb128 (abfd, info_ptr,
+						      bytes_read);
 
   return read_addr_index (cu, addr_index);
 }
@@ -17428,11 +17432,11 @@ dwarf_decode_line_header (unsigned int offset, struct dwarf2_cu *cu)
       unsigned int dir_index, mod_time, length;
 
       line_ptr += bytes_read;
-      dir_index = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+      dir_index = gdb_read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
       line_ptr += bytes_read;
-      mod_time = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+      mod_time = gdb_read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
       line_ptr += bytes_read;
-      length = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+      length = gdb_read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
       line_ptr += bytes_read;
 
       add_file_name (lh, cur_file, dir_index, mod_time, length);
@@ -17893,7 +17897,7 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
 	  else switch (op_code)
 	    {
 	    case DW_LNS_extended_op:
-	      extended_len = read_unsigned_leb128 (abfd, line_ptr,
+	      extended_len = gdb_read_unsigned_leb128 (abfd, line_ptr,
 						   &bytes_read);
 	      line_ptr += bytes_read;
 	      extended_end = line_ptr + extended_len;
@@ -17928,13 +17932,13 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
 						   &bytes_read);
                     line_ptr += bytes_read;
                     dir_index =
-                      read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+                      gdb_read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
                     line_ptr += bytes_read;
                     mod_time =
-                      read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+                      gdb_read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
                     line_ptr += bytes_read;
                     length =
-                      read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+                      gdb_read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
                     line_ptr += bytes_read;
                     add_file_name (lh, cur_file, dir_index, mod_time, length);
                   }
@@ -17946,7 +17950,7 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
 		     (non-prologue) line we want to coalesce them.
 		     PR 17276.  */
 		  state_machine.discriminator
-		    = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+		    = gdb_read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
 		  state_machine.line_has_non_zero_discriminator
 		    |= state_machine.discriminator != 0;
 		  line_ptr += bytes_read;
@@ -17973,7 +17977,7 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
 	    case DW_LNS_advance_pc:
 	      {
 		CORE_ADDR adjust
-		  = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+		  = gdb_read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
 		CORE_ADDR addr_adj;
 
 		addr_adj = (((state_machine.op_index + adjust)
@@ -18006,7 +18010,7 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
 		struct file_entry *fe;
 		const char *dir = NULL;
 
-		state_machine.file = read_unsigned_leb128 (abfd, line_ptr,
+		state_machine.file = gdb_read_unsigned_leb128 (abfd, line_ptr,
 							   &bytes_read);
 		line_ptr += bytes_read;
 		if (state_machine.file == 0
@@ -18028,7 +18032,7 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
 	      }
 	      break;
 	    case DW_LNS_set_column:
-	      (void) read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+	      (void) gdb_read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
 	      line_ptr += bytes_read;
 	      break;
 	    case DW_LNS_negate_stmt:
@@ -18073,7 +18077,8 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
 
 		for (i = 0; i < lh->standard_opcode_lengths[op_code]; i++)
 		  {
-		    (void) read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+		    (void) gdb_read_unsigned_leb128 (abfd, line_ptr,
+						     &bytes_read);
 		    line_ptr += bytes_read;
 		  }
 	      }
@@ -20644,7 +20649,7 @@ decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu)
 	  break;
 
 	case DW_OP_regx:
-	  unsnd = read_unsigned_leb128 (NULL, (data + i), &bytes_read);
+	  unsnd = gdb_read_unsigned_leb128 (NULL, (data + i), &bytes_read);
 	  i += bytes_read;
 	  stack[++stacki] = unsnd;
 	  if (i < size)
@@ -20693,7 +20698,7 @@ decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu)
 	  break;
 
 	case DW_OP_constu:
-	  stack[++stacki] = read_unsigned_leb128 (NULL, (data + i),
+	  stack[++stacki] = gdb_read_unsigned_leb128 (NULL, (data + i),
 						  &bytes_read);
 	  i += bytes_read;
 	  break;
@@ -20714,7 +20719,7 @@ decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu)
 	  break;
 
 	case DW_OP_plus_uconst:
-	  stack[stacki] += read_unsigned_leb128 (NULL, (data + i),
+	  stack[stacki] += gdb_read_unsigned_leb128 (NULL, (data + i),
 						 &bytes_read);
 	  i += bytes_read;
 	  break;
@@ -21118,7 +21123,7 @@ skip_form_bytes (bfd *abfd, const gdb_byte *bytes, const gdb_byte *buffer_end,
       break;
 
     case DW_FORM_block:
-      bytes += read_unsigned_leb128 (abfd, bytes, &bytes_read);
+      bytes += gdb_read_unsigned_leb128 (abfd, bytes, &bytes_read);
       bytes += bytes_read;
       break;
 
@@ -21182,7 +21187,7 @@ skip_unknown_opcode (unsigned int opcode,
     }
 
   defn = opcode_definitions[opcode];
-  arg = read_unsigned_leb128 (abfd, defn, &bytes_read);
+  arg = gdb_read_unsigned_leb128 (abfd, defn, &bytes_read);
   defn += bytes_read;
 
   for (i = 0; i < arg; ++i)
@@ -21251,7 +21256,7 @@ dwarf_parse_macro_header (const gdb_byte **opcode_definitions,
 	      opcode = read_1_byte (abfd, mac_ptr);
 	      ++mac_ptr;
 	      opcode_definitions[opcode] = mac_ptr;
-	      arg = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
+	      arg = gdb_read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
 	      mac_ptr += bytes_read;
 	      mac_ptr += arg;
 	    }
@@ -21329,7 +21334,7 @@ dwarf_decode_macro_bytes (bfd *abfd,
             const char *body;
 	    int is_define;
 
-	    line = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
+	    line = gdb_read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
 	    mac_ptr += bytes_read;
 
 	    if (macinfo_type == DW_MACRO_GNU_define
@@ -21395,9 +21400,9 @@ dwarf_decode_macro_bytes (bfd *abfd,
             unsigned int bytes_read;
             int line, file;
 
-            line = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
+            line = gdb_read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
             mac_ptr += bytes_read;
-            file = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
+            file = gdb_read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
             mac_ptr += bytes_read;
 
 	    if ((line == 0 && !at_commandline)
@@ -21516,7 +21521,7 @@ dwarf_decode_macro_bytes (bfd *abfd,
 
 	      /* This reads the constant, but since we don't recognize
 		 any vendor extensions, we ignore it.  */
-	      read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
+	      gdb_read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
 	      mac_ptr += bytes_read;
 	      read_direct_string (abfd, mac_ptr, &bytes_read);
 	      mac_ptr += bytes_read;
@@ -21640,7 +21645,7 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
 	  {
 	    unsigned int bytes_read;
 
-	    read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
+	    gdb_read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
 	    mac_ptr += bytes_read;
 	    read_direct_string (abfd, mac_ptr, &bytes_read);
 	    mac_ptr += bytes_read;
@@ -21652,9 +21657,9 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
 	    unsigned int bytes_read;
 	    int line, file;
 
-	    line = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
+	    line = gdb_read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
 	    mac_ptr += bytes_read;
-	    file = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
+	    file = gdb_read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
 	    mac_ptr += bytes_read;
 
 	    current_file = macro_start_file (file, line, current_file, lh);
@@ -21672,7 +21677,7 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
 	  {
 	    unsigned int bytes_read;
 
-	    read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
+	    gdb_read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
 	    mac_ptr += bytes_read;
 	    mac_ptr += offset_size;
 	  }
@@ -21692,7 +21697,7 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
 	    {
 	      unsigned int bytes_read;
 
-	      read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
+	      gdb_read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
 	      mac_ptr += bytes_read;
 	      read_direct_string (abfd, mac_ptr, &bytes_read);
 	      mac_ptr += bytes_read;

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

* [PATCH 2/8] Code cleanup: Split create_debug_types_hash_table
  2017-02-12 20:23 [PATCH 1/8] Rename read_unsigned_leb128 to gdb_read_unsigned_leb128 Jan Kratochvil
                   ` (3 preceding siblings ...)
  2017-02-12 20:23 ` [PATCH 3/8] Code cleanup: Split dwarf2_ranges_read to a callback Jan Kratochvil
@ 2017-02-12 20:23 ` Jan Kratochvil
  2017-02-16 19:33   ` Pedro Alves
  2017-02-12 20:23 ` [PATCH 8/8] DWARF-5: DW_FORM_data16 Jan Kratochvil
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-12 20:23 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 bf381a7..7c74718 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -4606,27 +4606,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
@@ -4637,136 +4627,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,
@@ -4777,10 +4783,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;
@@ -10616,8 +10622,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] 32+ messages in thread

* [PATCH 4/8] Code cleanup: Refactor abbrev_table_read_table cycle
  2017-02-12 20:23 [PATCH 1/8] Rename read_unsigned_leb128 to gdb_read_unsigned_leb128 Jan Kratochvil
  2017-02-12 20:23 ` [PATCH 7/8] DWARF-5: Macros Jan Kratochvil
@ 2017-02-12 20:23 ` Jan Kratochvil
  2017-02-17  1:21   ` Pedro Alves
  2017-02-12 20:23 ` [PATCH 6/8] DWARF-5: call sites Jan Kratochvil
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-12 20:23 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 1137541..e9c1b6a 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -15341,12 +15341,16 @@ abbrev_table_read_table (struct dwarf2_section_info *section,
       abbrev_ptr += 1;
 
       /* now read in declarations */
-      abbrev_name = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
-      abbrev_ptr += bytes_read;
-      abbrev_form = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
-      abbrev_ptr += bytes_read;
-      while (abbrev_name)
+      for (;;)
 	{
+	  abbrev_name = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+	  abbrev_ptr += bytes_read;
+	  abbrev_form = gdb_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;
@@ -15356,12 +15360,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 = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
-	  abbrev_ptr += bytes_read;
-	  abbrev_form = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
-	  abbrev_ptr += bytes_read;
+	  ++cur_abbrev->num_attrs;
 	}
 
       cur_abbrev->attrs =

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

* [PATCH 6/8] DWARF-5: call sites
  2017-02-12 20:23 [PATCH 1/8] Rename read_unsigned_leb128 to gdb_read_unsigned_leb128 Jan Kratochvil
  2017-02-12 20:23 ` [PATCH 7/8] DWARF-5: Macros Jan Kratochvil
  2017-02-12 20:23 ` [PATCH 4/8] Code cleanup: Refactor abbrev_table_read_table cycle Jan Kratochvil
@ 2017-02-12 20:23 ` Jan Kratochvil
  2017-02-12 20:41   ` Eli Zaretskii
  2017-02-17 11:57   ` Pedro Alves
  2017-02-12 20:23 ` [PATCH 3/8] Code cleanup: Split dwarf2_ranges_read to a callback Jan Kratochvil
                   ` (4 subsequent siblings)
  7 siblings, 2 replies; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-12 20:23 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.exp <COMPILE>: Use -gdwarf-5.
	* 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/testsuite/gdb.arch/amd64-entry-value-param.exp |    2 
 gdb/testsuite/gdb.arch/amd64-entry-value.exp       |    6 +
 13 files changed, 139 insertions(+), 101 deletions(-)

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 35804c1..f769d81 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 39a067d..2c9051d 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -589,9 +589,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;
   }
 
@@ -641,7 +641,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);
@@ -733,7 +733,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.  */
 
@@ -758,8 +758,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)));
@@ -771,7 +770,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),
@@ -784,8 +783,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
@@ -835,7 +833,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));
 
@@ -893,7 +891,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 ? "???"
@@ -1235,7 +1233,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),
@@ -1249,7 +1247,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 ? "???"
@@ -1266,7 +1264,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)),
@@ -1290,10 +1288,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)); 
     }
@@ -1303,8 +1301,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.
@@ -1328,9 +1326,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);
@@ -1381,7 +1379,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 =
 {
@@ -1396,7 +1394,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.  */
@@ -1420,7 +1418,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.  */
@@ -1448,7 +1446,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.  */
@@ -1472,7 +1470,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(*)"));
 }
 
@@ -2227,7 +2225,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;
@@ -2806,7 +2804,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,
@@ -4163,6 +4161,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,
@@ -4177,6 +4176,7 @@ disassemble_dwarf_expression (struct ui_file *stream,
 	  }
 	  break;
 
+	case DW_OP_deref_type:
 	case DW_OP_GNU_deref_type:
 	  {
 	    int addr_size = *data++;
@@ -4193,6 +4193,7 @@ disassemble_dwarf_expression (struct ui_file *stream,
 	  }
 	  break;
 
+	case DW_OP_const_type:
 	case DW_OP_GNU_const_type:
 	  {
 	    cu_offset type_die;
@@ -4207,6 +4208,7 @@ disassemble_dwarf_expression (struct ui_file *stream,
 	  }
 	  break;
 
+	case DW_OP_regval_type:
 	case DW_OP_GNU_regval_type:
 	  {
 	    uint64_t reg;
@@ -4226,7 +4228,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;
@@ -4248,6 +4252,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 aec0fa7..1b671e4 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.exp b/gdb/testsuite/gdb.arch/amd64-entry-value-param.exp
index c0072ac..aa14856 100644
--- a/gdb/testsuite/gdb.arch/amd64-entry-value-param.exp
+++ b/gdb/testsuite/gdb.arch/amd64-entry-value-param.exp
@@ -19,7 +19,7 @@ set opts {}
 if [info exists COMPILE] {
     # make check RUNTESTFLAGS="gdb.arch/amd64-entry-value-param.exp COMPILE=1"
     set srcfile ${srcfile2}
-    lappend opts debug optimize=-O2
+    lappend opts optimize=-O2 additional_flags=-gdwarf-5
 } elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
     verbose "Skipping amd64-entry-value-param."
     return
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] 32+ messages in thread

* [PATCH 8/8] DWARF-5: DW_FORM_data16
  2017-02-12 20:23 [PATCH 1/8] Rename read_unsigned_leb128 to gdb_read_unsigned_leb128 Jan Kratochvil
                   ` (4 preceding siblings ...)
  2017-02-12 20:23 ` [PATCH 2/8] Code cleanup: Split create_debug_types_hash_table Jan Kratochvil
@ 2017-02-12 20:23 ` Jan Kratochvil
  2017-02-17 12:09   ` Pedro Alves
  2017-02-17 12:24   ` Pedro Alves
  2017-02-12 20:23 ` [PATCH 5/8] DWARF-5 basic functionality Jan Kratochvil
  2017-02-16 15:23 ` [PATCH 1/8] Rename read_unsigned_leb128 to gdb_read_unsigned_leb128 Pedro Alves
  7 siblings, 2 replies; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-12 20:23 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                        |   26 ++++++++++
 gdb/testsuite/gdb.dwarf2/formdata16.c   |   22 +++++++++
 gdb/testsuite/gdb.dwarf2/formdata16.exp |   77 +++++++++++++++++++++++++++++++
 gdb/testsuite/lib/dwarf.exp             |    4 ++
 4 files changed, 128 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 420cbe0..e8a8588 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;
@@ -16550,6 +16553,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,10 @@ 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:
+	  /* FIXME: Print the contents.  */
+	  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 +20426,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 +20710,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 +21619,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 +22286,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..2152cba
--- /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 ${testfile}.exp ${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 ${testfile}.exp ${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] 32+ messages in thread

* [PATCH 3/8] Code cleanup: Split dwarf2_ranges_read to a callback
  2017-02-12 20:23 [PATCH 1/8] Rename read_unsigned_leb128 to gdb_read_unsigned_leb128 Jan Kratochvil
                   ` (2 preceding siblings ...)
  2017-02-12 20:23 ` [PATCH 6/8] DWARF-5: call sites Jan Kratochvil
@ 2017-02-12 20:23 ` Jan Kratochvil
  2017-02-17  1:19   ` Pedro Alves
  2017-02-12 20:23 ` [PATCH 2/8] Code cleanup: Split create_debug_types_hash_table Jan Kratochvil
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-12 20:23 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 7c74718..1137541 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -11874,14 +11874,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);
@@ -11894,9 +11893,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;
@@ -11912,8 +11908,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)
@@ -11978,6 +11972,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;
@@ -12008,7 +12029,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
@@ -12260,79 +12283,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] 32+ messages in thread

* [PATCH 5/8] DWARF-5 basic functionality
  2017-02-12 20:23 [PATCH 1/8] Rename read_unsigned_leb128 to gdb_read_unsigned_leb128 Jan Kratochvil
                   ` (5 preceding siblings ...)
  2017-02-12 20:23 ` [PATCH 8/8] DWARF-5: DW_FORM_data16 Jan Kratochvil
@ 2017-02-12 20:23 ` Jan Kratochvil
  2017-02-17 11:41   ` Pedro Alves
  2017-02-16 15:23 ` [PATCH 1/8] Rename read_unsigned_leb128 to gdb_read_unsigned_leb128 Pedro Alves
  7 siblings, 1 reply; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-12 20:23 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 (gdb_read_unsigned_leb128): New declaration.
	* dwarf2loc.c: Include libbfd.h.
	(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.
	(gdb_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.
	(gdb_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                        |   82 +++
 gdb/dwarf2loc.h                        |    2 
 gdb/dwarf2read.c                       |  770 +++++++++++++++++++++++++++-----
 gdb/symfile.h                          |    3 
 gdb/testsuite/gdb.dwarf2/dw2-error.exp |    2 
 gdb/xcoffread.c                        |    3 
 7 files changed, 728 insertions(+), 138 deletions(-)

diff --git a/gdb/defs.h b/gdb/defs.h
index ff1df91..54f172a 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 gdb_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..39a067d 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -39,6 +39,7 @@
 #include "dwarf2-frame.h"
 #include "compile/compile.h"
 #include "selftest.h"
+#include "libbfd.h"
 #include <algorithm>
 #include <vector>
 #include <unordered_set>
@@ -143,6 +144,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 +215,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 +226,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 +237,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 +289,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 +335,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 = gdb_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 e9c1b6a..aec0fa7 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,10 +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 gdb_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 *);
 
@@ -1866,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,
@@ -2225,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;
@@ -2240,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;
@@ -2260,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;
@@ -4334,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;
@@ -4350,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;
 }
 
@@ -4391,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
@@ -4422,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;
 
@@ -4488,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;
 }
@@ -4607,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;
@@ -4623,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);
@@ -4645,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;
@@ -4659,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;
@@ -4687,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;
@@ -4700,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;
@@ -4736,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;
     }
@@ -4772,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,
@@ -4786,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)
     {
@@ -5166,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));
 	}
@@ -5189,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.  */
@@ -5200,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.  */
@@ -5519,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
@@ -5542,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;
 	}
     }
 
@@ -5712,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);
 
@@ -7323,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:
@@ -11874,7 +11951,178 @@ 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.
+   Return 1 if the attributes are present and valid, otherwise, return 0.  */
+
+static int
+dwarf2_rnglists_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);
+  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
+		       + gdb_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 = gdb_read_unsigned_leb128 (obfd, buffer, &bytes_read);
+	  buffer += bytes_read;
+	  if (buffer > buf_end)
+	    {
+	      overflow = true;
+	      break;
+	    }
+	  range_end = gdb_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.
    Return 1 if the attributes are present and valid, otherwise, return 0.  */
 
 static int
@@ -11895,6 +12143,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;
 
@@ -15343,10 +15594,23 @@ abbrev_table_read_table (struct dwarf2_section_info *section,
       /* now read in declarations */
       for (;;)
 	{
+	  LONGEST implicit_const;
+
 	  abbrev_name = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
 	  abbrev_ptr += bytes_read;
 	  abbrev_form = gdb_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;
@@ -15362,6 +15626,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;
 	}
 
@@ -16196,7 +16461,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;
@@ -16273,6 +16538,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 ();
@@ -16353,7 +16628,16 @@ read_attribute_value (const struct die_reader_specs *reader,
     case DW_FORM_indirect:
       form = gdb_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)
@@ -16423,7 +16707,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.  */
@@ -16676,21 +16961,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
@@ -16717,6 +17028,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,
@@ -16727,7 +17042,21 @@ 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
 gdb_read_unsigned_leb128 (bfd *abfd, const gdb_byte *buf,
 			  unsigned int *bytes_read_ptr)
 {
@@ -17090,8 +17419,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,
@@ -17268,6 +17597,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++)
+    {
+      gdb_read_unsigned_leb128 (abfd, buf, &bytes_read);
+      buf += bytes_read;
+      gdb_read_unsigned_leb128 (abfd, buf, &bytes_read);
+      buf += bytes_read;
+    }
+
+  data_count = gdb_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 = gdb_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 = gdb_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 = gdb_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.
@@ -17337,7 +17801,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.  */
@@ -17345,6 +17809,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);
@@ -17382,30 +17865,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 = gdb_read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
-      line_ptr += bytes_read;
-      mod_time = gdb_read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
-      line_ptr += bytes_read;
-      length = gdb_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 = gdb_read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+	  line_ptr += bytes_read;
+	  mod_time = gdb_read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+	  line_ptr += bytes_read;
+	  length = gdb_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))
@@ -19759,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)",
@@ -21786,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.  */
@@ -21905,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;
 }
@@ -21965,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] 32+ messages in thread

* [PATCH 7/8] DWARF-5: Macros
  2017-02-12 20:23 [PATCH 1/8] Rename read_unsigned_leb128 to gdb_read_unsigned_leb128 Jan Kratochvil
@ 2017-02-12 20:23 ` Jan Kratochvil
  2017-02-17 11:59   ` Pedro Alves
  2017-02-12 20:23 ` [PATCH 4/8] Code cleanup: Refactor abbrev_table_read_table cycle Jan Kratochvil
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-12 20:23 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 1b671e4..420cbe0 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 = gdb_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] 32+ messages in thread

* Re: [PATCH 6/8] DWARF-5: call sites
  2017-02-12 20:23 ` [PATCH 6/8] DWARF-5: call sites Jan Kratochvil
@ 2017-02-12 20:41   ` Eli Zaretskii
  2017-02-17 11:57   ` Pedro Alves
  1 sibling, 0 replies; 32+ messages in thread
From: Eli Zaretskii @ 2017-02-12 20:41 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, 12 Feb 2017 21:23:29 +0100
> 
> 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.exp <COMPILE>: Use -gdwarf-5.
> 	* gdb.arch/amd64-entry-value.exp: Rename DW_OP_GNU_*, DW_TAG_GNU_* and
> 	DW_AT_GNU_*.

OK for the documentation part.

Thanks.

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

* Re: [PATCH 1/8] Rename read_unsigned_leb128 to gdb_read_unsigned_leb128
  2017-02-12 20:23 [PATCH 1/8] Rename read_unsigned_leb128 to gdb_read_unsigned_leb128 Jan Kratochvil
                   ` (6 preceding siblings ...)
  2017-02-12 20:23 ` [PATCH 5/8] DWARF-5 basic functionality Jan Kratochvil
@ 2017-02-16 15:23 ` Pedro Alves
  2017-02-16 19:40   ` Jan Kratochvil
  7 siblings, 1 reply; 32+ messages in thread
From: Pedro Alves @ 2017-02-16 15:23 UTC (permalink / raw)
  To: Jan Kratochvil, gdb-patches; +Cc: Victor Leschuk

On 02/12/2017 08:22 PM, Jan Kratochvil wrote:
> Hi,
> 
> read_unsigned_leb128 needs to be used outside of dwarf2read.c, removing its
> static qualifier.  But then it would clash with bfd/libbfd.c
> read_unsigned_leb128 global function of the same name.

Can't we just use bfd's version?  How is gdb's version different?

Thanks,
Pedro Alves

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

* Re: [PATCH 2/8] Code cleanup: Split create_debug_types_hash_table
  2017-02-12 20:23 ` [PATCH 2/8] Code cleanup: Split create_debug_types_hash_table Jan Kratochvil
@ 2017-02-16 19:33   ` Pedro Alves
  0 siblings, 0 replies; 32+ messages in thread
From: Pedro Alves @ 2017-02-16 19:33 UTC (permalink / raw)
  To: Jan Kratochvil, gdb-patches; +Cc: Victor Leschuk

On 02/12/2017 08:23 PM, 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.

OK.

Thanks,
Pedro Alves

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

* Re: [PATCH 1/8] Rename read_unsigned_leb128 to gdb_read_unsigned_leb128
  2017-02-16 15:23 ` [PATCH 1/8] Rename read_unsigned_leb128 to gdb_read_unsigned_leb128 Pedro Alves
@ 2017-02-16 19:40   ` Jan Kratochvil
  2017-02-16 20:01     ` Pedro Alves
  0 siblings, 1 reply; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-16 19:40 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Victor Leschuk

On Thu, 16 Feb 2017 16:23:51 +0100, Pedro Alves wrote:
> Can't we just use bfd's version?

bfd's version is in libbfd.c:
/* Assorted BFD support routines, only used internally.
and libbfd.h:
/* libbfd.h -- Declarations used by bfd library *implementation*.
   (This include file is not for users of the library.)

And I think GDB is a user of libbfd library.

(One could argue libbfd should use visibility and/or C++ namespaces but for
historical reasons libbfd does not use either.)

I do not mind any solution, I have just complied with the libbfd policy.


Jan

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

* Re: [PATCH 1/8] Rename read_unsigned_leb128 to gdb_read_unsigned_leb128
  2017-02-16 19:40   ` Jan Kratochvil
@ 2017-02-16 20:01     ` Pedro Alves
  2017-02-16 22:54       ` Pedro Alves
  0 siblings, 1 reply; 32+ messages in thread
From: Pedro Alves @ 2017-02-16 20:01 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches, Victor Leschuk

On 02/16/2017 07:40 PM, Jan Kratochvil wrote:
> On Thu, 16 Feb 2017 16:23:51 +0100, Pedro Alves wrote:
>> Can't we just use bfd's version?
> 
> bfd's version is in libbfd.c:
> /* Assorted BFD support routines, only used internally.
> and libbfd.h:
> /* libbfd.h -- Declarations used by bfd library *implementation*.
>    (This include file is not for users of the library.)
> 
> And I think GDB is a user of libbfd library.
> 
> (One could argue libbfd should use visibility and/or C++ namespaces but for
> historical reasons libbfd does not use either.)
> 
> I do not mind any solution, I have just complied with the libbfd policy.
> 

Bah, there are copies of leb128 reading code all over the toolchain.
binutils/ has read_leb128, gold/ has read_unsigned_LEB_128, gcc
has a copy or two as well.  And then the bfd version (and gdb's
version, which seems to have been copied from bfd's) needs a bfd
pointer, but it's not really necessary.  Cleaning this all
up quickly falls out of scope, so...

Patch is OK.

-- 
Pedro Alves

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

* Re: [PATCH 1/8] Rename read_unsigned_leb128 to gdb_read_unsigned_leb128
  2017-02-16 20:01     ` Pedro Alves
@ 2017-02-16 22:54       ` Pedro Alves
  2017-02-17  1:28         ` Pedro Alves
  2017-02-19 21:25         ` Jan Kratochvil
  0 siblings, 2 replies; 32+ messages in thread
From: Pedro Alves @ 2017-02-16 22:54 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches, Victor Leschuk

On 02/16/2017 08:00 PM, Pedro Alves wrote:
> On 02/16/2017 07:40 PM, Jan Kratochvil wrote:
>> On Thu, 16 Feb 2017 16:23:51 +0100, Pedro Alves wrote:
>>> Can't we just use bfd's version?
>>
>> bfd's version is in libbfd.c:
>> /* Assorted BFD support routines, only used internally.
>> and libbfd.h:
>> /* libbfd.h -- Declarations used by bfd library *implementation*.
>>    (This include file is not for users of the library.)
>>
>> And I think GDB is a user of libbfd library.
>>
>> (One could argue libbfd should use visibility and/or C++ namespaces but for
>> historical reasons libbfd does not use either.)
>>
>> I do not mind any solution, I have just complied with the libbfd policy.
>>
> 
> Bah, there are copies of leb128 reading code all over the toolchain.
> binutils/ has read_leb128, gold/ has read_unsigned_LEB_128, gcc
> has a copy or two as well.  And then the bfd version (and gdb's
> version, which seems to have been copied from bfd's) needs a bfd
> pointer, but it's not really necessary.  Cleaning this all
> up quickly falls out of scope, so...
> 
> Patch is OK.

Actually, I think visibility wouldn't work given bfd is linked
statically.  And C++ namespaces are out of question obviously
given bfd is written in C.  That leaves avoiding namespace
collision by renaming something, but I think that given
that it's bfd that is a library, that it should be bfd
that should have its internal-with-external-linkage symbols
renamed, giving them a "_bfd_" prefix, as other internal
symbols have.  I quickly hacked up a mini-series to rename these
plus a few others I noticed by playing with nm + grep.  I'll
post it to binutils@ in a bit.

Thanks,
Pedro Alves

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

* Re: [PATCH 3/8] Code cleanup: Split dwarf2_ranges_read to a callback
  2017-02-12 20:23 ` [PATCH 3/8] Code cleanup: Split dwarf2_ranges_read to a callback Jan Kratochvil
@ 2017-02-17  1:19   ` Pedro Alves
  2017-02-19 21:26     ` Jan Kratochvil
  0 siblings, 1 reply; 32+ messages in thread
From: Pedro Alves @ 2017-02-17  1:19 UTC (permalink / raw)
  To: Jan Kratochvil, gdb-patches; +Cc: Victor Leschuk

On 02/12/2017 08:23 PM, Jan Kratochvil wrote:

> -/* 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)

std::function is a lot of unnecessary overhead here.  Unless you
manage to trigger to small-function optimization (which you won't here,
the callbacks are too big), this is forcing a heap allocation inside
std::function for every call to dwarf2_ranges_process.

Let's only use std::function for it's intended use-case of when the
design calls for taking, or more usually, storing, a callable whose
type is not knowable at compile type.  In this case, the type is
determinable at compile type, as everything is local to the same file
and the callees are always known.

So make dwarf2_ranges_process a template, and the overhead disappears,
like:

~~~~~~~~~~~~~~~~~~
diff --git c/gdb/dwarf2read.c w/gdb/dwarf2read.c
index 1137541..94d5de2 100644
--- c/gdb/dwarf2read.c
+++ w/gdb/dwarf2read.c
@@ -11877,10 +11877,13 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
 /* Call CALLBACK from DW_AT_ranges attribute value OFFSET.
    Return 1 if the attributes are present and valid, otherwise, return 0.  */
 
+/* Callback's type should be:
+    void (CORE_ADDR range_beginning, CORE_ADDR range_end)
+*/
+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)
 {
~~~~~~~~~~~~~~~~~~

OK with that change.

Thanks,
Pedro Alves

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

* Re: [PATCH 4/8] Code cleanup: Refactor abbrev_table_read_table cycle
  2017-02-12 20:23 ` [PATCH 4/8] Code cleanup: Refactor abbrev_table_read_table cycle Jan Kratochvil
@ 2017-02-17  1:21   ` Pedro Alves
  0 siblings, 0 replies; 32+ messages in thread
From: Pedro Alves @ 2017-02-17  1:21 UTC (permalink / raw)
  To: Jan Kratochvil, gdb-patches; +Cc: Victor Leschuk

On 02/12/2017 08:23 PM, 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.

OK.

Thanks,
Pedro Alves

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

* Re: [PATCH 1/8] Rename read_unsigned_leb128 to gdb_read_unsigned_leb128
  2017-02-16 22:54       ` Pedro Alves
@ 2017-02-17  1:28         ` Pedro Alves
  2017-02-19 21:25         ` Jan Kratochvil
  1 sibling, 0 replies; 32+ messages in thread
From: Pedro Alves @ 2017-02-17  1:28 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches, Victor Leschuk

On 02/16/2017 10:54 PM, Pedro Alves wrote:

> Actually, I think visibility wouldn't work given bfd is linked
> statically.  And C++ namespaces are out of question obviously
> given bfd is written in C.  That leaves avoiding namespace
> collision by renaming something, but I think that given
> that it's bfd that is a library, that it should be bfd
> that should have its internal-with-external-linkage symbols
> renamed, giving them a "_bfd_" prefix, as other internal
> symbols have.  I quickly hacked up a mini-series to rename these
> plus a few others I noticed by playing with nm + grep.  I'll
> post it to binutils@ in a bit.

FYI, this is now done, and merged to master:
  https://sourceware.org/ml/binutils/2017-02/msg00165.html

Thanks,
Pedro Alves

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

* Re: [PATCH 5/8] DWARF-5 basic functionality
  2017-02-12 20:23 ` [PATCH 5/8] DWARF-5 basic functionality Jan Kratochvil
@ 2017-02-17 11:41   ` Pedro Alves
  2017-02-19 21:26     ` Jan Kratochvil
  0 siblings, 1 reply; 32+ messages in thread
From: Pedro Alves @ 2017-02-17 11:41 UTC (permalink / raw)
  To: Jan Kratochvil, gdb-patches; +Cc: Victor Leschuk

LGTM with a couple minor nits below.

On 02/12/2017 08:23 PM, Jan Kratochvil wrote:

> --- 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 gdb_read_unsigned_leb128 (bfd *, const gdb_byte *, unsigned int *);

Not needed anymore.

> +
>  /* 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..39a067d 100644
> --- a/gdb/dwarf2loc.c
> +++ b/gdb/dwarf2loc.c
> @@ -39,6 +39,7 @@
>  #include "dwarf2-frame.h"
>  #include "compile/compile.h"
>  #include "selftest.h"
> +#include "libbfd.h"

We've determined this is an internal bfd header.
Do we need this?

>  #include <algorithm>
>  #include <vector>
>  #include <unordered_set>
> @@ -143,6 +144,57 @@ decode_debug_loc_addresses (const gdb_byte *loc_ptr, const gdb_byte *buf_end,
>    return DEBUG_LOC_START_END;
>  }
>  


>  
> +/* Expected enum dwarf_unit_type for read_comp_unit_head.  */
> +enum class RCUH_Kind { COMPILE, TYPE };

RCUH_Kind -> rcuh_kind.  We only use uppercase type names
in template type parameter names.

> -/* Call CALLBACK from DW_AT_ranges attribute value OFFSET.
> +/* Call CALLBACK from DW_AT_ranges attribute value OFFSET
> +   reading .debug_rnglists.
> +   Return 1 if the attributes are present and valid, otherwise, return 0.  */
> +
> +static int

bool/true/false?

> +dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu,
> +			 std::function<void (CORE_ADDR range_beginning,
> +					     CORE_ADDR range_end)> callback)

Same comment about std::function.  (and I had forgotten to suggest
that callback should probably be a universal reference / "&&callback").

Thanks,
Pedro Alves

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

* Re: [PATCH 6/8] DWARF-5: call sites
  2017-02-12 20:23 ` [PATCH 6/8] DWARF-5: call sites Jan Kratochvil
  2017-02-12 20:41   ` Eli Zaretskii
@ 2017-02-17 11:57   ` Pedro Alves
  2017-02-19 21:26     ` Jan Kratochvil
  1 sibling, 1 reply; 32+ messages in thread
From: Pedro Alves @ 2017-02-17 11:57 UTC (permalink / raw)
  To: Jan Kratochvil, gdb-patches; +Cc: Victor Leschuk

On 02/12/2017 08:23 PM, Jan Kratochvil wrote:

>  /* OP_LAST is followed by an integer in the next exp_element.
> diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value-param.exp b/gdb/testsuite/gdb.arch/amd64-entry-value-param.exp
> index c0072ac..aa14856 100644
> --- a/gdb/testsuite/gdb.arch/amd64-entry-value-param.exp
> +++ b/gdb/testsuite/gdb.arch/amd64-entry-value-param.exp
> @@ -19,7 +19,7 @@ set opts {}
>  if [info exists COMPILE] {
>      # make check RUNTESTFLAGS="gdb.arch/amd64-entry-value-param.exp COMPILE=1"
>      set srcfile ${srcfile2}
> -    lappend opts debug optimize=-O2
> +    lappend opts optimize=-O2 additional_flags=-gdwarf-5

Did you mean to update the .S file?

I wonder whether it makes sense to run the test twice, once against
the current .S file using the GNU version of the opcodes, and
another against standard DWARF5 opcodes.  That raises the question
of why we don't do that with the c based tests, where we'll handle
whatever format the compiler outputs.  So maybe not go there...

>  } elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
>      verbose "Skipping amd64-entry-value-param."
>      return

Otherwise LGTM.

Thanks,
Pedro Alves

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

* Re: [PATCH 7/8] DWARF-5: Macros
  2017-02-12 20:23 ` [PATCH 7/8] DWARF-5: Macros Jan Kratochvil
@ 2017-02-17 11:59   ` Pedro Alves
  0 siblings, 0 replies; 32+ messages in thread
From: Pedro Alves @ 2017-02-17 11:59 UTC (permalink / raw)
  To: Jan Kratochvil, gdb-patches; +Cc: Victor Leschuk

On 02/12/2017 08:23 PM, Jan Kratochvil wrote:
> Hi,
> 
> DWARF-5 renamed DW_MACRO_GNU_* to DW_MACRO_*.

OK.

Thanks,
Pedro Alves

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

* Re: [PATCH 8/8] DWARF-5: DW_FORM_data16
  2017-02-12 20:23 ` [PATCH 8/8] DWARF-5: DW_FORM_data16 Jan Kratochvil
@ 2017-02-17 12:09   ` Pedro Alves
  2017-02-19 21:26     ` Jan Kratochvil
  2017-02-17 12:24   ` Pedro Alves
  1 sibling, 1 reply; 32+ messages in thread
From: Pedro Alves @ 2017-02-17 12:09 UTC (permalink / raw)
  To: Jan Kratochvil, gdb-patches; +Cc: Victor Leschuk

On 02/12/2017 08:23 PM, Jan Kratochvil wrote:

> @@ -20250,6 +20261,10 @@ 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:
> +	  /* FIXME: Print the contents.  */
> +	  fprintf_unfiltered (f, "constant of 16 bytes");

Should we fix that FIXME?

> +	  break;
>  	case DW_FORM_ref_addr:
>  	  fprintf_unfiltered (f, "ref address: ");
>  	  fputs_filtered (hex_string (DW_UNSND (&die->attrs[i])), f);
> @@ -20411,6 +20426,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.  */

Spurious space after "For".

>        complaint (&symfile_complaints,
>  		 _("Attribute value is not a constant (%s)"),
>                   dwarf_form_name (attr->form));
> @@ -20694,6 +20710,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;

> +# We need to know the endianess in order
> +# to write some of the debugging info we'd like to generate.
> +if [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] {

"failed to prepare for endianness test" instead of "${testfile}.exp".

> +    return -1
> +}
> +

> +if { [prepare_for_testing ${testfile}.exp ${testfile} \

"failed to prepare" instead of "${testfile}.exp".


> +			  [list $srcfile $asm_file] {nodebug}] } {
> +    return -1
> +}
> +
> +gdb_test "p/x xxx" " = 0x123456789abcdef00fedcba987654321"

Thanks,
Pedro Alves

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

* Re: [PATCH 8/8] DWARF-5: DW_FORM_data16
  2017-02-12 20:23 ` [PATCH 8/8] DWARF-5: DW_FORM_data16 Jan Kratochvil
  2017-02-17 12:09   ` Pedro Alves
@ 2017-02-17 12:24   ` Pedro Alves
  1 sibling, 0 replies; 32+ messages in thread
From: Pedro Alves @ 2017-02-17 12:24 UTC (permalink / raw)
  To: Jan Kratochvil, gdb-patches; +Cc: Victor Leschuk

BTW, with this series in, I think it'd be nice to have a
NEWS entry mentioning that GDB now supports DWARF5.

Thanks,
Pedro Alves

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

* Re: [PATCH 1/8] Rename read_unsigned_leb128 to gdb_read_unsigned_leb128
  2017-02-16 22:54       ` Pedro Alves
  2017-02-17  1:28         ` Pedro Alves
@ 2017-02-19 21:25         ` Jan Kratochvil
  1 sibling, 0 replies; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-19 21:25 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Victor Leschuk

On Thu, 16 Feb 2017 23:54:15 +0100, Pedro Alves wrote:
> Actually, I think visibility wouldn't work given bfd is linked statically.

Yes, that is a binutils-gdb project management bug.  That way all the library
bugs have to be backported by distros twice (to binutils and gdb).


> And C++ namespaces are out of question obviously given bfd is written in C.

Another bug. :-)


> I quickly hacked up a mini-series to rename these
> plus a few others I noticed by playing with nm + grep.

OK, thanks, dropped this patch.


Jan

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

* Re: [PATCH 3/8] Code cleanup: Split dwarf2_ranges_read to a callback
  2017-02-17  1:19   ` Pedro Alves
@ 2017-02-19 21:26     ` Jan Kratochvil
  2017-02-20 11:11       ` Pedro Alves
  0 siblings, 1 reply; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-19 21:26 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Victor Leschuk

On Fri, 17 Feb 2017 02:19:06 +0100, Pedro Alves wrote:
> std::function is a lot of unnecessary overhead here.  Unless you
> manage to trigger to small-function optimization (which you won't here,
> the callbacks are too big), this is forcing a heap allocation inside
> std::function for every call to dwarf2_ranges_process.

These microoptimizations lead to the still broken fundamental data types and
algorithms of GDB, having to wait for minutes to hours to print an expression
(although usually it is not printable anyway).

perf would show the problem if it is really significant.  It would be less
significant with tcmalloc which GNU libc systems still do not use by default.


> Let's only use std::function for it's intended use-case of when the
> design calls for taking, or more usually, storing, a callable whose
> type is not knowable at compile type.

You are defining a new C++ specification here?  I have checked the code as
I wrote it is a perfect use of std::function<> according to the ISO C++11
specification.

Thanks you have noticed current GCC has missed-optimization in this case and
that it can be workarounded by a template as you have suggested.  It leads to
worse compilation diagnostics and we can hope this hack can be removed in the
future.  Still I agree this workaround of GCC is worth the performance gain.


Jan

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

* Re: [PATCH 5/8] DWARF-5 basic functionality
  2017-02-17 11:41   ` Pedro Alves
@ 2017-02-19 21:26     ` Jan Kratochvil
  2017-02-20 11:41       ` Pedro Alves
  0 siblings, 1 reply; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-19 21:26 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Victor Leschuk

On Fri, 17 Feb 2017 12:41:22 +0100, Pedro Alves wrote:
> > +ULONGEST gdb_read_unsigned_leb128 (bfd *, const gdb_byte *, unsigned int *);
> 
> Not needed anymore.

Yes, dropped.


> > +#include "libbfd.h"
> 
> We've determined this is an internal bfd header.
> Do we need this?

No, a mistake, dropped.


> > +/* Expected enum dwarf_unit_type for read_comp_unit_head.  */
> > +enum class RCUH_Kind { COMPILE, TYPE };
> 
> RCUH_Kind -> rcuh_kind.  We only use uppercase type names
> in template type parameter names.

Done.


> > -/* Call CALLBACK from DW_AT_ranges attribute value OFFSET.
> > +/* Call CALLBACK from DW_AT_ranges attribute value OFFSET
> > +   reading .debug_rnglists.
> > +   Return 1 if the attributes are present and valid, otherwise, return 0.  */
> > +
> > +static int
> > +dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu,
> 
> bool/true/false?

It is just a variant of dwarf2_ranges_process which still does use int from
the C days of GDB.  Its return value is also passed as a return value of
dwarf2_ranges_process.  Using bool here would need to refactor
dwarf2_ranges_process first.  And then one can rather refactor it all to
a virtual class and after more refactoring to a different debugger.

So I have kept it as it was.  Otherwise specify which level of refactorization
do you wish.


> > +			 std::function<void (CORE_ADDR range_beginning,
> > +					     CORE_ADDR range_end)> callback)
> 
> Same comment about std::function.  (and I had forgotten to suggest
> that callback should probably be a universal reference / "&&callback").

That is OK, I have already noticed you had studied a lot of C++ schoolbooks
before you permitted GDB to use C++.


Jan

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

* Re: [PATCH 6/8] DWARF-5: call sites
  2017-02-17 11:57   ` Pedro Alves
@ 2017-02-19 21:26     ` Jan Kratochvil
  0 siblings, 0 replies; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-19 21:26 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Victor Leschuk, Sergio Durigan Junior

On Fri, 17 Feb 2017 12:57:42 +0100, Pedro Alves wrote:
> On 02/12/2017 08:23 PM, Jan Kratochvil wrote:
> > --- a/gdb/testsuite/gdb.arch/amd64-entry-value-param.exp
> > +++ b/gdb/testsuite/gdb.arch/amd64-entry-value-param.exp
> > @@ -19,7 +19,7 @@ set opts {}
> >  if [info exists COMPILE] {
> >      # make check RUNTESTFLAGS="gdb.arch/amd64-entry-value-param.exp COMPILE=1"
> >      set srcfile ${srcfile2}
> > -    lappend opts debug optimize=-O2
> > +    lappend opts optimize=-O2 additional_flags=-gdwarf-5
> 
> Did you mean to update the .S file?
> 
> I wonder whether it makes sense to run the test twice, once against
> the current .S file using the GNU version of the opcodes, and
> another against standard DWARF5 opcodes.

So I have added: gdb.arch/amd64-entry-value-param-dwarf5.exp

It is not perfect as gdb.arch/amd64-entry-value-param-dwarf5.c there is the
same as gdb.arch/amd64-entry-value-param.c .


> That raises the question
> of why we don't do that with the c based tests, where we'll handle
> whatever format the compiler outputs.  So maybe not go there...

We do that, unaware if Sergio does that with buildbot but at least I do that
with my GDB tester which I updated for DWARF-5:
	http://git.jankratochvil.net/?p=nethome.git;a=blob_plain;f=bin/hammock
	!defined $dwarf or ($dwarf>=2 && $dwarf<=5) or die "--dwarf requires DWARF version number";

Many years ago I was running the nightly testsuite runs for all DWARF
versions.

Nowadays I have at least regression tested this DWARF-5 patchset so that
-gdwarf-4 and -gdwarf-5 do produce the same testsuite results.  It has caught
some bugs in my patchset.


Jan

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

* Re: [PATCH 8/8] DWARF-5: DW_FORM_data16
  2017-02-17 12:09   ` Pedro Alves
@ 2017-02-19 21:26     ` Jan Kratochvil
  2017-02-20 11:44       ` Pedro Alves
  0 siblings, 1 reply; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-19 21:26 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Victor Leschuk

On Fri, 17 Feb 2017 13:09:42 +0100, Pedro Alves wrote:
> On 02/12/2017 08:23 PM, Jan Kratochvil wrote:
> 
> > @@ -20250,6 +20261,10 @@ 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:
> > +	  /* FIXME: Print the contents.  */
> > +	  fprintf_unfiltered (f, "constant of 16 bytes");
> 
> Should we fix that FIXME?

I think even the code above "expression: size %s" should print the contents
which it does not and it has no FIXME there.

So I have just removed the FIXME.


Jan

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

* Re: [PATCH 3/8] Code cleanup: Split dwarf2_ranges_read to a callback
  2017-02-19 21:26     ` Jan Kratochvil
@ 2017-02-20 11:11       ` Pedro Alves
  0 siblings, 0 replies; 32+ messages in thread
From: Pedro Alves @ 2017-02-20 11:11 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches, Victor Leschuk

On 02/19/2017 09:26 PM, Jan Kratochvil wrote:
> On Fri, 17 Feb 2017 02:19:06 +0100, Pedro Alves wrote:
>> std::function is a lot of unnecessary overhead here.  Unless you
>> manage to trigger to small-function optimization (which you won't here,
>> the callbacks are too big), this is forcing a heap allocation inside
>> std::function for every call to dwarf2_ranges_process.
> 
> These microoptimizations lead to the still broken fundamental data types and
> algorithms of GDB, having to wait for minutes to hours to print an expression
> (although usually it is not printable anyway).

"lead" here is totally a non sequitur...

> perf would show the problem if it is really significant.  It would be less
> significant with tcmalloc which GNU libc systems still do not use by default.

See urls below.  There are benchmarks all over the web.  The performance
problems with misuse of std::function are well known.  Best to nip a problem
in the bud.

> 
> 
>> Let's only use std::function for it's intended use-case of when the
>> design calls for taking, or more usually, storing, a callable whose
>> type is not knowable at compile type.
> 
> You are defining a new C++ specification here?  I have checked the code as
> I wrote it is a perfect use of std::function<> according to the ISO C++11
> specification.

The specification doesn't talk about how the classes it specifies are
meant to be used.  Only their interfaces and behaviors.  

You could do something ridiculous like only use "void*" as types of 
pointers throughout a program, and cast back to the proper dynamic type
before dereferencing them, and call it a "perfect" use according to
the spec, but that doesn't mean that that would be a be good idea.

A "perfect" use for std::function would be using it when you
need to save a list of callables in a container in a field of a
class, to call later.  E.g., it'd be a good fit to replace GDB's
observers (observer_attach..., observer_notify..., etc.)

For functions that take a callable as argument, but never store the
callable anywhere, just use it, the workaround IF you don't want
or can't use a template and you need the type-erasing of std::function, is
to wrap the callable around an std::reference_wrapper at the callee site,
using std::ref.  But that's quite inconvenient to use, because std::ref
doesn't accept rvalue references.  Meaning, #1, you have to remember
to use it, #2, you have to give the lambda's a name, like:

 auto some_callback = [&] (......) {
   .....
 };
 function_that_takes_callback_as_a_filter (foo, bar, std::ref (some_callback));

instead of the desired:

 function_that_takes_callback_as_a_filter (foo, bar, [&] (......) {
   .....
 };

So for the cases where we have a function where we:

 #1 - can't or don't want to use a template.
 #2 - want to accept any callable type (, thus need a type-erasing callable
      wrapper type like std::function).
 #3 - are sure the lifetime of the callable is as long as the
      function the callable is being passed to.
 #4 - are OK to take the callable by rvalue reference.

then what we really need is a "function_view" type.  I.e., something
like std::function that always takes a reference to a callable
instead of storing the callable inside.  Like std::string_view is to
std::string.  The standard is lacking here.

I'm not saying anything new here.  Several projects have such a thing (e.g., 
llvm::function_ref), I've seen it discussed in the std-proposals list, and
I've seen blogs about such things.  If you do the proper web searches, you'll
find explanations of all the above elsewhere.  To spare you the trouble,
I just did a search now for you, and here's what I found:

on std::function vs templates:
 http://stackoverflow.com/questions/14677997/stdfunction-vs-template

on std::function vs std::ref:
 http://blog.demofox.org/2015/02/25/avoiding-the-performance-hazzards-of-stdfunction/

Here's LLVM's llvm::function_ref:
 http://llvm.org/docs/doxygen/html/STLExtras_8h_source.html#l00060

Here's a recent blog on yet another "function_view" implementation:
 https://vittorioromeo.info/index/blog/passing_functions_to_functions.html

As it happens, I have a use for something like this in symtab.c, so
I think I'll add something like it to GDB, and avoid having to
discuss this again.

> Thanks you have noticed current GCC has missed-optimization in this case and
> that it can be workarounded by a template as you have suggested.  It leads to
> worse compilation diagnostics and we can hope this hack can be removed in the
> future.  Still I agree this workaround of GCC is worth the performance gain.

#1 - It's not a hack.

#2 - an optimization I imagine could make a difference here would be "new"
     elision, per N3664, which gcc doesn't do yet.  But in any case, it's much
     better if the type system reflects semantics, instead of relying on some
     optimization that is not guaranteed to trigger, even if the compiler
     supports it.

#3 - It's not a hack.

Thanks,
Pedro Alves

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

* Re: [PATCH 5/8] DWARF-5 basic functionality
  2017-02-19 21:26     ` Jan Kratochvil
@ 2017-02-20 11:41       ` Pedro Alves
  2017-02-20 19:52         ` Jan Kratochvil
  0 siblings, 1 reply; 32+ messages in thread
From: Pedro Alves @ 2017-02-20 11:41 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches, Victor Leschuk

On 02/19/2017 09:26 PM, Jan Kratochvil wrote:

>>> -/* Call CALLBACK from DW_AT_ranges attribute value OFFSET.
>>> +/* Call CALLBACK from DW_AT_ranges attribute value OFFSET
>>> +   reading .debug_rnglists.
>>> +   Return 1 if the attributes are present and valid, otherwise, return 0.  */
>>> +
>>> +static int
>>> +dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu,
>>
>> bool/true/false?
> 
> It is just a variant of dwarf2_ranges_process which still does use int from
> the C days of GDB.
> Its return value is also passed as a return value of
> dwarf2_ranges_process.  Using bool here would need to refactor
> dwarf2_ranges_process first. 

Why would it?  bool converts to int just fine.
You're already using bool inside the function, which prompted
my comment.

Not that I'd be opposed to changing dwarf2_ranges_process too,
but I'm not seeing the "need".  If we stick with the easy
incremental progress, then over time using "int" as bool ends up
fading that way.  If we keep using "int" as bool, then we'll
never evolve past it.

> And then one can rather refactor it all to
> a virtual class and after more refactoring to a different debugger.
> 
> So I have kept it as it was.  Otherwise specify which level of refactorization
> do you wish.

All I meant was to use bool in the new code.

> 
>>> +			 std::function<void (CORE_ADDR range_beginning,
>>> +					     CORE_ADDR range_end)> callback)
>>
>> Same comment about std::function.  (and I had forgotten to suggest
>> that callback should probably be a universal reference / "&&callback").
> 
> That is OK, I have already noticed you had studied a lot of C++ schoolbooks
> before you permitted GDB to use C++.

If my comment was incorrect, feel free to correct me.
Otherwise, let's keep the discussion technical please.  How I learned
C++ is not called for here.

Thanks,
Pedro Alves

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

* Re: [PATCH 8/8] DWARF-5: DW_FORM_data16
  2017-02-19 21:26     ` Jan Kratochvil
@ 2017-02-20 11:44       ` Pedro Alves
  0 siblings, 0 replies; 32+ messages in thread
From: Pedro Alves @ 2017-02-20 11:44 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches, Victor Leschuk

On 02/19/2017 09:26 PM, Jan Kratochvil wrote:
> On Fri, 17 Feb 2017 13:09:42 +0100, Pedro Alves wrote:
>> On 02/12/2017 08:23 PM, Jan Kratochvil wrote:
>>
>>> @@ -20250,6 +20261,10 @@ 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:
>>> +	  /* FIXME: Print the contents.  */
>>> +	  fprintf_unfiltered (f, "constant of 16 bytes");
>>
>> Should we fix that FIXME?
> 
> I think even the code above "expression: size %s" should print the contents
> which it does not and it has no FIXME there.
> 
> So I have just removed the FIXME.

OK.

Thanks,
Pedro Alves

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

* Re: [PATCH 5/8] DWARF-5 basic functionality
  2017-02-20 11:41       ` Pedro Alves
@ 2017-02-20 19:52         ` Jan Kratochvil
  2017-02-20 20:07           ` [commit] " Jan Kratochvil
  0 siblings, 1 reply; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-20 19:52 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Victor Leschuk

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

On Mon, 20 Feb 2017 12:41:39 +0100, Pedro Alves wrote:
> All I meant was to use bool in the new code.

Done.


Jan

[-- Attachment #2: Type: message/rfc822, Size: 55401 bytes --]

From: Jan Kratochvil <jan.kratochvil@redhat.com>
Subject: [PATCH] DWARF-5 basic functionality Hi,
Date: Sun, 19 Feb 2017 20:40:31 +0100

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                       | 780 +++++++++++++++++++++++++++------
 gdb/symfile.h                          |   3 +
 gdb/testsuite/gdb.dwarf2/dw2-error.exp |   2 +-
 gdb/xcoffread.c                        |   3 +
 7 files changed, 735 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..38c5706 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)
+			       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 (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)
-{
-  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,189 @@ 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 true if the attributes are present and valid, otherwise,
+   return false.  */
+
+template <typename Callback>
+static bool
+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 false;
+    }
+  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 false;
+	}
+      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 false;
+	}
+
+      if (range_beginning > range_end)
+	{
+	  /* Inverted range entries are invalid.  */
+	  complaint (&symfile_complaints,
+		     _("Invalid .debug_rnglists data (inverted range)"));
+	  return false;
+	}
+
+      /* 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 false;
+    }
+
+  return true;
+}
+
+/* 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 +12148,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 +15598,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 +15630,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 +16465,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 +16542,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 +16631,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 +16710,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 +16964,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 +17031,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 +17045,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 +17421,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 +17599,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 +17803,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 +17811,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 +17867,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 +20255,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 +22283,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 +22407,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 +22468,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 },
-- 
2.9.3

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

* [commit] [PATCH 5/8] DWARF-5 basic functionality
  2017-02-20 19:52         ` Jan Kratochvil
@ 2017-02-20 20:07           ` Jan Kratochvil
  0 siblings, 0 replies; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-20 20:07 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Victor Leschuk

On Mon, 20 Feb 2017 20:52:29 +0100, Jan Kratochvil wrote:
> 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.

43988095a5a4c53e6d5b00a6335454919c4fac55


Jan

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

end of thread, other threads:[~2017-02-20 20:07 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-12 20:23 [PATCH 1/8] Rename read_unsigned_leb128 to gdb_read_unsigned_leb128 Jan Kratochvil
2017-02-12 20:23 ` [PATCH 7/8] DWARF-5: Macros Jan Kratochvil
2017-02-17 11:59   ` Pedro Alves
2017-02-12 20:23 ` [PATCH 4/8] Code cleanup: Refactor abbrev_table_read_table cycle Jan Kratochvil
2017-02-17  1:21   ` Pedro Alves
2017-02-12 20:23 ` [PATCH 6/8] DWARF-5: call sites Jan Kratochvil
2017-02-12 20:41   ` Eli Zaretskii
2017-02-17 11:57   ` Pedro Alves
2017-02-19 21:26     ` Jan Kratochvil
2017-02-12 20:23 ` [PATCH 3/8] Code cleanup: Split dwarf2_ranges_read to a callback Jan Kratochvil
2017-02-17  1:19   ` Pedro Alves
2017-02-19 21:26     ` Jan Kratochvil
2017-02-20 11:11       ` Pedro Alves
2017-02-12 20:23 ` [PATCH 2/8] Code cleanup: Split create_debug_types_hash_table Jan Kratochvil
2017-02-16 19:33   ` Pedro Alves
2017-02-12 20:23 ` [PATCH 8/8] DWARF-5: DW_FORM_data16 Jan Kratochvil
2017-02-17 12:09   ` Pedro Alves
2017-02-19 21:26     ` Jan Kratochvil
2017-02-20 11:44       ` Pedro Alves
2017-02-17 12:24   ` Pedro Alves
2017-02-12 20:23 ` [PATCH 5/8] DWARF-5 basic functionality Jan Kratochvil
2017-02-17 11:41   ` Pedro Alves
2017-02-19 21:26     ` Jan Kratochvil
2017-02-20 11:41       ` Pedro Alves
2017-02-20 19:52         ` Jan Kratochvil
2017-02-20 20:07           ` [commit] " Jan Kratochvil
2017-02-16 15:23 ` [PATCH 1/8] Rename read_unsigned_leb128 to gdb_read_unsigned_leb128 Pedro Alves
2017-02-16 19:40   ` Jan Kratochvil
2017-02-16 20:01     ` Pedro Alves
2017-02-16 22:54       ` Pedro Alves
2017-02-17  1:28         ` Pedro Alves
2017-02-19 21:25         ` 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).