Remove some includes of readline.h
[deliverable/binutils-gdb.git] / gdb / psymtab.c
index e9cc8c3bc6d3173c09bcff246177f9dde9f0dd36..67e3e36aa9ee98b2351b50b83ec51721ebd40c98 100644 (file)
@@ -28,7 +28,7 @@
 #include "gdbtypes.h"
 #include "ui-out.h"
 #include "command.h"
-#include "readline/readline.h"
+#include "readline/tilde.h"
 #include "gdb_regex.h"
 #include "dictionary.h"
 #include "language.h"
@@ -301,14 +301,24 @@ find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc,
                      struct obj_section *section,
                      struct bound_minimal_symbol msymbol)
 {
-  CORE_ADDR baseaddr = ANOFFSET (objfile->section_offsets,
-                                SECT_OFF_TEXT (objfile));
-
-  /* Try just the PSYMTABS_ADDRMAP mapping first as it has better granularity
-     than the later used TEXTLOW/TEXTHIGH one.  */
-
-  if (objfile->partial_symtabs->psymtabs_addrmap != NULL)
+  /* Try just the PSYMTABS_ADDRMAP mapping first as it has better
+     granularity than the later used TEXTLOW/TEXTHIGH one.  However, we need
+     to take care as the PSYMTABS_ADDRMAP can hold things other than partial
+     symtabs in some cases.
+
+     This function should only be called for objfiles that are using partial
+     symtabs, not for objfiles that are using indexes (.gdb_index or
+     .debug_names), however 'maintenance print psymbols' calls this function
+     directly for all objfiles.  If we assume that PSYMTABS_ADDRMAP contains
+     partial symtabs then we will end up returning a pointer to an object
+     that is not a partial_symtab, which doesn't end well.  */
+
+  if (objfile->partial_symtabs->psymtabs != NULL
+      && objfile->partial_symtabs->psymtabs_addrmap != NULL)
     {
+      CORE_ADDR baseaddr = ANOFFSET (objfile->section_offsets,
+                                    SECT_OFF_TEXT (objfile));
+
       struct partial_symtab *pst
        = ((struct partial_symtab *)
           addrmap_find (objfile->partial_symtabs->psymtabs_addrmap,
@@ -1262,6 +1272,8 @@ recursively_search_psymtabs
          QUIT;
 
          if ((domain == ALL_DOMAIN
+              || (domain == MODULES_DOMAIN
+                  && (*psym)->domain == MODULE_DOMAIN)
               || (domain == VARIABLES_DOMAIN
                   && (*psym)->aclass != LOC_TYPEDEF
                   && (*psym)->aclass != LOC_BLOCK)
@@ -1558,7 +1570,7 @@ psymbol_compare (const void *addr1, const void *addr2, int length)
    different domain (or address) is possible and correct.  */
 
 static struct partial_symbol *
-add_psymbol_to_bcache (const char *name, int namelength, bool copy_name,
+add_psymbol_to_bcache (gdb::string_view name, bool copy_name,
                       domain_enum domain,
                       enum address_class theclass,
                       short section,
@@ -1575,7 +1587,7 @@ add_psymbol_to_bcache (const char *name, int namelength, bool copy_name,
   psymbol.aclass = theclass;
   symbol_set_language (&psymbol.ginfo, language,
                       objfile->partial_symtabs->obstack ());
-  symbol_set_names (&psymbol.ginfo, name, namelength, copy_name,
+  symbol_set_names (&psymbol.ginfo, name, copy_name,
                    objfile->per_bfd);
 
   /* Stash the partial symbol away in the cache.  */
@@ -1595,14 +1607,10 @@ append_psymbol_to_list (std::vector<partial_symbol *> *list,
   OBJSTAT (objfile, n_psyms++);
 }
 
-/* Add a symbol with a long value to a psymtab.
-   Since one arg is a struct, we pass in a ptr and deref it (sigh).
-   The only value we need to store for psyms is an address.
-   For all other psyms pass zero for COREADDR.
-   Return the partial symbol that has been added.  */
+/* See psympriv.h.  */
 
 void
-add_psymbol_to_list (const char *name, int namelength, bool copy_name,
+add_psymbol_to_list (gdb::string_view name, bool copy_name,
                     domain_enum domain,
                     enum address_class theclass,
                     short section,
@@ -1615,7 +1623,7 @@ add_psymbol_to_list (const char *name, int namelength, bool copy_name,
   int added;
 
   /* Stash the partial symbol away in the cache.  */
-  psym = add_psymbol_to_bcache (name, namelength, copy_name, domain, theclass,
+  psym = add_psymbol_to_bcache (name, copy_name, domain, theclass,
                                section, coreaddr, language, objfile, &added);
 
   /* Do not duplicate global partial symbols.  */
This page took 0.025762 seconds and 4 git commands to generate.