* ada-lang.c (user_select_syms): Use SYMBOL_SYMTAB.
[deliverable/binutils-gdb.git] / gdb / minsyms.h
1 /* Minimal symbol table definitions for GDB.
2
3 Copyright (C) 2011-2012 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 MINSYMS_H
21 #define MINSYMS_H
22
23 /* This header declares most of the API for dealing with minimal
24 symbols and minimal symbol tables. A few things are declared
25 elsewhere; see below.
26
27 A minimal symbol is a symbol for which there is no direct debug
28 information. For example, for an ELF binary, minimal symbols are
29 created from the ELF symbol table.
30
31 For the definition of the minimal symbol structure, see struct
32 minimal_symbol in symtab.h.
33
34 Minimal symbols are stored in tables attached to an objfile; see
35 objfiles.h for details. Code should generally treat these tables
36 as opaque and use functions provided by minsyms.c to inspect them.
37 */
38
39 /* Prepare to start collecting minimal symbols. This should be called
40 by a symbol reader to initialize the minimal symbol module.
41 Currently, minimal symbol table creation is not reentrant; it
42 relies on global (static) variables in minsyms.c. */
43
44 void init_minimal_symbol_collection (void);
45
46 /* Return a cleanup which is used to clean up the global state left
47 over by minimal symbol creation. After calling
48 init_minimal_symbol_collection, a symbol reader should call this
49 function. Then, after all minimal symbols have been read,
50 regardless of whether they are installed or not, the cleanup
51 returned by this function should be run. */
52
53 struct cleanup *make_cleanup_discard_minimal_symbols (void);
54
55 /* Record a new minimal symbol. This is the "full" entry point;
56 simpler convenience entry points are also provided below.
57
58 This returns a new minimal symbol. It is ok to modify the returned
59 minimal symbol (though generally not necessary). It is not ok,
60 though, to stash the pointer anywhere; as minimal symbols may be
61 moved after creation. The memory for the returned minimal symbol
62 is still owned by the minsyms.c code, and should not be freed.
63
64 Arguments are:
65
66 NAME - the symbol's name
67 NAME_LEN - the length of the name
68 COPY_NAME - if true, the minsym code must make a copy of NAME. If
69 false, then NAME must be NUL-terminated, and must have a lifetime
70 that is at least as long as OBJFILE's lifetime.
71 ADDRESS - the address of the symbol
72 MS_TYPE - the type of the symbol
73 SECTION - the symbol's section
74 BFD_SECTION - the symbol's BFD section; used to find the
75 appropriate obj_section for the minimal symbol. This can be NULL.
76 OBJFILE - the objfile associated with the minimal symbol. */
77
78 struct minimal_symbol *prim_record_minimal_symbol_full
79 (const char *name,
80 int name_len,
81 int copy_name,
82 CORE_ADDR address,
83 enum minimal_symbol_type ms_type,
84 int section,
85 asection *bfd_section,
86 struct objfile *objfile);
87
88 /* Like prim_record_minimal_symbol_full, but:
89 - uses strlen to compute NAME_LEN,
90 - passes COPY_NAME = 0,
91 - passes SECTION = 0,
92 - and passes BFD_SECTION = NULL.
93
94 This variant does not return the new symbol. */
95
96 void prim_record_minimal_symbol (const char *, CORE_ADDR,
97 enum minimal_symbol_type,
98 struct objfile *);
99
100 /* Like prim_record_minimal_symbol_full, but:
101 - uses strlen to compute NAME_LEN,
102 - passes COPY_NAME = 0. */
103
104 struct minimal_symbol *prim_record_minimal_symbol_and_info
105 (const char *,
106 CORE_ADDR,
107 enum minimal_symbol_type,
108 int section,
109 asection *bfd_section,
110 struct objfile *);
111
112 /* Install the minimal symbols that have been collected into the given
113 objfile. After this is called, the cleanup returned by
114 make_cleanup_discard_minimal_symbols should be run in order to
115 clean up global state. */
116
117 void install_minimal_symbols (struct objfile *);
118
119 /* Create the terminating entry of OBJFILE's minimal symbol table.
120 If OBJFILE->msymbols is zero, allocate a single entry from
121 OBJFILE->objfile_obstack; otherwise, just initialize
122 OBJFILE->msymbols[OBJFILE->minimal_symbol_count]. */
123
124 void terminate_minimal_symbol_table (struct objfile *objfile);
125
126 /* Sort all the minimal symbols in OBJFILE. This should be only be
127 called after relocating symbols; it ensures that the minimal
128 symbols are properly sorted by address. */
129
130 void msymbols_sort (struct objfile *objfile);
131
132 \f
133
134 /* Compute a hash code for the string argument. */
135
136 unsigned int msymbol_hash (const char *);
137
138 /* Like msymbol_hash, but compute a hash code that is compatible with
139 strcmp_iw. */
140
141 unsigned int msymbol_hash_iw (const char *);
142
143 /* Compute the next hash value from previous HASH and the character C. This
144 is only a GDB in-memory computed value with no external files compatibility
145 requirements. */
146
147 #define SYMBOL_HASH_NEXT(hash, c) \
148 ((hash) * 67 + tolower ((unsigned char) (c)) - 113)
149
150 \f
151
152 /* Return the objfile that holds the minimal symbol SYM. Every
153 minimal symbols is held by some objfile; this will never return
154 NULL. */
155
156 struct objfile *msymbol_objfile (struct minimal_symbol *sym);
157
158 \f
159
160 /* Look through all the current minimal symbol tables and find the
161 first minimal symbol that matches NAME. If OBJF is non-NULL, limit
162 the search to that objfile. If SFILE is non-NULL, the only file-scope
163 symbols considered will be from that source file (global symbols are
164 still preferred). Returns a pointer to the minimal symbol that
165 matches, or NULL if no match is found. */
166
167 struct minimal_symbol *lookup_minimal_symbol (const char *,
168 const char *,
169 struct objfile *);
170
171 /* Find the minimal symbol named NAME, and return both the minsym
172 struct and its objfile. This only checks the linkage name. Sets
173 *OBJFILE_P and returns the minimal symbol, if it is found. If it
174 is not found, returns NULL. */
175
176 struct minimal_symbol *lookup_minimal_symbol_and_objfile (const char *,
177 struct objfile **);
178
179 /* Look through all the current minimal symbol tables and find the
180 first minimal symbol that matches NAME and has text type. If OBJF
181 is non-NULL, limit the search to that objfile. Returns a pointer
182 to the minimal symbol that matches, or NULL if no match is found.
183
184 This function only searches the mangled (linkage) names. */
185
186 struct minimal_symbol *lookup_minimal_symbol_text (const char *,
187 struct objfile *);
188
189 /* Look through all the current minimal symbol tables and find the
190 first minimal symbol that matches NAME and is a solib trampoline.
191 If OBJF is non-NULL, limit the search to that objfile. Returns a
192 pointer to the minimal symbol that matches, or NULL if no match is
193 found.
194
195 This function only searches the mangled (linkage) names. */
196
197 struct minimal_symbol *lookup_minimal_symbol_solib_trampoline
198 (const char *,
199 struct objfile *);
200
201 /* Look through all the current minimal symbol tables and find the
202 first minimal symbol that matches NAME and PC. If OBJF is non-NULL,
203 limit the search to that objfile. Returns a pointer to the minimal
204 symbol that matches, or NULL if no match is found. */
205
206 struct minimal_symbol *lookup_minimal_symbol_by_pc_name
207 (CORE_ADDR, const char *, struct objfile *);
208
209 /* Search through the minimal symbol table for each objfile and find
210 the symbol whose address is the largest address that is still less
211 than or equal to PC, and which matches SECTION.
212
213 If SECTION is NULL, this uses the result of find_pc_section
214 instead.
215
216 Returns a pointer to the minimal symbol if such a symbol is found,
217 or NULL if PC is not in a suitable range. */
218
219 struct minimal_symbol *lookup_minimal_symbol_by_pc_section
220 (CORE_ADDR,
221 struct obj_section *);
222
223 /* Backward compatibility: search through the minimal symbol table
224 for a matching PC (no section given).
225
226 This is a wrapper that calls lookup_minimal_symbol_by_pc_section
227 with a NULL section argument. */
228
229 struct minimal_symbol *lookup_minimal_symbol_by_pc (CORE_ADDR);
230
231 /* Check if PC is in a shared library trampoline code stub.
232 Return minimal symbol for the trampoline entry or NULL if PC is not
233 in a trampoline code stub. */
234
235 struct minimal_symbol *lookup_solib_trampoline_symbol_by_pc (CORE_ADDR);
236
237 /* Iterate over all the minimal symbols in the objfile OBJF which
238 match NAME. Both the ordinary and demangled names of each symbol
239 are considered. The caller is responsible for canonicalizing NAME,
240 should that need to be done.
241
242 For each matching symbol, CALLBACK is called with the symbol and
243 USER_DATA as arguments. */
244
245 void iterate_over_minimal_symbols (struct objfile *objf,
246 const char *name,
247 void (*callback) (struct minimal_symbol *,
248 void *),
249 void *user_data);
250
251 #endif /* MINSYMS_H */
This page took 0.03867 seconds and 4 git commands to generate.