Code cleanup: Add objfile_name accessor
[deliverable/binutils-gdb.git] / gdb / objfiles.h
index 2b95ce47fc15cdb5158b82a1e0ee9ccb34e69ca8..8467aa4143b6112813193c2117f092bcd204c356 100644 (file)
@@ -1,6 +1,6 @@
 /* Definitions for symbol file management in GDB.
 
 /* Definitions for symbol file management in GDB.
 
-   Copyright (C) 1992-2004, 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 1992-2013 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 
    This file is part of GDB.
 
@@ -24,6 +24,7 @@
 #include "symfile.h"           /* For struct psymbol_allocation_list.  */
 #include "progspace.h"
 #include "registry.h"
 #include "symfile.h"           /* For struct psymbol_allocation_list.  */
 #include "progspace.h"
 #include "registry.h"
+#include "gdb_bfd.h"
 
 struct bcache;
 struct htab;
 
 struct bcache;
 struct htab;
@@ -123,7 +124,7 @@ struct obj_section
 
 /* Relocation offset applied to S.  */
 #define obj_section_offset(s)                                          \
 
 /* Relocation offset applied to S.  */
 #define obj_section_offset(s)                                          \
-  (((s)->objfile->section_offsets)->offsets[(s)->the_bfd_section->index])
+  (((s)->objfile->section_offsets)->offsets[gdb_bfd_section_index ((s)->objfile->obfd, (s)->the_bfd_section)])
 
 /* The memory address of section S (vma + offset).  */
 #define obj_section_addr(s)                                            \
 
 /* The memory address of section S (vma + offset).  */
 #define obj_section_addr(s)                                            \
@@ -174,6 +175,16 @@ struct objfile_per_bfd_storage
   /* Byte cache for file names.  */
 
   struct bcache *filename_cache;
   /* Byte cache for file names.  */
 
   struct bcache *filename_cache;
+
+  /* Byte cache for macros.  */
+  struct bcache *macro_cache;
+
+  /* The gdbarch associated with the BFD.  Note that this gdbarch is
+     determined solely from BFD information, without looking at target
+     information.  The gdbarch determined from a running target may
+     differ from this e.g. with respect to register types and names.  */
+
+  struct gdbarch *gdbarch;
 };
 
 /* Master structure for keeping track of each file from which
 };
 
 /* Master structure for keeping track of each file from which
@@ -194,10 +205,11 @@ struct objfile
 
     struct objfile *next;
 
 
     struct objfile *next;
 
-    /* The object file's name, tilde-expanded and absolute.  Malloc'd; free it
-       if you free this struct.  This pointer is never NULL.  */
+    /* The object file's name, tilde-expanded and absolute.  This
+       pointer is never NULL.  This does not have to be freed; it is
+       guaranteed to have a lifetime at least as long as the objfile.  */
 
 
-    char *name;
+    char *original_name;
 
     CORE_ADDR addr_low;
 
 
     CORE_ADDR addr_low;
 
@@ -243,23 +255,11 @@ struct objfile
 
     struct objfile_per_bfd_storage *per_bfd;
 
 
     struct objfile_per_bfd_storage *per_bfd;
 
-    /* The gdbarch associated with the BFD.  Note that this gdbarch is
-       determined solely from BFD information, without looking at target
-       information.  The gdbarch determined from a running target may
-       differ from this e.g. with respect to register types and names.  */
-
-    struct gdbarch *gdbarch;
-
     /* The modification timestamp of the object file, as of the last time
        we read its symbols.  */
 
     long mtime;
 
     /* The modification timestamp of the object file, as of the last time
        we read its symbols.  */
 
     long mtime;
 
-    /* Cached 32-bit CRC as computed by gnu_debuglink_crc32.  CRC32 is valid
-       iff CRC32_P.  */
-    unsigned long crc32;
-    int crc32_p;
-
     /* Obstack to hold objects that should be freed when we load a new symbol
        table from this object file.  */
 
     /* Obstack to hold objects that should be freed when we load a new symbol
        table from this object file.  */
 
@@ -269,7 +269,6 @@ struct objfile
        will not change.  */
 
     struct psymbol_bcache *psymbol_cache; /* Byte cache for partial syms.  */
        will not change.  */
 
     struct psymbol_bcache *psymbol_cache; /* Byte cache for partial syms.  */
-    struct bcache *macro_cache;           /* Byte cache for macros.  */
 
     /* Hash table for mapping symbol names to demangled names.  Each
        entry in the hash table is actually two consecutive strings,
 
     /* Hash table for mapping symbol names to demangled names.  Each
        entry in the hash table is actually two consecutive strings,
@@ -319,30 +318,7 @@ struct objfile
 
     struct entry_info ei;
 
 
     struct entry_info ei;
 
-    /* Information about stabs.  Will be filled in with a dbx_symfile_info
-       struct by those readers that need it.  */
-    /* NOTE: cagney/2004-10-23: This has been replaced by per-objfile
-       data points implemented using "data" and "num_data" below.  For
-       an example of how to use this replacement, see "objfile_data"
-       in "mips-tdep.c".  */
-
-    struct dbx_symfile_info *deprecated_sym_stab_info;
-
-    /* Hook for information for use by the symbol reader (currently used
-       for information shared by sym_init and sym_read).  It is
-       typically a pointer to malloc'd memory.  The symbol reader's finish
-       function is responsible for freeing the memory thusly allocated.  */
-    /* NOTE: cagney/2004-10-23: This has been replaced by per-objfile
-       data points implemented using "data" and "num_data" below.  For
-       an example of how to use this replacement, see "objfile_data"
-       in "mips-tdep.c".  */
-
-    void *deprecated_sym_private;
-
     /* Per objfile data-pointers required by other GDB modules.  */
     /* Per objfile data-pointers required by other GDB modules.  */
-    /* FIXME: kettenis/20030711: This mechanism could replace
-       deprecated_sym_stab_info and deprecated_sym_private
-       entirely.  */
 
     REGISTRY_FIELDS;
 
 
     REGISTRY_FIELDS;
 
@@ -374,9 +350,10 @@ struct objfile
        among other things, is used to map pc addresses into sections.
        SECTIONS points to the first entry in the table, and
        SECTIONS_END points to the first location past the last entry
        among other things, is used to map pc addresses into sections.
        SECTIONS points to the first entry in the table, and
        SECTIONS_END points to the first location past the last entry
-       in the table.  The table is stored on the objfile_obstack.
-       There is no particular order to the sections in this table, and it
-       only contains sections we care about (e.g. non-empty, SEC_ALLOC).  */
+       in the table.  The table is stored on the objfile_obstack.  The
+       sections are indexed by the BFD section index; but the
+       structure data is only valid for certain sections
+       (e.g. non-empty, SEC_ALLOC).  */
 
     struct obj_section *sections, *sections_end;
 
 
     struct obj_section *sections, *sections_end;
 
@@ -452,19 +429,12 @@ struct objfile
 
 #define OBJF_MAINLINE (1 << 5)
 
 
 #define OBJF_MAINLINE (1 << 5)
 
-/* The object file that contains the runtime common minimal symbols
-   for SunOS4.  Note that this objfile has no associated BFD.  */
-
-extern struct objfile *rt_common_objfile;
-
 /* Declarations for functions defined in objfiles.c */
 
 extern struct objfile *allocate_objfile (bfd *, int);
 
 extern struct gdbarch *get_objfile_arch (struct objfile *);
 
 /* Declarations for functions defined in objfiles.c */
 
 extern struct objfile *allocate_objfile (bfd *, int);
 
 extern struct gdbarch *get_objfile_arch (struct objfile *);
 
-extern void init_entry_point_info (struct objfile *);
-
 extern int entry_point_address_query (CORE_ADDR *entry_p);
 
 extern CORE_ADDR entry_point_address (void);
 extern int entry_point_address_query (CORE_ADDR *entry_p);
 
 extern CORE_ADDR entry_point_address (void);
@@ -492,7 +462,8 @@ extern struct cleanup *make_cleanup_free_objfile (struct objfile *);
 
 extern void free_all_objfiles (void);
 
 
 extern void free_all_objfiles (void);
 
-extern void objfile_relocate (struct objfile *, struct section_offsets *);
+extern void objfile_relocate (struct objfile *, const struct section_offsets *);
+extern void objfile_rebase (struct objfile *, CORE_ADDR);
 
 extern int objfile_has_partial_symbols (struct objfile *objfile);
 
 
 extern int objfile_has_partial_symbols (struct objfile *objfile);
 
@@ -519,12 +490,38 @@ extern int have_minimal_symbols (void);
 
 extern struct obj_section *find_pc_section (CORE_ADDR pc);
 
 
 extern struct obj_section *find_pc_section (CORE_ADDR pc);
 
-extern int in_plt_section (CORE_ADDR, char *);
+/* Return non-zero if PC is in a section called NAME.  */
+extern int pc_in_section (CORE_ADDR, char *);
+
+/* Return non-zero if PC is in a SVR4-style procedure linkage table
+   section.  */
+
+static inline int
+in_plt_section (CORE_ADDR pc)
+{
+  return pc_in_section (pc, ".plt");
+}
 
 /* Keep a registry of per-objfile data-pointers required by other GDB
    modules.  */
 DECLARE_REGISTRY(objfile);
 
 
 /* Keep a registry of per-objfile data-pointers required by other GDB
    modules.  */
 DECLARE_REGISTRY(objfile);
 
+/* In normal use, the section map will be rebuilt by find_pc_section
+   if objfiles have been added, removed or relocated since it was last
+   called.  Calling inhibit_section_map_updates will inhibit this
+   behavior until resume_section_map_updates is called.  If you call
+   inhibit_section_map_updates you must ensure that every call to
+   find_pc_section in the inhibited region relates to a section that
+   is already in the section map and has not since been removed or
+   relocated.  */
+extern void inhibit_section_map_updates (struct program_space *pspace);
+
+/* Resume automatically rebuilding the section map as required.  */
+extern void resume_section_map_updates (struct program_space *pspace);
+
+/* Version of the above suitable for use as a cleanup.  */
+extern void resume_section_map_updates_cleanup (void *arg);
+
 extern void default_iterate_over_objfiles_in_search_order
   (struct gdbarch *gdbarch,
    iterate_over_objfiles_in_search_order_cb_ftype *cb,
 extern void default_iterate_over_objfiles_in_search_order
   (struct gdbarch *gdbarch,
    iterate_over_objfiles_in_search_order_cb_ftype *cb,
@@ -538,7 +535,7 @@ extern void default_iterate_over_objfiles_in_search_order
 /* Traverse all object files in program space SS.  */
 
 #define ALL_PSPACE_OBJFILES(ss, obj)                                   \
 /* Traverse all object files in program space SS.  */
 
 #define ALL_PSPACE_OBJFILES(ss, obj)                                   \
-  for ((obj) = ss->objfiles; (obj) != NULL; (obj) = (obj)->next)       \
+  for ((obj) = ss->objfiles; (obj) != NULL; (obj) = (obj)->next)
 
 #define ALL_PSPACE_OBJFILES_SAFE(ss, obj, nxt)         \
   for ((obj) = ss->objfiles;                   \
 
 #define ALL_PSPACE_OBJFILES_SAFE(ss, obj, nxt)         \
   for ((obj) = ss->objfiles;                   \
@@ -602,7 +599,12 @@ extern void default_iterate_over_objfiles_in_search_order
     ALL_OBJFILE_MSYMBOLS (objfile, m)
 
 #define ALL_OBJFILE_OSECTIONS(objfile, osect)  \
     ALL_OBJFILE_MSYMBOLS (objfile, m)
 
 #define ALL_OBJFILE_OSECTIONS(objfile, osect)  \
-  for (osect = objfile->sections; osect < objfile->sections_end; osect++)
+  for (osect = objfile->sections; osect < objfile->sections_end; osect++) \
+    if (osect->the_bfd_section == NULL)                                        \
+      {                                                                        \
+       /* Nothing.  */                                                 \
+      }                                                                        \
+    else
 
 /* Traverse all obj_sections in all objfiles in the current program
    space.
 
 /* Traverse all obj_sections in all objfiles in the current program
    space.
@@ -638,9 +640,7 @@ extern void default_iterate_over_objfiles_in_search_order
        ? ((objfile) = (objfile)->next,                                 \
           (objfile) != NULL ? (osect) = (objfile)->sections_end : 0)   \
        : 0))                                                           \
        ? ((objfile) = (objfile)->next,                                 \
           (objfile) != NULL ? (osect) = (objfile)->sections_end : 0)   \
        : 0))                                                           \
-    for ((osect) = (objfile)->sections;                                        \
-        (osect) < (objfile)->sections_end;                             \
-        (osect)++)
+    ALL_OBJFILE_OSECTIONS (objfile, osect)
 
 #define SECT_OFF_DATA(objfile) \
      ((objfile->sect_index_data == -1) \
 
 #define SECT_OFF_DATA(objfile) \
      ((objfile->sect_index_data == -1) \
@@ -673,4 +673,6 @@ extern void default_iterate_over_objfiles_in_search_order
 
 void set_objfile_per_bfd (struct objfile *obj);
 
 
 void set_objfile_per_bfd (struct objfile *obj);
 
+const char *objfile_name (const struct objfile *objfile);
+
 #endif /* !defined (OBJFILES_H) */
 #endif /* !defined (OBJFILES_H) */
This page took 0.0267 seconds and 4 git commands to generate.