| 1 | /* Public partial symbol table definitions. |
| 2 | |
| 3 | Copyright (C) 2009-2019 Free Software Foundation, Inc. |
| 4 | |
| 5 | This file is part of GDB. |
| 6 | |
| 7 | This program is free software; you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by |
| 9 | the Free Software Foundation; either version 3 of the License, or |
| 10 | (at your option) any later version. |
| 11 | |
| 12 | This program is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 19 | |
| 20 | #ifndef PSYMTAB_H |
| 21 | #define PSYMTAB_H |
| 22 | |
| 23 | #include "gdb_obstack.h" |
| 24 | #include "symfile.h" |
| 25 | #include "common/next-iterator.h" |
| 26 | |
| 27 | struct partial_symbol; |
| 28 | |
| 29 | /* A bcache for partial symbols. */ |
| 30 | |
| 31 | struct psymbol_bcache; |
| 32 | |
| 33 | /* An instance of this class manages the partial symbol tables and |
| 34 | partial symbols for a given objfile. */ |
| 35 | |
| 36 | class psymtab_storage |
| 37 | { |
| 38 | public: |
| 39 | |
| 40 | explicit psymtab_storage (struct objfile *objfile); |
| 41 | |
| 42 | ~psymtab_storage (); |
| 43 | |
| 44 | DISABLE_COPY_AND_ASSIGN (psymtab_storage); |
| 45 | |
| 46 | /* Discard all partial symbol tables starting with "psymtabs" and |
| 47 | proceeding until "to" has been discarded. */ |
| 48 | |
| 49 | void discard_psymtabs_to (struct partial_symtab *to) |
| 50 | { |
| 51 | while (psymtabs != to) |
| 52 | discard_psymtab (psymtabs); |
| 53 | } |
| 54 | |
| 55 | /* Discard the partial symbol table. */ |
| 56 | |
| 57 | void discard_psymtab (struct partial_symtab *pst); |
| 58 | |
| 59 | /* Return the obstack that is used for storage by this object. */ |
| 60 | |
| 61 | struct obstack *obstack () |
| 62 | { |
| 63 | return m_obstack; |
| 64 | } |
| 65 | |
| 66 | /* Allocate storage for the "dependencies" field of a psymtab. |
| 67 | NUMBER says how many dependencies there are. */ |
| 68 | |
| 69 | struct partial_symtab **allocate_dependencies (int number) |
| 70 | { |
| 71 | return OBSTACK_CALLOC (obstack (), number, struct partial_symtab *); |
| 72 | } |
| 73 | |
| 74 | |
| 75 | /* Each objfile points to a linked list of partial symtabs derived from |
| 76 | this file, one partial symtab structure for each compilation unit |
| 77 | (source file). */ |
| 78 | |
| 79 | struct partial_symtab *psymtabs = nullptr; |
| 80 | |
| 81 | /* Map addresses to the entries of PSYMTABS. It would be more efficient to |
| 82 | have a map per the whole process but ADDRMAP cannot selectively remove |
| 83 | its items during FREE_OBJFILE. This mapping is already present even for |
| 84 | PARTIAL_SYMTABs which still have no corresponding full SYMTABs read. */ |
| 85 | |
| 86 | struct addrmap *psymtabs_addrmap = nullptr; |
| 87 | |
| 88 | /* List of freed partial symtabs, available for re-use. */ |
| 89 | |
| 90 | struct partial_symtab *free_psymtabs = nullptr; |
| 91 | |
| 92 | /* A byte cache where we can stash arbitrary "chunks" of bytes that |
| 93 | will not change. */ |
| 94 | |
| 95 | struct psymbol_bcache *psymbol_cache; |
| 96 | |
| 97 | /* Vectors of all partial symbols read in from file. The actual data |
| 98 | is stored in the objfile_obstack. */ |
| 99 | |
| 100 | std::vector<partial_symbol *> global_psymbols; |
| 101 | std::vector<partial_symbol *> static_psymbols; |
| 102 | |
| 103 | private: |
| 104 | |
| 105 | /* The obstack where allocations are made. */ |
| 106 | |
| 107 | struct obstack *m_obstack; |
| 108 | }; |
| 109 | |
| 110 | |
| 111 | extern struct psymbol_bcache *psymbol_bcache_init (void); |
| 112 | extern void psymbol_bcache_free (struct psymbol_bcache *); |
| 113 | extern struct bcache *psymbol_bcache_get_bcache (struct psymbol_bcache *); |
| 114 | |
| 115 | extern const struct quick_symbol_functions psym_functions; |
| 116 | |
| 117 | extern const struct quick_symbol_functions dwarf2_gdb_index_functions; |
| 118 | extern const struct quick_symbol_functions dwarf2_debug_names_functions; |
| 119 | |
| 120 | /* Ensure that the partial symbols for OBJFILE have been loaded. If |
| 121 | VERBOSE is non-zero, then this will print a message when symbols |
| 122 | are loaded. This function returns a range adapter suitable for |
| 123 | iterating over the psymtabs of OBJFILE. */ |
| 124 | |
| 125 | class objfile_psymtabs; |
| 126 | extern objfile_psymtabs require_partial_symbols (struct objfile *objfile, |
| 127 | int verbose); |
| 128 | |
| 129 | #endif /* PSYMTAB_H */ |