Fix detach with target remote (PR gdb/28080)
[deliverable/binutils-gdb.git] / gdb / objfiles.h
index 4cd392bd7f022e71571346a0e850395c5f27002a..766c4b409dfcc18e6bd855366fbf96de81dc29d0 100644 (file)
@@ -127,37 +127,6 @@ struct entry_info
   unsigned initialized : 1;
 };
 
-/* Sections in an objfile.  The section offsets are stored in the
-   OBJFILE.  */
-
-struct obj_section
-{
-  /* BFD section pointer */
-  struct bfd_section *the_bfd_section;
-
-  /* Objfile this section is part of.  */
-  struct objfile *objfile;
-
-  /* True if this "overlay section" is mapped into an "overlay region".  */
-  int ovly_mapped;
-};
-
-/* Relocation offset applied to S.  */
-#define obj_section_offset(s)                                          \
-  (((s)->objfile->section_offsets)[gdb_bfd_section_index ((s)->objfile->obfd, (s)->the_bfd_section)])
-
-/* The memory address of section S (vma + offset).  */
-#define obj_section_addr(s)                                            \
-  (bfd_section_vma (s->the_bfd_section)                                        \
-   + obj_section_offset (s))
-
-/* The one-passed-the-end memory address of section S
-   (vma + size + offset).  */
-#define obj_section_endaddr(s)                                         \
-  (bfd_section_vma (s->the_bfd_section)                                        \
-   + bfd_section_size ((s)->the_bfd_section)                           \
-   + obj_section_offset (s))
-
 #define ALL_OBJFILE_OSECTIONS(objfile, osect)  \
   for (osect = objfile->sections; osect < objfile->sections_end; osect++) \
     if (osect->the_bfd_section == NULL)                                        \
@@ -264,12 +233,36 @@ private:
 
 struct objfile_per_bfd_storage
 {
-  objfile_per_bfd_storage ()
-    : minsyms_read (false)
+  objfile_per_bfd_storage (bfd *bfd)
+    : minsyms_read (false), m_bfd (bfd)
   {}
 
   ~objfile_per_bfd_storage ();
 
+  /* Intern STRING in this object's string cache and return the unique copy.
+     The copy has the same lifetime as this object.
+
+     STRING must be null-terminated.  */
+
+  const char *intern (const char *str)
+  {
+    return (const char *) string_cache.insert (str, strlen (str) + 1);
+  }
+
+  /* Same as the above, but for an std::string.  */
+
+  const char *intern (const std::string &str)
+  {
+    return (const char *) string_cache.insert (str.c_str (), str.size () + 1);
+  }
+
+  /* Get the BFD this object is associated to.  */
+
+  bfd *get_bfd () const
+  {
+    return m_bfd;
+  }
+
   /* The storage has an obstack of its own.  */
 
   auto_obstack storage_obstack;
@@ -347,6 +340,11 @@ struct objfile_per_bfd_storage
   /* All the different languages of symbols found in the demangled
      hash table.  */
   std::bitset<nr_languages> demangled_hash_languages;
+
+private:
+  /* The BFD this object is associated to.  */
+
+  bfd *m_bfd;
 };
 
 /* An iterator that first returns a parent objfile, and then each
@@ -516,15 +514,14 @@ public:
      lifetime as the per-BFD object.  */
   const char *intern (const char *str)
   {
-    return (const char *) per_bfd->string_cache.insert (str, strlen (str) + 1);
+    return per_bfd->intern (str);
   }
 
   /* Intern STRING and return the unique copy.  The copy has the same
      lifetime as the per-BFD object.  */
   const char *intern (const std::string &str)
   {
-    return (const char *) per_bfd->string_cache.insert (str.c_str (),
-                                                       str.size () + 1);
+    return per_bfd->intern (str);
   }
 
   /* Retrieve the gdbarch associated with this objfile.  */
@@ -537,18 +534,44 @@ public:
 
   bool has_partial_symbols ();
 
+  /* Return true if this objfile has any unexpanded symbols.  A return
+     value of false indicates either, that this objfile has all its
+     symbols fully expanded (i.e. fully read in), or that this objfile has
+     no symbols at all (i.e. no debug information).  */
+  bool has_unexpanded_symtabs ();
+
   /* See quick_symbol_functions.  */
   struct symtab *find_last_source_symtab ();
 
   /* See quick_symbol_functions.  */
   void forget_cached_source_info ();
 
-  /* See quick_symbol_functions.  */
+  /* Expand and iterate over each "partial" symbol table in OBJFILE
+     where the source file is named NAME.
+
+     If NAME is not absolute, a match after a '/' in the symbol table's
+     file name will also work, REAL_PATH is NULL then.  If NAME is
+     absolute then REAL_PATH is non-NULL absolute file name as resolved
+     via gdb_realpath from NAME.
+
+     If a match is found, the "partial" symbol table is expanded.
+     Then, this calls iterate_over_some_symtabs (or equivalent) over
+     all newly-created symbol tables, passing CALLBACK to it.
+     The result of this call is returned.  */
   bool map_symtabs_matching_filename
     (const char *name, const char *real_path,
      gdb::function_view<bool (symtab *)> callback);
 
-  /* See quick_symbol_functions.  */
+  /* Check to see if the symbol is defined in a "partial" symbol table
+     of this objfile.  BLOCK_INDEX should be either GLOBAL_BLOCK or
+     STATIC_BLOCK, depending on whether we want to search global
+     symbols or static symbols.  NAME is the name of the symbol to
+     look for.  DOMAIN indicates what sort of symbol to search for.
+
+     Returns the newly-expanded compunit in which the symbol is
+     defined, or NULL if no such symbol table exists.  If OBJFILE
+     contains !TYPE_OPAQUE symbol prefer its compunit.  If it contains
+     only TYPE_OPAQUE symbol(s), return at least that compunit.  */
   struct compunit_symtab *lookup_symbol (block_enum kind, const char *name,
                                         domain_enum domain);
 
@@ -558,28 +581,34 @@ public:
   /* See quick_symbol_functions.  */
   void dump ();
 
-  /* See quick_symbol_functions.  */
+  /* Find all the symbols in OBJFILE named FUNC_NAME, and ensure that
+     the corresponding symbol tables are loaded.  */
   void expand_symtabs_for_function (const char *func_name);
 
   /* See quick_symbol_functions.  */
   void expand_all_symtabs ();
 
-  /* See quick_symbol_functions.  */
+  /* Read all symbol tables associated with OBJFILE which have
+     symtab_to_fullname equal to FULLNAME.
+     This is for the purposes of examining code only, e.g., expand_line_sal.
+     The routine may ignore debug info that is known to not be useful with
+     code, e.g., DW_TAG_type_unit for dwarf debug info.  */
   void expand_symtabs_with_fullname (const char *fullname);
 
   /* See quick_symbol_functions.  */
-  void map_matching_symbols
+  void expand_matching_symbols
     (const lookup_name_info &name, domain_enum domain,
      int global,
-     gdb::function_view<symbol_found_callback_ftype> callback,
      symbol_compare_ftype *ordered_compare);
 
   /* See quick_symbol_functions.  */
-  void expand_symtabs_matching
+  bool expand_symtabs_matching
     (gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
      const lookup_name_info *lookup_name,
      gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
+     block_search_flags search_flags,
+     domain_enum domain,
      enum search_domain kind);
 
   /* See quick_symbol_functions.  */
@@ -604,6 +633,27 @@ public:
   /* See quick_symbol_functions.  */
   void require_partial_symbols (bool verbose);
 
+  /* Return the relocation offset applied to SECTION.  */
+  CORE_ADDR section_offset (bfd_section *section) const
+  {
+    /* The section's owner can be nullptr if it is one of the _bfd_std_section
+       section.  */
+    gdb_assert (section->owner == nullptr || section->owner == this->obfd);
+
+    int idx = gdb_bfd_section_index (this->obfd, section);
+    return this->section_offsets[idx];
+  }
+
+  /* Set the relocation offset applied to SECTION.  */
+  void set_section_offset (bfd_section *section, CORE_ADDR offset)
+  {
+    /* The section's owner can be nullptr if it is one of the _bfd_std_section
+       section.  */
+    gdb_assert (section->owner == nullptr || section->owner == this->obfd);
+
+    int idx = gdb_bfd_section_index (this->obfd, section);
+    this->section_offsets[idx] = offset;
+  }
 
   /* The object file's original name as specified by the user,
      made absolute, and tilde-expanded.  However, it is not canonicalized
@@ -776,6 +826,47 @@ struct objfile_deleter
 
 typedef std::unique_ptr<objfile, objfile_deleter> objfile_up;
 
+
+/* Sections in an objfile.  The section offsets are stored in the
+   OBJFILE.  */
+
+struct obj_section
+{
+  /* Relocation offset applied to the section.  */
+  CORE_ADDR offset () const
+  {
+    return this->objfile->section_offset (this->the_bfd_section);
+  }
+
+  /* Set the relocation offset applied to the section.  */
+  void set_offset (CORE_ADDR offset)
+  {
+    this->objfile->set_section_offset (this->the_bfd_section, offset);
+  }
+
+  /* The memory address of the section (vma + offset).  */
+  CORE_ADDR addr () const
+  {
+    return bfd_section_vma (this->the_bfd_section) + this->offset ();
+  }
+
+  /* The one-passed-the-end memory address of the section
+     (vma + size + offset).  */
+  CORE_ADDR endaddr () const
+  {
+    return this->addr () + bfd_section_size (this->the_bfd_section);
+  }
+
+  /* BFD section pointer */
+  struct bfd_section *the_bfd_section;
+
+  /* Objfile this section is part of.  */
+  struct objfile *objfile;
+
+  /* True if this "overlay section" is mapped into an "overlay region".  */
+  int ovly_mapped;
+};
+
 /* Declarations for functions defined in objfiles.c */
 
 extern int entry_point_address_query (CORE_ADDR *entry_p);
This page took 0.025734 seconds and 4 git commands to generate.