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