[gdb/symtab] Fix name lookup in dw2_map_matching_symbols
[deliverable/binutils-gdb.git] / gdb / dwarf2 / line-header.h
index 08cf7b0810f44570f03e81d000f2eb47c4add8ac..6ec86fd08d7bb29ba6ed8bb18dd38bd655f5def4 100644 (file)
@@ -96,7 +96,7 @@ struct line_header
     return m_include_dirs[vec_index];
   }
 
-  bool is_valid_file_index (int file_index)
+  bool is_valid_file_index (int file_index) const
   {
     if (version >= 5)
       return 0 <= file_index && file_index < file_names_size ();
@@ -117,11 +117,21 @@ struct line_header
     return &m_file_names[vec_index];
   }
 
+  /* A const overload of the same.  */
+  const file_entry *file_name_at (file_name_index index) const
+  {
+    line_header *lh = const_cast<line_header *> (this);
+    return lh->file_name_at (index);
+  }
+
   /* The indexes are 0-based in DWARF 5 and 1-based in DWARF 4. Therefore,
      this method should only be used to iterate through all file entries in an
      index-agnostic manner.  */
   std::vector<file_entry> &file_names ()
   { return m_file_names; }
+  /* A const overload of the same.  */
+  const std::vector<file_entry> &file_names () const
+  { return m_file_names; }
 
   /* Offset of line number information in .debug_line section.  */
   sect_offset sect_off {};
@@ -145,7 +155,7 @@ struct line_header
      element is standard_opcode_lengths[opcode_base - 1].  */
   std::unique_ptr<unsigned char[]> standard_opcode_lengths;
 
-  int file_names_size ()
+  int file_names_size () const
   { return m_file_names.size(); }
 
   /* The start and end of the statement program following this
@@ -157,13 +167,13 @@ struct line_header
      compilation.  The result is allocated using xmalloc; the caller
      is responsible for freeing it.  */
   gdb::unique_xmalloc_ptr<char> file_full_name (int file,
-                                               const char *comp_dir);
+                                               const char *comp_dir) const;
 
   /* Return file name relative to the compilation directory of file
      number I in this object's file name table.  The result is
      allocated using xmalloc; the caller is responsible for freeing
      it.  */
-  gdb::unique_xmalloc_ptr<char> file_file_name (int file);
+  gdb::unique_xmalloc_ptr<char> file_file_name (int file) const;
 
  private:
   /* The include_directories table.  Note these are observing
@@ -185,4 +195,16 @@ file_entry::include_dir (const line_header *lh) const
   return lh->include_dir_at (d_index);
 }
 
+/* Read the statement program header starting at SECT_OFF in SECTION.
+   Return line_header.  Returns nullptr if there is a problem reading
+   the header, e.g., if it has a version we don't understand.
+
+   NOTE: the strings in the include directory and file name tables of
+   the returned object point into the dwarf line section buffer,
+   and must not be freed.  */
+
+extern line_header_up dwarf_decode_line_header
+  (sect_offset sect_off, bool is_dwz, dwarf2_per_objfile *per_objfile,
+   struct dwarf2_section_info *section, const struct comp_unit_head *cu_header);
+
 #endif /* DWARF2_LINE_HEADER_H */
This page took 0.024797 seconds and 4 git commands to generate.