*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / minsyms.c
index 55f2d4a569542cba714adc759f68b67effc716dc..485079761371d916b66bd97a928fe808f67da9d3 100644 (file)
@@ -7,7 +7,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -16,9 +16,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
 /* This file contains support routines for creating, manipulating, and
@@ -167,14 +165,12 @@ lookup_minimal_symbol (const char *name, const char *sfile,
   unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
   unsigned int dem_hash = msymbol_hash_iw (name) % MINIMAL_SYMBOL_HASH_SIZE;
 
-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
   if (sfile != NULL)
     {
       char *p = strrchr (sfile, '/');
       if (p != NULL)
        sfile = p + 1;
     }
-#endif
 
   for (objfile = object_files;
        objfile != NULL && found_symbol == NULL;
@@ -211,18 +207,9 @@ lookup_minimal_symbol (const char *name, const char *sfile,
                       case mst_file_text:
                       case mst_file_data:
                       case mst_file_bss:
-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
                         if (sfile == NULL
                            || strcmp (msymbol->filename, sfile) == 0)
                           found_file_symbol = msymbol;
-#else
-                        /* We have neither the ability nor the need to
-                           deal with the SFILE parameter.  If we find
-                           more than one symbol, just return the latest
-                           one (the user can't expect useful behavior in
-                           that case).  */
-                        found_file_symbol = msymbol;
-#endif
                         break;
 
                       case mst_solib_trampoline:
@@ -387,20 +374,20 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc, asection *section)
   if (pc_section == NULL)
     return NULL;
 
-  /* NOTE: cagney/2004-01-27: Removed code (added 2003-07-19) that was
-     trying to force the PC into a valid section as returned by
-     find_pc_section.  It broke IRIX 6.5 mdebug which relies on this
-     code returning an absolute symbol - the problem was that
-     find_pc_section wasn't returning an absolute section and hence
-     the code below would skip over absolute symbols.  Since the
-     original problem was with finding a frame's function, and that
-     uses [indirectly] lookup_minimal_symbol_by_pc, the original
-     problem has been fixed by having that function use
-     find_pc_section.  */
+  /* We can not require the symbol found to be in pc_section, because
+     e.g. IRIX 6.5 mdebug relies on this code returning an absolute
+     symbol - but find_pc_section won't return an absolute section and
+     hence the code below would skip over absolute symbols.  We can
+     still take advantage of the call to find_pc_section, though - the
+     object file still must match.  In case we have separate debug
+     files, search both the file and its separate debug file.  There's
+     no telling which one will have the minimal symbols.  */
 
-  for (objfile = object_files;
-       objfile != NULL;
-       objfile = objfile->next)
+  objfile = pc_section->objfile;
+  if (objfile->separate_debug_objfile)
+    objfile = objfile->separate_debug_objfile;
+
+  for (; objfile != NULL; objfile = objfile->separate_debug_objfile_backlink)
     {
       /* If this objfile has a minimal symbol table, go search it using
          a binary search.  Note that a minimal symbol table always consists
@@ -510,6 +497,22 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc, asection *section)
                      continue;
                    }
 
+                 /* If we are past the end of the current symbol, try
+                    the previous symbol if it has a larger overlapping
+                    size.  This happens on i686-pc-linux-gnu with glibc;
+                    the nocancel variants of system calls are inside
+                    the cancellable variants, but both have sizes.  */
+                 if (hi > 0
+                     && MSYMBOL_SIZE (&msymbol[hi]) != 0
+                     && pc >= (SYMBOL_VALUE_ADDRESS (&msymbol[hi])
+                               + MSYMBOL_SIZE (&msymbol[hi]))
+                     && pc < (SYMBOL_VALUE_ADDRESS (&msymbol[hi - 1])
+                              + MSYMBOL_SIZE (&msymbol[hi - 1])))
+                   {
+                     hi--;
+                     continue;
+                   }
+
                  /* Otherwise, this symbol must be as good as we're going
                     to get.  */
                  break;
@@ -1031,7 +1034,7 @@ lookup_solib_trampoline_symbol_by_pc (CORE_ADDR pc)
    a duplicate function in case this matters someday.  */
 
 CORE_ADDR
-find_solib_trampoline_target (CORE_ADDR pc)
+find_solib_trampoline_target (struct frame_info *frame, CORE_ADDR pc)
 {
   struct objfile *objfile;
   struct minimal_symbol *msymbol;
This page took 0.025554 seconds and 4 git commands to generate.