Updated copyright notices for most files.
[deliverable/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);
66bf4b3a 349 deprecated_print_address_numeric (SYMBOL_VALUE_ADDRESS (msymbol), 1, 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 (" ");
66bf4b3a 403 deprecated_print_address_numeric (ANOFFSET (psymtab->section_offsets, i),
c906108c
SS
404 1,
405 outfile);
406 }
407 fprintf_filtered (outfile, "\n");
408
409 fprintf_filtered (outfile, " Symbols cover text addresses ");
66bf4b3a 410 deprecated_print_address_numeric (psymtab->textlow, 1, outfile);
c906108c 411 fprintf_filtered (outfile, "-");
66bf4b3a 412 deprecated_print_address_numeric (psymtab->texthigh, 1, outfile);
c906108c
SS
413 fprintf_filtered (outfile, "\n");
414 fprintf_filtered (outfile, " Depends on %d other partial symtabs.\n",
c5aa993b
JM
415 psymtab->number_of_dependencies);
416 for (i = 0; i < psymtab->number_of_dependencies; i++)
c906108c
SS
417 {
418 fprintf_filtered (outfile, " %d ", i);
d4f3574e 419 gdb_print_host_address (psymtab->dependencies[i], outfile);
c906108c 420 fprintf_filtered (outfile, " %s\n",
c5aa993b 421 psymtab->dependencies[i]->filename);
c906108c 422 }
c5aa993b 423 if (psymtab->n_global_syms > 0)
c906108c 424 {
c5aa993b
JM
425 print_partial_symbols (objfile->global_psymbols.list
426 + psymtab->globals_offset,
427 psymtab->n_global_syms, "Global", outfile);
c906108c 428 }
c5aa993b 429 if (psymtab->n_static_syms > 0)
c906108c 430 {
c5aa993b
JM
431 print_partial_symbols (objfile->static_psymbols.list
432 + psymtab->statics_offset,
433 psymtab->n_static_syms, "Static", outfile);
c906108c
SS
434 }
435 fprintf_filtered (outfile, "\n");
436}
437
c5aa993b 438static void
44b164c5
JB
439dump_symtab_1 (struct objfile *objfile, struct symtab *symtab,
440 struct ui_file *outfile)
c906108c 441{
de4f826b
DC
442 int i;
443 struct dict_iterator iter;
c906108c 444 int len, blen;
de4f826b 445 struct linetable *l;
c906108c 446 struct blockvector *bv;
e88c90f2 447 struct symbol *sym;
de4f826b 448 struct block *b;
c906108c
SS
449 int depth;
450
451 fprintf_filtered (outfile, "\nSymtab for file %s\n", symtab->filename);
452 if (symtab->dirname)
453 fprintf_filtered (outfile, "Compilation directory is %s\n",
454 symtab->dirname);
455 fprintf_filtered (outfile, "Read from object file %s (", objfile->name);
d4f3574e 456 gdb_print_host_address (objfile, outfile);
c906108c
SS
457 fprintf_filtered (outfile, ")\n");
458 fprintf_filtered (outfile, "Language: %s\n", language_str (symtab->language));
459
460 /* First print the line table. */
461 l = LINETABLE (symtab);
462 if (l)
463 {
464 fprintf_filtered (outfile, "\nLine table:\n\n");
465 len = l->nitems;
466 for (i = 0; i < len; i++)
467 {
468 fprintf_filtered (outfile, " line %d at ", l->item[i].line);
66bf4b3a 469 deprecated_print_address_numeric (l->item[i].pc, 1, outfile);
c906108c
SS
470 fprintf_filtered (outfile, "\n");
471 }
472 }
473 /* Now print the block info, but only for primary symtabs since we will
474 print lots of duplicate info otherwise. */
c5aa993b 475 if (symtab->primary)
c906108c
SS
476 {
477 fprintf_filtered (outfile, "\nBlockvector:\n\n");
478 bv = BLOCKVECTOR (symtab);
479 len = BLOCKVECTOR_NBLOCKS (bv);
480 for (i = 0; i < len; i++)
481 {
482 b = BLOCKVECTOR_BLOCK (bv, i);
483 depth = block_depth (b) * 2;
484 print_spaces (depth, outfile);
485 fprintf_filtered (outfile, "block #%03d, object at ", i);
d4f3574e 486 gdb_print_host_address (b, outfile);
c906108c
SS
487 if (BLOCK_SUPERBLOCK (b))
488 {
489 fprintf_filtered (outfile, " under ");
d4f3574e 490 gdb_print_host_address (BLOCK_SUPERBLOCK (b), outfile);
c906108c 491 }
261397f8
DJ
492 /* drow/2002-07-10: We could save the total symbols count
493 even if we're using a hashtable, but nothing else but this message
494 wants it. */
de4f826b
DC
495 fprintf_filtered (outfile, ", %d syms/buckets in ",
496 dict_size (BLOCK_DICT (b)));
66bf4b3a 497 deprecated_print_address_numeric (BLOCK_START (b), 1, outfile);
c906108c 498 fprintf_filtered (outfile, "..");
66bf4b3a 499 deprecated_print_address_numeric (BLOCK_END (b), 1, outfile);
c906108c
SS
500 if (BLOCK_FUNCTION (b))
501 {
22abf04a 502 fprintf_filtered (outfile, ", function %s", DEPRECATED_SYMBOL_NAME (BLOCK_FUNCTION (b)));
c906108c
SS
503 if (SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b)) != NULL)
504 {
505 fprintf_filtered (outfile, ", %s",
c5aa993b 506 SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b)));
c906108c
SS
507 }
508 }
c906108c 509 fprintf_filtered (outfile, "\n");
261397f8
DJ
510 /* Now print each symbol in this block (in no particular order, if
511 we're using a hashtable). */
de4f826b 512 ALL_BLOCK_SYMBOLS (b, iter, sym)
c906108c
SS
513 {
514 struct print_symbol_args s;
e88c90f2 515 s.symbol = sym;
c906108c
SS
516 s.depth = depth + 1;
517 s.outfile = outfile;
518 catch_errors (print_symbol, &s, "Error printing symbol:\n",
519 RETURN_MASK_ALL);
520 }
521 }
522 fprintf_filtered (outfile, "\n");
523 }
524 else
525 {
526 fprintf_filtered (outfile, "\nBlockvector same as previous symtab\n\n");
527 }
528}
529
44b164c5
JB
530static void
531dump_symtab (struct objfile *objfile, struct symtab *symtab,
532 struct ui_file *outfile)
533{
534 enum language saved_lang;
535
536 /* Set the current language to the language of the symtab we're dumping
537 because certain routines used during dump_symtab() use the current
538 language to print an image of the symbol. We'll restore it later. */
539 saved_lang = set_language (symtab->language);
540
541 dump_symtab_1 (objfile, symtab, outfile);
542
543 set_language (saved_lang);
544}
545
c906108c 546void
fba45db2 547maintenance_print_symbols (char *args, int from_tty)
c906108c
SS
548{
549 char **argv;
d9fcf2fb 550 struct ui_file *outfile;
c906108c
SS
551 struct cleanup *cleanups;
552 char *symname = NULL;
553 char *filename = DEV_TTY;
554 struct objfile *objfile;
555 struct symtab *s;
556
557 dont_repeat ();
558
559 if (args == NULL)
560 {
8a3fe4f8
AC
561 error (_("\
562Arguments missing: an output file name and an optional symbol file name"));
c906108c
SS
563 }
564 else if ((argv = buildargv (args)) == NULL)
565 {
566 nomem (0);
567 }
7a292a7a 568 cleanups = make_cleanup_freeargv (argv);
c906108c
SS
569
570 if (argv[0] != NULL)
571 {
572 filename = argv[0];
573 /* If a second arg is supplied, it is a source file name to match on */
574 if (argv[1] != NULL)
575 {
576 symname = argv[1];
577 }
578 }
579
580 filename = tilde_expand (filename);
b8c9b27d 581 make_cleanup (xfree, filename);
c5aa993b 582
c906108c
SS
583 outfile = gdb_fopen (filename, FOPEN_WT);
584 if (outfile == 0)
585 perror_with_name (filename);
d9fcf2fb 586 make_cleanup_ui_file_delete (outfile);
c906108c
SS
587
588 immediate_quit++;
589 ALL_SYMTABS (objfile, s)
6314a349 590 if (symname == NULL || strcmp (symname, s->filename) == 0)
c5aa993b 591 dump_symtab (objfile, s, outfile);
c906108c
SS
592 immediate_quit--;
593 do_cleanups (cleanups);
594}
595
596/* Print symbol ARGS->SYMBOL on ARGS->OUTFILE. ARGS->DEPTH says how
597 far to indent. ARGS is really a struct print_symbol_args *, but is
598 declared as char * to get it past catch_errors. Returns 0 for error,
599 1 for success. */
600
601static int
4efb68b1 602print_symbol (void *args)
c906108c 603{
c5aa993b
JM
604 struct symbol *symbol = ((struct print_symbol_args *) args)->symbol;
605 int depth = ((struct print_symbol_args *) args)->depth;
d9fcf2fb 606 struct ui_file *outfile = ((struct print_symbol_args *) args)->outfile;
c906108c
SS
607
608 print_spaces (depth, outfile);
176620f1 609 if (SYMBOL_DOMAIN (symbol) == LABEL_DOMAIN)
c906108c 610 {
de5ad195 611 fprintf_filtered (outfile, "label %s at ", SYMBOL_PRINT_NAME (symbol));
66bf4b3a 612 deprecated_print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), 1, outfile);
c906108c
SS
613 if (SYMBOL_BFD_SECTION (symbol))
614 fprintf_filtered (outfile, " section %s\n",
c5aa993b
JM
615 bfd_section_name (SYMBOL_BFD_SECTION (symbol)->owner,
616 SYMBOL_BFD_SECTION (symbol)));
c906108c
SS
617 else
618 fprintf_filtered (outfile, "\n");
619 return 1;
620 }
176620f1 621 if (SYMBOL_DOMAIN (symbol) == STRUCT_DOMAIN)
c906108c
SS
622 {
623 if (TYPE_TAG_NAME (SYMBOL_TYPE (symbol)))
624 {
625 LA_PRINT_TYPE (SYMBOL_TYPE (symbol), "", outfile, 1, depth);
626 }
627 else
628 {
629 fprintf_filtered (outfile, "%s %s = ",
c5aa993b
JM
630 (TYPE_CODE (SYMBOL_TYPE (symbol)) == TYPE_CODE_ENUM
631 ? "enum"
632 : (TYPE_CODE (SYMBOL_TYPE (symbol)) == TYPE_CODE_STRUCT
633 ? "struct" : "union")),
22abf04a 634 DEPRECATED_SYMBOL_NAME (symbol));
c906108c
SS
635 LA_PRINT_TYPE (SYMBOL_TYPE (symbol), "", outfile, 1, depth);
636 }
637 fprintf_filtered (outfile, ";\n");
638 }
639 else
640 {
641 if (SYMBOL_CLASS (symbol) == LOC_TYPEDEF)
642 fprintf_filtered (outfile, "typedef ");
643 if (SYMBOL_TYPE (symbol))
644 {
645 /* Print details of types, except for enums where it's clutter. */
de5ad195 646 LA_PRINT_TYPE (SYMBOL_TYPE (symbol), SYMBOL_PRINT_NAME (symbol),
c906108c
SS
647 outfile,
648 TYPE_CODE (SYMBOL_TYPE (symbol)) != TYPE_CODE_ENUM,
649 depth);
650 fprintf_filtered (outfile, "; ");
651 }
652 else
de5ad195 653 fprintf_filtered (outfile, "%s ", SYMBOL_PRINT_NAME (symbol));
c906108c
SS
654
655 switch (SYMBOL_CLASS (symbol))
656 {
657 case LOC_CONST:
658 fprintf_filtered (outfile, "const %ld (0x%lx)",
659 SYMBOL_VALUE (symbol),
660 SYMBOL_VALUE (symbol));
661 break;
662
663 case LOC_CONST_BYTES:
664 {
665 unsigned i;
666 struct type *type = check_typedef (SYMBOL_TYPE (symbol));
667 fprintf_filtered (outfile, "const %u hex bytes:",
668 TYPE_LENGTH (type));
669 for (i = 0; i < TYPE_LENGTH (type); i++)
670 fprintf_filtered (outfile, " %02x",
c5aa993b 671 (unsigned) SYMBOL_VALUE_BYTES (symbol)[i]);
c906108c
SS
672 }
673 break;
674
675 case LOC_STATIC:
676 fprintf_filtered (outfile, "static at ");
66bf4b3a 677 deprecated_print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), 1, outfile);
c906108c
SS
678 if (SYMBOL_BFD_SECTION (symbol))
679 fprintf_filtered (outfile, " section %s",
680 bfd_section_name
681 (SYMBOL_BFD_SECTION (symbol)->owner,
682 SYMBOL_BFD_SECTION (symbol)));
683 break;
684
685 case LOC_INDIRECT:
686 fprintf_filtered (outfile, "extern global at *(");
66bf4b3a 687 deprecated_print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), 1, outfile);
c906108c
SS
688 fprintf_filtered (outfile, "),");
689 break;
690
691 case LOC_REGISTER:
692 fprintf_filtered (outfile, "register %ld", SYMBOL_VALUE (symbol));
693 break;
694
695 case LOC_ARG:
696 fprintf_filtered (outfile, "arg at offset 0x%lx",
697 SYMBOL_VALUE (symbol));
698 break;
699
700 case LOC_LOCAL_ARG:
701 fprintf_filtered (outfile, "arg at offset 0x%lx from fp",
c5aa993b 702 SYMBOL_VALUE (symbol));
c906108c
SS
703 break;
704
705 case LOC_REF_ARG:
706 fprintf_filtered (outfile, "reference arg at 0x%lx", SYMBOL_VALUE (symbol));
707 break;
708
709 case LOC_REGPARM:
710 fprintf_filtered (outfile, "parameter register %ld", SYMBOL_VALUE (symbol));
711 break;
712
713 case LOC_REGPARM_ADDR:
714 fprintf_filtered (outfile, "address parameter register %ld", SYMBOL_VALUE (symbol));
715 break;
716
717 case LOC_LOCAL:
718 fprintf_filtered (outfile, "local at offset 0x%lx",
719 SYMBOL_VALUE (symbol));
720 break;
721
722 case LOC_BASEREG:
723 fprintf_filtered (outfile, "local at 0x%lx from register %d",
c5aa993b 724 SYMBOL_VALUE (symbol), SYMBOL_BASEREG (symbol));
c906108c
SS
725 break;
726
727 case LOC_BASEREG_ARG:
728 fprintf_filtered (outfile, "arg at 0x%lx from register %d",
c5aa993b 729 SYMBOL_VALUE (symbol), SYMBOL_BASEREG (symbol));
c906108c
SS
730 break;
731
732 case LOC_TYPEDEF:
733 break;
734
735 case LOC_LABEL:
736 fprintf_filtered (outfile, "label at ");
66bf4b3a 737 deprecated_print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), 1, outfile);
c906108c
SS
738 if (SYMBOL_BFD_SECTION (symbol))
739 fprintf_filtered (outfile, " section %s",
740 bfd_section_name
741 (SYMBOL_BFD_SECTION (symbol)->owner,
742 SYMBOL_BFD_SECTION (symbol)));
743 break;
744
745 case LOC_BLOCK:
746 fprintf_filtered (outfile, "block object ");
d4f3574e 747 gdb_print_host_address (SYMBOL_BLOCK_VALUE (symbol), outfile);
c906108c 748 fprintf_filtered (outfile, ", ");
66bf4b3a 749 deprecated_print_address_numeric (BLOCK_START (SYMBOL_BLOCK_VALUE (symbol)),
c906108c
SS
750 1,
751 outfile);
752 fprintf_filtered (outfile, "..");
66bf4b3a 753 deprecated_print_address_numeric (BLOCK_END (SYMBOL_BLOCK_VALUE (symbol)),
c906108c
SS
754 1,
755 outfile);
756 if (SYMBOL_BFD_SECTION (symbol))
757 fprintf_filtered (outfile, " section %s",
758 bfd_section_name
759 (SYMBOL_BFD_SECTION (symbol)->owner,
760 SYMBOL_BFD_SECTION (symbol)));
761 break;
762
4c2df51b
DJ
763 case LOC_COMPUTED:
764 case LOC_COMPUTED_ARG:
765 fprintf_filtered (outfile, "computed at runtime");
766 break;
767
c906108c
SS
768 case LOC_UNRESOLVED:
769 fprintf_filtered (outfile, "unresolved");
770 break;
771
772 case LOC_OPTIMIZED_OUT:
773 fprintf_filtered (outfile, "optimized out");
774 break;
775
c5aa993b 776 default:
c906108c
SS
777 fprintf_filtered (outfile, "botched symbol class %x",
778 SYMBOL_CLASS (symbol));
779 break;
780 }
781 }
782 fprintf_filtered (outfile, "\n");
783 return 1;
784}
785
786void
fba45db2 787maintenance_print_psymbols (char *args, int from_tty)
c906108c
SS
788{
789 char **argv;
d9fcf2fb 790 struct ui_file *outfile;
c906108c
SS
791 struct cleanup *cleanups;
792 char *symname = NULL;
793 char *filename = DEV_TTY;
794 struct objfile *objfile;
795 struct partial_symtab *ps;
796
797 dont_repeat ();
798
799 if (args == NULL)
800 {
8a3fe4f8 801 error (_("print-psymbols takes an output file name and optional symbol file name"));
c906108c
SS
802 }
803 else if ((argv = buildargv (args)) == NULL)
804 {
805 nomem (0);
806 }
7a292a7a 807 cleanups = make_cleanup_freeargv (argv);
c906108c
SS
808
809 if (argv[0] != NULL)
810 {
811 filename = argv[0];
812 /* If a second arg is supplied, it is a source file name to match on */
813 if (argv[1] != NULL)
814 {
815 symname = argv[1];
816 }
817 }
818
819 filename = tilde_expand (filename);
b8c9b27d 820 make_cleanup (xfree, filename);
c5aa993b 821
c906108c
SS
822 outfile = gdb_fopen (filename, FOPEN_WT);
823 if (outfile == 0)
824 perror_with_name (filename);
d9fcf2fb 825 make_cleanup_ui_file_delete (outfile);
c906108c
SS
826
827 immediate_quit++;
828 ALL_PSYMTABS (objfile, ps)
6314a349 829 if (symname == NULL || strcmp (symname, ps->filename) == 0)
c5aa993b 830 dump_psymtab (objfile, ps, outfile);
c906108c
SS
831 immediate_quit--;
832 do_cleanups (cleanups);
833}
834
835static void
fba45db2
KB
836print_partial_symbols (struct partial_symbol **p, int count, char *what,
837 struct ui_file *outfile)
c906108c
SS
838{
839 fprintf_filtered (outfile, " %s partial symbols:\n", what);
840 while (count-- > 0)
841 {
22abf04a 842 fprintf_filtered (outfile, " `%s'", DEPRECATED_SYMBOL_NAME (*p));
c906108c
SS
843 if (SYMBOL_DEMANGLED_NAME (*p) != NULL)
844 {
845 fprintf_filtered (outfile, " `%s'", SYMBOL_DEMANGLED_NAME (*p));
846 }
847 fputs_filtered (", ", outfile);
176620f1 848 switch (SYMBOL_DOMAIN (*p))
c906108c 849 {
176620f1
EZ
850 case UNDEF_DOMAIN:
851 fputs_filtered ("undefined domain, ", outfile);
c906108c 852 break;
176620f1 853 case VAR_DOMAIN:
c906108c
SS
854 /* This is the usual thing -- don't print it */
855 break;
176620f1
EZ
856 case STRUCT_DOMAIN:
857 fputs_filtered ("struct domain, ", outfile);
c906108c 858 break;
176620f1
EZ
859 case LABEL_DOMAIN:
860 fputs_filtered ("label domain, ", outfile);
c906108c
SS
861 break;
862 default:
176620f1 863 fputs_filtered ("<invalid domain>, ", outfile);
c906108c
SS
864 break;
865 }
866 switch (SYMBOL_CLASS (*p))
867 {
868 case LOC_UNDEF:
869 fputs_filtered ("undefined", outfile);
870 break;
871 case LOC_CONST:
872 fputs_filtered ("constant int", outfile);
873 break;
874 case LOC_STATIC:
875 fputs_filtered ("static", outfile);
876 break;
877 case LOC_INDIRECT:
878 fputs_filtered ("extern global", outfile);
879 break;
880 case LOC_REGISTER:
881 fputs_filtered ("register", outfile);
882 break;
883 case LOC_ARG:
884 fputs_filtered ("pass by value", outfile);
885 break;
886 case LOC_REF_ARG:
887 fputs_filtered ("pass by reference", outfile);
888 break;
889 case LOC_REGPARM:
890 fputs_filtered ("register parameter", outfile);
891 break;
892 case LOC_REGPARM_ADDR:
893 fputs_filtered ("register address parameter", outfile);
894 break;
895 case LOC_LOCAL:
896 fputs_filtered ("stack parameter", outfile);
897 break;
898 case LOC_TYPEDEF:
899 fputs_filtered ("type", outfile);
900 break;
901 case LOC_LABEL:
902 fputs_filtered ("label", outfile);
903 break;
904 case LOC_BLOCK:
905 fputs_filtered ("function", outfile);
906 break;
907 case LOC_CONST_BYTES:
908 fputs_filtered ("constant bytes", outfile);
909 break;
910 case LOC_LOCAL_ARG:
911 fputs_filtered ("shuffled arg", outfile);
912 break;
913 case LOC_UNRESOLVED:
914 fputs_filtered ("unresolved", outfile);
915 break;
916 case LOC_OPTIMIZED_OUT:
917 fputs_filtered ("optimized out", outfile);
918 break;
4c2df51b
DJ
919 case LOC_COMPUTED:
920 case LOC_COMPUTED_ARG:
921 fputs_filtered ("computed at runtime", outfile);
922 break;
c906108c
SS
923 default:
924 fputs_filtered ("<invalid location>", outfile);
925 break;
926 }
927 fputs_filtered (", ", outfile);
66bf4b3a 928 deprecated_print_address_numeric (SYMBOL_VALUE_ADDRESS (*p), 1, outfile);
c906108c
SS
929 fprintf_filtered (outfile, "\n");
930 p++;
931 }
932}
933
934void
fba45db2 935maintenance_print_msymbols (char *args, int from_tty)
c906108c
SS
936{
937 char **argv;
d9fcf2fb 938 struct ui_file *outfile;
c906108c
SS
939 struct cleanup *cleanups;
940 char *filename = DEV_TTY;
941 char *symname = NULL;
942 struct objfile *objfile;
943
07318b29
CV
944 struct stat sym_st, obj_st;
945
c906108c
SS
946 dont_repeat ();
947
948 if (args == NULL)
949 {
8a3fe4f8 950 error (_("print-msymbols takes an output file name and optional symbol file name"));
c906108c
SS
951 }
952 else if ((argv = buildargv (args)) == NULL)
953 {
954 nomem (0);
955 }
7a292a7a 956 cleanups = make_cleanup_freeargv (argv);
c906108c
SS
957
958 if (argv[0] != NULL)
959 {
960 filename = argv[0];
961 /* If a second arg is supplied, it is a source file name to match on */
962 if (argv[1] != NULL)
963 {
07318b29
CV
964 symname = xfullpath (argv[1]);
965 make_cleanup (xfree, symname);
966 if (symname && stat (symname, &sym_st))
967 perror_with_name (symname);
c906108c
SS
968 }
969 }
970
971 filename = tilde_expand (filename);
b8c9b27d 972 make_cleanup (xfree, filename);
c5aa993b 973
c906108c
SS
974 outfile = gdb_fopen (filename, FOPEN_WT);
975 if (outfile == 0)
976 perror_with_name (filename);
d9fcf2fb 977 make_cleanup_ui_file_delete (outfile);
c906108c
SS
978
979 immediate_quit++;
980 ALL_OBJFILES (objfile)
07318b29
CV
981 if (symname == NULL
982 || (!stat (objfile->name, &obj_st) && sym_st.st_ino == obj_st.st_ino))
983 dump_msymbols (objfile, outfile);
c906108c
SS
984 immediate_quit--;
985 fprintf_filtered (outfile, "\n\n");
986 do_cleanups (cleanups);
987}
988
989void
fba45db2 990maintenance_print_objfiles (char *ignore, int from_tty)
c906108c
SS
991{
992 struct objfile *objfile;
993
994 dont_repeat ();
995
996 immediate_quit++;
997 ALL_OBJFILES (objfile)
998 dump_objfile (objfile);
999 immediate_quit--;
1000}
1001
44ea7b70 1002
5e7b2f39 1003/* List all the symbol tables whose names match REGEXP (optional). */
44ea7b70 1004void
5e7b2f39 1005maintenance_info_symtabs (char *regexp, int from_tty)
44ea7b70
JB
1006{
1007 struct objfile *objfile;
1008
1009 if (regexp)
1010 re_comp (regexp);
1011
1012 ALL_OBJFILES (objfile)
1013 {
1014 struct symtab *symtab;
1015
1016 /* We don't want to print anything for this objfile until we
1017 actually find a symtab whose name matches. */
1018 int printed_objfile_start = 0;
1019
1020 ALL_OBJFILE_SYMTABS (objfile, symtab)
1021 if (! regexp
1022 || re_exec (symtab->filename))
1023 {
1024 if (! printed_objfile_start)
1025 {
1026 printf_filtered ("{ objfile %s ", objfile->name);
1027 wrap_here (" ");
1028 printf_filtered ("((struct objfile *) %p)\n", objfile);
1029 printed_objfile_start = 1;
1030 }
1031
1032 printf_filtered (" { symtab %s ", symtab->filename);
1033 wrap_here (" ");
1034 printf_filtered ("((struct symtab *) %p)\n", symtab);
1035 printf_filtered (" dirname %s\n",
1036 symtab->dirname ? symtab->dirname : "(null)");
1037 printf_filtered (" fullname %s\n",
1038 symtab->fullname ? symtab->fullname : "(null)");
1039 printf_filtered (" blockvector ((struct blockvector *) %p)%s\n",
1040 symtab->blockvector,
1041 symtab->primary ? " (primary)" : "");
1b39d5c0
DE
1042 printf_filtered (" linetable ((struct linetable *) %p)\n",
1043 symtab->linetable);
44ea7b70
JB
1044 printf_filtered (" debugformat %s\n", symtab->debugformat);
1045 printf_filtered (" }\n");
1046 }
1047
1048 if (printed_objfile_start)
1049 printf_filtered ("}\n");
1050 }
1051}
1052
1053
5e7b2f39 1054/* List all the partial symbol tables whose names match REGEXP (optional). */
44ea7b70 1055void
5e7b2f39 1056maintenance_info_psymtabs (char *regexp, int from_tty)
44ea7b70
JB
1057{
1058 struct objfile *objfile;
1059
1060 if (regexp)
1061 re_comp (regexp);
1062
1063 ALL_OBJFILES (objfile)
1064 {
1065 struct partial_symtab *psymtab;
1066
1067 /* We don't want to print anything for this objfile until we
1068 actually find a symtab whose name matches. */
1069 int printed_objfile_start = 0;
1070
1071 ALL_OBJFILE_PSYMTABS (objfile, psymtab)
1072 if (! regexp
1073 || re_exec (psymtab->filename))
1074 {
1075 if (! printed_objfile_start)
1076 {
1077 printf_filtered ("{ objfile %s ", objfile->name);
1078 wrap_here (" ");
1079 printf_filtered ("((struct objfile *) %p)\n", objfile);
1080 printed_objfile_start = 1;
1081 }
1082
1083 printf_filtered (" { psymtab %s ", psymtab->filename);
1084 wrap_here (" ");
1085 printf_filtered ("((struct partial_symtab *) %p)\n", psymtab);
1086 printf_filtered (" readin %s\n",
1087 psymtab->readin ? "yes" : "no");
1088 printf_filtered (" fullname %s\n",
1089 psymtab->fullname ? psymtab->fullname : "(null)");
1090 printf_filtered (" text addresses ");
66bf4b3a 1091 deprecated_print_address_numeric (psymtab->textlow, 1, gdb_stdout);
44ea7b70 1092 printf_filtered (" -- ");
66bf4b3a 1093 deprecated_print_address_numeric (psymtab->texthigh, 1, gdb_stdout);
44ea7b70
JB
1094 printf_filtered ("\n");
1095 printf_filtered (" globals ");
1096 if (psymtab->n_global_syms)
1097 {
1098 printf_filtered ("(* (struct partial_symbol **) %p @ %d)\n",
1099 (psymtab->objfile->global_psymbols.list
1100 + psymtab->globals_offset),
1101 psymtab->n_global_syms);
1102 }
1103 else
1104 printf_filtered ("(none)\n");
1105 printf_filtered (" statics ");
1106 if (psymtab->n_static_syms)
1107 {
1108 printf_filtered ("(* (struct partial_symbol **) %p @ %d)\n",
1109 (psymtab->objfile->static_psymbols.list
1110 + psymtab->statics_offset),
1111 psymtab->n_static_syms);
1112 }
1113 else
1114 printf_filtered ("(none)\n");
1115 printf_filtered (" dependencies ");
1116 if (psymtab->number_of_dependencies)
1117 {
1118 int i;
1119
1120 printf_filtered ("{\n");
1121 for (i = 0; i < psymtab->number_of_dependencies; i++)
1122 {
1123 struct partial_symtab *dep = psymtab->dependencies[i];
1124
1125 /* Note the string concatenation there --- no comma. */
1126 printf_filtered (" psymtab %s "
1127 "((struct partial_symtab *) %p)\n",
1128 dep->filename, dep);
1129 }
1130 printf_filtered (" }\n");
1131 }
1132 else
1133 printf_filtered ("(none)\n");
1134 printf_filtered (" }\n");
1135 }
1136
1137 if (printed_objfile_start)
1138 printf_filtered ("}\n");
1139 }
1140}
1141
1142
c906108c
SS
1143/* Check consistency of psymtabs and symtabs. */
1144
1145void
fba45db2 1146maintenance_check_symtabs (char *ignore, int from_tty)
c906108c 1147{
52f0bd74
AC
1148 struct symbol *sym;
1149 struct partial_symbol **psym;
1150 struct symtab *s = NULL;
1151 struct partial_symtab *ps;
c906108c 1152 struct blockvector *bv;
52f0bd74
AC
1153 struct objfile *objfile;
1154 struct block *b;
c906108c
SS
1155 int length;
1156
1157 ALL_PSYMTABS (objfile, ps)
c5aa993b
JM
1158 {
1159 s = PSYMTAB_TO_SYMTAB (ps);
1160 if (s == NULL)
1161 continue;
1162 bv = BLOCKVECTOR (s);
1163 b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
1164 psym = ps->objfile->static_psymbols.list + ps->statics_offset;
1165 length = ps->n_static_syms;
1166 while (length--)
1167 {
22abf04a 1168 sym = lookup_block_symbol (b, DEPRECATED_SYMBOL_NAME (*psym),
176620f1 1169 NULL, SYMBOL_DOMAIN (*psym));
c5aa993b
JM
1170 if (!sym)
1171 {
1172 printf_filtered ("Static symbol `");
22abf04a 1173 puts_filtered (DEPRECATED_SYMBOL_NAME (*psym));
c5aa993b
JM
1174 printf_filtered ("' only found in ");
1175 puts_filtered (ps->filename);
1176 printf_filtered (" psymtab\n");
1177 }
1178 psym++;
1179 }
1180 b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
1181 psym = ps->objfile->global_psymbols.list + ps->globals_offset;
1182 length = ps->n_global_syms;
1183 while (length--)
1184 {
22abf04a 1185 sym = lookup_block_symbol (b, DEPRECATED_SYMBOL_NAME (*psym),
176620f1 1186 NULL, SYMBOL_DOMAIN (*psym));
c5aa993b
JM
1187 if (!sym)
1188 {
1189 printf_filtered ("Global symbol `");
22abf04a 1190 puts_filtered (DEPRECATED_SYMBOL_NAME (*psym));
c5aa993b
JM
1191 printf_filtered ("' only found in ");
1192 puts_filtered (ps->filename);
1193 printf_filtered (" psymtab\n");
1194 }
1195 psym++;
1196 }
1197 if (ps->texthigh < ps->textlow)
1198 {
1199 printf_filtered ("Psymtab ");
1200 puts_filtered (ps->filename);
1201 printf_filtered (" covers bad range ");
66bf4b3a 1202 deprecated_print_address_numeric (ps->textlow, 1, gdb_stdout);
c5aa993b 1203 printf_filtered (" - ");
66bf4b3a 1204 deprecated_print_address_numeric (ps->texthigh, 1, gdb_stdout);
c5aa993b 1205 printf_filtered ("\n");
c906108c 1206 continue;
c5aa993b
JM
1207 }
1208 if (ps->texthigh == 0)
1209 continue;
1210 if (ps->textlow < BLOCK_START (b) || ps->texthigh > BLOCK_END (b))
1211 {
1212 printf_filtered ("Psymtab ");
1213 puts_filtered (ps->filename);
1214 printf_filtered (" covers ");
66bf4b3a 1215 deprecated_print_address_numeric (ps->textlow, 1, gdb_stdout);
c5aa993b 1216 printf_filtered (" - ");
66bf4b3a 1217 deprecated_print_address_numeric (ps->texthigh, 1, gdb_stdout);
c5aa993b 1218 printf_filtered (" but symtab covers only ");
66bf4b3a 1219 deprecated_print_address_numeric (BLOCK_START (b), 1, gdb_stdout);
c5aa993b 1220 printf_filtered (" - ");
66bf4b3a 1221 deprecated_print_address_numeric (BLOCK_END (b), 1, gdb_stdout);
c5aa993b
JM
1222 printf_filtered ("\n");
1223 }
1224 }
c906108c 1225}
c906108c 1226\f
c5aa993b 1227
c906108c
SS
1228/* Return the nexting depth of a block within other blocks in its symtab. */
1229
1230static int
fba45db2 1231block_depth (struct block *block)
c906108c 1232{
52f0bd74 1233 int i = 0;
c5aa993b 1234 while ((block = BLOCK_SUPERBLOCK (block)) != NULL)
c906108c
SS
1235 {
1236 i++;
1237 }
1238 return i;
1239}
c906108c 1240\f
c5aa993b 1241
c906108c
SS
1242/* Increase the space allocated for LISTP, which is probably
1243 global_psymbols or static_psymbols. This space will eventually
1244 be freed in free_objfile(). */
1245
1246void
aa1ee363 1247extend_psymbol_list (struct psymbol_allocation_list *listp,
fba45db2 1248 struct objfile *objfile)
c906108c
SS
1249{
1250 int new_size;
1251 if (listp->size == 0)
1252 {
1253 new_size = 255;
1254 listp->list = (struct partial_symbol **)
7936743b 1255 xmalloc (new_size * sizeof (struct partial_symbol *));
c906108c
SS
1256 }
1257 else
1258 {
1259 new_size = listp->size * 2;
1260 listp->list = (struct partial_symbol **)
0efffb96
AC
1261 xrealloc ((char *) listp->list,
1262 new_size * sizeof (struct partial_symbol *));
c906108c
SS
1263 }
1264 /* Next assumes we only went one over. Should be good if
1265 program works correctly */
1266 listp->next = listp->list + listp->size;
1267 listp->size = new_size;
1268}
1269
1270
1271/* Do early runtime initializations. */
1272void
fba45db2 1273_initialize_symmisc (void)
c906108c 1274{
c5aa993b 1275 std_in = stdin;
c906108c
SS
1276 std_out = stdout;
1277 std_err = stderr;
1278}
This page took 0.766816 seconds and 4 git commands to generate.