1 /* Read a symbol table in MIPS' format (Third-Eye).
2 Copyright (C) 1986, 1987, 1989-1991 Free Software Foundation, Inc.
3 Contributed by Alessandro Forin (af@cs.cmu.edu) at CMU
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. */
24 #include <sys/param.h>
32 #include <mips/syms.h>
35 #endif /* not CMUCS */
37 /* Since these things are defined differently on various systems I'll
38 (re)define here what I really need in this module. I only assume the
39 three standard COFF structure definitions: filehdr, aouthdr, scnhdr */
40 #define MIPS /* Kludge to get MIPS version of coff */
41 #undef _ETEXT /* Avoid duplicated define from <syms.h> */
45 struct external_filehdr f;
46 struct external_aouthdr a;
54 #define a_magic a.magic /* magic number */
55 #define a_text a.tsize /* size of text segment */
56 #define a_data a.dsize /* size of initialized data */
57 #define a_bss a.bsize /* size of uninitialized data */
58 #define a_syms f.f_nsyms /* size of symbol table */
59 #define a_entry a.entry /* entry point */
63 (((x).a_magic)!=OMAGIC && ((x).a_magic)!=NMAGIC && ((x).a_magic)!=ZMAGIC)
65 /* Things we import explicitly from other modules */
67 extern int info_verbose;
68 extern struct block *block_for_pc();
69 extern void sort_symtab_syms();
71 /* Forward declarations */
73 static void psymtab_to_symtab_1();
75 /* Macros and extra defs */
77 struct complaint unknown_ext_complaint =
78 {"unknown external symbol %s", 0, 0};
80 /* Already parsed symbols are marked specially */
82 #define stParsed stType
84 /* Puns: hard to find whether -g was used and how */
86 #define MIN_GLEVEL GLEVEL_0
87 #define compare_glevel(a,b) \
88 (((a) == GLEVEL_3) ? ((b) < GLEVEL_3) : \
89 ((b) == GLEVEL_3) ? -1 : (int)((b) - (a)))
91 /* When looking at .o files avoid tripping over bad addresses */
93 #define SAFE_TEXT_ADDR 0x400000
94 #define SAFE_DATA_ADDR 0x10000000
96 #define UNSAFE_DATA_ADDR(p) ((unsigned)p < SAFE_DATA_ADDR || (unsigned)p > 2*SAFE_DATA_ADDR)
98 /* Things that really are local to this module */
100 /* GDB symtable for the current compilation unit */
102 static struct symtab *cur_stab;
104 /* Pointer to current file decriptor record, and its index */
109 /* Index of current symbol */
113 /* Note how much "debuggable" this image is. We would like
114 to see at least one FDR with full symbols */
119 /* When examining .o files, report on undefined symbols */
121 static int n_undef_symbols, n_undef_labels, n_undef_vars, n_undef_procs;
123 /* Extra builtin types */
125 struct type *builtin_type_complex;
126 struct type *builtin_type_double_complex;
127 struct type *builtin_type_fixed_dec;
128 struct type *builtin_type_float_dec;
129 struct type *builtin_type_string;
133 static struct type *builtin_type_ptr;
134 static struct type *builtin_type_struct;
135 static struct type *builtin_type_union;
136 static struct type *builtin_type_enum;
137 static struct type *builtin_type_range;
138 static struct type *builtin_type_set;
143 static struct symbol *new_symbol();
144 static struct type *new_type();
145 static struct field *new_field();
146 static struct block *new_block();
147 static struct symtab *new_symtab();
148 static struct linetable *new_linetable();
149 static struct blockvector *new_bvect();
151 static struct type *parse_type();
152 static struct type *make_type();
153 static struct symbol *mylookup_symbol();
154 static struct block *shrink_block();
156 static int compare_symtabs();
157 static int compare_psymtabs();
158 static int compare_blocks();
160 static struct partial_symtab *new_psymtab();
161 static struct partial_symbol *new_psymbol();
162 static struct partial_symtab *parse_fdr();
163 static int compare_psymbols();
165 static void reorder_symtabs();
166 static void reorder_psymtabs();
168 /* Things we export to other modules */
171 /* Lists of partial symbols */
173 struct psymbol_allocation_list global_psymbols, static_psymbols;
175 /* Address bounds for the signal trampoline in inferior, if any */
177 CORE_ADDR sigtramp_address, sigtramp_end;
180 /* Functions that we really export */
182 /* THIS DESCRIPTION IS OBSOLETE POST-BFD; FIXME! */
183 /* Basically, this module must provide two functions: symbol_file_command()
184 which loads the symbol table from a file, and add_file_command() which
185 adds more symbols to the symbol table (incrementally).
187 These two functions only do the minimum work necessary for letting the
188 user "name" things symbolically, they do not read the entire symtab.
189 Instead, they read in the external symbols and put them in partial
190 symbol tables. When more extensive information is requested of a
191 file the corresponding partial symbol table is mutated into a full
192 fledged symbol table by going back and reading the relative symbols
193 for real. mipscoff_psymtab_to_symtab() is the function that does this */
195 /* The entry point (starting address) of the file, if it is an executable. */
197 static CORE_ADDR entry_point;
199 extern CORE_ADDR startup_file_start; /* From blockframe.c */
200 extern CORE_ADDR startup_file_end; /* From blockframe.c */
208 mipscoff_symfile_init (sf)
211 bfd *abfd = sf->sym_bfd;
212 sf->sym_private = NULL;
213 /* Save startup file's range of PC addresses to help blockframe.c
214 decide where the bottom of the stack is. */
215 if (bfd_get_file_flags (abfd) & EXEC_P)
217 /* Executable file -- record its entry point so we'll recognize
218 the startup file because it contains the entry point. */
219 entry_point = bfd_get_start_address (abfd);
223 /* Examination of non-executable.o files. Short-circuit this stuff. */
224 /* ~0 will not be in any file, we hope. */
226 /* set the startup file to be an empty range. */
227 startup_file_start = 0;
228 startup_file_end = 0;
233 mipscoff_symfile_read(sf, addr, mainline)
238 struct coff_symfile_info *info = (struct coff_symfile_info *)sf->sym_private;
239 bfd *abfd = sf->sym_bfd;
240 char *name = bfd_get_filename (abfd);
245 int stringtab_offset;
247 /* WARNING WILL ROBINSON! ACCESSING BFD-PRIVATE DATA HERE! FIXME! */
248 desc = fileno ((FILE *)(abfd->iostream)); /* Raw file descriptor */
249 num_symbols = bfd_get_symcount (abfd); /* How many syms */
250 /* symtab_offset = obj_sym_filepos (abfd); * Symbol table file offset */
251 /* stringtab_offset = symtab_offset + num_symbols * SYMESZ; * String tab */
255 debug_info = text_hdr.s_relptr;
258 dc_terminate (tdesc_handle);
264 /* Read the line number table, all at once. */
265 info->min_lineno_offset = 0;
266 info->max_lineno_offset = 0;
267 bfd_map_over_sections (abfd, find_linenos, info);
269 val = init_lineno (desc, info->min_lineno_offset,
270 info->max_lineno_offset - info->min_lineno_offset);
272 error ("\"%s\": error reading line numbers\n", name);
274 /* Now read the string table, all at once. */
276 val = init_stringtab (desc, stringtab_offset);
279 free_all_symtabs (); /* FIXME blows whole symtab */
280 printf ("\"%s\": can't get string table", name);
284 make_cleanup (free_stringtab, 0);
287 /* Position to read the symbol table. Do not read it all at once. */
288 val = lseek (desc, (long)symtab_offset, 0);
290 perror_with_name (name);
292 init_misc_bunches ();
293 make_cleanup (discard_misc_bunches, 0);
295 /* Now that the executable file is positioned at symbol table,
296 process it and define symbols accordingly. */
298 read_mips_symtab(abfd, desc, 0);
300 /* patch_opaque_types ();*/
302 /* Sort symbols alphabetically within each block. */
304 sort_all_symtab_syms ();
306 /* Go over the misc symbol bunches and install them in vector. */
308 condense_misc_bunches (0);
310 /* Make a default for file to list. */
312 select_source_symtab (0); /* FIXME, this might be too slow, see dbxread */
316 mipscoff_symfile_discard()
320 /* Exported procedure: Allocate zeroed memory */
324 char *p = xmalloc(size);
330 /* Exported procedure: Builds a symtab from the PST partial one.
331 Restores the environment in effect when PST was created, delegates
332 most of the work to an ancillary procedure, and sorts
333 and reorders the symtab list at the end */
336 static HDRR *cur_hdr; /* MIPS symtab header for the current file */
339 mipscoff_psymtab_to_symtab(pst)
340 struct partial_symtab *pst;
349 printf_filtered("Reading in symbols for %s...", pst->filename);
352 /* Restore the header and list of pending typedefs */
353 cur_hdr = (HDRR *) pst->ldsymlen;
355 psymtab_to_symtab_1(pst);
359 /* Finish up the debug error message. */
361 printf_filtered("done.\n");
364 /* Exported procedure: Is PC in the signal trampoline code */
367 in_sigtramp(pc, name)
371 if (sigtramp_address == 0)
373 return (pc >= sigtramp_address && pc < sigtramp_end);
376 /* File-level interface functions */
378 /* Read the symtab information from file FSYM into memory. Also,
379 return address just past end of our text segment in *END_OF_TEXT_SEGP. */
382 read_the_mips_symtab(abfd, fsym, end_of_text_segp)
385 CORE_ADDR *end_of_text_segp;
387 int stsize, st_hdrsize;
390 /* Header for executable/object file we read symbols from */
391 struct coff_exec filhdr;
393 /* We get here with DESC pointing to the symtab header. But we need
394 * other info from the initial headers */
396 myread(fsym, &filhdr, sizeof filhdr);
398 if (end_of_text_segp)
400 bfd_h_get_32 (abfd, filhdr.a.text_start) +
401 bfd_h_get_32 (abfd, filhdr.a.tsize);
403 /* Find and read the symbol table header */
404 st_hdrsize = bfd_h_get_32 (abfd, filhdr.f.f_nsyms);
405 st_filptr = bfd_h_get_32 (abfd, filhdr.f.f_symptr);
409 lseek(fsym, st_filptr, L_SET);
410 if (st_hdrsize > sizeof (st_hdr)) /* Profanity check */
412 if (read(fsym, &st_hdr, st_hdrsize) != st_hdrsize)
415 /* Find out how large the symbol table is */
416 stsize = (st_hdr.cbExtOffset - (st_filptr + st_hdrsize))
417 + st_hdr.iextMax * cbEXTR;
419 /* Allocate space for the symbol table. Read it in. */
420 cur_hdr = (HDRR *) xmalloc(stsize + st_hdrsize);
422 bcopy(&st_hdr, cur_hdr, st_hdrsize);
423 if (read(fsym, (char *) cur_hdr + st_hdrsize, stsize) != stsize)
426 /* Fixup file_pointers in it */
427 fixup_symtab(cur_hdr, (char *) cur_hdr + st_hdrsize,
428 st_filptr + st_hdrsize);
432 error("Short read on %s", symfile);
436 /* Turn all file-relative pointers in the symtab described by HDR
437 into memory pointers, given that the symtab itself is located
438 at DATA in memory and F_PTR in the file. */
441 fixup_symtab( hdr, data, f_ptr)
453 * These fields are useless (and empty) by now:
454 * hdr->cbDnOffset, hdr->cbOptOffset
455 * We use them for other internal purposes.
458 hdr->cbOptOffset = 0;
461 if (hdr->off) hdr->off = (unsigned int)data + (hdr->off - f_ptr);
477 * Fix all string pointers inside the symtab, and
478 * the FDR records. Also fix other miscellany.
480 for (f_idx = 0; f_idx < hdr->ifdMax; f_idx++) {
481 register unsigned code_offset;
483 /* Header itself, and strings */
484 fh = (FDR *) (hdr->cbFdOffset) + f_idx;
485 fh->issBase += hdr->cbSsOffset;
487 fh->rss = (long)fh->rss + fh->issBase;
488 for (s_idx = 0; s_idx < fh->csym; s_idx++) {
489 sh = (SYMR*)(hdr->cbSymOffset) + fh->isymBase + s_idx;
490 sh->iss = (long) sh->iss + fh->issBase;
497 fh->isymBase = (int)((SYMR*)(hdr->cbSymOffset)+fh->isymBase);
499 /* cannot fix fh->ipdFirst because it is a short */
500 #define IPDFIRST(h,fh) \
501 ((long)h->cbPdOffset + fh->ipdFirst * sizeof(PDR))
503 /* Optional symbols (actually used for partial_symtabs) */
509 fh->iauxBase = hdr->cbAuxOffset + fh->iauxBase * sizeof(AUXU);
510 /* Relative file descriptor table */
511 fh->rfdBase = hdr->cbRfdOffset + fh->rfdBase * sizeof(RFDT);
515 fh->cbLineOffset += hdr->cbLineOffset;
517 /* Procedure symbols. (XXX This should be done later) */
518 code_offset = fh->adr;
519 for (s_idx = 0; s_idx < fh->cpd; s_idx++) {
520 unsigned name, only_ext;
522 pr = (PDR*)(IPDFIRST(hdr,fh)) + s_idx;
524 /* Simple rule to find files linked "-x" */
525 only_ext = fh->rss == -1;
527 if (pr->isym == -1) {
528 /* static function */
532 name = hdr->cbExtOffset + pr->isym * sizeof(EXTR);
533 sh = &((EXTR*)name)->asym;
537 sh = (SYMR*)fh->isymBase + pr->isym;
538 /* Included code ? */
539 if (s_idx == 0 && pr->adr != 0)
540 code_offset -= pr->adr;
543 /* Turn index into a pointer */
546 /* Fix line numbers */
547 pr->cbLineOffset += fh->cbLineOffset;
549 /* Relocate address */
551 pr->adr += code_offset;
555 /* External symbols: fix string */
556 for (s_idx = 0; s_idx < hdr->iextMax; s_idx++) {
557 esh = (EXTR*)(hdr->cbExtOffset) + s_idx;
558 esh->asym.iss = esh->asym.iss + hdr->cbSsExtOffset;
563 /* Find a file descriptor given its index RF relative to a file CF */
566 FDR *get_rfd( cf, rf)
570 f = (FDR *) (cur_hdr->cbFdOffset) + cf;
571 /* Object files do not have the RFD table, all refs are absolute */
573 return (FDR *) (cur_hdr->cbFdOffset) + rf;
574 cf = *((pRFDT) f->rfdBase + rf);
575 return (FDR *) (cur_hdr->cbFdOffset) + cf;
578 /* Return a safer print NAME for a file descriptor */
584 if (name == (char *) -1)
585 return "<stripped file>";
586 if (UNSAFE_DATA_ADDR(name))
592 /* Read in and parse the symtab of the file DESC. INCREMENTAL says
593 whether we are adding to the general symtab or not.
594 FIXME: INCREMENTAL is currently always zero, though it should not be. */
597 read_mips_symtab (abfd, desc, incremental)
602 CORE_ADDR end_of_text_seg;
604 read_the_mips_symtab(abfd, desc, &end_of_text_seg);
606 parse_partial_symbols(cur_hdr, incremental, end_of_text_seg);
610 * Check to make sure file was compiled with -g.
611 * If not, warn the user of this limitation.
613 if (compare_glevel(max_glevel, GLEVEL_2) < 0) {
614 if (max_gdbinfo == 0)
615 printf("\n%s not compiled with -g, debugging support is limited.", symfile);
616 printf("\nYou should compile with -g2 or -g3 for best debugging support.\n");
621 * Dont allow char * to have a typename (else would get
624 TYPE_NAME(lookup_pointer_type(builtin_type_char)) = 0;
628 /* Local utilities */
631 /* Map of FDR indexes to partial symtabs */
633 static struct pst_map {
634 struct partial_symtab *pst; /* the psymtab proper */
635 int n_globals; /* globals it exports */
639 /* Utility stack, used to nest procedures and blocks properly.
640 It is a doubly linked list, to avoid too many alloc/free.
641 Since we might need it quite a few times it is NOT deallocated
644 static struct parse_stack {
645 struct parse_stack *next, *prev;
646 struct symtab *cur_st; /* Current symtab */
647 struct block *cur_block; /* Block in it */
648 int blocktype; /* What are we parsing */
649 int maxsyms; /* Max symbols in this block */
650 struct type *cur_type; /* Type we parse fields for */
651 int procadr; /* Start addres of this procedure */
652 int numargs; /* Its argument count */
653 } *top_stack; /* Top stack ptr */
656 /* Enter a new lexical context */
658 static push_parse_stack()
660 struct parse_stack *new;
662 /* Reuse frames if possible */
663 if (top_stack && top_stack->prev)
664 new = top_stack->prev;
666 new = (struct parse_stack *) xzalloc(sizeof(struct parse_stack));
667 /* Initialize new frame with previous content */
669 register struct parse_stack *prev = new->prev;
672 top_stack->prev = new;
674 new->next = top_stack;
679 /* Exit a lexical context */
681 static pop_parse_stack()
686 top_stack = top_stack->next;
690 /* Cross-references might be to things we haven't looked at
691 yet, e.g. type references. To avoid too many type
692 duplications we keep a quick fixup table, an array
693 of lists of references indexed by file descriptor */
695 static struct pending {
696 struct pending *next; /* link */
697 SYMR *s; /* the symbol */
698 struct type *t; /* its partial type descriptor */
702 /* Check whether we already saw symbol SH in file FH as undefined */
705 struct pending *is_pending_symbol(fh, sh)
709 int f_idx = fh - (FDR *) cur_hdr->cbFdOffset;
710 register struct pending *p;
712 /* Linear search is ok, list is typically no more than 10 deep */
713 for (p = pending_list[f_idx]; p; p = p->next)
719 /* Check whether we already saw type T in file FH as undefined */
722 struct pending *is_pending_type(fh, t)
726 int f_idx = fh - (FDR *) cur_hdr->cbFdOffset;
727 register struct pending *p;
729 for (p = pending_list[f_idx]; p; p = p->next)
735 /* Add a new undef symbol SH of type T */
738 add_pending(fh, sh, t)
743 int f_idx = fh - (FDR *) cur_hdr->cbFdOffset;
744 struct pending *p = is_pending_symbol(fh, sh);
746 /* Make sure we do not make duplicates */
748 p = (struct pending *) xmalloc(sizeof(*p));
751 p->next = pending_list[f_idx];
752 pending_list[f_idx] = p;
754 sh->reserved = 1; /* for quick check */
757 /* Throw away undef entries when done with file index F_IDX */
762 register struct pending *p, *q;
764 for (p = pending_list[f_idx]; p; p = q) {
768 pending_list[f_idx] = 0;
771 /* The number of args to a procedure is not explicit in the symtab,
772 this is the list of all those we know of.
773 This makes parsing more reasonable and avoids extra passes */
775 static struct numarg {
776 struct numarg *next; /* link */
777 unsigned adr; /* procedure's start address */
778 unsigned num; /* arg count */
781 /* Record that the procedure at ADR takes NUM arguments. */
786 struct numarg *n = (struct numarg *) xmalloc(sizeof(struct numarg));
790 n->next = numargs_list;
794 /* See if we know how many arguments the procedure at ADR takes */
799 struct numarg *n = numargs_list;
801 while (n && n->adr != adr)
803 return (n) ? n->num : -1;
806 /* Release storage when done with this file */
811 struct numarg *n = numargs_list, *m;
822 /* Parsing Routines proper. */
824 /* Parse a single symbol. Mostly just make up a GDB symbol for it.
825 For blocks, procedures and types we open a new lexical context.
826 This is basically just a big switch on the symbol's type */
837 /* When a symbol is cross-referenced from other files/symbols
838 we mark it explicitly */
839 int pend = (sh->reserved == 1);
840 enum address_class class;
847 case stGlobal: /* external symbol, goes into the primary block */
849 b = BLOCKVECTOR_BLOCK(BLOCKVECTOR(top_stack->cur_st),
853 case stStatic: /* static data, goes into the current block. */
855 b = top_stack->cur_block;
858 case stLocal: /* local variable, goes into the current block */
859 if (sh->sc == scRegister) {
860 class = LOC_REGISTER;
865 b = top_stack->cur_block;
867 data: /* Common code for symbols describing data */
868 s = new_symbol(sh->iss);
869 SYMBOL_NAMESPACE(s) = VAR_NAMESPACE;
870 SYMBOL_CLASS(s) = class;
873 /* Type could be missing in a number of cases */
874 if (sh->sc == scUndefined || sh->sc == scNil ||
875 sh->index == 0xfffff)
876 SYMBOL_TYPE(s) = builtin_type_int; /* undefined? */
878 SYMBOL_TYPE(s) = parse_type(ax + sh->index, sh, 0);
879 /* Value of a data symbol is its memory address */
880 SYMBOL_VALUE(s) = sh->value;
883 case stParam: /* argument to procedure, goes into current block */
885 top_stack->numargs++;
886 s = new_symbol(sh->iss);
887 SYMBOL_NAMESPACE(s) = VAR_NAMESPACE;
888 if (sh->sc == scRegister) {
889 SYMBOL_CLASS(s) = LOC_REGPARM;
893 SYMBOL_CLASS(s) = LOC_ARG;
894 SYMBOL_VALUE(s) = sh->value;
895 SYMBOL_TYPE(s) = parse_type(ax + sh->index, sh, 0);
896 add_symbol(s, top_stack->cur_block);
899 case stLabel: /* label, we do make a symbol for it */
900 s = new_symbol(sh->iss);
901 SYMBOL_NAMESPACE(s) = VAR_NAMESPACE; /* so that it can be used */
902 SYMBOL_CLASS(s) = LOC_LABEL; /* but not misused */
903 SYMBOL_VALUE(s) = sh->value;
904 SYMBOL_TYPE(s) = builtin_type_int;
905 add_symbol(s, top_stack->cur_block);
908 case stProc: /* Procedure */
909 case stStaticProc: /* Static procedure */
910 s = new_symbol(sh->iss);
911 SYMBOL_NAMESPACE(s) = VAR_NAMESPACE;
912 SYMBOL_CLASS(s) = LOC_BLOCK;
913 /* Type of the return value */
914 if (sh->sc == scUndefined || sh->sc == scNil)
915 t = builtin_type_int;
917 t = parse_type(ax + sh->index, sh, 0);
918 add_symbol(s, top_stack->cur_block);
920 /* Make a type for the procedure itself */
921 SYMBOL_TYPE(s) = lookup_function_type (t);
923 /* Create and enter a new lexical context */
924 b = new_block(top_stack->maxsyms);
925 SYMBOL_BLOCK_VALUE(s) = b;
926 BLOCK_FUNCTION(b) = s;
927 BLOCK_START(b) = BLOCK_END(b) = sh->value;
928 BLOCK_SUPERBLOCK(b) = top_stack->cur_block;
929 add_block(b, top_stack->cur_st);
931 /* Not if we only have partial info */
932 if (sh->sc == scUndefined || sh->sc == scNil)
936 top_stack->cur_block = b;
937 top_stack->blocktype = sh->st;
938 top_stack->cur_type = SYMBOL_TYPE(s);
939 top_stack->procadr = sh->value;
940 top_stack->numargs = 0;
942 sh->value = (long) SYMBOL_TYPE(s);
945 case stBlock: /* Either a lexical block, or some type */
947 top_stack->blocktype = stBlock;
948 if (sh->sc == scInfo) { /* structure/union/enum def */
949 s = new_symbol(sh->iss);
950 SYMBOL_NAMESPACE(s) = STRUCT_NAMESPACE;
951 SYMBOL_CLASS(s) = LOC_TYPEDEF;
953 add_symbol(s, top_stack->cur_block);
954 /* If this type was expected, use its partial definition */
956 t = is_pending_symbol(cur_fdr, sh)->t;
958 /* Uhmm, can`t decide yet. Smash later */
959 t = new_type(sh->iss);
960 TYPE_CODE(t) = TYPE_CODE_UNDEF;
961 add_pending(cur_fdr, sh, t);
964 /* make this the current type */
965 top_stack->cur_type = t;
966 TYPE_LENGTH(t) = sh->value;
967 /* Mark that symbol has a type, and say which one */
968 sh->value = (long) t;
970 /* beginnning of (code) block. Value of symbol
971 is the displacement from procedure start */
972 b = new_block(top_stack->maxsyms);
973 BLOCK_START(b) = sh->value + top_stack->procadr;
974 BLOCK_SUPERBLOCK(b) = top_stack->cur_block;
975 top_stack->cur_block = b;
976 add_block(b, top_stack->cur_st);
980 case stEnd: /* end (of anything) */
981 if (sh->sc == scInfo) {
982 /* Finished with type */
983 top_stack->cur_type = 0;
984 } else if (sh->sc == scText &&
985 (top_stack->blocktype == stProc ||
986 top_stack->blocktype == stStaticProc)) {
987 /* Finished with procedure */
988 struct blockvector *bv = BLOCKVECTOR(top_stack->cur_st);
992 BLOCK_END(top_stack->cur_block) += sh->value; /* size */
993 got_numargs(top_stack->procadr, top_stack->numargs);
994 /* Reallocate symbols, saving memory */
995 b = shrink_block(top_stack->cur_block, top_stack->cur_st);
997 /* f77 emits proc-level with address bounds==[0,0],
998 So look for such child blocks, and patch them. */
999 for (i = 0; i < BLOCKVECTOR_NBLOCKS(bv); i++) {
1000 struct block *b_bad = BLOCKVECTOR_BLOCK(bv,i);
1001 if (BLOCK_SUPERBLOCK(b_bad) == b
1002 && BLOCK_START(b_bad) == top_stack->procadr
1003 && BLOCK_END(b_bad) == top_stack->procadr) {
1004 BLOCK_START(b_bad) = BLOCK_START(b);
1005 BLOCK_END(b_bad) = BLOCK_END(b);
1008 if (entry_point < BLOCK_END(b)
1009 && entry_point >= BLOCK_START(b)) {
1010 startup_file_start = BLOCK_START(b);
1011 startup_file_end = BLOCK_END(b);
1013 } else if (sh->sc == scText && top_stack->blocktype == stBlock) {
1014 /* End of (code) block. The value of the symbol
1015 is the displacement from the procedure`s start
1016 address of the end of this block. */
1017 BLOCK_END(top_stack->cur_block) = sh->value + top_stack->procadr;
1018 (void) shrink_block(top_stack->cur_block, top_stack->cur_st);
1020 pop_parse_stack(); /* restore previous lexical context */
1023 case stMember: /* member of struct/union/enum.. */
1024 f = new_field(top_stack->cur_type, sh->iss);
1025 f->bitpos = sh->value;
1026 f->type = parse_type(ax + sh->index, sh, &f->bitsize);
1029 case stTypedef: /* type definition */
1030 s = new_symbol(sh->iss);
1031 SYMBOL_NAMESPACE(s) = VAR_NAMESPACE;
1032 SYMBOL_CLASS(s) = LOC_TYPEDEF;
1033 SYMBOL_BLOCK_VALUE(s) = top_stack->cur_block;
1034 add_symbol(s, top_stack->cur_block);
1035 SYMBOL_TYPE(s) = parse_type(ax + sh->index, sh, 0);
1036 sh->value = (long) SYMBOL_TYPE(s);
1039 case stFile: /* file name */
1041 top_stack->blocktype = sh->st;
1044 /* I`ve never seen these for C */
1046 break; /* register relocation */
1048 break; /* forwarding address */
1050 break; /* constant */
1052 error("Unknown symbol type %x.", sh->st);
1057 /* Parse the type information provided in the AX entries for
1058 the symbol SH. Return the bitfield size in BS, in case. */
1060 static struct type *parse_type(ax, sh, bs)
1065 /* Null entries in this map are treated specially */
1066 static struct type **map_bt[] =
1068 &builtin_type_void, /* btNil */
1070 &builtin_type_char, /* btChar */
1071 &builtin_type_unsigned_char, /* btUChar */
1072 &builtin_type_short, /* btShort */
1073 &builtin_type_unsigned_short, /* btUShort */
1074 &builtin_type_int, /* btInt */
1075 &builtin_type_unsigned_int, /* btUInt */
1076 &builtin_type_long, /* btLong */
1077 &builtin_type_unsigned_long, /* btULong */
1078 &builtin_type_float, /* btFloat */
1079 &builtin_type_double, /* btDouble */
1086 &builtin_type_complex, /* btComplex */
1087 &builtin_type_double_complex, /* btDComplex */
1089 &builtin_type_fixed_dec, /* btFixedDec */
1090 &builtin_type_float_dec, /* btFloatDec */
1091 &builtin_type_string, /* btString */
1094 &builtin_type_void, /* btVoid */
1098 struct type *tp = 0, *tp1;
1101 /* Procedures start off by one */
1102 if (sh->st == stProc || sh->st == stStaticProc)
1105 /* Undefined ? Should not happen */
1106 if (ax->rndx.rfd == 0xfff) {
1107 return builtin_type_void;
1110 /* Use aux as a type information record, map its basic type */
1112 if (t->bt > 26 || t->bt == btPicture) {
1113 printf_filtered("Internal: cannot map MIPS basic type x%x\n", t->bt);
1114 return builtin_type_int;
1117 tp = *map_bt[t->bt];
1119 /* Cannot use builtin types, use templates */
1120 tp = make_type(TYPE_CODE_VOID, 0, 0, 0);
1123 *tp = *builtin_type_ptr;
1126 *tp = *builtin_type_struct;
1130 *tp = *builtin_type_union;
1134 *tp = *builtin_type_enum;
1138 *tp = *builtin_type_range;
1141 *tp = *builtin_type_set;
1147 /* Move on to next aux */
1150 /* This is the way it would work if the compiler worked */
1151 register TIR *t1 = t;
1152 while (t1->continued)
1156 /* For bitfields all we need is the width */
1162 /* All these types really point to some (common) MIPS type
1163 definition, and only the type-qualifiers fully identify
1164 them. We`ll make the same effort at sharing */
1165 if (t->bt == btIndirect ||
1166 t->bt == btStruct ||
1169 t->bt == btTypedef ||
1172 char name[256], *pn;
1174 /* Try to cross reference this type */
1176 ax += cross_ref(ax, &tp1, &pn);
1177 /* SOMEONE OUGHT TO FIX DBXREAD TO DROP "STRUCT" */
1178 sprintf(name, fmt, pn);
1180 /* reading .o file ? */
1181 if (UNSAFE_DATA_ADDR(tp1))
1183 if (TYPE_CODE(tp1) == TYPE_CODE_UNDEF) {
1185 * Type was incompletely defined, now we know.
1187 TYPE_CODE(tp1) = TYPE_CODE(tp);
1188 TYPE_NAME(tp1) = obsavestring(name, strlen(name));
1189 if (TYPE_CODE(tp1) == TYPE_CODE_ENUM) {
1192 for (i = 0; i < TYPE_NFIELDS(tp1); i++)
1193 make_enum_constant(&TYPE_FIELD(tp1,i), tp1);
1197 /* found as cross ref, rid of our template */
1198 if ((TYPE_FLAGS(tp) & TYPE_FLAG_PERM) == 0)
1201 /* stupid idea of prepending "struct" to type names */
1202 if (t->bt == btStruct && !index(TYPE_NAME(tp), ' ')) {
1203 sprintf(name, fmt, TYPE_NAME(tp));
1204 TYPE_NAME(tp) = obsavestring(name, strlen(name));
1207 TYPE_NAME(tp) = savestring(name, strlen(name));
1210 /* Deal with range types */
1211 if (t->bt == btRange) {
1214 f = new_field(tp, "Low");
1215 f->bitpos = ax->dnLow;
1217 f = new_field(tp, "High");
1218 f->bitpos = ax->dnHigh;
1222 /* Parse all the type qualifiers now. If there are more
1223 than 6 the game will continue in the next aux */
1225 #define PARSE_TQ(tq) \
1226 if (t->tq != tqNil) ax += upgrade_type(&tp, t->tq, ax, sh);
1228 again: PARSE_TQ(tq0);
1243 /* Make up a complex type from a basic one. Type is passed by
1244 reference in TPP and side-effected as necessary. The type
1245 qualifier TQ says how to handle the aux symbols at AX for
1246 the symbol SX we are currently analyzing.
1247 Returns the number of aux symbols we parsed. */
1250 upgrade_type(tpp, tq, ax, sh)
1260 t = lookup_pointer_type (*tpp);
1261 } else if (tq == tqProc) {
1262 t = lookup_function_type (*tpp);
1263 } else if (tq == tqArray) {
1269 t = make_type(TYPE_CODE_ARRAY, 0, 0, 0);
1270 TYPE_TARGET_TYPE(t) = *tpp;
1272 /* Pointer to domain type (type of index) */
1273 id = ax->rndx.index;
1274 if ((rf = ax->rndx.rfd) == 0xfff)
1275 rf = (++ax)->isym, off++;
1277 fh = get_rfd(cur_fd, rf);
1278 f = new_field(t, 0);
1279 bzero(&ss, sizeof ss);
1280 /* XXX */ f->type = parse_type(fh->iauxBase + id * sizeof(AUXU),
1284 * This seems to be a pointer to the end of the Block defining
1285 * the type. Why it is here is magic for me, and I have no
1286 * good use for it anyways.
1290 id = (++ax)->rndx.index;
1291 if ((rf = ax->rndx.rfd) == 0xfff)
1292 rf = (++ax)->isym, off++;
1294 f->bitpos = (++ax)->dnLow; /* ?? */
1295 f->bitsize = (++ax)->dnHigh; /* ?? */
1296 rf = (++ax)->width - 1; /* bit alignment */
1297 id = TYPE_LENGTH(TYPE_TARGET_TYPE(t)) << 3; /* bitsize */
1300 /* Most likely an undefined type */
1302 TYPE_LENGTH(TYPE_TARGET_TYPE(t)) = id >> 3;
1304 TYPE_LENGTH(t) = (f->bitsize < 0) ? 0 :
1305 (f->bitsize - f->bitpos + 1) * (id >> 3);
1309 printf_filtered("Internal: unknown type qualifier %x\n", tq);
1318 /* Parse a procedure descriptor record PR. Note that the procedure
1319 is parsed _after_ the local symbols, now we just make up the
1320 extra information we need into a special symbol that we insert
1321 in the procedure's main block. Note also that images that
1322 have been partially stripped (ld -x) have been deprived
1323 of local symbols, and we have to cope with them here.
1324 The procedure's code ends at BOUND */
1327 parse_procedure(pr, bound)
1330 struct symbol *s, *i;
1331 SYMR *sh = (SYMR*)pr->isym;
1333 struct mips_extra_func_info *e;
1337 /* Reuse the MIPS record */
1338 e = (struct mips_extra_func_info *) pr;
1339 e->numargs = lookup_numargs(pr->adr);
1341 /* Make up our special symbol */
1342 i = new_symbol(".gdbinfo.");
1343 SYMBOL_VALUE(i) = (int)e;
1344 SYMBOL_NAMESPACE(i) = LABEL_NAMESPACE;
1345 SYMBOL_CLASS(i) = LOC_CONST;
1346 SYMBOL_TYPE(i) = builtin_type_void;
1348 /* Make up a name for static procedures. Sigh. */
1349 if (sh == (SYMR*)-1) {
1350 sprintf(name,".static_procedure@%x",pr->adr);
1351 sh_name = savestring(name, strlen(name));
1355 sh_name = (char*)sh->iss;
1356 s = mylookup_symbol(sh_name, top_stack->cur_block,
1357 VAR_NAMESPACE, LOC_BLOCK);
1360 b = SYMBOL_BLOCK_VALUE(s);
1362 s = new_symbol(sh_name);
1363 SYMBOL_NAMESPACE(s) = VAR_NAMESPACE;
1364 SYMBOL_CLASS(s) = LOC_BLOCK;
1365 /* Donno its type, hope int is ok */
1366 SYMBOL_TYPE(s) = lookup_function_type (builtin_type_int);
1367 add_symbol(s, top_stack->cur_block);
1368 /* Wont have symbols for this one */
1370 SYMBOL_BLOCK_VALUE(s) = b;
1371 BLOCK_FUNCTION(b) = s;
1372 BLOCK_START(b) = pr->adr;
1373 BLOCK_END(b) = bound;
1374 BLOCK_SUPERBLOCK(b) = top_stack->cur_block;
1375 add_block(b, top_stack->cur_st);
1381 /* Parse the external symbol ES. Just call parse_symbol() after
1382 making sure we know where the aux are for it. For procedures,
1383 parsing of the PDRs has already provided all the needed
1384 information, we only parse them if SKIP_PROCEDURES is false,
1385 and only if this causes no symbol duplication */
1388 parse_external(es, skip_procedures)
1393 if (es->ifd != ifdNil) {
1395 cur_fdr = (FDR*)(cur_hdr->cbFdOffset) + cur_fd;
1396 ax = (AUXU*)cur_fdr->iauxBase;
1398 cur_fdr = (FDR*)(cur_hdr->cbFdOffset);
1401 top_stack->cur_st = cur_stab;
1402 top_stack->cur_block = BLOCKVECTOR_BLOCK(BLOCKVECTOR(top_stack->cur_st),
1405 /* Reading .o files */
1406 if (es->asym.sc == scUndefined || es->asym.sc == scNil) {
1408 switch (es->asym.st) {
1410 case stProc: what = "Procedure"; n_undef_procs++; break;
1411 case stGlobal: what = "Variable"; n_undef_vars++; break;
1412 case stLabel: what = "Label"; n_undef_labels++; break;
1413 default : what = "Symbol"; break;
1417 printf_filtered("Warning: %s %s is undefined (in %s)\n", what,
1418 es->asym.iss, fdr_name(cur_fdr->rss));
1422 switch (es->asym.st) {
1424 /* If we have full symbols we do not need more */
1425 if (skip_procedures)
1427 if (mylookup_symbol (es->asym.iss, top_stack->cur_block,
1428 VAR_NAMESPACE, LOC_BLOCK))
1434 * Note that the case of a symbol with indexNil
1435 * must be handled anyways by parse_symbol().
1437 parse_symbol(&es->asym, ax);
1444 /* Parse the line number info for file descriptor FH into
1445 GDB's linetable LT. MIPS' encoding requires a little bit
1446 of magic to get things out. Note also that MIPS' line
1447 numbers can go back and forth, apparently we can live
1448 with that and do not need to reorder our linetables */
1453 struct linetable *lt;
1455 char *base = (char*)fh->cbLineOffset;
1457 int delta, count, lineno = 0;
1463 /* Scan by procedure descriptors */
1464 i = 0; j = 0, k = 0;
1465 for (pr = (PDR*)IPDFIRST(cur_hdr,fh); j < fh->cpd; j++, pr++) {
1468 /* No code for this one */
1469 if (pr->iline == ilineNil ||
1470 pr->lnLow == -1 || pr->lnHigh == -1)
1473 * Aurgh! To know where to stop expanding we
1476 for (l = 1; l < (fh->cpd - j); l++)
1477 if (pr[l].iline != -1)
1479 if (l == (fh->cpd - j))
1484 * When procedures are moved around the linenumbers
1485 * are attributed to the next procedure up
1487 if (pr->iline >= halt) continue;
1489 base = (char*)pr->cbLineOffset;
1490 l = pr->adr >> 2; /* in words */
1491 halt += (pr->adr >> 2) - pr->iline;
1492 for (lineno = pr->lnLow; l < halt;) {
1493 count = *base & 0x0f;
1494 delta = *base++ >> 4;
1496 delta = (base[0] << 8) | (base[1] & 0xff);
1499 lineno += delta;/* first delta is 0 */
1500 k = add_line(lt, lineno, l, k);
1507 /* Parse the symbols of the file described by FH, whose index is F_IDX.
1508 BOUND is the highest core address of this file's procedures */
1511 parse_one_file(fh, f_idx, bound)
1518 /* Parse local symbols first */
1520 for (s_idx = 0; s_idx < fh->csym; s_idx++) {
1521 sh = (SYMR *) (fh->isymBase) + s_idx;
1523 parse_symbol(sh, fh->iauxBase);
1526 /* Procedures next, note we need to look-ahead to
1527 find out where the procedure's code ends */
1529 for (s_idx = 0; s_idx < fh->cpd-1; s_idx++) {
1530 pr = (PDR *) (IPDFIRST(cur_hdr, fh)) + s_idx;
1531 parse_procedure(pr, pr[1].adr); /* next proc up */
1534 pr = (PDR *) (IPDFIRST(cur_hdr, fh)) + s_idx;
1535 parse_procedure(pr, bound); /* next file up */
1538 /* Linenumbers. At the end, check if we can save memory */
1539 parse_lines(fh, LINETABLE(cur_stab));
1540 if (LINETABLE(cur_stab)->nitems < fh->cline)
1541 shrink_linetable(cur_stab);
1545 /* Master parsing procedure. Parses the symtab described by the
1546 symbolic header HDR. If INCREMENTAL is true we are called
1547 by add-file and must preserve the old symtabs. END_OF_TEXT_SEG
1548 gives the address just after the text segment for the symtab
1551 parse_partial_symbols(hdr, incremental, end_of_text_seg)
1554 int f_idx, s_idx, h_max;
1555 CORE_ADDR dummy, *prevhigh;
1556 /* Running pointers */
1564 * Only parse the External symbols, and the Relative FDR.
1565 * Fixup enough of the loader symtab to be able to use it.
1566 * Allocate space only for the file`s portions we need to
1572 max_glevel = MIN_GLEVEL;
1574 /* Allocate the map FDR -> PST.
1575 Minor hack: -O3 images might claim some global data belongs
1576 to FDR -1. We`ll go along with that */
1577 fdr_to_pst = (struct pst_map *)xzalloc((hdr->ifdMax+1) * sizeof *fdr_to_pst);
1580 struct partial_symtab * pst = new_psymtab("");
1581 fdr_to_pst[-1].pst = pst;
1585 /* Now scan the FDRs, mostly for dependencies */
1586 for (f_idx = 0; f_idx < hdr->ifdMax; f_idx++)
1587 (void) parse_fdr(f_idx, 1);
1589 /* Take a good guess at how many symbols we might ever need */
1590 h_max = hdr->iextMax;
1592 /* Parse externals: two passes because they can be ordered
1595 /* Pass 1: Presize and partition the list */
1596 for (s_idx = 0; s_idx < hdr->iextMax; s_idx++) {
1597 esh = (EXTR *) (hdr->cbExtOffset) + s_idx;
1598 fdr_to_pst[esh->ifd].n_globals++;
1601 if (global_psymbols.list) {
1602 global_psymbols.list = (struct partial_symbol *)
1603 xrealloc( global_psymbols.list, (h_max +
1604 global_psymbols.size) * sizeof(struct partial_symbol));
1605 global_psymbols.next = global_psymbols.list + global_psymbols.size;
1606 global_psymbols.size += h_max;
1608 global_psymbols.list = (struct partial_symbol *)
1609 xmalloc( h_max * sizeof(struct partial_symbol));
1610 global_psymbols.size = h_max;
1611 global_psymbols.next = global_psymbols.list;
1614 s_idx = global_psymbols.next - global_psymbols.list;
1615 for (f_idx = -1; f_idx < hdr->ifdMax; f_idx++) {
1616 fdr_to_pst[f_idx].pst->globals_offset = s_idx;
1617 s_idx += fdr_to_pst[f_idx].n_globals;
1620 /* Pass 2: fill in symbols */
1621 for (s_idx = 0; s_idx < hdr->iextMax; s_idx++) {
1622 register struct partial_symbol *p;
1623 enum misc_function_type misc_type = mf_text;
1624 esh = (EXTR *) (hdr->cbExtOffset) + s_idx;
1626 if (esh->asym.sc == scUndefined || esh->asym.sc == scNil)
1628 p = new_psymbol(&global_psymbols, esh->asym.iss, esh->ifd);
1629 SYMBOL_VALUE(p) = esh->asym.value;
1630 SYMBOL_NAMESPACE(p) = VAR_NAMESPACE;
1632 switch (esh->asym.st) {
1634 SYMBOL_CLASS(p) = LOC_BLOCK;
1637 SYMBOL_CLASS(p) = LOC_STATIC;
1638 misc_type = mf_data;
1641 SYMBOL_CLASS(p) = LOC_LABEL;
1644 misc_type = mf_unknown;
1645 complain (&unknown_ext_complaint, SYMBOL_NAME(p));
1647 prim_record_misc_function (SYMBOL_NAME(p),
1653 /* The array (of lists) of globals must be sorted.
1654 Take care, since we are at it, of pst->texthigh.
1656 NOTE: The way we handle textlow/high is incorrect, but good
1657 enough for a first approximation. The case we fail is on a
1658 file "foo.c" that looks like
1660 #include "bar.c" -- this contains proc2()
1662 where proc3() is attributed to bar.c. But since this is a
1663 dependent file it will cause loading of foo.c as well, so
1664 everything will be fine at the end. */
1667 for (f_idx = 0; f_idx < hdr->ifdMax; f_idx++) {
1668 struct partial_symtab *pst = fdr_to_pst[f_idx].pst;
1669 if (pst->n_global_syms > 1)
1670 qsort (global_psymbols.list + pst->globals_offset,
1671 pst->n_global_syms, sizeof (struct partial_symbol),
1674 *prevhigh = pst->textlow;
1675 prevhigh = &pst->texthigh;
1679 /* Mark the last code address, and remember it for later */
1680 *prevhigh = end_of_text_seg;
1681 hdr->cbDnOffset = end_of_text_seg;
1684 free(&fdr_to_pst[-1]);
1689 /* Do the initial analisys of the F_IDX-th file descriptor.
1690 Allocates a partial symtab for it, and builds the list
1691 of dependent files by recursion. LEV says at which level
1692 of recursion we are called (to pretty up debug traces) */
1694 static struct partial_symtab *
1695 parse_fdr(f_idx, lev)
1699 register struct partial_symtab *pst;
1702 fh = (FDR *) (cur_hdr->cbFdOffset) + f_idx;
1704 /* Use this to indicate into which symtab this file was parsed */
1706 return (struct partial_symtab *) fh->ioptBase;
1708 /* Debuggability level */
1709 if (compare_glevel(max_glevel, fh->glevel) < 0)
1710 max_glevel = fh->glevel;
1712 /* Make a new partial_symtab */
1713 pst = new_psymtab(fh->rss);
1718 pst->textlow = fh->adr;
1719 pst->texthigh = fh->cpd; /* To be fixed later */
1721 /* Reverse mapping PST -> FDR */
1722 pst->ldsymoff = f_idx;
1724 fdr_to_pst[f_idx].pst = pst;
1725 fh->ioptBase = (int)pst;
1727 /* Analyze its dependencies */
1732 if (fh->cpd == 0) { /* If there are no functions defined here ... */
1733 /* ...then presumably a .h file: drop reverse depends .h->.c */
1734 for (; s_id0 < fh->crfd; s_id0++) {
1735 RFDT *rh = (RFDT *) (fh->rfdBase) + s_id0;
1737 s_id0++; /* Skip self-dependency */
1742 pst->number_of_dependencies = fh->crfd - s_id0;
1743 pst->dependencies = (struct partial_symtab **)
1744 obstack_alloc (psymbol_obstack,
1745 pst->number_of_dependencies * sizeof(char*));
1746 for (s_idx = s_id0; s_idx < fh->crfd; s_idx++) {
1747 RFDT *rh = (RFDT *) (fh->rfdBase) + s_idx;
1749 pst->dependencies[s_idx-s_id0] = parse_fdr(*rh, lev+1);
1757 /* Ancillary function to psymtab_to_symtab(). Does all the work
1758 for turning the partial symtab PST into a symtab, recurring
1759 first on all dependent psymtabs */
1762 psymtab_to_symtab_1(pst)
1763 struct partial_symtab *pst;
1773 pending_list = (struct pending **) cur_hdr->cbOptOffset;
1774 if (pending_list == 0) {
1775 pending_list = (struct pending **)
1776 xzalloc(cur_hdr->ifdMax * sizeof(struct pending *));
1777 cur_hdr->cbOptOffset = (int)pending_list;
1780 /* How many symbols will we need */
1781 f_max = pst->n_global_syms + pst->n_static_syms;
1782 if (pst->ldsymoff == -1) {
1784 st = new_symtab( "unknown", f_max, 0);
1786 fh = (FDR *) (cur_hdr->cbFdOffset) + pst->ldsymoff;
1787 f_max += fh->csym + fh->cpd;
1788 st = new_symtab(pst->filename, 2 * f_max, 2 * fh->cline);
1792 * Read in all partial symbtabs on which this one is dependent.
1793 * NOTE that we do have circular dependencies, sigh.
1795 for (i = 0; i < pst->number_of_dependencies; i++)
1796 if (!pst->dependencies[i]->readin) {
1798 * DO NOT inform about additional files that need to
1799 * be read in, it would only annoy the user.
1801 psymtab_to_symtab_1(pst->dependencies[i]);
1804 /* Now read the symbols for this symtab */
1806 cur_fd = pst->ldsymoff;
1810 /* Get a new lexical context */
1813 top_stack->cur_st = cur_stab;
1814 top_stack->cur_block = BLOCKVECTOR_BLOCK(BLOCKVECTOR(cur_stab),
1816 BLOCK_START(top_stack->cur_block) = fh ? fh->adr : 0;
1817 BLOCK_END(top_stack->cur_block) = 0;
1818 top_stack->blocktype = stFile;
1819 top_stack->maxsyms = f_max;
1820 top_stack->cur_type = 0;
1821 top_stack->procadr = 0;
1822 top_stack->numargs = 0;
1824 /* Parse locals and procedures */
1826 parse_one_file(fh, cur_fd, (cur_fd == (cur_hdr->ifdMax - 1)) ?
1827 cur_hdr->cbDnOffset : fh[1].adr);
1829 /* .. and our share of externals.
1830 XXX use the global list to speed up things here. how ? */
1831 top_stack->blocktype = stFile;
1832 top_stack->maxsyms = cur_hdr->isymMax + cur_hdr->ipdMax + cur_hdr->iextMax;
1833 for (i = 0; i < cur_hdr->iextMax; i++) {
1834 register EXTR *esh = (EXTR *) (cur_hdr->cbExtOffset) + i;
1835 if (esh->ifd == cur_fd)
1836 parse_external(esh, 1);
1839 /* If there are undefined, tell the user */
1840 if (n_undef_symbols) {
1841 printf_filtered("File %s contains %d unresolved references:",
1842 st->filename, n_undef_symbols);
1843 printf_filtered("\n\t%4d variables\n\t%4d procedures\n\t%4d labels\n",
1844 n_undef_vars, n_undef_procs, n_undef_labels);
1845 n_undef_symbols = n_undef_labels = n_undef_vars = n_undef_procs = 0;
1851 * Sort the symbol table now, we are done adding symbols to it.
1853 sort_symtab_syms(st);
1859 /* Ancillary parsing procedures. */
1861 /* Lookup the type at relative index RN. Return it in TPP
1862 if found and in any event come up with its name PNAME.
1863 Return value says how many aux symbols we ate */
1866 cross_ref(rn, tpp, pname)
1873 /* Escape index means 'the next one' */
1874 if (rn->rfd == 0xfff)
1875 rf = *(unsigned *) (rn + 1);
1881 *pname = "<undefined>";
1884 * Find the relative file descriptor and the symbol in it
1886 FDR *fh = get_rfd(cur_fd, rf);
1891 * If we have processed this symbol then we left a forwarding
1892 * pointer to the corresponding GDB symbol. If not, we`ll put
1893 * it in a list of pending symbols, to be processed later when
1894 * the file f will be. In any event, we collect the name for
1895 * the type here. Which is why we made a first pass at
1898 sh = (SYMR *) (fh->isymBase) + rn->index;
1900 /* Careful, we might be looking at .o files */
1901 *pname = (UNSAFE_DATA_ADDR(sh->iss)) ? "<undefined>" :
1904 /* Have we parsed it ? */
1905 if ((!UNSAFE_DATA_ADDR(sh->value)) && (sh->st == stParsed)) {
1906 t = (struct type *) sh->value;
1911 /* Avoid duplicates */
1912 p = is_pending_symbol(fh, sh);
1917 add_pending(fh, sh, *tpp);
1920 return (rn->rfd == 0xfff);
1924 /* Quick&dirty lookup procedure, to avoid the MI ones that require
1925 keeping the symtab sorted */
1927 static struct symbol *
1928 mylookup_symbol (name, block, namespace, class)
1930 register struct block *block;
1931 enum namespace namespace;
1932 enum address_class class;
1934 register int bot, top, inc;
1935 register struct symbol *sym;
1938 top = BLOCK_NSYMS(block);
1941 sym = BLOCK_SYM(block, bot);
1942 if (SYMBOL_NAME(sym)[0] == inc
1943 && SYMBOL_NAMESPACE(sym) == namespace
1944 && SYMBOL_CLASS(sym) == class
1945 && !strcmp(SYMBOL_NAME(sym), name))
1949 if (block = BLOCK_SUPERBLOCK (block))
1950 return mylookup_symbol (name, block, namespace, class);
1955 /* Add a new symbol S to a block B */
1962 BLOCK_SYM(b,BLOCK_NSYMS(b)++) = s;
1963 if (b == top_stack->cur_block &&
1964 BLOCK_NSYMS(b) > top_stack->maxsyms)
1965 printf_filtered("Internal: block at @%x overfilled (by %d)\n",
1966 b, BLOCK_NSYMS(b) - top_stack->maxsyms);
1969 /* Add a new block B to a symtab S */
1976 struct blockvector *bv = BLOCKVECTOR(s);
1978 bv = (struct blockvector *)xrealloc(bv, sizeof(struct blockvector) +
1979 BLOCKVECTOR_NBLOCKS(bv) * sizeof(bv->block));
1980 if (bv != BLOCKVECTOR(s))
1981 BLOCKVECTOR(s) = bv;
1983 BLOCKVECTOR_BLOCK(bv, BLOCKVECTOR_NBLOCKS(bv)++) = b;
1986 /* Add a new linenumber entry (LINENO,ADR) to a linevector LT.
1987 MIPS' linenumber encoding might need more than one byte
1988 to describe it, LAST is used to detect these continuation lines */
1991 add_line(lt, lineno, adr, last)
1992 struct linetable *lt;
1996 last = -2; /* make sure we record first line */
1998 if (last == lineno) /* skip continuation lines */
2001 lt->item[lt->nitems].line = lineno;
2002 lt->item[lt->nitems++].pc = adr << 2;
2008 /* Comparison functions, used when sorting things */
2010 /* Symtabs must be ordered viz the code segments they cover */
2013 compare_symtabs( s1, s2)
2014 struct symtab **s1, **s2;
2016 /* "most specific" first */
2018 register struct block *b1, *b2;
2019 b1 = BLOCKVECTOR_BLOCK(BLOCKVECTOR(*s1),GLOBAL_BLOCK);
2020 b2 = BLOCKVECTOR_BLOCK(BLOCKVECTOR(*s2),GLOBAL_BLOCK);
2021 if (BLOCK_END(b1) == BLOCK_END(b2))
2022 return BLOCK_START(b1) - BLOCK_START(b2);
2023 return BLOCK_END(b1) - BLOCK_END(b2);
2027 /* Partial Symtabs, same */
2030 compare_psymtabs( s1, s2)
2031 struct partial_symtab **s1, **s2;
2033 /* Perf twist: put the ones with no code at the end */
2035 register int a = (*s1)->textlow;
2036 register int b = (*s2)->textlow;
2045 /* Partial symbols are compared lexicog by their print names */
2048 compare_psymbols (s1, s2)
2049 register struct partial_symbol *s1, *s2;
2052 *st1 = SYMBOL_NAME(s1),
2053 *st2 = SYMBOL_NAME(s2);
2055 return (st1[0] - st2[0] ? st1[0] - st2[0] :
2056 strcmp(st1 + 1, st2 + 1));
2059 /* Blocks with a smaller low bound should come first */
2061 static int compare_blocks(b1,b2)
2062 struct block **b1, **b2;
2064 register int addr_diff;
2066 addr_diff = (BLOCK_START((*b1))) - (BLOCK_START((*b2)));
2068 return (BLOCK_END((*b1))) - (BLOCK_END((*b2)));
2073 /* Sorting and reordering procedures */
2075 /* Sort the blocks of a symtab S.
2076 Reorder the blocks in the blockvector by code-address,
2077 as required by some MI search routines */
2083 struct blockvector *bv = BLOCKVECTOR(s);
2085 if (BLOCKVECTOR_NBLOCKS(bv) <= 2) {
2087 if (BLOCK_END(BLOCKVECTOR_BLOCK(bv,GLOBAL_BLOCK)) == 0)
2088 BLOCK_START(BLOCKVECTOR_BLOCK(bv,GLOBAL_BLOCK)) = 0;
2092 * This is very unfortunate: normally all functions are compiled in
2093 * the order they are found, but if the file is compiled -O3 things
2094 * are very different. It would be nice to find a reliable test
2095 * to detect -O3 images in advance.
2097 if (BLOCKVECTOR_NBLOCKS(bv) > 3)
2098 qsort(&BLOCKVECTOR_BLOCK(bv,FIRST_LOCAL_BLOCK),
2099 BLOCKVECTOR_NBLOCKS(bv) - FIRST_LOCAL_BLOCK,
2100 sizeof(struct block *),
2104 register CORE_ADDR high = 0;
2105 register int i, j = BLOCKVECTOR_NBLOCKS(bv);
2107 for (i = FIRST_LOCAL_BLOCK; i < j; i++)
2108 if (high < BLOCK_END(BLOCKVECTOR_BLOCK(bv,i)))
2109 high = BLOCK_END(BLOCKVECTOR_BLOCK(bv,i));
2110 BLOCK_END(BLOCKVECTOR_BLOCK(bv,GLOBAL_BLOCK)) = high;
2113 BLOCK_START(BLOCKVECTOR_BLOCK(bv,GLOBAL_BLOCK)) =
2114 BLOCK_START(BLOCKVECTOR_BLOCK(bv,FIRST_LOCAL_BLOCK));
2116 BLOCK_START(BLOCKVECTOR_BLOCK(bv,STATIC_BLOCK)) =
2117 BLOCK_START(BLOCKVECTOR_BLOCK(bv,GLOBAL_BLOCK));
2118 BLOCK_END (BLOCKVECTOR_BLOCK(bv,STATIC_BLOCK)) =
2119 BLOCK_END (BLOCKVECTOR_BLOCK(bv,GLOBAL_BLOCK));
2122 /* Sort the symtab list, as required by some search procedures.
2123 We want files ordered to make them look right to users, and for
2124 searching (see block_for_pc). */
2130 struct symtab *stab;
2131 register struct symtab **all_symtabs;
2132 register int symtab_count;
2137 /* Create an array of pointers to all the symtabs. */
2138 for (symtab_count = 0, stab = symtab_list;
2140 symtab_count++, stab = stab->next) {
2141 obstack_grow (psymbol_obstack, &stab, sizeof (stab));
2142 /* FIXME: Only sort blocks for new symtabs ??? */
2146 all_symtabs = (struct symtab **)
2147 obstack_base (psymbol_obstack);
2148 qsort((char *)all_symtabs, symtab_count,
2149 sizeof(struct symtab *), compare_symtabs);
2151 /* Re-construct the symtab list, but now it is sorted. */
2152 for (i = 0; i < symtab_count-1; i++)
2153 all_symtabs[i]->next = all_symtabs[i+1];
2154 all_symtabs[i]->next = 0;
2155 symtab_list = all_symtabs[0];
2157 obstack_free (psymbol_obstack, all_symtabs);
2160 /* Sort the partial symtab list, as required by some search procedures.
2161 PC lookups stop at the first psymtab such that textlow <= PC < texthigh */
2167 register int all_psymtabs_count;
2168 struct partial_symtab *pstab;
2169 struct partial_symtab **all_psymtabs;
2171 if (!partial_symtab_list)
2174 /* Create an array of pointers to all the partial_symtabs. */
2176 for (all_psymtabs_count = 0, pstab = partial_symtab_list;
2178 all_psymtabs_count++, pstab = pstab->next)
2179 obstack_grow (psymbol_obstack, &pstab, sizeof (pstab));
2181 all_psymtabs = (struct partial_symtab **)
2182 obstack_base (psymbol_obstack);
2184 qsort((char *)all_psymtabs, all_psymtabs_count,
2185 sizeof(struct partial_symtab *), compare_psymtabs);
2187 /* Re-construct the partial_symtab_list, but now it is sorted. */
2189 for (i = 0; i < all_psymtabs_count-1; i++)
2190 all_psymtabs[i]->next = all_psymtabs[i+1];
2191 all_psymtabs[i]->next = 0;
2192 partial_symtab_list = all_psymtabs[0];
2194 obstack_free (psymbol_obstack, all_psymtabs);
2197 /* Constructor/restructor/destructor procedures */
2199 /* Allocate a new symtab for NAME. Needs an estimate of how many symbols
2200 MAXSYMS and linenumbers MAXLINES we'll put in it */
2204 new_symtab(name, maxsyms, maxlines)
2207 struct symtab *s = (struct symtab *) xzalloc(sizeof(struct symtab));
2210 LINETABLE(s) = new_linetable(maxlines);
2214 /* All symtabs must have at least two blocks */
2215 BLOCKVECTOR(s) = new_bvect(2);
2216 BLOCKVECTOR_BLOCK(BLOCKVECTOR(s), GLOBAL_BLOCK) = new_block(maxsyms);
2217 BLOCKVECTOR_BLOCK(BLOCKVECTOR(s), STATIC_BLOCK) = new_block(maxsyms);
2218 BLOCK_SUPERBLOCK( BLOCKVECTOR_BLOCK(BLOCKVECTOR(s),STATIC_BLOCK)) =
2219 BLOCKVECTOR_BLOCK(BLOCKVECTOR(s), GLOBAL_BLOCK);
2221 s->free_code = free_linetable;
2223 /* Link the new symtab into the list of such. */
2224 s->next = symtab_list;
2230 /* Cleanup before loading a fresh image */
2232 static destroy_all_symtabs()
2239 current_source_symtab = 0;
2243 /* Allocate a new partial_symtab NAME */
2245 static struct partial_symtab *
2249 struct partial_symtab *pst;
2251 pst = (struct partial_symtab *)
2252 obstack_alloc (psymbol_obstack, sizeof (*pst));
2253 bzero (pst, sizeof (*pst));
2255 if (name == (char*)-1) /* FIXME -- why not null here? */
2256 pst->filename = "<no name>";
2258 pst->filename = name;
2260 pst->next = partial_symtab_list;
2261 partial_symtab_list = pst;
2263 /* Keep a backpointer to the file`s symbols */
2264 pst->ldsymlen = (int)cur_hdr;
2266 /* The way to turn this into a symtab is to call... */
2267 pst->read_symtab = mipscoff_psymtab_to_symtab;
2273 /* Allocate a new NAME psymbol from LIST, extending it if necessary.
2274 The psymbol belongs to the psymtab at index PST_IDX */
2276 static struct partial_symbol *
2277 new_psymbol(list, name, pst_idx)
2278 struct psymbol_allocation_list *list;
2281 struct partial_symbol *p;
2282 struct partial_symtab *pst = fdr_to_pst[pst_idx].pst;
2284 /* Lists are pre-sized, we won`t overflow */
2286 p = list->list + pst->globals_offset + pst->n_global_syms++;
2287 SYMBOL_NAME(p) = name;
2292 /* Allocate a linetable array of the given SIZE */
2295 struct linetable *new_linetable(size)
2297 struct linetable *l;
2299 size = size * sizeof(l->item) + sizeof(struct linetable);
2300 l = (struct linetable *)xmalloc(size);
2305 /* Oops, too big. Shrink it. This was important with the 2.4 linetables,
2306 I am not so sure about the 3.4 ones */
2308 static shrink_linetable(s)
2311 struct linetable *l = new_linetable(LINETABLE(s)->nitems);
2313 bcopy(LINETABLE(s), l,
2314 LINETABLE(s)->nitems * sizeof(l->item) + sizeof(struct linetable));
2315 free (LINETABLE(s));
2319 /* Allocate and zero a new blockvector of NBLOCKS blocks. */
2322 struct blockvector *new_bvect(nblocks)
2324 struct blockvector *bv;
2327 size = sizeof(struct blockvector) + nblocks * sizeof(struct block*);
2328 bv = (struct blockvector *) xzalloc(size);
2330 BLOCKVECTOR_NBLOCKS(bv) = nblocks;
2335 /* Allocate and zero a new block of MAXSYMS symbols */
2338 struct block *new_block(maxsyms)
2340 int size = sizeof(struct block) + (maxsyms-1) * sizeof(struct symbol *);
2341 struct block *b = (struct block *)xzalloc(size);
2346 /* Ooops, too big. Shrink block B in symtab S to its minimal size */
2348 static struct block *
2354 struct blockvector *bv = BLOCKVECTOR(s);
2357 /* Just get a new one, copy, and fix references to the old one */
2359 new = (struct block *)xmalloc(sizeof(struct block) +
2360 (BLOCK_NSYMS(b)-1) * sizeof(struct symbol *));
2362 bcopy(b, new, sizeof(*new) + (BLOCK_NSYMS(b) - 1) * sizeof(struct symbol*));
2364 /* Should chase pointers to old one. Fortunately, that`s just
2365 the block`s function and inferior blocks */
2366 if (BLOCK_FUNCTION(b) && SYMBOL_BLOCK_VALUE(BLOCK_FUNCTION(b)) == b)
2367 SYMBOL_BLOCK_VALUE(BLOCK_FUNCTION(b)) = new;
2368 for (i = 0; i < BLOCKVECTOR_NBLOCKS(bv); i++)
2369 if (BLOCKVECTOR_BLOCK(bv,i) == b)
2370 BLOCKVECTOR_BLOCK(bv,i) = new;
2371 else if (BLOCK_SUPERBLOCK(BLOCKVECTOR_BLOCK(bv,i)) == b)
2372 BLOCK_SUPERBLOCK(BLOCKVECTOR_BLOCK(bv,i)) = new;
2377 /* Create a new symbol with printname NAME */
2384 struct symbol *s = (struct symbol *)
2385 obstack_alloc (symbol_obstack, sizeof (struct symbol));
2387 bzero (s, sizeof (*s));
2388 SYMBOL_NAME(s) = name;
2392 /* Create a new type with printname NAME */
2399 struct type *t = (struct type *)
2400 obstack_alloc (symbol_obstack, sizeof (struct type));
2402 bzero (t, sizeof (*t));
2403 TYPE_NAME(t) = name;
2407 /* Create and initialize a new type with printname NAME.
2408 CODE and LENGTH are the initial info we put in,
2409 UNS says whether the type is unsigned or not. */
2413 make_type(code, length, uns, name)
2414 enum type_code code;
2418 register struct type *type;
2420 type = (struct type *) xzalloc(sizeof(struct type));
2421 TYPE_CODE(type) = code;
2422 TYPE_LENGTH(type) = length;
2423 TYPE_FLAGS(type) = uns ? TYPE_FLAG_UNSIGNED : 0;
2424 TYPE_NAME(type) = name;
2429 /* Allocate a new field named NAME to the type TYPE */
2432 struct field *new_field(type,name)
2438 /* Fields are kept in an array */
2439 if (TYPE_NFIELDS(type))
2440 TYPE_FIELDS(type) = (struct field*)xrealloc(TYPE_FIELDS(type),
2441 (TYPE_NFIELDS(type)+1) * sizeof(struct field));
2443 TYPE_FIELDS(type) = (struct field*)xzalloc(2*sizeof(struct field));
2444 f = &(TYPE_FIELD(type,TYPE_NFIELDS(type)++));
2445 bzero(f, sizeof(struct field));
2451 /* Make an enum constant for a member F of an enumerated type T */
2454 make_enum_constant(f,t)
2460 * This is awful, but that`s the way it is supposed to be
2461 * (BTW, no need to free the real 'type', it's a builtin)
2463 f->type = (struct type *) f->bitpos;
2465 s = new_symbol(f->name);
2466 SYMBOL_NAMESPACE(s) = VAR_NAMESPACE;
2467 SYMBOL_CLASS(s) = LOC_CONST;
2469 SYMBOL_VALUE(s) = f->bitpos;
2470 add_symbol(s, top_stack->cur_block);
2475 /* Things used for calling functions in the inferior.
2476 These functions are exported to our companion
2477 mips-dep.c file and are here because they play
2478 with the symbol-table explicitly. */
2481 /* Need to make a new symbol on the fly for the dummy
2482 frame we put on the stack. Which goes in the.. */
2484 static struct symtab *dummy_symtab;
2486 /* Make up a dummy symbol for the code we put at END_PC,
2487 of size SIZE, invoking a function with NARGS arguments
2488 and using a frame of FRAMESIZE bytes */
2490 mips_create_dummy_symbol(end_pc, size, nargs, framesize)
2494 struct mips_extra_func_info *gdbinfo;
2496 /* Allocate symtab if not done already */
2497 if (dummy_symtab == 0)
2498 dummy_symtab = new_symtab(".dummy_symtab.", 100, 0);
2500 /* Make a new block. Only needs one symbol */
2502 BLOCK_START(bl) = end_pc - size;
2503 BLOCK_END(bl) = end_pc;
2505 BLOCK_SUPERBLOCK(bl) =
2506 BLOCKVECTOR_BLOCK(BLOCKVECTOR(dummy_symtab),GLOBAL_BLOCK);
2507 add_block(bl, dummy_symtab);
2508 sort_blocks(dummy_symtab);
2510 BLOCK_FUNCTION(bl) = new_symbol("??");
2511 SYMBOL_BLOCK_VALUE(BLOCK_FUNCTION(bl)) = bl;
2512 g = new_symbol(".gdbinfo.");
2513 BLOCK_SYM(bl,BLOCK_NSYMS(bl)++) = g;
2515 SYMBOL_NAMESPACE(g) = LABEL_NAMESPACE;
2516 SYMBOL_CLASS(g) = LOC_CONST;
2517 SYMBOL_TYPE(g) = builtin_type_void;
2518 gdbinfo = (struct mips_extra_func_info *)
2519 xzalloc(sizeof(struct mips_extra_func_info));
2521 SYMBOL_VALUE(g) = (long) gdbinfo;
2523 gdbinfo->numargs = nargs;
2524 gdbinfo->framesize = framesize;
2525 gdbinfo->framereg = 29;
2526 gdbinfo->pcreg = 31;
2527 gdbinfo->regmask = -2;
2528 gdbinfo->regoffset = -4;
2529 gdbinfo->fregmask = 0; /* XXX */
2530 gdbinfo->fregoffset = 0; /* XXX */
2533 /* We just returned from the dummy code at END_PC, drop its symbol */
2535 mips_destroy_dummy_symbol(end_pc)
2538 struct blockvector *bv = BLOCKVECTOR(dummy_symtab);
2541 bl = block_for_pc(end_pc);
2542 free(BLOCK_FUNCTION(bl));
2543 free(SYMBOL_VALUE(BLOCK_SYM(bl,0)));
2544 free(BLOCK_SYM(bl,0));
2546 for (i = FIRST_LOCAL_BLOCK; i < BLOCKVECTOR_NBLOCKS(bv); i++)
2547 if (BLOCKVECTOR_BLOCK(bv,i) == bl)
2549 for (; i < BLOCKVECTOR_NBLOCKS(bv) - 1; i++)
2550 BLOCKVECTOR_BLOCK(bv,i) = BLOCKVECTOR_BLOCK(bv,i+1);
2551 BLOCKVECTOR_NBLOCKS(bv)--;
2552 sort_blocks(dummy_symtab);
2557 /* Sigtramp: make sure we have all the necessary information
2558 about the signal trampoline code. Since the official code
2559 from MIPS does not do so, we make up that information ourselves.
2560 If they fix the library (unlikely) this code will neutralize itself. */
2567 struct block *b, *b0;
2569 sigtramp_address = -1;
2571 /* We know it is sold as sigvec */
2572 s = lookup_symbol("sigvec", 0, VAR_NAMESPACE, 0, NULL);
2574 /* Most programs do not play with signals */
2578 b0 = SYMBOL_BLOCK_VALUE(s);
2580 /* A label of sigvec, to be more precise */
2581 s = lookup_symbol("sigtramp", b0, VAR_NAMESPACE, 0, NULL);
2583 /* But maybe this program uses its own version of sigvec */
2587 sigtramp_address = SYMBOL_VALUE(s);
2588 sigtramp_end = sigtramp_address + 0x88; /* black magic */
2590 /* Did we or MIPSco fix the library ? */
2591 if (SYMBOL_CLASS(s) == LOC_BLOCK)
2594 /* But what symtab does it live in ? */
2595 st = find_pc_symtab(SYMBOL_VALUE(s));
2598 * Ok, there goes the fix: turn it into a procedure, with all the
2599 * needed info. Note we make it a nested procedure of sigvec,
2600 * which is the way the (assembly) code is actually written.
2602 SYMBOL_NAMESPACE(s) = VAR_NAMESPACE;
2603 SYMBOL_CLASS(s) = LOC_BLOCK;
2604 SYMBOL_TYPE(s) = make_type(TYPE_CODE_FUNC, 4, 0, 0);
2605 TYPE_TARGET_TYPE(SYMBOL_TYPE(s)) = builtin_type_void;
2607 /* Need a block to allocate .gdbinfo. in */
2609 SYMBOL_BLOCK_VALUE(s) = b;
2610 BLOCK_START(b) = sigtramp_address;
2611 BLOCK_END(b) = sigtramp_end;
2612 BLOCK_FUNCTION(b) = s;
2613 BLOCK_SUPERBLOCK(b) = BLOCK_SUPERBLOCK(b0);
2617 /* Make a .gdbinfo. for it */
2619 struct mips_extra_func_info *e =
2620 (struct mips_extra_func_info *)
2621 xzalloc(sizeof(struct mips_extra_func_info));
2623 e->numargs = 0; /* the kernel thinks otherwise */
2624 /* align_longword(sigcontext + SIGFRAME) */
2625 e->framesize = 0x150;
2626 e->framereg = SP_REGNUM;
2629 e->regoffset = -(41 * sizeof(int));
2631 e->fregoffset = -(37 * sizeof(int));
2634 s = new_symbol(".gdbinfo.");
2635 SYMBOL_VALUE(s) = (int) e;
2636 SYMBOL_NAMESPACE(s) = LABEL_NAMESPACE;
2637 SYMBOL_CLASS(s) = LOC_CONST;
2638 SYMBOL_TYPE(s) = builtin_type_void;
2641 BLOCK_SYM(b,BLOCK_NSYMS(b)++) = s;
2645 /* Initialization */
2647 static struct sym_fns ecoff_sym_fns = {"ecoff", 5,
2648 mipscoff_new_init, mipscoff_symfile_init,
2649 mipscoff_symfile_read, mipscoff_symfile_discard};
2651 _initialize_mipsread ()
2653 add_symtab_fns (&ecoff_sym_fns);
2655 bzero (&global_psymbols, sizeof (global_psymbols));
2656 bzero (&static_psymbols, sizeof (static_psymbols));
2658 /* Missing basic types */
2659 builtin_type_string = make_type(TYPE_CODE_PASCAL_ARRAY,
2661 builtin_type_complex = make_type(TYPE_CODE_FLT,
2662 2 * sizeof(float), 0, "complex");
2663 builtin_type_double_complex = make_type(TYPE_CODE_FLT,
2664 2 * sizeof(double), 0, "double_complex");
2665 builtin_type_fixed_dec = make_type(TYPE_CODE_INT, sizeof(int),
2666 0, "fixed_decimal");
2667 builtin_type_float_dec = make_type(TYPE_CODE_FLT, sizeof(double),
2668 0, "floating_decimal");
2670 /* Templates types */
2671 builtin_type_ptr = lookup_pointer_type (builtin_type_void);
2672 builtin_type_struct = make_type(TYPE_CODE_STRUCT, 0, 0, 0);
2673 builtin_type_union = make_type(TYPE_CODE_UNION, 0, 0, 0);
2674 builtin_type_enum = make_type(TYPE_CODE_ENUM, 0, 0, 0);
2675 builtin_type_range = make_type(TYPE_CODE_RANGE, 0, 0, 0);
2676 builtin_type_set = make_type(TYPE_CODE_SET, 0, 0, 0);