Commit | Line | Data |
---|---|---|
ccefe4c4 TT |
1 | /* Partial symbol tables. |
2 | ||
28e7fd62 | 3 | Copyright (C) 2009-2013 Free Software Foundation, Inc. |
ccefe4c4 TT |
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 | #include "defs.h" | |
21 | #include "symtab.h" | |
22 | #include "psympriv.h" | |
23 | #include "objfiles.h" | |
24 | #include "gdb_assert.h" | |
25 | #include "block.h" | |
26 | #include "filenames.h" | |
27 | #include "source.h" | |
28 | #include "addrmap.h" | |
29 | #include "gdbtypes.h" | |
30 | #include "bcache.h" | |
31 | #include "ui-out.h" | |
32 | #include "command.h" | |
33 | #include "readline/readline.h" | |
34 | #include "gdb_regex.h" | |
40658b94 | 35 | #include "dictionary.h" |
c00f8484 KS |
36 | #include "language.h" |
37 | #include "cp-support.h" | |
dfc7bb5b | 38 | #include "gdbcmd.h" |
ccefe4c4 TT |
39 | |
40 | #ifndef DEV_TTY | |
41 | #define DEV_TTY "/dev/tty" | |
42 | #endif | |
43 | ||
710e1a31 SW |
44 | struct psymbol_bcache |
45 | { | |
46 | struct bcache *bcache; | |
47 | }; | |
48 | ||
5c80ed9d TT |
49 | static struct partial_symbol *match_partial_symbol (struct objfile *, |
50 | struct partial_symtab *, | |
40658b94 PH |
51 | int, |
52 | const char *, domain_enum, | |
2edb89d3 JK |
53 | symbol_compare_ftype *, |
54 | symbol_compare_ftype *); | |
40658b94 | 55 | |
5c80ed9d TT |
56 | static struct partial_symbol *lookup_partial_symbol (struct objfile *, |
57 | struct partial_symtab *, | |
ccefe4c4 TT |
58 | const char *, int, |
59 | domain_enum); | |
60 | ||
da5132d3 | 61 | static const char *psymtab_to_fullname (struct partial_symtab *ps); |
ccefe4c4 | 62 | |
5c80ed9d TT |
63 | static struct partial_symbol *find_pc_sect_psymbol (struct objfile *, |
64 | struct partial_symtab *, | |
ccefe4c4 TT |
65 | CORE_ADDR, |
66 | struct obj_section *); | |
67 | ||
50da2f25 YQ |
68 | static void fixup_psymbol_section (struct partial_symbol *psym, |
69 | struct objfile *objfile); | |
ccefe4c4 | 70 | |
5c80ed9d TT |
71 | static struct symtab *psymtab_to_symtab (struct objfile *objfile, |
72 | struct partial_symtab *pst); | |
ccefe4c4 | 73 | |
b11896a5 TT |
74 | /* Ensure that the partial symbols for OBJFILE have been loaded. This |
75 | function always returns its argument, as a convenience. */ | |
76 | ||
77 | struct objfile * | |
78 | require_partial_symbols (struct objfile *objfile, int verbose) | |
79 | { | |
80 | if ((objfile->flags & OBJF_PSYMTABS_READ) == 0) | |
81 | { | |
82 | objfile->flags |= OBJF_PSYMTABS_READ; | |
83 | ||
84 | if (objfile->sf->sym_read_psymbols) | |
85 | { | |
86 | if (verbose) | |
87 | { | |
88 | printf_unfiltered (_("Reading symbols from %s..."), | |
89 | objfile->name); | |
90 | gdb_flush (gdb_stdout); | |
91 | } | |
92 | (*objfile->sf->sym_read_psymbols) (objfile); | |
93 | if (verbose) | |
94 | { | |
95 | if (!objfile_has_symbols (objfile)) | |
96 | { | |
97 | wrap_here (""); | |
98 | printf_unfiltered (_("(no debugging symbols found)...")); | |
99 | wrap_here (""); | |
100 | } | |
101 | ||
102 | printf_unfiltered (_("done.\n")); | |
103 | } | |
104 | } | |
105 | } | |
106 | ||
107 | return objfile; | |
108 | } | |
109 | ||
110 | /* Traverse all psymtabs in one objfile, requiring that the psymtabs | |
111 | be read in. */ | |
112 | ||
113 | #define ALL_OBJFILE_PSYMTABS_REQUIRED(objfile, p) \ | |
114 | for ((p) = require_partial_symbols (objfile, 1)->psymtabs; \ | |
115 | (p) != NULL; \ | |
116 | (p) = (p)->next) | |
117 | ||
118 | /* We want to make sure this file always requires psymtabs. */ | |
119 | ||
120 | #undef ALL_OBJFILE_PSYMTABS | |
121 | ||
122 | /* Traverse all psymtabs in all objfiles. */ | |
123 | ||
124 | #define ALL_PSYMTABS(objfile, p) \ | |
125 | ALL_OBJFILES (objfile) \ | |
126 | ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, p) | |
127 | ||
f8eba3c6 TT |
128 | /* Helper function for partial_map_symtabs_matching_filename that |
129 | expands the symtabs and calls the iterator. */ | |
ccefe4c4 | 130 | |
f8eba3c6 TT |
131 | static int |
132 | partial_map_expand_apply (struct objfile *objfile, | |
133 | const char *name, | |
f8eba3c6 TT |
134 | const char *real_path, |
135 | struct partial_symtab *pst, | |
136 | int (*callback) (struct symtab *, void *), | |
137 | void *data) | |
138 | { | |
139 | struct symtab *last_made = objfile->symtabs; | |
140 | ||
9439a077 TT |
141 | /* Shared psymtabs should never be seen here. Instead they should |
142 | be handled properly by the caller. */ | |
143 | gdb_assert (pst->user == NULL); | |
144 | ||
f8eba3c6 TT |
145 | /* Don't visit already-expanded psymtabs. */ |
146 | if (pst->readin) | |
147 | return 0; | |
148 | ||
149 | /* This may expand more than one symtab, and we want to iterate over | |
150 | all of them. */ | |
5c80ed9d | 151 | psymtab_to_symtab (objfile, pst); |
f8eba3c6 | 152 | |
f5b95b50 | 153 | return iterate_over_some_symtabs (name, real_path, callback, data, |
f8eba3c6 TT |
154 | objfile->symtabs, last_made); |
155 | } | |
156 | ||
157 | /* Implementation of the map_symtabs_matching_filename method. */ | |
158 | ||
159 | static int | |
160 | partial_map_symtabs_matching_filename (struct objfile *objfile, | |
161 | const char *name, | |
f8eba3c6 TT |
162 | const char *real_path, |
163 | int (*callback) (struct symtab *, | |
164 | void *), | |
165 | void *data) | |
ccefe4c4 TT |
166 | { |
167 | struct partial_symtab *pst; | |
c011a4f4 | 168 | const char *name_basename = lbasename (name); |
ccefe4c4 | 169 | |
b11896a5 | 170 | ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst) |
ccefe4c4 | 171 | { |
9439a077 TT |
172 | /* We can skip shared psymtabs here, because any file name will be |
173 | attached to the unshared psymtab. */ | |
174 | if (pst->user != NULL) | |
175 | continue; | |
176 | ||
b4c41fc7 DE |
177 | /* Anonymous psymtabs don't have a file name. */ |
178 | if (pst->anonymous) | |
179 | continue; | |
180 | ||
af529f8f | 181 | if (compare_filenames_for_search (pst->filename, name)) |
ccefe4c4 | 182 | { |
f5b95b50 | 183 | if (partial_map_expand_apply (objfile, name, real_path, |
f8eba3c6 TT |
184 | pst, callback, data)) |
185 | return 1; | |
ccefe4c4 TT |
186 | } |
187 | ||
c011a4f4 DE |
188 | /* Before we invoke realpath, which can get expensive when many |
189 | files are involved, do a quick comparison of the basenames. */ | |
190 | if (! basenames_may_differ | |
191 | && FILENAME_CMP (name_basename, lbasename (pst->filename)) != 0) | |
192 | continue; | |
193 | ||
05cba821 JK |
194 | if (compare_filenames_for_search (psymtab_to_fullname (pst), name)) |
195 | { | |
196 | if (partial_map_expand_apply (objfile, name, real_path, | |
197 | pst, callback, data)) | |
198 | return 1; | |
199 | } | |
200 | ||
ccefe4c4 TT |
201 | /* If the user gave us an absolute path, try to find the file in |
202 | this symtab and use its absolute path. */ | |
ccefe4c4 TT |
203 | if (real_path != NULL) |
204 | { | |
af529f8f JK |
205 | gdb_assert (IS_ABSOLUTE_PATH (real_path)); |
206 | gdb_assert (IS_ABSOLUTE_PATH (name)); | |
fbd9ab74 | 207 | if (filename_cmp (psymtab_to_fullname (pst), real_path) == 0) |
ccefe4c4 | 208 | { |
f5b95b50 | 209 | if (partial_map_expand_apply (objfile, name, real_path, |
f8eba3c6 TT |
210 | pst, callback, data)) |
211 | return 1; | |
ccefe4c4 TT |
212 | } |
213 | } | |
214 | } | |
215 | ||
f8eba3c6 | 216 | return 0; |
ccefe4c4 TT |
217 | } |
218 | ||
219 | /* Find which partial symtab contains PC and SECTION starting at psymtab PST. | |
220 | We may find a different psymtab than PST. See FIND_PC_SECT_PSYMTAB. */ | |
221 | ||
222 | static struct partial_symtab * | |
5c80ed9d TT |
223 | find_pc_sect_psymtab_closer (struct objfile *objfile, |
224 | CORE_ADDR pc, struct obj_section *section, | |
ccefe4c4 TT |
225 | struct partial_symtab *pst, |
226 | struct minimal_symbol *msymbol) | |
227 | { | |
ccefe4c4 TT |
228 | struct partial_symtab *tpst; |
229 | struct partial_symtab *best_pst = pst; | |
230 | CORE_ADDR best_addr = pst->textlow; | |
231 | ||
9750bca9 JK |
232 | gdb_assert (!pst->psymtabs_addrmap_supported); |
233 | ||
ccefe4c4 TT |
234 | /* An objfile that has its functions reordered might have |
235 | many partial symbol tables containing the PC, but | |
236 | we want the partial symbol table that contains the | |
237 | function containing the PC. */ | |
238 | if (!(objfile->flags & OBJF_REORDERED) && | |
0df8b418 | 239 | section == 0) /* Can't validate section this way. */ |
ccefe4c4 TT |
240 | return pst; |
241 | ||
242 | if (msymbol == NULL) | |
243 | return (pst); | |
244 | ||
245 | /* The code range of partial symtabs sometimes overlap, so, in | |
246 | the loop below, we need to check all partial symtabs and | |
0df8b418 | 247 | find the one that fits better for the given PC address. We |
ccefe4c4 TT |
248 | select the partial symtab that contains a symbol whose |
249 | address is closest to the PC address. By closest we mean | |
250 | that find_pc_sect_symbol returns the symbol with address | |
251 | that is closest and still less than the given PC. */ | |
252 | for (tpst = pst; tpst != NULL; tpst = tpst->next) | |
253 | { | |
254 | if (pc >= tpst->textlow && pc < tpst->texthigh) | |
255 | { | |
256 | struct partial_symbol *p; | |
257 | CORE_ADDR this_addr; | |
258 | ||
259 | /* NOTE: This assumes that every psymbol has a | |
260 | corresponding msymbol, which is not necessarily | |
261 | true; the debug info might be much richer than the | |
262 | object's symbol table. */ | |
5c80ed9d | 263 | p = find_pc_sect_psymbol (objfile, tpst, pc, section); |
ccefe4c4 TT |
264 | if (p != NULL |
265 | && SYMBOL_VALUE_ADDRESS (p) | |
266 | == SYMBOL_VALUE_ADDRESS (msymbol)) | |
267 | return tpst; | |
268 | ||
269 | /* Also accept the textlow value of a psymtab as a | |
270 | "symbol", to provide some support for partial | |
271 | symbol tables with line information but no debug | |
272 | symbols (e.g. those produced by an assembler). */ | |
273 | if (p != NULL) | |
274 | this_addr = SYMBOL_VALUE_ADDRESS (p); | |
275 | else | |
276 | this_addr = tpst->textlow; | |
277 | ||
278 | /* Check whether it is closer than our current | |
279 | BEST_ADDR. Since this symbol address is | |
280 | necessarily lower or equal to PC, the symbol closer | |
281 | to PC is the symbol which address is the highest. | |
282 | This way we return the psymtab which contains such | |
0df8b418 | 283 | best match symbol. This can help in cases where the |
ccefe4c4 TT |
284 | symbol information/debuginfo is not complete, like |
285 | for instance on IRIX6 with gcc, where no debug info | |
0df8b418 MS |
286 | is emitted for statics. (See also the nodebug.exp |
287 | testcase.) */ | |
ccefe4c4 TT |
288 | if (this_addr > best_addr) |
289 | { | |
290 | best_addr = this_addr; | |
291 | best_pst = tpst; | |
292 | } | |
293 | } | |
294 | } | |
295 | return best_pst; | |
296 | } | |
297 | ||
298 | /* Find which partial symtab contains PC and SECTION. Return 0 if | |
299 | none. We return the psymtab that contains a symbol whose address | |
300 | exactly matches PC, or, if we cannot find an exact match, the | |
301 | psymtab that contains a symbol whose address is closest to PC. */ | |
302 | static struct partial_symtab * | |
303 | find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc, | |
304 | struct obj_section *section, | |
305 | struct minimal_symbol *msymbol) | |
306 | { | |
307 | struct partial_symtab *pst; | |
308 | ||
309 | /* Try just the PSYMTABS_ADDRMAP mapping first as it has better granularity | |
310 | than the later used TEXTLOW/TEXTHIGH one. */ | |
311 | ||
312 | if (objfile->psymtabs_addrmap != NULL) | |
313 | { | |
314 | pst = addrmap_find (objfile->psymtabs_addrmap, pc); | |
315 | if (pst != NULL) | |
316 | { | |
317 | /* FIXME: addrmaps currently do not handle overlayed sections, | |
318 | so fall back to the non-addrmap case if we're debugging | |
319 | overlays and the addrmap returned the wrong section. */ | |
320 | if (overlay_debugging && msymbol && section) | |
321 | { | |
322 | struct partial_symbol *p; | |
ad3bbd48 | 323 | |
ccefe4c4 TT |
324 | /* NOTE: This assumes that every psymbol has a |
325 | corresponding msymbol, which is not necessarily | |
326 | true; the debug info might be much richer than the | |
327 | object's symbol table. */ | |
5c80ed9d | 328 | p = find_pc_sect_psymbol (objfile, pst, pc, section); |
ccefe4c4 TT |
329 | if (!p |
330 | || SYMBOL_VALUE_ADDRESS (p) | |
331 | != SYMBOL_VALUE_ADDRESS (msymbol)) | |
332 | goto next; | |
333 | } | |
334 | ||
335 | /* We do not try to call FIND_PC_SECT_PSYMTAB_CLOSER as | |
336 | PSYMTABS_ADDRMAP we used has already the best 1-byte | |
337 | granularity and FIND_PC_SECT_PSYMTAB_CLOSER may mislead us into | |
338 | a worse chosen section due to the TEXTLOW/TEXTHIGH ranges | |
339 | overlap. */ | |
340 | ||
341 | return pst; | |
342 | } | |
343 | } | |
344 | ||
345 | next: | |
346 | ||
347 | /* Existing PSYMTABS_ADDRMAP mapping is present even for PARTIAL_SYMTABs | |
348 | which still have no corresponding full SYMTABs read. But it is not | |
349 | present for non-DWARF2 debug infos not supporting PSYMTABS_ADDRMAP in GDB | |
350 | so far. */ | |
351 | ||
352 | /* Check even OBJFILE with non-zero PSYMTABS_ADDRMAP as only several of | |
353 | its CUs may be missing in PSYMTABS_ADDRMAP as they may be varying | |
354 | debug info type in single OBJFILE. */ | |
355 | ||
b11896a5 | 356 | ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst) |
9750bca9 JK |
357 | if (!pst->psymtabs_addrmap_supported |
358 | && pc >= pst->textlow && pc < pst->texthigh) | |
ccefe4c4 TT |
359 | { |
360 | struct partial_symtab *best_pst; | |
361 | ||
5c80ed9d TT |
362 | best_pst = find_pc_sect_psymtab_closer (objfile, pc, section, pst, |
363 | msymbol); | |
ccefe4c4 TT |
364 | if (best_pst != NULL) |
365 | return best_pst; | |
366 | } | |
367 | ||
368 | return NULL; | |
369 | } | |
370 | ||
371 | static struct symtab * | |
372 | find_pc_sect_symtab_from_partial (struct objfile *objfile, | |
373 | struct minimal_symbol *msymbol, | |
374 | CORE_ADDR pc, struct obj_section *section, | |
375 | int warn_if_readin) | |
376 | { | |
377 | struct partial_symtab *ps = find_pc_sect_psymtab (objfile, pc, section, | |
378 | msymbol); | |
379 | if (ps) | |
380 | { | |
381 | if (warn_if_readin && ps->readin) | |
382 | /* Might want to error() here (in case symtab is corrupt and | |
383 | will cause a core dump), but maybe we can successfully | |
384 | continue, so let's not. */ | |
385 | warning (_("\ | |
386 | (Internal error: pc %s in read in psymtab, but not in symtab.)\n"), | |
5c80ed9d TT |
387 | paddress (get_objfile_arch (objfile), pc)); |
388 | psymtab_to_symtab (objfile, ps); | |
9703b513 | 389 | return ps->symtab; |
ccefe4c4 TT |
390 | } |
391 | return NULL; | |
392 | } | |
393 | ||
394 | /* Find which partial symbol within a psymtab matches PC and SECTION. | |
395 | Return 0 if none. */ | |
396 | ||
397 | static struct partial_symbol * | |
5c80ed9d TT |
398 | find_pc_sect_psymbol (struct objfile *objfile, |
399 | struct partial_symtab *psymtab, CORE_ADDR pc, | |
ccefe4c4 TT |
400 | struct obj_section *section) |
401 | { | |
402 | struct partial_symbol *best = NULL, *p, **pp; | |
403 | CORE_ADDR best_pc; | |
404 | ||
405 | gdb_assert (psymtab != NULL); | |
406 | ||
0df8b418 | 407 | /* Cope with programs that start at address 0. */ |
ccefe4c4 TT |
408 | best_pc = (psymtab->textlow != 0) ? psymtab->textlow - 1 : 0; |
409 | ||
410 | /* Search the global symbols as well as the static symbols, so that | |
411 | find_pc_partial_function doesn't use a minimal symbol and thus | |
412 | cache a bad endaddr. */ | |
5c80ed9d TT |
413 | for (pp = objfile->global_psymbols.list + psymtab->globals_offset; |
414 | (pp - (objfile->global_psymbols.list + psymtab->globals_offset) | |
ccefe4c4 TT |
415 | < psymtab->n_global_syms); |
416 | pp++) | |
417 | { | |
418 | p = *pp; | |
419 | if (SYMBOL_DOMAIN (p) == VAR_DOMAIN | |
420 | && SYMBOL_CLASS (p) == LOC_BLOCK | |
421 | && pc >= SYMBOL_VALUE_ADDRESS (p) | |
422 | && (SYMBOL_VALUE_ADDRESS (p) > best_pc | |
423 | || (psymtab->textlow == 0 | |
424 | && best_pc == 0 && SYMBOL_VALUE_ADDRESS (p) == 0))) | |
425 | { | |
0df8b418 | 426 | if (section) /* Match on a specific section. */ |
ccefe4c4 | 427 | { |
5c80ed9d | 428 | fixup_psymbol_section (p, objfile); |
ccefe4c4 TT |
429 | if (!matching_obj_sections (SYMBOL_OBJ_SECTION (p), section)) |
430 | continue; | |
431 | } | |
432 | best_pc = SYMBOL_VALUE_ADDRESS (p); | |
433 | best = p; | |
434 | } | |
435 | } | |
436 | ||
5c80ed9d TT |
437 | for (pp = objfile->static_psymbols.list + psymtab->statics_offset; |
438 | (pp - (objfile->static_psymbols.list + psymtab->statics_offset) | |
ccefe4c4 TT |
439 | < psymtab->n_static_syms); |
440 | pp++) | |
441 | { | |
442 | p = *pp; | |
443 | if (SYMBOL_DOMAIN (p) == VAR_DOMAIN | |
444 | && SYMBOL_CLASS (p) == LOC_BLOCK | |
445 | && pc >= SYMBOL_VALUE_ADDRESS (p) | |
446 | && (SYMBOL_VALUE_ADDRESS (p) > best_pc | |
447 | || (psymtab->textlow == 0 | |
448 | && best_pc == 0 && SYMBOL_VALUE_ADDRESS (p) == 0))) | |
449 | { | |
0df8b418 | 450 | if (section) /* Match on a specific section. */ |
ccefe4c4 | 451 | { |
5c80ed9d | 452 | fixup_psymbol_section (p, objfile); |
ccefe4c4 TT |
453 | if (!matching_obj_sections (SYMBOL_OBJ_SECTION (p), section)) |
454 | continue; | |
455 | } | |
456 | best_pc = SYMBOL_VALUE_ADDRESS (p); | |
457 | best = p; | |
458 | } | |
459 | } | |
460 | ||
461 | return best; | |
462 | } | |
463 | ||
50da2f25 | 464 | static void |
ccefe4c4 TT |
465 | fixup_psymbol_section (struct partial_symbol *psym, struct objfile *objfile) |
466 | { | |
467 | CORE_ADDR addr; | |
468 | ||
50da2f25 YQ |
469 | if (psym == NULL || SYMBOL_OBJ_SECTION (psym) != NULL) |
470 | return; | |
ccefe4c4 TT |
471 | |
472 | gdb_assert (objfile); | |
473 | ||
474 | switch (SYMBOL_CLASS (psym)) | |
475 | { | |
476 | case LOC_STATIC: | |
477 | case LOC_LABEL: | |
478 | case LOC_BLOCK: | |
479 | addr = SYMBOL_VALUE_ADDRESS (psym); | |
480 | break; | |
481 | default: | |
482 | /* Nothing else will be listed in the minsyms -- no use looking | |
483 | it up. */ | |
50da2f25 | 484 | return; |
ccefe4c4 TT |
485 | } |
486 | ||
487 | fixup_section (&psym->ginfo, addr, objfile); | |
ccefe4c4 TT |
488 | } |
489 | ||
490 | static struct symtab * | |
491 | lookup_symbol_aux_psymtabs (struct objfile *objfile, | |
492 | int block_index, const char *name, | |
493 | const domain_enum domain) | |
494 | { | |
495 | struct partial_symtab *ps; | |
496 | const int psymtab_index = (block_index == GLOBAL_BLOCK ? 1 : 0); | |
bfb05775 | 497 | struct symtab *stab_best = NULL; |
ccefe4c4 | 498 | |
b11896a5 | 499 | ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps) |
ccefe4c4 | 500 | { |
5c80ed9d TT |
501 | if (!ps->readin && lookup_partial_symbol (objfile, ps, name, |
502 | psymtab_index, domain)) | |
c00f8484 KS |
503 | { |
504 | struct symbol *sym = NULL; | |
5c80ed9d | 505 | struct symtab *stab = psymtab_to_symtab (objfile, ps); |
c00f8484 KS |
506 | |
507 | /* Some caution must be observed with overloaded functions | |
508 | and methods, since the psymtab will not contain any overload | |
509 | information (but NAME might contain it). */ | |
510 | if (stab->primary) | |
511 | { | |
512 | struct blockvector *bv = BLOCKVECTOR (stab); | |
513 | struct block *block = BLOCKVECTOR_BLOCK (bv, block_index); | |
514 | ||
515 | sym = lookup_block_symbol (block, name, domain); | |
516 | } | |
517 | ||
518 | if (sym && strcmp_iw (SYMBOL_SEARCH_NAME (sym), name) == 0) | |
bfb05775 JK |
519 | { |
520 | if (!TYPE_IS_OPAQUE (SYMBOL_TYPE (sym))) | |
521 | return stab; | |
522 | ||
523 | stab_best = stab; | |
524 | } | |
c00f8484 KS |
525 | |
526 | /* Keep looking through other psymtabs. */ | |
527 | } | |
ccefe4c4 TT |
528 | } |
529 | ||
bfb05775 | 530 | return stab_best; |
ccefe4c4 TT |
531 | } |
532 | ||
40658b94 PH |
533 | /* Look in PST for a symbol in DOMAIN whose name matches NAME. Search |
534 | the global block of PST if GLOBAL, and otherwise the static block. | |
535 | MATCH is the comparison operation that returns true iff MATCH (s, | |
536 | NAME), where s is a SYMBOL_SEARCH_NAME. If ORDERED_COMPARE is | |
537 | non-null, the symbols in the block are assumed to be ordered | |
538 | according to it (allowing binary search). It must be compatible | |
539 | with MATCH. Returns the symbol, if found, and otherwise NULL. */ | |
540 | ||
541 | static struct partial_symbol * | |
5c80ed9d TT |
542 | match_partial_symbol (struct objfile *objfile, |
543 | struct partial_symtab *pst, int global, | |
40658b94 | 544 | const char *name, domain_enum domain, |
2edb89d3 JK |
545 | symbol_compare_ftype *match, |
546 | symbol_compare_ftype *ordered_compare) | |
40658b94 PH |
547 | { |
548 | struct partial_symbol **start, **psym; | |
549 | struct partial_symbol **top, **real_top, **bottom, **center; | |
550 | int length = (global ? pst->n_global_syms : pst->n_static_syms); | |
551 | int do_linear_search = 1; | |
552 | ||
553 | if (length == 0) | |
554 | return NULL; | |
555 | start = (global ? | |
5c80ed9d TT |
556 | objfile->global_psymbols.list + pst->globals_offset : |
557 | objfile->static_psymbols.list + pst->statics_offset); | |
40658b94 PH |
558 | |
559 | if (global && ordered_compare) /* Can use a binary search. */ | |
560 | { | |
561 | do_linear_search = 0; | |
562 | ||
563 | /* Binary search. This search is guaranteed to end with center | |
564 | pointing at the earliest partial symbol whose name might be | |
565 | correct. At that point *all* partial symbols with an | |
566 | appropriate name will be checked against the correct | |
567 | domain. */ | |
568 | ||
569 | bottom = start; | |
570 | top = start + length - 1; | |
571 | real_top = top; | |
572 | while (top > bottom) | |
573 | { | |
574 | center = bottom + (top - bottom) / 2; | |
575 | gdb_assert (center < top); | |
576 | if (!do_linear_search | |
577 | && (SYMBOL_LANGUAGE (*center) == language_java)) | |
578 | do_linear_search = 1; | |
579 | if (ordered_compare (SYMBOL_SEARCH_NAME (*center), name) >= 0) | |
580 | top = center; | |
581 | else | |
582 | bottom = center + 1; | |
583 | } | |
584 | gdb_assert (top == bottom); | |
585 | ||
586 | while (top <= real_top | |
587 | && match (SYMBOL_SEARCH_NAME (*top), name) == 0) | |
588 | { | |
589 | if (symbol_matches_domain (SYMBOL_LANGUAGE (*top), | |
590 | SYMBOL_DOMAIN (*top), domain)) | |
591 | return *top; | |
592 | top++; | |
593 | } | |
594 | } | |
595 | ||
596 | /* Can't use a binary search or else we found during the binary search that | |
597 | we should also do a linear search. */ | |
598 | ||
599 | if (do_linear_search) | |
600 | { | |
601 | for (psym = start; psym < start + length; psym++) | |
602 | { | |
603 | if (symbol_matches_domain (SYMBOL_LANGUAGE (*psym), | |
604 | SYMBOL_DOMAIN (*psym), domain) | |
605 | && match (SYMBOL_SEARCH_NAME (*psym), name) == 0) | |
606 | return *psym; | |
607 | } | |
608 | } | |
609 | ||
610 | return NULL; | |
611 | } | |
612 | ||
c00f8484 KS |
613 | /* Returns the name used to search psymtabs. Unlike symtabs, psymtabs do |
614 | not contain any method/function instance information (since this would | |
615 | force reading type information while reading psymtabs). Therefore, | |
616 | if NAME contains overload information, it must be stripped before searching | |
617 | psymtabs. | |
618 | ||
619 | The caller is responsible for freeing the return result. */ | |
620 | ||
621 | static char * | |
622 | psymtab_search_name (const char *name) | |
623 | { | |
624 | switch (current_language->la_language) | |
625 | { | |
626 | case language_cplus: | |
627 | case language_java: | |
628 | { | |
629 | if (strchr (name, '(')) | |
630 | { | |
631 | char *ret = cp_remove_params (name); | |
632 | ||
633 | if (ret) | |
634 | return ret; | |
635 | } | |
636 | } | |
637 | break; | |
638 | ||
639 | default: | |
640 | break; | |
641 | } | |
642 | ||
643 | return xstrdup (name); | |
644 | } | |
645 | ||
ccefe4c4 | 646 | /* Look, in partial_symtab PST, for symbol whose natural name is NAME. |
40658b94 | 647 | Check the global symbols if GLOBAL, the static symbols if not. */ |
ccefe4c4 | 648 | |
18430289 | 649 | static struct partial_symbol * |
5c80ed9d TT |
650 | lookup_partial_symbol (struct objfile *objfile, |
651 | struct partial_symtab *pst, const char *name, | |
ccefe4c4 TT |
652 | int global, domain_enum domain) |
653 | { | |
ccefe4c4 TT |
654 | struct partial_symbol **start, **psym; |
655 | struct partial_symbol **top, **real_top, **bottom, **center; | |
656 | int length = (global ? pst->n_global_syms : pst->n_static_syms); | |
657 | int do_linear_search = 1; | |
c00f8484 KS |
658 | char *search_name; |
659 | struct cleanup *cleanup; | |
ccefe4c4 TT |
660 | |
661 | if (length == 0) | |
662 | { | |
663 | return (NULL); | |
664 | } | |
c00f8484 KS |
665 | |
666 | search_name = psymtab_search_name (name); | |
667 | cleanup = make_cleanup (xfree, search_name); | |
ccefe4c4 | 668 | start = (global ? |
5c80ed9d TT |
669 | objfile->global_psymbols.list + pst->globals_offset : |
670 | objfile->static_psymbols.list + pst->statics_offset); | |
ccefe4c4 | 671 | |
0df8b418 | 672 | if (global) /* This means we can use a binary search. */ |
ccefe4c4 TT |
673 | { |
674 | do_linear_search = 0; | |
675 | ||
676 | /* Binary search. This search is guaranteed to end with center | |
677 | pointing at the earliest partial symbol whose name might be | |
678 | correct. At that point *all* partial symbols with an | |
679 | appropriate name will be checked against the correct | |
680 | domain. */ | |
681 | ||
682 | bottom = start; | |
683 | top = start + length - 1; | |
684 | real_top = top; | |
685 | while (top > bottom) | |
686 | { | |
687 | center = bottom + (top - bottom) / 2; | |
688 | if (!(center < top)) | |
3e43a32a MS |
689 | internal_error (__FILE__, __LINE__, |
690 | _("failed internal consistency check")); | |
ccefe4c4 | 691 | if (!do_linear_search |
40658b94 | 692 | && SYMBOL_LANGUAGE (*center) == language_java) |
ccefe4c4 TT |
693 | { |
694 | do_linear_search = 1; | |
695 | } | |
c00f8484 KS |
696 | if (strcmp_iw_ordered (SYMBOL_SEARCH_NAME (*center), |
697 | search_name) >= 0) | |
ccefe4c4 TT |
698 | { |
699 | top = center; | |
700 | } | |
701 | else | |
702 | { | |
703 | bottom = center + 1; | |
704 | } | |
705 | } | |
706 | if (!(top == bottom)) | |
3e43a32a MS |
707 | internal_error (__FILE__, __LINE__, |
708 | _("failed internal consistency check")); | |
ccefe4c4 | 709 | |
559a7a62 JK |
710 | /* For `case_sensitivity == case_sensitive_off' strcmp_iw_ordered will |
711 | search more exactly than what matches SYMBOL_MATCHES_SEARCH_NAME. */ | |
712 | while (top >= start && SYMBOL_MATCHES_SEARCH_NAME (*top, search_name)) | |
713 | top--; | |
714 | ||
715 | /* Fixup to have a symbol which matches SYMBOL_MATCHES_SEARCH_NAME. */ | |
716 | top++; | |
717 | ||
718 | while (top <= real_top && SYMBOL_MATCHES_SEARCH_NAME (*top, search_name)) | |
ccefe4c4 TT |
719 | { |
720 | if (symbol_matches_domain (SYMBOL_LANGUAGE (*top), | |
721 | SYMBOL_DOMAIN (*top), domain)) | |
c00f8484 KS |
722 | { |
723 | do_cleanups (cleanup); | |
724 | return (*top); | |
725 | } | |
ccefe4c4 TT |
726 | top++; |
727 | } | |
728 | } | |
729 | ||
730 | /* Can't use a binary search or else we found during the binary search that | |
40658b94 | 731 | we should also do a linear search. */ |
ccefe4c4 TT |
732 | |
733 | if (do_linear_search) | |
734 | { | |
735 | for (psym = start; psym < start + length; psym++) | |
736 | { | |
737 | if (symbol_matches_domain (SYMBOL_LANGUAGE (*psym), | |
738 | SYMBOL_DOMAIN (*psym), domain) | |
c00f8484 KS |
739 | && SYMBOL_MATCHES_SEARCH_NAME (*psym, search_name)) |
740 | { | |
741 | do_cleanups (cleanup); | |
742 | return (*psym); | |
743 | } | |
ccefe4c4 TT |
744 | } |
745 | } | |
746 | ||
c00f8484 | 747 | do_cleanups (cleanup); |
ccefe4c4 TT |
748 | return (NULL); |
749 | } | |
750 | ||
751 | /* Get the symbol table that corresponds to a partial_symtab. | |
a2ca7a52 | 752 | This is fast after the first time you do it. */ |
ccefe4c4 TT |
753 | |
754 | static struct symtab * | |
5c80ed9d | 755 | psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst) |
ccefe4c4 | 756 | { |
9439a077 TT |
757 | /* If it is a shared psymtab, find an unshared psymtab that includes |
758 | it. Any such psymtab will do. */ | |
759 | while (pst->user != NULL) | |
760 | pst = pst->user; | |
761 | ||
0df8b418 | 762 | /* If it's been looked up before, return it. */ |
ccefe4c4 TT |
763 | if (pst->symtab) |
764 | return pst->symtab; | |
765 | ||
766 | /* If it has not yet been read in, read it. */ | |
767 | if (!pst->readin) | |
768 | { | |
769 | struct cleanup *back_to = increment_reading_symtab (); | |
ad3bbd48 | 770 | |
257e7a09 | 771 | (*pst->read_symtab) (pst, objfile); |
ccefe4c4 TT |
772 | do_cleanups (back_to); |
773 | } | |
774 | ||
775 | return pst->symtab; | |
776 | } | |
777 | ||
778 | static void | |
779 | relocate_psymtabs (struct objfile *objfile, | |
780 | struct section_offsets *new_offsets, | |
781 | struct section_offsets *delta) | |
782 | { | |
783 | struct partial_symbol **psym; | |
784 | struct partial_symtab *p; | |
785 | ||
b11896a5 | 786 | ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, p) |
ccefe4c4 TT |
787 | { |
788 | p->textlow += ANOFFSET (delta, SECT_OFF_TEXT (objfile)); | |
789 | p->texthigh += ANOFFSET (delta, SECT_OFF_TEXT (objfile)); | |
790 | } | |
791 | ||
792 | for (psym = objfile->global_psymbols.list; | |
793 | psym < objfile->global_psymbols.next; | |
794 | psym++) | |
795 | { | |
796 | fixup_psymbol_section (*psym, objfile); | |
797 | if (SYMBOL_SECTION (*psym) >= 0) | |
798 | SYMBOL_VALUE_ADDRESS (*psym) += ANOFFSET (delta, | |
799 | SYMBOL_SECTION (*psym)); | |
800 | } | |
801 | for (psym = objfile->static_psymbols.list; | |
802 | psym < objfile->static_psymbols.next; | |
803 | psym++) | |
804 | { | |
805 | fixup_psymbol_section (*psym, objfile); | |
806 | if (SYMBOL_SECTION (*psym) >= 0) | |
807 | SYMBOL_VALUE_ADDRESS (*psym) += ANOFFSET (delta, | |
808 | SYMBOL_SECTION (*psym)); | |
809 | } | |
810 | } | |
811 | ||
812 | static struct symtab * | |
813 | find_last_source_symtab_from_partial (struct objfile *ofp) | |
814 | { | |
ccefe4c4 TT |
815 | struct partial_symtab *ps; |
816 | struct partial_symtab *cs_pst = 0; | |
817 | ||
b11896a5 | 818 | ALL_OBJFILE_PSYMTABS_REQUIRED (ofp, ps) |
ccefe4c4 TT |
819 | { |
820 | const char *name = ps->filename; | |
821 | int len = strlen (name); | |
ad3bbd48 | 822 | |
ccefe4c4 TT |
823 | if (!(len > 2 && (strcmp (&name[len - 2], ".h") == 0 |
824 | || strcmp (name, "<<C++-namespaces>>") == 0))) | |
825 | cs_pst = ps; | |
826 | } | |
827 | ||
828 | if (cs_pst) | |
829 | { | |
830 | if (cs_pst->readin) | |
831 | { | |
832 | internal_error (__FILE__, __LINE__, | |
833 | _("select_source_symtab: " | |
834 | "readin pst found and no symtabs.")); | |
835 | } | |
836 | else | |
5c80ed9d | 837 | return psymtab_to_symtab (ofp, cs_pst); |
ccefe4c4 TT |
838 | } |
839 | return NULL; | |
840 | } | |
841 | ||
842 | static void | |
843 | forget_cached_source_info_partial (struct objfile *objfile) | |
844 | { | |
845 | struct partial_symtab *pst; | |
846 | ||
b11896a5 | 847 | ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst) |
ccefe4c4 TT |
848 | { |
849 | if (pst->fullname != NULL) | |
850 | { | |
851 | xfree (pst->fullname); | |
852 | pst->fullname = NULL; | |
853 | } | |
854 | } | |
855 | } | |
856 | ||
857 | static void | |
858 | print_partial_symbols (struct gdbarch *gdbarch, | |
859 | struct partial_symbol **p, int count, char *what, | |
860 | struct ui_file *outfile) | |
861 | { | |
862 | fprintf_filtered (outfile, " %s partial symbols:\n", what); | |
863 | while (count-- > 0) | |
864 | { | |
27618ce4 | 865 | QUIT; |
ccefe4c4 TT |
866 | fprintf_filtered (outfile, " `%s'", SYMBOL_LINKAGE_NAME (*p)); |
867 | if (SYMBOL_DEMANGLED_NAME (*p) != NULL) | |
868 | { | |
869 | fprintf_filtered (outfile, " `%s'", SYMBOL_DEMANGLED_NAME (*p)); | |
870 | } | |
871 | fputs_filtered (", ", outfile); | |
872 | switch (SYMBOL_DOMAIN (*p)) | |
873 | { | |
874 | case UNDEF_DOMAIN: | |
875 | fputs_filtered ("undefined domain, ", outfile); | |
876 | break; | |
877 | case VAR_DOMAIN: | |
0df8b418 | 878 | /* This is the usual thing -- don't print it. */ |
ccefe4c4 TT |
879 | break; |
880 | case STRUCT_DOMAIN: | |
881 | fputs_filtered ("struct domain, ", outfile); | |
882 | break; | |
883 | case LABEL_DOMAIN: | |
884 | fputs_filtered ("label domain, ", outfile); | |
885 | break; | |
886 | default: | |
887 | fputs_filtered ("<invalid domain>, ", outfile); | |
888 | break; | |
889 | } | |
890 | switch (SYMBOL_CLASS (*p)) | |
891 | { | |
892 | case LOC_UNDEF: | |
893 | fputs_filtered ("undefined", outfile); | |
894 | break; | |
895 | case LOC_CONST: | |
896 | fputs_filtered ("constant int", outfile); | |
897 | break; | |
898 | case LOC_STATIC: | |
899 | fputs_filtered ("static", outfile); | |
900 | break; | |
901 | case LOC_REGISTER: | |
902 | fputs_filtered ("register", outfile); | |
903 | break; | |
904 | case LOC_ARG: | |
905 | fputs_filtered ("pass by value", outfile); | |
906 | break; | |
907 | case LOC_REF_ARG: | |
908 | fputs_filtered ("pass by reference", outfile); | |
909 | break; | |
910 | case LOC_REGPARM_ADDR: | |
911 | fputs_filtered ("register address parameter", outfile); | |
912 | break; | |
913 | case LOC_LOCAL: | |
914 | fputs_filtered ("stack parameter", outfile); | |
915 | break; | |
916 | case LOC_TYPEDEF: | |
917 | fputs_filtered ("type", outfile); | |
918 | break; | |
919 | case LOC_LABEL: | |
920 | fputs_filtered ("label", outfile); | |
921 | break; | |
922 | case LOC_BLOCK: | |
923 | fputs_filtered ("function", outfile); | |
924 | break; | |
925 | case LOC_CONST_BYTES: | |
926 | fputs_filtered ("constant bytes", outfile); | |
927 | break; | |
928 | case LOC_UNRESOLVED: | |
929 | fputs_filtered ("unresolved", outfile); | |
930 | break; | |
931 | case LOC_OPTIMIZED_OUT: | |
932 | fputs_filtered ("optimized out", outfile); | |
933 | break; | |
934 | case LOC_COMPUTED: | |
935 | fputs_filtered ("computed at runtime", outfile); | |
936 | break; | |
937 | default: | |
938 | fputs_filtered ("<invalid location>", outfile); | |
939 | break; | |
940 | } | |
941 | fputs_filtered (", ", outfile); | |
942 | fputs_filtered (paddress (gdbarch, SYMBOL_VALUE_ADDRESS (*p)), outfile); | |
943 | fprintf_filtered (outfile, "\n"); | |
944 | p++; | |
945 | } | |
946 | } | |
947 | ||
948 | static void | |
949 | dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab, | |
950 | struct ui_file *outfile) | |
951 | { | |
952 | struct gdbarch *gdbarch = get_objfile_arch (objfile); | |
953 | int i; | |
954 | ||
b4c41fc7 DE |
955 | if (psymtab->anonymous) |
956 | { | |
957 | fprintf_filtered (outfile, "\nAnonymous partial symtab (%s) ", | |
958 | psymtab->filename); | |
959 | } | |
960 | else | |
961 | { | |
962 | fprintf_filtered (outfile, "\nPartial symtab for source file %s ", | |
963 | psymtab->filename); | |
964 | } | |
ccefe4c4 TT |
965 | fprintf_filtered (outfile, "(object "); |
966 | gdb_print_host_address (psymtab, outfile); | |
967 | fprintf_filtered (outfile, ")\n\n"); | |
968 | fprintf_unfiltered (outfile, " Read from object file %s (", | |
969 | objfile->name); | |
970 | gdb_print_host_address (objfile, outfile); | |
971 | fprintf_unfiltered (outfile, ")\n"); | |
972 | ||
973 | if (psymtab->readin) | |
974 | { | |
975 | fprintf_filtered (outfile, | |
976 | " Full symtab was read (at "); | |
977 | gdb_print_host_address (psymtab->symtab, outfile); | |
978 | fprintf_filtered (outfile, " by function at "); | |
979 | gdb_print_host_address (psymtab->read_symtab, outfile); | |
980 | fprintf_filtered (outfile, ")\n"); | |
981 | } | |
982 | ||
983 | fprintf_filtered (outfile, " Relocate symbols by "); | |
5c80ed9d | 984 | for (i = 0; i < objfile->num_sections; ++i) |
ccefe4c4 TT |
985 | { |
986 | if (i != 0) | |
987 | fprintf_filtered (outfile, ", "); | |
988 | wrap_here (" "); | |
989 | fputs_filtered (paddress (gdbarch, | |
990 | ANOFFSET (psymtab->section_offsets, i)), | |
991 | outfile); | |
992 | } | |
993 | fprintf_filtered (outfile, "\n"); | |
994 | ||
995 | fprintf_filtered (outfile, " Symbols cover text addresses "); | |
996 | fputs_filtered (paddress (gdbarch, psymtab->textlow), outfile); | |
997 | fprintf_filtered (outfile, "-"); | |
998 | fputs_filtered (paddress (gdbarch, psymtab->texthigh), outfile); | |
999 | fprintf_filtered (outfile, "\n"); | |
9750bca9 JK |
1000 | fprintf_filtered (outfile, " Address map supported - %s.\n", |
1001 | psymtab->psymtabs_addrmap_supported ? "yes" : "no"); | |
ccefe4c4 TT |
1002 | fprintf_filtered (outfile, " Depends on %d other partial symtabs.\n", |
1003 | psymtab->number_of_dependencies); | |
1004 | for (i = 0; i < psymtab->number_of_dependencies; i++) | |
1005 | { | |
1006 | fprintf_filtered (outfile, " %d ", i); | |
1007 | gdb_print_host_address (psymtab->dependencies[i], outfile); | |
1008 | fprintf_filtered (outfile, " %s\n", | |
1009 | psymtab->dependencies[i]->filename); | |
1010 | } | |
9439a077 TT |
1011 | if (psymtab->user != NULL) |
1012 | { | |
1013 | fprintf_filtered (outfile, " Shared partial symtab with user "); | |
1014 | gdb_print_host_address (psymtab->user, outfile); | |
1015 | fprintf_filtered (outfile, "\n"); | |
1016 | } | |
ccefe4c4 TT |
1017 | if (psymtab->n_global_syms > 0) |
1018 | { | |
1019 | print_partial_symbols (gdbarch, | |
1020 | objfile->global_psymbols.list | |
1021 | + psymtab->globals_offset, | |
1022 | psymtab->n_global_syms, "Global", outfile); | |
1023 | } | |
1024 | if (psymtab->n_static_syms > 0) | |
1025 | { | |
1026 | print_partial_symbols (gdbarch, | |
1027 | objfile->static_psymbols.list | |
1028 | + psymtab->statics_offset, | |
1029 | psymtab->n_static_syms, "Static", outfile); | |
1030 | } | |
1031 | fprintf_filtered (outfile, "\n"); | |
1032 | } | |
1033 | ||
1034 | static void | |
1035 | print_psymtab_stats_for_objfile (struct objfile *objfile) | |
1036 | { | |
1037 | int i; | |
1038 | struct partial_symtab *ps; | |
ad3bbd48 | 1039 | |
ccefe4c4 | 1040 | i = 0; |
b11896a5 | 1041 | ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps) |
ccefe4c4 TT |
1042 | { |
1043 | if (ps->readin == 0) | |
1044 | i++; | |
1045 | } | |
1046 | printf_filtered (_(" Number of psym tables (not yet expanded): %d\n"), i); | |
1047 | } | |
1048 | ||
1049 | static void | |
1050 | dump_psymtabs_for_objfile (struct objfile *objfile) | |
1051 | { | |
1052 | struct partial_symtab *psymtab; | |
1053 | ||
1054 | if (objfile->psymtabs) | |
1055 | { | |
1056 | printf_filtered ("Psymtabs:\n"); | |
1057 | for (psymtab = objfile->psymtabs; | |
1058 | psymtab != NULL; | |
1059 | psymtab = psymtab->next) | |
1060 | { | |
1061 | printf_filtered ("%s at ", | |
1062 | psymtab->filename); | |
1063 | gdb_print_host_address (psymtab, gdb_stdout); | |
1064 | printf_filtered (", "); | |
ccefe4c4 TT |
1065 | wrap_here (" "); |
1066 | } | |
1067 | printf_filtered ("\n\n"); | |
1068 | } | |
1069 | } | |
1070 | ||
1071 | /* Look through the partial symtabs for all symbols which begin | |
0df8b418 | 1072 | by matching FUNC_NAME. Make sure we read that symbol table in. */ |
ccefe4c4 TT |
1073 | |
1074 | static void | |
1075 | read_symtabs_for_function (struct objfile *objfile, const char *func_name) | |
1076 | { | |
1077 | struct partial_symtab *ps; | |
1078 | ||
b11896a5 | 1079 | ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps) |
ccefe4c4 TT |
1080 | { |
1081 | if (ps->readin) | |
1082 | continue; | |
1083 | ||
5c80ed9d | 1084 | if ((lookup_partial_symbol (objfile, ps, func_name, 1, VAR_DOMAIN) |
ccefe4c4 | 1085 | != NULL) |
5c80ed9d | 1086 | || (lookup_partial_symbol (objfile, ps, func_name, 0, VAR_DOMAIN) |
ccefe4c4 | 1087 | != NULL)) |
5c80ed9d | 1088 | psymtab_to_symtab (objfile, ps); |
ccefe4c4 TT |
1089 | } |
1090 | } | |
1091 | ||
1092 | static void | |
1093 | expand_partial_symbol_tables (struct objfile *objfile) | |
1094 | { | |
1095 | struct partial_symtab *psymtab; | |
1096 | ||
b11896a5 | 1097 | ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, psymtab) |
ccefe4c4 | 1098 | { |
5c80ed9d | 1099 | psymtab_to_symtab (objfile, psymtab); |
ccefe4c4 TT |
1100 | } |
1101 | } | |
1102 | ||
1103 | static void | |
652a8996 | 1104 | read_psymtabs_with_fullname (struct objfile *objfile, const char *fullname) |
ccefe4c4 TT |
1105 | { |
1106 | struct partial_symtab *p; | |
1107 | ||
b11896a5 | 1108 | ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, p) |
ccefe4c4 | 1109 | { |
b4c41fc7 DE |
1110 | /* Anonymous psymtabs don't have a name of a source file. */ |
1111 | if (p->anonymous) | |
1112 | continue; | |
1113 | ||
05cba821 | 1114 | if (filename_cmp (fullname, psymtab_to_fullname (p)) == 0) |
5c80ed9d | 1115 | psymtab_to_symtab (objfile, p); |
ccefe4c4 TT |
1116 | } |
1117 | } | |
1118 | ||
ccefe4c4 TT |
1119 | static void |
1120 | map_symbol_filenames_psymtab (struct objfile *objfile, | |
74e2f255 DE |
1121 | symbol_filename_ftype *fun, void *data, |
1122 | int need_fullname) | |
ccefe4c4 TT |
1123 | { |
1124 | struct partial_symtab *ps; | |
1125 | ||
b11896a5 | 1126 | ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps) |
ccefe4c4 TT |
1127 | { |
1128 | const char *fullname; | |
1129 | ||
1130 | if (ps->readin) | |
1131 | continue; | |
1132 | ||
f80c6f3f DE |
1133 | /* We can skip shared psymtabs here, because any file name will be |
1134 | attached to the unshared psymtab. */ | |
1135 | if (ps->user != NULL) | |
1136 | continue; | |
1137 | ||
b4c41fc7 DE |
1138 | /* Anonymous psymtabs don't have a file name. */ |
1139 | if (ps->anonymous) | |
1140 | continue; | |
1141 | ||
821296b7 | 1142 | QUIT; |
74e2f255 DE |
1143 | if (need_fullname) |
1144 | fullname = psymtab_to_fullname (ps); | |
1145 | else | |
1146 | fullname = NULL; | |
2837d59e | 1147 | (*fun) (ps->filename, fullname, data); |
ccefe4c4 TT |
1148 | } |
1149 | } | |
1150 | ||
ccefe4c4 TT |
1151 | /* Finds the fullname that a partial_symtab represents. |
1152 | ||
1153 | If this functions finds the fullname, it will save it in ps->fullname | |
1154 | and it will also return the value. | |
1155 | ||
1156 | If this function fails to find the file that this partial_symtab represents, | |
1157 | NULL will be returned and ps->fullname will be set to NULL. */ | |
256f06f3 | 1158 | |
da5132d3 | 1159 | static const char * |
ccefe4c4 TT |
1160 | psymtab_to_fullname (struct partial_symtab *ps) |
1161 | { | |
fbd9ab74 | 1162 | gdb_assert (!ps->anonymous); |
ccefe4c4 | 1163 | |
256f06f3 DE |
1164 | /* Use cached copy if we have it. |
1165 | We rely on forget_cached_source_info being called appropriately | |
1166 | to handle cases like the file being moved. */ | |
fbd9ab74 JK |
1167 | if (ps->fullname == NULL) |
1168 | { | |
1169 | int fd = find_and_open_source (ps->filename, ps->dirname, &ps->fullname); | |
256f06f3 | 1170 | |
fbd9ab74 JK |
1171 | if (fd >= 0) |
1172 | close (fd); | |
1173 | else | |
1174 | { | |
1175 | char *fullname; | |
1176 | struct cleanup *back_to; | |
ccefe4c4 | 1177 | |
fbd9ab74 JK |
1178 | /* rewrite_source_path would be applied by find_and_open_source, we |
1179 | should report the pathname where GDB tried to find the file. */ | |
ccefe4c4 | 1180 | |
fbd9ab74 JK |
1181 | if (ps->dirname == NULL || IS_ABSOLUTE_PATH (ps->filename)) |
1182 | fullname = xstrdup (ps->filename); | |
1183 | else | |
1184 | fullname = concat (ps->dirname, SLASH_STRING, ps->filename, NULL); | |
1185 | ||
1186 | back_to = make_cleanup (xfree, fullname); | |
1187 | ps->fullname = rewrite_source_path (fullname); | |
1188 | if (ps->fullname == NULL) | |
1189 | ps->fullname = xstrdup (fullname); | |
1190 | do_cleanups (back_to); | |
1191 | } | |
1192 | } | |
1193 | ||
1194 | return ps->fullname; | |
ccefe4c4 TT |
1195 | } |
1196 | ||
dd786858 | 1197 | static const char * |
ccefe4c4 TT |
1198 | find_symbol_file_from_partial (struct objfile *objfile, const char *name) |
1199 | { | |
1200 | struct partial_symtab *pst; | |
1201 | ||
b11896a5 | 1202 | ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst) |
ccefe4c4 | 1203 | { |
5c80ed9d | 1204 | if (lookup_partial_symbol (objfile, pst, name, 1, VAR_DOMAIN)) |
ccefe4c4 TT |
1205 | return pst->filename; |
1206 | } | |
1207 | return NULL; | |
1208 | } | |
1209 | ||
40658b94 PH |
1210 | /* For all symbols, s, in BLOCK that are in NAMESPACE and match NAME |
1211 | according to the function MATCH, call CALLBACK(BLOCK, s, DATA). | |
1212 | BLOCK is assumed to come from OBJFILE. Returns 1 iff CALLBACK | |
1213 | ever returns non-zero, and otherwise returns 0. */ | |
ccefe4c4 | 1214 | |
40658b94 PH |
1215 | static int |
1216 | map_block (const char *name, domain_enum namespace, struct objfile *objfile, | |
1217 | struct block *block, | |
1218 | int (*callback) (struct block *, struct symbol *, void *), | |
2edb89d3 | 1219 | void *data, symbol_compare_ftype *match) |
ccefe4c4 | 1220 | { |
8157b174 | 1221 | struct block_iterator iter; |
40658b94 | 1222 | struct symbol *sym; |
ccefe4c4 | 1223 | |
8157b174 TT |
1224 | for (sym = block_iter_match_first (block, name, match, &iter); |
1225 | sym != NULL; sym = block_iter_match_next (name, match, &iter)) | |
ccefe4c4 | 1226 | { |
40658b94 PH |
1227 | if (symbol_matches_domain (SYMBOL_LANGUAGE (sym), |
1228 | SYMBOL_DOMAIN (sym), namespace)) | |
1229 | { | |
1230 | if (callback (block, sym, data)) | |
1231 | return 1; | |
1232 | } | |
ccefe4c4 TT |
1233 | } |
1234 | ||
40658b94 | 1235 | return 0; |
ccefe4c4 TT |
1236 | } |
1237 | ||
40658b94 PH |
1238 | /* Psymtab version of map_matching_symbols. See its definition in |
1239 | the definition of quick_symbol_functions in symfile.h. */ | |
1240 | ||
ccefe4c4 | 1241 | static void |
40658b94 PH |
1242 | map_matching_symbols_psymtab (const char *name, domain_enum namespace, |
1243 | struct objfile *objfile, int global, | |
1244 | int (*callback) (struct block *, | |
1245 | struct symbol *, void *), | |
1246 | void *data, | |
2edb89d3 JK |
1247 | symbol_compare_ftype *match, |
1248 | symbol_compare_ftype *ordered_compare) | |
ccefe4c4 | 1249 | { |
40658b94 | 1250 | const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK; |
ccefe4c4 TT |
1251 | struct partial_symtab *ps; |
1252 | ||
b11896a5 | 1253 | ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps) |
ccefe4c4 TT |
1254 | { |
1255 | QUIT; | |
1256 | if (ps->readin | |
5c80ed9d | 1257 | || match_partial_symbol (objfile, ps, global, name, namespace, match, |
40658b94 | 1258 | ordered_compare)) |
ccefe4c4 | 1259 | { |
5c80ed9d | 1260 | struct symtab *s = psymtab_to_symtab (objfile, ps); |
40658b94 | 1261 | struct block *block; |
ad3bbd48 | 1262 | |
ccefe4c4 TT |
1263 | if (s == NULL || !s->primary) |
1264 | continue; | |
40658b94 PH |
1265 | block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), block_kind); |
1266 | if (map_block (name, namespace, objfile, block, | |
1267 | callback, data, match)) | |
1268 | return; | |
1269 | if (callback (block, NULL, data)) | |
1270 | return; | |
ccefe4c4 TT |
1271 | } |
1272 | } | |
40658b94 | 1273 | } |
ccefe4c4 | 1274 | |
9439a077 TT |
1275 | /* A helper for expand_symtabs_matching_via_partial that handles |
1276 | searching included psymtabs. This returns 1 if a symbol is found, | |
1277 | and zero otherwise. It also updates the 'searched_flag' on the | |
1278 | various psymtabs that it searches. */ | |
1279 | ||
1280 | static int | |
1281 | recursively_search_psymtabs (struct partial_symtab *ps, | |
1282 | struct objfile *objfile, | |
1283 | enum search_domain kind, | |
1284 | int (*name_matcher) (const char *, void *), | |
1285 | void *data) | |
1286 | { | |
1287 | struct partial_symbol **psym; | |
1288 | struct partial_symbol **bound, **gbound, **sbound; | |
1289 | int keep_going = 1; | |
1290 | int result = PST_SEARCHED_AND_NOT_FOUND; | |
1291 | int i; | |
1292 | ||
1293 | if (ps->searched_flag != PST_NOT_SEARCHED) | |
1294 | return ps->searched_flag == PST_SEARCHED_AND_FOUND; | |
1295 | ||
1296 | /* Recurse into shared psymtabs first, because they may have already | |
1297 | been searched, and this could save some time. */ | |
1298 | for (i = 0; i < ps->number_of_dependencies; ++i) | |
1299 | { | |
1300 | int r; | |
1301 | ||
1302 | /* Skip non-shared dependencies, these are handled elsewhere. */ | |
1303 | if (ps->dependencies[i]->user == NULL) | |
1304 | continue; | |
1305 | ||
1306 | r = recursively_search_psymtabs (ps->dependencies[i], | |
1307 | objfile, kind, name_matcher, data); | |
1308 | if (r != 0) | |
1309 | { | |
1310 | ps->searched_flag = PST_SEARCHED_AND_FOUND; | |
1311 | return 1; | |
1312 | } | |
1313 | } | |
1314 | ||
1315 | gbound = (objfile->global_psymbols.list | |
1316 | + ps->globals_offset + ps->n_global_syms); | |
1317 | sbound = (objfile->static_psymbols.list | |
1318 | + ps->statics_offset + ps->n_static_syms); | |
1319 | bound = gbound; | |
1320 | ||
1321 | /* Go through all of the symbols stored in a partial | |
1322 | symtab in one loop. */ | |
1323 | psym = objfile->global_psymbols.list + ps->globals_offset; | |
1324 | while (keep_going) | |
1325 | { | |
1326 | if (psym >= bound) | |
1327 | { | |
1328 | if (bound == gbound && ps->n_static_syms != 0) | |
1329 | { | |
1330 | psym = objfile->static_psymbols.list + ps->statics_offset; | |
1331 | bound = sbound; | |
1332 | } | |
1333 | else | |
1334 | keep_going = 0; | |
1335 | continue; | |
1336 | } | |
1337 | else | |
1338 | { | |
1339 | QUIT; | |
1340 | ||
1341 | if ((kind == ALL_DOMAIN | |
1342 | || (kind == VARIABLES_DOMAIN | |
1343 | && SYMBOL_CLASS (*psym) != LOC_TYPEDEF | |
1344 | && SYMBOL_CLASS (*psym) != LOC_BLOCK) | |
1345 | || (kind == FUNCTIONS_DOMAIN | |
1346 | && SYMBOL_CLASS (*psym) == LOC_BLOCK) | |
1347 | || (kind == TYPES_DOMAIN | |
1348 | && SYMBOL_CLASS (*psym) == LOC_TYPEDEF)) | |
1349 | && (*name_matcher) (SYMBOL_SEARCH_NAME (*psym), data)) | |
1350 | { | |
1351 | /* Found a match, so notify our caller. */ | |
1352 | result = PST_SEARCHED_AND_FOUND; | |
1353 | keep_going = 0; | |
1354 | } | |
1355 | } | |
1356 | psym++; | |
1357 | } | |
1358 | ||
1359 | ps->searched_flag = result; | |
1360 | return result == PST_SEARCHED_AND_FOUND; | |
1361 | } | |
1362 | ||
ccefe4c4 | 1363 | static void |
f8eba3c6 TT |
1364 | expand_symtabs_matching_via_partial |
1365 | (struct objfile *objfile, | |
fbd9ab74 | 1366 | int (*file_matcher) (const char *, void *, int basenames), |
e078317b | 1367 | int (*name_matcher) (const char *, void *), |
f8eba3c6 TT |
1368 | enum search_domain kind, |
1369 | void *data) | |
ccefe4c4 TT |
1370 | { |
1371 | struct partial_symtab *ps; | |
1372 | ||
9439a077 | 1373 | /* Clear the search flags. */ |
b11896a5 | 1374 | ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps) |
ccefe4c4 | 1375 | { |
9439a077 TT |
1376 | ps->searched_flag = PST_NOT_SEARCHED; |
1377 | } | |
ccefe4c4 | 1378 | |
9439a077 TT |
1379 | ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps) |
1380 | { | |
ccefe4c4 TT |
1381 | if (ps->readin) |
1382 | continue; | |
1383 | ||
9439a077 TT |
1384 | /* We skip shared psymtabs because file-matching doesn't apply |
1385 | to them; but we search them later in the loop. */ | |
1386 | if (ps->user != NULL) | |
ccefe4c4 TT |
1387 | continue; |
1388 | ||
b4c41fc7 DE |
1389 | if (file_matcher) |
1390 | { | |
1391 | if (ps->anonymous) | |
1392 | continue; | |
fbd9ab74 JK |
1393 | |
1394 | /* Before we invoke realpath, which can get expensive when many | |
1395 | files are involved, do a quick comparison of the basenames. */ | |
1396 | if (!(*file_matcher) (ps->filename, data, 0) | |
1397 | && (basenames_may_differ | |
1398 | || (*file_matcher) (lbasename (ps->filename), data, 1)) | |
1399 | && !(*file_matcher) (psymtab_to_fullname (ps), data, 0)) | |
b4c41fc7 DE |
1400 | continue; |
1401 | } | |
ccefe4c4 | 1402 | |
9439a077 | 1403 | if (recursively_search_psymtabs (ps, objfile, kind, name_matcher, data)) |
5c80ed9d | 1404 | psymtab_to_symtab (objfile, ps); |
ccefe4c4 TT |
1405 | } |
1406 | } | |
1407 | ||
1408 | static int | |
1409 | objfile_has_psyms (struct objfile *objfile) | |
1410 | { | |
1411 | return objfile->psymtabs != NULL; | |
1412 | } | |
1413 | ||
1414 | const struct quick_symbol_functions psym_functions = | |
1415 | { | |
1416 | objfile_has_psyms, | |
1417 | find_last_source_symtab_from_partial, | |
1418 | forget_cached_source_info_partial, | |
f8eba3c6 | 1419 | partial_map_symtabs_matching_filename, |
ccefe4c4 TT |
1420 | lookup_symbol_aux_psymtabs, |
1421 | print_psymtab_stats_for_objfile, | |
1422 | dump_psymtabs_for_objfile, | |
1423 | relocate_psymtabs, | |
1424 | read_symtabs_for_function, | |
1425 | expand_partial_symbol_tables, | |
652a8996 | 1426 | read_psymtabs_with_fullname, |
ccefe4c4 | 1427 | find_symbol_file_from_partial, |
40658b94 | 1428 | map_matching_symbols_psymtab, |
ccefe4c4 TT |
1429 | expand_symtabs_matching_via_partial, |
1430 | find_pc_sect_symtab_from_partial, | |
ccefe4c4 TT |
1431 | map_symbol_filenames_psymtab |
1432 | }; | |
1433 | ||
1434 | \f | |
1435 | ||
1436 | /* This compares two partial symbols by names, using strcmp_iw_ordered | |
1437 | for the comparison. */ | |
1438 | ||
1439 | static int | |
1440 | compare_psymbols (const void *s1p, const void *s2p) | |
1441 | { | |
1442 | struct partial_symbol *const *s1 = s1p; | |
1443 | struct partial_symbol *const *s2 = s2p; | |
1444 | ||
1445 | return strcmp_iw_ordered (SYMBOL_SEARCH_NAME (*s1), | |
1446 | SYMBOL_SEARCH_NAME (*s2)); | |
1447 | } | |
1448 | ||
1449 | void | |
5c80ed9d | 1450 | sort_pst_symbols (struct objfile *objfile, struct partial_symtab *pst) |
ccefe4c4 | 1451 | { |
0df8b418 | 1452 | /* Sort the global list; don't sort the static list. */ |
ccefe4c4 | 1453 | |
5c80ed9d | 1454 | qsort (objfile->global_psymbols.list + pst->globals_offset, |
ccefe4c4 TT |
1455 | pst->n_global_syms, sizeof (struct partial_symbol *), |
1456 | compare_psymbols); | |
1457 | } | |
1458 | ||
1459 | /* Allocate and partially fill a partial symtab. It will be | |
1460 | completely filled at the end of the symbol list. | |
1461 | ||
0df8b418 | 1462 | FILENAME is the name of the symbol-file we are reading from. */ |
ccefe4c4 TT |
1463 | |
1464 | struct partial_symtab * | |
1465 | start_psymtab_common (struct objfile *objfile, | |
1466 | struct section_offsets *section_offsets, | |
1467 | const char *filename, | |
1468 | CORE_ADDR textlow, struct partial_symbol **global_syms, | |
1469 | struct partial_symbol **static_syms) | |
1470 | { | |
1471 | struct partial_symtab *psymtab; | |
1472 | ||
1473 | psymtab = allocate_psymtab (filename, objfile); | |
1474 | psymtab->section_offsets = section_offsets; | |
1475 | psymtab->textlow = textlow; | |
1476 | psymtab->texthigh = psymtab->textlow; /* default */ | |
1477 | psymtab->globals_offset = global_syms - objfile->global_psymbols.list; | |
1478 | psymtab->statics_offset = static_syms - objfile->static_psymbols.list; | |
1479 | return (psymtab); | |
1480 | } | |
1481 | ||
cbd70537 SW |
1482 | /* Calculate a hash code for the given partial symbol. The hash is |
1483 | calculated using the symbol's value, language, domain, class | |
0df8b418 | 1484 | and name. These are the values which are set by |
cbd70537 SW |
1485 | add_psymbol_to_bcache. */ |
1486 | ||
710e1a31 | 1487 | static unsigned long |
cbd70537 SW |
1488 | psymbol_hash (const void *addr, int length) |
1489 | { | |
1490 | unsigned long h = 0; | |
1491 | struct partial_symbol *psymbol = (struct partial_symbol *) addr; | |
1492 | unsigned int lang = psymbol->ginfo.language; | |
1493 | unsigned int domain = PSYMBOL_DOMAIN (psymbol); | |
1494 | unsigned int class = PSYMBOL_CLASS (psymbol); | |
1495 | ||
1496 | h = hash_continue (&psymbol->ginfo.value, sizeof (psymbol->ginfo.value), h); | |
1497 | h = hash_continue (&lang, sizeof (unsigned int), h); | |
1498 | h = hash_continue (&domain, sizeof (unsigned int), h); | |
1499 | h = hash_continue (&class, sizeof (unsigned int), h); | |
1500 | h = hash_continue (psymbol->ginfo.name, strlen (psymbol->ginfo.name), h); | |
1501 | ||
1502 | return h; | |
1503 | } | |
1504 | ||
1505 | /* Returns true if the symbol at addr1 equals the symbol at addr2. | |
1506 | For the comparison this function uses a symbols value, | |
1507 | language, domain, class and name. */ | |
1508 | ||
710e1a31 | 1509 | static int |
cbd70537 SW |
1510 | psymbol_compare (const void *addr1, const void *addr2, int length) |
1511 | { | |
1512 | struct partial_symbol *sym1 = (struct partial_symbol *) addr1; | |
1513 | struct partial_symbol *sym2 = (struct partial_symbol *) addr2; | |
1514 | ||
1515 | return (memcmp (&sym1->ginfo.value, &sym1->ginfo.value, | |
1516 | sizeof (sym1->ginfo.value)) == 0 | |
1517 | && sym1->ginfo.language == sym2->ginfo.language | |
1518 | && PSYMBOL_DOMAIN (sym1) == PSYMBOL_DOMAIN (sym2) | |
1519 | && PSYMBOL_CLASS (sym1) == PSYMBOL_CLASS (sym2) | |
1520 | && sym1->ginfo.name == sym2->ginfo.name); | |
1521 | } | |
1522 | ||
710e1a31 SW |
1523 | /* Initialize a partial symbol bcache. */ |
1524 | ||
1525 | struct psymbol_bcache * | |
1526 | psymbol_bcache_init (void) | |
1527 | { | |
1528 | struct psymbol_bcache *bcache = XCALLOC (1, struct psymbol_bcache); | |
1529 | bcache->bcache = bcache_xmalloc (psymbol_hash, psymbol_compare); | |
1530 | return bcache; | |
1531 | } | |
1532 | ||
1533 | /* Free a partial symbol bcache. */ | |
1534 | void | |
1535 | psymbol_bcache_free (struct psymbol_bcache *bcache) | |
1536 | { | |
1537 | if (bcache == NULL) | |
1538 | return; | |
1539 | ||
1540 | bcache_xfree (bcache->bcache); | |
1541 | xfree (bcache); | |
1542 | } | |
1543 | ||
0df8b418 | 1544 | /* Return the internal bcache of the psymbol_bcache BCACHE. */ |
710e1a31 SW |
1545 | |
1546 | struct bcache * | |
1547 | psymbol_bcache_get_bcache (struct psymbol_bcache *bcache) | |
1548 | { | |
1549 | return bcache->bcache; | |
1550 | } | |
1551 | ||
1552 | /* Find a copy of the SYM in BCACHE. If BCACHE has never seen this | |
1553 | symbol before, add a copy to BCACHE. In either case, return a pointer | |
1554 | to BCACHE's copy of the symbol. If optional ADDED is not NULL, return | |
1555 | 1 in case of new entry or 0 if returning an old entry. */ | |
1556 | ||
1557 | static const struct partial_symbol * | |
1558 | psymbol_bcache_full (struct partial_symbol *sym, | |
1559 | struct psymbol_bcache *bcache, | |
1560 | int *added) | |
1561 | { | |
1562 | return bcache_full (sym, | |
1563 | sizeof (struct partial_symbol), | |
1564 | bcache->bcache, | |
1565 | added); | |
1566 | } | |
1567 | ||
ccefe4c4 TT |
1568 | /* Helper function, initialises partial symbol structure and stashes |
1569 | it into objfile's bcache. Note that our caching mechanism will | |
1570 | use all fields of struct partial_symbol to determine hash value of the | |
1571 | structure. In other words, having two symbols with the same name but | |
1572 | different domain (or address) is possible and correct. */ | |
1573 | ||
1574 | static const struct partial_symbol * | |
72b9f47f | 1575 | add_psymbol_to_bcache (const char *name, int namelength, int copy_name, |
ccefe4c4 TT |
1576 | domain_enum domain, |
1577 | enum address_class class, | |
1578 | long val, /* Value as a long */ | |
1579 | CORE_ADDR coreaddr, /* Value as a CORE_ADDR */ | |
1580 | enum language language, struct objfile *objfile, | |
1581 | int *added) | |
1582 | { | |
cbd70537 SW |
1583 | struct partial_symbol psymbol; |
1584 | ||
fc956729 SW |
1585 | /* We must ensure that the entire 'value' field has been zeroed |
1586 | before assigning to it, because an assignment may not write the | |
1587 | entire field. */ | |
1588 | memset (&psymbol.ginfo.value, 0, sizeof (psymbol.ginfo.value)); | |
1589 | ||
0df8b418 | 1590 | /* val and coreaddr are mutually exclusive, one of them *will* be zero. */ |
ccefe4c4 TT |
1591 | if (val != 0) |
1592 | { | |
1593 | SYMBOL_VALUE (&psymbol) = val; | |
1594 | } | |
1595 | else | |
1596 | { | |
1597 | SYMBOL_VALUE_ADDRESS (&psymbol) = coreaddr; | |
1598 | } | |
1599 | SYMBOL_SECTION (&psymbol) = 0; | |
fc956729 | 1600 | SYMBOL_OBJ_SECTION (&psymbol) = NULL; |
33e5013e | 1601 | SYMBOL_SET_LANGUAGE (&psymbol, language); |
ccefe4c4 TT |
1602 | PSYMBOL_DOMAIN (&psymbol) = domain; |
1603 | PSYMBOL_CLASS (&psymbol) = class; | |
1604 | ||
1605 | SYMBOL_SET_NAMES (&psymbol, name, namelength, copy_name, objfile); | |
1606 | ||
0df8b418 | 1607 | /* Stash the partial symbol away in the cache. */ |
710e1a31 SW |
1608 | return psymbol_bcache_full (&psymbol, |
1609 | objfile->psymbol_cache, | |
1610 | added); | |
ccefe4c4 TT |
1611 | } |
1612 | ||
923c6a3d | 1613 | /* Increase the space allocated for LISTP, which is probably |
0df8b418 | 1614 | global_psymbols or static_psymbols. This space will eventually |
923c6a3d TT |
1615 | be freed in free_objfile(). */ |
1616 | ||
1617 | static void | |
1618 | extend_psymbol_list (struct psymbol_allocation_list *listp, | |
1619 | struct objfile *objfile) | |
1620 | { | |
1621 | int new_size; | |
1622 | ||
1623 | if (listp->size == 0) | |
1624 | { | |
1625 | new_size = 255; | |
1626 | listp->list = (struct partial_symbol **) | |
1627 | xmalloc (new_size * sizeof (struct partial_symbol *)); | |
1628 | } | |
1629 | else | |
1630 | { | |
1631 | new_size = listp->size * 2; | |
1632 | listp->list = (struct partial_symbol **) | |
1633 | xrealloc ((char *) listp->list, | |
1634 | new_size * sizeof (struct partial_symbol *)); | |
1635 | } | |
1636 | /* Next assumes we only went one over. Should be good if | |
0df8b418 | 1637 | program works correctly. */ |
923c6a3d TT |
1638 | listp->next = listp->list + listp->size; |
1639 | listp->size = new_size; | |
1640 | } | |
1641 | ||
ccefe4c4 TT |
1642 | /* Helper function, adds partial symbol to the given partial symbol |
1643 | list. */ | |
1644 | ||
1645 | static void | |
1646 | append_psymbol_to_list (struct psymbol_allocation_list *list, | |
1647 | const struct partial_symbol *psym, | |
1648 | struct objfile *objfile) | |
1649 | { | |
1650 | if (list->next >= list->list + list->size) | |
1651 | extend_psymbol_list (list, objfile); | |
1652 | *list->next++ = (struct partial_symbol *) psym; | |
1653 | OBJSTAT (objfile, n_psyms++); | |
1654 | } | |
1655 | ||
1656 | /* Add a symbol with a long value to a psymtab. | |
1657 | Since one arg is a struct, we pass in a ptr and deref it (sigh). | |
1658 | Return the partial symbol that has been added. */ | |
1659 | ||
7dc25483 | 1660 | void |
72b9f47f | 1661 | add_psymbol_to_list (const char *name, int namelength, int copy_name, |
ccefe4c4 TT |
1662 | domain_enum domain, |
1663 | enum address_class class, | |
1664 | struct psymbol_allocation_list *list, | |
1665 | long val, /* Value as a long */ | |
1666 | CORE_ADDR coreaddr, /* Value as a CORE_ADDR */ | |
1667 | enum language language, struct objfile *objfile) | |
1668 | { | |
1669 | const struct partial_symbol *psym; | |
1670 | ||
1671 | int added; | |
1672 | ||
0df8b418 | 1673 | /* Stash the partial symbol away in the cache. */ |
ccefe4c4 TT |
1674 | psym = add_psymbol_to_bcache (name, namelength, copy_name, domain, class, |
1675 | val, coreaddr, language, objfile, &added); | |
1676 | ||
1677 | /* Do not duplicate global partial symbols. */ | |
1678 | if (list == &objfile->global_psymbols | |
1679 | && !added) | |
7dc25483 | 1680 | return; |
ccefe4c4 | 1681 | |
0df8b418 | 1682 | /* Save pointer to partial symbol in psymtab, growing symtab if needed. */ |
ccefe4c4 | 1683 | append_psymbol_to_list (list, psym, objfile); |
ccefe4c4 TT |
1684 | } |
1685 | ||
1686 | /* Initialize storage for partial symbols. */ | |
1687 | ||
1688 | void | |
1689 | init_psymbol_list (struct objfile *objfile, int total_symbols) | |
1690 | { | |
1691 | /* Free any previously allocated psymbol lists. */ | |
1692 | ||
1693 | if (objfile->global_psymbols.list) | |
1694 | { | |
1695 | xfree (objfile->global_psymbols.list); | |
1696 | } | |
1697 | if (objfile->static_psymbols.list) | |
1698 | { | |
1699 | xfree (objfile->static_psymbols.list); | |
1700 | } | |
1701 | ||
1702 | /* Current best guess is that approximately a twentieth | |
1703 | of the total symbols (in a debugging file) are global or static | |
ca9c6ee2 | 1704 | oriented symbols, then multiply that by slop factor of two. */ |
ccefe4c4 TT |
1705 | |
1706 | objfile->global_psymbols.size = total_symbols / 10; | |
1707 | objfile->static_psymbols.size = total_symbols / 10; | |
1708 | ||
1709 | if (objfile->global_psymbols.size > 0) | |
1710 | { | |
1711 | objfile->global_psymbols.next = | |
1712 | objfile->global_psymbols.list = (struct partial_symbol **) | |
1713 | xmalloc ((objfile->global_psymbols.size | |
1714 | * sizeof (struct partial_symbol *))); | |
1715 | } | |
1716 | if (objfile->static_psymbols.size > 0) | |
1717 | { | |
1718 | objfile->static_psymbols.next = | |
1719 | objfile->static_psymbols.list = (struct partial_symbol **) | |
1720 | xmalloc ((objfile->static_psymbols.size | |
1721 | * sizeof (struct partial_symbol *))); | |
1722 | } | |
1723 | } | |
1724 | ||
1725 | struct partial_symtab * | |
1726 | allocate_psymtab (const char *filename, struct objfile *objfile) | |
1727 | { | |
1728 | struct partial_symtab *psymtab; | |
1729 | ||
1730 | if (objfile->free_psymtabs) | |
1731 | { | |
1732 | psymtab = objfile->free_psymtabs; | |
1733 | objfile->free_psymtabs = psymtab->next; | |
1734 | } | |
1735 | else | |
1736 | psymtab = (struct partial_symtab *) | |
1737 | obstack_alloc (&objfile->objfile_obstack, | |
1738 | sizeof (struct partial_symtab)); | |
1739 | ||
1740 | memset (psymtab, 0, sizeof (struct partial_symtab)); | |
10f0c4bb TT |
1741 | psymtab->filename = obstack_copy0 (&objfile->objfile_obstack, |
1742 | filename, strlen (filename)); | |
ccefe4c4 TT |
1743 | psymtab->symtab = NULL; |
1744 | ||
1745 | /* Prepend it to the psymtab list for the objfile it belongs to. | |
1746 | Psymtabs are searched in most recent inserted -> least recent | |
0df8b418 | 1747 | inserted order. */ |
ccefe4c4 | 1748 | |
ccefe4c4 TT |
1749 | psymtab->next = objfile->psymtabs; |
1750 | objfile->psymtabs = psymtab; | |
ccefe4c4 | 1751 | |
45cfd468 DE |
1752 | if (symtab_create_debug) |
1753 | { | |
1754 | /* Be a bit clever with debugging messages, and don't print objfile | |
1755 | every time, only when it changes. */ | |
1756 | static char *last_objfile_name = NULL; | |
1757 | ||
1758 | if (last_objfile_name == NULL | |
1759 | || strcmp (last_objfile_name, objfile->name) != 0) | |
1760 | { | |
1761 | xfree (last_objfile_name); | |
1762 | last_objfile_name = xstrdup (objfile->name); | |
1763 | fprintf_unfiltered (gdb_stdlog, | |
1764 | "Creating one or more psymtabs for objfile %s ...\n", | |
1765 | last_objfile_name); | |
1766 | } | |
1767 | fprintf_unfiltered (gdb_stdlog, | |
fd55216c DE |
1768 | "Created psymtab %s for module %s.\n", |
1769 | host_address_to_string (psymtab), filename); | |
45cfd468 DE |
1770 | } |
1771 | ||
ccefe4c4 TT |
1772 | return (psymtab); |
1773 | } | |
1774 | ||
1775 | void | |
5c80ed9d | 1776 | discard_psymtab (struct objfile *objfile, struct partial_symtab *pst) |
ccefe4c4 TT |
1777 | { |
1778 | struct partial_symtab **prev_pst; | |
1779 | ||
1780 | /* From dbxread.c: | |
1781 | Empty psymtabs happen as a result of header files which don't | |
1782 | have any symbols in them. There can be a lot of them. But this | |
1783 | check is wrong, in that a psymtab with N_SLINE entries but | |
1784 | nothing else is not empty, but we don't realize that. Fixing | |
1785 | that without slowing things down might be tricky. */ | |
1786 | ||
0df8b418 | 1787 | /* First, snip it out of the psymtab chain. */ |
ccefe4c4 | 1788 | |
5c80ed9d | 1789 | prev_pst = &(objfile->psymtabs); |
ccefe4c4 TT |
1790 | while ((*prev_pst) != pst) |
1791 | prev_pst = &((*prev_pst)->next); | |
1792 | (*prev_pst) = pst->next; | |
1793 | ||
0df8b418 | 1794 | /* Next, put it on a free list for recycling. */ |
ccefe4c4 | 1795 | |
5c80ed9d TT |
1796 | pst->next = objfile->free_psymtabs; |
1797 | objfile->free_psymtabs = pst; | |
ccefe4c4 TT |
1798 | } |
1799 | ||
c9bf0622 TT |
1800 | /* An object of this type is passed to discard_psymtabs_upto. */ |
1801 | ||
1802 | struct psymtab_state | |
1803 | { | |
1804 | /* The objfile where psymtabs are discarded. */ | |
1805 | ||
1806 | struct objfile *objfile; | |
1807 | ||
1808 | /* The first psymtab to save. */ | |
1809 | ||
1810 | struct partial_symtab *save; | |
1811 | }; | |
1812 | ||
1813 | /* A cleanup function used by make_cleanup_discard_psymtabs. */ | |
1814 | ||
1815 | static void | |
1816 | discard_psymtabs_upto (void *arg) | |
1817 | { | |
1818 | struct psymtab_state *state = arg; | |
1819 | ||
1820 | while (state->objfile->psymtabs != state->save) | |
1821 | discard_psymtab (state->objfile, state->objfile->psymtabs); | |
1822 | } | |
1823 | ||
1824 | /* Return a new cleanup that discards all psymtabs created in OBJFILE | |
1825 | after this function is called. */ | |
1826 | ||
1827 | struct cleanup * | |
1828 | make_cleanup_discard_psymtabs (struct objfile *objfile) | |
1829 | { | |
1830 | struct psymtab_state *state = XNEW (struct psymtab_state); | |
1831 | ||
1832 | state->objfile = objfile; | |
1833 | state->save = objfile->psymtabs; | |
1834 | ||
1835 | return make_cleanup_dtor (discard_psymtabs_upto, state, xfree); | |
1836 | } | |
1837 | ||
ccefe4c4 TT |
1838 | \f |
1839 | ||
dfc7bb5b | 1840 | static void |
ccefe4c4 TT |
1841 | maintenance_print_psymbols (char *args, int from_tty) |
1842 | { | |
1843 | char **argv; | |
1844 | struct ui_file *outfile; | |
1845 | struct cleanup *cleanups; | |
1846 | char *symname = NULL; | |
1847 | char *filename = DEV_TTY; | |
1848 | struct objfile *objfile; | |
1849 | struct partial_symtab *ps; | |
1850 | ||
1851 | dont_repeat (); | |
1852 | ||
1853 | if (args == NULL) | |
1854 | { | |
3e43a32a MS |
1855 | error (_("\ |
1856 | print-psymbols takes an output file name and optional symbol file name")); | |
ccefe4c4 TT |
1857 | } |
1858 | argv = gdb_buildargv (args); | |
1859 | cleanups = make_cleanup_freeargv (argv); | |
1860 | ||
1861 | if (argv[0] != NULL) | |
1862 | { | |
1863 | filename = argv[0]; | |
0df8b418 | 1864 | /* If a second arg is supplied, it is a source file name to match on. */ |
ccefe4c4 TT |
1865 | if (argv[1] != NULL) |
1866 | { | |
1867 | symname = argv[1]; | |
1868 | } | |
1869 | } | |
1870 | ||
1871 | filename = tilde_expand (filename); | |
1872 | make_cleanup (xfree, filename); | |
1873 | ||
1874 | outfile = gdb_fopen (filename, FOPEN_WT); | |
1875 | if (outfile == 0) | |
1876 | perror_with_name (filename); | |
1877 | make_cleanup_ui_file_delete (outfile); | |
1878 | ||
ccefe4c4 | 1879 | ALL_PSYMTABS (objfile, ps) |
27618ce4 TT |
1880 | { |
1881 | QUIT; | |
1882 | if (symname == NULL || filename_cmp (symname, ps->filename) == 0) | |
1883 | dump_psymtab (objfile, ps, outfile); | |
1884 | } | |
ccefe4c4 TT |
1885 | do_cleanups (cleanups); |
1886 | } | |
1887 | ||
1888 | /* List all the partial symbol tables whose names match REGEXP (optional). */ | |
dfc7bb5b | 1889 | static void |
ccefe4c4 TT |
1890 | maintenance_info_psymtabs (char *regexp, int from_tty) |
1891 | { | |
1892 | struct program_space *pspace; | |
1893 | struct objfile *objfile; | |
1894 | ||
1895 | if (regexp) | |
1896 | re_comp (regexp); | |
1897 | ||
1898 | ALL_PSPACES (pspace) | |
1899 | ALL_PSPACE_OBJFILES (pspace, objfile) | |
1900 | { | |
1901 | struct gdbarch *gdbarch = get_objfile_arch (objfile); | |
1902 | struct partial_symtab *psymtab; | |
1903 | ||
1904 | /* We don't want to print anything for this objfile until we | |
1905 | actually find a symtab whose name matches. */ | |
1906 | int printed_objfile_start = 0; | |
1907 | ||
b11896a5 | 1908 | ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, psymtab) |
ccefe4c4 TT |
1909 | { |
1910 | QUIT; | |
1911 | ||
1912 | if (! regexp | |
1913 | || re_exec (psymtab->filename)) | |
1914 | { | |
1915 | if (! printed_objfile_start) | |
1916 | { | |
1917 | printf_filtered ("{ objfile %s ", objfile->name); | |
1918 | wrap_here (" "); | |
1919 | printf_filtered ("((struct objfile *) %s)\n", | |
1920 | host_address_to_string (objfile)); | |
1921 | printed_objfile_start = 1; | |
1922 | } | |
1923 | ||
1924 | printf_filtered (" { psymtab %s ", psymtab->filename); | |
1925 | wrap_here (" "); | |
1926 | printf_filtered ("((struct partial_symtab *) %s)\n", | |
1927 | host_address_to_string (psymtab)); | |
1928 | ||
1929 | printf_filtered (" readin %s\n", | |
1930 | psymtab->readin ? "yes" : "no"); | |
1931 | printf_filtered (" fullname %s\n", | |
3e43a32a MS |
1932 | psymtab->fullname |
1933 | ? psymtab->fullname : "(null)"); | |
ccefe4c4 TT |
1934 | printf_filtered (" text addresses "); |
1935 | fputs_filtered (paddress (gdbarch, psymtab->textlow), | |
1936 | gdb_stdout); | |
1937 | printf_filtered (" -- "); | |
1938 | fputs_filtered (paddress (gdbarch, psymtab->texthigh), | |
1939 | gdb_stdout); | |
1940 | printf_filtered ("\n"); | |
9750bca9 JK |
1941 | printf_filtered (" psymtabs_addrmap_supported %s\n", |
1942 | (psymtab->psymtabs_addrmap_supported | |
1943 | ? "yes" : "no")); | |
ccefe4c4 TT |
1944 | printf_filtered (" globals "); |
1945 | if (psymtab->n_global_syms) | |
1946 | { | |
1947 | printf_filtered ("(* (struct partial_symbol **) %s @ %d)\n", | |
5c80ed9d | 1948 | host_address_to_string (objfile->global_psymbols.list |
ccefe4c4 TT |
1949 | + psymtab->globals_offset), |
1950 | psymtab->n_global_syms); | |
1951 | } | |
1952 | else | |
1953 | printf_filtered ("(none)\n"); | |
1954 | printf_filtered (" statics "); | |
1955 | if (psymtab->n_static_syms) | |
1956 | { | |
1957 | printf_filtered ("(* (struct partial_symbol **) %s @ %d)\n", | |
5c80ed9d | 1958 | host_address_to_string (objfile->static_psymbols.list |
ccefe4c4 TT |
1959 | + psymtab->statics_offset), |
1960 | psymtab->n_static_syms); | |
1961 | } | |
1962 | else | |
1963 | printf_filtered ("(none)\n"); | |
1964 | printf_filtered (" dependencies "); | |
1965 | if (psymtab->number_of_dependencies) | |
1966 | { | |
1967 | int i; | |
1968 | ||
1969 | printf_filtered ("{\n"); | |
1970 | for (i = 0; i < psymtab->number_of_dependencies; i++) | |
1971 | { | |
1972 | struct partial_symtab *dep = psymtab->dependencies[i]; | |
1973 | ||
1974 | /* Note the string concatenation there --- no comma. */ | |
1975 | printf_filtered (" psymtab %s " | |
1976 | "((struct partial_symtab *) %s)\n", | |
1977 | dep->filename, | |
1978 | host_address_to_string (dep)); | |
1979 | } | |
1980 | printf_filtered (" }\n"); | |
1981 | } | |
1982 | else | |
1983 | printf_filtered ("(none)\n"); | |
1984 | printf_filtered (" }\n"); | |
1985 | } | |
1986 | } | |
1987 | ||
1988 | if (printed_objfile_start) | |
1989 | printf_filtered ("}\n"); | |
1990 | } | |
1991 | } | |
1992 | ||
1993 | /* Check consistency of psymtabs and symtabs. */ | |
1994 | ||
dfc7bb5b | 1995 | static void |
ccefe4c4 TT |
1996 | maintenance_check_symtabs (char *ignore, int from_tty) |
1997 | { | |
1998 | struct symbol *sym; | |
1999 | struct partial_symbol **psym; | |
2000 | struct symtab *s = NULL; | |
2001 | struct partial_symtab *ps; | |
2002 | struct blockvector *bv; | |
2003 | struct objfile *objfile; | |
2004 | struct block *b; | |
2005 | int length; | |
2006 | ||
2007 | ALL_PSYMTABS (objfile, ps) | |
2008 | { | |
2009 | struct gdbarch *gdbarch = get_objfile_arch (objfile); | |
ad3bbd48 | 2010 | |
5c80ed9d | 2011 | s = psymtab_to_symtab (objfile, ps); |
ccefe4c4 TT |
2012 | if (s == NULL) |
2013 | continue; | |
2014 | bv = BLOCKVECTOR (s); | |
2015 | b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); | |
5c80ed9d | 2016 | psym = objfile->static_psymbols.list + ps->statics_offset; |
ccefe4c4 TT |
2017 | length = ps->n_static_syms; |
2018 | while (length--) | |
2019 | { | |
2020 | sym = lookup_block_symbol (b, SYMBOL_LINKAGE_NAME (*psym), | |
2021 | SYMBOL_DOMAIN (*psym)); | |
2022 | if (!sym) | |
2023 | { | |
2024 | printf_filtered ("Static symbol `"); | |
2025 | puts_filtered (SYMBOL_LINKAGE_NAME (*psym)); | |
2026 | printf_filtered ("' only found in "); | |
2027 | puts_filtered (ps->filename); | |
2028 | printf_filtered (" psymtab\n"); | |
2029 | } | |
2030 | psym++; | |
2031 | } | |
2032 | b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); | |
5c80ed9d | 2033 | psym = objfile->global_psymbols.list + ps->globals_offset; |
ccefe4c4 TT |
2034 | length = ps->n_global_syms; |
2035 | while (length--) | |
2036 | { | |
2037 | sym = lookup_block_symbol (b, SYMBOL_LINKAGE_NAME (*psym), | |
2038 | SYMBOL_DOMAIN (*psym)); | |
2039 | if (!sym) | |
2040 | { | |
2041 | printf_filtered ("Global symbol `"); | |
2042 | puts_filtered (SYMBOL_LINKAGE_NAME (*psym)); | |
2043 | printf_filtered ("' only found in "); | |
2044 | puts_filtered (ps->filename); | |
2045 | printf_filtered (" psymtab\n"); | |
2046 | } | |
2047 | psym++; | |
2048 | } | |
2049 | if (ps->texthigh < ps->textlow) | |
2050 | { | |
2051 | printf_filtered ("Psymtab "); | |
2052 | puts_filtered (ps->filename); | |
2053 | printf_filtered (" covers bad range "); | |
2054 | fputs_filtered (paddress (gdbarch, ps->textlow), gdb_stdout); | |
2055 | printf_filtered (" - "); | |
2056 | fputs_filtered (paddress (gdbarch, ps->texthigh), gdb_stdout); | |
2057 | printf_filtered ("\n"); | |
2058 | continue; | |
2059 | } | |
2060 | if (ps->texthigh == 0) | |
2061 | continue; | |
2062 | if (ps->textlow < BLOCK_START (b) || ps->texthigh > BLOCK_END (b)) | |
2063 | { | |
2064 | printf_filtered ("Psymtab "); | |
2065 | puts_filtered (ps->filename); | |
2066 | printf_filtered (" covers "); | |
2067 | fputs_filtered (paddress (gdbarch, ps->textlow), gdb_stdout); | |
2068 | printf_filtered (" - "); | |
2069 | fputs_filtered (paddress (gdbarch, ps->texthigh), gdb_stdout); | |
2070 | printf_filtered (" but symtab covers only "); | |
2071 | fputs_filtered (paddress (gdbarch, BLOCK_START (b)), gdb_stdout); | |
2072 | printf_filtered (" - "); | |
2073 | fputs_filtered (paddress (gdbarch, BLOCK_END (b)), gdb_stdout); | |
2074 | printf_filtered ("\n"); | |
2075 | } | |
2076 | } | |
2077 | } | |
2078 | ||
2079 | \f | |
2080 | ||
2081 | void | |
e078317b | 2082 | expand_partial_symbol_names (int (*fun) (const char *, void *), |
f8eba3c6 | 2083 | void *data) |
ccefe4c4 TT |
2084 | { |
2085 | struct objfile *objfile; | |
2086 | ||
2087 | ALL_OBJFILES (objfile) | |
2088 | { | |
2089 | if (objfile->sf) | |
7b08b9eb JK |
2090 | objfile->sf->qf->expand_symtabs_matching (objfile, NULL, fun, |
2091 | ALL_DOMAIN, data); | |
ccefe4c4 TT |
2092 | } |
2093 | } | |
2094 | ||
2095 | void | |
74e2f255 DE |
2096 | map_partial_symbol_filenames (symbol_filename_ftype *fun, void *data, |
2097 | int need_fullname) | |
ccefe4c4 TT |
2098 | { |
2099 | struct objfile *objfile; | |
2100 | ||
2101 | ALL_OBJFILES (objfile) | |
2102 | { | |
2103 | if (objfile->sf) | |
74e2f255 DE |
2104 | objfile->sf->qf->map_symbol_filenames (objfile, fun, data, |
2105 | need_fullname); | |
ccefe4c4 TT |
2106 | } |
2107 | } | |
dfc7bb5b YQ |
2108 | |
2109 | extern initialize_file_ftype _initialize_psymtab; | |
2110 | ||
2111 | void | |
2112 | _initialize_psymtab (void) | |
2113 | { | |
2114 | add_cmd ("psymbols", class_maintenance, maintenance_print_psymbols, _("\ | |
2115 | Print dump of current partial symbol definitions.\n\ | |
2116 | Entries in the partial symbol table are dumped to file OUTFILE.\n\ | |
2117 | If a SOURCE file is specified, dump only that file's partial symbols."), | |
2118 | &maintenanceprintlist); | |
2119 | ||
2120 | add_cmd ("psymtabs", class_maintenance, maintenance_info_psymtabs, _("\ | |
2121 | List the partial symbol tables for all object files.\n\ | |
2122 | This does not include information about individual partial symbols,\n\ | |
2123 | just the symbol table structures themselves."), | |
2124 | &maintenanceinfolist); | |
2125 | ||
2126 | add_cmd ("check-symtabs", class_maintenance, maintenance_check_symtabs, | |
2127 | _("Check consistency of psymtabs and symtabs."), | |
2128 | &maintenancelist); | |
2129 | } |