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