Fix memory leak in watch_main_source_file_lossage.
[deliverable/binutils-gdb.git] / gdb / objfiles.c
index dba13fbbfba04728a4b67454918a3ef8ef292002..38a365ca678c8e48bc92b2427af72096245c9ddd 100644 (file)
 #include "expression.h"
 #include "parser-defs.h"
 
-#include "gdb_assert.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include "gdb_obstack.h"
-#include <string.h>
 #include "hashtab.h"
 
 #include "breakpoint.h"
@@ -294,7 +292,6 @@ allocate_objfile (bfd *abfd, const char *name, int flags)
   /* We could use obstack_specify_allocation here instead, but
      gdb_obstack.h specifies the alloc/dealloc functions.  */
   obstack_init (&objfile->objfile_obstack);
-  terminate_minimal_symbol_table (objfile);
 
   objfile_alloc_data (objfile);
 
@@ -334,6 +331,8 @@ allocate_objfile (bfd *abfd, const char *name, int flags)
   objfile->per_bfd = get_objfile_bfd_data (objfile, abfd);
   objfile->pspace = current_program_space;
 
+  terminate_minimal_symbol_table (objfile);
+
   /* Initialize the section indexes for this objfile, so that we can
      later detect if they are used w/o being properly assigned to.  */
 
@@ -367,8 +366,9 @@ allocate_objfile (bfd *abfd, const char *name, int flags)
 }
 
 /* Retrieve the gdbarch associated with OBJFILE.  */
+
 struct gdbarch *
-get_objfile_arch (struct objfile *objfile)
+get_objfile_arch (const struct objfile *objfile)
 {
   return objfile->per_bfd->gdbarch;
 }
@@ -745,7 +745,7 @@ objfile_relocate1 (struct objfile *objfile,
     ALL_OBJFILE_SYMTABS (objfile, s)
     {
       struct linetable *l;
-      struct blockvector *bv;
+      const struct blockvector *bv;
       int i;
 
       /* First the line table.  */
@@ -800,19 +800,6 @@ objfile_relocate1 (struct objfile *objfile,
   if (objfile->sf)
     objfile->sf->qf->relocate (objfile, new_offsets, delta);
 
-  {
-    struct minimal_symbol *msym;
-
-    ALL_OBJFILE_MSYMBOLS (objfile, msym)
-      if (MSYMBOL_SECTION (msym) >= 0)
-       SET_MSYMBOL_VALUE_ADDRESS (msym, (MSYMBOL_VALUE_ADDRESS (msym)
-                                         + ANOFFSET (delta,
-                                                     MSYMBOL_SECTION (msym))));
-  }
-  /* Relocating different sections by different amounts may cause the symbols
-     to be out of order.  */
-  msymbols_sort (objfile);
-
   {
     int i;
 
@@ -832,11 +819,6 @@ objfile_relocate1 (struct objfile *objfile,
                                obj_section_addr (s));
     }
 
-  /* Relocating probes.  */
-  if (objfile->sf && objfile->sf->sym_probe_fns)
-    objfile->sf->sym_probe_fns->sym_relocate_probe (objfile,
-                                                   new_offsets, delta);
-
   /* Data changed.  */
   return 1;
 }
@@ -1042,7 +1024,7 @@ have_minimal_symbols (void)
 
   ALL_OBJFILES (ofp)
   {
-    if (ofp->minimal_symbol_count > 0)
+    if (ofp->per_bfd->minimal_symbol_count > 0)
       {
        return 1;
       }
@@ -1470,6 +1452,22 @@ is_addr_in_objfile (CORE_ADDR addr, const struct objfile *objfile)
   return 0;
 }
 
+int
+shared_objfile_contains_address_p (struct program_space *pspace,
+                                  CORE_ADDR address)
+{
+  struct objfile *objfile;
+
+  ALL_PSPACE_OBJFILES (pspace, objfile)
+    {
+      if ((objfile->flags & OBJF_SHARED) != 0
+         && is_addr_in_objfile (address, objfile))
+       return 1;
+    }
+
+  return 0;
+}
+
 /* The default implementation for the "iterate_over_objfiles_in_search_order"
    gdbarch method.  It is equivalent to use the ALL_OBJFILES macro,
    searching the objfiles in the order they are stored internally,
This page took 0.024969 seconds and 4 git commands to generate.