6b846667d481b1287426cd865356a58f9ee431e6
[deliverable/binutils-gdb.git] / gdb / buildsym.c
1 /* Build symbol tables in GDB's internal format.
2 Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992
3 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21 /* This module provides subroutines used for creating and adding to
22 the symbol table. These routines are called from various symbol-
23 file-reading routines.
24
25 They originated in dbxread.c of gdb-4.2, and were split out to
26 make xcoffread.c more maintainable by sharing code. */
27
28 #include "defs.h"
29 #include "obstack.h"
30 #include "symtab.h"
31 #include "gdbtypes.h"
32 #include "breakpoint.h"
33 #include "gdbcore.h" /* for bfd stuff for symfile.h */
34 #include "symfile.h" /* Needed for "struct complaint" */
35 #include "objfiles.h"
36 #include "aout/stab_gnu.h" /* We always use GNU stabs, not native */
37 #include <string.h>
38 #include <ctype.h>
39
40 /* Ask buildsym.h to define the vars it normally declares `extern'. */
41 #define EXTERN /**/
42 #include "buildsym.h" /* Our own declarations */
43 #undef EXTERN
44
45 static void
46 patch_block_stabs PARAMS ((struct pending *, struct pending_stabs *,
47 struct objfile *));
48
49 static void
50 read_huge_number PARAMS ((char **, int, long *, int *));
51
52 struct type *
53 dbx_alloc_type PARAMS ((int [2], struct objfile *));
54
55 static int
56 compare_line_numbers PARAMS ((const void *, const void *));
57
58 static struct blockvector *
59 make_blockvector PARAMS ((struct objfile *));
60
61 static void
62 fix_common_block PARAMS ((struct symbol *, int));
63
64 static void
65 cleanup_undefined_types PARAMS ((void));
66
67 static struct type *
68 read_range_type PARAMS ((char **, int [2], struct objfile *));
69
70 static struct type *
71 read_sun_builtin_type PARAMS ((char **, int [2], struct objfile *));
72
73 static struct type *
74 read_sun_floating_type PARAMS ((char **, int [2], struct objfile *));
75
76 static struct type *
77 read_enum_type PARAMS ((char **, struct type *, struct objfile *));
78
79 static struct type *
80 read_struct_type PARAMS ((char **, struct type *, struct objfile *));
81
82 static struct type *
83 read_array_type PARAMS ((char **, struct type *, struct objfile *));
84
85 static struct type **
86 read_args PARAMS ((char **, int, struct objfile *));
87
88 \f
89
90 static const char vptr_name[] = { '_','v','p','t','r',CPLUS_MARKER,'\0' };
91 static const char vb_name[] = { '_','v','b',CPLUS_MARKER,'\0' };
92
93 /* Define this as 1 if a pcc declaration of a char or short argument
94 gives the correct address. Otherwise assume pcc gives the
95 address of the corresponding int, which is not the same on a
96 big-endian machine. */
97
98 #ifndef BELIEVE_PCC_PROMOTION
99 #define BELIEVE_PCC_PROMOTION 0
100 #endif
101
102 /* During some calls to read_type (and thus to read_range_type), this
103 contains the name of the type being defined. Range types are only
104 used in C as basic types. We use the name to distinguish the otherwise
105 identical basic types "int" and "long" and their unsigned versions.
106 FIXME, this should disappear with better type management. */
107
108 static char *long_kludge_name;
109
110 /* Make a list of forward references which haven't been defined. */
111 static struct type **undef_types;
112 static int undef_types_allocated, undef_types_length;
113
114 /* Initial sizes of data structures. These are realloc'd larger if needed,
115 and realloc'd down to the size actually used, when completed. */
116
117 #define INITIAL_CONTEXT_STACK_SIZE 10
118 #define INITIAL_TYPE_VECTOR_LENGTH 160
119 #define INITIAL_LINE_VECTOR_LENGTH 1000
120 \f
121 /* Complaints about the symbols we have encountered. */
122
123 struct complaint innerblock_complaint =
124 {"inner block not inside outer block in %s", 0, 0};
125
126 struct complaint blockvector_complaint =
127 {"block at %x out of order", 0, 0};
128
129 #if 0
130 struct complaint dbx_class_complaint =
131 {"encountered DBX-style class variable debugging information.\n\
132 You seem to have compiled your program with \
133 \"g++ -g0\" instead of \"g++ -g\".\n\
134 Therefore GDB will not know about your class variables", 0, 0};
135 #endif
136
137 struct complaint invalid_cpp_abbrev_complaint =
138 {"invalid C++ abbreviation `%s'", 0, 0};
139
140 struct complaint invalid_cpp_type_complaint =
141 {"C++ abbreviated type name unknown at symtab pos %d", 0, 0};
142
143 struct complaint member_fn_complaint =
144 {"member function type missing, got '%c'", 0, 0};
145
146 struct complaint const_vol_complaint =
147 {"const/volatile indicator missing, got '%c'", 0, 0};
148
149 struct complaint error_type_complaint =
150 {"debug info mismatch between compiler and debugger", 0, 0};
151
152 struct complaint invalid_member_complaint =
153 {"invalid (minimal) member type data format at symtab pos %d.", 0, 0};
154
155 struct complaint range_type_base_complaint =
156 {"base type %d of range type is not defined", 0, 0};
157
158 struct complaint reg_value_complaint =
159 {"register number too large in symbol %s", 0, 0};
160 \f
161 int
162 hashname (name)
163 char *name;
164 {
165 register char *p = name;
166 register int total = p[0];
167 register int c;
168
169 c = p[1];
170 total += c << 2;
171 if (c)
172 {
173 c = p[2];
174 total += c << 4;
175 if (c)
176 total += p[3] << 6;
177 }
178
179 /* Ensure result is positive. */
180 if (total < 0) total += (1000 << 6);
181 return total % HASHSIZE;
182 }
183
184 \f
185 /* Look up a dbx type-number pair. Return the address of the slot
186 where the type for that number-pair is stored.
187 The number-pair is in TYPENUMS.
188
189 This can be used for finding the type associated with that pair
190 or for associating a new type with the pair. */
191
192 struct type **
193 dbx_lookup_type (typenums)
194 int typenums[2];
195 {
196 register int filenum = typenums[0], index = typenums[1];
197 unsigned old_len;
198
199 if (filenum == -1) /* -1,-1 is for temporary types. */
200 return 0;
201
202 if (filenum < 0 || filenum >= n_this_object_header_files)
203 error ("Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.",
204 filenum, index, symnum);
205
206 if (filenum == 0)
207 {
208 /* Type is defined outside of header files.
209 Find it in this object file's type vector. */
210 if (index >= type_vector_length)
211 {
212 old_len = type_vector_length;
213 if (old_len == 0) {
214 type_vector_length = INITIAL_TYPE_VECTOR_LENGTH;
215 type_vector = (struct type **)
216 malloc (type_vector_length * sizeof (struct type *));
217 }
218 while (index >= type_vector_length)
219 type_vector_length *= 2;
220 type_vector = (struct type **)
221 xrealloc ((char *) type_vector,
222 (type_vector_length * sizeof (struct type *)));
223 bzero (&type_vector[old_len],
224 (type_vector_length - old_len) * sizeof (struct type *));
225 }
226 return &type_vector[index];
227 }
228 else
229 {
230 register int real_filenum = this_object_header_files[filenum];
231 register struct header_file *f;
232 int f_orig_length;
233
234 if (real_filenum >= n_header_files)
235 abort ();
236
237 f = &header_files[real_filenum];
238
239 f_orig_length = f->length;
240 if (index >= f_orig_length)
241 {
242 while (index >= f->length)
243 f->length *= 2;
244 f->vector = (struct type **)
245 xrealloc ((char *) f->vector, f->length * sizeof (struct type *));
246 bzero (&f->vector[f_orig_length],
247 (f->length - f_orig_length) * sizeof (struct type *));
248 }
249 return &f->vector[index];
250 }
251 }
252
253 /* Make sure there is a type allocated for type numbers TYPENUMS
254 and return the type object.
255 This can create an empty (zeroed) type object.
256 TYPENUMS may be (-1, -1) to return a new type object that is not
257 put into the type vector, and so may not be referred to by number. */
258
259 struct type *
260 dbx_alloc_type (typenums, objfile)
261 int typenums[2];
262 struct objfile *objfile;
263 {
264 register struct type **type_addr;
265
266 if (typenums[0] == -1)
267 return alloc_type (objfile);
268
269 type_addr = dbx_lookup_type (typenums);
270
271 /* If we are referring to a type not known at all yet,
272 allocate an empty type for it.
273 We will fill it in later if we find out how. */
274 if (*type_addr == 0)
275 *type_addr = alloc_type (objfile);
276
277 return *type_addr;
278 }
279 \f
280 /* maintain the lists of symbols and blocks */
281
282 /* Add a symbol to one of the lists of symbols. */
283 void
284 add_symbol_to_list (symbol, listhead)
285 struct symbol *symbol;
286 struct pending **listhead;
287 {
288 /* We keep PENDINGSIZE symbols in each link of the list.
289 If we don't have a link with room in it, add a new link. */
290 if (*listhead == 0 || (*listhead)->nsyms == PENDINGSIZE)
291 {
292 register struct pending *link;
293 if (free_pendings)
294 {
295 link = free_pendings;
296 free_pendings = link->next;
297 }
298 else
299 link = (struct pending *) xmalloc (sizeof (struct pending));
300
301 link->next = *listhead;
302 *listhead = link;
303 link->nsyms = 0;
304 }
305
306 (*listhead)->symbol[(*listhead)->nsyms++] = symbol;
307 }
308
309 /* Find a symbol on a pending list. */
310 struct symbol *
311 find_symbol_in_list (list, name, length)
312 struct pending *list;
313 char *name;
314 int length;
315 {
316 int j;
317
318 while (list) {
319 for (j = list->nsyms; --j >= 0; ) {
320 char *pp = SYMBOL_NAME (list->symbol[j]);
321 if (*pp == *name && strncmp (pp, name, length) == 0 && pp[length] == '\0')
322 return list->symbol[j];
323 }
324 list = list->next;
325 }
326 return NULL;
327 }
328
329 /* At end of reading syms, or in case of quit,
330 really free as many `struct pending's as we can easily find. */
331
332 /* ARGSUSED */
333 void
334 really_free_pendings (foo)
335 int foo;
336 {
337 struct pending *next, *next1;
338 #if 0
339 struct pending_block *bnext, *bnext1;
340 #endif
341
342 for (next = free_pendings; next; next = next1)
343 {
344 next1 = next->next;
345 free ((PTR)next);
346 }
347 free_pendings = 0;
348
349 #if 0 /* Now we make the links in the symbol_obstack, so don't free them. */
350 for (bnext = pending_blocks; bnext; bnext = bnext1)
351 {
352 bnext1 = bnext->next;
353 free ((PTR)bnext);
354 }
355 #endif
356 pending_blocks = 0;
357
358 for (next = file_symbols; next; next = next1)
359 {
360 next1 = next->next;
361 free ((PTR)next);
362 }
363 file_symbols = 0;
364
365 for (next = global_symbols; next; next = next1)
366 {
367 next1 = next->next;
368 free ((PTR)next);
369 }
370 global_symbols = 0;
371 }
372
373 /* Take one of the lists of symbols and make a block from it.
374 Keep the order the symbols have in the list (reversed from the input file).
375 Put the block on the list of pending blocks. */
376
377 void
378 finish_block (symbol, listhead, old_blocks, start, end, objfile)
379 struct symbol *symbol;
380 struct pending **listhead;
381 struct pending_block *old_blocks;
382 CORE_ADDR start, end;
383 struct objfile *objfile;
384 {
385 register struct pending *next, *next1;
386 register struct block *block;
387 register struct pending_block *pblock;
388 struct pending_block *opblock;
389 register int i;
390
391 /* Count the length of the list of symbols. */
392
393 for (next = *listhead, i = 0;
394 next;
395 i += next->nsyms, next = next->next)
396 /*EMPTY*/;
397
398 block = (struct block *) obstack_alloc (&objfile -> symbol_obstack,
399 (sizeof (struct block) + ((i - 1) * sizeof (struct symbol *))));
400
401 /* Copy the symbols into the block. */
402
403 BLOCK_NSYMS (block) = i;
404 for (next = *listhead; next; next = next->next)
405 {
406 register int j;
407 for (j = next->nsyms - 1; j >= 0; j--)
408 BLOCK_SYM (block, --i) = next->symbol[j];
409 }
410
411 BLOCK_START (block) = start;
412 BLOCK_END (block) = end;
413 BLOCK_SUPERBLOCK (block) = 0; /* Filled in when containing block is made */
414 BLOCK_GCC_COMPILED (block) = processing_gcc_compilation;
415
416 /* Put the block in as the value of the symbol that names it. */
417
418 if (symbol)
419 {
420 SYMBOL_BLOCK_VALUE (symbol) = block;
421 BLOCK_FUNCTION (block) = symbol;
422 }
423 else
424 BLOCK_FUNCTION (block) = 0;
425
426 /* Now "free" the links of the list, and empty the list. */
427
428 for (next = *listhead; next; next = next1)
429 {
430 next1 = next->next;
431 next->next = free_pendings;
432 free_pendings = next;
433 }
434 *listhead = 0;
435
436 /* Install this block as the superblock
437 of all blocks made since the start of this scope
438 that don't have superblocks yet. */
439
440 opblock = 0;
441 for (pblock = pending_blocks; pblock != old_blocks; pblock = pblock->next)
442 {
443 if (BLOCK_SUPERBLOCK (pblock->block) == 0) {
444 #if 1
445 /* Check to be sure the blocks are nested as we receive them.
446 If the compiler/assembler/linker work, this just burns a small
447 amount of time. */
448 if (BLOCK_START (pblock->block) < BLOCK_START (block)
449 || BLOCK_END (pblock->block) > BLOCK_END (block)) {
450 complain(&innerblock_complaint, symbol? SYMBOL_NAME (symbol):
451 "(don't know)");
452 BLOCK_START (pblock->block) = BLOCK_START (block);
453 BLOCK_END (pblock->block) = BLOCK_END (block);
454 }
455 #endif
456 BLOCK_SUPERBLOCK (pblock->block) = block;
457 }
458 opblock = pblock;
459 }
460
461 /* Record this block on the list of all blocks in the file.
462 Put it after opblock, or at the beginning if opblock is 0.
463 This puts the block in the list after all its subblocks. */
464
465 /* Allocate in the symbol_obstack to save time.
466 It wastes a little space. */
467 pblock = (struct pending_block *)
468 obstack_alloc (&objfile -> symbol_obstack,
469 sizeof (struct pending_block));
470 pblock->block = block;
471 if (opblock)
472 {
473 pblock->next = opblock->next;
474 opblock->next = pblock;
475 }
476 else
477 {
478 pblock->next = pending_blocks;
479 pending_blocks = pblock;
480 }
481 }
482
483 static struct blockvector *
484 make_blockvector (objfile)
485 struct objfile *objfile;
486 {
487 register struct pending_block *next;
488 register struct blockvector *blockvector;
489 register int i;
490
491 /* Count the length of the list of blocks. */
492
493 for (next = pending_blocks, i = 0; next; next = next->next, i++);
494
495 blockvector = (struct blockvector *)
496 obstack_alloc (&objfile -> symbol_obstack,
497 (sizeof (struct blockvector)
498 + (i - 1) * sizeof (struct block *)));
499
500 /* Copy the blocks into the blockvector.
501 This is done in reverse order, which happens to put
502 the blocks into the proper order (ascending starting address).
503 finish_block has hair to insert each block into the list
504 after its subblocks in order to make sure this is true. */
505
506 BLOCKVECTOR_NBLOCKS (blockvector) = i;
507 for (next = pending_blocks; next; next = next->next) {
508 BLOCKVECTOR_BLOCK (blockvector, --i) = next->block;
509 }
510
511 #if 0 /* Now we make the links in the obstack, so don't free them. */
512 /* Now free the links of the list, and empty the list. */
513
514 for (next = pending_blocks; next; next = next1)
515 {
516 next1 = next->next;
517 free (next);
518 }
519 #endif
520 pending_blocks = 0;
521
522 #if 1 /* FIXME, shut this off after a while to speed up symbol reading. */
523 /* Some compilers output blocks in the wrong order, but we depend
524 on their being in the right order so we can binary search.
525 Check the order and moan about it. FIXME. */
526 if (BLOCKVECTOR_NBLOCKS (blockvector) > 1)
527 for (i = 1; i < BLOCKVECTOR_NBLOCKS (blockvector); i++) {
528 if (BLOCK_START(BLOCKVECTOR_BLOCK (blockvector, i-1))
529 > BLOCK_START(BLOCKVECTOR_BLOCK (blockvector, i))) {
530 complain (&blockvector_complaint,
531 (char *) BLOCK_START(BLOCKVECTOR_BLOCK (blockvector, i)));
532 }
533 }
534 #endif
535
536 return blockvector;
537 }
538 \f
539 /* Start recording information about source code that came from an included
540 (or otherwise merged-in) source file with a different name. */
541
542 void
543 start_subfile (name, dirname)
544 char *name;
545 char *dirname;
546 {
547 register struct subfile *subfile;
548
549 /* See if this subfile is already known as a subfile of the
550 current main source file. */
551
552 for (subfile = subfiles; subfile; subfile = subfile->next)
553 {
554 if (!strcmp (subfile->name, name))
555 {
556 current_subfile = subfile;
557 return;
558 }
559 }
560
561 /* This subfile is not known. Add an entry for it.
562 Make an entry for this subfile in the list of all subfiles
563 of the current main source file. */
564
565 subfile = (struct subfile *) xmalloc (sizeof (struct subfile));
566 subfile->next = subfiles;
567 subfiles = subfile;
568 current_subfile = subfile;
569
570 /* Save its name and compilation directory name */
571 subfile->name = strdup (name);
572 if (dirname == NULL)
573 subfile->dirname = NULL;
574 else
575 subfile->dirname = strdup (dirname);
576
577 /* Initialize line-number recording for this subfile. */
578 subfile->line_vector = 0;
579 }
580 \f
581 /* Handle the N_BINCL and N_EINCL symbol types
582 that act like N_SOL for switching source files
583 (different subfiles, as we call them) within one object file,
584 but using a stack rather than in an arbitrary order. */
585
586 void
587 push_subfile ()
588 {
589 register struct subfile_stack *tem
590 = (struct subfile_stack *) xmalloc (sizeof (struct subfile_stack));
591
592 tem->next = subfile_stack;
593 subfile_stack = tem;
594 if (current_subfile == 0 || current_subfile->name == 0)
595 abort ();
596 tem->name = current_subfile->name;
597 }
598
599 char *
600 pop_subfile ()
601 {
602 register char *name;
603 register struct subfile_stack *link = subfile_stack;
604
605 if (link == 0)
606 abort ();
607
608 name = link->name;
609 subfile_stack = link->next;
610 free ((PTR)link);
611
612 return name;
613 }
614 \f
615 /* Manage the vector of line numbers for each subfile. */
616
617 void
618 record_line (subfile, line, pc)
619 register struct subfile *subfile;
620 int line;
621 CORE_ADDR pc;
622 {
623 struct linetable_entry *e;
624 /* Ignore the dummy line number in libg.o */
625
626 if (line == 0xffff)
627 return;
628
629 /* Make sure line vector exists and is big enough. */
630 if (!subfile->line_vector) {
631 subfile->line_vector_length = INITIAL_LINE_VECTOR_LENGTH;
632 subfile->line_vector = (struct linetable *)
633 xmalloc (sizeof (struct linetable)
634 + subfile->line_vector_length * sizeof (struct linetable_entry));
635 subfile->line_vector->nitems = 0;
636 }
637
638 if (subfile->line_vector->nitems + 1 >= subfile->line_vector_length)
639 {
640 subfile->line_vector_length *= 2;
641 subfile->line_vector = (struct linetable *)
642 xrealloc ((char *) subfile->line_vector, (sizeof (struct linetable)
643 + subfile->line_vector_length * sizeof (struct linetable_entry)));
644 }
645
646 e = subfile->line_vector->item + subfile->line_vector->nitems++;
647 e->line = line; e->pc = pc;
648 }
649
650
651 /* Needed in order to sort line tables from IBM xcoff files. Sigh! */
652
653 static int
654 compare_line_numbers (ln1p, ln2p)
655 const PTR ln1p;
656 const PTR ln2p;
657 {
658 return (((struct linetable_entry *) ln1p) -> line -
659 ((struct linetable_entry *) ln2p) -> line);
660 }
661
662 \f
663 /* Start a new symtab for a new source file.
664 This is called when a dbx symbol of type N_SO is seen;
665 it indicates the start of data for one original source file. */
666
667 void
668 start_symtab (name, dirname, start_addr)
669 char *name;
670 char *dirname;
671 CORE_ADDR start_addr;
672 {
673
674 last_source_file = name;
675 last_source_start_addr = start_addr;
676 file_symbols = 0;
677 global_symbols = 0;
678 global_stabs = 0; /* AIX COFF */
679 within_function = 0;
680
681 /* Context stack is initially empty. Allocate first one with room for
682 10 levels; reuse it forever afterward. */
683 if (context_stack == 0) {
684 context_stack_size = INITIAL_CONTEXT_STACK_SIZE;
685 context_stack = (struct context_stack *)
686 xmalloc (context_stack_size * sizeof (struct context_stack));
687 }
688 context_stack_depth = 0;
689
690 /* Leave FILENUM of 0 free for builtin types and this file's types. */
691 n_this_object_header_files = 1;
692
693 type_vector_length = 0;
694 type_vector = (struct type **) 0;
695
696 /* Initialize the list of sub source files with one entry
697 for this file (the top-level source file). */
698
699 subfiles = 0;
700 current_subfile = 0;
701 start_subfile (name, dirname);
702 }
703
704 /* for all the stabs in a given stab vector, build appropriate types
705 and fix their symbols in given symbol vector. */
706
707 static void
708 patch_block_stabs (symbols, stabs, objfile)
709 struct pending *symbols;
710 struct pending_stabs *stabs;
711 struct objfile *objfile;
712 {
713 int ii;
714
715 if (stabs)
716 {
717
718 /* for all the stab entries, find their corresponding symbols and
719 patch their types! */
720
721 for (ii = 0; ii < stabs->count; ++ii)
722 {
723 char *name = stabs->stab[ii];
724 char *pp = (char*) strchr (name, ':');
725 struct symbol *sym = find_symbol_in_list (symbols, name, pp-name);
726 if (!sym)
727 {
728 #ifndef IBM6000_TARGET
729 printf ("ERROR! stab symbol not found!\n"); /* FIXME */
730 #endif
731 }
732 else
733 {
734 pp += 2;
735 if (*(pp-1) == 'F' || *(pp-1) == 'f')
736 {
737 SYMBOL_TYPE (sym) =
738 lookup_function_type (read_type (&pp, objfile));
739 }
740 else
741 {
742 SYMBOL_TYPE (sym) = read_type (&pp, objfile);
743 }
744 }
745 }
746 }
747 }
748
749 /* Finish the symbol definitions for one main source file,
750 close off all the lexical contexts for that file
751 (creating struct block's for them), then make the struct symtab
752 for that file and put it in the list of all such.
753
754 END_ADDR is the address of the end of the file's text. */
755
756 struct symtab *
757 end_symtab (end_addr, sort_pending, sort_linevec, objfile)
758 CORE_ADDR end_addr;
759 int sort_pending;
760 int sort_linevec;
761 struct objfile *objfile;
762 {
763 register struct symtab *symtab;
764 register struct blockvector *blockvector;
765 register struct subfile *subfile;
766 struct subfile *nextsub;
767
768 /* Finish the lexical context of the last function in the file;
769 pop the context stack. */
770
771 if (context_stack_depth > 0)
772 {
773 register struct context_stack *cstk;
774 context_stack_depth--;
775 cstk = &context_stack[context_stack_depth];
776 /* Make a block for the local symbols within. */
777 finish_block (cstk->name, &local_symbols, cstk->old_blocks,
778 cstk->start_addr, end_addr, objfile);
779
780 /* Debug: if context stack still has something in it, we are in
781 trouble. */
782 if (context_stack_depth > 0)
783 abort ();
784 }
785
786 /* It is unfortunate that in aixcoff, pending blocks might not be ordered
787 in this stage. Especially, blocks for static functions will show up at
788 the end. We need to sort them, so tools like `find_pc_function' and
789 `find_pc_block' can work reliably. */
790 if (sort_pending && pending_blocks) {
791 /* FIXME! Remove this horrid bubble sort and use qsort!!! */
792 int swapped;
793 do {
794 struct pending_block *pb, *pbnext;
795
796 pb = pending_blocks, pbnext = pb->next;
797 swapped = 0;
798
799 while ( pbnext ) {
800
801 /* swap blocks if unordered! */
802
803 if (BLOCK_START(pb->block) < BLOCK_START(pbnext->block)) {
804 struct block *tmp = pb->block;
805 pb->block = pbnext->block;
806 pbnext->block = tmp;
807 swapped = 1;
808 }
809 pb = pbnext;
810 pbnext = pbnext->next;
811 }
812 } while (swapped);
813 }
814
815 /* Cleanup any undefined types that have been left hanging around
816 (this needs to be done before the finish_blocks so that
817 file_symbols is still good). */
818 cleanup_undefined_types ();
819
820 if (global_stabs) {
821 patch_block_stabs (global_symbols, global_stabs, objfile);
822 free ((PTR)global_stabs);
823 global_stabs = 0;
824 }
825
826 if (pending_blocks == 0
827 && file_symbols == 0
828 && global_symbols == 0) {
829 /* Ignore symtabs that have no functions with real debugging info */
830 blockvector = NULL;
831 } else {
832 /* Define the STATIC_BLOCK and GLOBAL_BLOCK, and build the blockvector. */
833 finish_block (0, &file_symbols, 0, last_source_start_addr, end_addr, objfile);
834 finish_block (0, &global_symbols, 0, last_source_start_addr, end_addr, objfile);
835 blockvector = make_blockvector (objfile);
836 }
837
838 #ifdef PROCESS_LINENUMBER_HOOK
839 PROCESS_LINENUMBER_HOOK (); /* Needed for aixcoff. */
840 #endif
841
842 /* Now create the symtab objects proper, one for each subfile. */
843 /* (The main file is the last one on the chain.) */
844
845 for (subfile = subfiles; subfile; subfile = nextsub)
846 {
847 int linetablesize;
848 /* If we have blocks of symbols, make a symtab.
849 Otherwise, just ignore this file and any line number info in it. */
850 symtab = 0;
851 if (blockvector) {
852 if (subfile->line_vector) {
853 /* First, shrink the linetable to make more memory. */
854 linetablesize = sizeof (struct linetable) +
855 subfile->line_vector->nitems * sizeof (struct linetable_entry);
856 subfile->line_vector = (struct linetable *)
857 xrealloc ((char *) subfile->line_vector, linetablesize);
858
859 if (sort_linevec)
860 qsort (subfile->line_vector->item, subfile->line_vector->nitems,
861 sizeof (struct linetable_entry), compare_line_numbers);
862 }
863
864 /* Now, allocate a symbol table. */
865 symtab = allocate_symtab (subfile->name, objfile);
866
867 /* Fill in its components. */
868 symtab->blockvector = blockvector;
869 if (subfile->line_vector)
870 {
871 /* Reallocate the line table on the symbol obstack */
872 symtab->linetable = (struct linetable *)
873 obstack_alloc (&objfile -> symbol_obstack, linetablesize);
874 memcpy (symtab->linetable, subfile->line_vector, linetablesize);
875 }
876 else
877 {
878 symtab->linetable = NULL;
879 }
880 symtab->dirname = subfile->dirname;
881 symtab->free_code = free_linetable;
882 symtab->free_ptr = 0;
883
884 #ifdef IBM6000_TARGET
885 /* In case we need to duplicate symbol tables (to represent include
886 files), and in case our system needs relocation, we want to
887 relocate the main symbol table node only (for the main file,
888 not for the include files). */
889
890 symtab->nonreloc = TRUE;
891 #endif
892 }
893 if (subfile->line_vector)
894 free ((PTR)subfile->line_vector);
895
896 nextsub = subfile->next;
897 free ((PTR)subfile);
898 }
899
900 #ifdef IBM6000_TARGET
901 /* all include symbol tables are non-relocatable, except the main source
902 file's. */
903 if (symtab)
904 symtab->nonreloc = FALSE;
905 #endif
906
907 if (type_vector)
908 free ((char *) type_vector);
909 type_vector = 0;
910 type_vector_length = 0;
911
912 last_source_file = 0;
913 current_subfile = 0;
914 previous_stab_code = 0;
915
916 return symtab;
917 }
918
919
920 /* Push a context block. Args are an identifying nesting level (checkable
921 when you pop it), and the starting PC address of this context. */
922
923 struct context_stack *
924 push_context (desc, valu)
925 int desc;
926 CORE_ADDR valu;
927 {
928 register struct context_stack *new;
929
930 if (context_stack_depth == context_stack_size)
931 {
932 context_stack_size *= 2;
933 context_stack = (struct context_stack *)
934 xrealloc ((char *) context_stack,
935 (context_stack_size * sizeof (struct context_stack)));
936 }
937
938 new = &context_stack[context_stack_depth++];
939 new->depth = desc;
940 new->locals = local_symbols;
941 new->old_blocks = pending_blocks;
942 new->start_addr = valu;
943 new->name = 0;
944
945 local_symbols = 0;
946
947 return new;
948 }
949 \f
950 /* Initialize anything that needs initializing when starting to read
951 a fresh piece of a symbol file, e.g. reading in the stuff corresponding
952 to a psymtab. */
953
954 void
955 buildsym_init ()
956 {
957 free_pendings = 0;
958 file_symbols = 0;
959 global_symbols = 0;
960 pending_blocks = 0;
961 }
962
963 /* Initialize anything that needs initializing when a completely new
964 symbol file is specified (not just adding some symbols from another
965 file, e.g. a shared library). */
966
967 void
968 buildsym_new_init ()
969 {
970 /* Empty the hash table of global syms looking for values. */
971 bzero (global_sym_chain, sizeof global_sym_chain);
972
973 buildsym_init ();
974 }
975
976 /* Scan through all of the global symbols defined in the object file,
977 assigning values to the debugging symbols that need to be assigned
978 to. Get these symbols from the minimal symbol table. */
979
980 void
981 scan_file_globals (objfile)
982 struct objfile *objfile;
983 {
984 int hash;
985 struct minimal_symbol *msymbol;
986 struct symbol *sym, *prev;
987
988 for (msymbol = objfile -> msymbols; msymbol -> name != NULL; msymbol++)
989 {
990 QUIT;
991
992 prev = (struct symbol *) 0;
993
994 /* Get the hash index and check all the symbols
995 under that hash index. */
996
997 hash = hashname (msymbol -> name);
998
999 for (sym = global_sym_chain[hash]; sym;)
1000 {
1001 if (*(msymbol -> name) == SYMBOL_NAME (sym)[0]
1002 && !strcmp(msymbol -> name + 1, SYMBOL_NAME (sym) + 1))
1003 {
1004 /* Splice this symbol out of the hash chain and
1005 assign the value we have to it. */
1006 if (prev)
1007 SYMBOL_VALUE_CHAIN (prev) = SYMBOL_VALUE_CHAIN (sym);
1008 else
1009 global_sym_chain[hash] = SYMBOL_VALUE_CHAIN (sym);
1010
1011 /* Check to see whether we need to fix up a common block. */
1012 /* Note: this code might be executed several times for
1013 the same symbol if there are multiple references. */
1014 if (SYMBOL_CLASS (sym) == LOC_BLOCK)
1015 fix_common_block (sym, msymbol -> address);
1016 else
1017 SYMBOL_VALUE_ADDRESS (sym) = msymbol -> address;
1018
1019 if (prev)
1020 sym = SYMBOL_VALUE_CHAIN (prev);
1021 else
1022 sym = global_sym_chain[hash];
1023 }
1024 else
1025 {
1026 prev = sym;
1027 sym = SYMBOL_VALUE_CHAIN (sym);
1028 }
1029 }
1030 }
1031 }
1032
1033 \f
1034 /* Read a number by which a type is referred to in dbx data,
1035 or perhaps read a pair (FILENUM, TYPENUM) in parentheses.
1036 Just a single number N is equivalent to (0,N).
1037 Return the two numbers by storing them in the vector TYPENUMS.
1038 TYPENUMS will then be used as an argument to dbx_lookup_type. */
1039
1040 void
1041 read_type_number (pp, typenums)
1042 register char **pp;
1043 register int *typenums;
1044 {
1045 if (**pp == '(')
1046 {
1047 (*pp)++;
1048 typenums[0] = read_number (pp, ',');
1049 typenums[1] = read_number (pp, ')');
1050 }
1051 else
1052 {
1053 typenums[0] = 0;
1054 typenums[1] = read_number (pp, 0);
1055 }
1056 }
1057 \f
1058 /* To handle GNU C++ typename abbreviation, we need to be able to
1059 fill in a type's name as soon as space for that type is allocated.
1060 `type_synonym_name' is the name of the type being allocated.
1061 It is cleared as soon as it is used (lest all allocated types
1062 get this name). */
1063 static char *type_synonym_name;
1064
1065 /* ARGSUSED */
1066 struct symbol *
1067 define_symbol (valu, string, desc, type, objfile)
1068 unsigned int valu;
1069 char *string;
1070 int desc;
1071 int type;
1072 struct objfile *objfile;
1073 {
1074 register struct symbol *sym;
1075 char *p = (char *) strchr (string, ':');
1076 int deftype;
1077 int synonym = 0;
1078 register int i;
1079 struct type *temptype;
1080
1081 #ifdef IBM6000_TARGET
1082 /* We would like to eliminate nameless symbols, but keep their types.
1083 E.g. stab entry ":t10=*2" should produce a type 10, which is a pointer
1084 to type 2, but, should not creat a symbol to address that type. Since
1085 the symbol will be nameless, there is no way any user can refer to it. */
1086
1087 int nameless;
1088 #endif
1089
1090 /* Ignore syms with empty names. */
1091 if (string[0] == 0)
1092 return 0;
1093
1094 /* Ignore old-style symbols from cc -go */
1095 if (p == 0)
1096 return 0;
1097
1098 #ifdef IBM6000_TARGET
1099 /* If a nameless stab entry, all we need is the type, not the symbol.
1100 e.g. ":t10=*2" */
1101 nameless = (p == string);
1102 #endif
1103
1104 sym = (struct symbol *)obstack_alloc (&objfile -> symbol_obstack, sizeof (struct symbol));
1105
1106 if (processing_gcc_compilation) {
1107 /* GCC 2.x puts the line number in desc. SunOS apparently puts in the
1108 number of bytes occupied by a type or object, which we ignore. */
1109 SYMBOL_LINE(sym) = desc;
1110 } else {
1111 SYMBOL_LINE(sym) = 0; /* unknown */
1112 }
1113
1114 if (string[0] == CPLUS_MARKER)
1115 {
1116 /* Special GNU C++ names. */
1117 switch (string[1])
1118 {
1119 case 't':
1120 SYMBOL_NAME (sym) = obsavestring ("this", strlen ("this"),
1121 &objfile -> symbol_obstack);
1122 break;
1123 case 'v': /* $vtbl_ptr_type */
1124 /* Was: SYMBOL_NAME (sym) = "vptr"; */
1125 goto normal;
1126 case 'e':
1127 SYMBOL_NAME (sym) = obsavestring ("eh_throw", strlen ("eh_throw"),
1128 &objfile -> symbol_obstack);
1129 break;
1130
1131 case '_':
1132 /* This was an anonymous type that was never fixed up. */
1133 goto normal;
1134
1135 default:
1136 abort ();
1137 }
1138 }
1139 else
1140 {
1141 normal:
1142 SYMBOL_NAME (sym)
1143 = (char *) obstack_alloc (&objfile -> symbol_obstack, ((p - string) + 1));
1144 /* Open-coded bcopy--saves function call time. */
1145 {
1146 register char *p1 = string;
1147 register char *p2 = SYMBOL_NAME (sym);
1148 while (p1 != p)
1149 *p2++ = *p1++;
1150 *p2++ = '\0';
1151 }
1152 }
1153 p++;
1154 /* Determine the type of name being defined. */
1155 /* The Acorn RISC machine's compiler can put out locals that don't
1156 start with "234=" or "(3,4)=", so assume anything other than the
1157 deftypes we know how to handle is a local. */
1158 /* (Peter Watkins @ Computervision)
1159 Handle Sun-style local fortran array types 'ar...' .
1160 (gnu@cygnus.com) -- this strchr() handles them properly?
1161 (tiemann@cygnus.com) -- 'C' is for catch. */
1162
1163 #ifdef IBM6000_TARGET
1164
1165 /* 'R' is for register parameters. */
1166
1167 if (!strchr ("cfFGpPrStTvVXCR", *p))
1168 #else
1169
1170 if (!strchr ("cfFGpPrStTvVXC", *p))
1171 #endif
1172 deftype = 'l';
1173 else
1174 deftype = *p++;
1175
1176 /* c is a special case, not followed by a type-number.
1177 SYMBOL:c=iVALUE for an integer constant symbol.
1178 SYMBOL:c=rVALUE for a floating constant symbol.
1179 SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol.
1180 e.g. "b:c=e6,0" for "const b = blob1"
1181 (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
1182 if (deftype == 'c')
1183 {
1184 if (*p++ != '=')
1185 error ("Invalid symbol data at symtab pos %d.", symnum);
1186 switch (*p++)
1187 {
1188 case 'r':
1189 {
1190 double d = atof (p);
1191 char *dbl_valu;
1192
1193 SYMBOL_TYPE (sym) = lookup_fundamental_type (objfile,
1194 FT_DBL_PREC_FLOAT);
1195 dbl_valu = (char *)
1196 obstack_alloc (&objfile -> type_obstack,
1197 sizeof (double));
1198 memcpy (dbl_valu, &d, sizeof (double));
1199 SWAP_TARGET_AND_HOST (dbl_valu, sizeof (double));
1200 SYMBOL_VALUE_BYTES (sym) = dbl_valu;
1201 SYMBOL_CLASS (sym) = LOC_CONST_BYTES;
1202 }
1203 break;
1204 case 'i':
1205 {
1206 SYMBOL_TYPE (sym) = lookup_fundamental_type (objfile,
1207 FT_INTEGER);
1208 SYMBOL_VALUE (sym) = atoi (p);
1209 SYMBOL_CLASS (sym) = LOC_CONST;
1210 }
1211 break;
1212 case 'e':
1213 /* SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol.
1214 e.g. "b:c=e6,0" for "const b = blob1"
1215 (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
1216 {
1217 int typenums[2];
1218
1219 read_type_number (&p, typenums);
1220 if (*p++ != ',')
1221 error ("Invalid symbol data: no comma in enum const symbol");
1222
1223 SYMBOL_TYPE (sym) = *dbx_lookup_type (typenums);
1224 SYMBOL_VALUE (sym) = atoi (p);
1225 SYMBOL_CLASS (sym) = LOC_CONST;
1226 }
1227 break;
1228 default:
1229 error ("Invalid symbol data at symtab pos %d.", symnum);
1230 }
1231 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1232 add_symbol_to_list (sym, &file_symbols);
1233 return sym;
1234 }
1235
1236 /* Now usually comes a number that says which data type,
1237 and possibly more stuff to define the type
1238 (all of which is handled by read_type) */
1239
1240 if (deftype == 'p' && *p == 'F')
1241 /* pF is a two-letter code that means a function parameter in Fortran.
1242 The type-number specifies the type of the return value.
1243 Translate it into a pointer-to-function type. */
1244 {
1245 p++;
1246 SYMBOL_TYPE (sym)
1247 = lookup_pointer_type (lookup_function_type (read_type (&p, objfile)));
1248 }
1249
1250 #ifdef IBM6000_TARGET
1251 else if (deftype == 'R')
1252 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1253 #endif
1254
1255 else
1256 {
1257 struct type *type_read;
1258 synonym = *p == 't';
1259
1260 if (synonym)
1261 {
1262 p += 1;
1263 type_synonym_name = obsavestring (SYMBOL_NAME (sym),
1264 strlen (SYMBOL_NAME (sym)),
1265 &objfile -> symbol_obstack);
1266 }
1267
1268 /* Here we save the name of the symbol for read_range_type, which
1269 ends up reading in the basic types. In stabs, unfortunately there
1270 is no distinction between "int" and "long" types except their
1271 names. Until we work out a saner type policy (eliminating most
1272 builtin types and using the names specified in the files), we
1273 save away the name so that far away from here in read_range_type,
1274 we can examine it to decide between "int" and "long". FIXME. */
1275 long_kludge_name = SYMBOL_NAME (sym);
1276
1277 type_read = read_type (&p, objfile);
1278
1279 if ((deftype == 'F' || deftype == 'f') && *p == ';') {
1280 /* Sun acc puts declared types of aguments here. We don't care
1281 about their actual types (FIXME -- we should remember the whole
1282 function prototype), but the list
1283 may define some new types that we have to remember, so we must
1284 scan them now. */
1285 while (*p == ';') {
1286 p++;
1287 read_type (&p, objfile);
1288 }
1289 }
1290
1291 if ((deftype == 'F' || deftype == 'f')
1292 && TYPE_CODE (type_read) != TYPE_CODE_FUNC)
1293 {
1294 #if 0
1295 /* This code doesn't work -- it needs to realloc and can't. */
1296 /* Attempt to set up to record a function prototype... */
1297 struct type *new = (struct type *)
1298 obstack_alloc (&objfile -> type_obstack,
1299 sizeof (struct type));
1300
1301 /* Generate a template for the type of this function. The
1302 types of the arguments will be added as we read the symbol
1303 table. */
1304 *new = *lookup_function_type (type_read);
1305 SYMBOL_TYPE(sym) = new;
1306 TYPE_OBJFILE (new) = objfile;
1307 in_function_type = new;
1308 #else
1309 SYMBOL_TYPE (sym) = lookup_function_type (type_read);
1310 #endif
1311 }
1312 else
1313 SYMBOL_TYPE (sym) = type_read;
1314 }
1315
1316 switch (deftype)
1317 {
1318 case 'C':
1319 /* The name of a caught exception. */
1320 SYMBOL_CLASS (sym) = LOC_LABEL;
1321 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1322 SYMBOL_VALUE_ADDRESS (sym) = valu;
1323 add_symbol_to_list (sym, &local_symbols);
1324 break;
1325
1326 case 'f':
1327 SYMBOL_CLASS (sym) = LOC_BLOCK;
1328 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1329 add_symbol_to_list (sym, &file_symbols);
1330 break;
1331
1332 case 'F':
1333 SYMBOL_CLASS (sym) = LOC_BLOCK;
1334 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1335 add_symbol_to_list (sym, &global_symbols);
1336 break;
1337
1338 case 'G':
1339 /* For a class G (global) symbol, it appears that the
1340 value is not correct. It is necessary to search for the
1341 corresponding linker definition to find the value.
1342 These definitions appear at the end of the namelist. */
1343 i = hashname (SYMBOL_NAME (sym));
1344 SYMBOL_VALUE_CHAIN (sym) = global_sym_chain[i];
1345 global_sym_chain[i] = sym;
1346 SYMBOL_CLASS (sym) = LOC_STATIC;
1347 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1348 add_symbol_to_list (sym, &global_symbols);
1349 break;
1350
1351 /* This case is faked by a conditional above,
1352 when there is no code letter in the dbx data.
1353 Dbx data never actually contains 'l'. */
1354 case 'l':
1355 SYMBOL_CLASS (sym) = LOC_LOCAL;
1356 SYMBOL_VALUE (sym) = valu;
1357 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1358 add_symbol_to_list (sym, &local_symbols);
1359 break;
1360
1361 case 'p':
1362 /* Normally this is a parameter, a LOC_ARG. On the i960, it
1363 can also be a LOC_LOCAL_ARG depending on symbol type. */
1364 #ifndef DBX_PARM_SYMBOL_CLASS
1365 #define DBX_PARM_SYMBOL_CLASS(type) LOC_ARG
1366 #endif
1367 SYMBOL_CLASS (sym) = DBX_PARM_SYMBOL_CLASS (type);
1368 SYMBOL_VALUE (sym) = valu;
1369 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1370 #if 0
1371 /* This doesn't work yet. */
1372 add_param_to_type (&in_function_type, sym);
1373 #endif
1374 add_symbol_to_list (sym, &local_symbols);
1375
1376 /* If it's gcc-compiled, if it says `short', believe it. */
1377 if (processing_gcc_compilation || BELIEVE_PCC_PROMOTION)
1378 break;
1379
1380 #if defined(BELIEVE_PCC_PROMOTION_TYPE)
1381 /* This macro is defined on machines (e.g. sparc) where
1382 we should believe the type of a PCC 'short' argument,
1383 but shouldn't believe the address (the address is
1384 the address of the corresponding int). Note that
1385 this is only different from the BELIEVE_PCC_PROMOTION
1386 case on big-endian machines.
1387
1388 My guess is that this correction, as opposed to changing
1389 the parameter to an 'int' (as done below, for PCC
1390 on most machines), is the right thing to do
1391 on all machines, but I don't want to risk breaking
1392 something that already works. On most PCC machines,
1393 the sparc problem doesn't come up because the calling
1394 function has to zero the top bytes (not knowing whether
1395 the called function wants an int or a short), so there
1396 is no practical difference between an int and a short
1397 (except perhaps what happens when the GDB user types
1398 "print short_arg = 0x10000;").
1399
1400 Hacked for SunOS 4.1 by gnu@cygnus.com. In 4.1, the compiler
1401 actually produces the correct address (we don't need to fix it
1402 up). I made this code adapt so that it will offset the symbol
1403 if it was pointing at an int-aligned location and not
1404 otherwise. This way you can use the same gdb for 4.0.x and
1405 4.1 systems.
1406
1407 If the parameter is shorter than an int, and is integral
1408 (e.g. char, short, or unsigned equivalent), and is claimed to
1409 be passed on an integer boundary, don't believe it! Offset the
1410 parameter's address to the tail-end of that integer. */
1411
1412 temptype = lookup_fundamental_type (objfile, FT_INTEGER);
1413 if (TYPE_LENGTH (SYMBOL_TYPE (sym)) < TYPE_LENGTH (temptype)
1414 && TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_INT
1415 && 0 == SYMBOL_VALUE (sym) % TYPE_LENGTH (temptype))
1416 {
1417 SYMBOL_VALUE (sym) += TYPE_LENGTH (temptype)
1418 - TYPE_LENGTH (SYMBOL_TYPE (sym));
1419 }
1420 break;
1421
1422 #else /* no BELIEVE_PCC_PROMOTION_TYPE. */
1423
1424 /* If PCC says a parameter is a short or a char,
1425 it is really an int. */
1426 temptype = lookup_fundamental_type (objfile, FT_INTEGER);
1427 if (TYPE_LENGTH (SYMBOL_TYPE (sym)) < TYPE_LENGTH (temptype)
1428 && TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_INT)
1429 {
1430 SYMBOL_TYPE (sym) = TYPE_UNSIGNED (SYMBOL_TYPE (sym))
1431 ? lookup_fundamental_type (objfile, FT_UNSIGNED_INTEGER)
1432 : temptype;
1433 }
1434 break;
1435
1436 #endif /* no BELIEVE_PCC_PROMOTION_TYPE. */
1437
1438 case 'P':
1439 /* Parameter which is in a register. */
1440
1441 /* acc seems to use P to delare the types of functions that
1442 are called by this file. gdb is not prepared to deal
1443 with this extra information. */
1444 if (processing_acc_compilation)
1445 break;
1446
1447 SYMBOL_CLASS (sym) = LOC_REGPARM;
1448 SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
1449 if (SYMBOL_VALUE (sym) >= NUM_REGS)
1450 {
1451 complain (&reg_value_complaint, SYMBOL_NAME (sym));
1452 SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */
1453 }
1454 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1455 add_symbol_to_list (sym, &local_symbols);
1456 break;
1457
1458 #ifdef IBM6000_TARGET
1459 case 'R':
1460 #endif
1461 case 'r':
1462 /* Register variable (either global or local). */
1463 SYMBOL_CLASS (sym) = LOC_REGISTER;
1464 SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
1465 if (SYMBOL_VALUE (sym) >= NUM_REGS)
1466 {
1467 complain (&reg_value_complaint, SYMBOL_NAME (sym));
1468 SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */
1469 }
1470 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1471 if (within_function)
1472 add_symbol_to_list (sym, &local_symbols);
1473 else
1474 add_symbol_to_list (sym, &file_symbols);
1475 break;
1476
1477 case 'S':
1478 /* Static symbol at top level of file */
1479 SYMBOL_CLASS (sym) = LOC_STATIC;
1480 SYMBOL_VALUE_ADDRESS (sym) = valu;
1481 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1482 add_symbol_to_list (sym, &file_symbols);
1483 break;
1484
1485 case 't':
1486 #ifdef IBM6000_TARGET
1487 /* For a nameless type, we don't want a create a symbol, thus we
1488 did not use `sym'. Return without further processing. */
1489
1490 if (nameless) return NULL;
1491 #endif
1492 SYMBOL_CLASS (sym) = LOC_TYPEDEF;
1493 SYMBOL_VALUE (sym) = valu;
1494 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1495 /* C++ vagaries: we may have a type which is derived from
1496 a base type which did not have its name defined when the
1497 derived class was output. We fill in the derived class's
1498 base part member's name here in that case. */
1499 if (TYPE_NAME (SYMBOL_TYPE (sym)) != NULL)
1500 if ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
1501 || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION)
1502 && TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)))
1503 {
1504 int j;
1505 for (j = TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)) - 1; j >= 0; j--)
1506 if (TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) == 0)
1507 TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) =
1508 type_name_no_tag (TYPE_BASECLASS (SYMBOL_TYPE (sym), j));
1509 }
1510
1511 add_symbol_to_list (sym, &file_symbols);
1512 break;
1513
1514 case 'T':
1515 SYMBOL_CLASS (sym) = LOC_TYPEDEF;
1516 SYMBOL_VALUE (sym) = valu;
1517 SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE;
1518 if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)
1519 TYPE_NAME (SYMBOL_TYPE (sym))
1520 = obconcat (&objfile -> type_obstack, "",
1521 (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_ENUM
1522 ? "enum "
1523 : (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
1524 ? "struct " : "union ")),
1525 SYMBOL_NAME (sym));
1526 add_symbol_to_list (sym, &file_symbols);
1527
1528 if (synonym)
1529 {
1530 register struct symbol *typedef_sym = (struct symbol *)
1531 obstack_alloc (&objfile -> type_obstack,
1532 sizeof (struct symbol));
1533 SYMBOL_NAME (typedef_sym) = SYMBOL_NAME (sym);
1534 SYMBOL_TYPE (typedef_sym) = SYMBOL_TYPE (sym);
1535
1536 SYMBOL_CLASS (typedef_sym) = LOC_TYPEDEF;
1537 SYMBOL_VALUE (typedef_sym) = valu;
1538 SYMBOL_NAMESPACE (typedef_sym) = VAR_NAMESPACE;
1539 add_symbol_to_list (typedef_sym, &file_symbols);
1540 }
1541 break;
1542
1543 case 'V':
1544 /* Static symbol of local scope */
1545 SYMBOL_CLASS (sym) = LOC_STATIC;
1546 SYMBOL_VALUE_ADDRESS (sym) = valu;
1547 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1548 add_symbol_to_list (sym, &local_symbols);
1549 break;
1550
1551 case 'v':
1552 /* Reference parameter */
1553 SYMBOL_CLASS (sym) = LOC_REF_ARG;
1554 SYMBOL_VALUE (sym) = valu;
1555 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1556 add_symbol_to_list (sym, &local_symbols);
1557 break;
1558
1559 case 'X':
1560 /* This is used by Sun FORTRAN for "function result value".
1561 Sun claims ("dbx and dbxtool interfaces", 2nd ed)
1562 that Pascal uses it too, but when I tried it Pascal used
1563 "x:3" (local symbol) instead. */
1564 SYMBOL_CLASS (sym) = LOC_LOCAL;
1565 SYMBOL_VALUE (sym) = valu;
1566 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1567 add_symbol_to_list (sym, &local_symbols);
1568 break;
1569
1570 default:
1571 error ("Invalid symbol data: unknown symbol-type code `%c' at symtab pos %d.", deftype, symnum);
1572 }
1573 return sym;
1574 }
1575 \f
1576 /* What about types defined as forward references inside of a small lexical
1577 scope? */
1578 /* Add a type to the list of undefined types to be checked through
1579 once this file has been read in. */
1580 void
1581 add_undefined_type (type)
1582 struct type *type;
1583 {
1584 if (undef_types_length == undef_types_allocated)
1585 {
1586 undef_types_allocated *= 2;
1587 undef_types = (struct type **)
1588 xrealloc ((char *) undef_types,
1589 undef_types_allocated * sizeof (struct type *));
1590 }
1591 undef_types[undef_types_length++] = type;
1592 }
1593
1594 /* Go through each undefined type, see if it's still undefined, and fix it
1595 up if possible. We have two kinds of undefined types:
1596
1597 TYPE_CODE_ARRAY: Array whose target type wasn't defined yet.
1598 Fix: update array length using the element bounds
1599 and the target type's length.
1600 TYPE_CODE_STRUCT, TYPE_CODE_UNION: Structure whose fields were not
1601 yet defined at the time a pointer to it was made.
1602 Fix: Do a full lookup on the struct/union tag. */
1603 static void
1604 cleanup_undefined_types ()
1605 {
1606 struct type **type;
1607
1608 for (type = undef_types; type < undef_types + undef_types_length; type++) {
1609 switch (TYPE_CODE (*type)) {
1610
1611 case TYPE_CODE_STRUCT:
1612 case TYPE_CODE_UNION:
1613 case TYPE_CODE_ENUM:
1614 {
1615 /* Reasonable test to see if it's been defined since. */
1616 if (TYPE_NFIELDS (*type) == 0)
1617 {
1618 struct pending *ppt;
1619 int i;
1620 /* Name of the type, without "struct" or "union" */
1621 char *typename = TYPE_NAME (*type);
1622
1623 if (!strncmp (typename, "struct ", 7))
1624 typename += 7;
1625 if (!strncmp (typename, "union ", 6))
1626 typename += 6;
1627 if (!strncmp (typename, "enum ", 5))
1628 typename += 5;
1629
1630 for (ppt = file_symbols; ppt; ppt = ppt->next)
1631 for (i = 0; i < ppt->nsyms; i++)
1632 {
1633 struct symbol *sym = ppt->symbol[i];
1634
1635 if (SYMBOL_CLASS (sym) == LOC_TYPEDEF
1636 && SYMBOL_NAMESPACE (sym) == STRUCT_NAMESPACE
1637 && (TYPE_CODE (SYMBOL_TYPE (sym)) ==
1638 TYPE_CODE (*type))
1639 && !strcmp (SYMBOL_NAME (sym), typename))
1640 memcpy (*type, SYMBOL_TYPE (sym), sizeof (struct type));
1641 }
1642 }
1643 else
1644 /* It has been defined; don't mark it as a stub. */
1645 TYPE_FLAGS (*type) &= ~TYPE_FLAG_STUB;
1646 }
1647 break;
1648
1649 case TYPE_CODE_ARRAY:
1650 {
1651 struct type *range_type;
1652 int lower, upper;
1653
1654 if (TYPE_LENGTH (*type) != 0) /* Better be unknown */
1655 goto badtype;
1656 if (TYPE_NFIELDS (*type) != 1)
1657 goto badtype;
1658 range_type = TYPE_FIELD_TYPE (*type, 0);
1659 if (TYPE_CODE (range_type) != TYPE_CODE_RANGE)
1660 goto badtype;
1661
1662 /* Now recompute the length of the array type, based on its
1663 number of elements and the target type's length. */
1664 lower = TYPE_FIELD_BITPOS (range_type, 0);
1665 upper = TYPE_FIELD_BITPOS (range_type, 1);
1666 TYPE_LENGTH (*type) = (upper - lower + 1)
1667 * TYPE_LENGTH (TYPE_TARGET_TYPE (*type));
1668 }
1669 break;
1670
1671 default:
1672 badtype:
1673 error ("GDB internal error. cleanup_undefined_types with bad\
1674 type %d.", TYPE_CODE (*type));
1675 break;
1676 }
1677 }
1678 undef_types_length = 0;
1679 }
1680 \f
1681 /* Skip rest of this symbol and return an error type.
1682
1683 General notes on error recovery: error_type always skips to the
1684 end of the symbol (modulo cretinous dbx symbol name continuation).
1685 Thus code like this:
1686
1687 if (*(*pp)++ != ';')
1688 return error_type (pp);
1689
1690 is wrong because if *pp starts out pointing at '\0' (typically as the
1691 result of an earlier error), it will be incremented to point to the
1692 start of the next symbol, which might produce strange results, at least
1693 if you run off the end of the string table. Instead use
1694
1695 if (**pp != ';')
1696 return error_type (pp);
1697 ++*pp;
1698
1699 or
1700
1701 if (**pp != ';')
1702 foo = error_type (pp);
1703 else
1704 ++*pp;
1705
1706 And in case it isn't obvious, the point of all this hair is so the compiler
1707 can define new types and new syntaxes, and old versions of the
1708 debugger will be able to read the new symbol tables. */
1709
1710 struct type *
1711 error_type (pp)
1712 char **pp;
1713 {
1714 complain (&error_type_complaint, 0);
1715 while (1)
1716 {
1717 /* Skip to end of symbol. */
1718 while (**pp != '\0')
1719 (*pp)++;
1720
1721 /* Check for and handle cretinous dbx symbol name continuation! */
1722 if ((*pp)[-1] == '\\')
1723 *pp = next_symbol_text ();
1724 else
1725 break;
1726 }
1727 return builtin_type_error;
1728 }
1729 \f
1730 /* Read a dbx type reference or definition;
1731 return the type that is meant.
1732 This can be just a number, in which case it references
1733 a type already defined and placed in type_vector.
1734 Or the number can be followed by an =, in which case
1735 it means to define a new type according to the text that
1736 follows the =. */
1737
1738 struct type *
1739 read_type (pp, objfile)
1740 register char **pp;
1741 struct objfile *objfile;
1742 {
1743 register struct type *type = 0;
1744 struct type *type1;
1745 int typenums[2];
1746 int xtypenums[2];
1747
1748 /* Read type number if present. The type number may be omitted.
1749 for instance in a two-dimensional array declared with type
1750 "ar1;1;10;ar1;1;10;4". */
1751 if ((**pp >= '0' && **pp <= '9')
1752 || **pp == '(')
1753 {
1754 read_type_number (pp, typenums);
1755
1756 /* Type is not being defined here. Either it already exists,
1757 or this is a forward reference to it. dbx_alloc_type handles
1758 both cases. */
1759 if (**pp != '=')
1760 return dbx_alloc_type (typenums, objfile);
1761
1762 /* Type is being defined here. */
1763 #if 0 /* Callers aren't prepared for a NULL result! FIXME -- metin! */
1764 {
1765 struct type *tt;
1766
1767 /* if such a type already exists, this is an unnecessary duplication
1768 of the stab string, which is common in (RS/6000) xlc generated
1769 objects. In that case, simply return NULL and let the caller take
1770 care of it. */
1771
1772 tt = *dbx_lookup_type (typenums);
1773 if (tt && tt->length && tt->code)
1774 return NULL;
1775 }
1776 #endif
1777
1778 *pp += 2;
1779 }
1780 else
1781 {
1782 /* 'typenums=' not present, type is anonymous. Read and return
1783 the definition, but don't put it in the type vector. */
1784 typenums[0] = typenums[1] = -1;
1785 *pp += 1;
1786 }
1787
1788 switch ((*pp)[-1])
1789 {
1790 case 'x':
1791 {
1792 enum type_code code;
1793
1794 /* Used to index through file_symbols. */
1795 struct pending *ppt;
1796 int i;
1797
1798 /* Name including "struct", etc. */
1799 char *type_name;
1800
1801 /* Name without "struct", etc. */
1802 char *type_name_only;
1803
1804 {
1805 char *prefix;
1806 char *from, *to;
1807
1808 /* Set the type code according to the following letter. */
1809 switch ((*pp)[0])
1810 {
1811 case 's':
1812 code = TYPE_CODE_STRUCT;
1813 prefix = "struct ";
1814 break;
1815 case 'u':
1816 code = TYPE_CODE_UNION;
1817 prefix = "union ";
1818 break;
1819 case 'e':
1820 code = TYPE_CODE_ENUM;
1821 prefix = "enum ";
1822 break;
1823 default:
1824 return error_type (pp);
1825 }
1826
1827 to = type_name = (char *)
1828 obstack_alloc (&objfile -> type_obstack,
1829 (strlen (prefix) +
1830 ((char *) strchr (*pp, ':') - (*pp)) + 1));
1831
1832 /* Copy the prefix. */
1833 from = prefix;
1834 while (*to++ = *from++)
1835 ;
1836 to--;
1837
1838 type_name_only = to;
1839
1840 /* Copy the name. */
1841 from = *pp + 1;
1842 while ((*to++ = *from++) != ':')
1843 ;
1844 *--to = '\0';
1845
1846 /* Set the pointer ahead of the name which we just read. */
1847 *pp = from;
1848
1849 #if 0
1850 /* The following hack is clearly wrong, because it doesn't
1851 check whether we are in a baseclass. I tried to reproduce
1852 the case that it is trying to fix, but I couldn't get
1853 g++ to put out a cross reference to a basetype. Perhaps
1854 it doesn't do it anymore. */
1855 /* Note: for C++, the cross reference may be to a base type which
1856 has not yet been seen. In this case, we skip to the comma,
1857 which will mark the end of the base class name. (The ':'
1858 at the end of the base class name will be skipped as well.)
1859 But sometimes (ie. when the cross ref is the last thing on
1860 the line) there will be no ','. */
1861 from = (char *) strchr (*pp, ',');
1862 if (from)
1863 *pp = from;
1864 #endif /* 0 */
1865 }
1866
1867 /* Now check to see whether the type has already been declared. */
1868 /* This is necessary at least in the case where the
1869 program says something like
1870 struct foo bar[5];
1871 The compiler puts out a cross-reference; we better find
1872 set the length of the structure correctly so we can
1873 set the length of the array. */
1874 for (ppt = file_symbols; ppt; ppt = ppt->next)
1875 for (i = 0; i < ppt->nsyms; i++)
1876 {
1877 struct symbol *sym = ppt->symbol[i];
1878
1879 if (SYMBOL_CLASS (sym) == LOC_TYPEDEF
1880 && SYMBOL_NAMESPACE (sym) == STRUCT_NAMESPACE
1881 && (TYPE_CODE (SYMBOL_TYPE (sym)) == code)
1882 && !strcmp (SYMBOL_NAME (sym), type_name_only))
1883 {
1884 obstack_free (&objfile -> type_obstack, type_name);
1885 type = SYMBOL_TYPE (sym);
1886 return type;
1887 }
1888 }
1889
1890 /* Didn't find the type to which this refers, so we must
1891 be dealing with a forward reference. Allocate a type
1892 structure for it, and keep track of it so we can
1893 fill in the rest of the fields when we get the full
1894 type. */
1895 type = dbx_alloc_type (typenums, objfile);
1896 TYPE_CODE (type) = code;
1897 TYPE_NAME (type) = type_name;
1898 INIT_CPLUS_SPECIFIC(type);
1899 TYPE_FLAGS (type) |= TYPE_FLAG_STUB;
1900
1901 add_undefined_type (type);
1902 return type;
1903 }
1904
1905 case '-': /* RS/6000 built-in type */
1906 (*pp)--;
1907 type = builtin_type (pp); /* (in xcoffread.c) */
1908 goto after_digits;
1909
1910 case '0':
1911 case '1':
1912 case '2':
1913 case '3':
1914 case '4':
1915 case '5':
1916 case '6':
1917 case '7':
1918 case '8':
1919 case '9':
1920 case '(':
1921 (*pp)--;
1922 read_type_number (pp, xtypenums);
1923 type = *dbx_lookup_type (xtypenums);
1924 /* fall through */
1925
1926 after_digits:
1927 if (type == 0)
1928 type = lookup_fundamental_type (objfile, FT_VOID);
1929 if (typenums[0] != -1)
1930 *dbx_lookup_type (typenums) = type;
1931 break;
1932
1933 /* In the following types, we must be sure to overwrite any existing
1934 type that the typenums refer to, rather than allocating a new one
1935 and making the typenums point to the new one. This is because there
1936 may already be pointers to the existing type (if it had been
1937 forward-referenced), and we must change it to a pointer, function,
1938 reference, or whatever, *in-place*. */
1939
1940 case '*':
1941 type1 = read_type (pp, objfile);
1942 type = make_pointer_type (type1, dbx_lookup_type (typenums));
1943 break;
1944
1945 case '&': /* Reference to another type */
1946 type1 = read_type (pp, objfile);
1947 type = make_reference_type (type1, dbx_lookup_type (typenums));
1948 break;
1949
1950 case 'f': /* Function returning another type */
1951 type1 = read_type (pp, objfile);
1952 type = make_function_type (type1, dbx_lookup_type (typenums));
1953 break;
1954
1955 /* FIXME -- we should be doing smash_to_XXX types here. */
1956 case '@': /* Member (class & variable) type */
1957 {
1958 struct type *domain = read_type (pp, objfile);
1959 struct type *memtype;
1960
1961 if (**pp != ',')
1962 /* Invalid member type data format. */
1963 return error_type (pp);
1964 ++*pp;
1965
1966 memtype = read_type (pp, objfile);
1967 type = dbx_alloc_type (typenums, objfile);
1968 smash_to_member_type (type, domain, memtype);
1969 }
1970 break;
1971
1972 case '#': /* Method (class & fn) type */
1973 if ((*pp)[0] == '#')
1974 {
1975 /* We'll get the parameter types from the name. */
1976 struct type *return_type;
1977
1978 *pp += 1;
1979 return_type = read_type (pp, objfile);
1980 if (*(*pp)++ != ';')
1981 complain (&invalid_member_complaint, (char *) symnum);
1982 type = allocate_stub_method (return_type);
1983 if (typenums[0] != -1)
1984 *dbx_lookup_type (typenums) = type;
1985 }
1986 else
1987 {
1988 struct type *domain = read_type (pp, objfile);
1989 struct type *return_type;
1990 struct type **args;
1991
1992 if (*(*pp)++ != ',')
1993 error ("invalid member type data format, at symtab pos %d.",
1994 symnum);
1995
1996 return_type = read_type (pp, objfile);
1997 args = read_args (pp, ';', objfile);
1998 type = dbx_alloc_type (typenums, objfile);
1999 smash_to_method_type (type, domain, return_type, args);
2000 }
2001 break;
2002
2003 case 'r': /* Range type */
2004 type = read_range_type (pp, typenums, objfile);
2005 if (typenums[0] != -1)
2006 *dbx_lookup_type (typenums) = type;
2007 break;
2008
2009 case 'b': /* Sun ACC builtin int type */
2010 type = read_sun_builtin_type (pp, typenums, objfile);
2011 if (typenums[0] != -1)
2012 *dbx_lookup_type (typenums) = type;
2013 break;
2014
2015 case 'R': /* Sun ACC builtin float type */
2016 type = read_sun_floating_type (pp, typenums, objfile);
2017 if (typenums[0] != -1)
2018 *dbx_lookup_type (typenums) = type;
2019 break;
2020
2021 case 'e': /* Enumeration type */
2022 type = dbx_alloc_type (typenums, objfile);
2023 type = read_enum_type (pp, type, objfile);
2024 *dbx_lookup_type (typenums) = type;
2025 break;
2026
2027 case 's': /* Struct type */
2028 type = dbx_alloc_type (typenums, objfile);
2029 if (!TYPE_NAME (type))
2030 TYPE_NAME (type) = type_synonym_name;
2031 type_synonym_name = 0;
2032 type = read_struct_type (pp, type, objfile);
2033 break;
2034
2035 case 'u': /* Union type */
2036 type = dbx_alloc_type (typenums, objfile);
2037 if (!TYPE_NAME (type))
2038 TYPE_NAME (type) = type_synonym_name;
2039 type_synonym_name = 0;
2040 type = read_struct_type (pp, type, objfile);
2041 TYPE_CODE (type) = TYPE_CODE_UNION;
2042 break;
2043
2044 case 'a': /* Array type */
2045 if (**pp != 'r')
2046 return error_type (pp);
2047 ++*pp;
2048
2049 type = dbx_alloc_type (typenums, objfile);
2050 type = read_array_type (pp, type, objfile);
2051 break;
2052
2053 default:
2054 --*pp; /* Go back to the symbol in error */
2055 /* Particularly important if it was \0! */
2056 return error_type (pp);
2057 }
2058
2059 if (type == 0)
2060 abort ();
2061
2062 return type;
2063 }
2064 \f
2065 /* This page contains subroutines of read_type. */
2066
2067 /* Read the description of a structure (or union type)
2068 and return an object describing the type. */
2069
2070 static struct type *
2071 read_struct_type (pp, type, objfile)
2072 char **pp;
2073 register struct type *type;
2074 struct objfile *objfile;
2075 {
2076 /* Total number of methods defined in this class.
2077 If the class defines two `f' methods, and one `g' method,
2078 then this will have the value 3. */
2079 int total_length = 0;
2080
2081 struct nextfield
2082 {
2083 struct nextfield *next;
2084 int visibility; /* 0=public, 1=protected, 2=public */
2085 struct field field;
2086 };
2087
2088 struct next_fnfield
2089 {
2090 struct next_fnfield *next;
2091 struct fn_field fn_field;
2092 };
2093
2094 struct next_fnfieldlist
2095 {
2096 struct next_fnfieldlist *next;
2097 struct fn_fieldlist fn_fieldlist;
2098 };
2099
2100 register struct nextfield *list = 0;
2101 struct nextfield *new;
2102 register char *p;
2103 int nfields = 0;
2104 int non_public_fields = 0;
2105 register int n;
2106
2107 register struct next_fnfieldlist *mainlist = 0;
2108 int nfn_fields = 0;
2109
2110 TYPE_CODE (type) = TYPE_CODE_STRUCT;
2111 INIT_CPLUS_SPECIFIC(type);
2112
2113 /* First comes the total size in bytes. */
2114
2115 TYPE_LENGTH (type) = read_number (pp, 0);
2116
2117 /* C++: Now, if the class is a derived class, then the next character
2118 will be a '!', followed by the number of base classes derived from.
2119 Each element in the list contains visibility information,
2120 the offset of this base class in the derived structure,
2121 and then the base type. */
2122 if (**pp == '!')
2123 {
2124 int i, n_baseclasses, offset;
2125 struct type *baseclass;
2126 int via_public;
2127
2128 /* Nonzero if it is a virtual baseclass, i.e.,
2129
2130 struct A{};
2131 struct B{};
2132 struct C : public B, public virtual A {};
2133
2134 B is a baseclass of C; A is a virtual baseclass for C. This is a C++
2135 2.0 language feature. */
2136 int via_virtual;
2137
2138 *pp += 1;
2139
2140 ALLOCATE_CPLUS_STRUCT_TYPE(type);
2141
2142 n_baseclasses = read_number (pp, ',');
2143 TYPE_FIELD_VIRTUAL_BITS (type) =
2144 (B_TYPE *) obstack_alloc (&objfile -> type_obstack,
2145 B_BYTES (n_baseclasses));
2146 B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), n_baseclasses);
2147
2148 for (i = 0; i < n_baseclasses; i++)
2149 {
2150 if (**pp == '\\')
2151 *pp = next_symbol_text ();
2152
2153 switch (**pp)
2154 {
2155 case '0':
2156 via_virtual = 0;
2157 break;
2158 case '1':
2159 via_virtual = 1;
2160 break;
2161 default:
2162 /* Bad visibility format. */
2163 return error_type (pp);
2164 }
2165 ++*pp;
2166
2167 switch (**pp)
2168 {
2169 case '0':
2170 via_public = 0;
2171 non_public_fields++;
2172 break;
2173 case '2':
2174 via_public = 2;
2175 break;
2176 default:
2177 /* Bad visibility format. */
2178 return error_type (pp);
2179 }
2180 if (via_virtual)
2181 SET_TYPE_FIELD_VIRTUAL (type, i);
2182 ++*pp;
2183
2184 /* Offset of the portion of the object corresponding to
2185 this baseclass. Always zero in the absence of
2186 multiple inheritance. */
2187 offset = read_number (pp, ',');
2188 baseclass = read_type (pp, objfile);
2189 *pp += 1; /* skip trailing ';' */
2190
2191 /* Make this baseclass visible for structure-printing purposes. */
2192 new = (struct nextfield *) alloca (sizeof (struct nextfield));
2193 new->next = list;
2194 list = new;
2195 list->visibility = via_public;
2196 list->field.type = baseclass;
2197 list->field.name = type_name_no_tag (baseclass);
2198 list->field.bitpos = offset;
2199 list->field.bitsize = 0; /* this should be an unpacked field! */
2200 nfields++;
2201 }
2202 TYPE_N_BASECLASSES (type) = n_baseclasses;
2203 }
2204
2205 /* Now come the fields, as NAME:?TYPENUM,BITPOS,BITSIZE; for each one.
2206 At the end, we see a semicolon instead of a field.
2207
2208 In C++, this may wind up being NAME:?TYPENUM:PHYSNAME; for
2209 a static field.
2210
2211 The `?' is a placeholder for one of '/2' (public visibility),
2212 '/1' (protected visibility), '/0' (private visibility), or nothing
2213 (C style symbol table, public visibility). */
2214
2215 /* We better set p right now, in case there are no fields at all... */
2216 p = *pp;
2217
2218 while (**pp != ';')
2219 {
2220 /* Check for and handle cretinous dbx symbol name continuation! */
2221 if (**pp == '\\') *pp = next_symbol_text ();
2222
2223 /* Get space to record the next field's data. */
2224 new = (struct nextfield *) alloca (sizeof (struct nextfield));
2225 new->next = list;
2226 list = new;
2227
2228 /* Get the field name. */
2229 p = *pp;
2230 if (*p == CPLUS_MARKER)
2231 {
2232 /* Special GNU C++ name. */
2233 if (*++p == 'v')
2234 {
2235 const char *prefix;
2236 char *name = 0;
2237 struct type *context;
2238
2239 switch (*++p)
2240 {
2241 case 'f':
2242 prefix = vptr_name;
2243 break;
2244 case 'b':
2245 prefix = vb_name;
2246 break;
2247 default:
2248 complain (&invalid_cpp_abbrev_complaint, *pp);
2249 prefix = "INVALID_C++_ABBREV";
2250 break;
2251 }
2252 *pp = p + 1;
2253 context = read_type (pp, objfile);
2254 name = type_name_no_tag (context);
2255 if (name == 0)
2256 {
2257 complain (&invalid_cpp_type_complaint, (char *) symnum);
2258 name = "FOO";
2259 }
2260 list->field.name = obconcat (&objfile -> type_obstack,
2261 prefix, name, "");
2262 p = ++(*pp);
2263 if (p[-1] != ':')
2264 complain (&invalid_cpp_abbrev_complaint, *pp);
2265 list->field.type = read_type (pp, objfile);
2266 (*pp)++; /* Skip the comma. */
2267 list->field.bitpos = read_number (pp, ';');
2268 /* This field is unpacked. */
2269 list->field.bitsize = 0;
2270 list->visibility = 0; /* private */
2271 non_public_fields++;
2272 }
2273 /* GNU C++ anonymous type. */
2274 else if (*p == '_')
2275 break;
2276 else
2277 complain (&invalid_cpp_abbrev_complaint, *pp);
2278
2279 nfields++;
2280 continue;
2281 }
2282
2283 while (*p != ':') p++;
2284 list->field.name = obsavestring (*pp, p - *pp,
2285 &objfile -> type_obstack);
2286
2287 /* C++: Check to see if we have hit the methods yet. */
2288 if (p[1] == ':')
2289 break;
2290
2291 *pp = p + 1;
2292
2293 /* This means we have a visibility for a field coming. */
2294 if (**pp == '/')
2295 {
2296 switch (*++*pp)
2297 {
2298 case '0':
2299 list->visibility = 0; /* private */
2300 non_public_fields++;
2301 *pp += 1;
2302 break;
2303
2304 case '1':
2305 list->visibility = 1; /* protected */
2306 non_public_fields++;
2307 *pp += 1;
2308 break;
2309
2310 case '2':
2311 list->visibility = 2; /* public */
2312 *pp += 1;
2313 break;
2314 }
2315 }
2316 else /* normal dbx-style format. */
2317 list->visibility = 2; /* public */
2318
2319 list->field.type = read_type (pp, objfile);
2320 if (**pp == ':')
2321 {
2322 /* Static class member. */
2323 list->field.bitpos = (long)-1;
2324 p = ++(*pp);
2325 while (*p != ';') p++;
2326 list->field.bitsize = (long) savestring (*pp, p - *pp);
2327 *pp = p + 1;
2328 nfields++;
2329 continue;
2330 }
2331 else if (**pp != ',')
2332 /* Bad structure-type format. */
2333 return error_type (pp);
2334
2335 (*pp)++; /* Skip the comma. */
2336 list->field.bitpos = read_number (pp, ',');
2337 list->field.bitsize = read_number (pp, ';');
2338
2339 #if 0
2340 /* FIXME-tiemann: Can't the compiler put out something which
2341 lets us distinguish these? (or maybe just not put out anything
2342 for the field). What is the story here? What does the compiler
2343 really do? Also, patch gdb.texinfo for this case; I document
2344 it as a possible problem there. Search for "DBX-style". */
2345
2346 /* This is wrong because this is identical to the symbols
2347 produced for GCC 0-size arrays. For example:
2348 typedef union {
2349 int num;
2350 char str[0];
2351 } foo;
2352 The code which dumped core in such circumstances should be
2353 fixed not to dump core. */
2354
2355 /* g++ -g0 can put out bitpos & bitsize zero for a static
2356 field. This does not give us any way of getting its
2357 class, so we can't know its name. But we can just
2358 ignore the field so we don't dump core and other nasty
2359 stuff. */
2360 if (list->field.bitpos == 0
2361 && list->field.bitsize == 0)
2362 {
2363 complain (&dbx_class_complaint, 0);
2364 /* Ignore this field. */
2365 list = list->next;
2366 }
2367 else
2368 #endif /* 0 */
2369 {
2370 /* Detect an unpacked field and mark it as such.
2371 dbx gives a bit size for all fields.
2372 Note that forward refs cannot be packed,
2373 and treat enums as if they had the width of ints. */
2374 if (TYPE_CODE (list->field.type) != TYPE_CODE_INT
2375 && TYPE_CODE (list->field.type) != TYPE_CODE_ENUM)
2376 list->field.bitsize = 0;
2377 if ((list->field.bitsize == 8 * TYPE_LENGTH (list->field.type)
2378 || (TYPE_CODE (list->field.type) == TYPE_CODE_ENUM
2379 && (list->field.bitsize
2380 == 8 * TYPE_LENGTH (lookup_fundamental_type (objfile, FT_INTEGER)))
2381 )
2382 )
2383 &&
2384 list->field.bitpos % 8 == 0)
2385 list->field.bitsize = 0;
2386 nfields++;
2387 }
2388 }
2389
2390 if (p[1] == ':')
2391 /* chill the list of fields: the last entry (at the head)
2392 is a partially constructed entry which we now scrub. */
2393 list = list->next;
2394
2395 /* Now create the vector of fields, and record how big it is.
2396 We need this info to record proper virtual function table information
2397 for this class's virtual functions. */
2398
2399 TYPE_NFIELDS (type) = nfields;
2400 TYPE_FIELDS (type) = (struct field *)
2401 obstack_alloc (&objfile -> type_obstack, sizeof (struct field) * nfields);
2402
2403 if (non_public_fields)
2404 {
2405 ALLOCATE_CPLUS_STRUCT_TYPE (type);
2406
2407 TYPE_FIELD_PRIVATE_BITS (type) =
2408 (B_TYPE *) obstack_alloc (&objfile -> type_obstack,
2409 B_BYTES (nfields));
2410 B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type), nfields);
2411
2412 TYPE_FIELD_PROTECTED_BITS (type) =
2413 (B_TYPE *) obstack_alloc (&objfile -> type_obstack,
2414 B_BYTES (nfields));
2415 B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type), nfields);
2416 }
2417
2418 /* Copy the saved-up fields into the field vector. */
2419
2420 for (n = nfields; list; list = list->next)
2421 {
2422 n -= 1;
2423 TYPE_FIELD (type, n) = list->field;
2424 if (list->visibility == 0)
2425 SET_TYPE_FIELD_PRIVATE (type, n);
2426 else if (list->visibility == 1)
2427 SET_TYPE_FIELD_PROTECTED (type, n);
2428 }
2429
2430 /* Now come the method fields, as NAME::methods
2431 where each method is of the form TYPENUM,ARGS,...:PHYSNAME;
2432 At the end, we see a semicolon instead of a field.
2433
2434 For the case of overloaded operators, the format is
2435 op$::*.methods, where $ is the CPLUS_MARKER (usually '$'),
2436 `*' holds the place for an operator name (such as `+=')
2437 and `.' marks the end of the operator name. */
2438 if (p[1] == ':')
2439 {
2440 /* Now, read in the methods. To simplify matters, we
2441 "unread" the name that has been read, so that we can
2442 start from the top. */
2443
2444 ALLOCATE_CPLUS_STRUCT_TYPE (type);
2445 /* For each list of method lists... */
2446 do
2447 {
2448 int i;
2449 struct next_fnfield *sublist = 0;
2450 struct type *look_ahead_type = NULL;
2451 int length = 0;
2452 struct next_fnfieldlist *new_mainlist =
2453 (struct next_fnfieldlist *)alloca (sizeof (struct next_fnfieldlist));
2454 char *main_fn_name;
2455
2456 p = *pp;
2457
2458 /* read in the name. */
2459 while (*p != ':') p++;
2460 if ((*pp)[0] == 'o' && (*pp)[1] == 'p' && (*pp)[2] == CPLUS_MARKER)
2461 {
2462 /* This is a completely wierd case. In order to stuff in the
2463 names that might contain colons (the usual name delimiter),
2464 Mike Tiemann defined a different name format which is
2465 signalled if the identifier is "op$". In that case, the
2466 format is "op$::XXXX." where XXXX is the name. This is
2467 used for names like "+" or "=". YUUUUUUUK! FIXME! */
2468 /* This lets the user type "break operator+".
2469 We could just put in "+" as the name, but that wouldn't
2470 work for "*". */
2471 static char opname[32] = {'o', 'p', CPLUS_MARKER};
2472 char *o = opname + 3;
2473
2474 /* Skip past '::'. */
2475 *pp = p + 2;
2476 if (**pp == '\\') *pp = next_symbol_text ();
2477 p = *pp;
2478 while (*p != '.')
2479 *o++ = *p++;
2480 main_fn_name = savestring (opname, o - opname);
2481 /* Skip past '.' */
2482 *pp = p + 1;
2483 }
2484 else
2485 {
2486 main_fn_name = savestring (*pp, p - *pp);
2487 /* Skip past '::'. */
2488 *pp = p + 2;
2489 }
2490 new_mainlist->fn_fieldlist.name = main_fn_name;
2491
2492 do
2493 {
2494 struct next_fnfield *new_sublist =
2495 (struct next_fnfield *)alloca (sizeof (struct next_fnfield));
2496
2497 /* Check for and handle cretinous dbx symbol name continuation! */
2498 if (look_ahead_type == NULL) /* Normal case. */
2499 {
2500 if (**pp == '\\') *pp = next_symbol_text ();
2501
2502 new_sublist->fn_field.type = read_type (pp, objfile);
2503 if (**pp != ':')
2504 /* Invalid symtab info for method. */
2505 return error_type (pp);
2506 }
2507 else
2508 { /* g++ version 1 kludge */
2509 new_sublist->fn_field.type = look_ahead_type;
2510 look_ahead_type = NULL;
2511 }
2512
2513 *pp += 1;
2514 p = *pp;
2515 while (*p != ';') p++;
2516
2517 /* If this is just a stub, then we don't have the
2518 real name here. */
2519 if (TYPE_FLAGS (new_sublist->fn_field.type) & TYPE_FLAG_STUB)
2520 new_sublist->fn_field.is_stub = 1;
2521 new_sublist->fn_field.physname = savestring (*pp, p - *pp);
2522 *pp = p + 1;
2523
2524 /* Set this method's visibility fields. */
2525 switch (*(*pp)++ - '0')
2526 {
2527 case 0:
2528 new_sublist->fn_field.is_private = 1;
2529 break;
2530 case 1:
2531 new_sublist->fn_field.is_protected = 1;
2532 break;
2533 }
2534
2535 if (**pp == '\\') *pp = next_symbol_text ();
2536 switch (**pp)
2537 {
2538 case 'A': /* Normal functions. */
2539 new_sublist->fn_field.is_const = 0;
2540 new_sublist->fn_field.is_volatile = 0;
2541 (*pp)++;
2542 break;
2543 case 'B': /* `const' member functions. */
2544 new_sublist->fn_field.is_const = 1;
2545 new_sublist->fn_field.is_volatile = 0;
2546 (*pp)++;
2547 break;
2548 case 'C': /* `volatile' member function. */
2549 new_sublist->fn_field.is_const = 0;
2550 new_sublist->fn_field.is_volatile = 1;
2551 (*pp)++;
2552 break;
2553 case 'D': /* `const volatile' member function. */
2554 new_sublist->fn_field.is_const = 1;
2555 new_sublist->fn_field.is_volatile = 1;
2556 (*pp)++;
2557 break;
2558 case '*': /* File compiled with g++ version 1 -- no info */
2559 case '?':
2560 case '.':
2561 break;
2562 default:
2563 complain (&const_vol_complaint, (char *) (long) **pp);
2564 break;
2565 }
2566
2567 switch (*(*pp)++)
2568 {
2569 case '*':
2570 /* virtual member function, followed by index. */
2571 /* The sign bit is set to distinguish pointers-to-methods
2572 from virtual function indicies. Since the array is
2573 in words, the quantity must be shifted left by 1
2574 on 16 bit machine, and by 2 on 32 bit machine, forcing
2575 the sign bit out, and usable as a valid index into
2576 the array. Remove the sign bit here. */
2577 new_sublist->fn_field.voffset =
2578 (0x7fffffff & read_number (pp, ';')) + 2;
2579
2580 if (**pp == '\\') *pp = next_symbol_text ();
2581
2582 if (**pp == ';' || **pp == '\0')
2583 /* Must be g++ version 1. */
2584 new_sublist->fn_field.fcontext = 0;
2585 else
2586 {
2587 /* Figure out from whence this virtual function came.
2588 It may belong to virtual function table of
2589 one of its baseclasses. */
2590 look_ahead_type = read_type (pp, objfile);
2591 if (**pp == ':')
2592 { /* g++ version 1 overloaded methods. */ }
2593 else
2594 {
2595 new_sublist->fn_field.fcontext = look_ahead_type;
2596 if (**pp != ';')
2597 return error_type (pp);
2598 else
2599 ++*pp;
2600 look_ahead_type = NULL;
2601 }
2602 }
2603 break;
2604
2605 case '?':
2606 /* static member function. */
2607 new_sublist->fn_field.voffset = VOFFSET_STATIC;
2608 if (strncmp (new_sublist->fn_field.physname,
2609 main_fn_name, strlen (main_fn_name)))
2610 new_sublist->fn_field.is_stub = 1;
2611 break;
2612
2613 default:
2614 /* error */
2615 complain (&member_fn_complaint, (char *) (long) (*pp)[-1]);
2616 /* Fall through into normal member function. */
2617
2618 case '.':
2619 /* normal member function. */
2620 new_sublist->fn_field.voffset = 0;
2621 new_sublist->fn_field.fcontext = 0;
2622 break;
2623 }
2624
2625 new_sublist->next = sublist;
2626 sublist = new_sublist;
2627 length++;
2628 if (**pp == '\\') *pp = next_symbol_text ();
2629 }
2630 while (**pp != ';' && **pp != '\0');
2631
2632 *pp += 1;
2633
2634 new_mainlist->fn_fieldlist.fn_fields =
2635 (struct fn_field *) obstack_alloc (&objfile -> type_obstack,
2636 sizeof (struct fn_field) * length);
2637 for (i = length; (i--, sublist); sublist = sublist->next)
2638 new_mainlist->fn_fieldlist.fn_fields[i] = sublist->fn_field;
2639
2640 new_mainlist->fn_fieldlist.length = length;
2641 new_mainlist->next = mainlist;
2642 mainlist = new_mainlist;
2643 nfn_fields++;
2644 total_length += length;
2645 if (**pp == '\\') *pp = next_symbol_text ();
2646 }
2647 while (**pp != ';');
2648 }
2649
2650 *pp += 1;
2651
2652
2653 if (nfn_fields)
2654 {
2655 TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *)
2656 obstack_alloc (&objfile -> type_obstack,
2657 sizeof (struct fn_fieldlist) * nfn_fields);
2658 TYPE_NFN_FIELDS (type) = nfn_fields;
2659 TYPE_NFN_FIELDS_TOTAL (type) = total_length;
2660 }
2661
2662 {
2663 int i;
2664 for (i = 0; i < TYPE_N_BASECLASSES (type); ++i)
2665 TYPE_NFN_FIELDS_TOTAL (type) +=
2666 TYPE_NFN_FIELDS_TOTAL (TYPE_BASECLASS (type, i));
2667 }
2668
2669 for (n = nfn_fields; mainlist; mainlist = mainlist->next) {
2670 --n; /* Circumvent Sun3 compiler bug */
2671 TYPE_FN_FIELDLISTS (type)[n] = mainlist->fn_fieldlist;
2672 }
2673
2674 if (**pp == '~')
2675 {
2676 *pp += 1;
2677
2678 if (**pp == '=' || **pp == '+' || **pp == '-')
2679 {
2680 /* Obsolete flags that used to indicate the presence
2681 of constructors and/or destructors. */
2682 *pp += 1;
2683 }
2684
2685 /* Read either a '%' or the final ';'. */
2686 if (*(*pp)++ == '%')
2687 {
2688 /* We'd like to be able to derive the vtable pointer field
2689 from the type information, but when it's inherited, that's
2690 hard. A reason it's hard is because we may read in the
2691 info about a derived class before we read in info about
2692 the base class that provides the vtable pointer field.
2693 Once the base info has been read, we could fill in the info
2694 for the derived classes, but for the fact that by then,
2695 we don't remember who needs what. */
2696
2697 #if 0
2698 int predicted_fieldno = -1;
2699 #endif
2700
2701 /* Now we must record the virtual function table pointer's
2702 field information. */
2703
2704 struct type *t;
2705 int i;
2706
2707
2708 #if 0
2709 {
2710 /* In version 2, we derive the vfield ourselves. */
2711 for (n = 0; n < nfields; n++)
2712 {
2713 if (! strncmp (TYPE_FIELD_NAME (type, n), vptr_name,
2714 sizeof (vptr_name) -1))
2715 {
2716 predicted_fieldno = n;
2717 break;
2718 }
2719 }
2720 if (predicted_fieldno < 0)
2721 for (n = 0; n < TYPE_N_BASECLASSES (type); n++)
2722 if (! TYPE_FIELD_VIRTUAL (type, n)
2723 && TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type, n)) >= 0)
2724 {
2725 predicted_fieldno = TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type, n));
2726 break;
2727 }
2728 }
2729 #endif
2730
2731 t = read_type (pp, objfile);
2732 p = (*pp)++;
2733 while (*p != '\0' && *p != ';')
2734 p++;
2735 if (*p == '\0')
2736 /* Premature end of symbol. */
2737 return error_type (pp);
2738
2739 TYPE_VPTR_BASETYPE (type) = t;
2740 if (type == t)
2741 {
2742 if (TYPE_FIELD_NAME (t, TYPE_N_BASECLASSES (t)) == 0)
2743 {
2744 /* FIXME-tiemann: what's this? */
2745 #if 0
2746 TYPE_VPTR_FIELDNO (type) = i = TYPE_N_BASECLASSES (t);
2747 #else
2748 error_type (pp);
2749 #endif
2750 }
2751 else for (i = TYPE_NFIELDS (t) - 1; i >= TYPE_N_BASECLASSES (t); --i)
2752 if (! strncmp (TYPE_FIELD_NAME (t, i), vptr_name,
2753 sizeof (vptr_name) -1))
2754 {
2755 TYPE_VPTR_FIELDNO (type) = i;
2756 break;
2757 }
2758 if (i < 0)
2759 /* Virtual function table field not found. */
2760 return error_type (pp);
2761 }
2762 else
2763 TYPE_VPTR_FIELDNO (type) = TYPE_VPTR_FIELDNO (t);
2764
2765 #if 0
2766 if (TYPE_VPTR_FIELDNO (type) != predicted_fieldno)
2767 error ("TYPE_VPTR_FIELDNO miscalculated");
2768 #endif
2769
2770 *pp = p + 1;
2771 }
2772 }
2773
2774 return type;
2775 }
2776
2777 /* Read a definition of an array type,
2778 and create and return a suitable type object.
2779 Also creates a range type which represents the bounds of that
2780 array. */
2781 static struct type *
2782 read_array_type (pp, type, objfile)
2783 register char **pp;
2784 register struct type *type;
2785 struct objfile *objfile;
2786 {
2787 struct type *index_type, *element_type, *range_type;
2788 int lower, upper;
2789 int adjustable = 0;
2790
2791 /* Format of an array type:
2792 "ar<index type>;lower;upper;<array_contents_type>". Put code in
2793 to handle this.
2794
2795 Fortran adjustable arrays use Adigits or Tdigits for lower or upper;
2796 for these, produce a type like float[][]. */
2797
2798 index_type = read_type (pp, objfile);
2799 if (**pp != ';')
2800 /* Improper format of array type decl. */
2801 return error_type (pp);
2802 ++*pp;
2803
2804 if (!(**pp >= '0' && **pp <= '9'))
2805 {
2806 *pp += 1;
2807 adjustable = 1;
2808 }
2809 lower = read_number (pp, ';');
2810
2811 if (!(**pp >= '0' && **pp <= '9'))
2812 {
2813 *pp += 1;
2814 adjustable = 1;
2815 }
2816 upper = read_number (pp, ';');
2817
2818 element_type = read_type (pp, objfile);
2819
2820 if (adjustable)
2821 {
2822 lower = 0;
2823 upper = -1;
2824 }
2825
2826 {
2827 /* Create range type. */
2828 range_type = (struct type *)
2829 obstack_alloc (&objfile -> type_obstack, sizeof (struct type));
2830 bzero (range_type, sizeof (struct type));
2831 TYPE_OBJFILE (range_type) = objfile;
2832 TYPE_CODE (range_type) = TYPE_CODE_RANGE;
2833 TYPE_TARGET_TYPE (range_type) = index_type;
2834
2835 /* This should never be needed. */
2836 TYPE_LENGTH (range_type) = sizeof (int);
2837
2838 TYPE_NFIELDS (range_type) = 2;
2839 TYPE_FIELDS (range_type) =
2840 (struct field *) obstack_alloc (&objfile -> type_obstack,
2841 2 * sizeof (struct field));
2842 TYPE_FIELD_BITPOS (range_type, 0) = lower;
2843 TYPE_FIELD_BITPOS (range_type, 1) = upper;
2844 }
2845
2846 TYPE_CODE (type) = TYPE_CODE_ARRAY;
2847 TYPE_TARGET_TYPE (type) = element_type;
2848 TYPE_LENGTH (type) = (upper - lower + 1) * TYPE_LENGTH (element_type);
2849 TYPE_NFIELDS (type) = 1;
2850 TYPE_FIELDS (type) =
2851 (struct field *) obstack_alloc (&objfile -> type_obstack,
2852 sizeof (struct field));
2853 TYPE_FIELD_TYPE (type, 0) = range_type;
2854
2855 /* If we have an array whose element type is not yet known, but whose
2856 bounds *are* known, record it to be adjusted at the end of the file. */
2857 if (TYPE_LENGTH (element_type) == 0 && !adjustable)
2858 add_undefined_type (type);
2859
2860 return type;
2861 }
2862
2863
2864 /* Read a definition of an enumeration type,
2865 and create and return a suitable type object.
2866 Also defines the symbols that represent the values of the type. */
2867
2868 static struct type *
2869 read_enum_type (pp, type, objfile)
2870 register char **pp;
2871 register struct type *type;
2872 struct objfile *objfile;
2873 {
2874 register char *p;
2875 char *name;
2876 register long n;
2877 register struct symbol *sym;
2878 int nsyms = 0;
2879 struct pending **symlist;
2880 struct pending *osyms, *syms;
2881 int o_nsyms;
2882
2883 #if 0
2884 /* FIXME! The stabs produced by Sun CC merrily define things that ought
2885 to be file-scope, between N_FN entries, using N_LSYM. What's a mother
2886 to do? For now, force all enum values to file scope. */
2887 if (within_function)
2888 symlist = &local_symbols;
2889 else
2890 #endif
2891 symlist = &file_symbols;
2892 osyms = *symlist;
2893 o_nsyms = osyms ? osyms->nsyms : 0;
2894
2895 /* Read the value-names and their values.
2896 The input syntax is NAME:VALUE,NAME:VALUE, and so on.
2897 A semicolon or comma instead of a NAME means the end. */
2898 while (**pp && **pp != ';' && **pp != ',')
2899 {
2900 /* Check for and handle cretinous dbx symbol name continuation! */
2901 if (**pp == '\\') *pp = next_symbol_text ();
2902
2903 p = *pp;
2904 while (*p != ':') p++;
2905 name = obsavestring (*pp, p - *pp, &objfile -> symbol_obstack);
2906 *pp = p + 1;
2907 n = read_number (pp, ',');
2908
2909 sym = (struct symbol *) obstack_alloc (&objfile -> symbol_obstack, sizeof (struct symbol));
2910 bzero (sym, sizeof (struct symbol));
2911 SYMBOL_NAME (sym) = name;
2912 SYMBOL_CLASS (sym) = LOC_CONST;
2913 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2914 SYMBOL_VALUE (sym) = n;
2915 add_symbol_to_list (sym, symlist);
2916 nsyms++;
2917 }
2918
2919 if (**pp == ';')
2920 (*pp)++; /* Skip the semicolon. */
2921
2922 /* Now fill in the fields of the type-structure. */
2923
2924 TYPE_LENGTH (type) = sizeof (int);
2925 TYPE_CODE (type) = TYPE_CODE_ENUM;
2926 TYPE_NFIELDS (type) = nsyms;
2927 TYPE_FIELDS (type) = (struct field *)
2928 obstack_alloc (&objfile -> type_obstack,
2929 sizeof (struct field) * nsyms);
2930
2931 /* Find the symbols for the values and put them into the type.
2932 The symbols can be found in the symlist that we put them on
2933 to cause them to be defined. osyms contains the old value
2934 of that symlist; everything up to there was defined by us. */
2935 /* Note that we preserve the order of the enum constants, so
2936 that in something like "enum {FOO, LAST_THING=FOO}" we print
2937 FOO, not LAST_THING. */
2938
2939 for (syms = *symlist, n = 0; syms; syms = syms->next)
2940 {
2941 int j = 0;
2942 if (syms == osyms)
2943 j = o_nsyms;
2944 for (; j < syms->nsyms; j++,n++)
2945 {
2946 struct symbol *xsym = syms->symbol[j];
2947 SYMBOL_TYPE (xsym) = type;
2948 TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym);
2949 TYPE_FIELD_VALUE (type, n) = 0;
2950 TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (xsym);
2951 TYPE_FIELD_BITSIZE (type, n) = 0;
2952 }
2953 if (syms == osyms)
2954 break;
2955 }
2956
2957 #if 0
2958 /* This screws up perfectly good C programs with enums. FIXME. */
2959 /* Is this Modula-2's BOOLEAN type? Flag it as such if so. */
2960 if(TYPE_NFIELDS(type) == 2 &&
2961 ((!strcmp(TYPE_FIELD_NAME(type,0),"TRUE") &&
2962 !strcmp(TYPE_FIELD_NAME(type,1),"FALSE")) ||
2963 (!strcmp(TYPE_FIELD_NAME(type,1),"TRUE") &&
2964 !strcmp(TYPE_FIELD_NAME(type,0),"FALSE"))))
2965 TYPE_CODE(type) = TYPE_CODE_BOOL;
2966 #endif
2967
2968 return type;
2969 }
2970
2971 /* this is for the initial typedefs in every file (for int, long, etc) */
2972 static struct type *
2973 read_sun_builtin_type (pp, typenums, objfile)
2974 char **pp;
2975 int typenums[2];
2976 struct objfile *objfile;
2977 {
2978 int nbits;
2979 int signed_type;
2980
2981 switch (**pp) {
2982 case 's':
2983 signed_type = 1;
2984 break;
2985 case 'u':
2986 signed_type = 0;
2987 break;
2988 default:
2989 return error_type (pp);
2990 }
2991 (*pp)++;
2992
2993 /* The first number appears to be the number of bytes occupied
2994 by this type, except that unsigned short is 4 instead of 2.
2995 Since this information is redundant with the third number,
2996 we will ignore it. */
2997 read_number (pp, ';');
2998
2999 /* The second number is always 0, so ignore it too. */
3000 read_number (pp, ';');
3001
3002 /* The third number is the number of bits for this type. */
3003 nbits = read_number (pp, 0);
3004
3005 /* FIXME. Here we should just be able to make a type of the right
3006 number of bits and signedness. FIXME. */
3007
3008 if (nbits == TARGET_LONG_LONG_BIT)
3009 return (lookup_fundamental_type (objfile,
3010 signed_type? FT_LONG_LONG: FT_UNSIGNED_LONG_LONG));
3011
3012 if (nbits == TARGET_INT_BIT) {
3013 /* FIXME -- the only way to distinguish `int' from `long'
3014 is to look at its name! */
3015 if (signed_type) {
3016 if (long_kludge_name && long_kludge_name[0] == 'l' /* long */)
3017 return lookup_fundamental_type (objfile, FT_LONG);
3018 else
3019 return lookup_fundamental_type (objfile, FT_INTEGER);
3020 } else {
3021 if (long_kludge_name
3022 && ((long_kludge_name[0] == 'u' /* unsigned */ &&
3023 long_kludge_name[9] == 'l' /* long */)
3024 || (long_kludge_name[0] == 'l' /* long unsigned */)))
3025 return lookup_fundamental_type (objfile, FT_UNSIGNED_LONG);
3026 else
3027 return lookup_fundamental_type (objfile, FT_UNSIGNED_INTEGER);
3028 }
3029 }
3030
3031 if (nbits == TARGET_SHORT_BIT)
3032 return (lookup_fundamental_type (objfile,
3033 signed_type? FT_SHORT: FT_UNSIGNED_SHORT));
3034
3035 if (nbits == TARGET_CHAR_BIT)
3036 return (lookup_fundamental_type (objfile,
3037 signed_type? FT_CHAR: FT_UNSIGNED_CHAR));
3038
3039 if (nbits == 0)
3040 return lookup_fundamental_type (objfile, FT_VOID);
3041
3042 return error_type (pp);
3043 }
3044
3045 static struct type *
3046 read_sun_floating_type (pp, typenums, objfile)
3047 char **pp;
3048 int typenums[2];
3049 struct objfile *objfile;
3050 {
3051 int nbytes;
3052
3053 /* The first number has more details about the type, for example
3054 FN_COMPLEX. See the sun stab.h. */
3055 read_number (pp, ';');
3056
3057 /* The second number is the number of bytes occupied by this type */
3058 nbytes = read_number (pp, ';');
3059
3060 if (**pp != 0)
3061 return error_type (pp);
3062
3063 if (nbytes == TARGET_FLOAT_BIT / TARGET_CHAR_BIT)
3064 return lookup_fundamental_type (objfile, FT_FLOAT);
3065
3066 if (nbytes == TARGET_DOUBLE_BIT / TARGET_CHAR_BIT)
3067 return lookup_fundamental_type (objfile, FT_DBL_PREC_FLOAT);
3068
3069 if (nbytes == TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT)
3070 return lookup_fundamental_type (objfile, FT_EXT_PREC_FLOAT);
3071
3072 return error_type (pp);
3073 }
3074
3075 /* Read a number from the string pointed to by *PP.
3076 The value of *PP is advanced over the number.
3077 If END is nonzero, the character that ends the
3078 number must match END, or an error happens;
3079 and that character is skipped if it does match.
3080 If END is zero, *PP is left pointing to that character.
3081
3082 If the number fits in a long, set *VALUE and set *BITS to 0.
3083 If not, set *BITS to be the number of bits in the number.
3084
3085 If encounter garbage, set *BITS to -1. */
3086
3087 static void
3088 read_huge_number (pp, end, valu, bits)
3089 char **pp;
3090 int end;
3091 long *valu;
3092 int *bits;
3093 {
3094 char *p = *pp;
3095 int sign = 1;
3096 long n = 0;
3097 int radix = 10;
3098 char overflow = 0;
3099 int nbits = 0;
3100 int c;
3101 long upper_limit;
3102
3103 if (*p == '-')
3104 {
3105 sign = -1;
3106 p++;
3107 }
3108
3109 /* Leading zero means octal. GCC uses this to output values larger
3110 than an int (because that would be hard in decimal). */
3111 if (*p == '0')
3112 {
3113 radix = 8;
3114 p++;
3115 }
3116
3117 upper_limit = LONG_MAX / radix;
3118 while ((c = *p++) >= '0' && c <= ('0' + radix))
3119 {
3120 if (n <= upper_limit)
3121 {
3122 n *= radix;
3123 n += c - '0'; /* FIXME this overflows anyway */
3124 }
3125 else
3126 overflow = 1;
3127
3128 /* This depends on large values being output in octal, which is
3129 what GCC does. */
3130 if (radix == 8)
3131 {
3132 if (nbits == 0)
3133 {
3134 if (c == '0')
3135 /* Ignore leading zeroes. */
3136 ;
3137 else if (c == '1')
3138 nbits = 1;
3139 else if (c == '2' || c == '3')
3140 nbits = 2;
3141 else
3142 nbits = 3;
3143 }
3144 else
3145 nbits += 3;
3146 }
3147 }
3148 if (end)
3149 {
3150 if (c && c != end)
3151 {
3152 if (bits != NULL)
3153 *bits = -1;
3154 return;
3155 }
3156 }
3157 else
3158 --p;
3159
3160 *pp = p;
3161 if (overflow)
3162 {
3163 if (nbits == 0)
3164 {
3165 /* Large decimal constants are an error (because it is hard to
3166 count how many bits are in them). */
3167 if (bits != NULL)
3168 *bits = -1;
3169 return;
3170 }
3171
3172 /* -0x7f is the same as 0x80. So deal with it by adding one to
3173 the number of bits. */
3174 if (sign == -1)
3175 ++nbits;
3176 if (bits)
3177 *bits = nbits;
3178 }
3179 else
3180 {
3181 if (valu)
3182 *valu = n * sign;
3183 if (bits)
3184 *bits = 0;
3185 }
3186 }
3187
3188 static struct type *
3189 read_range_type (pp, typenums, objfile)
3190 char **pp;
3191 int typenums[2];
3192 struct objfile *objfile;
3193 {
3194 int rangenums[2];
3195 long n2, n3;
3196 int n2bits, n3bits;
3197 int self_subrange;
3198 struct type *result_type;
3199
3200 /* First comes a type we are a subrange of.
3201 In C it is usually 0, 1 or the type being defined. */
3202 read_type_number (pp, rangenums);
3203 self_subrange = (rangenums[0] == typenums[0] &&
3204 rangenums[1] == typenums[1]);
3205
3206 /* A semicolon should now follow; skip it. */
3207 if (**pp == ';')
3208 (*pp)++;
3209
3210 /* The remaining two operands are usually lower and upper bounds
3211 of the range. But in some special cases they mean something else. */
3212 read_huge_number (pp, ';', &n2, &n2bits);
3213 read_huge_number (pp, ';', &n3, &n3bits);
3214
3215 if (n2bits == -1 || n3bits == -1)
3216 return error_type (pp);
3217
3218 /* If limits are huge, must be large integral type. */
3219 if (n2bits != 0 || n3bits != 0)
3220 {
3221 char got_signed = 0;
3222 char got_unsigned = 0;
3223 /* Number of bits in the type. */
3224 int nbits;
3225
3226 /* Range from 0 to <large number> is an unsigned large integral type. */
3227 if ((n2bits == 0 && n2 == 0) && n3bits != 0)
3228 {
3229 got_unsigned = 1;
3230 nbits = n3bits;
3231 }
3232 /* Range from <large number> to <large number>-1 is a large signed
3233 integral type. */
3234 else if (n2bits != 0 && n3bits != 0 && n2bits == n3bits + 1)
3235 {
3236 got_signed = 1;
3237 nbits = n2bits;
3238 }
3239
3240 /* Check for "long long". */
3241 if (got_signed && nbits == TARGET_LONG_LONG_BIT)
3242 return (lookup_fundamental_type (objfile, FT_LONG_LONG));
3243 if (got_unsigned && nbits == TARGET_LONG_LONG_BIT)
3244 return (lookup_fundamental_type (objfile, FT_UNSIGNED_LONG_LONG));
3245
3246 if (got_signed || got_unsigned)
3247 {
3248 result_type = (struct type *)
3249 obstack_alloc (&objfile -> type_obstack,
3250 sizeof (struct type));
3251 bzero (result_type, sizeof (struct type));
3252 TYPE_OBJFILE (result_type) = objfile;
3253 TYPE_LENGTH (result_type) = nbits / TARGET_CHAR_BIT;
3254 TYPE_CODE (result_type) = TYPE_CODE_INT;
3255 if (got_unsigned)
3256 TYPE_FLAGS (result_type) |= TYPE_FLAG_UNSIGNED;
3257 return result_type;
3258 }
3259 else
3260 return error_type (pp);
3261 }
3262
3263 /* A type defined as a subrange of itself, with bounds both 0, is void. */
3264 if (self_subrange && n2 == 0 && n3 == 0)
3265 return (lookup_fundamental_type (objfile, FT_VOID));
3266
3267 /* If n3 is zero and n2 is not, we want a floating type,
3268 and n2 is the width in bytes.
3269
3270 Fortran programs appear to use this for complex types also,
3271 and they give no way to distinguish between double and single-complex!
3272 We don't have complex types, so we would lose on all fortran files!
3273 So return type `double' for all of those. It won't work right
3274 for the complex values, but at least it makes the file loadable.
3275
3276 FIXME, we may be able to distinguish these by their names. FIXME. */
3277
3278 if (n3 == 0 && n2 > 0)
3279 {
3280 if (n2 == sizeof (float))
3281 return (lookup_fundamental_type (objfile, FT_FLOAT));
3282 return (lookup_fundamental_type (objfile, FT_DBL_PREC_FLOAT));
3283 }
3284
3285 /* If the upper bound is -1, it must really be an unsigned int. */
3286
3287 else if (n2 == 0 && n3 == -1)
3288 {
3289 /* FIXME -- the only way to distinguish `unsigned int' from `unsigned
3290 long' is to look at its name! */
3291 if (
3292 long_kludge_name && ((long_kludge_name[0] == 'u' /* unsigned */ &&
3293 long_kludge_name[9] == 'l' /* long */)
3294 || (long_kludge_name[0] == 'l' /* long unsigned */)))
3295 return (lookup_fundamental_type (objfile, FT_UNSIGNED_LONG));
3296 else
3297 return (lookup_fundamental_type (objfile, FT_UNSIGNED_INTEGER));
3298 }
3299
3300 /* Special case: char is defined (Who knows why) as a subrange of
3301 itself with range 0-127. */
3302 else if (self_subrange && n2 == 0 && n3 == 127)
3303 return (lookup_fundamental_type (objfile, FT_CHAR));
3304
3305 /* Assumptions made here: Subrange of self is equivalent to subrange
3306 of int. FIXME: Host and target type-sizes assumed the same. */
3307 /* FIXME: This is the *only* place in GDB that depends on comparing
3308 some type to a builtin type with ==. Fix it! */
3309 else if (n2 == 0
3310 && (self_subrange ||
3311 *dbx_lookup_type (rangenums) == lookup_fundamental_type (objfile, FT_INTEGER)))
3312 {
3313 /* an unsigned type */
3314 #ifdef LONG_LONG
3315 if (n3 == - sizeof (long long))
3316 return (lookup_fundamental_type (objfile, FT_UNSIGNED_LONG_LONG));
3317 #endif
3318 /* FIXME -- the only way to distinguish `unsigned int' from `unsigned
3319 long' is to look at its name! */
3320 if (n3 == (unsigned long)~0L &&
3321 long_kludge_name && ((long_kludge_name[0] == 'u' /* unsigned */ &&
3322 long_kludge_name[9] == 'l' /* long */)
3323 || (long_kludge_name[0] == 'l' /* long unsigned */)))
3324 return (lookup_fundamental_type (objfile, FT_UNSIGNED_LONG));
3325 if (n3 == (unsigned int)~0L)
3326 return (lookup_fundamental_type (objfile, FT_UNSIGNED_INTEGER));
3327 if (n3 == (unsigned short)~0L)
3328 return (lookup_fundamental_type (objfile, FT_UNSIGNED_SHORT));
3329 if (n3 == (unsigned char)~0L)
3330 return (lookup_fundamental_type (objfile, FT_UNSIGNED_CHAR));
3331 }
3332 #ifdef LONG_LONG
3333 else if (n3 == 0 && n2 == -sizeof (long long))
3334 return (lookup_fundamental_type (objfile, FT_LONG_LONG));
3335 #endif
3336 else if (n2 == -n3 -1)
3337 {
3338 /* a signed type */
3339 /* FIXME -- the only way to distinguish `int' from `long' is to look
3340 at its name! */
3341 if ((n3 ==(long)(((unsigned long)1 << (8 * sizeof (long) - 1)) - 1)) &&
3342 long_kludge_name && long_kludge_name[0] == 'l' /* long */)
3343 return (lookup_fundamental_type (objfile, FT_LONG));
3344 if (n3 == (long)(((unsigned long)1 << (8 * sizeof (int) - 1)) - 1))
3345 return (lookup_fundamental_type (objfile, FT_INTEGER));
3346 if (n3 == ( 1 << (8 * sizeof (short) - 1)) - 1)
3347 return (lookup_fundamental_type (objfile, FT_SHORT));
3348 if (n3 == ( 1 << (8 * sizeof (char) - 1)) - 1)
3349 return (lookup_fundamental_type (objfile, FT_CHAR));
3350 }
3351
3352 /* We have a real range type on our hands. Allocate space and
3353 return a real pointer. */
3354
3355 /* At this point I don't have the faintest idea how to deal with
3356 a self_subrange type; I'm going to assume that this is used
3357 as an idiom, and that all of them are special cases. So . . . */
3358 if (self_subrange)
3359 return error_type (pp);
3360
3361 result_type = (struct type *)
3362 obstack_alloc (&objfile -> type_obstack, sizeof (struct type));
3363 bzero (result_type, sizeof (struct type));
3364 TYPE_OBJFILE (result_type) = objfile;
3365
3366 TYPE_CODE (result_type) = TYPE_CODE_RANGE;
3367
3368 TYPE_TARGET_TYPE (result_type) = *dbx_lookup_type(rangenums);
3369 if (TYPE_TARGET_TYPE (result_type) == 0) {
3370 complain (&range_type_base_complaint, (char *) rangenums[1]);
3371 TYPE_TARGET_TYPE (result_type) = lookup_fundamental_type (objfile, FT_INTEGER);
3372 }
3373
3374 TYPE_NFIELDS (result_type) = 2;
3375 TYPE_FIELDS (result_type) =
3376 (struct field *) obstack_alloc (&objfile -> type_obstack,
3377 2 * sizeof (struct field));
3378 bzero (TYPE_FIELDS (result_type), 2 * sizeof (struct field));
3379 TYPE_FIELD_BITPOS (result_type, 0) = n2;
3380 TYPE_FIELD_BITPOS (result_type, 1) = n3;
3381
3382 TYPE_LENGTH (result_type) = TYPE_LENGTH (TYPE_TARGET_TYPE (result_type));
3383
3384 return result_type;
3385 }
3386
3387 /* Read a number from the string pointed to by *PP.
3388 The value of *PP is advanced over the number.
3389 If END is nonzero, the character that ends the
3390 number must match END, or an error happens;
3391 and that character is skipped if it does match.
3392 If END is zero, *PP is left pointing to that character. */
3393
3394 long
3395 read_number (pp, end)
3396 char **pp;
3397 int end;
3398 {
3399 register char *p = *pp;
3400 register long n = 0;
3401 register int c;
3402 int sign = 1;
3403
3404 /* Handle an optional leading minus sign. */
3405
3406 if (*p == '-')
3407 {
3408 sign = -1;
3409 p++;
3410 }
3411
3412 /* Read the digits, as far as they go. */
3413
3414 while ((c = *p++) >= '0' && c <= '9')
3415 {
3416 n *= 10;
3417 n += c - '0';
3418 }
3419 if (end)
3420 {
3421 if (c && c != end)
3422 error ("Invalid symbol data: invalid character \\%03o at symbol pos %d.", c, symnum);
3423 }
3424 else
3425 --p;
3426
3427 *pp = p;
3428 return n * sign;
3429 }
3430
3431 /* Read in an argument list. This is a list of types, separated by commas
3432 and terminated with END. Return the list of types read in, or (struct type
3433 **)-1 if there is an error. */
3434 static struct type **
3435 read_args (pp, end, objfile)
3436 char **pp;
3437 int end;
3438 struct objfile *objfile;
3439 {
3440 /* FIXME! Remove this arbitrary limit! */
3441 struct type *types[1024], **rval; /* allow for fns of 1023 parameters */
3442 int n = 0;
3443
3444 while (**pp != end)
3445 {
3446 if (**pp != ',')
3447 /* Invalid argument list: no ','. */
3448 return (struct type **)-1;
3449 *pp += 1;
3450
3451 /* Check for and handle cretinous dbx symbol name continuation! */
3452 if (**pp == '\\')
3453 *pp = next_symbol_text ();
3454
3455 types[n++] = read_type (pp, objfile);
3456 }
3457 *pp += 1; /* get past `end' (the ':' character) */
3458
3459 if (n == 1)
3460 {
3461 rval = (struct type **) xmalloc (2 * sizeof (struct type *));
3462 }
3463 else if (TYPE_CODE (types[n-1]) != TYPE_CODE_VOID)
3464 {
3465 rval = (struct type **) xmalloc ((n + 1) * sizeof (struct type *));
3466 bzero (rval + n, sizeof (struct type *));
3467 }
3468 else
3469 {
3470 rval = (struct type **) xmalloc (n * sizeof (struct type *));
3471 }
3472 memcpy (rval, types, n * sizeof (struct type *));
3473 return rval;
3474 }
3475
3476 /* Add a common block's start address to the offset of each symbol
3477 declared to be in it (by being between a BCOMM/ECOMM pair that uses
3478 the common block name). */
3479
3480 static void
3481 fix_common_block (sym, valu)
3482 struct symbol *sym;
3483 int valu;
3484 {
3485 struct pending *next = (struct pending *) SYMBOL_NAMESPACE (sym);
3486 for ( ; next; next = next->next)
3487 {
3488 register int j;
3489 for (j = next->nsyms - 1; j >= 0; j--)
3490 SYMBOL_VALUE_ADDRESS (next->symbol[j]) += valu;
3491 }
3492 }
3493
3494 /* Initializer for this module */
3495 void
3496 _initialize_buildsym ()
3497 {
3498 undef_types_allocated = 20;
3499 undef_types_length = 0;
3500 undef_types = (struct type **) xmalloc (undef_types_allocated *
3501 sizeof (struct type *));
3502 }
This page took 0.104755 seconds and 4 git commands to generate.