Implement get_syscall_trapinfo for aarch64-linux
[deliverable/binutils-gdb.git] / gdb / minsyms.c
index 6f1fb35b71fa8bc295a91c5b6933ed3052638a8e..b47840264b78258031212a534251563a79606259 100644 (file)
@@ -1,5 +1,5 @@
 /* GDB routines for manipulating the minimal symbol tables.
 /* GDB routines for manipulating the minimal symbol tables.
-   Copyright (C) 1992-2014 Free Software Foundation, Inc.
+   Copyright (C) 1992-2016 Free Software Foundation, Inc.
    Contributed by Cygnus Support, using pieces from other GDB modules.
 
    This file is part of GDB.
    Contributed by Cygnus Support, using pieces from other GDB modules.
 
    This file is part of GDB.
@@ -38,7 +38,6 @@
 
 #include "defs.h"
 #include <ctype.h>
 
 #include "defs.h"
 #include <ctype.h>
-#include <string.h>
 #include "symtab.h"
 #include "bfd.h"
 #include "filenames.h"
 #include "symtab.h"
 #include "bfd.h"
 #include "filenames.h"
@@ -51,6 +50,7 @@
 #include "cp-support.h"
 #include "language.h"
 #include "cli/cli-utils.h"
 #include "cp-support.h"
 #include "language.h"
 #include "cli/cli-utils.h"
+#include "symbol.h"
 
 /* Accumulate the minimal symbols for each objfile in bunches of BUNCH_SIZE.
    At the end, copy them all into one newly allocated location on an objfile's
 
 /* Accumulate the minimal symbols for each objfile in bunches of BUNCH_SIZE.
    At the end, copy them all into one newly allocated location on an objfile's
@@ -203,6 +203,14 @@ lookup_minimal_symbol (const char *name, const char *sfile,
             and the second over the demangled hash table.  */
         int pass;
 
             and the second over the demangled hash table.  */
         int pass;
 
+       if (symbol_lookup_debug)
+         {
+           fprintf_unfiltered (gdb_stdlog,
+                               "lookup_minimal_symbol (%s, %s, %s)\n",
+                               name, sfile != NULL ? sfile : "NULL",
+                               objfile_debug_name (objfile));
+         }
+
         for (pass = 1; pass <= 2 && found_symbol.minsym == NULL; pass++)
            {
             /* Select hash list according to pass.  */
         for (pass = 1; pass <= 2 && found_symbol.minsym == NULL; pass++)
            {
             /* Select hash list according to pass.  */
@@ -282,13 +290,42 @@ lookup_minimal_symbol (const char *name, const char *sfile,
 
   /* External symbols are best.  */
   if (found_symbol.minsym != NULL)
 
   /* External symbols are best.  */
   if (found_symbol.minsym != NULL)
-    return found_symbol;
+    {
+      if (symbol_lookup_debug)
+       {
+         fprintf_unfiltered (gdb_stdlog,
+                             "lookup_minimal_symbol (...) = %s"
+                             " (external)\n",
+                             host_address_to_string (found_symbol.minsym));
+       }
+      return found_symbol;
+    }
 
   /* File-local symbols are next best.  */
   if (found_file_symbol.minsym != NULL)
 
   /* File-local symbols are next best.  */
   if (found_file_symbol.minsym != NULL)
-    return found_file_symbol;
+    {
+      if (symbol_lookup_debug)
+       {
+         fprintf_unfiltered (gdb_stdlog,
+                             "lookup_minimal_symbol (...) = %s"
+                             " (file-local)\n",
+                             host_address_to_string
+                               (found_file_symbol.minsym));
+       }
+      return found_file_symbol;
+    }
 
   /* Symbols for shared library trampolines are next best.  */
 
   /* Symbols for shared library trampolines are next best.  */
+  if (symbol_lookup_debug)
+    {
+      fprintf_unfiltered (gdb_stdlog,
+                         "lookup_minimal_symbol (...) = %s%s\n",
+                         trampoline_symbol.minsym != NULL
+                         ? host_address_to_string (trampoline_symbol.minsym)
+                         : "NULL",
+                         trampoline_symbol.minsym != NULL
+                         ? " (trampoline)" : "");
+    }
   return trampoline_symbol;
 }
 
   return trampoline_symbol;
 }
 
@@ -300,6 +337,21 @@ lookup_bound_minimal_symbol (const char *name)
   return lookup_minimal_symbol (name, NULL, NULL);
 }
 
   return lookup_minimal_symbol (name, NULL, NULL);
 }
 
+/* See common/symbol.h.  */
+
+int
+find_minimal_symbol_address (const char *name, CORE_ADDR *addr,
+                            struct objfile *objfile)
+{
+  struct bound_minimal_symbol sym
+    = lookup_minimal_symbol (name, NULL, objfile);
+
+  if (sym.minsym != NULL)
+    *addr = BMSYMBOL_VALUE_ADDRESS (sym);
+
+  return sym.minsym == NULL;
+}
+
 /* See minsyms.h.  */
 
 void
 /* See minsyms.h.  */
 
 void
@@ -498,7 +550,7 @@ lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc_in,
 {
   int lo;
   int hi;
 {
   int lo;
   int hi;
-  int new;
+  int newobj;
   struct objfile *objfile;
   struct minimal_symbol *msymbol;
   struct minimal_symbol *best_symbol = NULL;
   struct objfile *objfile;
   struct minimal_symbol *msymbol;
   struct minimal_symbol *best_symbol = NULL;
@@ -565,15 +617,15 @@ lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc_in,
                {
                  /* pc is still strictly less than highest address.  */
                  /* Note "new" will always be >= lo.  */
                {
                  /* pc is still strictly less than highest address.  */
                  /* Note "new" will always be >= lo.  */
-                 new = (lo + hi) / 2;
-                 if ((MSYMBOL_VALUE_RAW_ADDRESS (&msymbol[new]) >= pc)
-                     || (lo == new))
+                 newobj = (lo + hi) / 2;
+                 if ((MSYMBOL_VALUE_RAW_ADDRESS (&msymbol[newobj]) >= pc)
+                     || (lo == newobj))
                    {
                    {
-                     hi = new;
+                     hi = newobj;
                    }
                  else
                    {
                    }
                  else
                    {
-                     lo = new;
+                     lo = newobj;
                    }
                }
 
                    }
                }
 
@@ -645,10 +697,10 @@ lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc_in,
                     symbol isn't an object or function (e.g. a
                     label), or it may just mean that the size was not
                     specified.  */
                     symbol isn't an object or function (e.g. a
                     label), or it may just mean that the size was not
                     specified.  */
-                 if (MSYMBOL_SIZE (&msymbol[hi]) == 0
-                     && best_zero_sized == -1)
+                 if (MSYMBOL_SIZE (&msymbol[hi]) == 0)
                    {
                    {
-                     best_zero_sized = hi;
+                     if (best_zero_sized == -1)
+                       best_zero_sized = hi;
                      hi--;
                      continue;
                    }
                      hi--;
                      continue;
                    }
@@ -922,8 +974,7 @@ prim_record_minimal_symbol_full (const char *name, int name_len, int copy_name,
                                 int section,
                                 struct objfile *objfile)
 {
                                 int section,
                                 struct objfile *objfile)
 {
-  struct obj_section *obj_section;
-  struct msym_bunch *new;
+  struct msym_bunch *newobj;
   struct minimal_symbol *msymbol;
 
   /* Don't put gcc_compiled, __gnu_compiled_cplus, and friends into
   struct minimal_symbol *msymbol;
 
   /* Don't put gcc_compiled, __gnu_compiled_cplus, and friends into
@@ -944,15 +995,15 @@ prim_record_minimal_symbol_full (const char *name, int name_len, int copy_name,
       --name_len;
     }
 
       --name_len;
     }
 
-  if (ms_type == mst_file_text && strncmp (name, "__gnu_compiled", 14) == 0)
+  if (ms_type == mst_file_text && startswith (name, "__gnu_compiled"))
     return (NULL);
 
   if (msym_bunch_index == BUNCH_SIZE)
     {
     return (NULL);
 
   if (msym_bunch_index == BUNCH_SIZE)
     {
-      new = XCNEW (struct msym_bunch);
+      newobj = XCNEW (struct msym_bunch);
       msym_bunch_index = 0;
       msym_bunch_index = 0;
-      new->next = msym_bunch;
-      msym_bunch = new;
+      newobj->next = msym_bunch;
+      msym_bunch = newobj;
     }
   msymbol = &msym_bunch->contents[msym_bunch_index];
   MSYMBOL_SET_LANGUAGE (msymbol, language_auto,
     }
   msymbol = &msym_bunch->contents[msym_bunch_index];
   MSYMBOL_SET_LANGUAGE (msymbol, language_auto,
@@ -1255,7 +1306,7 @@ install_minimal_symbols (struct objfile *objfile)
 
       mcount = compact_minimal_symbols (msymbols, mcount, objfile);
 
 
       mcount = compact_minimal_symbols (msymbols, mcount, objfile);
 
-      obstack_blank (&objfile->per_bfd->storage_obstack,
+      obstack_blank_fast (&objfile->per_bfd->storage_obstack,
               (mcount + 1 - alloc_count) * sizeof (struct minimal_symbol));
       msymbols = (struct minimal_symbol *)
        obstack_finish (&objfile->per_bfd->storage_obstack);
               (mcount + 1 - alloc_count) * sizeof (struct minimal_symbol));
       msymbols = (struct minimal_symbol *)
        obstack_finish (&objfile->per_bfd->storage_obstack);
This page took 0.026064 seconds and 4 git commands to generate.