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