GDB (API)
/home/stan/gdb/src/gdb/objfiles.h
Go to the documentation of this file.
00001 /* Definitions for symbol file management in GDB.
00002 
00003    Copyright (C) 1992-2013 Free Software Foundation, Inc.
00004 
00005    This file is part of GDB.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 3 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00019 
00020 #if !defined (OBJFILES_H)
00021 #define OBJFILES_H
00022 
00023 #include "gdb_obstack.h"        /* For obstack internals.  */
00024 #include "symfile.h"            /* For struct psymbol_allocation_list.  */
00025 #include "progspace.h"
00026 #include "registry.h"
00027 #include "gdb_bfd.h"
00028 
00029 struct bcache;
00030 struct htab;
00031 struct symtab;
00032 struct objfile_data;
00033 
00034 /* This structure maintains information on a per-objfile basis about the
00035    "entry point" of the objfile, and the scope within which the entry point
00036    exists.  It is possible that gdb will see more than one objfile that is
00037    executable, each with its own entry point.
00038 
00039    For example, for dynamically linked executables in SVR4, the dynamic linker
00040    code is contained within the shared C library, which is actually executable
00041    and is run by the kernel first when an exec is done of a user executable
00042    that is dynamically linked.  The dynamic linker within the shared C library
00043    then maps in the various program segments in the user executable and jumps
00044    to the user executable's recorded entry point, as if the call had been made
00045    directly by the kernel.
00046 
00047    The traditional gdb method of using this info was to use the
00048    recorded entry point to set the entry-file's lowpc and highpc from
00049    the debugging information, where these values are the starting
00050    address (inclusive) and ending address (exclusive) of the
00051    instruction space in the executable which correspond to the
00052    "startup file", i.e. crt0.o in most cases.  This file is assumed to
00053    be a startup file and frames with pc's inside it are treated as
00054    nonexistent.  Setting these variables is necessary so that
00055    backtraces do not fly off the bottom of the stack.
00056 
00057    NOTE: cagney/2003-09-09: It turns out that this "traditional"
00058    method doesn't work.  Corinna writes: ``It turns out that the call
00059    to test for "inside entry file" destroys a meaningful backtrace
00060    under some conditions.  E.g. the backtrace tests in the asm-source
00061    testcase are broken for some targets.  In this test the functions
00062    are all implemented as part of one file and the testcase is not
00063    necessarily linked with a start file (depending on the target).
00064    What happens is, that the first frame is printed normaly and
00065    following frames are treated as being inside the enttry file then.
00066    This way, only the #0 frame is printed in the backtrace output.''
00067    Ref "frame.c" "NOTE: vinschen/2003-04-01".
00068 
00069    Gdb also supports an alternate method to avoid running off the bottom
00070    of the stack.
00071 
00072    There are two frames that are "special", the frame for the function
00073    containing the process entry point, since it has no predecessor frame,
00074    and the frame for the function containing the user code entry point
00075    (the main() function), since all the predecessor frames are for the
00076    process startup code.  Since we have no guarantee that the linked
00077    in startup modules have any debugging information that gdb can use,
00078    we need to avoid following frame pointers back into frames that might
00079    have been built in the startup code, as we might get hopelessly 
00080    confused.  However, we almost always have debugging information
00081    available for main().
00082 
00083    These variables are used to save the range of PC values which are
00084    valid within the main() function and within the function containing
00085    the process entry point.  If we always consider the frame for
00086    main() as the outermost frame when debugging user code, and the
00087    frame for the process entry point function as the outermost frame
00088    when debugging startup code, then all we have to do is have
00089    DEPRECATED_FRAME_CHAIN_VALID return false whenever a frame's
00090    current PC is within the range specified by these variables.  In
00091    essence, we set "ceilings" in the frame chain beyond which we will
00092    not proceed when following the frame chain back up the stack.
00093 
00094    A nice side effect is that we can still debug startup code without
00095    running off the end of the frame chain, assuming that we have usable
00096    debugging information in the startup modules, and if we choose to not
00097    use the block at main, or can't find it for some reason, everything
00098    still works as before.  And if we have no startup code debugging
00099    information but we do have usable information for main(), backtraces
00100    from user code don't go wandering off into the startup code.  */
00101 
00102 struct entry_info
00103   {
00104     /* The relocated value we should use for this objfile entry point.  */
00105     CORE_ADDR entry_point;
00106 
00107     /* Set to 1 iff ENTRY_POINT contains a valid value.  */
00108     unsigned entry_point_p : 1;
00109   };
00110 
00111 /* Sections in an objfile.  The section offsets are stored in the
00112    OBJFILE.  */
00113 
00114 struct obj_section
00115   {
00116     struct bfd_section *the_bfd_section;        /* BFD section pointer */
00117 
00118     /* Objfile this section is part of.  */
00119     struct objfile *objfile;
00120 
00121     /* True if this "overlay section" is mapped into an "overlay region".  */
00122     int ovly_mapped;
00123   };
00124 
00125 /* Relocation offset applied to S.  */
00126 #define obj_section_offset(s)                                           \
00127   (((s)->objfile->section_offsets)->offsets[gdb_bfd_section_index ((s)->objfile->obfd, (s)->the_bfd_section)])
00128 
00129 /* The memory address of section S (vma + offset).  */
00130 #define obj_section_addr(s)                                             \
00131   (bfd_get_section_vma ((s)->objfile->obfd, s->the_bfd_section)         \
00132    + obj_section_offset (s))
00133 
00134 /* The one-passed-the-end memory address of section S
00135    (vma + size + offset).  */
00136 #define obj_section_endaddr(s)                                          \
00137   (bfd_get_section_vma ((s)->objfile->obfd, s->the_bfd_section)         \
00138    + bfd_get_section_size ((s)->the_bfd_section)                        \
00139    + obj_section_offset (s))
00140 
00141 /* The "objstats" structure provides a place for gdb to record some
00142    interesting information about its internal state at runtime, on a
00143    per objfile basis, such as information about the number of symbols
00144    read, size of string table (if any), etc.  */
00145 
00146 struct objstats
00147   {
00148     int n_minsyms;              /* Number of minimal symbols read */
00149     int n_psyms;                /* Number of partial symbols read */
00150     int n_syms;                 /* Number of full symbols read */
00151     int n_stabs;                /* Number of ".stabs" read (if applicable) */
00152     int n_types;                /* Number of types */
00153     int sz_strtab;              /* Size of stringtable, (if applicable) */
00154   };
00155 
00156 #define OBJSTAT(objfile, expr) (objfile -> stats.expr)
00157 #define OBJSTATS struct objstats stats
00158 extern void print_objfile_statistics (void);
00159 extern void print_symbol_bcache_statistics (void);
00160 
00161 /* Number of entries in the minimal symbol hash table.  */
00162 #define MINIMAL_SYMBOL_HASH_SIZE 2039
00163 
00164 /* Some objfile data is hung off the BFD.  This enables sharing of the
00165    data across all objfiles using the BFD.  The data is stored in an
00166    instance of this structure, and associated with the BFD using the
00167    registry system.  */
00168 
00169 struct objfile_per_bfd_storage
00170 {
00171   /* The storage has an obstack of its own.  */
00172 
00173   struct obstack storage_obstack;
00174   
00175   /* Byte cache for file names.  */
00176 
00177   struct bcache *filename_cache;
00178 
00179   /* Byte cache for macros.  */
00180   struct bcache *macro_cache;
00181 
00182   /* The gdbarch associated with the BFD.  Note that this gdbarch is
00183      determined solely from BFD information, without looking at target
00184      information.  The gdbarch determined from a running target may
00185      differ from this e.g. with respect to register types and names.  */
00186 
00187   struct gdbarch *gdbarch;
00188 
00189   /* Hash table for mapping symbol names to demangled names.  Each
00190      entry in the hash table is actually two consecutive strings,
00191      both null-terminated; the first one is a mangled or linkage
00192      name, and the second is the demangled name or just a zero byte
00193      if the name doesn't demangle.  */
00194   struct htab *demangled_names_hash;
00195 };
00196 
00197 /* Master structure for keeping track of each file from which
00198    gdb reads symbols.  There are several ways these get allocated: 1.
00199    The main symbol file, symfile_objfile, set by the symbol-file command,
00200    2.  Additional symbol files added by the add-symbol-file command,
00201    3.  Shared library objfiles, added by ADD_SOLIB,  4.  symbol files
00202    for modules that were loaded when GDB attached to a remote system
00203    (see remote-vx.c).  */
00204 
00205 struct objfile
00206   {
00207 
00208     /* All struct objfile's are chained together by their next pointers.
00209        The program space field "objfiles"  (frequently referenced via
00210        the macro "object_files") points to the first link in this
00211        chain.  */
00212 
00213     struct objfile *next;
00214 
00215     /* The object file's name, tilde-expanded and absolute.  This
00216        pointer is never NULL.  This does not have to be freed; it is
00217        guaranteed to have a lifetime at least as long as the objfile.  */
00218 
00219     char *original_name;
00220 
00221     CORE_ADDR addr_low;
00222 
00223     /* Some flag bits for this objfile.
00224        The values are defined by OBJF_*.  */
00225 
00226     unsigned short flags;
00227 
00228     /* The program space associated with this objfile.  */
00229 
00230     struct program_space *pspace;
00231 
00232     /* Each objfile points to a linked list of symtabs derived from this file,
00233        one symtab structure for each compilation unit (source file).  Each link
00234        in the symtab list contains a backpointer to this objfile.  */
00235 
00236     struct symtab *symtabs;
00237 
00238     /* Each objfile points to a linked list of partial symtabs derived from
00239        this file, one partial symtab structure for each compilation unit
00240        (source file).  */
00241 
00242     struct partial_symtab *psymtabs;
00243 
00244     /* Map addresses to the entries of PSYMTABS.  It would be more efficient to
00245        have a map per the whole process but ADDRMAP cannot selectively remove
00246        its items during FREE_OBJFILE.  This mapping is already present even for
00247        PARTIAL_SYMTABs which still have no corresponding full SYMTABs read.  */
00248 
00249     struct addrmap *psymtabs_addrmap;
00250 
00251     /* List of freed partial symtabs, available for re-use.  */
00252 
00253     struct partial_symtab *free_psymtabs;
00254 
00255     /* The object file's BFD.  Can be null if the objfile contains only
00256        minimal symbols, e.g. the run time common symbols for SunOS4.  */
00257 
00258     bfd *obfd;
00259 
00260     /* The per-BFD data.  Note that this is treated specially if OBFD
00261        is NULL.  */
00262 
00263     struct objfile_per_bfd_storage *per_bfd;
00264 
00265     /* The modification timestamp of the object file, as of the last time
00266        we read its symbols.  */
00267 
00268     long mtime;
00269 
00270     /* Obstack to hold objects that should be freed when we load a new symbol
00271        table from this object file.  */
00272 
00273     struct obstack objfile_obstack; 
00274 
00275     /* A byte cache where we can stash arbitrary "chunks" of bytes that
00276        will not change.  */
00277 
00278     struct psymbol_bcache *psymbol_cache; /* Byte cache for partial syms.  */
00279 
00280     /* Vectors of all partial symbols read in from file.  The actual data
00281        is stored in the objfile_obstack.  */
00282 
00283     struct psymbol_allocation_list global_psymbols;
00284     struct psymbol_allocation_list static_psymbols;
00285 
00286     /* Each file contains a pointer to an array of minimal symbols for all
00287        global symbols that are defined within the file.  The array is
00288        terminated by a "null symbol", one that has a NULL pointer for the
00289        name and a zero value for the address.  This makes it easy to walk
00290        through the array when passed a pointer to somewhere in the middle
00291        of it.  There is also a count of the number of symbols, which does
00292        not include the terminating null symbol.  The array itself, as well
00293        as all the data that it points to, should be allocated on the
00294        objfile_obstack for this file.  */
00295 
00296     struct minimal_symbol *msymbols;
00297     int minimal_symbol_count;
00298 
00299     /* This is a hash table used to index the minimal symbols by name.  */
00300 
00301     struct minimal_symbol *msymbol_hash[MINIMAL_SYMBOL_HASH_SIZE];
00302 
00303     /* This hash table is used to index the minimal symbols by their
00304        demangled names.  */
00305 
00306     struct minimal_symbol *msymbol_demangled_hash[MINIMAL_SYMBOL_HASH_SIZE];
00307 
00308     /* Structure which keeps track of functions that manipulate objfile's
00309        of the same type as this objfile.  I.e. the function to read partial
00310        symbols for example.  Note that this structure is in statically
00311        allocated memory, and is shared by all objfiles that use the
00312        object module reader of this type.  */
00313 
00314     const struct sym_fns *sf;
00315 
00316     /* The per-objfile information about the entry point, the scope (file/func)
00317        containing the entry point, and the scope of the user's main() func.  */
00318 
00319     struct entry_info ei;
00320 
00321     /* Per objfile data-pointers required by other GDB modules.  */
00322 
00323     REGISTRY_FIELDS;
00324 
00325     /* Set of relocation offsets to apply to each section.
00326        The table is indexed by the_bfd_section->index, thus it is generally
00327        as large as the number of sections in the binary.
00328        The table is stored on the objfile_obstack.
00329 
00330        These offsets indicate that all symbols (including partial and
00331        minimal symbols) which have been read have been relocated by this
00332        much.  Symbols which are yet to be read need to be relocated by it.  */
00333 
00334     struct section_offsets *section_offsets;
00335     int num_sections;
00336 
00337     /* Indexes in the section_offsets array.  These are initialized by the
00338        *_symfile_offsets() family of functions (som_symfile_offsets,
00339        xcoff_symfile_offsets, default_symfile_offsets).  In theory they
00340        should correspond to the section indexes used by bfd for the
00341        current objfile.  The exception to this for the time being is the
00342        SOM version.  */
00343 
00344     int sect_index_text;
00345     int sect_index_data;
00346     int sect_index_bss;
00347     int sect_index_rodata;
00348 
00349     /* These pointers are used to locate the section table, which
00350        among other things, is used to map pc addresses into sections.
00351        SECTIONS points to the first entry in the table, and
00352        SECTIONS_END points to the first location past the last entry
00353        in the table.  The table is stored on the objfile_obstack.  The
00354        sections are indexed by the BFD section index; but the
00355        structure data is only valid for certain sections
00356        (e.g. non-empty, SEC_ALLOC).  */
00357 
00358     struct obj_section *sections, *sections_end;
00359 
00360     /* GDB allows to have debug symbols in separate object files.  This is
00361        used by .gnu_debuglink, ELF build id note and Mach-O OSO.
00362        Although this is a tree structure, GDB only support one level
00363        (ie a separate debug for a separate debug is not supported).  Note that
00364        separate debug object are in the main chain and therefore will be
00365        visited by ALL_OBJFILES & co iterators.  Separate debug objfile always
00366        has a non-nul separate_debug_objfile_backlink.  */
00367 
00368     /* Link to the first separate debug object, if any.  */
00369     struct objfile *separate_debug_objfile;
00370 
00371     /* If this is a separate debug object, this is used as a link to the
00372        actual executable objfile.  */
00373     struct objfile *separate_debug_objfile_backlink;
00374 
00375     /* If this is a separate debug object, this is a link to the next one
00376        for the same executable objfile.  */
00377     struct objfile *separate_debug_objfile_link;
00378 
00379     /* Place to stash various statistics about this objfile.  */
00380     OBJSTATS;
00381 
00382     /* A linked list of symbols created when reading template types or
00383        function templates.  These symbols are not stored in any symbol
00384        table, so we have to keep them here to relocate them
00385        properly.  */
00386     struct symbol *template_symbols;
00387   };
00388 
00389 /* Defines for the objfile flag word.  */
00390 
00391 /* When an object file has its functions reordered (currently Irix-5.2
00392    shared libraries exhibit this behaviour), we will need an expensive
00393    algorithm to locate a partial symtab or symtab via an address.
00394    To avoid this penalty for normal object files, we use this flag,
00395    whose setting is determined upon symbol table read in.  */
00396 
00397 #define OBJF_REORDERED  (1 << 0)        /* Functions are reordered */
00398 
00399 /* Distinguish between an objfile for a shared library and a "vanilla"
00400    objfile.  (If not set, the objfile may still actually be a solib.
00401    This can happen if the user created the objfile by using the
00402    add-symbol-file command.  GDB doesn't in that situation actually
00403    check whether the file is a solib.  Rather, the target's
00404    implementation of the solib interface is responsible for setting
00405    this flag when noticing solibs used by an inferior.)  */
00406 
00407 #define OBJF_SHARED     (1 << 1)        /* From a shared library */
00408 
00409 /* User requested that this objfile be read in it's entirety.  */
00410 
00411 #define OBJF_READNOW    (1 << 2)        /* Immediate full read */
00412 
00413 /* This objfile was created because the user explicitly caused it
00414    (e.g., used the add-symbol-file command).  This bit offers a way
00415    for run_command to remove old objfile entries which are no longer
00416    valid (i.e., are associated with an old inferior), but to preserve
00417    ones that the user explicitly loaded via the add-symbol-file
00418    command.  */
00419 
00420 #define OBJF_USERLOADED (1 << 3)        /* User loaded */
00421 
00422 /* Set if we have tried to read partial symtabs for this objfile.
00423    This is used to allow lazy reading of partial symtabs.  */
00424 
00425 #define OBJF_PSYMTABS_READ (1 << 4)
00426 
00427 /* Set if this is the main symbol file
00428    (as opposed to symbol file for dynamically loaded code).  */
00429 
00430 #define OBJF_MAINLINE (1 << 5)
00431 
00432 /* ORIGINAL_NAME and OBFD->FILENAME correspond to text description unrelated to
00433    filesystem names.  It can be for example "<image in memory>".  */
00434 
00435 #define OBJF_NOT_FILENAME (1 << 6)
00436 
00437 /* Declarations for functions defined in objfiles.c */
00438 
00439 extern struct objfile *allocate_objfile (bfd *, const char *name, int);
00440 
00441 extern struct gdbarch *get_objfile_arch (struct objfile *);
00442 
00443 extern int entry_point_address_query (CORE_ADDR *entry_p);
00444 
00445 extern CORE_ADDR entry_point_address (void);
00446 
00447 extern void build_objfile_section_table (struct objfile *);
00448 
00449 extern void terminate_minimal_symbol_table (struct objfile *objfile);
00450 
00451 extern struct objfile *objfile_separate_debug_iterate (const struct objfile *,
00452                                                        const struct objfile *);
00453 
00454 extern void put_objfile_before (struct objfile *, struct objfile *);
00455 
00456 extern void objfile_to_front (struct objfile *);
00457 
00458 extern void add_separate_debug_objfile (struct objfile *, struct objfile *);
00459 
00460 extern void unlink_objfile (struct objfile *);
00461 
00462 extern void free_objfile (struct objfile *);
00463 
00464 extern void free_objfile_separate_debug (struct objfile *);
00465 
00466 extern struct cleanup *make_cleanup_free_objfile (struct objfile *);
00467 
00468 extern void free_all_objfiles (void);
00469 
00470 extern void objfile_relocate (struct objfile *, const struct section_offsets *);
00471 extern void objfile_rebase (struct objfile *, CORE_ADDR);
00472 
00473 extern int objfile_has_partial_symbols (struct objfile *objfile);
00474 
00475 extern int objfile_has_full_symbols (struct objfile *objfile);
00476 
00477 extern int objfile_has_symbols (struct objfile *objfile);
00478 
00479 extern int have_partial_symbols (void);
00480 
00481 extern int have_full_symbols (void);
00482 
00483 extern void objfile_set_sym_fns (struct objfile *objfile,
00484                                  const struct sym_fns *sf);
00485 
00486 extern void objfiles_changed (void);
00487 
00488 /* This operation deletes all objfile entries that represent solibs that
00489    weren't explicitly loaded by the user, via e.g., the add-symbol-file
00490    command.  */
00491 
00492 extern void objfile_purge_solibs (void);
00493 
00494 /* Functions for dealing with the minimal symbol table, really a misc
00495    address<->symbol mapping for things we don't have debug symbols for.  */
00496 
00497 extern int have_minimal_symbols (void);
00498 
00499 extern struct obj_section *find_pc_section (CORE_ADDR pc);
00500 
00501 /* Return non-zero if PC is in a section called NAME.  */
00502 extern int pc_in_section (CORE_ADDR, char *);
00503 
00504 /* Return non-zero if PC is in a SVR4-style procedure linkage table
00505    section.  */
00506 
00507 static inline int
00508 in_plt_section (CORE_ADDR pc)
00509 {
00510   return pc_in_section (pc, ".plt");
00511 }
00512 
00513 /* Keep a registry of per-objfile data-pointers required by other GDB
00514    modules.  */
00515 DECLARE_REGISTRY(objfile);
00516 
00517 /* In normal use, the section map will be rebuilt by find_pc_section
00518    if objfiles have been added, removed or relocated since it was last
00519    called.  Calling inhibit_section_map_updates will inhibit this
00520    behavior until resume_section_map_updates is called.  If you call
00521    inhibit_section_map_updates you must ensure that every call to
00522    find_pc_section in the inhibited region relates to a section that
00523    is already in the section map and has not since been removed or
00524    relocated.  */
00525 extern void inhibit_section_map_updates (struct program_space *pspace);
00526 
00527 /* Resume automatically rebuilding the section map as required.  */
00528 extern void resume_section_map_updates (struct program_space *pspace);
00529 
00530 /* Version of the above suitable for use as a cleanup.  */
00531 extern void resume_section_map_updates_cleanup (void *arg);
00532 
00533 extern void default_iterate_over_objfiles_in_search_order
00534   (struct gdbarch *gdbarch,
00535    iterate_over_objfiles_in_search_order_cb_ftype *cb,
00536    void *cb_data, struct objfile *current_objfile);
00537 
00538 
00539 /* Traverse all object files in the current program space.
00540    ALL_OBJFILES_SAFE works even if you delete the objfile during the
00541    traversal.  */
00542 
00543 /* Traverse all object files in program space SS.  */
00544 
00545 #define ALL_PSPACE_OBJFILES(ss, obj)                                    \
00546   for ((obj) = ss->objfiles; (obj) != NULL; (obj) = (obj)->next)
00547 
00548 #define ALL_PSPACE_OBJFILES_SAFE(ss, obj, nxt)          \
00549   for ((obj) = ss->objfiles;                    \
00550        (obj) != NULL? ((nxt)=(obj)->next,1) :0; \
00551        (obj) = (nxt))
00552 
00553 #define ALL_OBJFILES(obj)                           \
00554   for ((obj) = current_program_space->objfiles; \
00555        (obj) != NULL;                               \
00556        (obj) = (obj)->next)
00557 
00558 #define ALL_OBJFILES_SAFE(obj,nxt)                      \
00559   for ((obj) = current_program_space->objfiles; \
00560        (obj) != NULL? ((nxt)=(obj)->next,1) :0; \
00561        (obj) = (nxt))
00562 
00563 /* Traverse all symtabs in one objfile.  */
00564 
00565 #define ALL_OBJFILE_SYMTABS(objfile, s) \
00566     for ((s) = (objfile) -> symtabs; (s) != NULL; (s) = (s) -> next)
00567 
00568 /* Traverse all primary symtabs in one objfile.  */
00569 
00570 #define ALL_OBJFILE_PRIMARY_SYMTABS(objfile, s) \
00571   ALL_OBJFILE_SYMTABS ((objfile), (s)) \
00572     if ((s)->primary)
00573 
00574 /* Traverse all minimal symbols in one objfile.  */
00575 
00576 #define ALL_OBJFILE_MSYMBOLS(objfile, m) \
00577     for ((m) = (objfile) -> msymbols; SYMBOL_LINKAGE_NAME(m) != NULL; (m)++)
00578 
00579 /* Traverse all symtabs in all objfiles in the current symbol
00580    space.  */
00581 
00582 #define ALL_SYMTABS(objfile, s) \
00583   ALL_OBJFILES (objfile)         \
00584     ALL_OBJFILE_SYMTABS (objfile, s)
00585 
00586 #define ALL_PSPACE_SYMTABS(ss, objfile, s)              \
00587   ALL_PSPACE_OBJFILES (ss, objfile)                     \
00588     ALL_OBJFILE_SYMTABS (objfile, s)
00589 
00590 /* Traverse all symtabs in all objfiles in the current program space,
00591    skipping included files (which share a blockvector with their
00592    primary symtab).  */
00593 
00594 #define ALL_PRIMARY_SYMTABS(objfile, s) \
00595   ALL_OBJFILES (objfile)                \
00596     ALL_OBJFILE_PRIMARY_SYMTABS (objfile, s)
00597 
00598 #define ALL_PSPACE_PRIMARY_SYMTABS(pspace, objfile, s)  \
00599   ALL_PSPACE_OBJFILES (ss, objfile)                     \
00600     ALL_OBJFILE_PRIMARY_SYMTABS (objfile, s)
00601 
00602 /* Traverse all minimal symbols in all objfiles in the current symbol
00603    space.  */
00604 
00605 #define ALL_MSYMBOLS(objfile, m) \
00606   ALL_OBJFILES (objfile)         \
00607     ALL_OBJFILE_MSYMBOLS (objfile, m)
00608 
00609 #define ALL_OBJFILE_OSECTIONS(objfile, osect)   \
00610   for (osect = objfile->sections; osect < objfile->sections_end; osect++) \
00611     if (osect->the_bfd_section == NULL)                                 \
00612       {                                                                 \
00613         /* Nothing.  */                                                 \
00614       }                                                                 \
00615     else
00616 
00617 /* Traverse all obj_sections in all objfiles in the current program
00618    space.
00619 
00620    Note that this detects a "break" in the inner loop, and exits
00621    immediately from the outer loop as well, thus, client code doesn't
00622    need to know that this is implemented with a double for.  The extra
00623    hair is to make sure that a "break;" stops the outer loop iterating
00624    as well, and both OBJFILE and OSECT are left unmodified:
00625 
00626     - The outer loop learns about the inner loop's end condition, and
00627       stops iterating if it detects the inner loop didn't reach its
00628       end.  In other words, the outer loop keeps going only if the
00629       inner loop reached its end cleanly [(osect) ==
00630       (objfile)->sections_end].
00631 
00632     - OSECT is initialized in the outer loop initialization
00633       expressions, such as if the inner loop has reached its end, so
00634       the check mentioned above succeeds the first time.
00635 
00636     - The trick to not clearing OBJFILE on a "break;" is, in the outer
00637       loop's loop expression, advance OBJFILE, but iff the inner loop
00638       reached its end.  If not, there was a "break;", so leave OBJFILE
00639       as is; the outer loop's conditional will break immediately as
00640       well (as OSECT will be different from OBJFILE->sections_end).  */
00641 
00642 #define ALL_OBJSECTIONS(objfile, osect)                                 \
00643   for ((objfile) = current_program_space->objfiles,                     \
00644          (objfile) != NULL ? ((osect) = (objfile)->sections_end) : 0;   \
00645        (objfile) != NULL                                                \
00646          && (osect) == (objfile)->sections_end;                         \
00647        ((osect) == (objfile)->sections_end                              \
00648         ? ((objfile) = (objfile)->next,                                 \
00649            (objfile) != NULL ? (osect) = (objfile)->sections_end : 0)   \
00650         : 0))                                                           \
00651     ALL_OBJFILE_OSECTIONS (objfile, osect)
00652 
00653 #define SECT_OFF_DATA(objfile) \
00654      ((objfile->sect_index_data == -1) \
00655       ? (internal_error (__FILE__, __LINE__, \
00656                          _("sect_index_data not initialized")), -1)     \
00657       : objfile->sect_index_data)
00658 
00659 #define SECT_OFF_RODATA(objfile) \
00660      ((objfile->sect_index_rodata == -1) \
00661       ? (internal_error (__FILE__, __LINE__, \
00662                          _("sect_index_rodata not initialized")), -1)   \
00663       : objfile->sect_index_rodata)
00664 
00665 #define SECT_OFF_TEXT(objfile) \
00666      ((objfile->sect_index_text == -1) \
00667       ? (internal_error (__FILE__, __LINE__, \
00668                          _("sect_index_text not initialized")), -1)     \
00669       : objfile->sect_index_text)
00670 
00671 /* Sometimes the .bss section is missing from the objfile, so we don't
00672    want to die here.  Let the users of SECT_OFF_BSS deal with an
00673    uninitialized section index.  */
00674 #define SECT_OFF_BSS(objfile) (objfile)->sect_index_bss
00675 
00676 /* Answer whether there is more than one object file loaded.  */
00677 
00678 #define MULTI_OBJFILE_P() (object_files && object_files->next)
00679 
00680 /* Reset the per-BFD storage area on OBJ.  */
00681 
00682 void set_objfile_per_bfd (struct objfile *obj);
00683 
00684 const char *objfile_name (const struct objfile *objfile);
00685 
00686 #endif /* !defined (OBJFILES_H) */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines