]>
Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Do various things to symbol tables (other than lookup), for GDB. |
af5f3db6 AC |
2 | |
3 | Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, | |
de5ad195 DC |
4 | 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003 Free Software |
5 | Foundation, Inc. | |
c906108c | 6 | |
c5aa993b | 7 | This file is part of GDB. |
c906108c | 8 | |
c5aa993b JM |
9 | This program is free software; you can redistribute it and/or modify |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation; either version 2 of the License, or | |
12 | (at your option) any later version. | |
c906108c | 13 | |
c5aa993b JM |
14 | This program is distributed in the hope that it will be useful, |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
c906108c | 18 | |
c5aa993b JM |
19 | You should have received a copy of the GNU General Public License |
20 | along with this program; if not, write to the Free Software | |
21 | Foundation, Inc., 59 Temple Place - Suite 330, | |
22 | Boston, MA 02111-1307, USA. */ | |
c906108c SS |
23 | |
24 | #include "defs.h" | |
25 | #include "symtab.h" | |
26 | #include "gdbtypes.h" | |
27 | #include "bfd.h" | |
28 | #include "symfile.h" | |
29 | #include "objfiles.h" | |
30 | #include "breakpoint.h" | |
31 | #include "command.h" | |
04ea0df1 | 32 | #include "gdb_obstack.h" |
c906108c SS |
33 | #include "language.h" |
34 | #include "bcache.h" | |
fe898f56 | 35 | #include "block.h" |
c906108c SS |
36 | |
37 | #include "gdb_string.h" | |
38017ce8 | 38 | #include <readline/readline.h> |
c906108c SS |
39 | |
40 | #ifndef DEV_TTY | |
41 | #define DEV_TTY "/dev/tty" | |
42 | #endif | |
43 | ||
44 | /* Unfortunately for debugging, stderr is usually a macro. This is painful | |
45 | when calling functions that take FILE *'s from the debugger. | |
46 | So we make a variable which has the same value and which is accessible when | |
47 | debugging GDB with itself. Because stdin et al need not be constants, | |
48 | we initialize them in the _initialize_symmisc function at the bottom | |
49 | of the file. */ | |
50 | FILE *std_in; | |
51 | FILE *std_out; | |
52 | FILE *std_err; | |
53 | ||
54 | /* Prototypes for local functions */ | |
55 | ||
d9fcf2fb JM |
56 | static void dump_symtab (struct objfile *, struct symtab *, |
57 | struct ui_file *); | |
c906108c | 58 | |
d9fcf2fb JM |
59 | static void dump_psymtab (struct objfile *, struct partial_symtab *, |
60 | struct ui_file *); | |
c906108c | 61 | |
d9fcf2fb | 62 | static void dump_msymbols (struct objfile *, struct ui_file *); |
c906108c | 63 | |
a14ed312 | 64 | static void dump_objfile (struct objfile *); |
c906108c | 65 | |
a14ed312 | 66 | static int block_depth (struct block *); |
c906108c | 67 | |
d9fcf2fb JM |
68 | static void print_partial_symbols (struct partial_symbol **, int, |
69 | char *, struct ui_file *); | |
c906108c | 70 | |
a14ed312 | 71 | static void free_symtab_block (struct objfile *, struct block *); |
c906108c | 72 | |
a14ed312 | 73 | void _initialize_symmisc (void); |
c906108c | 74 | |
c5aa993b JM |
75 | struct print_symbol_args |
76 | { | |
77 | struct symbol *symbol; | |
78 | int depth; | |
d9fcf2fb | 79 | struct ui_file *outfile; |
c5aa993b | 80 | }; |
c906108c | 81 | |
4efb68b1 | 82 | static int print_symbol (void *); |
c906108c | 83 | |
a14ed312 | 84 | static void free_symtab_block (struct objfile *, struct block *); |
c906108c | 85 | \f |
c5aa993b | 86 | |
c906108c SS |
87 | /* Free a struct block <- B and all the symbols defined in that block. */ |
88 | ||
89 | static void | |
fba45db2 | 90 | free_symtab_block (struct objfile *objfile, struct block *b) |
c906108c SS |
91 | { |
92 | register int i, n; | |
261397f8 DJ |
93 | struct symbol *sym, *next_sym; |
94 | ||
95 | n = BLOCK_BUCKETS (b); | |
c906108c SS |
96 | for (i = 0; i < n; i++) |
97 | { | |
261397f8 DJ |
98 | for (sym = BLOCK_BUCKET (b, i); sym; sym = next_sym) |
99 | { | |
100 | next_sym = sym->hash_next; | |
101 | xmfree (objfile->md, SYMBOL_NAME (sym)); | |
4efb68b1 | 102 | xmfree (objfile->md, sym); |
261397f8 | 103 | } |
c906108c | 104 | } |
4efb68b1 | 105 | xmfree (objfile->md, b); |
c906108c SS |
106 | } |
107 | ||
108 | /* Free all the storage associated with the struct symtab <- S. | |
109 | Note that some symtabs have contents malloc'ed structure by structure, | |
110 | while some have contents that all live inside one big block of memory, | |
111 | and some share the contents of another symbol table and so you should | |
112 | not free the contents on their behalf (except sometimes the linetable, | |
113 | which maybe per symtab even when the rest is not). | |
114 | It is s->free_code that says which alternative to use. */ | |
115 | ||
116 | void | |
fba45db2 | 117 | free_symtab (register struct symtab *s) |
c906108c SS |
118 | { |
119 | register int i, n; | |
120 | register struct blockvector *bv; | |
121 | ||
122 | switch (s->free_code) | |
123 | { | |
124 | case free_nothing: | |
125 | /* All the contents are part of a big block of memory (an obstack), | |
c5aa993b JM |
126 | and some other symtab is in charge of freeing that block. |
127 | Therefore, do nothing. */ | |
c906108c SS |
128 | break; |
129 | ||
130 | case free_contents: | |
131 | /* Here all the contents were malloc'ed structure by structure | |
c5aa993b | 132 | and must be freed that way. */ |
c906108c SS |
133 | /* First free the blocks (and their symbols. */ |
134 | bv = BLOCKVECTOR (s); | |
135 | n = BLOCKVECTOR_NBLOCKS (bv); | |
136 | for (i = 0; i < n; i++) | |
c5aa993b | 137 | free_symtab_block (s->objfile, BLOCKVECTOR_BLOCK (bv, i)); |
c906108c | 138 | /* Free the blockvector itself. */ |
4efb68b1 | 139 | xmfree (s->objfile->md, bv); |
c906108c | 140 | /* Also free the linetable. */ |
c5aa993b | 141 | |
c906108c SS |
142 | case free_linetable: |
143 | /* Everything will be freed either by our `free_ptr' | |
c5aa993b JM |
144 | or by some other symtab, except for our linetable. |
145 | Free that now. */ | |
c906108c | 146 | if (LINETABLE (s)) |
4efb68b1 | 147 | xmfree (s->objfile->md, LINETABLE (s)); |
c906108c SS |
148 | break; |
149 | } | |
150 | ||
151 | /* If there is a single block of memory to free, free it. */ | |
c5aa993b | 152 | if (s->free_ptr != NULL) |
aac7f4ea | 153 | xmfree (s->objfile->md, s->free_ptr); |
c906108c SS |
154 | |
155 | /* Free source-related stuff */ | |
c5aa993b | 156 | if (s->line_charpos != NULL) |
4efb68b1 | 157 | xmfree (s->objfile->md, s->line_charpos); |
c5aa993b | 158 | if (s->fullname != NULL) |
aac7f4ea | 159 | xmfree (s->objfile->md, s->fullname); |
c5aa993b | 160 | if (s->debugformat != NULL) |
aac7f4ea | 161 | xmfree (s->objfile->md, s->debugformat); |
4efb68b1 | 162 | xmfree (s->objfile->md, s); |
c906108c SS |
163 | } |
164 | ||
c906108c | 165 | void |
fba45db2 | 166 | print_symbol_bcache_statistics (void) |
c906108c SS |
167 | { |
168 | struct objfile *objfile; | |
169 | ||
170 | immediate_quit++; | |
171 | ALL_OBJFILES (objfile) | |
c5aa993b JM |
172 | { |
173 | printf_filtered ("Byte cache statistics for '%s':\n", objfile->name); | |
af5f3db6 | 174 | print_bcache_statistics (objfile->psymbol_cache, "partial symbol cache"); |
c5aa993b | 175 | } |
c906108c SS |
176 | immediate_quit--; |
177 | } | |
178 | ||
179 | void | |
fba45db2 | 180 | print_objfile_statistics (void) |
c906108c SS |
181 | { |
182 | struct objfile *objfile; | |
c4f90d87 JM |
183 | struct symtab *s; |
184 | struct partial_symtab *ps; | |
185 | int i, linetables, blockvectors; | |
c906108c SS |
186 | |
187 | immediate_quit++; | |
188 | ALL_OBJFILES (objfile) | |
c5aa993b JM |
189 | { |
190 | printf_filtered ("Statistics for '%s':\n", objfile->name); | |
191 | if (OBJSTAT (objfile, n_stabs) > 0) | |
192 | printf_filtered (" Number of \"stab\" symbols read: %d\n", | |
193 | OBJSTAT (objfile, n_stabs)); | |
194 | if (OBJSTAT (objfile, n_minsyms) > 0) | |
195 | printf_filtered (" Number of \"minimal\" symbols read: %d\n", | |
196 | OBJSTAT (objfile, n_minsyms)); | |
197 | if (OBJSTAT (objfile, n_psyms) > 0) | |
198 | printf_filtered (" Number of \"partial\" symbols read: %d\n", | |
199 | OBJSTAT (objfile, n_psyms)); | |
200 | if (OBJSTAT (objfile, n_syms) > 0) | |
201 | printf_filtered (" Number of \"full\" symbols read: %d\n", | |
202 | OBJSTAT (objfile, n_syms)); | |
203 | if (OBJSTAT (objfile, n_types) > 0) | |
204 | printf_filtered (" Number of \"types\" defined: %d\n", | |
205 | OBJSTAT (objfile, n_types)); | |
c4f90d87 JM |
206 | i = 0; |
207 | ALL_OBJFILE_PSYMTABS (objfile, ps) | |
208 | { | |
209 | if (ps->readin == 0) | |
210 | i++; | |
211 | } | |
212 | printf_filtered (" Number of psym tables (not yet expanded): %d\n", i); | |
213 | i = linetables = blockvectors = 0; | |
214 | ALL_OBJFILE_SYMTABS (objfile, s) | |
215 | { | |
216 | i++; | |
217 | if (s->linetable != NULL) | |
218 | linetables++; | |
219 | if (s->primary == 1) | |
220 | blockvectors++; | |
221 | } | |
222 | printf_filtered (" Number of symbol tables: %d\n", i); | |
223 | printf_filtered (" Number of symbol tables with line tables: %d\n", | |
224 | linetables); | |
225 | printf_filtered (" Number of symbol tables with blockvectors: %d\n", | |
226 | blockvectors); | |
227 | ||
c5aa993b JM |
228 | if (OBJSTAT (objfile, sz_strtab) > 0) |
229 | printf_filtered (" Space used by a.out string tables: %d\n", | |
230 | OBJSTAT (objfile, sz_strtab)); | |
231 | printf_filtered (" Total memory used for psymbol obstack: %d\n", | |
232 | obstack_memory_used (&objfile->psymbol_obstack)); | |
233 | printf_filtered (" Total memory used for psymbol cache: %d\n", | |
af5f3db6 | 234 | bcache_memory_used (objfile->psymbol_cache)); |
99d9066e | 235 | printf_filtered (" Total memory used for macro cache: %d\n", |
af5f3db6 | 236 | bcache_memory_used (objfile->macro_cache)); |
c5aa993b JM |
237 | printf_filtered (" Total memory used for symbol obstack: %d\n", |
238 | obstack_memory_used (&objfile->symbol_obstack)); | |
239 | printf_filtered (" Total memory used for type obstack: %d\n", | |
240 | obstack_memory_used (&objfile->type_obstack)); | |
241 | } | |
c906108c SS |
242 | immediate_quit--; |
243 | } | |
244 | ||
c5aa993b | 245 | static void |
fba45db2 | 246 | dump_objfile (struct objfile *objfile) |
c906108c SS |
247 | { |
248 | struct symtab *symtab; | |
249 | struct partial_symtab *psymtab; | |
250 | ||
c5aa993b | 251 | printf_filtered ("\nObject file %s: ", objfile->name); |
c906108c | 252 | printf_filtered ("Objfile at "); |
d4f3574e | 253 | gdb_print_host_address (objfile, gdb_stdout); |
c906108c | 254 | printf_filtered (", bfd at "); |
d4f3574e | 255 | gdb_print_host_address (objfile->obfd, gdb_stdout); |
c906108c SS |
256 | printf_filtered (", %d minsyms\n\n", |
257 | objfile->minimal_symbol_count); | |
258 | ||
c5aa993b | 259 | if (objfile->psymtabs) |
c906108c SS |
260 | { |
261 | printf_filtered ("Psymtabs:\n"); | |
c5aa993b | 262 | for (psymtab = objfile->psymtabs; |
c906108c | 263 | psymtab != NULL; |
c5aa993b | 264 | psymtab = psymtab->next) |
c906108c SS |
265 | { |
266 | printf_filtered ("%s at ", | |
c5aa993b | 267 | psymtab->filename); |
d4f3574e | 268 | gdb_print_host_address (psymtab, gdb_stdout); |
c906108c | 269 | printf_filtered (", "); |
c5aa993b | 270 | if (psymtab->objfile != objfile) |
c906108c SS |
271 | { |
272 | printf_filtered ("NOT ON CHAIN! "); | |
273 | } | |
274 | wrap_here (" "); | |
275 | } | |
276 | printf_filtered ("\n\n"); | |
277 | } | |
278 | ||
c5aa993b | 279 | if (objfile->symtabs) |
c906108c SS |
280 | { |
281 | printf_filtered ("Symtabs:\n"); | |
c5aa993b | 282 | for (symtab = objfile->symtabs; |
c906108c SS |
283 | symtab != NULL; |
284 | symtab = symtab->next) | |
285 | { | |
c5aa993b | 286 | printf_filtered ("%s at ", symtab->filename); |
d4f3574e | 287 | gdb_print_host_address (symtab, gdb_stdout); |
c906108c | 288 | printf_filtered (", "); |
c5aa993b | 289 | if (symtab->objfile != objfile) |
c906108c SS |
290 | { |
291 | printf_filtered ("NOT ON CHAIN! "); | |
292 | } | |
293 | wrap_here (" "); | |
294 | } | |
295 | printf_filtered ("\n\n"); | |
296 | } | |
297 | } | |
298 | ||
299 | /* Print minimal symbols from this objfile. */ | |
c5aa993b JM |
300 | |
301 | static void | |
fba45db2 | 302 | dump_msymbols (struct objfile *objfile, struct ui_file *outfile) |
c906108c SS |
303 | { |
304 | struct minimal_symbol *msymbol; | |
305 | int index; | |
306 | char ms_type; | |
c5aa993b JM |
307 | |
308 | fprintf_filtered (outfile, "\nObject file %s:\n\n", objfile->name); | |
309 | if (objfile->minimal_symbol_count == 0) | |
c906108c SS |
310 | { |
311 | fprintf_filtered (outfile, "No minimal symbols found.\n"); | |
312 | return; | |
313 | } | |
c5aa993b | 314 | for (index = 0, msymbol = objfile->msymbols; |
c906108c SS |
315 | SYMBOL_NAME (msymbol) != NULL; msymbol++, index++) |
316 | { | |
c5aa993b | 317 | switch (msymbol->type) |
c906108c | 318 | { |
c5aa993b JM |
319 | case mst_unknown: |
320 | ms_type = 'u'; | |
321 | break; | |
322 | case mst_text: | |
323 | ms_type = 'T'; | |
324 | break; | |
325 | case mst_solib_trampoline: | |
326 | ms_type = 'S'; | |
327 | break; | |
328 | case mst_data: | |
329 | ms_type = 'D'; | |
330 | break; | |
331 | case mst_bss: | |
332 | ms_type = 'B'; | |
333 | break; | |
334 | case mst_abs: | |
335 | ms_type = 'A'; | |
336 | break; | |
337 | case mst_file_text: | |
338 | ms_type = 't'; | |
339 | break; | |
340 | case mst_file_data: | |
341 | ms_type = 'd'; | |
342 | break; | |
343 | case mst_file_bss: | |
344 | ms_type = 'b'; | |
345 | break; | |
346 | default: | |
347 | ms_type = '?'; | |
348 | break; | |
c906108c SS |
349 | } |
350 | fprintf_filtered (outfile, "[%2d] %c ", index, ms_type); | |
351 | print_address_numeric (SYMBOL_VALUE_ADDRESS (msymbol), 1, outfile); | |
352 | fprintf_filtered (outfile, " %s", SYMBOL_NAME (msymbol)); | |
353 | if (SYMBOL_BFD_SECTION (msymbol)) | |
354 | fprintf_filtered (outfile, " section %s", | |
355 | bfd_section_name (objfile->obfd, | |
356 | SYMBOL_BFD_SECTION (msymbol))); | |
357 | if (SYMBOL_DEMANGLED_NAME (msymbol) != NULL) | |
358 | { | |
359 | fprintf_filtered (outfile, " %s", SYMBOL_DEMANGLED_NAME (msymbol)); | |
360 | } | |
361 | #ifdef SOFUN_ADDRESS_MAYBE_MISSING | |
362 | if (msymbol->filename) | |
363 | fprintf_filtered (outfile, " %s", msymbol->filename); | |
364 | #endif | |
365 | fputs_filtered ("\n", outfile); | |
366 | } | |
c5aa993b | 367 | if (objfile->minimal_symbol_count != index) |
c906108c SS |
368 | { |
369 | warning ("internal error: minimal symbol count %d != %d", | |
c5aa993b | 370 | objfile->minimal_symbol_count, index); |
c906108c SS |
371 | } |
372 | fprintf_filtered (outfile, "\n"); | |
373 | } | |
374 | ||
375 | static void | |
fba45db2 KB |
376 | dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab, |
377 | struct ui_file *outfile) | |
c906108c SS |
378 | { |
379 | int i; | |
380 | ||
381 | fprintf_filtered (outfile, "\nPartial symtab for source file %s ", | |
c5aa993b | 382 | psymtab->filename); |
c906108c | 383 | fprintf_filtered (outfile, "(object "); |
d4f3574e | 384 | gdb_print_host_address (psymtab, outfile); |
c906108c SS |
385 | fprintf_filtered (outfile, ")\n\n"); |
386 | fprintf_unfiltered (outfile, " Read from object file %s (", | |
c5aa993b | 387 | objfile->name); |
d4f3574e | 388 | gdb_print_host_address (objfile, outfile); |
c906108c SS |
389 | fprintf_unfiltered (outfile, ")\n"); |
390 | ||
c5aa993b | 391 | if (psymtab->readin) |
c906108c SS |
392 | { |
393 | fprintf_filtered (outfile, | |
c5aa993b | 394 | " Full symtab was read (at "); |
d4f3574e | 395 | gdb_print_host_address (psymtab->symtab, outfile); |
c906108c | 396 | fprintf_filtered (outfile, " by function at "); |
4efb68b1 | 397 | gdb_print_host_address (psymtab->read_symtab, outfile); |
c906108c SS |
398 | fprintf_filtered (outfile, ")\n"); |
399 | } | |
400 | ||
401 | fprintf_filtered (outfile, " Relocate symbols by "); | |
402 | for (i = 0; i < psymtab->objfile->num_sections; ++i) | |
403 | { | |
404 | if (i != 0) | |
405 | fprintf_filtered (outfile, ", "); | |
406 | wrap_here (" "); | |
407 | print_address_numeric (ANOFFSET (psymtab->section_offsets, i), | |
408 | 1, | |
409 | outfile); | |
410 | } | |
411 | fprintf_filtered (outfile, "\n"); | |
412 | ||
413 | fprintf_filtered (outfile, " Symbols cover text addresses "); | |
414 | print_address_numeric (psymtab->textlow, 1, outfile); | |
415 | fprintf_filtered (outfile, "-"); | |
416 | print_address_numeric (psymtab->texthigh, 1, outfile); | |
417 | fprintf_filtered (outfile, "\n"); | |
418 | fprintf_filtered (outfile, " Depends on %d other partial symtabs.\n", | |
c5aa993b JM |
419 | psymtab->number_of_dependencies); |
420 | for (i = 0; i < psymtab->number_of_dependencies; i++) | |
c906108c SS |
421 | { |
422 | fprintf_filtered (outfile, " %d ", i); | |
d4f3574e | 423 | gdb_print_host_address (psymtab->dependencies[i], outfile); |
c906108c | 424 | fprintf_filtered (outfile, " %s\n", |
c5aa993b | 425 | psymtab->dependencies[i]->filename); |
c906108c | 426 | } |
c5aa993b | 427 | if (psymtab->n_global_syms > 0) |
c906108c | 428 | { |
c5aa993b JM |
429 | print_partial_symbols (objfile->global_psymbols.list |
430 | + psymtab->globals_offset, | |
431 | psymtab->n_global_syms, "Global", outfile); | |
c906108c | 432 | } |
c5aa993b | 433 | if (psymtab->n_static_syms > 0) |
c906108c | 434 | { |
c5aa993b JM |
435 | print_partial_symbols (objfile->static_psymbols.list |
436 | + psymtab->statics_offset, | |
437 | psymtab->n_static_syms, "Static", outfile); | |
c906108c SS |
438 | } |
439 | fprintf_filtered (outfile, "\n"); | |
440 | } | |
441 | ||
c5aa993b | 442 | static void |
fba45db2 KB |
443 | dump_symtab (struct objfile *objfile, struct symtab *symtab, |
444 | struct ui_file *outfile) | |
c906108c SS |
445 | { |
446 | register int i, j; | |
447 | int len, blen; | |
448 | register struct linetable *l; | |
449 | struct blockvector *bv; | |
e88c90f2 | 450 | struct symbol *sym; |
c906108c SS |
451 | register struct block *b; |
452 | int depth; | |
453 | ||
454 | fprintf_filtered (outfile, "\nSymtab for file %s\n", symtab->filename); | |
455 | if (symtab->dirname) | |
456 | fprintf_filtered (outfile, "Compilation directory is %s\n", | |
457 | symtab->dirname); | |
458 | fprintf_filtered (outfile, "Read from object file %s (", objfile->name); | |
d4f3574e | 459 | gdb_print_host_address (objfile, outfile); |
c906108c SS |
460 | fprintf_filtered (outfile, ")\n"); |
461 | fprintf_filtered (outfile, "Language: %s\n", language_str (symtab->language)); | |
462 | ||
463 | /* First print the line table. */ | |
464 | l = LINETABLE (symtab); | |
465 | if (l) | |
466 | { | |
467 | fprintf_filtered (outfile, "\nLine table:\n\n"); | |
468 | len = l->nitems; | |
469 | for (i = 0; i < len; i++) | |
470 | { | |
471 | fprintf_filtered (outfile, " line %d at ", l->item[i].line); | |
472 | print_address_numeric (l->item[i].pc, 1, outfile); | |
473 | fprintf_filtered (outfile, "\n"); | |
474 | } | |
475 | } | |
476 | /* Now print the block info, but only for primary symtabs since we will | |
477 | print lots of duplicate info otherwise. */ | |
c5aa993b | 478 | if (symtab->primary) |
c906108c SS |
479 | { |
480 | fprintf_filtered (outfile, "\nBlockvector:\n\n"); | |
481 | bv = BLOCKVECTOR (symtab); | |
482 | len = BLOCKVECTOR_NBLOCKS (bv); | |
483 | for (i = 0; i < len; i++) | |
484 | { | |
485 | b = BLOCKVECTOR_BLOCK (bv, i); | |
486 | depth = block_depth (b) * 2; | |
487 | print_spaces (depth, outfile); | |
488 | fprintf_filtered (outfile, "block #%03d, object at ", i); | |
d4f3574e | 489 | gdb_print_host_address (b, outfile); |
c906108c SS |
490 | if (BLOCK_SUPERBLOCK (b)) |
491 | { | |
492 | fprintf_filtered (outfile, " under "); | |
d4f3574e | 493 | gdb_print_host_address (BLOCK_SUPERBLOCK (b), outfile); |
c906108c | 494 | } |
261397f8 DJ |
495 | /* drow/2002-07-10: We could save the total symbols count |
496 | even if we're using a hashtable, but nothing else but this message | |
497 | wants it. */ | |
498 | blen = BLOCK_BUCKETS (b); | |
499 | if (BLOCK_HASHTABLE (b)) | |
500 | fprintf_filtered (outfile, ", %d buckets in ", blen); | |
501 | else | |
502 | fprintf_filtered (outfile, ", %d syms in ", blen); | |
c906108c SS |
503 | print_address_numeric (BLOCK_START (b), 1, outfile); |
504 | fprintf_filtered (outfile, ".."); | |
505 | print_address_numeric (BLOCK_END (b), 1, outfile); | |
506 | if (BLOCK_FUNCTION (b)) | |
507 | { | |
508 | fprintf_filtered (outfile, ", function %s", SYMBOL_NAME (BLOCK_FUNCTION (b))); | |
509 | if (SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b)) != NULL) | |
510 | { | |
511 | fprintf_filtered (outfile, ", %s", | |
c5aa993b | 512 | SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b))); |
c906108c SS |
513 | } |
514 | } | |
c5aa993b JM |
515 | if (BLOCK_GCC_COMPILED (b)) |
516 | fprintf_filtered (outfile, ", compiled with gcc%d", BLOCK_GCC_COMPILED (b)); | |
c906108c | 517 | fprintf_filtered (outfile, "\n"); |
261397f8 DJ |
518 | /* Now print each symbol in this block (in no particular order, if |
519 | we're using a hashtable). */ | |
e88c90f2 | 520 | ALL_BLOCK_SYMBOLS (b, j, sym) |
c906108c SS |
521 | { |
522 | struct print_symbol_args s; | |
e88c90f2 | 523 | s.symbol = sym; |
c906108c SS |
524 | s.depth = depth + 1; |
525 | s.outfile = outfile; | |
526 | catch_errors (print_symbol, &s, "Error printing symbol:\n", | |
527 | RETURN_MASK_ALL); | |
528 | } | |
529 | } | |
530 | fprintf_filtered (outfile, "\n"); | |
531 | } | |
532 | else | |
533 | { | |
534 | fprintf_filtered (outfile, "\nBlockvector same as previous symtab\n\n"); | |
535 | } | |
536 | } | |
537 | ||
538 | void | |
fba45db2 | 539 | maintenance_print_symbols (char *args, int from_tty) |
c906108c SS |
540 | { |
541 | char **argv; | |
d9fcf2fb | 542 | struct ui_file *outfile; |
c906108c SS |
543 | struct cleanup *cleanups; |
544 | char *symname = NULL; | |
545 | char *filename = DEV_TTY; | |
546 | struct objfile *objfile; | |
547 | struct symtab *s; | |
548 | ||
549 | dont_repeat (); | |
550 | ||
551 | if (args == NULL) | |
552 | { | |
553 | error ("\ | |
554 | Arguments missing: an output file name and an optional symbol file name"); | |
555 | } | |
556 | else if ((argv = buildargv (args)) == NULL) | |
557 | { | |
558 | nomem (0); | |
559 | } | |
7a292a7a | 560 | cleanups = make_cleanup_freeargv (argv); |
c906108c SS |
561 | |
562 | if (argv[0] != NULL) | |
563 | { | |
564 | filename = argv[0]; | |
565 | /* If a second arg is supplied, it is a source file name to match on */ | |
566 | if (argv[1] != NULL) | |
567 | { | |
568 | symname = argv[1]; | |
569 | } | |
570 | } | |
571 | ||
572 | filename = tilde_expand (filename); | |
b8c9b27d | 573 | make_cleanup (xfree, filename); |
c5aa993b | 574 | |
c906108c SS |
575 | outfile = gdb_fopen (filename, FOPEN_WT); |
576 | if (outfile == 0) | |
577 | perror_with_name (filename); | |
d9fcf2fb | 578 | make_cleanup_ui_file_delete (outfile); |
c906108c SS |
579 | |
580 | immediate_quit++; | |
581 | ALL_SYMTABS (objfile, s) | |
c5aa993b JM |
582 | if (symname == NULL || (STREQ (symname, s->filename))) |
583 | dump_symtab (objfile, s, outfile); | |
c906108c SS |
584 | immediate_quit--; |
585 | do_cleanups (cleanups); | |
586 | } | |
587 | ||
588 | /* Print symbol ARGS->SYMBOL on ARGS->OUTFILE. ARGS->DEPTH says how | |
589 | far to indent. ARGS is really a struct print_symbol_args *, but is | |
590 | declared as char * to get it past catch_errors. Returns 0 for error, | |
591 | 1 for success. */ | |
592 | ||
593 | static int | |
4efb68b1 | 594 | print_symbol (void *args) |
c906108c | 595 | { |
c5aa993b JM |
596 | struct symbol *symbol = ((struct print_symbol_args *) args)->symbol; |
597 | int depth = ((struct print_symbol_args *) args)->depth; | |
d9fcf2fb | 598 | struct ui_file *outfile = ((struct print_symbol_args *) args)->outfile; |
c906108c SS |
599 | |
600 | print_spaces (depth, outfile); | |
601 | if (SYMBOL_NAMESPACE (symbol) == LABEL_NAMESPACE) | |
602 | { | |
de5ad195 | 603 | fprintf_filtered (outfile, "label %s at ", SYMBOL_PRINT_NAME (symbol)); |
c906108c SS |
604 | print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), 1, outfile); |
605 | if (SYMBOL_BFD_SECTION (symbol)) | |
606 | fprintf_filtered (outfile, " section %s\n", | |
c5aa993b JM |
607 | bfd_section_name (SYMBOL_BFD_SECTION (symbol)->owner, |
608 | SYMBOL_BFD_SECTION (symbol))); | |
c906108c SS |
609 | else |
610 | fprintf_filtered (outfile, "\n"); | |
611 | return 1; | |
612 | } | |
613 | if (SYMBOL_NAMESPACE (symbol) == STRUCT_NAMESPACE) | |
614 | { | |
615 | if (TYPE_TAG_NAME (SYMBOL_TYPE (symbol))) | |
616 | { | |
617 | LA_PRINT_TYPE (SYMBOL_TYPE (symbol), "", outfile, 1, depth); | |
618 | } | |
619 | else | |
620 | { | |
621 | fprintf_filtered (outfile, "%s %s = ", | |
c5aa993b JM |
622 | (TYPE_CODE (SYMBOL_TYPE (symbol)) == TYPE_CODE_ENUM |
623 | ? "enum" | |
624 | : (TYPE_CODE (SYMBOL_TYPE (symbol)) == TYPE_CODE_STRUCT | |
625 | ? "struct" : "union")), | |
626 | SYMBOL_NAME (symbol)); | |
c906108c SS |
627 | LA_PRINT_TYPE (SYMBOL_TYPE (symbol), "", outfile, 1, depth); |
628 | } | |
629 | fprintf_filtered (outfile, ";\n"); | |
630 | } | |
631 | else | |
632 | { | |
633 | if (SYMBOL_CLASS (symbol) == LOC_TYPEDEF) | |
634 | fprintf_filtered (outfile, "typedef "); | |
635 | if (SYMBOL_TYPE (symbol)) | |
636 | { | |
637 | /* Print details of types, except for enums where it's clutter. */ | |
de5ad195 | 638 | LA_PRINT_TYPE (SYMBOL_TYPE (symbol), SYMBOL_PRINT_NAME (symbol), |
c906108c SS |
639 | outfile, |
640 | TYPE_CODE (SYMBOL_TYPE (symbol)) != TYPE_CODE_ENUM, | |
641 | depth); | |
642 | fprintf_filtered (outfile, "; "); | |
643 | } | |
644 | else | |
de5ad195 | 645 | fprintf_filtered (outfile, "%s ", SYMBOL_PRINT_NAME (symbol)); |
c906108c SS |
646 | |
647 | switch (SYMBOL_CLASS (symbol)) | |
648 | { | |
649 | case LOC_CONST: | |
650 | fprintf_filtered (outfile, "const %ld (0x%lx)", | |
651 | SYMBOL_VALUE (symbol), | |
652 | SYMBOL_VALUE (symbol)); | |
653 | break; | |
654 | ||
655 | case LOC_CONST_BYTES: | |
656 | { | |
657 | unsigned i; | |
658 | struct type *type = check_typedef (SYMBOL_TYPE (symbol)); | |
659 | fprintf_filtered (outfile, "const %u hex bytes:", | |
660 | TYPE_LENGTH (type)); | |
661 | for (i = 0; i < TYPE_LENGTH (type); i++) | |
662 | fprintf_filtered (outfile, " %02x", | |
c5aa993b | 663 | (unsigned) SYMBOL_VALUE_BYTES (symbol)[i]); |
c906108c SS |
664 | } |
665 | break; | |
666 | ||
667 | case LOC_STATIC: | |
668 | fprintf_filtered (outfile, "static at "); | |
c5aa993b | 669 | print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), 1, outfile); |
c906108c SS |
670 | if (SYMBOL_BFD_SECTION (symbol)) |
671 | fprintf_filtered (outfile, " section %s", | |
672 | bfd_section_name | |
673 | (SYMBOL_BFD_SECTION (symbol)->owner, | |
674 | SYMBOL_BFD_SECTION (symbol))); | |
675 | break; | |
676 | ||
677 | case LOC_INDIRECT: | |
678 | fprintf_filtered (outfile, "extern global at *("); | |
c5aa993b | 679 | print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), 1, outfile); |
c906108c SS |
680 | fprintf_filtered (outfile, "),"); |
681 | break; | |
682 | ||
683 | case LOC_REGISTER: | |
684 | fprintf_filtered (outfile, "register %ld", SYMBOL_VALUE (symbol)); | |
685 | break; | |
686 | ||
687 | case LOC_ARG: | |
688 | fprintf_filtered (outfile, "arg at offset 0x%lx", | |
689 | SYMBOL_VALUE (symbol)); | |
690 | break; | |
691 | ||
692 | case LOC_LOCAL_ARG: | |
693 | fprintf_filtered (outfile, "arg at offset 0x%lx from fp", | |
c5aa993b | 694 | SYMBOL_VALUE (symbol)); |
c906108c SS |
695 | break; |
696 | ||
697 | case LOC_REF_ARG: | |
698 | fprintf_filtered (outfile, "reference arg at 0x%lx", SYMBOL_VALUE (symbol)); | |
699 | break; | |
700 | ||
701 | case LOC_REGPARM: | |
702 | fprintf_filtered (outfile, "parameter register %ld", SYMBOL_VALUE (symbol)); | |
703 | break; | |
704 | ||
705 | case LOC_REGPARM_ADDR: | |
706 | fprintf_filtered (outfile, "address parameter register %ld", SYMBOL_VALUE (symbol)); | |
707 | break; | |
708 | ||
709 | case LOC_LOCAL: | |
710 | fprintf_filtered (outfile, "local at offset 0x%lx", | |
711 | SYMBOL_VALUE (symbol)); | |
712 | break; | |
713 | ||
714 | case LOC_BASEREG: | |
715 | fprintf_filtered (outfile, "local at 0x%lx from register %d", | |
c5aa993b | 716 | SYMBOL_VALUE (symbol), SYMBOL_BASEREG (symbol)); |
c906108c SS |
717 | break; |
718 | ||
719 | case LOC_BASEREG_ARG: | |
720 | fprintf_filtered (outfile, "arg at 0x%lx from register %d", | |
c5aa993b | 721 | SYMBOL_VALUE (symbol), SYMBOL_BASEREG (symbol)); |
c906108c SS |
722 | break; |
723 | ||
724 | case LOC_TYPEDEF: | |
725 | break; | |
726 | ||
727 | case LOC_LABEL: | |
728 | fprintf_filtered (outfile, "label at "); | |
729 | print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), 1, outfile); | |
730 | if (SYMBOL_BFD_SECTION (symbol)) | |
731 | fprintf_filtered (outfile, " section %s", | |
732 | bfd_section_name | |
733 | (SYMBOL_BFD_SECTION (symbol)->owner, | |
734 | SYMBOL_BFD_SECTION (symbol))); | |
735 | break; | |
736 | ||
737 | case LOC_BLOCK: | |
738 | fprintf_filtered (outfile, "block object "); | |
d4f3574e | 739 | gdb_print_host_address (SYMBOL_BLOCK_VALUE (symbol), outfile); |
c906108c SS |
740 | fprintf_filtered (outfile, ", "); |
741 | print_address_numeric (BLOCK_START (SYMBOL_BLOCK_VALUE (symbol)), | |
742 | 1, | |
743 | outfile); | |
744 | fprintf_filtered (outfile, ".."); | |
745 | print_address_numeric (BLOCK_END (SYMBOL_BLOCK_VALUE (symbol)), | |
746 | 1, | |
747 | outfile); | |
748 | if (SYMBOL_BFD_SECTION (symbol)) | |
749 | fprintf_filtered (outfile, " section %s", | |
750 | bfd_section_name | |
751 | (SYMBOL_BFD_SECTION (symbol)->owner, | |
752 | SYMBOL_BFD_SECTION (symbol))); | |
753 | break; | |
754 | ||
755 | case LOC_UNRESOLVED: | |
756 | fprintf_filtered (outfile, "unresolved"); | |
757 | break; | |
758 | ||
759 | case LOC_OPTIMIZED_OUT: | |
760 | fprintf_filtered (outfile, "optimized out"); | |
761 | break; | |
762 | ||
c5aa993b | 763 | default: |
c906108c SS |
764 | fprintf_filtered (outfile, "botched symbol class %x", |
765 | SYMBOL_CLASS (symbol)); | |
766 | break; | |
767 | } | |
768 | } | |
769 | fprintf_filtered (outfile, "\n"); | |
770 | return 1; | |
771 | } | |
772 | ||
773 | void | |
fba45db2 | 774 | maintenance_print_psymbols (char *args, int from_tty) |
c906108c SS |
775 | { |
776 | char **argv; | |
d9fcf2fb | 777 | struct ui_file *outfile; |
c906108c SS |
778 | struct cleanup *cleanups; |
779 | char *symname = NULL; | |
780 | char *filename = DEV_TTY; | |
781 | struct objfile *objfile; | |
782 | struct partial_symtab *ps; | |
783 | ||
784 | dont_repeat (); | |
785 | ||
786 | if (args == NULL) | |
787 | { | |
788 | error ("print-psymbols takes an output file name and optional symbol file name"); | |
789 | } | |
790 | else if ((argv = buildargv (args)) == NULL) | |
791 | { | |
792 | nomem (0); | |
793 | } | |
7a292a7a | 794 | cleanups = make_cleanup_freeargv (argv); |
c906108c SS |
795 | |
796 | if (argv[0] != NULL) | |
797 | { | |
798 | filename = argv[0]; | |
799 | /* If a second arg is supplied, it is a source file name to match on */ | |
800 | if (argv[1] != NULL) | |
801 | { | |
802 | symname = argv[1]; | |
803 | } | |
804 | } | |
805 | ||
806 | filename = tilde_expand (filename); | |
b8c9b27d | 807 | make_cleanup (xfree, filename); |
c5aa993b | 808 | |
c906108c SS |
809 | outfile = gdb_fopen (filename, FOPEN_WT); |
810 | if (outfile == 0) | |
811 | perror_with_name (filename); | |
d9fcf2fb | 812 | make_cleanup_ui_file_delete (outfile); |
c906108c SS |
813 | |
814 | immediate_quit++; | |
815 | ALL_PSYMTABS (objfile, ps) | |
c5aa993b JM |
816 | if (symname == NULL || (STREQ (symname, ps->filename))) |
817 | dump_psymtab (objfile, ps, outfile); | |
c906108c SS |
818 | immediate_quit--; |
819 | do_cleanups (cleanups); | |
820 | } | |
821 | ||
822 | static void | |
fba45db2 KB |
823 | print_partial_symbols (struct partial_symbol **p, int count, char *what, |
824 | struct ui_file *outfile) | |
c906108c SS |
825 | { |
826 | fprintf_filtered (outfile, " %s partial symbols:\n", what); | |
827 | while (count-- > 0) | |
828 | { | |
c5aa993b | 829 | fprintf_filtered (outfile, " `%s'", SYMBOL_NAME (*p)); |
c906108c SS |
830 | if (SYMBOL_DEMANGLED_NAME (*p) != NULL) |
831 | { | |
832 | fprintf_filtered (outfile, " `%s'", SYMBOL_DEMANGLED_NAME (*p)); | |
833 | } | |
834 | fputs_filtered (", ", outfile); | |
835 | switch (SYMBOL_NAMESPACE (*p)) | |
836 | { | |
837 | case UNDEF_NAMESPACE: | |
838 | fputs_filtered ("undefined namespace, ", outfile); | |
839 | break; | |
840 | case VAR_NAMESPACE: | |
841 | /* This is the usual thing -- don't print it */ | |
842 | break; | |
843 | case STRUCT_NAMESPACE: | |
844 | fputs_filtered ("struct namespace, ", outfile); | |
845 | break; | |
846 | case LABEL_NAMESPACE: | |
847 | fputs_filtered ("label namespace, ", outfile); | |
848 | break; | |
849 | default: | |
850 | fputs_filtered ("<invalid namespace>, ", outfile); | |
851 | break; | |
852 | } | |
853 | switch (SYMBOL_CLASS (*p)) | |
854 | { | |
855 | case LOC_UNDEF: | |
856 | fputs_filtered ("undefined", outfile); | |
857 | break; | |
858 | case LOC_CONST: | |
859 | fputs_filtered ("constant int", outfile); | |
860 | break; | |
861 | case LOC_STATIC: | |
862 | fputs_filtered ("static", outfile); | |
863 | break; | |
864 | case LOC_INDIRECT: | |
865 | fputs_filtered ("extern global", outfile); | |
866 | break; | |
867 | case LOC_REGISTER: | |
868 | fputs_filtered ("register", outfile); | |
869 | break; | |
870 | case LOC_ARG: | |
871 | fputs_filtered ("pass by value", outfile); | |
872 | break; | |
873 | case LOC_REF_ARG: | |
874 | fputs_filtered ("pass by reference", outfile); | |
875 | break; | |
876 | case LOC_REGPARM: | |
877 | fputs_filtered ("register parameter", outfile); | |
878 | break; | |
879 | case LOC_REGPARM_ADDR: | |
880 | fputs_filtered ("register address parameter", outfile); | |
881 | break; | |
882 | case LOC_LOCAL: | |
883 | fputs_filtered ("stack parameter", outfile); | |
884 | break; | |
885 | case LOC_TYPEDEF: | |
886 | fputs_filtered ("type", outfile); | |
887 | break; | |
888 | case LOC_LABEL: | |
889 | fputs_filtered ("label", outfile); | |
890 | break; | |
891 | case LOC_BLOCK: | |
892 | fputs_filtered ("function", outfile); | |
893 | break; | |
894 | case LOC_CONST_BYTES: | |
895 | fputs_filtered ("constant bytes", outfile); | |
896 | break; | |
897 | case LOC_LOCAL_ARG: | |
898 | fputs_filtered ("shuffled arg", outfile); | |
899 | break; | |
900 | case LOC_UNRESOLVED: | |
901 | fputs_filtered ("unresolved", outfile); | |
902 | break; | |
903 | case LOC_OPTIMIZED_OUT: | |
904 | fputs_filtered ("optimized out", outfile); | |
905 | break; | |
906 | default: | |
907 | fputs_filtered ("<invalid location>", outfile); | |
908 | break; | |
909 | } | |
910 | fputs_filtered (", ", outfile); | |
911 | print_address_numeric (SYMBOL_VALUE_ADDRESS (*p), 1, outfile); | |
912 | fprintf_filtered (outfile, "\n"); | |
913 | p++; | |
914 | } | |
915 | } | |
916 | ||
917 | void | |
fba45db2 | 918 | maintenance_print_msymbols (char *args, int from_tty) |
c906108c SS |
919 | { |
920 | char **argv; | |
d9fcf2fb | 921 | struct ui_file *outfile; |
c906108c SS |
922 | struct cleanup *cleanups; |
923 | char *filename = DEV_TTY; | |
924 | char *symname = NULL; | |
925 | struct objfile *objfile; | |
926 | ||
927 | dont_repeat (); | |
928 | ||
929 | if (args == NULL) | |
930 | { | |
931 | error ("print-msymbols takes an output file name and optional symbol file name"); | |
932 | } | |
933 | else if ((argv = buildargv (args)) == NULL) | |
934 | { | |
935 | nomem (0); | |
936 | } | |
7a292a7a | 937 | cleanups = make_cleanup_freeargv (argv); |
c906108c SS |
938 | |
939 | if (argv[0] != NULL) | |
940 | { | |
941 | filename = argv[0]; | |
942 | /* If a second arg is supplied, it is a source file name to match on */ | |
943 | if (argv[1] != NULL) | |
944 | { | |
945 | symname = argv[1]; | |
946 | } | |
947 | } | |
948 | ||
949 | filename = tilde_expand (filename); | |
b8c9b27d | 950 | make_cleanup (xfree, filename); |
c5aa993b | 951 | |
c906108c SS |
952 | outfile = gdb_fopen (filename, FOPEN_WT); |
953 | if (outfile == 0) | |
954 | perror_with_name (filename); | |
d9fcf2fb | 955 | make_cleanup_ui_file_delete (outfile); |
c906108c SS |
956 | |
957 | immediate_quit++; | |
958 | ALL_OBJFILES (objfile) | |
c5aa993b JM |
959 | if (symname == NULL || (STREQ (symname, objfile->name))) |
960 | dump_msymbols (objfile, outfile); | |
c906108c SS |
961 | immediate_quit--; |
962 | fprintf_filtered (outfile, "\n\n"); | |
963 | do_cleanups (cleanups); | |
964 | } | |
965 | ||
966 | void | |
fba45db2 | 967 | maintenance_print_objfiles (char *ignore, int from_tty) |
c906108c SS |
968 | { |
969 | struct objfile *objfile; | |
970 | ||
971 | dont_repeat (); | |
972 | ||
973 | immediate_quit++; | |
974 | ALL_OBJFILES (objfile) | |
975 | dump_objfile (objfile); | |
976 | immediate_quit--; | |
977 | } | |
978 | ||
979 | /* Check consistency of psymtabs and symtabs. */ | |
980 | ||
981 | void | |
fba45db2 | 982 | maintenance_check_symtabs (char *ignore, int from_tty) |
c906108c SS |
983 | { |
984 | register struct symbol *sym; | |
985 | register struct partial_symbol **psym; | |
986 | register struct symtab *s = NULL; | |
987 | register struct partial_symtab *ps; | |
988 | struct blockvector *bv; | |
989 | register struct objfile *objfile; | |
990 | register struct block *b; | |
991 | int length; | |
992 | ||
993 | ALL_PSYMTABS (objfile, ps) | |
c5aa993b JM |
994 | { |
995 | s = PSYMTAB_TO_SYMTAB (ps); | |
996 | if (s == NULL) | |
997 | continue; | |
998 | bv = BLOCKVECTOR (s); | |
999 | b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); | |
1000 | psym = ps->objfile->static_psymbols.list + ps->statics_offset; | |
1001 | length = ps->n_static_syms; | |
1002 | while (length--) | |
1003 | { | |
1004 | sym = lookup_block_symbol (b, SYMBOL_NAME (*psym), | |
3121eff0 | 1005 | NULL, SYMBOL_NAMESPACE (*psym)); |
c5aa993b JM |
1006 | if (!sym) |
1007 | { | |
1008 | printf_filtered ("Static symbol `"); | |
1009 | puts_filtered (SYMBOL_NAME (*psym)); | |
1010 | printf_filtered ("' only found in "); | |
1011 | puts_filtered (ps->filename); | |
1012 | printf_filtered (" psymtab\n"); | |
1013 | } | |
1014 | psym++; | |
1015 | } | |
1016 | b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); | |
1017 | psym = ps->objfile->global_psymbols.list + ps->globals_offset; | |
1018 | length = ps->n_global_syms; | |
1019 | while (length--) | |
1020 | { | |
1021 | sym = lookup_block_symbol (b, SYMBOL_NAME (*psym), | |
3121eff0 | 1022 | NULL, SYMBOL_NAMESPACE (*psym)); |
c5aa993b JM |
1023 | if (!sym) |
1024 | { | |
1025 | printf_filtered ("Global symbol `"); | |
1026 | puts_filtered (SYMBOL_NAME (*psym)); | |
1027 | printf_filtered ("' only found in "); | |
1028 | puts_filtered (ps->filename); | |
1029 | printf_filtered (" psymtab\n"); | |
1030 | } | |
1031 | psym++; | |
1032 | } | |
1033 | if (ps->texthigh < ps->textlow) | |
1034 | { | |
1035 | printf_filtered ("Psymtab "); | |
1036 | puts_filtered (ps->filename); | |
1037 | printf_filtered (" covers bad range "); | |
1038 | print_address_numeric (ps->textlow, 1, gdb_stdout); | |
1039 | printf_filtered (" - "); | |
1040 | print_address_numeric (ps->texthigh, 1, gdb_stdout); | |
1041 | printf_filtered ("\n"); | |
c906108c | 1042 | continue; |
c5aa993b JM |
1043 | } |
1044 | if (ps->texthigh == 0) | |
1045 | continue; | |
1046 | if (ps->textlow < BLOCK_START (b) || ps->texthigh > BLOCK_END (b)) | |
1047 | { | |
1048 | printf_filtered ("Psymtab "); | |
1049 | puts_filtered (ps->filename); | |
1050 | printf_filtered (" covers "); | |
1051 | print_address_numeric (ps->textlow, 1, gdb_stdout); | |
1052 | printf_filtered (" - "); | |
1053 | print_address_numeric (ps->texthigh, 1, gdb_stdout); | |
1054 | printf_filtered (" but symtab covers only "); | |
1055 | print_address_numeric (BLOCK_START (b), 1, gdb_stdout); | |
1056 | printf_filtered (" - "); | |
1057 | print_address_numeric (BLOCK_END (b), 1, gdb_stdout); | |
1058 | printf_filtered ("\n"); | |
1059 | } | |
1060 | } | |
c906108c | 1061 | } |
c906108c | 1062 | \f |
c5aa993b | 1063 | |
c906108c SS |
1064 | /* Return the nexting depth of a block within other blocks in its symtab. */ |
1065 | ||
1066 | static int | |
fba45db2 | 1067 | block_depth (struct block *block) |
c906108c SS |
1068 | { |
1069 | register int i = 0; | |
c5aa993b | 1070 | while ((block = BLOCK_SUPERBLOCK (block)) != NULL) |
c906108c SS |
1071 | { |
1072 | i++; | |
1073 | } | |
1074 | return i; | |
1075 | } | |
c906108c | 1076 | \f |
c5aa993b | 1077 | |
c906108c SS |
1078 | /* Increase the space allocated for LISTP, which is probably |
1079 | global_psymbols or static_psymbols. This space will eventually | |
1080 | be freed in free_objfile(). */ | |
1081 | ||
1082 | void | |
fba45db2 KB |
1083 | extend_psymbol_list (register struct psymbol_allocation_list *listp, |
1084 | struct objfile *objfile) | |
c906108c SS |
1085 | { |
1086 | int new_size; | |
1087 | if (listp->size == 0) | |
1088 | { | |
1089 | new_size = 255; | |
1090 | listp->list = (struct partial_symbol **) | |
c5aa993b | 1091 | xmmalloc (objfile->md, new_size * sizeof (struct partial_symbol *)); |
c906108c SS |
1092 | } |
1093 | else | |
1094 | { | |
1095 | new_size = listp->size * 2; | |
1096 | listp->list = (struct partial_symbol **) | |
c5aa993b | 1097 | xmrealloc (objfile->md, (char *) listp->list, |
c906108c SS |
1098 | new_size * sizeof (struct partial_symbol *)); |
1099 | } | |
1100 | /* Next assumes we only went one over. Should be good if | |
1101 | program works correctly */ | |
1102 | listp->next = listp->list + listp->size; | |
1103 | listp->size = new_size; | |
1104 | } | |
1105 | ||
1106 | ||
1107 | /* Do early runtime initializations. */ | |
1108 | void | |
fba45db2 | 1109 | _initialize_symmisc (void) |
c906108c | 1110 | { |
c5aa993b | 1111 | std_in = stdin; |
c906108c SS |
1112 | std_out = stdout; |
1113 | std_err = stderr; | |
1114 | } |