Revert "Turn off threaded minsym demangling by default"
[deliverable/binutils-gdb.git] / gdb / psymtab.h
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 "gdbsupport/next-iterator.h"
26 #include "bcache.h"
27
28 struct partial_symbol;
29
30 /* An instance of this class manages the partial symbol tables and
31 partial symbols for a given objfile.
32
33 The core psymtab functions -- those in psymtab.c -- arrange for
34 nearly all psymtab- and psymbol-related allocations to happen
35 either in the psymtab_storage object (either on its obstack or in
36 other memory managed by this class), or on the per-BFD object. The
37 only link from the psymtab storage object back to the objfile (or
38 objfile_obstack) that is made by the core psymtab code is the
39 compunit_symtab member in the psymtab.
40
41 However, it is up to each symbol reader to maintain this invariant
42 in other ways, if it wants to reuse psymtabs across multiple
43 objfiles. The main issue here is ensuring that read_symtab_private
44 does not point into objfile_obstack. */
45
46 class psymtab_storage
47 {
48 public:
49
50 psymtab_storage ();
51
52 ~psymtab_storage ();
53
54 DISABLE_COPY_AND_ASSIGN (psymtab_storage);
55
56 /* Discard all partial symbol tables starting with "psymtabs" and
57 proceeding until "to" has been discarded. */
58
59 void discard_psymtabs_to (struct partial_symtab *to)
60 {
61 while (psymtabs != to)
62 discard_psymtab (psymtabs);
63 }
64
65 /* Discard the partial symbol table. */
66
67 void discard_psymtab (struct partial_symtab *pst);
68
69 /* Return the obstack that is used for storage by this object. */
70
71 struct obstack *obstack ()
72 {
73 if (!m_obstack.has_value ())
74 m_obstack.emplace ();
75 return &*m_obstack;
76 }
77
78 /* Allocate storage for the "dependencies" field of a psymtab.
79 NUMBER says how many dependencies there are. */
80
81 struct partial_symtab **allocate_dependencies (int number)
82 {
83 return OBSTACK_CALLOC (obstack (), number, struct partial_symtab *);
84 }
85
86 /* Allocate a new psymtab on the psymtab obstack. The new psymtab
87 will be linked in to the "psymtabs" list, but otherwise all other
88 fields will be zero. */
89
90 struct partial_symtab *allocate_psymtab ();
91
92 typedef next_adapter<struct partial_symtab> partial_symtab_range;
93
94 /* A range adapter that makes it possible to iterate over all
95 psymtabs in one objfile. */
96
97 partial_symtab_range range ()
98 {
99 return partial_symtab_range (psymtabs);
100 }
101
102
103 /* Each objfile points to a linked list of partial symtabs derived from
104 this file, one partial symtab structure for each compilation unit
105 (source file). */
106
107 struct partial_symtab *psymtabs = nullptr;
108
109 /* Map addresses to the entries of PSYMTABS. It would be more efficient to
110 have a map per the whole process but ADDRMAP cannot selectively remove
111 its items during FREE_OBJFILE. This mapping is already present even for
112 PARTIAL_SYMTABs which still have no corresponding full SYMTABs read.
113
114 The DWARF parser reuses this addrmap to store things other than
115 psymtabs in the cases where debug information is being read from, for
116 example, the .debug-names section. */
117
118 struct addrmap *psymtabs_addrmap = nullptr;
119
120 /* A byte cache where we can stash arbitrary "chunks" of bytes that
121 will not change. */
122
123 gdb::bcache psymbol_cache;
124
125 /* Vectors of all partial symbols read in from file. The actual data
126 is stored in the objfile_obstack. */
127
128 std::vector<partial_symbol *> global_psymbols;
129 std::vector<partial_symbol *> static_psymbols;
130
131 private:
132
133 /* List of freed partial symtabs, available for re-use. */
134
135 struct partial_symtab *free_psymtabs = nullptr;
136
137 /* The obstack where allocations are made. This is lazily allocated
138 so that we don't waste memory when there are no psymtabs. */
139
140 gdb::optional<auto_obstack> m_obstack;
141 };
142
143
144 extern const struct quick_symbol_functions psym_functions;
145
146 extern const struct quick_symbol_functions dwarf2_gdb_index_functions;
147 extern const struct quick_symbol_functions dwarf2_debug_names_functions;
148
149 /* Ensure that the partial symbols for OBJFILE have been loaded. If
150 VERBOSE is true, then this will print a message when symbols
151 are loaded. This function returns a range adapter suitable for
152 iterating over the psymtabs of OBJFILE. */
153
154 extern psymtab_storage::partial_symtab_range require_partial_symbols
155 (struct objfile *objfile, bool verbose);
156
157 #endif /* PSYMTAB_H */
This page took 0.031586 seconds and 4 git commands to generate.