1 /* Build symbol tables in GDB's internal format.
2 Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992
3 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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. */
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.
25 They originated in dbxread.c of gdb-4.2, and were split out to
26 make xcoffread.c more maintainable by sharing code. */
32 #include "breakpoint.h"
33 #include "gdbcore.h" /* for bfd stuff for symfile.h */
34 #include "symfile.h" /* Needed for "struct complaint" */
36 #include "aout/stab_gnu.h" /* We always use GNU stabs, not native */
40 /* Ask buildsym.h to define the vars it normally declares `extern'. */
42 #include "buildsym.h" /* Our own declarations */
46 patch_block_stabs PARAMS ((struct pending *, struct pending_stabs *,
50 read_huge_number PARAMS ((char **, int, long *, int *));
53 dbx_alloc_type PARAMS ((int [2], struct objfile *));
56 compare_line_numbers PARAMS ((const void *, const void *));
58 static struct blockvector *
59 make_blockvector PARAMS ((struct objfile *));
62 fix_common_block PARAMS ((struct symbol *, int));
65 cleanup_undefined_types PARAMS ((void));
68 read_range_type PARAMS ((char **, int [2], struct objfile *));
71 read_sun_builtin_type PARAMS ((char **, int [2], struct objfile *));
74 read_sun_floating_type PARAMS ((char **, int [2], struct objfile *));
77 read_enum_type PARAMS ((char **, struct type *, struct objfile *));
80 read_struct_type PARAMS ((char **, struct type *, struct objfile *));
83 read_array_type PARAMS ((char **, struct type *, struct objfile *));
86 read_args PARAMS ((char **, int, struct objfile *));
90 static const char vptr_name[] = { '_','v','p','t','r',CPLUS_MARKER,'\0' };
91 static const char vb_name[] = { '_','v','b',CPLUS_MARKER,'\0' };
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. */
98 #ifndef BELIEVE_PCC_PROMOTION
99 #define BELIEVE_PCC_PROMOTION 0
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. */
108 static char *long_kludge_name;
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;
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. */
117 #define INITIAL_CONTEXT_STACK_SIZE 10
118 #define INITIAL_TYPE_VECTOR_LENGTH 160
119 #define INITIAL_LINE_VECTOR_LENGTH 1000
121 /* Complaints about the symbols we have encountered. */
123 struct complaint innerblock_complaint =
124 {"inner block not inside outer block in %s", 0, 0};
126 struct complaint innerblock_anon_complaint =
127 {"inner block not inside outer block", 0, 0};
129 struct complaint blockvector_complaint =
130 {"block at 0x%x out of order", 0, 0};
133 struct complaint dbx_class_complaint =
134 {"encountered DBX-style class variable debugging information.\n\
135 You seem to have compiled your program with \
136 \"g++ -g0\" instead of \"g++ -g\".\n\
137 Therefore GDB will not know about your class variables", 0, 0};
140 struct complaint invalid_cpp_abbrev_complaint =
141 {"invalid C++ abbreviation `%s'", 0, 0};
143 struct complaint invalid_cpp_type_complaint =
144 {"C++ abbreviated type name unknown at symtab pos %d", 0, 0};
146 struct complaint member_fn_complaint =
147 {"member function type missing, got '%c'", 0, 0};
149 struct complaint const_vol_complaint =
150 {"const/volatile indicator missing, got '%c'", 0, 0};
152 struct complaint error_type_complaint =
153 {"debug info mismatch between compiler and debugger", 0, 0};
155 struct complaint invalid_member_complaint =
156 {"invalid (minimal) member type data format at symtab pos %d.", 0, 0};
158 struct complaint range_type_base_complaint =
159 {"base type %d of range type is not defined", 0, 0};
161 struct complaint reg_value_complaint =
162 {"register number too large in symbol %s", 0, 0};
168 register char *p = name;
169 register int total = p[0];
182 /* Ensure result is positive. */
183 if (total < 0) total += (1000 << 6);
184 return total % HASHSIZE;
188 /* Look up a dbx type-number pair. Return the address of the slot
189 where the type for that number-pair is stored.
190 The number-pair is in TYPENUMS.
192 This can be used for finding the type associated with that pair
193 or for associating a new type with the pair. */
196 dbx_lookup_type (typenums)
199 register int filenum = typenums[0], index = typenums[1];
202 if (filenum == -1) /* -1,-1 is for temporary types. */
205 if (filenum < 0 || filenum >= n_this_object_header_files)
206 error ("Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.",
207 filenum, index, symnum);
211 /* Type is defined outside of header files.
212 Find it in this object file's type vector. */
213 if (index >= type_vector_length)
215 old_len = type_vector_length;
217 type_vector_length = INITIAL_TYPE_VECTOR_LENGTH;
218 type_vector = (struct type **)
219 malloc (type_vector_length * sizeof (struct type *));
221 while (index >= type_vector_length)
222 type_vector_length *= 2;
223 type_vector = (struct type **)
224 xrealloc ((char *) type_vector,
225 (type_vector_length * sizeof (struct type *)));
226 memset (&type_vector[old_len], 0,
227 (type_vector_length - old_len) * sizeof (struct type *));
229 return &type_vector[index];
233 register int real_filenum = this_object_header_files[filenum];
234 register struct header_file *f;
237 if (real_filenum >= n_header_files)
240 f = &header_files[real_filenum];
242 f_orig_length = f->length;
243 if (index >= f_orig_length)
245 while (index >= f->length)
247 f->vector = (struct type **)
248 xrealloc ((char *) f->vector, f->length * sizeof (struct type *));
249 memset (&f->vector[f_orig_length], 0,
250 (f->length - f_orig_length) * sizeof (struct type *));
252 return &f->vector[index];
256 /* Make sure there is a type allocated for type numbers TYPENUMS
257 and return the type object.
258 This can create an empty (zeroed) type object.
259 TYPENUMS may be (-1, -1) to return a new type object that is not
260 put into the type vector, and so may not be referred to by number. */
263 dbx_alloc_type (typenums, objfile)
265 struct objfile *objfile;
267 register struct type **type_addr;
269 if (typenums[0] == -1)
270 return alloc_type (objfile);
272 type_addr = dbx_lookup_type (typenums);
274 /* If we are referring to a type not known at all yet,
275 allocate an empty type for it.
276 We will fill it in later if we find out how. */
278 *type_addr = alloc_type (objfile);
283 /* maintain the lists of symbols and blocks */
285 /* Add a symbol to one of the lists of symbols. */
287 add_symbol_to_list (symbol, listhead)
288 struct symbol *symbol;
289 struct pending **listhead;
291 /* We keep PENDINGSIZE symbols in each link of the list.
292 If we don't have a link with room in it, add a new link. */
293 if (*listhead == 0 || (*listhead)->nsyms == PENDINGSIZE)
295 register struct pending *link;
298 link = free_pendings;
299 free_pendings = link->next;
302 link = (struct pending *) xmalloc (sizeof (struct pending));
304 link->next = *listhead;
309 (*listhead)->symbol[(*listhead)->nsyms++] = symbol;
312 /* Find a symbol on a pending list. */
314 find_symbol_in_list (list, name, length)
315 struct pending *list;
322 for (j = list->nsyms; --j >= 0; ) {
323 char *pp = SYMBOL_NAME (list->symbol[j]);
324 if (*pp == *name && strncmp (pp, name, length) == 0 && pp[length] == '\0')
325 return list->symbol[j];
332 /* At end of reading syms, or in case of quit,
333 really free as many `struct pending's as we can easily find. */
337 really_free_pendings (foo)
340 struct pending *next, *next1;
342 struct pending_block *bnext, *bnext1;
345 for (next = free_pendings; next; next = next1)
352 #if 0 /* Now we make the links in the symbol_obstack, so don't free them. */
353 for (bnext = pending_blocks; bnext; bnext = bnext1)
355 bnext1 = bnext->next;
361 for (next = file_symbols; next; next = next1)
368 for (next = global_symbols; next; next = next1)
376 /* Take one of the lists of symbols and make a block from it.
377 Keep the order the symbols have in the list (reversed from the input file).
378 Put the block on the list of pending blocks. */
381 finish_block (symbol, listhead, old_blocks, start, end, objfile)
382 struct symbol *symbol;
383 struct pending **listhead;
384 struct pending_block *old_blocks;
385 CORE_ADDR start, end;
386 struct objfile *objfile;
388 register struct pending *next, *next1;
389 register struct block *block;
390 register struct pending_block *pblock;
391 struct pending_block *opblock;
394 /* Count the length of the list of symbols. */
396 for (next = *listhead, i = 0;
398 i += next->nsyms, next = next->next)
401 block = (struct block *) obstack_alloc (&objfile -> symbol_obstack,
402 (sizeof (struct block) + ((i - 1) * sizeof (struct symbol *))));
404 /* Copy the symbols into the block. */
406 BLOCK_NSYMS (block) = i;
407 for (next = *listhead; next; next = next->next)
410 for (j = next->nsyms - 1; j >= 0; j--)
411 BLOCK_SYM (block, --i) = next->symbol[j];
414 BLOCK_START (block) = start;
415 BLOCK_END (block) = end;
416 BLOCK_SUPERBLOCK (block) = 0; /* Filled in when containing block is made */
417 BLOCK_GCC_COMPILED (block) = processing_gcc_compilation;
419 /* Put the block in as the value of the symbol that names it. */
423 SYMBOL_BLOCK_VALUE (symbol) = block;
424 BLOCK_FUNCTION (block) = symbol;
427 BLOCK_FUNCTION (block) = 0;
429 /* Now "free" the links of the list, and empty the list. */
431 for (next = *listhead; next; next = next1)
434 next->next = free_pendings;
435 free_pendings = next;
439 /* Install this block as the superblock
440 of all blocks made since the start of this scope
441 that don't have superblocks yet. */
444 for (pblock = pending_blocks; pblock != old_blocks; pblock = pblock->next)
446 if (BLOCK_SUPERBLOCK (pblock->block) == 0) {
448 /* Check to be sure the blocks are nested as we receive them.
449 If the compiler/assembler/linker work, this just burns a small
451 if (BLOCK_START (pblock->block) < BLOCK_START (block)
452 || BLOCK_END (pblock->block) > BLOCK_END (block)) {
454 complain(&innerblock_complaint, SYMBOL_NAME (symbol));
456 complain(&innerblock_anon_complaint, 0);
457 BLOCK_START (pblock->block) = BLOCK_START (block);
458 BLOCK_END (pblock->block) = BLOCK_END (block);
461 BLOCK_SUPERBLOCK (pblock->block) = block;
466 /* Record this block on the list of all blocks in the file.
467 Put it after opblock, or at the beginning if opblock is 0.
468 This puts the block in the list after all its subblocks. */
470 /* Allocate in the symbol_obstack to save time.
471 It wastes a little space. */
472 pblock = (struct pending_block *)
473 obstack_alloc (&objfile -> symbol_obstack,
474 sizeof (struct pending_block));
475 pblock->block = block;
478 pblock->next = opblock->next;
479 opblock->next = pblock;
483 pblock->next = pending_blocks;
484 pending_blocks = pblock;
488 static struct blockvector *
489 make_blockvector (objfile)
490 struct objfile *objfile;
492 register struct pending_block *next;
493 register struct blockvector *blockvector;
496 /* Count the length of the list of blocks. */
498 for (next = pending_blocks, i = 0; next; next = next->next, i++);
500 blockvector = (struct blockvector *)
501 obstack_alloc (&objfile -> symbol_obstack,
502 (sizeof (struct blockvector)
503 + (i - 1) * sizeof (struct block *)));
505 /* Copy the blocks into the blockvector.
506 This is done in reverse order, which happens to put
507 the blocks into the proper order (ascending starting address).
508 finish_block has hair to insert each block into the list
509 after its subblocks in order to make sure this is true. */
511 BLOCKVECTOR_NBLOCKS (blockvector) = i;
512 for (next = pending_blocks; next; next = next->next) {
513 BLOCKVECTOR_BLOCK (blockvector, --i) = next->block;
516 #if 0 /* Now we make the links in the obstack, so don't free them. */
517 /* Now free the links of the list, and empty the list. */
519 for (next = pending_blocks; next; next = next1)
527 #if 1 /* FIXME, shut this off after a while to speed up symbol reading. */
528 /* Some compilers output blocks in the wrong order, but we depend
529 on their being in the right order so we can binary search.
530 Check the order and moan about it. FIXME. */
531 if (BLOCKVECTOR_NBLOCKS (blockvector) > 1)
532 for (i = 1; i < BLOCKVECTOR_NBLOCKS (blockvector); i++) {
533 if (BLOCK_START(BLOCKVECTOR_BLOCK (blockvector, i-1))
534 > BLOCK_START(BLOCKVECTOR_BLOCK (blockvector, i))) {
535 complain (&blockvector_complaint,
536 (char *) BLOCK_START(BLOCKVECTOR_BLOCK (blockvector, i)));
544 /* Start recording information about source code that came from an included
545 (or otherwise merged-in) source file with a different name. */
548 start_subfile (name, dirname)
552 register struct subfile *subfile;
554 /* See if this subfile is already known as a subfile of the
555 current main source file. */
557 for (subfile = subfiles; subfile; subfile = subfile->next)
559 if (!strcmp (subfile->name, name))
561 current_subfile = subfile;
566 /* This subfile is not known. Add an entry for it.
567 Make an entry for this subfile in the list of all subfiles
568 of the current main source file. */
570 subfile = (struct subfile *) xmalloc (sizeof (struct subfile));
571 subfile->next = subfiles;
573 current_subfile = subfile;
575 /* Save its name and compilation directory name */
576 subfile->name = strdup (name);
578 subfile->dirname = NULL;
580 subfile->dirname = strdup (dirname);
582 /* Initialize line-number recording for this subfile. */
583 subfile->line_vector = 0;
586 /* Handle the N_BINCL and N_EINCL symbol types
587 that act like N_SOL for switching source files
588 (different subfiles, as we call them) within one object file,
589 but using a stack rather than in an arbitrary order. */
594 register struct subfile_stack *tem
595 = (struct subfile_stack *) xmalloc (sizeof (struct subfile_stack));
597 tem->next = subfile_stack;
599 if (current_subfile == 0 || current_subfile->name == 0)
601 tem->name = current_subfile->name;
608 register struct subfile_stack *link = subfile_stack;
614 subfile_stack = link->next;
620 /* Manage the vector of line numbers for each subfile. */
623 record_line (subfile, line, pc)
624 register struct subfile *subfile;
628 struct linetable_entry *e;
629 /* Ignore the dummy line number in libg.o */
634 /* Make sure line vector exists and is big enough. */
635 if (!subfile->line_vector) {
636 subfile->line_vector_length = INITIAL_LINE_VECTOR_LENGTH;
637 subfile->line_vector = (struct linetable *)
638 xmalloc (sizeof (struct linetable)
639 + subfile->line_vector_length * sizeof (struct linetable_entry));
640 subfile->line_vector->nitems = 0;
643 if (subfile->line_vector->nitems + 1 >= subfile->line_vector_length)
645 subfile->line_vector_length *= 2;
646 subfile->line_vector = (struct linetable *)
647 xrealloc ((char *) subfile->line_vector, (sizeof (struct linetable)
648 + subfile->line_vector_length * sizeof (struct linetable_entry)));
651 e = subfile->line_vector->item + subfile->line_vector->nitems++;
652 e->line = line; e->pc = pc;
656 /* Needed in order to sort line tables from IBM xcoff files. Sigh! */
659 compare_line_numbers (ln1p, ln2p)
663 return (((struct linetable_entry *) ln1p) -> line -
664 ((struct linetable_entry *) ln2p) -> line);
668 /* Start a new symtab for a new source file.
669 This is called when a dbx symbol of type N_SO is seen;
670 it indicates the start of data for one original source file. */
673 start_symtab (name, dirname, start_addr)
676 CORE_ADDR start_addr;
679 last_source_file = name;
680 last_source_start_addr = start_addr;
683 global_stabs = 0; /* AIX COFF */
686 /* Context stack is initially empty. Allocate first one with room for
687 10 levels; reuse it forever afterward. */
688 if (context_stack == 0) {
689 context_stack_size = INITIAL_CONTEXT_STACK_SIZE;
690 context_stack = (struct context_stack *)
691 xmalloc (context_stack_size * sizeof (struct context_stack));
693 context_stack_depth = 0;
695 /* Leave FILENUM of 0 free for builtin types and this file's types. */
696 n_this_object_header_files = 1;
698 type_vector_length = 0;
699 type_vector = (struct type **) 0;
701 /* Initialize the list of sub source files with one entry
702 for this file (the top-level source file). */
706 start_subfile (name, dirname);
709 /* for all the stabs in a given stab vector, build appropriate types
710 and fix their symbols in given symbol vector. */
713 patch_block_stabs (symbols, stabs, objfile)
714 struct pending *symbols;
715 struct pending_stabs *stabs;
716 struct objfile *objfile;
723 /* for all the stab entries, find their corresponding symbols and
724 patch their types! */
726 for (ii = 0; ii < stabs->count; ++ii)
728 char *name = stabs->stab[ii];
729 char *pp = (char*) strchr (name, ':');
730 struct symbol *sym = find_symbol_in_list (symbols, name, pp-name);
733 #ifndef IBM6000_TARGET
734 printf ("ERROR! stab symbol not found!\n"); /* FIXME */
740 if (*(pp-1) == 'F' || *(pp-1) == 'f')
743 lookup_function_type (read_type (&pp, objfile));
747 SYMBOL_TYPE (sym) = read_type (&pp, objfile);
754 /* Finish the symbol definitions for one main source file,
755 close off all the lexical contexts for that file
756 (creating struct block's for them), then make the struct symtab
757 for that file and put it in the list of all such.
759 END_ADDR is the address of the end of the file's text. */
762 end_symtab (end_addr, sort_pending, sort_linevec, objfile)
766 struct objfile *objfile;
768 register struct symtab *symtab;
769 register struct blockvector *blockvector;
770 register struct subfile *subfile;
771 struct subfile *nextsub;
773 /* Finish the lexical context of the last function in the file;
774 pop the context stack. */
776 if (context_stack_depth > 0)
778 register struct context_stack *cstk;
779 context_stack_depth--;
780 cstk = &context_stack[context_stack_depth];
781 /* Make a block for the local symbols within. */
782 finish_block (cstk->name, &local_symbols, cstk->old_blocks,
783 cstk->start_addr, end_addr, objfile);
785 /* Debug: if context stack still has something in it, we are in
787 if (context_stack_depth > 0)
791 /* It is unfortunate that in aixcoff, pending blocks might not be ordered
792 in this stage. Especially, blocks for static functions will show up at
793 the end. We need to sort them, so tools like `find_pc_function' and
794 `find_pc_block' can work reliably. */
795 if (sort_pending && pending_blocks) {
796 /* FIXME! Remove this horrid bubble sort and use qsort!!! */
799 struct pending_block *pb, *pbnext;
801 pb = pending_blocks, pbnext = pb->next;
806 /* swap blocks if unordered! */
808 if (BLOCK_START(pb->block) < BLOCK_START(pbnext->block)) {
809 struct block *tmp = pb->block;
810 pb->block = pbnext->block;
815 pbnext = pbnext->next;
820 /* Cleanup any undefined types that have been left hanging around
821 (this needs to be done before the finish_blocks so that
822 file_symbols is still good). */
823 cleanup_undefined_types ();
826 patch_block_stabs (global_symbols, global_stabs, objfile);
827 free ((PTR)global_stabs);
831 if (pending_blocks == 0
833 && global_symbols == 0) {
834 /* Ignore symtabs that have no functions with real debugging info */
837 /* Define the STATIC_BLOCK and GLOBAL_BLOCK, and build the blockvector. */
838 finish_block (0, &file_symbols, 0, last_source_start_addr, end_addr, objfile);
839 finish_block (0, &global_symbols, 0, last_source_start_addr, end_addr, objfile);
840 blockvector = make_blockvector (objfile);
843 #ifdef PROCESS_LINENUMBER_HOOK
844 PROCESS_LINENUMBER_HOOK (); /* Needed for aixcoff. */
847 /* Now create the symtab objects proper, one for each subfile. */
848 /* (The main file is the last one on the chain.) */
850 for (subfile = subfiles; subfile; subfile = nextsub)
853 /* If we have blocks of symbols, make a symtab.
854 Otherwise, just ignore this file and any line number info in it. */
857 if (subfile->line_vector) {
858 /* First, shrink the linetable to make more memory. */
859 linetablesize = sizeof (struct linetable) +
860 subfile->line_vector->nitems * sizeof (struct linetable_entry);
861 subfile->line_vector = (struct linetable *)
862 xrealloc ((char *) subfile->line_vector, linetablesize);
865 qsort (subfile->line_vector->item, subfile->line_vector->nitems,
866 sizeof (struct linetable_entry), compare_line_numbers);
869 /* Now, allocate a symbol table. */
870 symtab = allocate_symtab (subfile->name, objfile);
872 /* Fill in its components. */
873 symtab->blockvector = blockvector;
874 if (subfile->line_vector)
876 /* Reallocate the line table on the symbol obstack */
877 symtab->linetable = (struct linetable *)
878 obstack_alloc (&objfile -> symbol_obstack, linetablesize);
879 memcpy (symtab->linetable, subfile->line_vector, linetablesize);
883 symtab->linetable = NULL;
885 symtab->dirname = subfile->dirname;
886 symtab->free_code = free_linetable;
887 symtab->free_ptr = 0;
889 #ifdef IBM6000_TARGET
890 /* In case we need to duplicate symbol tables (to represent include
891 files), and in case our system needs relocation, we want to
892 relocate the main symbol table node only (for the main file,
893 not for the include files). */
895 symtab->nonreloc = TRUE;
898 if (subfile->line_vector)
899 free ((PTR)subfile->line_vector);
901 nextsub = subfile->next;
905 #ifdef IBM6000_TARGET
906 /* all include symbol tables are non-relocatable, except the main source
909 symtab->nonreloc = FALSE;
913 free ((char *) type_vector);
915 type_vector_length = 0;
917 last_source_file = 0;
919 previous_stab_code = 0;
925 /* Push a context block. Args are an identifying nesting level (checkable
926 when you pop it), and the starting PC address of this context. */
928 struct context_stack *
929 push_context (desc, valu)
933 register struct context_stack *new;
935 if (context_stack_depth == context_stack_size)
937 context_stack_size *= 2;
938 context_stack = (struct context_stack *)
939 xrealloc ((char *) context_stack,
940 (context_stack_size * sizeof (struct context_stack)));
943 new = &context_stack[context_stack_depth++];
945 new->locals = local_symbols;
946 new->old_blocks = pending_blocks;
947 new->start_addr = valu;
955 /* Initialize anything that needs initializing when starting to read
956 a fresh piece of a symbol file, e.g. reading in the stuff corresponding
968 /* Initialize anything that needs initializing when a completely new
969 symbol file is specified (not just adding some symbols from another
970 file, e.g. a shared library). */
975 /* Empty the hash table of global syms looking for values. */
976 memset (global_sym_chain, 0, sizeof global_sym_chain);
981 /* Scan through all of the global symbols defined in the object file,
982 assigning values to the debugging symbols that need to be assigned
983 to. Get these symbols from the minimal symbol table. */
986 scan_file_globals (objfile)
987 struct objfile *objfile;
990 struct minimal_symbol *msymbol;
991 struct symbol *sym, *prev;
993 if (objfile->msymbols == 0) /* Beware the null file. */
996 for (msymbol = objfile -> msymbols; msymbol -> name != NULL; msymbol++)
1000 prev = (struct symbol *) 0;
1002 /* Get the hash index and check all the symbols
1003 under that hash index. */
1005 hash = hashname (msymbol -> name);
1007 for (sym = global_sym_chain[hash]; sym;)
1009 if (*(msymbol -> name) == SYMBOL_NAME (sym)[0]
1010 && !strcmp(msymbol -> name + 1, SYMBOL_NAME (sym) + 1))
1012 /* Splice this symbol out of the hash chain and
1013 assign the value we have to it. */
1015 SYMBOL_VALUE_CHAIN (prev) = SYMBOL_VALUE_CHAIN (sym);
1017 global_sym_chain[hash] = SYMBOL_VALUE_CHAIN (sym);
1019 /* Check to see whether we need to fix up a common block. */
1020 /* Note: this code might be executed several times for
1021 the same symbol if there are multiple references. */
1022 if (SYMBOL_CLASS (sym) == LOC_BLOCK)
1023 fix_common_block (sym, msymbol -> address);
1025 SYMBOL_VALUE_ADDRESS (sym) = msymbol -> address;
1028 sym = SYMBOL_VALUE_CHAIN (prev);
1030 sym = global_sym_chain[hash];
1035 sym = SYMBOL_VALUE_CHAIN (sym);
1042 /* Read a number by which a type is referred to in dbx data,
1043 or perhaps read a pair (FILENUM, TYPENUM) in parentheses.
1044 Just a single number N is equivalent to (0,N).
1045 Return the two numbers by storing them in the vector TYPENUMS.
1046 TYPENUMS will then be used as an argument to dbx_lookup_type. */
1049 read_type_number (pp, typenums)
1051 register int *typenums;
1056 typenums[0] = read_number (pp, ',');
1057 typenums[1] = read_number (pp, ')');
1062 typenums[1] = read_number (pp, 0);
1066 /* To handle GNU C++ typename abbreviation, we need to be able to
1067 fill in a type's name as soon as space for that type is allocated.
1068 `type_synonym_name' is the name of the type being allocated.
1069 It is cleared as soon as it is used (lest all allocated types
1071 static char *type_synonym_name;
1075 define_symbol (valu, string, desc, type, objfile)
1080 struct objfile *objfile;
1082 register struct symbol *sym;
1083 char *p = (char *) strchr (string, ':');
1087 struct type *temptype;
1089 /* We would like to eliminate nameless symbols, but keep their types.
1090 E.g. stab entry ":t10=*2" should produce a type 10, which is a pointer
1091 to type 2, but, should not creat a symbol to address that type. Since
1092 the symbol will be nameless, there is no way any user can refer to it. */
1096 /* Ignore syms with empty names. */
1100 /* Ignore old-style symbols from cc -go */
1104 /* If a nameless stab entry, all we need is the type, not the symbol.
1106 nameless = (p == string);
1108 sym = (struct symbol *)obstack_alloc (&objfile -> symbol_obstack, sizeof (struct symbol));
1110 if (processing_gcc_compilation) {
1111 /* GCC 2.x puts the line number in desc. SunOS apparently puts in the
1112 number of bytes occupied by a type or object, which we ignore. */
1113 SYMBOL_LINE(sym) = desc;
1115 SYMBOL_LINE(sym) = 0; /* unknown */
1118 if (string[0] == CPLUS_MARKER)
1120 /* Special GNU C++ names. */
1124 SYMBOL_NAME (sym) = obsavestring ("this", strlen ("this"),
1125 &objfile -> symbol_obstack);
1127 case 'v': /* $vtbl_ptr_type */
1128 /* Was: SYMBOL_NAME (sym) = "vptr"; */
1131 SYMBOL_NAME (sym) = obsavestring ("eh_throw", strlen ("eh_throw"),
1132 &objfile -> symbol_obstack);
1136 /* This was an anonymous type that was never fixed up. */
1147 = (char *) obstack_alloc (&objfile -> symbol_obstack, ((p - string) + 1));
1148 /* Open-coded bcopy--saves function call time. */
1150 register char *p1 = string;
1151 register char *p2 = SYMBOL_NAME (sym);
1158 /* Determine the type of name being defined. */
1159 /* The Acorn RISC machine's compiler can put out locals that don't
1160 start with "234=" or "(3,4)=", so assume anything other than the
1161 deftypes we know how to handle is a local. */
1162 /* (Peter Watkins @ Computervision)
1163 Handle Sun-style local fortran array types 'ar...' .
1167 #ifdef IBM6000_TARGET
1169 /* 'R' is for register parameters. */
1171 if (!strchr ("cfFGpPrStTvVXCR", *p))
1174 if (!strchr ("cfFGpPrStTvVXC", *p))
1180 /* c is a special case, not followed by a type-number.
1181 SYMBOL:c=iVALUE for an integer constant symbol.
1182 SYMBOL:c=rVALUE for a floating constant symbol.
1183 SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol.
1184 e.g. "b:c=e6,0" for "const b = blob1"
1185 (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
1189 error ("Invalid symbol data at symtab pos %d.", symnum);
1194 double d = atof (p);
1197 SYMBOL_TYPE (sym) = lookup_fundamental_type (objfile,
1200 obstack_alloc (&objfile -> type_obstack,
1202 memcpy (dbl_valu, &d, sizeof (double));
1203 SWAP_TARGET_AND_HOST (dbl_valu, sizeof (double));
1204 SYMBOL_VALUE_BYTES (sym) = dbl_valu;
1205 SYMBOL_CLASS (sym) = LOC_CONST_BYTES;
1210 SYMBOL_TYPE (sym) = lookup_fundamental_type (objfile,
1212 SYMBOL_VALUE (sym) = atoi (p);
1213 SYMBOL_CLASS (sym) = LOC_CONST;
1217 /* SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol.
1218 e.g. "b:c=e6,0" for "const b = blob1"
1219 (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
1223 read_type_number (&p, typenums);
1225 error ("Invalid symbol data: no comma in enum const symbol");
1227 SYMBOL_TYPE (sym) = *dbx_lookup_type (typenums);
1228 SYMBOL_VALUE (sym) = atoi (p);
1229 SYMBOL_CLASS (sym) = LOC_CONST;
1233 error ("Invalid symbol data at symtab pos %d.", symnum);
1235 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1236 add_symbol_to_list (sym, &file_symbols);
1240 /* Now usually comes a number that says which data type,
1241 and possibly more stuff to define the type
1242 (all of which is handled by read_type) */
1244 if (deftype == 'p' && *p == 'F')
1245 /* pF is a two-letter code that means a function parameter in Fortran.
1246 The type-number specifies the type of the return value.
1247 Translate it into a pointer-to-function type. */
1251 = lookup_pointer_type (lookup_function_type (read_type (&p, objfile)));
1254 #ifdef IBM6000_TARGET
1255 else if (deftype == 'R')
1256 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1261 /* The symbol class letter is followed by a type (typically the
1262 type of the symbol, or its return-type, or etc). Read it. */
1264 synonym = *p == 't';
1269 type_synonym_name = obsavestring (SYMBOL_NAME (sym),
1270 strlen (SYMBOL_NAME (sym)),
1271 &objfile -> symbol_obstack);
1274 /* Here we save the name of the symbol for read_range_type, which
1275 ends up reading in the basic types. In stabs, unfortunately there
1276 is no distinction between "int" and "long" types except their
1277 names. Until we work out a saner type policy (eliminating most
1278 builtin types and using the names specified in the files), we
1279 save away the name so that far away from here in read_range_type,
1280 we can examine it to decide between "int" and "long". FIXME. */
1281 long_kludge_name = SYMBOL_NAME (sym);
1283 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1289 /* The name of a caught exception. */
1290 SYMBOL_CLASS (sym) = LOC_LABEL;
1291 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1292 SYMBOL_VALUE_ADDRESS (sym) = valu;
1293 add_symbol_to_list (sym, &local_symbols);
1297 /* A static function definition. */
1298 SYMBOL_CLASS (sym) = LOC_BLOCK;
1299 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1300 add_symbol_to_list (sym, &file_symbols);
1301 /* fall into process_function_types. */
1303 process_function_types:
1304 /* Function result types are described as the result type in stabs.
1305 We need to convert this to the function-returning-type-X type
1306 in GDB. E.g. "int" is converted to "function returning int". */
1307 if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_FUNC)
1310 /* This code doesn't work -- it needs to realloc and can't. */
1311 /* Attempt to set up to record a function prototype... */
1312 struct type *new = (struct type *)
1313 obstack_alloc (&objfile -> type_obstack,
1314 sizeof (struct type));
1316 /* Generate a template for the type of this function. The
1317 types of the arguments will be added as we read the symbol
1319 *new = *lookup_function_type (SYMBOL_TYPE(sym));
1320 SYMBOL_TYPE(sym) = new;
1321 TYPE_OBJFILE (new) = objfile;
1322 in_function_type = new;
1324 SYMBOL_TYPE (sym) = lookup_function_type (SYMBOL_TYPE (sym));
1327 /* fall into process_prototype_types */
1329 process_prototype_types:
1330 /* Sun acc puts declared types of arguments here. We don't care
1331 about their actual types (FIXME -- we should remember the whole
1332 function prototype), but the list may define some new types
1333 that we have to remember, so we must scan it now. */
1336 read_type (&p, objfile);
1341 /* A global function definition. */
1342 SYMBOL_CLASS (sym) = LOC_BLOCK;
1343 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1344 add_symbol_to_list (sym, &global_symbols);
1345 goto process_function_types;
1348 /* For a class G (global) symbol, it appears that the
1349 value is not correct. It is necessary to search for the
1350 corresponding linker definition to find the value.
1351 These definitions appear at the end of the namelist. */
1352 i = hashname (SYMBOL_NAME (sym));
1353 SYMBOL_VALUE_CHAIN (sym) = global_sym_chain[i];
1354 global_sym_chain[i] = sym;
1355 SYMBOL_CLASS (sym) = LOC_STATIC;
1356 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1357 add_symbol_to_list (sym, &global_symbols);
1360 /* This case is faked by a conditional above,
1361 when there is no code letter in the dbx data.
1362 Dbx data never actually contains 'l'. */
1364 SYMBOL_CLASS (sym) = LOC_LOCAL;
1365 SYMBOL_VALUE (sym) = valu;
1366 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1367 add_symbol_to_list (sym, &local_symbols);
1371 /* Normally this is a parameter, a LOC_ARG. On the i960, it
1372 can also be a LOC_LOCAL_ARG depending on symbol type. */
1373 #ifndef DBX_PARM_SYMBOL_CLASS
1374 #define DBX_PARM_SYMBOL_CLASS(type) LOC_ARG
1376 SYMBOL_CLASS (sym) = DBX_PARM_SYMBOL_CLASS (type);
1377 SYMBOL_VALUE (sym) = valu;
1378 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1380 /* This doesn't work yet. */
1381 add_param_to_type (&in_function_type, sym);
1383 add_symbol_to_list (sym, &local_symbols);
1385 /* If it's gcc-compiled, if it says `short', believe it. */
1386 if (processing_gcc_compilation || BELIEVE_PCC_PROMOTION)
1389 #if defined(BELIEVE_PCC_PROMOTION_TYPE)
1390 /* This macro is defined on machines (e.g. sparc) where
1391 we should believe the type of a PCC 'short' argument,
1392 but shouldn't believe the address (the address is
1393 the address of the corresponding int). Note that
1394 this is only different from the BELIEVE_PCC_PROMOTION
1395 case on big-endian machines.
1397 My guess is that this correction, as opposed to changing
1398 the parameter to an 'int' (as done below, for PCC
1399 on most machines), is the right thing to do
1400 on all machines, but I don't want to risk breaking
1401 something that already works. On most PCC machines,
1402 the sparc problem doesn't come up because the calling
1403 function has to zero the top bytes (not knowing whether
1404 the called function wants an int or a short), so there
1405 is no practical difference between an int and a short
1406 (except perhaps what happens when the GDB user types
1407 "print short_arg = 0x10000;").
1410 actually produces the correct address (we don't need to fix it
1411 up). I made this code adapt so that it will offset the symbol
1412 if it was pointing at an int-aligned location and not
1413 otherwise. This way you can use the same gdb for 4.0.x and
1416 If the parameter is shorter than an int, and is integral
1417 (e.g. char, short, or unsigned equivalent), and is claimed to
1418 be passed on an integer boundary, don't believe it! Offset the
1419 parameter's address to the tail-end of that integer. */
1421 temptype = lookup_fundamental_type (objfile, FT_INTEGER);
1422 if (TYPE_LENGTH (SYMBOL_TYPE (sym)) < TYPE_LENGTH (temptype)
1423 && TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_INT
1424 && 0 == SYMBOL_VALUE (sym) % TYPE_LENGTH (temptype))
1426 SYMBOL_VALUE (sym) += TYPE_LENGTH (temptype)
1427 - TYPE_LENGTH (SYMBOL_TYPE (sym));
1431 #else /* no BELIEVE_PCC_PROMOTION_TYPE. */
1433 /* If PCC says a parameter is a short or a char,
1434 it is really an int. */
1435 temptype = lookup_fundamental_type (objfile, FT_INTEGER);
1436 if (TYPE_LENGTH (SYMBOL_TYPE (sym)) < TYPE_LENGTH (temptype)
1437 && TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_INT)
1439 SYMBOL_TYPE (sym) = TYPE_UNSIGNED (SYMBOL_TYPE (sym))
1440 ? lookup_fundamental_type (objfile, FT_UNSIGNED_INTEGER)
1445 #endif /* no BELIEVE_PCC_PROMOTION_TYPE. */
1448 /* acc seems to use P to delare the prototypes of functions that
1449 are referenced by this file. gdb is not prepared to deal
1450 with this extra information. FIXME, it ought to. */
1452 goto process_prototype_types;
1454 /* Parameter which is in a register. */
1455 SYMBOL_CLASS (sym) = LOC_REGPARM;
1456 SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
1457 if (SYMBOL_VALUE (sym) >= NUM_REGS)
1459 complain (®_value_complaint, SYMBOL_NAME (sym));
1460 SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */
1462 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1463 add_symbol_to_list (sym, &local_symbols);
1466 #ifdef IBM6000_TARGET
1470 /* Register variable (either global or local). */
1471 SYMBOL_CLASS (sym) = LOC_REGISTER;
1472 SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
1473 if (SYMBOL_VALUE (sym) >= NUM_REGS)
1475 complain (®_value_complaint, SYMBOL_NAME (sym));
1476 SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */
1478 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1479 if (within_function)
1480 add_symbol_to_list (sym, &local_symbols);
1482 add_symbol_to_list (sym, &file_symbols);
1486 /* Static symbol at top level of file */
1487 SYMBOL_CLASS (sym) = LOC_STATIC;
1488 SYMBOL_VALUE_ADDRESS (sym) = valu;
1489 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1490 add_symbol_to_list (sym, &file_symbols);
1494 /* For a nameless type, we don't want a create a symbol, thus we
1495 did not use `sym'. Return without further processing. */
1496 if (nameless) return NULL;
1498 SYMBOL_CLASS (sym) = LOC_TYPEDEF;
1499 SYMBOL_VALUE (sym) = valu;
1500 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1501 /* C++ vagaries: we may have a type which is derived from
1502 a base type which did not have its name defined when the
1503 derived class was output. We fill in the derived class's
1504 base part member's name here in that case. */
1505 if (TYPE_NAME (SYMBOL_TYPE (sym)) != NULL)
1506 if ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
1507 || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION)
1508 && TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)))
1511 for (j = TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)) - 1; j >= 0; j--)
1512 if (TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) == 0)
1513 TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) =
1514 type_name_no_tag (TYPE_BASECLASS (SYMBOL_TYPE (sym), j));
1517 add_symbol_to_list (sym, &file_symbols);
1521 /* For a nameless type, we don't want a create a symbol, thus we
1522 did not use `sym'. Return without further processing. */
1523 if (nameless) return NULL;
1525 SYMBOL_CLASS (sym) = LOC_TYPEDEF;
1526 SYMBOL_VALUE (sym) = valu;
1527 SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE;
1528 if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)
1529 TYPE_NAME (SYMBOL_TYPE (sym))
1530 = obconcat (&objfile -> type_obstack, "",
1531 (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_ENUM
1533 : (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
1534 ? "struct " : "union ")),
1536 add_symbol_to_list (sym, &file_symbols);
1540 register struct symbol *typedef_sym = (struct symbol *)
1541 obstack_alloc (&objfile -> type_obstack,
1542 sizeof (struct symbol));
1543 SYMBOL_NAME (typedef_sym) = SYMBOL_NAME (sym);
1544 SYMBOL_TYPE (typedef_sym) = SYMBOL_TYPE (sym);
1546 SYMBOL_CLASS (typedef_sym) = LOC_TYPEDEF;
1547 SYMBOL_VALUE (typedef_sym) = valu;
1548 SYMBOL_NAMESPACE (typedef_sym) = VAR_NAMESPACE;
1549 add_symbol_to_list (typedef_sym, &file_symbols);
1554 /* Static symbol of local scope */
1555 SYMBOL_CLASS (sym) = LOC_STATIC;
1556 SYMBOL_VALUE_ADDRESS (sym) = valu;
1557 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1558 add_symbol_to_list (sym, &local_symbols);
1562 /* Reference parameter */
1563 SYMBOL_CLASS (sym) = LOC_REF_ARG;
1564 SYMBOL_VALUE (sym) = valu;
1565 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1566 add_symbol_to_list (sym, &local_symbols);
1570 /* This is used by Sun FORTRAN for "function result value".
1571 Sun claims ("dbx and dbxtool interfaces", 2nd ed)
1572 that Pascal uses it too, but when I tried it Pascal used
1573 "x:3" (local symbol) instead. */
1574 SYMBOL_CLASS (sym) = LOC_LOCAL;
1575 SYMBOL_VALUE (sym) = valu;
1576 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1577 add_symbol_to_list (sym, &local_symbols);
1581 error ("Invalid symbol data: unknown symbol-type code `%c' at symtab pos %d.", deftype, symnum);
1586 /* What about types defined as forward references inside of a small lexical
1588 /* Add a type to the list of undefined types to be checked through
1589 once this file has been read in. */
1591 add_undefined_type (type)
1594 if (undef_types_length == undef_types_allocated)
1596 undef_types_allocated *= 2;
1597 undef_types = (struct type **)
1598 xrealloc ((char *) undef_types,
1599 undef_types_allocated * sizeof (struct type *));
1601 undef_types[undef_types_length++] = type;
1604 /* Go through each undefined type, see if it's still undefined, and fix it
1605 up if possible. We have two kinds of undefined types:
1607 TYPE_CODE_ARRAY: Array whose target type wasn't defined yet.
1608 Fix: update array length using the element bounds
1609 and the target type's length.
1610 TYPE_CODE_STRUCT, TYPE_CODE_UNION: Structure whose fields were not
1611 yet defined at the time a pointer to it was made.
1612 Fix: Do a full lookup on the struct/union tag. */
1614 cleanup_undefined_types ()
1618 for (type = undef_types; type < undef_types + undef_types_length; type++) {
1619 switch (TYPE_CODE (*type)) {
1621 case TYPE_CODE_STRUCT:
1622 case TYPE_CODE_UNION:
1623 case TYPE_CODE_ENUM:
1625 /* Reasonable test to see if it's been defined since. */
1626 if (TYPE_NFIELDS (*type) == 0)
1628 struct pending *ppt;
1630 /* Name of the type, without "struct" or "union" */
1631 char *typename = TYPE_NAME (*type);
1633 if (!strncmp (typename, "struct ", 7))
1635 if (!strncmp (typename, "union ", 6))
1637 if (!strncmp (typename, "enum ", 5))
1640 for (ppt = file_symbols; ppt; ppt = ppt->next)
1641 for (i = 0; i < ppt->nsyms; i++)
1643 struct symbol *sym = ppt->symbol[i];
1645 if (SYMBOL_CLASS (sym) == LOC_TYPEDEF
1646 && SYMBOL_NAMESPACE (sym) == STRUCT_NAMESPACE
1647 && (TYPE_CODE (SYMBOL_TYPE (sym)) ==
1649 && !strcmp (SYMBOL_NAME (sym), typename))
1650 memcpy (*type, SYMBOL_TYPE (sym), sizeof (struct type));
1654 /* It has been defined; don't mark it as a stub. */
1655 TYPE_FLAGS (*type) &= ~TYPE_FLAG_STUB;
1659 case TYPE_CODE_ARRAY:
1661 struct type *range_type;
1664 if (TYPE_LENGTH (*type) != 0) /* Better be unknown */
1666 if (TYPE_NFIELDS (*type) != 1)
1668 range_type = TYPE_FIELD_TYPE (*type, 0);
1669 if (TYPE_CODE (range_type) != TYPE_CODE_RANGE)
1672 /* Now recompute the length of the array type, based on its
1673 number of elements and the target type's length. */
1674 lower = TYPE_FIELD_BITPOS (range_type, 0);
1675 upper = TYPE_FIELD_BITPOS (range_type, 1);
1676 TYPE_LENGTH (*type) = (upper - lower + 1)
1677 * TYPE_LENGTH (TYPE_TARGET_TYPE (*type));
1683 error ("GDB internal error. cleanup_undefined_types with bad\
1684 type %d.", TYPE_CODE (*type));
1688 undef_types_length = 0;
1691 /* Skip rest of this symbol and return an error type.
1693 General notes on error recovery: error_type always skips to the
1694 end of the symbol (modulo cretinous dbx symbol name continuation).
1695 Thus code like this:
1697 if (*(*pp)++ != ';')
1698 return error_type (pp);
1700 is wrong because if *pp starts out pointing at '\0' (typically as the
1701 result of an earlier error), it will be incremented to point to the
1702 start of the next symbol, which might produce strange results, at least
1703 if you run off the end of the string table. Instead use
1706 return error_type (pp);
1712 foo = error_type (pp);
1716 And in case it isn't obvious, the point of all this hair is so the compiler
1717 can define new types and new syntaxes, and old versions of the
1718 debugger will be able to read the new symbol tables. */
1724 complain (&error_type_complaint, 0);
1727 /* Skip to end of symbol. */
1728 while (**pp != '\0')
1731 /* Check for and handle cretinous dbx symbol name continuation! */
1732 if ((*pp)[-1] == '\\')
1733 *pp = next_symbol_text ();
1737 return builtin_type_error;
1740 /* Read a dbx type reference or definition;
1741 return the type that is meant.
1742 This can be just a number, in which case it references
1743 a type already defined and placed in type_vector.
1744 Or the number can be followed by an =, in which case
1745 it means to define a new type according to the text that
1749 read_type (pp, objfile)
1751 struct objfile *objfile;
1753 register struct type *type = 0;
1758 /* Read type number if present. The type number may be omitted.
1759 for instance in a two-dimensional array declared with type
1760 "ar1;1;10;ar1;1;10;4". */
1761 if ((**pp >= '0' && **pp <= '9')
1764 read_type_number (pp, typenums);
1766 /* Type is not being defined here. Either it already exists,
1767 or this is a forward reference to it. dbx_alloc_type handles
1770 return dbx_alloc_type (typenums, objfile);
1772 /* Type is being defined here. */
1773 #if 0 /* Callers aren't prepared for a NULL result! FIXME -- metin! */
1777 /* if such a type already exists, this is an unnecessary duplication
1778 of the stab string, which is common in (RS/6000) xlc generated
1779 objects. In that case, simply return NULL and let the caller take
1782 tt = *dbx_lookup_type (typenums);
1783 if (tt && tt->length && tt->code)
1792 /* 'typenums=' not present, type is anonymous. Read and return
1793 the definition, but don't put it in the type vector. */
1794 typenums[0] = typenums[1] = -1;
1802 enum type_code code;
1804 /* Used to index through file_symbols. */
1805 struct pending *ppt;
1808 /* Name including "struct", etc. */
1811 /* Name without "struct", etc. */
1812 char *type_name_only;
1818 /* Set the type code according to the following letter. */
1822 code = TYPE_CODE_STRUCT;
1826 code = TYPE_CODE_UNION;
1830 code = TYPE_CODE_ENUM;
1834 return error_type (pp);
1837 to = type_name = (char *)
1838 obstack_alloc (&objfile -> type_obstack,
1840 ((char *) strchr (*pp, ':') - (*pp)) + 1));
1842 /* Copy the prefix. */
1844 while (*to++ = *from++)
1848 type_name_only = to;
1850 /* Copy the name. */
1852 while ((*to++ = *from++) != ':')
1856 /* Set the pointer ahead of the name which we just read. */
1860 /* The following hack is clearly wrong, because it doesn't
1861 check whether we are in a baseclass. I tried to reproduce
1862 the case that it is trying to fix, but I couldn't get
1863 g++ to put out a cross reference to a basetype. Perhaps
1864 it doesn't do it anymore. */
1865 /* Note: for C++, the cross reference may be to a base type which
1866 has not yet been seen. In this case, we skip to the comma,
1867 which will mark the end of the base class name. (The ':'
1868 at the end of the base class name will be skipped as well.)
1869 But sometimes (ie. when the cross ref is the last thing on
1870 the line) there will be no ','. */
1871 from = (char *) strchr (*pp, ',');
1877 /* Now check to see whether the type has already been declared. */
1878 /* This is necessary at least in the case where the
1879 program says something like
1881 The compiler puts out a cross-reference; we better find
1882 set the length of the structure correctly so we can
1883 set the length of the array. */
1884 for (ppt = file_symbols; ppt; ppt = ppt->next)
1885 for (i = 0; i < ppt->nsyms; i++)
1887 struct symbol *sym = ppt->symbol[i];
1889 if (SYMBOL_CLASS (sym) == LOC_TYPEDEF
1890 && SYMBOL_NAMESPACE (sym) == STRUCT_NAMESPACE
1891 && (TYPE_CODE (SYMBOL_TYPE (sym)) == code)
1892 && !strcmp (SYMBOL_NAME (sym), type_name_only))
1894 obstack_free (&objfile -> type_obstack, type_name);
1895 type = SYMBOL_TYPE (sym);
1900 /* Didn't find the type to which this refers, so we must
1901 be dealing with a forward reference. Allocate a type
1902 structure for it, and keep track of it so we can
1903 fill in the rest of the fields when we get the full
1905 type = dbx_alloc_type (typenums, objfile);
1906 TYPE_CODE (type) = code;
1907 TYPE_NAME (type) = type_name;
1908 INIT_CPLUS_SPECIFIC(type);
1909 TYPE_FLAGS (type) |= TYPE_FLAG_STUB;
1911 add_undefined_type (type);
1915 case '-': /* RS/6000 built-in type */
1917 type = builtin_type (pp); /* (in xcoffread.c) */
1932 read_type_number (pp, xtypenums);
1933 type = *dbx_lookup_type (xtypenums);
1938 type = lookup_fundamental_type (objfile, FT_VOID);
1939 if (typenums[0] != -1)
1940 *dbx_lookup_type (typenums) = type;
1943 /* In the following types, we must be sure to overwrite any existing
1944 type that the typenums refer to, rather than allocating a new one
1945 and making the typenums point to the new one. This is because there
1946 may already be pointers to the existing type (if it had been
1947 forward-referenced), and we must change it to a pointer, function,
1948 reference, or whatever, *in-place*. */
1951 type1 = read_type (pp, objfile);
1952 type = make_pointer_type (type1, dbx_lookup_type (typenums));
1955 case '&': /* Reference to another type */
1956 type1 = read_type (pp, objfile);
1957 type = make_reference_type (type1, dbx_lookup_type (typenums));
1960 case 'f': /* Function returning another type */
1961 type1 = read_type (pp, objfile);
1962 type = make_function_type (type1, dbx_lookup_type (typenums));
1965 case 'k': /* Const qualifier on some type (Sun) */
1966 type = read_type (pp, objfile);
1967 /* FIXME! For now, we ignore const and volatile qualifiers. */
1970 case 'B': /* Volatile qual on some type (Sun) */
1971 type = read_type (pp, objfile);
1972 /* FIXME! For now, we ignore const and volatile qualifiers. */
1975 /* FIXME -- we should be doing smash_to_XXX types here. */
1976 case '@': /* Member (class & variable) type */
1978 struct type *domain = read_type (pp, objfile);
1979 struct type *memtype;
1982 /* Invalid member type data format. */
1983 return error_type (pp);
1986 memtype = read_type (pp, objfile);
1987 type = dbx_alloc_type (typenums, objfile);
1988 smash_to_member_type (type, domain, memtype);
1992 case '#': /* Method (class & fn) type */
1993 if ((*pp)[0] == '#')
1995 /* We'll get the parameter types from the name. */
1996 struct type *return_type;
1999 return_type = read_type (pp, objfile);
2000 if (*(*pp)++ != ';')
2001 complain (&invalid_member_complaint, (char *) symnum);
2002 type = allocate_stub_method (return_type);
2003 if (typenums[0] != -1)
2004 *dbx_lookup_type (typenums) = type;
2008 struct type *domain = read_type (pp, objfile);
2009 struct type *return_type;
2012 if (*(*pp)++ != ',')
2013 error ("invalid member type data format, at symtab pos %d.",
2016 return_type = read_type (pp, objfile);
2017 args = read_args (pp, ';', objfile);
2018 type = dbx_alloc_type (typenums, objfile);
2019 smash_to_method_type (type, domain, return_type, args);
2023 case 'r': /* Range type */
2024 type = read_range_type (pp, typenums, objfile);
2025 if (typenums[0] != -1)
2026 *dbx_lookup_type (typenums) = type;
2029 case 'b': /* Sun ACC builtin int type */
2030 type = read_sun_builtin_type (pp, typenums, objfile);
2031 if (typenums[0] != -1)
2032 *dbx_lookup_type (typenums) = type;
2035 case 'R': /* Sun ACC builtin float type */
2036 type = read_sun_floating_type (pp, typenums, objfile);
2037 if (typenums[0] != -1)
2038 *dbx_lookup_type (typenums) = type;
2041 case 'e': /* Enumeration type */
2042 type = dbx_alloc_type (typenums, objfile);
2043 type = read_enum_type (pp, type, objfile);
2044 *dbx_lookup_type (typenums) = type;
2047 case 's': /* Struct type */
2048 type = dbx_alloc_type (typenums, objfile);
2049 if (!TYPE_NAME (type))
2050 TYPE_NAME (type) = type_synonym_name;
2051 type_synonym_name = 0;
2052 type = read_struct_type (pp, type, objfile);
2055 case 'u': /* Union type */
2056 type = dbx_alloc_type (typenums, objfile);
2057 if (!TYPE_NAME (type))
2058 TYPE_NAME (type) = type_synonym_name;
2059 type_synonym_name = 0;
2060 type = read_struct_type (pp, type, objfile);
2061 TYPE_CODE (type) = TYPE_CODE_UNION;
2064 case 'a': /* Array type */
2066 return error_type (pp);
2069 type = dbx_alloc_type (typenums, objfile);
2070 type = read_array_type (pp, type, objfile);
2074 --*pp; /* Go back to the symbol in error */
2075 /* Particularly important if it was \0! */
2076 return error_type (pp);
2085 /* This page contains subroutines of read_type. */
2087 /* Read the description of a structure (or union type)
2088 and return an object describing the type. */
2090 static struct type *
2091 read_struct_type (pp, type, objfile)
2093 register struct type *type;
2094 struct objfile *objfile;
2096 /* Total number of methods defined in this class.
2097 If the class defines two `f' methods, and one `g' method,
2098 then this will have the value 3. */
2099 int total_length = 0;
2103 struct nextfield *next;
2104 int visibility; /* 0=public, 1=protected, 2=public */
2110 struct next_fnfield *next;
2111 struct fn_field fn_field;
2114 struct next_fnfieldlist
2116 struct next_fnfieldlist *next;
2117 struct fn_fieldlist fn_fieldlist;
2120 register struct nextfield *list = 0;
2121 struct nextfield *new;
2124 int non_public_fields = 0;
2127 register struct next_fnfieldlist *mainlist = 0;
2130 TYPE_CODE (type) = TYPE_CODE_STRUCT;
2131 INIT_CPLUS_SPECIFIC(type);
2133 /* First comes the total size in bytes. */
2135 TYPE_LENGTH (type) = read_number (pp, 0);
2137 /* C++: Now, if the class is a derived class, then the next character
2138 will be a '!', followed by the number of base classes derived from.
2139 Each element in the list contains visibility information,
2140 the offset of this base class in the derived structure,
2141 and then the base type. */
2144 int i, n_baseclasses, offset;
2145 struct type *baseclass;
2148 /* Nonzero if it is a virtual baseclass, i.e.,
2152 struct C : public B, public virtual A {};
2154 B is a baseclass of C; A is a virtual baseclass for C. This is a C++
2155 2.0 language feature. */
2160 ALLOCATE_CPLUS_STRUCT_TYPE(type);
2162 n_baseclasses = read_number (pp, ',');
2163 TYPE_FIELD_VIRTUAL_BITS (type) =
2164 (B_TYPE *) obstack_alloc (&objfile -> type_obstack,
2165 B_BYTES (n_baseclasses));
2166 B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), n_baseclasses);
2168 for (i = 0; i < n_baseclasses; i++)
2171 *pp = next_symbol_text ();
2182 /* Bad visibility format. */
2183 return error_type (pp);
2191 non_public_fields++;
2197 /* Bad visibility format. */
2198 return error_type (pp);
2201 SET_TYPE_FIELD_VIRTUAL (type, i);
2204 /* Offset of the portion of the object corresponding to
2205 this baseclass. Always zero in the absence of
2206 multiple inheritance. */
2207 offset = read_number (pp, ',');
2208 baseclass = read_type (pp, objfile);
2209 *pp += 1; /* skip trailing ';' */
2211 /* Make this baseclass visible for structure-printing purposes. */
2212 new = (struct nextfield *) alloca (sizeof (struct nextfield));
2215 list->visibility = via_public;
2216 list->field.type = baseclass;
2217 list->field.name = type_name_no_tag (baseclass);
2218 list->field.bitpos = offset;
2219 list->field.bitsize = 0; /* this should be an unpacked field! */
2222 TYPE_N_BASECLASSES (type) = n_baseclasses;
2225 /* Now come the fields, as NAME:?TYPENUM,BITPOS,BITSIZE; for each one.
2226 At the end, we see a semicolon instead of a field.
2228 In C++, this may wind up being NAME:?TYPENUM:PHYSNAME; for
2231 The `?' is a placeholder for one of '/2' (public visibility),
2232 '/1' (protected visibility), '/0' (private visibility), or nothing
2233 (C style symbol table, public visibility). */
2235 /* We better set p right now, in case there are no fields at all... */
2240 /* Check for and handle cretinous dbx symbol name continuation! */
2241 if (**pp == '\\') *pp = next_symbol_text ();
2243 /* Get space to record the next field's data. */
2244 new = (struct nextfield *) alloca (sizeof (struct nextfield));
2248 /* Get the field name. */
2250 if (*p == CPLUS_MARKER)
2252 /* Special GNU C++ name. */
2257 struct type *context;
2268 complain (&invalid_cpp_abbrev_complaint, *pp);
2269 prefix = "INVALID_C++_ABBREV";
2273 context = read_type (pp, objfile);
2274 name = type_name_no_tag (context);
2277 complain (&invalid_cpp_type_complaint, (char *) symnum);
2280 list->field.name = obconcat (&objfile -> type_obstack,
2284 complain (&invalid_cpp_abbrev_complaint, *pp);
2285 list->field.type = read_type (pp, objfile);
2286 (*pp)++; /* Skip the comma. */
2287 list->field.bitpos = read_number (pp, ';');
2288 /* This field is unpacked. */
2289 list->field.bitsize = 0;
2290 list->visibility = 0; /* private */
2291 non_public_fields++;
2293 /* GNU C++ anonymous type. */
2297 complain (&invalid_cpp_abbrev_complaint, *pp);
2303 while (*p != ':') p++;
2304 list->field.name = obsavestring (*pp, p - *pp,
2305 &objfile -> type_obstack);
2307 /* C++: Check to see if we have hit the methods yet. */
2313 /* This means we have a visibility for a field coming. */
2319 list->visibility = 0; /* private */
2320 non_public_fields++;
2325 list->visibility = 1; /* protected */
2326 non_public_fields++;
2331 list->visibility = 2; /* public */
2336 else /* normal dbx-style format. */
2337 list->visibility = 2; /* public */
2339 list->field.type = read_type (pp, objfile);
2342 /* Static class member. */
2343 list->field.bitpos = (long)-1;
2345 while (*p != ';') p++;
2346 list->field.bitsize = (long) savestring (*pp, p - *pp);
2351 else if (**pp != ',')
2352 /* Bad structure-type format. */
2353 return error_type (pp);
2355 (*pp)++; /* Skip the comma. */
2356 list->field.bitpos = read_number (pp, ',');
2357 list->field.bitsize = read_number (pp, ';');
2360 /* FIXME-tiemann: Can't the compiler put out something which
2361 lets us distinguish these? (or maybe just not put out anything
2362 for the field). What is the story here? What does the compiler
2363 really do? Also, patch gdb.texinfo for this case; I document
2364 it as a possible problem there. Search for "DBX-style". */
2366 /* This is wrong because this is identical to the symbols
2367 produced for GCC 0-size arrays. For example:
2372 The code which dumped core in such circumstances should be
2373 fixed not to dump core. */
2375 /* g++ -g0 can put out bitpos & bitsize zero for a static
2376 field. This does not give us any way of getting its
2377 class, so we can't know its name. But we can just
2378 ignore the field so we don't dump core and other nasty
2380 if (list->field.bitpos == 0
2381 && list->field.bitsize == 0)
2383 complain (&dbx_class_complaint, 0);
2384 /* Ignore this field. */
2390 /* Detect an unpacked field and mark it as such.
2391 dbx gives a bit size for all fields.
2392 Note that forward refs cannot be packed,
2393 and treat enums as if they had the width of ints. */
2394 if (TYPE_CODE (list->field.type) != TYPE_CODE_INT
2395 && TYPE_CODE (list->field.type) != TYPE_CODE_ENUM)
2396 list->field.bitsize = 0;
2397 if ((list->field.bitsize == 8 * TYPE_LENGTH (list->field.type)
2398 || (TYPE_CODE (list->field.type) == TYPE_CODE_ENUM
2399 && (list->field.bitsize
2400 == 8 * TYPE_LENGTH (lookup_fundamental_type (objfile, FT_INTEGER)))
2404 list->field.bitpos % 8 == 0)
2405 list->field.bitsize = 0;
2411 /* chill the list of fields: the last entry (at the head)
2412 is a partially constructed entry which we now scrub. */
2415 /* Now create the vector of fields, and record how big it is.
2416 We need this info to record proper virtual function table information
2417 for this class's virtual functions. */
2419 TYPE_NFIELDS (type) = nfields;
2420 TYPE_FIELDS (type) = (struct field *)
2421 obstack_alloc (&objfile -> type_obstack, sizeof (struct field) * nfields);
2423 if (non_public_fields)
2425 ALLOCATE_CPLUS_STRUCT_TYPE (type);
2427 TYPE_FIELD_PRIVATE_BITS (type) =
2428 (B_TYPE *) obstack_alloc (&objfile -> type_obstack,
2430 B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type), nfields);
2432 TYPE_FIELD_PROTECTED_BITS (type) =
2433 (B_TYPE *) obstack_alloc (&objfile -> type_obstack,
2435 B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type), nfields);
2438 /* Copy the saved-up fields into the field vector. */
2440 for (n = nfields; list; list = list->next)
2443 TYPE_FIELD (type, n) = list->field;
2444 if (list->visibility == 0)
2445 SET_TYPE_FIELD_PRIVATE (type, n);
2446 else if (list->visibility == 1)
2447 SET_TYPE_FIELD_PROTECTED (type, n);
2450 /* Now come the method fields, as NAME::methods
2451 where each method is of the form TYPENUM,ARGS,...:PHYSNAME;
2452 At the end, we see a semicolon instead of a field.
2454 For the case of overloaded operators, the format is
2455 op$::*.methods, where $ is the CPLUS_MARKER (usually '$'),
2456 `*' holds the place for an operator name (such as `+=')
2457 and `.' marks the end of the operator name. */
2460 /* Now, read in the methods. To simplify matters, we
2461 "unread" the name that has been read, so that we can
2462 start from the top. */
2464 ALLOCATE_CPLUS_STRUCT_TYPE (type);
2465 /* For each list of method lists... */
2469 struct next_fnfield *sublist = 0;
2470 struct type *look_ahead_type = NULL;
2472 struct next_fnfieldlist *new_mainlist =
2473 (struct next_fnfieldlist *)alloca (sizeof (struct next_fnfieldlist));
2478 /* read in the name. */
2479 while (*p != ':') p++;
2480 if ((*pp)[0] == 'o' && (*pp)[1] == 'p' && (*pp)[2] == CPLUS_MARKER)
2482 /* This is a completely wierd case. In order to stuff in the
2483 names that might contain colons (the usual name delimiter),
2484 Mike Tiemann defined a different name format which is
2485 signalled if the identifier is "op$". In that case, the
2486 format is "op$::XXXX." where XXXX is the name. This is
2487 used for names like "+" or "=". YUUUUUUUK! FIXME! */
2488 /* This lets the user type "break operator+".
2489 We could just put in "+" as the name, but that wouldn't
2491 static char opname[32] = {'o', 'p', CPLUS_MARKER};
2492 char *o = opname + 3;
2494 /* Skip past '::'. */
2496 if (**pp == '\\') *pp = next_symbol_text ();
2500 main_fn_name = savestring (opname, o - opname);
2506 main_fn_name = savestring (*pp, p - *pp);
2507 /* Skip past '::'. */
2510 new_mainlist->fn_fieldlist.name = main_fn_name;
2514 struct next_fnfield *new_sublist =
2515 (struct next_fnfield *)alloca (sizeof (struct next_fnfield));
2517 /* Check for and handle cretinous dbx symbol name continuation! */
2518 if (look_ahead_type == NULL) /* Normal case. */
2520 if (**pp == '\\') *pp = next_symbol_text ();
2522 new_sublist->fn_field.type = read_type (pp, objfile);
2524 /* Invalid symtab info for method. */
2525 return error_type (pp);
2528 { /* g++ version 1 kludge */
2529 new_sublist->fn_field.type = look_ahead_type;
2530 look_ahead_type = NULL;
2535 while (*p != ';') p++;
2537 /* If this is just a stub, then we don't have the
2539 if (TYPE_FLAGS (new_sublist->fn_field.type) & TYPE_FLAG_STUB)
2540 new_sublist->fn_field.is_stub = 1;
2541 new_sublist->fn_field.physname = savestring (*pp, p - *pp);
2544 /* Set this method's visibility fields. */
2545 switch (*(*pp)++ - '0')
2548 new_sublist->fn_field.is_private = 1;
2551 new_sublist->fn_field.is_protected = 1;
2555 if (**pp == '\\') *pp = next_symbol_text ();
2558 case 'A': /* Normal functions. */
2559 new_sublist->fn_field.is_const = 0;
2560 new_sublist->fn_field.is_volatile = 0;
2563 case 'B': /* `const' member functions. */
2564 new_sublist->fn_field.is_const = 1;
2565 new_sublist->fn_field.is_volatile = 0;
2568 case 'C': /* `volatile' member function. */
2569 new_sublist->fn_field.is_const = 0;
2570 new_sublist->fn_field.is_volatile = 1;
2573 case 'D': /* `const volatile' member function. */
2574 new_sublist->fn_field.is_const = 1;
2575 new_sublist->fn_field.is_volatile = 1;
2578 case '*': /* File compiled with g++ version 1 -- no info */
2583 complain (&const_vol_complaint, (char *) (long) **pp);
2590 /* virtual member function, followed by index. */
2591 /* The sign bit is set to distinguish pointers-to-methods
2592 from virtual function indicies. Since the array is
2593 in words, the quantity must be shifted left by 1
2594 on 16 bit machine, and by 2 on 32 bit machine, forcing
2595 the sign bit out, and usable as a valid index into
2596 the array. Remove the sign bit here. */
2597 new_sublist->fn_field.voffset =
2598 (0x7fffffff & read_number (pp, ';')) + 2;
2600 if (**pp == '\\') *pp = next_symbol_text ();
2602 if (**pp == ';' || **pp == '\0')
2603 /* Must be g++ version 1. */
2604 new_sublist->fn_field.fcontext = 0;
2607 /* Figure out from whence this virtual function came.
2608 It may belong to virtual function table of
2609 one of its baseclasses. */
2610 look_ahead_type = read_type (pp, objfile);
2612 { /* g++ version 1 overloaded methods. */ }
2615 new_sublist->fn_field.fcontext = look_ahead_type;
2617 return error_type (pp);
2620 look_ahead_type = NULL;
2626 /* static member function. */
2627 new_sublist->fn_field.voffset = VOFFSET_STATIC;
2628 if (strncmp (new_sublist->fn_field.physname,
2629 main_fn_name, strlen (main_fn_name)))
2630 new_sublist->fn_field.is_stub = 1;
2635 complain (&member_fn_complaint, (char *) (long) (*pp)[-1]);
2636 /* Fall through into normal member function. */
2639 /* normal member function. */
2640 new_sublist->fn_field.voffset = 0;
2641 new_sublist->fn_field.fcontext = 0;
2645 new_sublist->next = sublist;
2646 sublist = new_sublist;
2648 if (**pp == '\\') *pp = next_symbol_text ();
2650 while (**pp != ';' && **pp != '\0');
2654 new_mainlist->fn_fieldlist.fn_fields =
2655 (struct fn_field *) obstack_alloc (&objfile -> type_obstack,
2656 sizeof (struct fn_field) * length);
2657 for (i = length; (i--, sublist); sublist = sublist->next)
2658 new_mainlist->fn_fieldlist.fn_fields[i] = sublist->fn_field;
2660 new_mainlist->fn_fieldlist.length = length;
2661 new_mainlist->next = mainlist;
2662 mainlist = new_mainlist;
2664 total_length += length;
2665 if (**pp == '\\') *pp = next_symbol_text ();
2667 while (**pp != ';');
2675 TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *)
2676 obstack_alloc (&objfile -> type_obstack,
2677 sizeof (struct fn_fieldlist) * nfn_fields);
2678 TYPE_NFN_FIELDS (type) = nfn_fields;
2679 TYPE_NFN_FIELDS_TOTAL (type) = total_length;
2684 for (i = 0; i < TYPE_N_BASECLASSES (type); ++i)
2685 TYPE_NFN_FIELDS_TOTAL (type) +=
2686 TYPE_NFN_FIELDS_TOTAL (TYPE_BASECLASS (type, i));
2689 for (n = nfn_fields; mainlist; mainlist = mainlist->next) {
2690 --n; /* Circumvent Sun3 compiler bug */
2691 TYPE_FN_FIELDLISTS (type)[n] = mainlist->fn_fieldlist;
2698 if (**pp == '=' || **pp == '+' || **pp == '-')
2700 /* Obsolete flags that used to indicate the presence
2701 of constructors and/or destructors. */
2705 /* Read either a '%' or the final ';'. */
2706 if (*(*pp)++ == '%')
2708 /* We'd like to be able to derive the vtable pointer field
2709 from the type information, but when it's inherited, that's
2710 hard. A reason it's hard is because we may read in the
2711 info about a derived class before we read in info about
2712 the base class that provides the vtable pointer field.
2713 Once the base info has been read, we could fill in the info
2714 for the derived classes, but for the fact that by then,
2715 we don't remember who needs what. */
2718 int predicted_fieldno = -1;
2721 /* Now we must record the virtual function table pointer's
2722 field information. */
2730 /* In version 2, we derive the vfield ourselves. */
2731 for (n = 0; n < nfields; n++)
2733 if (! strncmp (TYPE_FIELD_NAME (type, n), vptr_name,
2734 sizeof (vptr_name) -1))
2736 predicted_fieldno = n;
2740 if (predicted_fieldno < 0)
2741 for (n = 0; n < TYPE_N_BASECLASSES (type); n++)
2742 if (! TYPE_FIELD_VIRTUAL (type, n)
2743 && TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type, n)) >= 0)
2745 predicted_fieldno = TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type, n));
2751 t = read_type (pp, objfile);
2753 while (*p != '\0' && *p != ';')
2756 /* Premature end of symbol. */
2757 return error_type (pp);
2759 TYPE_VPTR_BASETYPE (type) = t;
2762 if (TYPE_FIELD_NAME (t, TYPE_N_BASECLASSES (t)) == 0)
2764 /* FIXME-tiemann: what's this? */
2766 TYPE_VPTR_FIELDNO (type) = i = TYPE_N_BASECLASSES (t);
2771 else for (i = TYPE_NFIELDS (t) - 1; i >= TYPE_N_BASECLASSES (t); --i)
2772 if (! strncmp (TYPE_FIELD_NAME (t, i), vptr_name,
2773 sizeof (vptr_name) -1))
2775 TYPE_VPTR_FIELDNO (type) = i;
2779 /* Virtual function table field not found. */
2780 return error_type (pp);
2783 TYPE_VPTR_FIELDNO (type) = TYPE_VPTR_FIELDNO (t);
2786 if (TYPE_VPTR_FIELDNO (type) != predicted_fieldno)
2787 error ("TYPE_VPTR_FIELDNO miscalculated");
2797 /* Read a definition of an array type,
2798 and create and return a suitable type object.
2799 Also creates a range type which represents the bounds of that
2801 static struct type *
2802 read_array_type (pp, type, objfile)
2804 register struct type *type;
2805 struct objfile *objfile;
2807 struct type *index_type, *element_type, *range_type;
2811 /* Format of an array type:
2812 "ar<index type>;lower;upper;<array_contents_type>". Put code in
2815 Fortran adjustable arrays use Adigits or Tdigits for lower or upper;
2816 for these, produce a type like float[][]. */
2818 index_type = read_type (pp, objfile);
2820 /* Improper format of array type decl. */
2821 return error_type (pp);
2824 if (!(**pp >= '0' && **pp <= '9'))
2829 lower = read_number (pp, ';');
2831 if (!(**pp >= '0' && **pp <= '9'))
2836 upper = read_number (pp, ';');
2838 element_type = read_type (pp, objfile);
2847 /* Create range type. */
2848 range_type = (struct type *)
2849 obstack_alloc (&objfile -> type_obstack, sizeof (struct type));
2850 memset (range_type, 0, sizeof (struct type));
2851 TYPE_OBJFILE (range_type) = objfile;
2852 TYPE_CODE (range_type) = TYPE_CODE_RANGE;
2853 TYPE_TARGET_TYPE (range_type) = index_type;
2855 /* This should never be needed. */
2856 TYPE_LENGTH (range_type) = sizeof (int);
2858 TYPE_NFIELDS (range_type) = 2;
2859 TYPE_FIELDS (range_type) =
2860 (struct field *) obstack_alloc (&objfile -> type_obstack,
2861 2 * sizeof (struct field));
2862 TYPE_FIELD_BITPOS (range_type, 0) = lower;
2863 TYPE_FIELD_BITPOS (range_type, 1) = upper;
2866 TYPE_CODE (type) = TYPE_CODE_ARRAY;
2867 TYPE_TARGET_TYPE (type) = element_type;
2868 TYPE_LENGTH (type) = (upper - lower + 1) * TYPE_LENGTH (element_type);
2869 TYPE_NFIELDS (type) = 1;
2870 TYPE_FIELDS (type) =
2871 (struct field *) obstack_alloc (&objfile -> type_obstack,
2872 sizeof (struct field));
2873 TYPE_FIELD_TYPE (type, 0) = range_type;
2875 /* If we have an array whose element type is not yet known, but whose
2876 bounds *are* known, record it to be adjusted at the end of the file. */
2877 if (TYPE_LENGTH (element_type) == 0 && !adjustable)
2878 add_undefined_type (type);
2884 /* Read a definition of an enumeration type,
2885 and create and return a suitable type object.
2886 Also defines the symbols that represent the values of the type. */
2888 static struct type *
2889 read_enum_type (pp, type, objfile)
2891 register struct type *type;
2892 struct objfile *objfile;
2897 register struct symbol *sym;
2899 struct pending **symlist;
2900 struct pending *osyms, *syms;
2904 /* FIXME! The stabs produced by Sun CC merrily define things that ought
2905 to be file-scope, between N_FN entries, using N_LSYM. What's a mother
2906 to do? For now, force all enum values to file scope. */
2907 if (within_function)
2908 symlist = &local_symbols;
2911 symlist = &file_symbols;
2913 o_nsyms = osyms ? osyms->nsyms : 0;
2915 /* Read the value-names and their values.
2916 The input syntax is NAME:VALUE,NAME:VALUE, and so on.
2917 A semicolon or comma instead of a NAME means the end. */
2918 while (**pp && **pp != ';' && **pp != ',')
2920 /* Check for and handle cretinous dbx symbol name continuation! */
2921 if (**pp == '\\') *pp = next_symbol_text ();
2924 while (*p != ':') p++;
2925 name = obsavestring (*pp, p - *pp, &objfile -> symbol_obstack);
2927 n = read_number (pp, ',');
2929 sym = (struct symbol *) obstack_alloc (&objfile -> symbol_obstack, sizeof (struct symbol));
2930 memset (sym, 0, sizeof (struct symbol));
2931 SYMBOL_NAME (sym) = name;
2932 SYMBOL_CLASS (sym) = LOC_CONST;
2933 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2934 SYMBOL_VALUE (sym) = n;
2935 add_symbol_to_list (sym, symlist);
2940 (*pp)++; /* Skip the semicolon. */
2942 /* Now fill in the fields of the type-structure. */
2944 TYPE_LENGTH (type) = sizeof (int);
2945 TYPE_CODE (type) = TYPE_CODE_ENUM;
2946 TYPE_NFIELDS (type) = nsyms;
2947 TYPE_FIELDS (type) = (struct field *)
2948 obstack_alloc (&objfile -> type_obstack,
2949 sizeof (struct field) * nsyms);
2951 /* Find the symbols for the values and put them into the type.
2952 The symbols can be found in the symlist that we put them on
2953 to cause them to be defined. osyms contains the old value
2954 of that symlist; everything up to there was defined by us. */
2955 /* Note that we preserve the order of the enum constants, so
2956 that in something like "enum {FOO, LAST_THING=FOO}" we print
2957 FOO, not LAST_THING. */
2959 for (syms = *symlist, n = 0; syms; syms = syms->next)
2964 for (; j < syms->nsyms; j++,n++)
2966 struct symbol *xsym = syms->symbol[j];
2967 SYMBOL_TYPE (xsym) = type;
2968 TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym);
2969 TYPE_FIELD_VALUE (type, n) = 0;
2970 TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (xsym);
2971 TYPE_FIELD_BITSIZE (type, n) = 0;
2978 /* This screws up perfectly good C programs with enums. FIXME. */
2979 /* Is this Modula-2's BOOLEAN type? Flag it as such if so. */
2980 if(TYPE_NFIELDS(type) == 2 &&
2981 ((!strcmp(TYPE_FIELD_NAME(type,0),"TRUE") &&
2982 !strcmp(TYPE_FIELD_NAME(type,1),"FALSE")) ||
2983 (!strcmp(TYPE_FIELD_NAME(type,1),"TRUE") &&
2984 !strcmp(TYPE_FIELD_NAME(type,0),"FALSE"))))
2985 TYPE_CODE(type) = TYPE_CODE_BOOL;
2991 /* Sun's ACC uses a somewhat saner method for specifying the builtin
2992 typedefs in every file (for int, long, etc):
2994 type = b <signed> <width>; <offset>; <nbits>
2995 signed = u or s. Possible c in addition to u or s (for char?).
2996 offset = offset from high order bit to start bit of type.
2997 width is # bytes in object of this type, nbits is # bits in type.
2999 The width/offset stuff appears to be for small objects stored in
3000 larger ones (e.g. `shorts' in `int' registers). We ignore it for now,
3003 static struct type *
3004 read_sun_builtin_type (pp, typenums, objfile)
3007 struct objfile *objfile;
3020 return error_type (pp);
3024 /* For some odd reason, all forms of char put a c here. This is strange
3025 because no other type has this honor. We can safely ignore this because
3026 we actually determine 'char'acterness by the number of bits specified in
3032 /* The first number appears to be the number of bytes occupied
3033 by this type, except that unsigned short is 4 instead of 2.
3034 Since this information is redundant with the third number,
3035 we will ignore it. */
3036 read_number (pp, ';');
3038 /* The second number is always 0, so ignore it too. */
3039 read_number (pp, ';');
3041 /* The third number is the number of bits for this type. */
3042 nbits = read_number (pp, 0);
3044 /* FIXME. Here we should just be able to make a type of the right
3045 number of bits and signedness. FIXME. */
3047 if (nbits == TARGET_LONG_LONG_BIT)
3048 return (lookup_fundamental_type (objfile,
3049 signed_type? FT_LONG_LONG: FT_UNSIGNED_LONG_LONG));
3051 if (nbits == TARGET_INT_BIT) {
3052 /* FIXME -- the only way to distinguish `int' from `long'
3053 is to look at its name! */
3055 if (long_kludge_name && long_kludge_name[0] == 'l' /* long */)
3056 return lookup_fundamental_type (objfile, FT_LONG);
3058 return lookup_fundamental_type (objfile, FT_INTEGER);
3060 if (long_kludge_name
3061 && ((long_kludge_name[0] == 'u' /* unsigned */ &&
3062 long_kludge_name[9] == 'l' /* long */)
3063 || (long_kludge_name[0] == 'l' /* long unsigned */)))
3064 return lookup_fundamental_type (objfile, FT_UNSIGNED_LONG);
3066 return lookup_fundamental_type (objfile, FT_UNSIGNED_INTEGER);
3070 if (nbits == TARGET_SHORT_BIT)
3071 return (lookup_fundamental_type (objfile,
3072 signed_type? FT_SHORT: FT_UNSIGNED_SHORT));
3074 if (nbits == TARGET_CHAR_BIT)
3075 return (lookup_fundamental_type (objfile,
3076 signed_type? FT_CHAR: FT_UNSIGNED_CHAR));
3079 return lookup_fundamental_type (objfile, FT_VOID);
3081 return error_type (pp);
3084 static struct type *
3085 read_sun_floating_type (pp, typenums, objfile)
3088 struct objfile *objfile;
3092 /* The first number has more details about the type, for example
3093 FN_COMPLEX. See the sun stab.h. */
3094 read_number (pp, ';');
3096 /* The second number is the number of bytes occupied by this type */
3097 nbytes = read_number (pp, ';');
3100 return error_type (pp);
3102 if (nbytes == TARGET_FLOAT_BIT / TARGET_CHAR_BIT)
3103 return lookup_fundamental_type (objfile, FT_FLOAT);
3105 if (nbytes == TARGET_DOUBLE_BIT / TARGET_CHAR_BIT)
3106 return lookup_fundamental_type (objfile, FT_DBL_PREC_FLOAT);
3108 if (nbytes == TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT)
3109 return lookup_fundamental_type (objfile, FT_EXT_PREC_FLOAT);
3111 return error_type (pp);
3114 /* Read a number from the string pointed to by *PP.
3115 The value of *PP is advanced over the number.
3116 If END is nonzero, the character that ends the
3117 number must match END, or an error happens;
3118 and that character is skipped if it does match.
3119 If END is zero, *PP is left pointing to that character.
3121 If the number fits in a long, set *VALUE and set *BITS to 0.
3122 If not, set *BITS to be the number of bits in the number.
3124 If encounter garbage, set *BITS to -1. */
3127 read_huge_number (pp, end, valu, bits)
3148 /* Leading zero means octal. GCC uses this to output values larger
3149 than an int (because that would be hard in decimal). */
3156 upper_limit = LONG_MAX / radix;
3157 while ((c = *p++) >= '0' && c <= ('0' + radix))
3159 if (n <= upper_limit)
3162 n += c - '0'; /* FIXME this overflows anyway */
3167 /* This depends on large values being output in octal, which is
3174 /* Ignore leading zeroes. */
3178 else if (c == '2' || c == '3')
3204 /* Large decimal constants are an error (because it is hard to
3205 count how many bits are in them). */
3211 /* -0x7f is the same as 0x80. So deal with it by adding one to
3212 the number of bits. */
3227 static struct type *
3228 read_range_type (pp, typenums, objfile)
3231 struct objfile *objfile;
3237 struct type *result_type;
3239 /* First comes a type we are a subrange of.
3240 In C it is usually 0, 1 or the type being defined. */
3241 read_type_number (pp, rangenums);
3242 self_subrange = (rangenums[0] == typenums[0] &&
3243 rangenums[1] == typenums[1]);
3245 /* A semicolon should now follow; skip it. */
3249 /* The remaining two operands are usually lower and upper bounds
3250 of the range. But in some special cases they mean something else. */
3251 read_huge_number (pp, ';', &n2, &n2bits);
3252 read_huge_number (pp, ';', &n3, &n3bits);
3254 if (n2bits == -1 || n3bits == -1)
3255 return error_type (pp);
3257 /* If limits are huge, must be large integral type. */
3258 if (n2bits != 0 || n3bits != 0)
3260 char got_signed = 0;
3261 char got_unsigned = 0;
3262 /* Number of bits in the type. */
3265 /* Range from 0 to <large number> is an unsigned large integral type. */
3266 if ((n2bits == 0 && n2 == 0) && n3bits != 0)
3271 /* Range from <large number> to <large number>-1 is a large signed
3273 else if (n2bits != 0 && n3bits != 0 && n2bits == n3bits + 1)
3279 /* Check for "long long". */
3280 if (got_signed && nbits == TARGET_LONG_LONG_BIT)
3281 return (lookup_fundamental_type (objfile, FT_LONG_LONG));
3282 if (got_unsigned && nbits == TARGET_LONG_LONG_BIT)
3283 return (lookup_fundamental_type (objfile, FT_UNSIGNED_LONG_LONG));
3285 if (got_signed || got_unsigned)
3287 result_type = (struct type *)
3288 obstack_alloc (&objfile -> type_obstack,
3289 sizeof (struct type));
3290 memset (result_type, 0, sizeof (struct type));
3291 TYPE_OBJFILE (result_type) = objfile;
3292 TYPE_LENGTH (result_type) = nbits / TARGET_CHAR_BIT;
3293 TYPE_CODE (result_type) = TYPE_CODE_INT;
3295 TYPE_FLAGS (result_type) |= TYPE_FLAG_UNSIGNED;
3299 return error_type (pp);
3302 /* A type defined as a subrange of itself, with bounds both 0, is void. */
3303 if (self_subrange && n2 == 0 && n3 == 0)
3304 return (lookup_fundamental_type (objfile, FT_VOID));
3306 /* If n3 is zero and n2 is not, we want a floating type,
3307 and n2 is the width in bytes.
3309 Fortran programs appear to use this for complex types also,
3310 and they give no way to distinguish between double and single-complex!
3311 We don't have complex types, so we would lose on all fortran files!
3312 So return type `double' for all of those. It won't work right
3313 for the complex values, but at least it makes the file loadable.
3315 FIXME, we may be able to distinguish these by their names. FIXME. */
3317 if (n3 == 0 && n2 > 0)
3319 if (n2 == sizeof (float))
3320 return (lookup_fundamental_type (objfile, FT_FLOAT));
3321 return (lookup_fundamental_type (objfile, FT_DBL_PREC_FLOAT));
3324 /* If the upper bound is -1, it must really be an unsigned int. */
3326 else if (n2 == 0 && n3 == -1)
3328 /* FIXME -- the only way to distinguish `unsigned int' from `unsigned
3329 long' is to look at its name! */
3331 long_kludge_name && ((long_kludge_name[0] == 'u' /* unsigned */ &&
3332 long_kludge_name[9] == 'l' /* long */)
3333 || (long_kludge_name[0] == 'l' /* long unsigned */)))
3334 return (lookup_fundamental_type (objfile, FT_UNSIGNED_LONG));
3336 return (lookup_fundamental_type (objfile, FT_UNSIGNED_INTEGER));
3339 /* Special case: char is defined (Who knows why) as a subrange of
3340 itself with range 0-127. */
3341 else if (self_subrange && n2 == 0 && n3 == 127)
3342 return (lookup_fundamental_type (objfile, FT_CHAR));
3344 /* Assumptions made here: Subrange of self is equivalent to subrange
3345 of int. FIXME: Host and target type-sizes assumed the same. */
3346 /* FIXME: This is the *only* place in GDB that depends on comparing
3347 some type to a builtin type with ==. Fix it! */
3349 && (self_subrange ||
3350 *dbx_lookup_type (rangenums) == lookup_fundamental_type (objfile, FT_INTEGER)))
3352 /* an unsigned type */
3354 if (n3 == - sizeof (long long))
3355 return (lookup_fundamental_type (objfile, FT_UNSIGNED_LONG_LONG));
3357 /* FIXME -- the only way to distinguish `unsigned int' from `unsigned
3358 long' is to look at its name! */
3359 if (n3 == (unsigned long)~0L &&
3360 long_kludge_name && ((long_kludge_name[0] == 'u' /* unsigned */ &&
3361 long_kludge_name[9] == 'l' /* long */)
3362 || (long_kludge_name[0] == 'l' /* long unsigned */)))
3363 return (lookup_fundamental_type (objfile, FT_UNSIGNED_LONG));
3364 if (n3 == (unsigned int)~0L)
3365 return (lookup_fundamental_type (objfile, FT_UNSIGNED_INTEGER));
3366 if (n3 == (unsigned short)~0L)
3367 return (lookup_fundamental_type (objfile, FT_UNSIGNED_SHORT));
3368 if (n3 == (unsigned char)~0L)
3369 return (lookup_fundamental_type (objfile, FT_UNSIGNED_CHAR));
3372 else if (n3 == 0 && n2 == -sizeof (long long))
3373 return (lookup_fundamental_type (objfile, FT_LONG_LONG));
3375 else if (n2 == -n3 -1)
3378 /* FIXME -- the only way to distinguish `int' from `long' is to look
3380 if ((n3 ==(long)(((unsigned long)1 << (8 * sizeof (long) - 1)) - 1)) &&
3381 long_kludge_name && long_kludge_name[0] == 'l' /* long */)
3382 return (lookup_fundamental_type (objfile, FT_LONG));
3383 if (n3 == (long)(((unsigned long)1 << (8 * sizeof (int) - 1)) - 1))
3384 return (lookup_fundamental_type (objfile, FT_INTEGER));
3385 if (n3 == ( 1 << (8 * sizeof (short) - 1)) - 1)
3386 return (lookup_fundamental_type (objfile, FT_SHORT));
3387 if (n3 == ( 1 << (8 * sizeof (char) - 1)) - 1)
3388 return (lookup_fundamental_type (objfile, FT_SIGNED_CHAR));
3391 /* We have a real range type on our hands. Allocate space and
3392 return a real pointer. */
3394 /* At this point I don't have the faintest idea how to deal with
3395 a self_subrange type; I'm going to assume that this is used
3396 as an idiom, and that all of them are special cases. So . . . */
3398 return error_type (pp);
3400 result_type = (struct type *)
3401 obstack_alloc (&objfile -> type_obstack, sizeof (struct type));
3402 memset (result_type, 0, sizeof (struct type));
3403 TYPE_OBJFILE (result_type) = objfile;
3405 TYPE_CODE (result_type) = TYPE_CODE_RANGE;
3407 TYPE_TARGET_TYPE (result_type) = *dbx_lookup_type(rangenums);
3408 if (TYPE_TARGET_TYPE (result_type) == 0) {
3409 complain (&range_type_base_complaint, (char *) rangenums[1]);
3410 TYPE_TARGET_TYPE (result_type) = lookup_fundamental_type (objfile, FT_INTEGER);
3413 TYPE_NFIELDS (result_type) = 2;
3414 TYPE_FIELDS (result_type) =
3415 (struct field *) obstack_alloc (&objfile -> type_obstack,
3416 2 * sizeof (struct field));
3417 memset (TYPE_FIELDS (result_type), 0, 2 * sizeof (struct field));
3418 TYPE_FIELD_BITPOS (result_type, 0) = n2;
3419 TYPE_FIELD_BITPOS (result_type, 1) = n3;
3421 TYPE_LENGTH (result_type) = TYPE_LENGTH (TYPE_TARGET_TYPE (result_type));
3426 /* Read a number from the string pointed to by *PP.
3427 The value of *PP is advanced over the number.
3428 If END is nonzero, the character that ends the
3429 number must match END, or an error happens;
3430 and that character is skipped if it does match.
3431 If END is zero, *PP is left pointing to that character. */
3434 read_number (pp, end)
3438 register char *p = *pp;
3439 register long n = 0;
3443 /* Handle an optional leading minus sign. */
3451 /* Read the digits, as far as they go. */
3453 while ((c = *p++) >= '0' && c <= '9')
3461 error ("Invalid symbol data: invalid character \\%03o at symbol pos %d.", c, symnum);
3470 /* Read in an argument list. This is a list of types, separated by commas
3471 and terminated with END. Return the list of types read in, or (struct type
3472 **)-1 if there is an error. */
3473 static struct type **
3474 read_args (pp, end, objfile)
3477 struct objfile *objfile;
3479 /* FIXME! Remove this arbitrary limit! */
3480 struct type *types[1024], **rval; /* allow for fns of 1023 parameters */
3486 /* Invalid argument list: no ','. */
3487 return (struct type **)-1;
3490 /* Check for and handle cretinous dbx symbol name continuation! */
3492 *pp = next_symbol_text ();
3494 types[n++] = read_type (pp, objfile);
3496 *pp += 1; /* get past `end' (the ':' character) */
3500 rval = (struct type **) xmalloc (2 * sizeof (struct type *));
3502 else if (TYPE_CODE (types[n-1]) != TYPE_CODE_VOID)
3504 rval = (struct type **) xmalloc ((n + 1) * sizeof (struct type *));
3505 memset (rval + n, 0, sizeof (struct type *));
3509 rval = (struct type **) xmalloc (n * sizeof (struct type *));
3511 memcpy (rval, types, n * sizeof (struct type *));
3515 /* Add a common block's start address to the offset of each symbol
3516 declared to be in it (by being between a BCOMM/ECOMM pair that uses
3517 the common block name). */
3520 fix_common_block (sym, valu)
3524 struct pending *next = (struct pending *) SYMBOL_NAMESPACE (sym);
3525 for ( ; next; next = next->next)
3528 for (j = next->nsyms - 1; j >= 0; j--)
3529 SYMBOL_VALUE_ADDRESS (next->symbol[j]) += valu;
3533 /* Initializer for this module */
3535 _initialize_buildsym ()
3537 undef_types_allocated = 20;
3538 undef_types_length = 0;
3539 undef_types = (struct type **) xmalloc (undef_types_allocated *
3540 sizeof (struct type *));