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