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