remove msymbol_objfile
authorTom Tromey <tromey@redhat.com>
Mon, 5 Aug 2013 15:51:02 +0000 (15:51 +0000)
committerTom Tromey <tromey@redhat.com>
Mon, 5 Aug 2013 15:51:02 +0000 (15:51 +0000)
This is another patch in my ongoing series to "split" objfile to share
more read-only data across inferiors.  See

    http://sourceware.org/gdb/wiki/ObjfileSplitting

When symbols are finally shared, there will be no back-link from the
symbol to its containing objfile, because there may be more than one
such objfile.  So, all such back-links must be removed.

One hidden back-link is the msymbol_objfile function.  Since
(eventually) a symbol may appear in more than one objfile, trying to
look up the objfile given just a symbol cannot work.

This patch removes msymbol_objfile in favor of using a bound minimal
symbol.  It introduces a new function to make this conversion simpler
in some spots.

The bonus of this patch is that using msymbol_objfile is slower than
simply looking up the owning objfile in the first place.

Built and regtested on x86-64 Fedora 18.

* ada-exp.y (write_var_or_type): Use bound_minimal_symbol.
* ada-lang.c (ada_lookup_simple_minsym): Return
bound_minimal_symbol.
* ada-lang.h (ada_lookup_simple_minsym): Update.
* c-exp.y (variable): Use lookup_bound_minimal_symbol.
* f-exp.y (variable): Use lookup_bound_minimal_symbol.
* go-exp.y (variable): Use lookup_bound_minimal_symbol.
* jv-exp.y (push_expression_name): Use lookup_bound_minimal_symbol.
* m2-exp.y (variable): Use lookup_bound_minimal_symbol.
* minsyms.c (msymbol_objfile): Remove.
(lookup_minimal_symbol_internal): New function, from
lookup_minimal_symbol.
(lookup_minimal_symbol): Rewrite using
lookup_minimal_symbol_internal.
(lookup_bound_minimal_symbol): New function.
* minsyms.h (msymbol_objfile): Remove.
(lookup_bound_minimal_symbol): Declare.
* p-exp.y (variable): Use lookup_bound_minimal_symbol.
* parse.c (write_exp_msymbol): Change parameter to a
bound_minimal_symbol.
(write_dollar_variable): Use lookup_bound_minimal_symbol.
* parser-defs.h (write_exp_msymbol): Update.
* printcmd.c (address_info): Use lookup_bound_minimal_symbol.
* symfile.c (simple_read_overlay_table): Use
lookup_bound_minimal_symbol.
* symtab.c (skip_prologue_sal): Don't use msymbol_objfile.
(search_symbols): Likewise.
(print_msymbol_info): Take a bound_minimal_symbol argument.
(symtab_symbol_info, rbreak_command): Update.
* symtab.h (struct symbol_search) <msymbol>: Change type
to bound_minimal_symbol.
* valops.c (find_function_in_inferior): Use
lookup_bound_minimal_symbol.
* value.c (value_fn_field): Use lookup_bound_minimal_symbol.

20 files changed:
gdb/ChangeLog
gdb/ada-exp.y
gdb/ada-lang.c
gdb/ada-lang.h
gdb/c-exp.y
gdb/f-exp.y
gdb/go-exp.y
gdb/jv-exp.y
gdb/m2-exp.y
gdb/minsyms.c
gdb/minsyms.h
gdb/p-exp.y
gdb/parse.c
gdb/parser-defs.h
gdb/printcmd.c
gdb/symfile.c
gdb/symtab.c
gdb/symtab.h
gdb/valops.c
gdb/value.c

index 2a7773c25fce6c065e6671f8855c2d7279050252..5da081f25cadc3b8a9e5f3f54438dbe1d3f89bb7 100644 (file)
@@ -1,3 +1,40 @@
+2013-08-05  Tom Tromey  <tromey@redhat.com>
+
+       * ada-exp.y (write_var_or_type): Use bound_minimal_symbol.
+       * ada-lang.c (ada_lookup_simple_minsym): Return
+       bound_minimal_symbol.
+       * ada-lang.h (ada_lookup_simple_minsym): Update.
+       * c-exp.y (variable): Use lookup_bound_minimal_symbol.
+       * f-exp.y (variable): Use lookup_bound_minimal_symbol.
+       * go-exp.y (variable): Use lookup_bound_minimal_symbol.
+       * jv-exp.y (push_expression_name): Use lookup_bound_minimal_symbol.
+       * m2-exp.y (variable): Use lookup_bound_minimal_symbol.
+       * minsyms.c (msymbol_objfile): Remove.
+       (lookup_minimal_symbol_internal): New function, from
+       lookup_minimal_symbol.
+       (lookup_minimal_symbol): Rewrite using
+       lookup_minimal_symbol_internal.
+       (lookup_bound_minimal_symbol): New function.
+       * minsyms.h (msymbol_objfile): Remove.
+       (lookup_bound_minimal_symbol): Declare.
+       * p-exp.y (variable): Use lookup_bound_minimal_symbol.
+       * parse.c (write_exp_msymbol): Change parameter to a
+       bound_minimal_symbol.
+       (write_dollar_variable): Use lookup_bound_minimal_symbol.
+       * parser-defs.h (write_exp_msymbol): Update.
+       * printcmd.c (address_info): Use lookup_bound_minimal_symbol.
+       * symfile.c (simple_read_overlay_table): Use
+       lookup_bound_minimal_symbol.
+       * symtab.c (skip_prologue_sal): Don't use msymbol_objfile.
+       (search_symbols): Likewise.
+       (print_msymbol_info): Take a bound_minimal_symbol argument.
+       (symtab_symbol_info, rbreak_command): Update.
+       * symtab.h (struct symbol_search) <msymbol>: Change type
+       to bound_minimal_symbol.
+       * valops.c (find_function_in_inferior): Use
+       lookup_bound_minimal_symbol.
+       * value.c (value_fn_field): Use lookup_bound_minimal_symbol.
+
 2013-08-05  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        Code cleanup.
index d9fa9acd0ce64c3c9d5d559f212134ae936dec69..702a32e83e9cd4514d703081672a06766a2ef39f 100644 (file)
@@ -1369,9 +1369,9 @@ write_var_or_type (const struct block *block, struct stoken name0)
            }
          else if (nsyms == 0) 
            {
-             struct minimal_symbol *msym 
+             struct bound_minimal_symbol msym
                = ada_lookup_simple_minsym (encoded_name);
-             if (msym != NULL)
+             if (msym.minsym != NULL)
                {
                  write_exp_msymbol (msym);
                  /* Maybe cause error here rather than later? FIXME? */
index dc5f2b6e3bc9687018038f0076c045bdeb29a896..ba59913b38eadcc3bc3344ca89b382fe15414a06 100644 (file)
@@ -4405,18 +4405,22 @@ defns_collected (struct obstack *obstackp, int finish)
     return (struct ada_symbol_info *) obstack_base (obstackp);
 }
 
-/* Return a minimal symbol matching NAME according to Ada decoding
-   rules.  Returns NULL if there is no such minimal symbol.  Names
-   prefixed with "standard__" are handled specially: "standard__" is
-   first stripped off, and only static and global symbols are searched.  */
+/* Return a bound minimal symbol matching NAME according to Ada
+   decoding rules.  Returns an invalid symbol if there is no such
+   minimal symbol.  Names prefixed with "standard__" are handled
+   specially: "standard__" is first stripped off, and only static and
+   global symbols are searched.  */
 
-struct minimal_symbol *
+struct bound_minimal_symbol
 ada_lookup_simple_minsym (const char *name)
 {
+  struct bound_minimal_symbol result;
   struct objfile *objfile;
   struct minimal_symbol *msymbol;
   const int wild_match_p = should_use_wild_match (name);
 
+  memset (&result, 0, sizeof (result));
+
   /* Special case: If the user specifies a symbol name inside package
      Standard, do a non-wild matching of the symbol name without
      the "standard__" prefix.  This was primarily introduced in order
@@ -4431,10 +4435,14 @@ ada_lookup_simple_minsym (const char *name)
   {
     if (match_name (SYMBOL_LINKAGE_NAME (msymbol), name, wild_match_p)
         && MSYMBOL_TYPE (msymbol) != mst_solib_trampoline)
-      return msymbol;
+      {
+       result.minsym = msymbol;
+       result.objfile = objfile;
+       break;
+      }
   }
 
-  return NULL;
+  return result;
 }
 
 /* For all subprograms that statically enclose the subprogram of the
index 55c0a8192a25e8cfcbee13c81513951f568327c7..4ea25b80ba9f051f7a738bf2b2ac291182983a1a 100644 (file)
@@ -239,7 +239,7 @@ extern void ada_lookup_encoded_symbol
   (const char *name, const struct block *block, domain_enum namespace,
    struct ada_symbol_info *symbol_info);
 
-extern struct minimal_symbol *ada_lookup_simple_minsym (const char *);
+extern struct bound_minimal_symbol ada_lookup_simple_minsym (const char *);
 
 extern void ada_fill_in_ada_prototype (struct symbol *);
 
index dd032d2ead0f86963760506d4226bdd0623072a0..3a51878da5cf68ea03f826f95e09330fbd850ab9 100644 (file)
@@ -1004,7 +1004,7 @@ variable: qualified_name
                        {
                          char *name = copy_name ($2.stoken);
                          struct symbol *sym;
-                         struct minimal_symbol *msymbol;
+                         struct bound_minimal_symbol msymbol;
 
                          sym =
                            lookup_symbol (name, (const struct block *) NULL,
@@ -1018,8 +1018,8 @@ variable: qualified_name
                              break;
                            }
 
-                         msymbol = lookup_minimal_symbol (name, NULL, NULL);
-                         if (msymbol != NULL)
+                         msymbol = lookup_bound_minimal_symbol (name);
+                         if (msymbol.minsym != NULL)
                            write_exp_msymbol (msymbol);
                          else if (!have_full_symbols () && !have_partial_symbols ())
                            error (_("No symbol table is loaded.  Use the \"file\" command."));
@@ -1066,12 +1066,12 @@ variable:       name_not_typename
                            }
                          else
                            {
-                             struct minimal_symbol *msymbol;
+                             struct bound_minimal_symbol msymbol;
                              char *arg = copy_name ($1.stoken);
 
                              msymbol =
-                               lookup_minimal_symbol (arg, NULL, NULL);
-                             if (msymbol != NULL)
+                               lookup_bound_minimal_symbol (arg);
+                             if (msymbol.minsym != NULL)
                                write_exp_msymbol (msymbol);
                              else if (!have_full_symbols () && !have_partial_symbols ())
                                error (_("No symbol table is loaded.  Use the \"file\" command."));
index 846cc02b3b187464bd2aa102dc2d3aea7fdd6325..296a7fe1c7334d7811843ed866d7ff9618521f59 100644 (file)
@@ -513,12 +513,12 @@ variable: name_not_typename
                            }
                          else
                            {
-                             struct minimal_symbol *msymbol;
+                             struct bound_minimal_symbol msymbol;
                              char *arg = copy_name ($1.stoken);
 
                              msymbol =
-                               lookup_minimal_symbol (arg, NULL, NULL);
-                             if (msymbol != NULL)
+                               lookup_bound_minimal_symbol (arg);
+                             if (msymbol.minsym != NULL)
                                write_exp_msymbol (msymbol);
                              else if (!have_full_symbols () && !have_partial_symbols ())
                                error (_("No symbol table is loaded.  Use the \"file\" command."));
index 66d9149d9444e0ae34c33dc326d5706a667cf744..2ccb394dce91756919c9108a1fd5fb0e7d86a06e 100644 (file)
@@ -616,12 +616,12 @@ variable: name_not_typename
                            }
                          else
                            {
-                             struct minimal_symbol *msymbol;
+                             struct bound_minimal_symbol msymbol;
                              char *arg = copy_name ($1.stoken);
 
                              msymbol =
-                               lookup_minimal_symbol (arg, NULL, NULL);
-                             if (msymbol != NULL)
+                               lookup_bound_minimal_symbol (arg);
+                             if (msymbol.minsym != NULL)
                                write_exp_msymbol (msymbol);
                              else if (!have_full_symbols ()
                                       && !have_partial_symbols ())
index ea562965c0c05d567eb46464be1b3ea3a870584f..a4e1253e34d07fdcf2afe3c04a3f063715a19f93 100644 (file)
@@ -1391,10 +1391,10 @@ push_expression_name (struct stoken name)
     }
   else
     {
-      struct minimal_symbol *msymbol;
+      struct bound_minimal_symbol msymbol;
 
-      msymbol = lookup_minimal_symbol (tmp, NULL, NULL);
-      if (msymbol != NULL)
+      msymbol = lookup_bound_minimal_symbol (tmp);
+      if (msymbol.minsym != NULL)
        write_exp_msymbol (msymbol);
       else if (!have_full_symbols () && !have_partial_symbols ())
        error (_("No symbol table is loaded.  Use the \"file\" command"));
index 69e17d84d054fcefef9458add6ceaee85ecfe30d..eaa5a23ac89ab88b4f395a74885c6c9ae89d7489 100644 (file)
@@ -627,12 +627,12 @@ variable: NAME
                            }
                          else
                            {
-                             struct minimal_symbol *msymbol;
+                             struct bound_minimal_symbol msymbol;
                              char *arg = copy_name ($1);
 
                              msymbol =
-                               lookup_minimal_symbol (arg, NULL, NULL);
-                             if (msymbol != NULL)
+                               lookup_bound_minimal_symbol (arg);
+                             if (msymbol.minsym != NULL)
                                write_exp_msymbol (msymbol);
                              else if (!have_full_symbols () && !have_partial_symbols ())
                                error (_("No symbol table is loaded.  Use the \"symbol-file\" command."));
index 89e538af0ec50333eda1fffeaf827ea60a997c8f..e2079301fad7ce8aa1b3983901b7014d1a03ea47 100644 (file)
@@ -139,27 +139,6 @@ add_minsym_to_demangled_hash_table (struct minimal_symbol *sym,
     }
 }
 
-/* See minsyms.h.  */
-
-struct objfile *
-msymbol_objfile (struct minimal_symbol *sym)
-{
-  struct objfile *objf;
-  struct minimal_symbol *tsym;
-
-  unsigned int hash
-    = msymbol_hash (SYMBOL_LINKAGE_NAME (sym)) % MINIMAL_SYMBOL_HASH_SIZE;
-
-  for (objf = object_files; objf; objf = objf->next)
-    for (tsym = objf->msymbol_hash[hash]; tsym; tsym = tsym->hash_next)
-      if (tsym == sym)
-       return objf;
-
-  /* We should always be able to find the objfile ...  */
-  internal_error (__FILE__, __LINE__, _("failed internal consistency check"));
-}
-
-
 /* Look through all the current minimal symbol tables and find the
    first minimal symbol that matches NAME.  If OBJF is non-NULL, limit
    the search to that objfile.  If SFILE is non-NULL, the only file-scope
@@ -180,15 +159,14 @@ msymbol_objfile (struct minimal_symbol *sym)
    Obviously, there must be distinct mangled names for each of these,
    but the demangled names are all the same: S::S or S::~S.  */
 
-struct minimal_symbol *
-lookup_minimal_symbol (const char *name, const char *sfile,
-                      struct objfile *objf)
+static struct bound_minimal_symbol
+lookup_minimal_symbol_internal (const char *name, const char *sfile,
+                               struct objfile *objf)
 {
   struct objfile *objfile;
-  struct minimal_symbol *msymbol;
-  struct minimal_symbol *found_symbol = NULL;
-  struct minimal_symbol *found_file_symbol = NULL;
-  struct minimal_symbol *trampoline_symbol = NULL;
+  struct bound_minimal_symbol found_symbol = { NULL, NULL };
+  struct bound_minimal_symbol found_file_symbol = { NULL, NULL };
+  struct bound_minimal_symbol trampoline_symbol = { NULL, NULL };
 
   unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
   unsigned int dem_hash = msymbol_hash_iw (name) % MINIMAL_SYMBOL_HASH_SIZE;
@@ -213,9 +191,11 @@ lookup_minimal_symbol (const char *name, const char *sfile,
     }
 
   for (objfile = object_files;
-       objfile != NULL && found_symbol == NULL;
+       objfile != NULL && found_symbol.minsym == NULL;
        objfile = objfile->next)
     {
+      struct minimal_symbol *msymbol;
+
       if (objf == NULL || objf == objfile
          || objf == objfile->separate_debug_objfile_backlink)
        {
@@ -223,7 +203,7 @@ lookup_minimal_symbol (const char *name, const char *sfile,
             and the second over the demangled hash table.  */
         int pass;
 
-        for (pass = 1; pass <= 2 && found_symbol == NULL; pass++)
+        for (pass = 1; pass <= 2 && found_symbol.minsym == NULL; pass++)
            {
             /* Select hash list according to pass.  */
             if (pass == 1)
@@ -231,7 +211,7 @@ lookup_minimal_symbol (const char *name, const char *sfile,
             else
               msymbol = objfile->msymbol_demangled_hash[dem_hash];
 
-            while (msymbol != NULL && found_symbol == NULL)
+            while (msymbol != NULL && found_symbol.minsym == NULL)
                {
                  int match;
 
@@ -260,7 +240,10 @@ lookup_minimal_symbol (const char *name, const char *sfile,
                       case mst_file_bss:
                         if (sfile == NULL
                            || filename_cmp (msymbol->filename, sfile) == 0)
-                          found_file_symbol = msymbol;
+                         {
+                           found_file_symbol.minsym = msymbol;
+                           found_file_symbol.objfile = objfile;
+                         }
                         break;
 
                       case mst_solib_trampoline:
@@ -269,13 +252,17 @@ lookup_minimal_symbol (const char *name, const char *sfile,
                            keep looking for the *real* symbol.  If the
                            actual symbol is not found, then we'll use the
                            trampoline entry.  */
-                        if (trampoline_symbol == NULL)
-                          trampoline_symbol = msymbol;
+                        if (trampoline_symbol.minsym == NULL)
+                         {
+                           trampoline_symbol.minsym = msymbol;
+                           trampoline_symbol.objfile = objfile;
+                         }
                         break;
 
                       case mst_unknown:
                       default:
-                        found_symbol = msymbol;
+                        found_symbol.minsym = msymbol;
+                       found_symbol.objfile = objfile;
                         break;
                       }
                    }
@@ -294,18 +281,36 @@ lookup_minimal_symbol (const char *name, const char *sfile,
     xfree ((void *) modified_name);
 
   /* External symbols are best.  */
-  if (found_symbol)
+  if (found_symbol.minsym != NULL)
     return found_symbol;
 
   /* File-local symbols are next best.  */
-  if (found_file_symbol)
+  if (found_file_symbol.minsym != NULL)
     return found_file_symbol;
 
   /* Symbols for shared library trampolines are next best.  */
-  if (trampoline_symbol)
-    return trampoline_symbol;
+  return trampoline_symbol;
+}
 
-  return NULL;
+/* See minsyms.h.  */
+
+struct minimal_symbol *
+lookup_minimal_symbol (const char *name, const char *sfile,
+                      struct objfile *objf)
+{
+  struct bound_minimal_symbol bms = lookup_minimal_symbol_internal (name,
+                                                                   sfile,
+                                                                   objf);
+
+  return bms.minsym;
+}
+
+/* See minsyms.h.  */
+
+struct bound_minimal_symbol
+lookup_bound_minimal_symbol (const char *name)
+{
+  return lookup_minimal_symbol_internal (name, NULL, NULL);
 }
 
 /* See minsyms.h.  */
index 4d484771f8db6d8b419228be01cec88fd61eef57..95bbdc51f25543ea8d055e5db266c4a69e210c93 100644 (file)
@@ -162,14 +162,6 @@ unsigned int msymbol_hash_iw (const char *);
 
 \f
 
-/* Return the objfile that holds the minimal symbol SYM.  Every
-   minimal symbols is held by some objfile; this will never return
-   NULL.  */
-
-struct objfile *msymbol_objfile (struct minimal_symbol *sym);
-
-\f
-
 /* Look through all the current minimal symbol tables and find the
    first minimal symbol that matches NAME.  If OBJF is non-NULL, limit
    the search to that objfile.  If SFILE is non-NULL, the only file-scope
@@ -181,6 +173,11 @@ struct minimal_symbol *lookup_minimal_symbol (const char *,
                                              const char *,
                                              struct objfile *);
 
+/* Like lookup_minimal_symbol, but searches all files and objfiles
+   and returns a bound minimal symbol.  */
+
+struct bound_minimal_symbol lookup_bound_minimal_symbol (const char *);
+
 /* Find the minimal symbol named NAME, and return both the minsym
    struct and its objfile.  This only checks the linkage name.  */
 
index a989ac4ca55b5717cb462b74c6cddb46fe55310f..da8d5f74714b1ba5e24c503a5ddd87e8cc5ddef7 100644 (file)
@@ -700,7 +700,7 @@ variable:   qualified_name
                        {
                          char *name = copy_name ($2);
                          struct symbol *sym;
-                         struct minimal_symbol *msymbol;
+                         struct bound_minimal_symbol msymbol;
 
                          sym =
                            lookup_symbol (name, (const struct block *) NULL,
@@ -714,8 +714,8 @@ variable:   qualified_name
                              break;
                            }
 
-                         msymbol = lookup_minimal_symbol (name, NULL, NULL);
-                         if (msymbol != NULL)
+                         msymbol = lookup_bound_minimal_symbol (name);
+                         if (msymbol.minsym != NULL)
                            write_exp_msymbol (msymbol);
                          else if (!have_full_symbols ()
                                   && !have_partial_symbols ())
@@ -779,12 +779,12 @@ variable: name_not_typename
                            }
                          else
                            {
-                             struct minimal_symbol *msymbol;
+                             struct bound_minimal_symbol msymbol;
                              char *arg = copy_name ($1.stoken);
 
                              msymbol =
-                               lookup_minimal_symbol (arg, NULL, NULL);
-                             if (msymbol != NULL)
+                               lookup_bound_minimal_symbol (arg);
+                             if (msymbol.minsym != NULL)
                                write_exp_msymbol (msymbol);
                              else if (!have_full_symbols ()
                                       && !have_partial_symbols ())
index 13699a85e6bc4e71af590ae1402ddf6ee2125a6a..674342bd3aa1ffbde0cc8b4e1b3aa9c847ab6ab7 100644 (file)
@@ -496,9 +496,10 @@ write_exp_bitstring (struct stoken str)
    the expression.  */
 
 void
-write_exp_msymbol (struct minimal_symbol *msymbol)
+write_exp_msymbol (struct bound_minimal_symbol bound_msym)
 {
-  struct objfile *objfile = msymbol_objfile (msymbol);
+  struct minimal_symbol *msymbol = bound_msym.minsym;
+  struct objfile *objfile = bound_msym.objfile;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
 
   CORE_ADDR addr = SYMBOL_VALUE_ADDRESS (msymbol);
@@ -640,7 +641,7 @@ void
 write_dollar_variable (struct stoken str)
 {
   struct symbol *sym = NULL;
-  struct minimal_symbol *msym = NULL;
+  struct bound_minimal_symbol msym;
   struct internalvar *isym = NULL;
 
   /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1)
@@ -704,8 +705,8 @@ write_dollar_variable (struct stoken str)
       write_exp_elt_opcode (OP_VAR_VALUE);
       return;
     }
-  msym = lookup_minimal_symbol (copy_name (str), NULL, NULL);
-  if (msym)
+  msym = lookup_bound_minimal_symbol (copy_name (str));
+  if (msym.minsym)
     {
       write_exp_msymbol (msym);
       return;
index 5fbae0db59396352a84766687667931412b9cb91..92daca99198ca71b08106531a15ce854f49cb660 100644 (file)
@@ -195,7 +195,7 @@ extern void write_exp_elt_block (const struct block *);
 
 extern void write_exp_elt_objfile (struct objfile *objfile);
 
-extern void write_exp_msymbol (struct minimal_symbol *);
+extern void write_exp_msymbol (struct bound_minimal_symbol);
 
 extern void write_dollar_variable (struct stoken str);
 
index 1cc248d70f60091eb2f1be4f7a1297ff7cfaec32..68921b05dfd40ec2cc1df33285ffc38ae5bbe9e7 100644 (file)
@@ -1201,7 +1201,7 @@ address_info (char *exp, int from_tty)
   struct gdbarch *gdbarch;
   int regno;
   struct symbol *sym;
-  struct minimal_symbol *msymbol;
+  struct bound_minimal_symbol msymbol;
   long val;
   struct obj_section *section;
   CORE_ADDR load_addr, context_pc = 0;
@@ -1227,14 +1227,14 @@ address_info (char *exp, int from_tty)
          return;
        }
 
-      msymbol = lookup_minimal_symbol (exp, NULL, NULL);
+      msymbol = lookup_bound_minimal_symbol (exp);
 
-      if (msymbol != NULL)
+      if (msymbol.minsym != NULL)
        {
-         struct objfile *objfile = msymbol_objfile (msymbol);
+         struct objfile *objfile = msymbol.objfile;
 
          gdbarch = get_objfile_arch (objfile);
-         load_addr = SYMBOL_VALUE_ADDRESS (msymbol);
+         load_addr = SYMBOL_VALUE_ADDRESS (msymbol.minsym);
 
          printf_filtered ("Symbol \"");
          fprintf_symbol_filtered (gdb_stdout, exp,
@@ -1242,7 +1242,7 @@ address_info (char *exp, int from_tty)
          printf_filtered ("\" is at ");
          fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout);
          printf_filtered (" in a file compiled without debugging");
-         section = SYMBOL_OBJ_SECTION (objfile, msymbol);
+         section = SYMBOL_OBJ_SECTION (objfile, msymbol.minsym);
          if (section_is_overlay (section))
            {
              load_addr = overlay_unmapped_address (load_addr, section);
index 51291054a7cecbcade31d075946aa5c46c113d97..332864875550f455104dbd0c25e3fbc69a34b61b 100644 (file)
@@ -3399,7 +3399,8 @@ read_target_long_array (CORE_ADDR memaddr, unsigned int *myaddr,
 static int
 simple_read_overlay_table (void)
 {
-  struct minimal_symbol *novlys_msym, *ovly_table_msym;
+  struct minimal_symbol *novlys_msym;
+  struct bound_minimal_symbol ovly_table_msym;
   struct gdbarch *gdbarch;
   int word_size;
   enum bfd_endian byte_order;
@@ -3414,8 +3415,8 @@ simple_read_overlay_table (void)
       return 0;
     }
 
-  ovly_table_msym = lookup_minimal_symbol ("_ovly_table", NULL, NULL);
-  if (! ovly_table_msym)
+  ovly_table_msym = lookup_bound_minimal_symbol ("_ovly_table");
+  if (! ovly_table_msym.minsym)
     {
       error (_("Error reading inferior's overlay table: couldn't find "
              "`_ovly_table' array\n"
@@ -3423,7 +3424,7 @@ simple_read_overlay_table (void)
       return 0;
     }
 
-  gdbarch = get_objfile_arch (msymbol_objfile (ovly_table_msym));
+  gdbarch = get_objfile_arch (ovly_table_msym.objfile);
   word_size = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
   byte_order = gdbarch_byte_order (gdbarch);
 
@@ -3431,7 +3432,7 @@ simple_read_overlay_table (void)
                                      4, byte_order);
   cache_ovly_table
     = (void *) xmalloc (cache_novlys * sizeof (*cache_ovly_table));
-  cache_ovly_table_base = SYMBOL_VALUE_ADDRESS (ovly_table_msym);
+  cache_ovly_table_base = SYMBOL_VALUE_ADDRESS (ovly_table_msym.minsym);
   read_target_long_array (cache_ovly_table_base,
                           (unsigned int *) cache_ovly_table,
                           cache_novlys * 4, word_size, byte_order);
index 237b2582e9c91db14effae6493e603bc77d3c603..8076fe5bb30e87e107989f630cae576067acf5af 100644 (file)
@@ -101,8 +101,6 @@ struct symbol *lookup_symbol_aux_quick (struct objfile *objfile,
                                        const char *name,
                                        const domain_enum domain);
 
-static void print_msymbol_info (struct minimal_symbol *);
-
 void _initialize_symtab (void);
 
 /* */
@@ -2832,19 +2830,19 @@ skip_prologue_sal (struct symtab_and_line *sal)
     }
   else
     {
-      struct minimal_symbol *msymbol
-        = lookup_minimal_symbol_by_pc_section (sal->pc, sal->section).minsym;
+      struct bound_minimal_symbol msymbol
+        = lookup_minimal_symbol_by_pc_section (sal->pc, sal->section);
 
-      if (msymbol == NULL)
+      if (msymbol.minsym == NULL)
        {
          do_cleanups (old_chain);
          return;
        }
 
-      objfile = msymbol_objfile (msymbol);
-      pc = SYMBOL_VALUE_ADDRESS (msymbol);
-      section = SYMBOL_OBJ_SECTION (objfile, msymbol);
-      name = SYMBOL_LINKAGE_NAME (msymbol);
+      objfile = msymbol.objfile;
+      pc = SYMBOL_VALUE_ADDRESS (msymbol.minsym);
+      section = SYMBOL_OBJ_SECTION (objfile, msymbol.minsym);
+      name = SYMBOL_LINKAGE_NAME (msymbol.minsym);
     }
 
   gdbarch = get_objfile_arch (objfile);
@@ -3666,7 +3664,7 @@ search_symbols (char *regexp, enum search_domain kind,
                psr->block = i;
                psr->symtab = real_symtab;
                psr->symbol = sym;
-               psr->msymbol = NULL;
+               memset (&psr->msymbol, 0, sizeof (psr->msymbol));
                psr->next = NULL;
                if (tail == NULL)
                  found = psr;
@@ -3719,7 +3717,8 @@ search_symbols (char *regexp, enum search_domain kind,
                        struct symbol_search *psr = (struct symbol_search *)
                          xmalloc (sizeof (struct symbol_search));
                        psr->block = i;
-                       psr->msymbol = msymbol;
+                       psr->msymbol.minsym = msymbol;
+                       psr->msymbol.objfile = objfile;
                        psr->symtab = NULL;
                        psr->symbol = NULL;
                        psr->next = NULL;
@@ -3783,20 +3782,20 @@ print_symbol_info (enum search_domain kind,
    for non-debugging symbols to gdb_stdout.  */
 
 static void
-print_msymbol_info (struct minimal_symbol *msymbol)
+print_msymbol_info (struct bound_minimal_symbol msymbol)
 {
-  struct gdbarch *gdbarch = get_objfile_arch (msymbol_objfile (msymbol));
+  struct gdbarch *gdbarch = get_objfile_arch (msymbol.objfile);
   char *tmp;
 
   if (gdbarch_addr_bit (gdbarch) <= 32)
-    tmp = hex_string_custom (SYMBOL_VALUE_ADDRESS (msymbol)
+    tmp = hex_string_custom (SYMBOL_VALUE_ADDRESS (msymbol.minsym)
                             & (CORE_ADDR) 0xffffffff,
                             8);
   else
-    tmp = hex_string_custom (SYMBOL_VALUE_ADDRESS (msymbol),
+    tmp = hex_string_custom (SYMBOL_VALUE_ADDRESS (msymbol.minsym),
                             16);
   printf_filtered ("%s  %s\n",
-                  tmp, SYMBOL_PRINT_NAME (msymbol));
+                  tmp, SYMBOL_PRINT_NAME (msymbol.minsym));
 }
 
 /* This is the guts of the commands "info functions", "info types", and
@@ -3831,7 +3830,7 @@ symtab_symbol_info (char *regexp, enum search_domain kind, int from_tty)
     {
       QUIT;
 
-      if (p->msymbol != NULL)
+      if (p->msymbol.minsym != NULL)
        {
          if (first)
            {
@@ -3928,7 +3927,7 @@ rbreak_command (char *regexp, int from_tty)
   make_cleanup (do_end_rbreak_breakpoints, NULL);
   for (p = ss; p != NULL; p = p->next)
     {
-      if (p->msymbol == NULL)
+      if (p->msymbol.minsym == NULL)
        {
          const char *fullname = symtab_to_fullname (p->symtab);
 
@@ -3954,7 +3953,7 @@ rbreak_command (char *regexp, int from_tty)
        }
       else
        {
-         int newlen = (strlen (SYMBOL_LINKAGE_NAME (p->msymbol)) + 3);
+         int newlen = (strlen (SYMBOL_LINKAGE_NAME (p->msymbol.minsym)) + 3);
 
          if (newlen > len)
            {
@@ -3962,12 +3961,12 @@ rbreak_command (char *regexp, int from_tty)
              len = newlen;
            }
          strcpy (string, "'");
-         strcat (string, SYMBOL_LINKAGE_NAME (p->msymbol));
+         strcat (string, SYMBOL_LINKAGE_NAME (p->msymbol.minsym));
          strcat (string, "'");
 
          break_command (string, from_tty);
          printf_filtered ("<function, no debug info> %s;\n",
-                          SYMBOL_PRINT_NAME (p->msymbol));
+                          SYMBOL_PRINT_NAME (p->msymbol.minsym));
        }
     }
 
index 32897aabb7da8511a365f0ad22d6dad234571eda..6d81507f57f929c909d096fda3c3d5e96520c4de 100644 (file)
@@ -1299,7 +1299,7 @@ struct symbol_search
 
   /* If msymbol is non-null, then a match was made on something for
      which only minimal_symbols exist.  */
-  struct minimal_symbol *msymbol;
+  struct bound_minimal_symbol msymbol;
 
   /* A link to the next match, or NULL for the end.  */
   struct symbol_search *next;
index f527550f37fd09d94a6123c742b3c23bc9f11a1e..f86b2835d548a82cde5a948de3363843f001ce27 100644 (file)
@@ -149,12 +149,12 @@ find_function_in_inferior (const char *name, struct objfile **objf_p)
     }
   else
     {
-      struct minimal_symbol *msymbol = 
-       lookup_minimal_symbol (name, NULL, NULL);
+      struct bound_minimal_symbol msymbol = 
+       lookup_bound_minimal_symbol (name);
 
-      if (msymbol != NULL)
+      if (msymbol.minsym != NULL)
        {
-         struct objfile *objfile = msymbol_objfile (msymbol);
+         struct objfile *objfile = msymbol.objfile;
          struct gdbarch *gdbarch = get_objfile_arch (objfile);
 
          struct type *type;
@@ -162,7 +162,7 @@ find_function_in_inferior (const char *name, struct objfile **objf_p)
          type = lookup_pointer_type (builtin_type (gdbarch)->builtin_char);
          type = lookup_function_type (type);
          type = lookup_pointer_type (type);
-         maddr = SYMBOL_VALUE_ADDRESS (msymbol);
+         maddr = SYMBOL_VALUE_ADDRESS (msymbol.minsym);
 
          if (objf_p)
            *objf_p = objfile;
index 8d635c7bc250db6efb999e3e78ba5416aa8356e8..09ab1bb4e2dcbaf80e1a7ec22ae6cf9b54d0aa13 100644 (file)
@@ -2773,18 +2773,18 @@ value_fn_field (struct value **arg1p, struct fn_field *f,
   struct type *ftype = TYPE_FN_FIELD_TYPE (f, j);
   const char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
   struct symbol *sym;
-  struct minimal_symbol *msym;
+  struct bound_minimal_symbol msym;
 
   sym = lookup_symbol (physname, 0, VAR_DOMAIN, 0);
   if (sym != NULL)
     {
-      msym = NULL;
+      memset (&msym, 0, sizeof (msym));
     }
   else
     {
       gdb_assert (sym == NULL);
-      msym = lookup_minimal_symbol (physname, NULL, NULL);
-      if (msym == NULL)
+      msym = lookup_bound_minimal_symbol (physname);
+      if (msym.minsym == NULL)
        return NULL;
     }
 
@@ -2797,12 +2797,12 @@ value_fn_field (struct value **arg1p, struct fn_field *f,
     {
       /* The minimal symbol might point to a function descriptor;
         resolve it to the actual code address instead.  */
-      struct objfile *objfile = msymbol_objfile (msym);
+      struct objfile *objfile = msym.objfile;
       struct gdbarch *gdbarch = get_objfile_arch (objfile);
 
       set_value_address (v,
        gdbarch_convert_from_func_ptr_addr
-          (gdbarch, SYMBOL_VALUE_ADDRESS (msym), &current_target));
+          (gdbarch, SYMBOL_VALUE_ADDRESS (msym.minsym), &current_target));
     }
 
   if (arg1p)