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