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