Introduce MOD2 switch to segregate material on Modula-2; eventually
[deliverable/binutils-gdb.git] / gdb / symmisc.c
1 /* Do various things to symbol tables (other than lookup), for GDB.
2 Copyright 1986, 1987, 1989, 1991, 1992 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 #include "defs.h"
21 #include "symtab.h"
22 #include "gdbtypes.h"
23 #include "bfd.h"
24 #include "symfile.h"
25 #include "objfiles.h"
26 #include "breakpoint.h"
27 #include "command.h"
28 #include "obstack.h"
29 #include "language.h"
30
31 #include <string.h>
32
33 #ifndef DEV_TTY
34 #define DEV_TTY "/dev/tty"
35 #endif
36
37 /* Unfortunately for debugging, stderr is usually a macro. Better if we
38 make a variable which has the same value and which is accessible when
39 debugging GDB with itself. */
40 FILE *std_in = stdin;
41 FILE *std_out = stdout;
42 FILE *std_err = stderr;
43
44 /* Prototypes for local functions */
45
46 static void
47 dump_symtab PARAMS ((struct objfile *, struct symtab *, FILE *));
48
49 static void
50 dump_psymtab PARAMS ((struct objfile *, struct partial_symtab *, FILE *));
51
52 static void
53 dump_msymbols PARAMS ((struct objfile *, FILE *));
54
55 static void
56 dump_objfile PARAMS ((struct objfile *));
57
58 static int
59 block_depth PARAMS ((struct block *));
60
61 static void
62 print_partial_symbol PARAMS ((struct partial_symbol *, int, char *, FILE *));
63
64 static void
65 print_symbol PARAMS ((struct symbol *, int, FILE *));
66
67 static void
68 free_symtab_block PARAMS ((struct objfile *, struct block *));
69
70 \f
71 /* Free a struct block <- B and all the symbols defined in that block. */
72
73 static void
74 free_symtab_block (objfile, b)
75 struct objfile *objfile;
76 struct block *b;
77 {
78 register int i, n;
79 n = BLOCK_NSYMS (b);
80 for (i = 0; i < n; i++)
81 {
82 mfree (objfile -> md, SYMBOL_NAME (BLOCK_SYM (b, i)));
83 mfree (objfile -> md, (PTR) BLOCK_SYM (b, i));
84 }
85 mfree (objfile -> md, (PTR) b);
86 }
87
88 /* Free all the storage associated with the struct symtab <- S.
89 Note that some symtabs have contents malloc'ed structure by structure,
90 while some have contents that all live inside one big block of memory,
91 and some share the contents of another symbol table and so you should
92 not free the contents on their behalf (except sometimes the linetable,
93 which maybe per symtab even when the rest is not).
94 It is s->free_code that says which alternative to use. */
95
96 void
97 free_symtab (s)
98 register struct symtab *s;
99 {
100 register int i, n;
101 register struct blockvector *bv;
102
103 switch (s->free_code)
104 {
105 case free_nothing:
106 /* All the contents are part of a big block of memory (an obstack),
107 and some other symtab is in charge of freeing that block.
108 Therefore, do nothing. */
109 break;
110
111 case free_contents:
112 /* Here all the contents were malloc'ed structure by structure
113 and must be freed that way. */
114 /* First free the blocks (and their symbols. */
115 bv = BLOCKVECTOR (s);
116 n = BLOCKVECTOR_NBLOCKS (bv);
117 for (i = 0; i < n; i++)
118 free_symtab_block (s -> objfile, BLOCKVECTOR_BLOCK (bv, i));
119 /* Free the blockvector itself. */
120 mfree (s -> objfile -> md, (PTR) bv);
121 /* Also free the linetable. */
122
123 case free_linetable:
124 /* Everything will be freed either by our `free_ptr'
125 or by some other symtab, except for our linetable.
126 Free that now. */
127 if (LINETABLE (s))
128 mfree (s -> objfile -> md, (PTR) LINETABLE (s));
129 break;
130 }
131
132 /* If there is a single block of memory to free, free it. */
133 if (s -> free_ptr != NULL)
134 mfree (s -> objfile -> md, s -> free_ptr);
135
136 /* Free source-related stuff */
137 if (s -> line_charpos != NULL)
138 mfree (s -> objfile -> md, (PTR) s -> line_charpos);
139 if (s -> fullname != NULL)
140 mfree (s -> objfile -> md, s -> fullname);
141 mfree (s -> objfile -> md, (PTR) s);
142 }
143
144 #if MAINTENANCE_CMDS
145
146 static void
147 dump_objfile (objfile)
148 struct objfile *objfile;
149 {
150 struct symtab *symtab;
151 struct partial_symtab *psymtab;
152
153 printf_filtered ("\nObject file %s: ", objfile -> name);
154 printf_filtered ("Objfile at %x, bfd at %x, %d minsyms\n\n",
155 objfile, objfile -> obfd, objfile->minimal_symbol_count);
156
157 if (objfile -> psymtabs)
158 {
159 printf_filtered ("Psymtabs:\n");
160 for (psymtab = objfile -> psymtabs;
161 psymtab != NULL;
162 psymtab = psymtab -> next)
163 {
164 printf_filtered ("%s at %x, ", psymtab -> filename, psymtab);
165 if (psymtab -> objfile != objfile)
166 {
167 printf_filtered ("NOT ON CHAIN! ");
168 }
169 wrap_here (" ");
170 }
171 printf_filtered ("\n\n");
172 }
173
174 if (objfile -> symtabs)
175 {
176 printf_filtered ("Symtabs:\n");
177 for (symtab = objfile -> symtabs;
178 symtab != NULL;
179 symtab = symtab->next)
180 {
181 printf_filtered ("%s at %x, ", symtab -> filename, symtab);
182 if (symtab -> objfile != objfile)
183 {
184 printf_filtered ("NOT ON CHAIN! ");
185 }
186 wrap_here (" ");
187 }
188 printf_filtered ("\n\n");
189 }
190 }
191
192 /* Print minimal symbols from this objfile. */
193
194 static void
195 dump_msymbols (objfile, outfile)
196 struct objfile *objfile;
197 FILE *outfile;
198 {
199 struct minimal_symbol *msymbol;
200 int index;
201 char ms_type;
202
203 fprintf_filtered (outfile, "\nObject file %s:\n\n", objfile -> name);
204 for (index = 0, msymbol = objfile -> msymbols;
205 SYMBOL_NAME (msymbol) != NULL; msymbol++, index++)
206 {
207 switch (msymbol -> type)
208 {
209 case mst_unknown:
210 ms_type = 'u';
211 break;
212 case mst_text:
213 ms_type = 't';
214 break;
215 case mst_data:
216 ms_type = 'd';
217 break;
218 case mst_bss:
219 ms_type = 'b';
220 break;
221 case mst_abs:
222 ms_type = 'a';
223 break;
224 default:
225 ms_type = '?';
226 break;
227 }
228 fprintf_filtered (outfile, "[%2d] %c %#10x %s", index, ms_type,
229 SYMBOL_VALUE_ADDRESS (msymbol), SYMBOL_NAME (msymbol));
230 if (SYMBOL_DEMANGLED_NAME (msymbol) != NULL)
231 {
232 fprintf_filtered (outfile, " %s", SYMBOL_DEMANGLED_NAME (msymbol));
233 }
234 fputs_filtered ("\n", outfile);
235 }
236 if (objfile -> minimal_symbol_count != index)
237 {
238 warning ("internal error: minimal symbol count %d != %d",
239 objfile -> minimal_symbol_count, index);
240 }
241 fprintf_filtered (outfile, "\n");
242 }
243
244 static void
245 dump_psymtab (objfile, psymtab, outfile)
246 struct objfile *objfile;
247 struct partial_symtab *psymtab;
248 FILE *outfile;
249 {
250
251 fprintf_filtered (outfile, "\nPartial symtab for source file %s ",
252 psymtab -> filename);
253 fprintf_filtered (outfile, "(object 0x%x)\n\n", psymtab);
254 fprintf (outfile, " Read from object file %s (0x%x)\n",
255 objfile -> name, (unsigned int) objfile);
256
257 if (psymtab -> readin)
258 {
259 fprintf_filtered (outfile,
260 " Full symtab was read (at 0x%x by function at 0x%x)\n",
261 psymtab -> symtab, psymtab -> read_symtab);
262 }
263
264 /* FIXME, we need to be able to print the relocation stuff. */
265 /* This prints some garbage for anything but stabs right now. FIXME. */
266 if (psymtab->section_offsets)
267 fprintf_filtered (outfile, " Relocate symbols by 0x%x, 0x%x, 0x%x, 0x%x.\n",
268 ANOFFSET (psymtab->section_offsets, 0),
269 ANOFFSET (psymtab->section_offsets, 1),
270 ANOFFSET (psymtab->section_offsets, 2),
271 ANOFFSET (psymtab->section_offsets, 3));
272
273 fprintf_filtered (outfile, " Symbols cover text addresses 0x%x-0x%x\n",
274 psymtab -> textlow, psymtab -> texthigh);
275 fprintf_filtered (outfile, " Depends on %d other partial symtabs.\n",
276 psymtab -> number_of_dependencies);
277 if (psymtab -> n_global_syms > 0)
278 {
279 print_partial_symbol (objfile -> global_psymbols.list
280 + psymtab -> globals_offset,
281 psymtab -> n_global_syms, "Global", outfile);
282 }
283 if (psymtab -> n_static_syms > 0)
284 {
285 print_partial_symbol (objfile -> static_psymbols.list
286 + psymtab -> statics_offset,
287 psymtab -> n_static_syms, "Static", outfile);
288 }
289 fprintf_filtered (outfile, "\n");
290 }
291
292 static void
293 dump_symtab (objfile, symtab, outfile)
294 struct objfile *objfile;
295 struct symtab *symtab;
296 FILE *outfile;
297 {
298 register int i, j;
299 int len, blen;
300 register struct linetable *l;
301 struct blockvector *bv;
302 register struct block *b;
303 int depth;
304
305 fprintf (outfile, "\nSymtab for file %s\n", symtab->filename);
306 fprintf (outfile, "Read from object file %s (%x)\n", objfile->name,
307 (unsigned int) objfile);
308 fprintf (outfile, "Language: %s\n", language_str (symtab -> language));
309
310 /* First print the line table. */
311 l = LINETABLE (symtab);
312 if (l) {
313 fprintf (outfile, "\nLine table:\n\n");
314 len = l->nitems;
315 for (i = 0; i < len; i++)
316 fprintf (outfile, " line %d at %x\n", l->item[i].line,
317 l->item[i].pc);
318 }
319 /* Now print the block info. */
320 fprintf (outfile, "\nBlockvector:\n\n");
321 bv = BLOCKVECTOR (symtab);
322 len = BLOCKVECTOR_NBLOCKS (bv);
323 for (i = 0; i < len; i++)
324 {
325 b = BLOCKVECTOR_BLOCK (bv, i);
326 depth = block_depth (b) * 2;
327 print_spaces (depth, outfile);
328 fprintf (outfile, "block #%03d (object 0x%x) ", i, (unsigned int) b);
329 fprintf (outfile, "[0x%x..0x%x]", BLOCK_START (b), BLOCK_END (b));
330 if (BLOCK_SUPERBLOCK (b))
331 fprintf (outfile, " (under 0x%x)", (unsigned int) BLOCK_SUPERBLOCK (b));
332 if (BLOCK_FUNCTION (b))
333 {
334 fprintf (outfile, " %s", SYMBOL_NAME (BLOCK_FUNCTION (b)));
335 if (SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b)) != NULL)
336 {
337 fprintf (outfile, " %s",
338 SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b)));
339 }
340 }
341 if (BLOCK_GCC_COMPILED(b))
342 fprintf (outfile, " gcc%d compiled", BLOCK_GCC_COMPILED(b));
343 fputc ('\n', outfile);
344 blen = BLOCK_NSYMS (b);
345 for (j = 0; j < blen; j++)
346 {
347 print_symbol (BLOCK_SYM (b, j), depth + 1, outfile);
348 }
349 }
350 fprintf (outfile, "\n");
351 }
352
353 void
354 maintenance_print_symbols (args, from_tty)
355 char *args;
356 int from_tty;
357 {
358 char **argv;
359 FILE *outfile;
360 struct cleanup *cleanups;
361 char *symname = NULL;
362 char *filename = DEV_TTY;
363 struct objfile *objfile;
364 struct symtab *s;
365
366 dont_repeat ();
367
368 if (args == NULL)
369 {
370 error ("print-symbols takes an output file name and optional symbol file name");
371 }
372 else if ((argv = buildargv (args)) == NULL)
373 {
374 nomem (0);
375 }
376 cleanups = make_cleanup (freeargv, (char *) argv);
377
378 if (argv[0] != NULL)
379 {
380 filename = argv[0];
381 /* If a second arg is supplied, it is a source file name to match on */
382 if (argv[1] != NULL)
383 {
384 symname = argv[1];
385 }
386 }
387
388 filename = tilde_expand (filename);
389 make_cleanup (free, filename);
390
391 outfile = fopen (filename, "w");
392 if (outfile == 0)
393 perror_with_name (filename);
394 make_cleanup (fclose, (char *) outfile);
395
396 immediate_quit++;
397 ALL_SYMTABS (objfile, s)
398 if (symname == NULL || (STREQ (symname, s -> filename)))
399 dump_symtab (objfile, s, outfile);
400 immediate_quit--;
401 do_cleanups (cleanups);
402 }
403
404 static void
405 print_symbol (symbol, depth, outfile)
406 struct symbol *symbol;
407 int depth;
408 FILE *outfile;
409 {
410 print_spaces (depth, outfile);
411 if (SYMBOL_NAMESPACE (symbol) == LABEL_NAMESPACE)
412 {
413 fprintf (outfile, "label %s at 0x%x\n", SYMBOL_SOURCE_NAME (symbol),
414 SYMBOL_VALUE_ADDRESS (symbol));
415 return;
416 }
417 if (SYMBOL_NAMESPACE (symbol) == STRUCT_NAMESPACE)
418 {
419 if (TYPE_NAME (SYMBOL_TYPE (symbol)))
420 {
421 LA_PRINT_TYPE (SYMBOL_TYPE (symbol), "", outfile, 1, depth);
422 }
423 else
424 {
425 fprintf (outfile, "%s %s = ",
426 (TYPE_CODE (SYMBOL_TYPE (symbol)) == TYPE_CODE_ENUM
427 ? "enum"
428 : (TYPE_CODE (SYMBOL_TYPE (symbol)) == TYPE_CODE_STRUCT
429 ? "struct" : "union")),
430 SYMBOL_NAME (symbol));
431 LA_PRINT_TYPE (SYMBOL_TYPE (symbol), "", outfile, 1, depth);
432 }
433 fprintf (outfile, ";\n");
434 }
435 else
436 {
437 if (SYMBOL_CLASS (symbol) == LOC_TYPEDEF)
438 fprintf (outfile, "typedef ");
439 if (SYMBOL_TYPE (symbol))
440 {
441 /* Print details of types, except for enums where it's clutter. */
442 LA_PRINT_TYPE (SYMBOL_TYPE (symbol), SYMBOL_NAME (symbol), outfile,
443 TYPE_CODE (SYMBOL_TYPE (symbol)) != TYPE_CODE_ENUM,
444 depth);
445 fprintf (outfile, "; ");
446 }
447 else
448 fprintf (outfile, "%s ", SYMBOL_SOURCE_NAME (symbol));
449
450 switch (SYMBOL_CLASS (symbol))
451 {
452 case LOC_CONST:
453 fprintf (outfile, "const %ld (0x%lx),",
454 SYMBOL_VALUE (symbol), SYMBOL_VALUE (symbol));
455 break;
456
457 case LOC_CONST_BYTES:
458 fprintf (outfile, "const %u hex bytes:",
459 TYPE_LENGTH (SYMBOL_TYPE (symbol)));
460 {
461 unsigned i;
462 for (i = 0; i < TYPE_LENGTH (SYMBOL_TYPE (symbol)); i++)
463 fprintf (outfile, " %2x",
464 (unsigned)SYMBOL_VALUE_BYTES (symbol) [i]);
465 fprintf (outfile, ",");
466 }
467 break;
468
469 case LOC_STATIC:
470 fprintf (outfile, "static at 0x%x,", SYMBOL_VALUE_ADDRESS (symbol));
471 break;
472
473 case LOC_REGISTER:
474 fprintf (outfile, "register %ld,", SYMBOL_VALUE (symbol));
475 break;
476
477 case LOC_ARG:
478 if (SYMBOL_BASEREG_VALID (symbol))
479 {
480 fprintf (outfile, "arg at 0x%lx from register %d,",
481 SYMBOL_VALUE (symbol), SYMBOL_BASEREG (symbol));
482 }
483 else
484 {
485 fprintf (outfile, "arg at 0x%lx,", SYMBOL_VALUE (symbol));
486 }
487 break;
488
489 case LOC_LOCAL_ARG:
490 if (SYMBOL_BASEREG_VALID (symbol))
491 {
492 fprintf (outfile, "arg at offset 0x%lx from register %d,",
493 SYMBOL_VALUE (symbol), SYMBOL_BASEREG (symbol));
494 }
495 else
496 {
497 fprintf (outfile, "arg at offset 0x%lx from fp,",
498 SYMBOL_VALUE (symbol));
499 }
500
501 case LOC_REF_ARG:
502 fprintf (outfile, "reference arg at 0x%lx,", SYMBOL_VALUE (symbol));
503 break;
504
505 case LOC_REGPARM:
506 fprintf (outfile, "parameter register %ld,", SYMBOL_VALUE (symbol));
507 break;
508
509 case LOC_LOCAL:
510 if (SYMBOL_BASEREG_VALID (symbol))
511 {
512 fprintf (outfile, "local at 0x%lx from register %d",
513 SYMBOL_VALUE (symbol), SYMBOL_BASEREG (symbol));
514 }
515 else
516 {
517 fprintf (outfile, "local at 0x%lx,", SYMBOL_VALUE (symbol));
518 }
519 break;
520
521 case LOC_TYPEDEF:
522 break;
523
524 case LOC_LABEL:
525 fprintf (outfile, "label at 0x%lx", SYMBOL_VALUE_ADDRESS (symbol));
526 break;
527
528 case LOC_BLOCK:
529 fprintf (outfile, "block (object 0x%x) starting at 0x%x,",
530 (unsigned int) SYMBOL_BLOCK_VALUE (symbol),
531 BLOCK_START (SYMBOL_BLOCK_VALUE (symbol)));
532 break;
533
534 default:
535 fprintf (outfile, "botched symbol class %x", SYMBOL_CLASS (symbol));
536 break;
537 }
538 }
539 fprintf (outfile, "\n");
540 }
541
542 void
543 maintenance_print_psymbols (args, from_tty)
544 char *args;
545 int from_tty;
546 {
547 char **argv;
548 FILE *outfile;
549 struct cleanup *cleanups;
550 char *symname = NULL;
551 char *filename = DEV_TTY;
552 struct objfile *objfile;
553 struct partial_symtab *ps;
554
555 dont_repeat ();
556
557 if (args == NULL)
558 {
559 error ("print-psymbols takes an output file name and optional symbol file name");
560 }
561 else if ((argv = buildargv (args)) == NULL)
562 {
563 nomem (0);
564 }
565 cleanups = make_cleanup (freeargv, (char *) argv);
566
567 if (argv[0] != NULL)
568 {
569 filename = argv[0];
570 /* If a second arg is supplied, it is a source file name to match on */
571 if (argv[1] != NULL)
572 {
573 symname = argv[1];
574 }
575 }
576
577 filename = tilde_expand (filename);
578 make_cleanup (free, filename);
579
580 outfile = fopen (filename, "w");
581 if (outfile == 0)
582 perror_with_name (filename);
583 make_cleanup (fclose, outfile);
584
585 immediate_quit++;
586 ALL_PSYMTABS (objfile, ps)
587 if (symname == NULL || (STREQ (symname, ps -> filename)))
588 dump_psymtab (objfile, ps, outfile);
589 immediate_quit--;
590 do_cleanups (cleanups);
591 }
592
593 static void
594 print_partial_symbol (p, count, what, outfile)
595 struct partial_symbol *p;
596 int count;
597 char *what;
598 FILE *outfile;
599 {
600
601 fprintf_filtered (outfile, " %s partial symbols:\n", what);
602 while (count-- > 0)
603 {
604 fprintf_filtered (outfile, " `%s'", SYMBOL_NAME(p));
605 if (SYMBOL_DEMANGLED_NAME (p) != NULL)
606 {
607 fprintf_filtered (outfile, " `%s'", SYMBOL_DEMANGLED_NAME (p));
608 }
609 fputs_filtered (", ", outfile);
610 switch (SYMBOL_NAMESPACE (p))
611 {
612 case UNDEF_NAMESPACE:
613 fputs_filtered ("undefined namespace, ", outfile);
614 break;
615 case VAR_NAMESPACE:
616 /* This is the usual thing -- don't print it */
617 break;
618 case STRUCT_NAMESPACE:
619 fputs_filtered ("struct namespace, ", outfile);
620 break;
621 case LABEL_NAMESPACE:
622 fputs_filtered ("label namespace, ", outfile);
623 break;
624 default:
625 fputs_filtered ("<invalid namespace>, ", outfile);
626 break;
627 }
628 switch (SYMBOL_CLASS (p))
629 {
630 case LOC_UNDEF:
631 fputs_filtered ("undefined", outfile);
632 break;
633 case LOC_CONST:
634 fputs_filtered ("constant int", outfile);
635 break;
636 case LOC_STATIC:
637 fputs_filtered ("static", outfile);
638 break;
639 case LOC_REGISTER:
640 fputs_filtered ("register", outfile);
641 break;
642 case LOC_ARG:
643 fputs_filtered ("pass by value", outfile);
644 break;
645 case LOC_REF_ARG:
646 fputs_filtered ("pass by reference", outfile);
647 break;
648 case LOC_REGPARM:
649 fputs_filtered ("register parameter", outfile);
650 break;
651 case LOC_LOCAL:
652 fputs_filtered ("stack parameter", outfile);
653 break;
654 case LOC_TYPEDEF:
655 fputs_filtered ("type", outfile);
656 break;
657 case LOC_LABEL:
658 fputs_filtered ("label", outfile);
659 break;
660 case LOC_BLOCK:
661 fputs_filtered ("function", outfile);
662 break;
663 case LOC_CONST_BYTES:
664 fputs_filtered ("constant bytes", outfile);
665 break;
666 case LOC_LOCAL_ARG:
667 fputs_filtered ("shuffled arg", outfile);
668 break;
669 default:
670 fputs_filtered ("<invalid location>", outfile);
671 break;
672 }
673 fputs_filtered (", ", outfile);
674 fprintf_filtered (outfile, "0x%x\n", SYMBOL_VALUE (p));
675 p++;
676 }
677 }
678
679 void
680 maintenance_print_msymbols (args, from_tty)
681 char *args;
682 int from_tty;
683 {
684 char **argv;
685 FILE *outfile;
686 struct cleanup *cleanups;
687 char *filename = DEV_TTY;
688 char *symname = NULL;
689 struct objfile *objfile;
690
691 dont_repeat ();
692
693 if (args == NULL)
694 {
695 error ("print-msymbols takes an output file name and optional symbol file name");
696 }
697 else if ((argv = buildargv (args)) == NULL)
698 {
699 nomem (0);
700 }
701 cleanups = make_cleanup (freeargv, argv);
702
703 if (argv[0] != NULL)
704 {
705 filename = argv[0];
706 /* If a second arg is supplied, it is a source file name to match on */
707 if (argv[1] != NULL)
708 {
709 symname = argv[1];
710 }
711 }
712
713 filename = tilde_expand (filename);
714 make_cleanup (free, filename);
715
716 outfile = fopen (filename, "w");
717 if (outfile == 0)
718 perror_with_name (filename);
719 make_cleanup (fclose, outfile);
720
721 immediate_quit++;
722 ALL_OBJFILES (objfile)
723 if (symname == NULL || (STREQ (symname, objfile -> name)))
724 dump_msymbols (objfile, outfile);
725 immediate_quit--;
726 fprintf_filtered (outfile, "\n\n");
727 do_cleanups (cleanups);
728 }
729
730 void
731 maintenance_print_objfiles (ignore, from_tty)
732 char *ignore;
733 int from_tty;
734 {
735 struct objfile *objfile;
736
737 dont_repeat ();
738
739 immediate_quit++;
740 ALL_OBJFILES (objfile)
741 dump_objfile (objfile);
742 immediate_quit--;
743 }
744
745 \f
746 /* Return the nexting depth of a block within other blocks in its symtab. */
747
748 static int
749 block_depth (block)
750 struct block *block;
751 {
752 register int i = 0;
753 while ((block = BLOCK_SUPERBLOCK (block)) != NULL)
754 {
755 i++;
756 }
757 return i;
758 }
759
760 #endif /* MAINTENANCE_CMDS */
761
762 \f
763 /* Increase the space allocated for LISTP, which is probably
764 global_psymbol_list or static_psymbol_list. This space will eventually
765 be freed in free_objfile(). */
766
767 void
768 extend_psymbol_list (listp, objfile)
769 register struct psymbol_allocation_list *listp;
770 struct objfile *objfile;
771 {
772 int new_size;
773 if (listp->size == 0)
774 {
775 new_size = 255;
776 listp->list = (struct partial_symbol *)
777 xmmalloc (objfile -> md, new_size * sizeof (struct partial_symbol));
778 }
779 else
780 {
781 new_size = listp->size * 2;
782 listp->list = (struct partial_symbol *)
783 xmrealloc (objfile -> md, (char *) listp->list,
784 new_size * sizeof (struct partial_symbol));
785 }
786 /* Next assumes we only went one over. Should be good if
787 program works correctly */
788 listp->next = listp->list + listp->size;
789 listp->size = new_size;
790 }
This page took 0.047815 seconds and 4 git commands to generate.