sim: profile: implement --profile-file backend
[deliverable/binutils-gdb.git] / gdb / minsyms.c
index 64d20d2d7c0075168d11201b2c01dcffdb57fa2f..287f9de875e8ef90e52f66c7a97df9c8c3d476ec 100644 (file)
@@ -1,6 +1,6 @@
 /* GDB routines for manipulating the minimal symbol tables.
    Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-   2002, 2003, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
+   2002, 2003, 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Cygnus Support, using pieces from other GDB modules.
 
    This file is part of GDB.
@@ -216,7 +216,7 @@ lookup_minimal_symbol (const char *name, const char *sfile,
        objfile = objfile->next)
     {
       if (objf == NULL || objf == objfile
-         || objf->separate_debug_objfile == objfile)
+         || objf == objfile->separate_debug_objfile_backlink)
        {
          /* Do two passes: the first over the ordinary hash table,
             and the second over the demangled hash table.  */
@@ -324,7 +324,7 @@ lookup_minimal_symbol_text (const char *name, struct objfile *objf)
        objfile = objfile->next)
     {
       if (objf == NULL || objf == objfile
-         || objf->separate_debug_objfile == objfile)
+         || objf == objfile->separate_debug_objfile_backlink)
        {
          for (msymbol = objfile->msymbol_hash[hash];
               msymbol != NULL && found_symbol == NULL;
@@ -377,7 +377,7 @@ lookup_minimal_symbol_by_pc_name (CORE_ADDR pc, const char *name,
        objfile = objfile->next)
     {
       if (objf == NULL || objf == objfile
-         || objf->separate_debug_objfile == objfile)
+         || objf == objfile->separate_debug_objfile_backlink)
        {
          for (msymbol = objfile->msymbol_hash[hash];
               msymbol != NULL;
@@ -416,7 +416,7 @@ lookup_minimal_symbol_solib_trampoline (const char *name,
        objfile = objfile->next)
     {
       if (objf == NULL || objf == objfile
-         || objf->separate_debug_objfile == objfile)
+         || objf == objfile->separate_debug_objfile_backlink)
        {
          for (msymbol = objfile->msymbol_hash[hash];
               msymbol != NULL && found_symbol == NULL;
@@ -473,11 +473,10 @@ lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc,
      no telling which one will have the minimal symbols.  */
 
   gdb_assert (section != NULL);
-  objfile = section->objfile;
-  if (objfile->separate_debug_objfile)
-    objfile = objfile->separate_debug_objfile;
 
-  for (; objfile != NULL; objfile = objfile->separate_debug_objfile_backlink)
+  for (objfile = section->objfile;
+       objfile != NULL;
+       objfile = objfile_separate_debug_iterate (section->objfile, objfile))
     {
       /* If this objfile has a minimal symbol table, go search it using
          a binary search.  Note that a minimal symbol table always consists
@@ -694,6 +693,37 @@ lookup_minimal_symbol_by_pc (CORE_ADDR pc)
 {
   return lookup_minimal_symbol_by_pc_section (pc, NULL);
 }
+
+/* Find the minimal symbol named NAME, and return both the minsym
+   struct and its objfile.  This only checks the linkage name.  Sets
+   *OBJFILE_P and returns the minimal symbol, if it is found.  If it
+   is not found, returns NULL.  */
+
+struct minimal_symbol *
+lookup_minimal_symbol_and_objfile (const char *name,
+                                  struct objfile **objfile_p)
+{
+  struct objfile *objfile;
+  unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
+
+  ALL_OBJFILES (objfile)
+    {
+      struct minimal_symbol *msym;
+
+      for (msym = objfile->msymbol_hash[hash];
+          msym != NULL;
+          msym = msym->hash_next)
+       {
+         if (strcmp (SYMBOL_LINKAGE_NAME (msym), name) == 0)
+           {
+             *objfile_p = objfile;
+             return msym;
+           }
+       }
+    }
+
+  return 0;
+}
 \f
 
 /* Return leading symbol character for a BFD. If BFD is NULL,
@@ -757,11 +787,12 @@ prim_record_minimal_symbol (const char *name, CORE_ADDR address,
    newly created.  */
 
 struct minimal_symbol *
-prim_record_minimal_symbol_and_info (const char *name, CORE_ADDR address,
-                                    enum minimal_symbol_type ms_type,
-                                    int section,
-                                    asection *bfd_section,
-                                    struct objfile *objfile)
+prim_record_minimal_symbol_full (const char *name, int name_len, int copy_name,
+                                CORE_ADDR address,
+                                enum minimal_symbol_type ms_type,
+                                int section,
+                                asection *bfd_section,
+                                struct objfile *objfile)
 {
   struct obj_section *obj_section;
   struct msym_bunch *new;
@@ -780,7 +811,10 @@ prim_record_minimal_symbol_and_info (const char *name, CORE_ADDR address,
   /* It's safe to strip the leading char here once, since the name
      is also stored stripped in the minimal symbol table. */
   if (name[0] == get_symbol_leading_char (objfile->obfd))
-    ++name;
+    {
+      ++name;
+      --name_len;
+    }
 
   if (ms_type == mst_file_text && strncmp (name, "__gnu_compiled", 14) == 0)
     return (NULL);
@@ -795,7 +829,7 @@ prim_record_minimal_symbol_and_info (const char *name, CORE_ADDR address,
   msymbol = &msym_bunch->contents[msym_bunch_index];
   SYMBOL_INIT_LANGUAGE_SPECIFIC (msymbol, language_unknown);
   SYMBOL_LANGUAGE (msymbol) = language_auto;
-  SYMBOL_SET_NAMES (msymbol, (char *)name, strlen (name), objfile);
+  SYMBOL_SET_NAMES (msymbol, name, name_len, copy_name, objfile);
 
   SYMBOL_VALUE_ADDRESS (msymbol) = address;
   SYMBOL_SECTION (msymbol) = section;
@@ -828,6 +862,21 @@ prim_record_minimal_symbol_and_info (const char *name, CORE_ADDR address,
   return msymbol;
 }
 
+/* Record a minimal symbol in the msym bunches.  Returns the symbol
+   newly created.  */
+
+struct minimal_symbol *
+prim_record_minimal_symbol_and_info (const char *name, CORE_ADDR address,
+                                    enum minimal_symbol_type ms_type,
+                                    int section,
+                                    asection *bfd_section,
+                                    struct objfile *objfile)
+{
+  return prim_record_minimal_symbol_full (name, strlen (name), 1,
+                                         address, ms_type, section,
+                                         bfd_section, objfile);
+}
+
 /* Compare two minimal symbols by address and return a signed result based
    on unsigned comparisons, so that we sort into unsigned numeric order.  
    Within groups with the same address, sort by name.  */
This page took 0.030731 seconds and 4 git commands to generate.