1 /* Read a symbol table in MIPS' format (Third-Eye).
2 Copyright 1986, 1987, 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
3 Contributed by Alessandro Forin (af@cs.cmu.edu) at CMU. Major
4 work by Per Bothner and John Gilmore at Cygnus Support.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
22 /* This module provides three functions: mipscoff_symfile_init,
23 which initializes to read a symbol file; mipscoff_new_init, which
24 discards existing cached information when all symbols are being
25 discarded; and mipscoff_symfile_read, which reads a symbol table
28 mipscoff_symfile_read only does the minimum work necessary for letting the
29 user "name" things symbolically; it does not read the entire symtab.
30 Instead, it reads the external and static symbols and puts them in partial
31 symbol tables. When more extensive information is requested of a
32 file, the corresponding partial symbol table is mutated into a full
33 fledged symbol table by going back and reading the symbols
34 for real. mipscoff_psymtab_to_symtab() is called indirectly through
35 a pointer in the psymtab to do this.
37 ECOFF symbol tables are mostly written in the byte order of the
38 target machine. However, one section of the table (the auxiliary
39 symbol information) is written in the host byte order. There is a
40 bit in the other symbol info which describes which host byte order
41 was used. ECOFF thereby takes the trophy from Intel `b.out' for
42 the most brain-dead adaptation of a file format to byte order.
44 This module can read all four of the known byte-order combinations,
45 on any type of host. However, it does make (and check) the assumption
46 that the external form of a symbol table structure (on disk)
47 occupies the same number of bytes as the internal form (in a struct).
48 Fixing this is possible but requires larger structural changes. */
50 #define TM_FILE_OVERRIDE
62 #include <sys/types.h>
67 #include <sys/param.h>
72 /* Undo brain-damage in some <strings.h> that '#define index strchr'.
73 Note that tm-mips.h includes coff/sym.h, which has a structure with a
74 member named 'index'. */
77 #include "coff/mips.h" /* COFF-like aspects of ecoff files */
78 #include "coff/ecoff-ext.h" /* External forms of ecoff sym structures */
80 #include "libaout.h" /* FIXME Secret internal BFD stuff for a.out */
81 #include "aout/aout64.h"
82 #include "aout/stab_gnu.h" /* STABS information */
85 struct external_filehdr f
;
86 struct external_aouthdr a
;
89 /* These must match the corresponding definition in gcc/config/xm-mips.h.
90 At some point, these should probably go into a shared include file,
91 but currently gcc and gdb do not share any directories. */
93 #define CODE_MASK 0x8F300
94 #define MIPS_IS_STAB(sym) (((sym)->index & 0xFFF00) == CODE_MASK)
95 #define MIPS_MARK_STAB(code) ((code)+CODE_MASK)
96 #define MIPS_UNMARK_STAB(code) ((code)-CODE_MASK)
97 #define STABS_SYMBOL "@stabs"
99 /* Each partial symbol table entry contains a pointer to private data for the
100 read_symtab() function to use when expanding a partial symbol table entry
101 to a full symbol table entry.
103 For mipsread this structure contains the index of the FDR that this psymtab
104 represents and a pointer to the symbol table header HDRR from the symbol
105 file that the psymtab was created from. */
107 #define PST_PRIVATE(p) ((struct symloc *)(p)->read_symtab_private)
108 #define FDR_IDX(p) (PST_PRIVATE(p)->fdr_idx)
109 #define CUR_HDR(p) (PST_PRIVATE(p)->cur_hdr)
114 EXTR
**extern_tab
; /* Pointer to external symbols for this file. */
115 int extern_count
; /* Size of extern_tab. */
118 /* Things we import explicitly from other modules */
120 extern int info_verbose
;
122 /* Various complaints about symbol reading that don't abort the process */
124 struct complaint bad_file_number_complaint
=
125 {"bad file number %d", 0, 0};
127 struct complaint index_complaint
=
128 {"bad aux index at symbol %s", 0, 0};
130 struct complaint aux_index_complaint
=
131 {"bad proc end in aux found from symbol %s", 0, 0};
133 struct complaint unknown_ext_complaint
=
134 {"unknown external symbol %s", 0, 0};
136 struct complaint unknown_sym_complaint
=
137 {"unknown local symbol %s", 0, 0};
139 struct complaint unknown_st_complaint
=
140 {"with type %d", 0, 0};
142 struct complaint block_overflow_complaint
=
143 {"block containing %s overfilled", 0, 0};
145 struct complaint basic_type_complaint
=
146 {"cannot map MIPS basic type 0x%x", 0, 0};
148 struct complaint unknown_type_qual_complaint
=
149 {"unknown type qualifier 0x%x", 0, 0};
151 struct complaint array_bitsize_complaint
=
152 {"size of array target type not known, assuming %d bits", 0, 0};
154 struct complaint bad_tag_guess_complaint
=
155 {"guessed tag type of %s incorrectly", 0, 0};
157 struct complaint block_member_complaint
=
158 {"declaration block contains unhandled symbol type %d", 0, 0};
160 struct complaint stEnd_complaint
=
161 {"stEnd with storage class %d not handled", 0, 0};
163 struct complaint unknown_mips_symtype_complaint
=
164 {"unknown symbol type 0x%x", 0, 0};
166 struct complaint stab_unknown_complaint
=
167 {"unknown stabs symbol %s", 0, 0};
169 struct complaint pdr_for_nonsymbol_complaint
=
170 {"PDR for %s, but no symbol", 0, 0};
172 struct complaint pdr_static_symbol_complaint
=
173 {"can't handle PDR for static proc at 0x%x", 0, 0};
175 /* Macros and extra defs */
177 /* Already-parsed symbols are marked specially */
179 #define stParsed stType
181 /* Puns: hard to find whether -g was used and how */
183 #define MIN_GLEVEL GLEVEL_0
184 #define compare_glevel(a,b) \
185 (((a) == GLEVEL_3) ? ((b) < GLEVEL_3) : \
186 ((b) == GLEVEL_3) ? -1 : (int)((b) - (a)))
188 /* When looking at .o files, avoid tripping over bad addresses */
190 #define SAFE_TEXT_ADDR 0x400000
191 #define SAFE_DATA_ADDR 0x10000000
193 #define UNSAFE_DATA_ADDR(p) ((unsigned)p < SAFE_DATA_ADDR || (unsigned)p > 2*SAFE_DATA_ADDR)
195 /* Things that really are local to this module */
197 /* MIPS symtab header for the current file */
199 static HDRR
*cur_hdr
;
201 /* Pointer to current file decriptor record, and its index */
206 /* Index of current symbol */
210 /* Note how much "debuggable" this image is. We would like
211 to see at least one FDR with full symbols */
216 /* When examining .o files, report on undefined symbols */
218 static int n_undef_symbols
, n_undef_labels
, n_undef_vars
, n_undef_procs
;
220 /* Pseudo symbol to use when putting stabs into the symbol table. */
222 static char stabs_symbol
[] = STABS_SYMBOL
;
224 /* Extra builtin types */
226 struct type
*builtin_type_complex
;
227 struct type
*builtin_type_double_complex
;
228 struct type
*builtin_type_fixed_dec
;
229 struct type
*builtin_type_float_dec
;
230 struct type
*builtin_type_string
;
232 /* Forward declarations */
235 fixup_symtab
PARAMS ((HDRR
*, char *, int, bfd
*));
238 read_mips_symtab
PARAMS ((struct objfile
*));
241 read_the_mips_symtab
PARAMS ((bfd
*, CORE_ADDR
*));
244 upgrade_type
PARAMS ((struct type
**, int, union aux_ext
*, int));
247 parse_partial_symbols
PARAMS ((int, struct objfile
*));
250 cross_ref
PARAMS ((union aux_ext
*, struct type
**, enum type_code
, char **,
254 fixup_sigtramp
PARAMS ((void));
256 static struct symbol
*
257 new_symbol
PARAMS ((char *));
260 new_type
PARAMS ((char *));
262 static struct block
*
263 new_block
PARAMS ((int));
265 static struct symtab
*
266 new_symtab
PARAMS ((char *, int, int, struct objfile
*));
268 static struct linetable
*
269 new_linetable
PARAMS ((int));
271 static struct blockvector
*
272 new_bvect
PARAMS ((int));
275 parse_type
PARAMS ((union aux_ext
*, int *, int));
277 static struct symbol
*
278 mylookup_symbol
PARAMS ((char *, struct block
*, enum namespace,
279 enum address_class
));
281 static struct block
*
282 shrink_block
PARAMS ((struct block
*, struct symtab
*));
285 xzalloc
PARAMS ((unsigned int));
288 sort_blocks
PARAMS ((struct symtab
*));
291 compare_blocks
PARAMS ((const void *, const void *));
293 static struct partial_symtab
*
294 new_psymtab
PARAMS ((char *, struct objfile
*));
297 static struct partial_symtab
*
298 parse_fdr
PARAMS ((int, int, struct objfile
*));
302 psymtab_to_symtab_1
PARAMS ((struct partial_symtab
*, char *));
305 add_block
PARAMS ((struct block
*, struct symtab
*));
308 add_symbol
PARAMS ((struct symbol
*, struct block
*));
311 add_line
PARAMS ((struct linetable
*, int, CORE_ADDR
, int));
313 static struct linetable
*
314 shrink_linetable
PARAMS ((struct linetable
*));
317 mips_next_symbol_text
PARAMS ((void));
319 /* Things we export to other modules */
321 /* Address bounds for the signal trampoline in inferior, if any */
322 /* FIXME: Nothing really seems to use this. Why is it here? */
324 CORE_ADDR sigtramp_address
, sigtramp_end
;
327 mipscoff_new_init (ignore
)
328 struct objfile
*ignore
;
333 mipscoff_symfile_init (objfile
)
334 struct objfile
*objfile
;
336 if (objfile
-> sym_private
!= NULL
)
338 mfree (objfile
-> md
, objfile
-> sym_private
);
340 objfile
-> sym_private
= NULL
;
344 mipscoff_symfile_read (objfile
, addr
, mainline
)
345 struct objfile
*objfile
;
349 bfd
*abfd
= objfile
-> obfd
;
351 init_minimal_symbol_collection ();
352 make_cleanup (discard_minimal_symbols
, 0);
354 /* Now that the executable file is positioned at symbol table,
355 process it and define symbols accordingly. */
357 read_mips_symtab(objfile
);
359 /* Install any minimal symbols that have been collected as the current
360 minimal symbols for this objfile. */
362 install_minimal_symbols (objfile
);
365 /* Perform any local cleanups required when we are done with a particular
366 objfile. I.E, we are in the process of discarding all symbol information
367 for an objfile, freeing up all memory held for it, and unlinking the
368 objfile struct from the global list of known objfiles. */
371 mipscoff_symfile_finish (objfile
)
372 struct objfile
*objfile
;
374 if (objfile
-> sym_private
!= NULL
)
376 mfree (objfile
-> md
, objfile
-> sym_private
);
379 /* If we have a file symbol header lying around, blow it away. */
388 /* Allocate zeroed memory */
394 PTR p
= xmalloc(size
);
400 /* Exported procedure: Builds a symtab from the PST partial one.
401 Restores the environment in effect when PST was created, delegates
402 most of the work to an ancillary procedure, and sorts
403 and reorders the symtab list at the end */
406 mipscoff_psymtab_to_symtab(pst
)
407 struct partial_symtab
*pst
;
414 printf_filtered("Reading in symbols for %s...", pst
->filename
);
417 /* Restore the header and list of pending typedefs */
418 cur_hdr
= CUR_HDR(pst
);
420 next_symbol_text_func
= mips_next_symbol_text
;
422 psymtab_to_symtab_1(pst
, pst
->filename
);
424 /* Match with global symbols. This only needs to be done once,
425 after all of the symtabs and dependencies have been read in. */
426 scan_file_globals (pst
->objfile
);
429 printf_filtered("done.\n");
432 /* Exported procedure: Is PC in the signal trampoline code */
435 in_sigtramp(pc
, ignore
)
437 char *ignore
; /* function name */
439 if (sigtramp_address
== 0)
441 return (pc
>= sigtramp_address
&& pc
< sigtramp_end
);
444 /* File-level interface functions */
446 /* Read the symtab information from file ABFD into memory. Also,
447 return address just past end of our text segment in *END_OF_TEXT_SEGP. */
450 read_the_mips_symtab(abfd
, end_of_text_segp
)
452 CORE_ADDR
*end_of_text_segp
;
454 int stsize
, st_hdrsize
;
456 struct hdr_ext hdr_ext
;
458 /* Header for executable/object file we read symbols from */
459 struct coff_exec filhdr
;
462 /* We need some info from the initial headers */
463 val
= bfd_seek(abfd
, 0L, L_SET
);
464 val
= bfd_read((PTR
)&filhdr
, sizeof filhdr
, 1, abfd
);
466 if (end_of_text_segp
)
468 bfd_h_get_32 (abfd
, filhdr
.a
.text_start
) +
469 bfd_h_get_32 (abfd
, filhdr
.a
.tsize
);
471 /* Find and read the symbol table header */
472 st_hdrsize
= bfd_h_get_32 (abfd
, filhdr
.f
.f_nsyms
);
473 st_filptr
= bfd_h_get_32 (abfd
, filhdr
.f
.f_symptr
);
477 bfd_seek (abfd
, st_filptr
, L_SET
);
478 if (st_hdrsize
!= sizeof (hdr_ext
)) { /* Profanity check */
479 error ("Wrong header size: %d, not %d", st_hdrsize
,
482 if (bfd_read((PTR
)&hdr_ext
, st_hdrsize
, 1, abfd
) != st_hdrsize
)
484 ecoff_swap_hdr_in (abfd
, &hdr_ext
, &st_hdr
);
486 /* Find out how large the symbol table is */
487 stsize
= (st_hdr
.cbExtOffset
- (st_filptr
+ st_hdrsize
))
488 + st_hdr
.iextMax
* cbEXTR
;
490 /* Allocate space for the symbol table. Read it in. */
491 cur_hdr
= (HDRR
*) xmalloc(stsize
+ st_hdrsize
);
493 memcpy((PTR
)cur_hdr
, (PTR
)&hdr_ext
, st_hdrsize
);
494 if (bfd_read((char *)cur_hdr
+ st_hdrsize
, stsize
, 1, abfd
) != stsize
)
497 /* Fixup file_pointers in it */
498 fixup_symtab(cur_hdr
, (char *) cur_hdr
+ st_hdrsize
,
499 st_filptr
+ st_hdrsize
, abfd
);
503 error("Short read on %s", bfd_get_filename (abfd
));
507 /* Turn all file-relative pointers in the symtab described by HDR
508 into memory pointers, given that the symtab itself is located
509 at DATA in memory and F_PTR in the file.
511 Byte-swap all the data structures, in place, while we are at it --
512 except AUX entries, which we leave in their original byte order.
513 They will be swapped as they are used instead. (FIXME: we ought to
514 do all the data structures that way.) */
517 fixup_symtab (hdr
, data
, f_ptr
, abfd
)
528 struct rfd_ext
*rbase
;
530 /* This function depends on the external and internal forms
531 of the MIPS symbol table taking identical space. Check this
532 assumption at compile-time. */
533 static check_hdr1
[1 + sizeof (struct hdr_ext
) - sizeof (HDRR
)] = {0};
534 static check_hdr2
[1 + sizeof (HDRR
) - sizeof (struct hdr_ext
)] = {0};
535 static check_fdr1
[1 + sizeof (struct fdr_ext
) - sizeof (FDR
)] = {0};
536 static check_fdr2
[1 + sizeof (FDR
) - sizeof (struct fdr_ext
)] = {0};
537 static check_pdr1
[1 + sizeof (struct pdr_ext
) - sizeof (PDR
)] = {0};
538 static check_pdr2
[1 + sizeof (PDR
) - sizeof (struct pdr_ext
)] = {0};
539 static check_sym1
[1 + sizeof (struct sym_ext
) - sizeof (SYMR
)] = {0};
540 static check_sym2
[1 + sizeof (SYMR
) - sizeof (struct sym_ext
)] = {0};
541 static check_ext1
[1 + sizeof (struct ext_ext
) - sizeof (EXTR
)] = {0};
542 static check_ext2
[1 + sizeof (EXTR
) - sizeof (struct ext_ext
)] = {0};
543 static check_rfd1
[1 + sizeof (struct rfd_ext
) - sizeof (RFDT
)] = {0};
544 static check_rfd2
[1 + sizeof (RFDT
) - sizeof (struct rfd_ext
)] = {0};
546 /* Swap in the header record. */
547 ecoff_swap_hdr_in (abfd
, hdr
, hdr
);
550 * These fields are useless (and empty) by now:
551 * hdr->cbDnOffset, hdr->cbOptOffset
552 * We use them for other internal purposes.
555 hdr
->cbOptOffset
= 0;
558 if (hdr->off) hdr->off = (unsigned int)data + (hdr->off - f_ptr);
572 /* Fix all the RFD's. */
573 rbase
= (struct rfd_ext
*)(hdr
->cbRfdOffset
);
574 for (i
= 0; i
< hdr
->crfd
; i
++) {
575 ecoff_swap_rfd_in (abfd
, rbase
+i
, (pRFDT
) rbase
+i
);
578 /* Fix all string pointers inside the symtab, and
579 the FDR records. Also fix other miscellany. */
581 for (f_idx
= 0; f_idx
< hdr
->ifdMax
; f_idx
++) {
582 register unsigned code_offset
;
584 /* Header itself, and strings */
585 fh
= (FDR
*) (hdr
->cbFdOffset
) + f_idx
;
587 /* Swap in the FDR */
588 ecoff_swap_fdr_in (abfd
, fh
, fh
);
590 fh
->issBase
+= hdr
->cbSsOffset
;
592 fh
->rss
= (long)fh
->rss
+ fh
->issBase
;
595 fh
->isymBase
= (int)((SYMR
*)(hdr
->cbSymOffset
)+fh
->isymBase
);
597 /* FIXME! Probably don't want to do this here! */
598 for (s_idx
= 0; s_idx
< fh
->csym
; s_idx
++) {
599 sh
= (SYMR
*)fh
->isymBase
+ s_idx
;
600 ecoff_swap_sym_in (abfd
, sh
, sh
);
602 sh
->iss
= (long) sh
->iss
+ fh
->issBase
;
608 /* cannot fix fh->ipdFirst because it is a short */
609 #define IPDFIRST(h,fh) \
610 ((long)h->cbPdOffset + fh->ipdFirst * sizeof(PDR))
612 /* Optional symbols (actually used for partial_symtabs) */
618 fh
->iauxBase
= hdr
->cbAuxOffset
+ fh
->iauxBase
* sizeof(union aux_ext
);
619 /* Relative file descriptor table */
620 fh
->rfdBase
= hdr
->cbRfdOffset
+ fh
->rfdBase
* sizeof(RFDT
);
624 fh
->cbLineOffset
+= hdr
->cbLineOffset
;
626 /* Procedure symbols. (XXX This should be done later) */
627 code_offset
= fh
->adr
;
628 for (s_idx
= 0; s_idx
< fh
->cpd
; s_idx
++) {
629 unsigned name
, only_ext
;
631 pr
= (PDR
*)(IPDFIRST(hdr
,fh
)) + s_idx
;
632 ecoff_swap_pdr_in (abfd
, pr
, pr
);
634 /* Simple rule to find files linked "-x" */
635 only_ext
= fh
->rss
== -1;
637 if (pr
->isym
== -1) {
638 /* static function */
642 name
= hdr
->cbExtOffset
+ pr
->isym
* sizeof(EXTR
);
643 sh
= &((EXTR
*)name
)->asym
;
647 sh
= (SYMR
*)fh
->isymBase
+ pr
->isym
;
648 /* Included code ? */
649 if (s_idx
== 0 && pr
->adr
!= 0)
650 code_offset
-= pr
->adr
;
653 /* Turn index into a pointer */
656 /* Fix line numbers */
657 pr
->cbLineOffset
+= fh
->cbLineOffset
;
659 /* Relocate address */
661 pr
->adr
+= code_offset
;
665 /* External symbols: swap in, and fix string */
666 for (s_idx
= 0; s_idx
< hdr
->iextMax
; s_idx
++) {
667 esh
= (EXTR
*)(hdr
->cbExtOffset
) + s_idx
;
668 ecoff_swap_ext_in (abfd
, esh
, esh
);
669 esh
->asym
.iss
= esh
->asym
.iss
+ hdr
->cbSsExtOffset
;
674 /* Find a file descriptor given its index RF relative to a file CF */
682 f
= (FDR
*) (cur_hdr
->cbFdOffset
) + cf
;
683 /* Object files do not have the RFD table, all refs are absolute */
685 return (FDR
*) (cur_hdr
->cbFdOffset
) + rf
;
686 cf
= *((pRFDT
) f
->rfdBase
+ rf
);
687 return (FDR
*) (cur_hdr
->cbFdOffset
) + cf
;
690 /* Return a safer print NAME for a file descriptor */
696 if (name
== (char *) -1)
697 return "<stripped file>";
698 if (UNSAFE_DATA_ADDR(name
))
704 /* Read in and parse the symtab of the file DESC. INCREMENTAL says
705 whether we are adding to the general symtab or not.
706 FIXME: INCREMENTAL is currently always zero, though it should not be. */
709 read_mips_symtab (objfile
)
710 struct objfile
*objfile
;
712 CORE_ADDR end_of_text_seg
;
714 read_the_mips_symtab(objfile
->obfd
, &end_of_text_seg
);
716 parse_partial_symbols(end_of_text_seg
, objfile
);
720 * Check to make sure file was compiled with -g.
721 * If not, warn the user of this limitation.
723 if (compare_glevel(max_glevel
, GLEVEL_2
) < 0) {
724 if (max_gdbinfo
== 0)
726 "\n%s not compiled with -g, debugging support is limited.\n",
729 "You should compile with -g2 or -g3 for best debugging support.\n");
735 /* Local utilities */
737 /* Map of FDR indexes to partial symtabs */
740 struct partial_symtab
*pst
; /* the psymtab proper */
741 int n_globals
; /* exported globals (external symbols) */
742 int globals_offset
; /* cumulative */
746 /* Utility stack, used to nest procedures and blocks properly.
747 It is a doubly linked list, to avoid too many alloc/free.
748 Since we might need it quite a few times it is NOT deallocated
751 static struct parse_stack
{
752 struct parse_stack
*next
, *prev
;
753 struct symtab
*cur_st
; /* Current symtab. */
754 struct block
*cur_block
; /* Block in it. */
755 int blocktype
; /* What are we parsing. */
756 int maxsyms
; /* Max symbols in this block. */
757 struct type
*cur_type
; /* Type we parse fields for. */
758 int cur_field
; /* Field number in cur_type. */
759 int procadr
; /* Start addres of this procedure */
760 int numargs
; /* Its argument count */
761 } *top_stack
; /* Top stack ptr */
764 /* Enter a new lexical context */
769 struct parse_stack
*new;
771 /* Reuse frames if possible */
772 if (top_stack
&& top_stack
->prev
)
773 new = top_stack
->prev
;
775 new = (struct parse_stack
*) xzalloc(sizeof(struct parse_stack
));
776 /* Initialize new frame with previous content */
778 register struct parse_stack
*prev
= new->prev
;
781 top_stack
->prev
= new;
783 new->next
= top_stack
;
788 /* Exit a lexical context */
796 top_stack
= top_stack
->next
;
800 /* Cross-references might be to things we haven't looked at
801 yet, e.g. type references. To avoid too many type
802 duplications we keep a quick fixup table, an array
803 of lists of references indexed by file descriptor */
805 static struct mips_pending
{
806 struct mips_pending
*next
; /* link */
807 SYMR
*s
; /* the symbol */
808 struct type
*t
; /* its partial type descriptor */
812 /* Check whether we already saw symbol SH in file FH as undefined */
814 static struct mips_pending
*
815 is_pending_symbol(fh
, sh
)
819 int f_idx
= fh
- (FDR
*) cur_hdr
->cbFdOffset
;
820 register struct mips_pending
*p
;
822 /* Linear search is ok, list is typically no more than 10 deep */
823 for (p
= pending_list
[f_idx
]; p
; p
= p
->next
)
829 /* Add a new undef symbol SH of type T */
832 add_pending(fh
, sh
, t
)
837 int f_idx
= fh
- (FDR
*) cur_hdr
->cbFdOffset
;
838 struct mips_pending
*p
= is_pending_symbol(fh
, sh
);
840 /* Make sure we do not make duplicates */
842 p
= (struct mips_pending
*) xmalloc(sizeof(*p
));
845 p
->next
= pending_list
[f_idx
];
846 pending_list
[f_idx
] = p
;
848 sh
->reserved
= 1; /* for quick check */
851 /* Throw away undef entries when done with file index F_IDX */
852 /* FIXME -- storage leak. This is never called!!! --gnu */
858 register struct mips_pending
*p
, *q
;
860 for (p
= pending_list
[f_idx
]; p
; p
= q
) {
864 pending_list
[f_idx
] = 0;
868 prepend_tag_kind(tag_name
, type_code
)
870 enum type_code type_code
;
878 case TYPE_CODE_STRUCT
:
881 case TYPE_CODE_UNION
:
888 result
= (char*)obstack_alloc (¤t_objfile
->symbol_obstack
,
889 strlen(prefix
) + strlen(tag_name
) + 1);
890 sprintf(result
, "%s%s", prefix
, tag_name
);
895 /* Parsing Routines proper. */
897 /* Parse a single symbol. Mostly just make up a GDB symbol for it.
898 For blocks, procedures and types we open a new lexical context.
899 This is basically just a big switch on the symbol's type.
900 Argument AX is the base pointer of aux symbols for this file (fh->iauxBase).
901 BIGEND says whether aux symbols are big-endian or little-endian.
902 Return count of SYMR's handled (normally one). */
905 parse_symbol(sh
, ax
, bigend
)
916 /* When a symbol is cross-referenced from other files/symbols
917 we mark it explicitly */
918 int pend
= (sh
->reserved
== 1);
919 enum address_class
class;
927 case stGlobal
: /* external symbol, goes into global block */
929 b
= BLOCKVECTOR_BLOCK(BLOCKVECTOR(top_stack
->cur_st
),
931 s
= new_symbol((char *)sh
->iss
);
932 SYMBOL_VALUE_ADDRESS(s
) = (CORE_ADDR
)sh
->value
;
935 case stStatic
: /* static data, goes into current block. */
937 b
= top_stack
->cur_block
;
938 s
= new_symbol((char *)sh
->iss
);
939 SYMBOL_VALUE_ADDRESS(s
) = (CORE_ADDR
)sh
->value
;
942 case stLocal
: /* local variable, goes into current block */
943 if (sh
->sc
== scRegister
) {
944 class = LOC_REGISTER
;
946 sh
->value
+= FP0_REGNUM
-32;
949 b
= top_stack
->cur_block
;
950 s
= new_symbol((char *)sh
->iss
);
951 SYMBOL_VALUE(s
) = sh
->value
;
953 data
: /* Common code for symbols describing data */
954 SYMBOL_NAMESPACE(s
) = VAR_NAMESPACE
;
955 SYMBOL_CLASS(s
) = class;
958 /* Type could be missing in a number of cases */
959 if (sh
->sc
== scUndefined
|| sh
->sc
== scNil
||
960 sh
->index
== 0xfffff)
961 SYMBOL_TYPE(s
) = builtin_type_int
; /* undefined? */
963 SYMBOL_TYPE(s
) = parse_type(ax
+ sh
->index
, 0, bigend
);
964 /* Value of a data symbol is its memory address */
967 case stParam
: /* arg to procedure, goes into current block */
969 top_stack
->numargs
++;
971 name
= (char*)sh
->iss
;
972 /* Special GNU C++ name. */
973 if (name
[0] == CPLUS_MARKER
&& name
[1] == 't' && name
[2] == 0)
974 name
= "this"; /* FIXME, not alloc'd in obstack */
975 s
= new_symbol(name
);
977 SYMBOL_NAMESPACE(s
) = VAR_NAMESPACE
;
978 if (sh
->sc
== scRegister
) {
979 SYMBOL_CLASS(s
) = LOC_REGPARM
;
981 sh
->value
+= FP0_REGNUM
-32;
983 SYMBOL_CLASS(s
) = LOC_ARG
;
984 SYMBOL_VALUE(s
) = sh
->value
;
985 SYMBOL_TYPE(s
) = parse_type(ax
+ sh
->index
, 0, bigend
);
986 add_symbol(s
, top_stack
->cur_block
);
988 /* FIXME: This has not been tested. See dbxread.c */
989 /* Add the type of this parameter to the function/procedure
990 type of this block. */
991 add_param_to_type(&top_stack
->cur_block
->function
->type
,s
);
995 case stLabel
: /* label, goes into current block */
996 s
= new_symbol((char *)sh
->iss
);
997 SYMBOL_NAMESPACE(s
) = VAR_NAMESPACE
; /* so that it can be used */
998 SYMBOL_CLASS(s
) = LOC_LABEL
; /* but not misused */
999 SYMBOL_VALUE_ADDRESS(s
) = (CORE_ADDR
)sh
->value
;
1000 SYMBOL_TYPE(s
) = builtin_type_int
;
1001 add_symbol(s
, top_stack
->cur_block
);
1004 case stProc
: /* Procedure, usually goes into global block */
1005 case stStaticProc
: /* Static procedure, goes into current block */
1006 s
= new_symbol((char *)sh
->iss
);
1007 SYMBOL_NAMESPACE(s
) = VAR_NAMESPACE
;
1008 SYMBOL_CLASS(s
) = LOC_BLOCK
;
1009 /* Type of the return value */
1010 if (sh
->sc
== scUndefined
|| sh
->sc
== scNil
)
1011 t
= builtin_type_int
;
1013 t
= parse_type(ax
+ sh
->index
+ 1, 0, bigend
);
1014 b
= top_stack
->cur_block
;
1015 if (sh
->st
== stProc
) {
1016 struct blockvector
*bv
= BLOCKVECTOR(top_stack
->cur_st
);
1017 /* The next test should normally be true,
1018 but provides a hook for nested functions
1019 (which we don't want to make global). */
1020 if (b
== BLOCKVECTOR_BLOCK(bv
, STATIC_BLOCK
))
1021 b
= BLOCKVECTOR_BLOCK(bv
, GLOBAL_BLOCK
);
1025 /* Make a type for the procedure itself */
1027 /* FIXME: This has not been tested yet! See dbxread.c */
1028 /* Generate a template for the type of this function. The
1029 types of the arguments will be added as we read the symbol
1031 bcopy(SYMBOL_TYPE(s
),lookup_function_type(t
),sizeof(struct type
));
1033 SYMBOL_TYPE(s
) = lookup_function_type (t
);
1036 /* Create and enter a new lexical context */
1037 b
= new_block(top_stack
->maxsyms
);
1038 SYMBOL_BLOCK_VALUE(s
) = b
;
1039 BLOCK_FUNCTION(b
) = s
;
1040 BLOCK_START(b
) = BLOCK_END(b
) = sh
->value
;
1041 BLOCK_SUPERBLOCK(b
) = top_stack
->cur_block
;
1042 add_block(b
, top_stack
->cur_st
);
1044 /* Not if we only have partial info */
1045 if (sh
->sc
== scUndefined
|| sh
->sc
== scNil
)
1049 top_stack
->cur_block
= b
;
1050 top_stack
->blocktype
= sh
->st
;
1051 top_stack
->cur_type
= SYMBOL_TYPE(s
);
1052 top_stack
->cur_field
= -1;
1053 top_stack
->procadr
= sh
->value
;
1054 top_stack
->numargs
= 0;
1056 sh
->value
= (long) SYMBOL_TYPE(s
);
1059 /* Beginning of code for structure, union, and enum definitions.
1060 They all share a common set of local variables, defined here. */
1062 enum type_code type_code
;
1068 case stStruct
: /* Start a block defining a struct type */
1069 type_code
= TYPE_CODE_STRUCT
;
1070 goto structured_common
;
1072 case stUnion
: /* Start a block defining a union type */
1073 type_code
= TYPE_CODE_UNION
;
1074 goto structured_common
;
1076 case stEnum
: /* Start a block defining an enum type */
1077 type_code
= TYPE_CODE_ENUM
;
1078 goto structured_common
;
1080 case stBlock
: /* Either a lexical block, or some type */
1081 if (sh
->sc
!= scInfo
)
1082 goto case_stBlock_code
; /* Lexical block */
1084 type_code
= TYPE_CODE_UNDEF
; /* We have a type. */
1086 /* Common code for handling struct, union, enum, and/or as-yet-
1087 unknown-type blocks of info about structured data. `type_code'
1088 has been set to the proper TYPE_CODE, if we know it. */
1091 top_stack
->blocktype
= stBlock
;
1093 s
= new_symbol((char *)sh
->iss
);
1094 SYMBOL_NAMESPACE(s
) = STRUCT_NAMESPACE
;
1095 SYMBOL_CLASS(s
) = LOC_TYPEDEF
;
1096 SYMBOL_VALUE(s
) = 0;
1097 add_symbol(s
, top_stack
->cur_block
);
1099 /* First count the number of fields and the highest value. */
1102 for (tsym
= sh
+1; tsym
->st
!= stEnd
; tsym
++)
1104 if (tsym
->st
== stMember
) {
1105 if (nfields
== 0 && type_code
== TYPE_CODE_UNDEF
)
1106 /* If the type of the member is Nil (or Void),
1107 assume the tag is an enumeration. */
1108 if (tsym
->index
== indexNil
)
1109 type_code
= TYPE_CODE_ENUM
;
1111 ecoff_swap_tir_in (bigend
,
1112 &ax
[tsym
->index
].a_ti
,
1114 if (tir
.bt
== btNil
|| tir
.bt
== btVoid
)
1115 type_code
= TYPE_CODE_ENUM
;
1118 if (tsym
->value
> max_value
)
1119 max_value
= tsym
->value
;
1121 else if (tsym
->st
== stBlock
1122 || tsym
->st
== stUnion
1123 || tsym
->st
== stEnum
1124 || tsym
->st
== stStruct
1125 || tsym
->st
== stParsed
) {
1126 if (tsym
->sc
== scVariant
) ; /*UNIMPLEMENTED*/
1127 if (tsym
->index
!= 0)
1128 tsym
= ((SYMR
*)cur_fdr
->isymBase
)
1131 else complain (&block_member_complaint
, (char *)tsym
->st
);
1134 /* In an stBlock, there is no way to distinguish structs,
1135 unions, and enums at this point. This is a bug in the
1136 original design (that has been fixed with the
1137 recent addition of the stStruct, stUnion, and stEnum
1138 symbol types.) The way you can tell is if/when you
1139 see a variable or field of that type. In that case
1140 the variable's type (in the AUX table) says if the
1141 type is struct, union, or enum,
1142 and points back to the stBlock here.
1143 So you can patch the tag kind up later - but only
1144 if there actually is a variable or field of that type.
1146 So until we know for sure, we will guess at this point.
1148 If the first member has index==indexNil or a void type,
1149 assume we have an enumeration.
1150 Otherwise, if there is more than one member, and all
1151 the members have offset 0, assume we have a union.
1152 Otherwise, assume we have a struct.
1154 The heuristic could guess wrong in the case of
1155 of an enumeration with no members or a union
1156 with one (or zero) members, or when all except the
1157 last field of a struct have width zero.
1158 These are uncommon and/or illegal situations, and
1159 in any case guessing wrong probably doesn't matter much.
1161 But if we later do find out we were wrong,
1162 we fixup the tag kind. Members of an enumeration
1163 must be handled differently from struct/union fields,
1164 and that is harder to patch up, but luckily we
1165 shouldn't need to. (If there are any enumeration
1166 members, we can tell for sure it's an enum here.) */
1168 if (type_code
== TYPE_CODE_UNDEF
)
1169 if (nfields
> 1 && max_value
== 0)
1170 type_code
= TYPE_CODE_UNION
;
1172 type_code
= TYPE_CODE_STRUCT
;
1174 /* If this type was expected, use its partial definition */
1176 t
= is_pending_symbol(cur_fdr
, sh
)->t
;
1178 t
= new_type(prepend_tag_kind((char *)sh
->iss
,
1181 TYPE_CODE(t
) = type_code
;
1182 TYPE_LENGTH(t
) = sh
->value
;
1183 TYPE_NFIELDS(t
) = nfields
;
1184 TYPE_FIELDS(t
) = f
= (struct field
*)
1185 obstack_alloc (¤t_objfile
-> type_obstack
,
1186 nfields
* sizeof (struct field
));
1188 if (type_code
== TYPE_CODE_ENUM
) {
1189 /* This is a non-empty enum. */
1190 for (tsym
= sh
+ 1; tsym
->st
== stMember
; tsym
++) {
1191 struct symbol
*enum_sym
;
1192 f
->bitpos
= tsym
->value
;
1194 f
->name
= (char*)tsym
->iss
;
1197 enum_sym
= (struct symbol
*)
1198 obstack_alloc (¤t_objfile
->symbol_obstack
,
1199 sizeof (struct symbol
));
1200 memset ((PTR
)enum_sym
, 0, sizeof (struct symbol
));
1201 SYMBOL_NAME (enum_sym
) = f
->name
;
1202 SYMBOL_CLASS (enum_sym
) = LOC_CONST
;
1203 SYMBOL_TYPE (enum_sym
) = t
;
1204 SYMBOL_NAMESPACE (enum_sym
) = VAR_NAMESPACE
;
1205 SYMBOL_VALUE (enum_sym
) = tsym
->value
;
1206 add_symbol(enum_sym
, top_stack
->cur_block
);
1208 /* Skip the stMembers that we've handled. */
1214 /* make this the current type */
1215 top_stack
->cur_type
= t
;
1216 top_stack
->cur_field
= 0;
1217 /* Mark that symbol has a type, and say which one */
1218 sh
->value
= (long) t
;
1221 /* End of local variables shared by struct, union, enum, and
1222 block (as yet unknown struct/union/enum) processing. */
1226 /* beginnning of (code) block. Value of symbol
1227 is the displacement from procedure start */
1229 top_stack
->blocktype
= stBlock
;
1230 b
= new_block(top_stack
->maxsyms
);
1231 BLOCK_START(b
) = sh
->value
+ top_stack
->procadr
;
1232 BLOCK_SUPERBLOCK(b
) = top_stack
->cur_block
;
1233 top_stack
->cur_block
= b
;
1234 add_block(b
, top_stack
->cur_st
);
1237 case stEnd
: /* end (of anything) */
1238 if (sh
->sc
== scInfo
) {
1239 /* Finished with type */
1240 top_stack
->cur_type
= 0;
1241 } else if (sh
->sc
== scText
&&
1242 (top_stack
->blocktype
== stProc
||
1243 top_stack
->blocktype
== stStaticProc
)) {
1244 /* Finished with procedure */
1245 struct blockvector
*bv
= BLOCKVECTOR(top_stack
->cur_st
);
1246 struct mips_extra_func_info
*e
;
1250 BLOCK_END(top_stack
->cur_block
) += sh
->value
; /* size */
1252 /* Make up special symbol to contain procedure specific
1254 s
= new_symbol(".gdbinfo.");
1255 SYMBOL_NAMESPACE(s
) = LABEL_NAMESPACE
;
1256 SYMBOL_CLASS(s
) = LOC_CONST
;
1257 SYMBOL_TYPE(s
) = builtin_type_void
;
1258 e
= (struct mips_extra_func_info
*)
1259 obstack_alloc (¤t_objfile
->symbol_obstack
,
1260 sizeof (struct mips_extra_func_info
));
1261 SYMBOL_VALUE(s
) = (int)e
;
1262 e
->numargs
= top_stack
->numargs
;
1263 add_symbol(s
, top_stack
->cur_block
);
1265 /* Reallocate symbols, saving memory */
1266 b
= shrink_block(top_stack
->cur_block
, top_stack
->cur_st
);
1268 /* f77 emits proc-level with address bounds==[0,0],
1269 So look for such child blocks, and patch them. */
1270 for (i
= 0; i
< BLOCKVECTOR_NBLOCKS(bv
); i
++) {
1271 struct block
*b_bad
= BLOCKVECTOR_BLOCK(bv
,i
);
1272 if (BLOCK_SUPERBLOCK(b_bad
) == b
1273 && BLOCK_START(b_bad
) == top_stack
->procadr
1274 && BLOCK_END(b_bad
) == top_stack
->procadr
) {
1275 BLOCK_START(b_bad
) = BLOCK_START(b
);
1276 BLOCK_END(b_bad
) = BLOCK_END(b
);
1279 } else if (sh
->sc
== scText
&& top_stack
->blocktype
== stBlock
) {
1280 /* End of (code) block. The value of the symbol
1281 is the displacement from the procedure`s start
1282 address of the end of this block. */
1283 BLOCK_END(top_stack
->cur_block
) = sh
->value
+ top_stack
->procadr
;
1284 (void) shrink_block(top_stack
->cur_block
, top_stack
->cur_st
);
1285 } else complain (&stEnd_complaint
, (char *)sh
->sc
);
1287 pop_parse_stack(); /* restore previous lexical context */
1290 case stMember
: /* member of struct or union */
1291 f
= &TYPE_FIELDS(top_stack
->cur_type
)[top_stack
->cur_field
++];
1292 f
->name
= (char*)sh
->iss
;
1293 f
->bitpos
= sh
->value
;
1295 f
->type
= parse_type(ax
+ sh
->index
, &f
->bitsize
, bigend
);
1298 case stTypedef
: /* type definition */
1299 s
= new_symbol((char *)sh
->iss
);
1300 SYMBOL_NAMESPACE(s
) = VAR_NAMESPACE
;
1301 SYMBOL_CLASS(s
) = LOC_TYPEDEF
;
1302 SYMBOL_BLOCK_VALUE(s
) = top_stack
->cur_block
;
1303 add_symbol(s
, top_stack
->cur_block
);
1304 SYMBOL_TYPE(s
) = parse_type(ax
+ sh
->index
, 0, bigend
);
1305 sh
->value
= (long) SYMBOL_TYPE(s
);
1308 case stFile
: /* file name */
1310 top_stack
->blocktype
= sh
->st
;
1313 /* I`ve never seen these for C */
1315 break; /* register relocation */
1317 break; /* forwarding address */
1319 break; /* constant */
1321 complain(&unknown_mips_symtype_complaint
, (char *)sh
->st
);
1328 /* Parse the type information provided in the raw AX entries for
1329 the symbol SH. Return the bitfield size in BS, in case.
1330 We must byte-swap the AX entries before we use them; BIGEND says whether
1331 they are big-endian or little-endian (from fh->fBigendian). */
1333 static struct type
*
1334 parse_type(ax
, bs
, bigend
)
1339 /* Null entries in this map are treated specially */
1340 static struct type
**map_bt
[] =
1342 &builtin_type_void
, /* btNil */
1344 &builtin_type_char
, /* btChar */
1345 &builtin_type_unsigned_char
, /* btUChar */
1346 &builtin_type_short
, /* btShort */
1347 &builtin_type_unsigned_short
, /* btUShort */
1348 &builtin_type_int
, /* btInt */
1349 &builtin_type_unsigned_int
, /* btUInt */
1350 &builtin_type_long
, /* btLong */
1351 &builtin_type_unsigned_long
, /* btULong */
1352 &builtin_type_float
, /* btFloat */
1353 &builtin_type_double
, /* btDouble */
1360 &builtin_type_complex
, /* btComplex */
1361 &builtin_type_double_complex
, /* btDComplex */
1363 &builtin_type_fixed_dec
, /* btFixedDec */
1364 &builtin_type_float_dec
, /* btFloatDec */
1365 &builtin_type_string
, /* btString */
1368 &builtin_type_void
, /* btVoid */
1369 &builtin_type_long_long
, /* btLongLong */
1370 &builtin_type_unsigned_long_long
,/* btULongLong */
1374 struct type
*tp
= 0;
1377 enum type_code type_code
;
1379 /* Use aux as a type information record, map its basic type. */
1381 ecoff_swap_tir_in (bigend
, &tax
->a_ti
, t
);
1382 if (t
->bt
> (sizeof (map_bt
)/sizeof (*map_bt
))) {
1383 complain (&basic_type_complaint
, (char *)t
->bt
);
1384 return builtin_type_int
;
1386 if (map_bt
[t
->bt
]) {
1387 tp
= *map_bt
[t
->bt
];
1391 /* Cannot use builtin types -- build our own */
1394 tp
= lookup_pointer_type (builtin_type_void
);
1398 type_code
= TYPE_CODE_STRUCT
;
1402 type_code
= TYPE_CODE_UNION
;
1406 type_code
= TYPE_CODE_ENUM
;
1410 type_code
= TYPE_CODE_RANGE
;
1414 type_code
= TYPE_CODE_SET
;
1419 complain (&basic_type_complaint
, (char *)t
->bt
);
1420 return builtin_type_int
;
1424 /* Skip over any further type qualifiers (FIXME). */
1426 /* This is the way it would work if the compiler worked */
1430 ecoff_swap_tir_in (bigend
, ax
, t1
);
1431 } while (t1
->continued
);
1434 /* Move on to next aux */
1438 *bs
= AUX_GET_WIDTH (bigend
, ax
);
1442 /* All these types really point to some (common) MIPS type
1443 definition, and only the type-qualifiers fully identify
1444 them. We'll make the same effort at sharing. */
1445 if (t
->bt
== btIndirect
||
1446 t
->bt
== btStruct
||
1449 t
->bt
== btTypedef
||
1452 char name
[256], *pn
;
1454 /* Try to cross reference this type */
1455 ax
+= cross_ref(ax
, &tp
, type_code
, &pn
, bigend
);
1456 /* reading .o file ? */
1457 if (UNSAFE_DATA_ADDR(tp
))
1458 tp
= init_type(type_code
, 0, 0, 0, (struct objfile
*) NULL
);
1459 /* SOMEONE OUGHT TO FIX DBXREAD TO DROP "STRUCT" */
1460 sprintf(name
, fmt
, pn
);
1462 /* Usually, TYPE_CODE(tp) is already type_code. The main
1463 exception is if we guessed wrong re struct/union/enum. */
1464 if (TYPE_CODE(tp
) != type_code
) {
1465 complain (&bad_tag_guess_complaint
, name
);
1466 TYPE_CODE(tp
) = type_code
;
1468 if (TYPE_NAME(tp
) == NULL
|| strcmp(TYPE_NAME(tp
), name
) != 0)
1469 TYPE_NAME(tp
) = obsavestring(name
, strlen(name
),
1470 ¤t_objfile
-> type_obstack
);
1473 /* Deal with range types */
1474 if (t
->bt
== btRange
) {
1475 TYPE_NFIELDS (tp
) = 2;
1477 (struct field
*) obstack_alloc (¤t_objfile
-> type_obstack
,
1478 2 * sizeof (struct field
));
1479 TYPE_FIELD_NAME (tp
, 0) = obsavestring ("Low", strlen ("Low"),
1480 ¤t_objfile
-> type_obstack
);
1481 TYPE_FIELD_BITPOS (tp
, 0) = AUX_GET_DNLOW (bigend
, ax
);
1483 TYPE_FIELD_NAME (tp
, 1) = obsavestring ("High", strlen ("High"),
1484 ¤t_objfile
-> type_obstack
);
1485 TYPE_FIELD_BITPOS (tp
, 1) = AUX_GET_DNHIGH (bigend
, ax
);
1489 /* Parse all the type qualifiers now. If there are more
1490 than 6 the game will continue in the next aux */
1492 #define PARSE_TQ(tq) \
1493 if (t->tq != tqNil) ax += upgrade_type(&tp, t->tq, ax, bigend);
1495 again
: PARSE_TQ(tq0
);
1505 ecoff_swap_tir_in (bigend
, &tax
->a_ti
, t
);
1511 /* Make up a complex type from a basic one. Type is passed by
1512 reference in TPP and side-effected as necessary. The type
1513 qualifier TQ says how to handle the aux symbols at AX for
1514 the symbol SX we are currently analyzing. BIGEND says whether
1515 aux symbols are big-endian or little-endian.
1516 Returns the number of aux symbols we parsed. */
1519 upgrade_type(tpp
, tq
, ax
, bigend
)
1528 /* Used in array processing */
1537 t
= lookup_pointer_type (*tpp
);
1542 t
= lookup_function_type (*tpp
);
1548 t
= init_type(TYPE_CODE_ARRAY
, 0, 0, 0, (struct objfile
*) NULL
);
1549 TYPE_TARGET_TYPE(t
) = *tpp
;
1551 /* Determine and record the domain type (type of index) */
1552 ecoff_swap_rndx_in (bigend
, ax
, &rndx
);
1557 rf
= AUX_GET_ISYM (bigend
, ax
);
1560 fh
= get_rfd(cur_fd
, rf
);
1562 /* Fields are kept in an array */
1563 /* FIXME - Memory leak! */
1564 if (TYPE_NFIELDS(t
))
1565 TYPE_FIELDS(t
) = (struct field
*)
1566 xrealloc((PTR
) TYPE_FIELDS(t
),
1567 (TYPE_NFIELDS(t
)+1) * sizeof(struct field
));
1569 TYPE_FIELDS(t
) = (struct field
*)
1570 xzalloc(sizeof(struct field
));
1571 f
= &(TYPE_FIELD(t
,TYPE_NFIELDS(t
)));
1573 memset((PTR
)f
, 0, sizeof(struct field
));
1575 /* XXX */ f
->type
= parse_type(id
+ (union aux_ext
*)fh
->iauxBase
,
1576 &f
->bitsize
, bigend
);
1579 lower
= AUX_GET_DNLOW (bigend
, ax
);
1581 upper
= AUX_GET_DNHIGH (bigend
, ax
);
1583 rf
= AUX_GET_WIDTH (bigend
, ax
); /* bit size of array element */
1585 /* Check whether supplied array element bit size matches
1586 the known size of the element type. If this complaint
1587 ends up not happening, we can remove this code. It's
1588 here because we aren't sure we understand this *&%&$
1590 id
= TYPE_LENGTH(TYPE_TARGET_TYPE(t
)) << 3; /* bitsize */
1592 /* Most likely an undefined type */
1594 TYPE_LENGTH(TYPE_TARGET_TYPE(t
)) = id
>> 3;
1597 complain (&array_bitsize_complaint
, (char *)rf
);
1599 TYPE_LENGTH(t
) = (upper
< 0) ? 0 :
1600 (upper
- lower
+ 1) * (rf
>> 3);
1605 /* Volatile -- currently ignored */
1609 /* Const -- currently ignored */
1613 complain (&unknown_type_qual_complaint
, (char *)tq
);
1619 /* Parse a procedure descriptor record PR. Note that the procedure
1620 is parsed _after_ the local symbols, now we just insert the extra
1621 information we need into a special ".gdbinfo." symbol that has already
1622 been placed in the procedure's main block. Note also that images that
1623 have been partially stripped (ld -x) have been deprived
1624 of local symbols, and we have to cope with them here.
1625 The procedure's code ends at BOUND */
1628 parse_procedure (pr
, bound
, have_stabs
)
1633 struct symbol
*s
, *i
;
1634 SYMR
*sh
= (SYMR
*)pr
->isym
;
1636 struct mips_extra_func_info
*e
;
1640 /* Static procedure at address pr->adr. Sigh. */
1641 if (sh
== (SYMR
*)-1) {
1642 complain (&pdr_static_symbol_complaint
, (char *)pr
->adr
);
1645 sh_name
= (char*)sh
->iss
;
1647 s
= lookup_symbol(sh_name
, NULL
, VAR_NAMESPACE
, 0, NULL
);
1649 s
= mylookup_symbol(sh_name
, top_stack
->cur_block
,
1650 VAR_NAMESPACE
, LOC_BLOCK
);
1653 b
= SYMBOL_BLOCK_VALUE(s
);
1655 complain (&pdr_for_nonsymbol_complaint
, sh_name
);
1659 /* FIXME -- delete. We can't do symbol allocation now; it's all done. */
1660 s
= new_symbol(sh_name
);
1661 SYMBOL_NAMESPACE(s
) = VAR_NAMESPACE
;
1662 SYMBOL_CLASS(s
) = LOC_BLOCK
;
1663 /* Donno its type, hope int is ok */
1664 SYMBOL_TYPE(s
) = lookup_function_type (builtin_type_int
);
1665 add_symbol(s
, top_stack
->cur_block
);
1666 /* Wont have symbols for this one */
1668 SYMBOL_BLOCK_VALUE(s
) = b
;
1669 BLOCK_FUNCTION(b
) = s
;
1670 BLOCK_START(b
) = pr
->adr
;
1671 BLOCK_END(b
) = bound
;
1672 BLOCK_SUPERBLOCK(b
) = top_stack
->cur_block
;
1673 add_block(b
, top_stack
->cur_st
);
1677 i
= mylookup_symbol(".gdbinfo.", b
, LABEL_NAMESPACE
, LOC_CONST
);
1681 e
= (struct mips_extra_func_info
*)SYMBOL_VALUE(i
);
1683 e
->pdr
.isym
= (long)s
;
1687 /* Parse the external symbol ES. Just call parse_symbol() after
1688 making sure we know where the aux are for it. For procedures,
1689 parsing of the PDRs has already provided all the needed
1690 information, we only parse them if SKIP_PROCEDURES is false,
1691 and only if this causes no symbol duplication.
1692 BIGEND says whether aux entries are big-endian or little-endian.
1694 This routine clobbers top_stack->cur_block and ->cur_st. */
1697 parse_external(es
, skip_procedures
, bigend
)
1699 int skip_procedures
;
1704 if (es
->ifd
!= ifdNil
) {
1706 cur_fdr
= (FDR
*)(cur_hdr
->cbFdOffset
) + cur_fd
;
1707 ax
= (union aux_ext
*)cur_fdr
->iauxBase
;
1709 cur_fdr
= (FDR
*)(cur_hdr
->cbFdOffset
);
1713 /* Reading .o files */
1714 if (es
->asym
.sc
== scUndefined
|| es
->asym
.sc
== scNil
) {
1716 switch (es
->asym
.st
) {
1718 case stProc
: what
= "procedure"; n_undef_procs
++; break;
1719 case stGlobal
: what
= "variable"; n_undef_vars
++; break;
1720 case stLabel
: what
= "label"; n_undef_labels
++; break;
1721 default : what
= "symbol"; break;
1724 /* FIXME: Turn this into a complaint? */
1726 printf_filtered("Warning: %s `%s' is undefined (in %s)\n",
1727 what
, es
->asym
.iss
, fdr_name((char *)cur_fdr
->rss
));
1731 switch (es
->asym
.st
) {
1733 /* If we have full symbols we do not need more */
1734 if (skip_procedures
)
1736 if (mylookup_symbol ((char *)es
->asym
.iss
, top_stack
->cur_block
,
1737 VAR_NAMESPACE
, LOC_BLOCK
))
1743 * Note that the case of a symbol with indexNil
1744 * must be handled anyways by parse_symbol().
1746 parse_symbol(&es
->asym
, ax
, bigend
);
1753 /* Parse the line number info for file descriptor FH into
1754 GDB's linetable LT. MIPS' encoding requires a little bit
1755 of magic to get things out. Note also that MIPS' line
1756 numbers can go back and forth, apparently we can live
1757 with that and do not need to reorder our linetables */
1762 struct linetable
*lt
;
1764 unsigned char *base
= (unsigned char*)fh
->cbLineOffset
;
1766 int delta
, count
, lineno
= 0;
1772 /* Scan by procedure descriptors */
1774 for (pr
= (PDR
*)IPDFIRST(cur_hdr
,fh
); j
< fh
->cpd
; j
++, pr
++) {
1777 /* No code for this one */
1778 if (pr
->iline
== ilineNil
||
1779 pr
->lnLow
== -1 || pr
->lnHigh
== -1)
1782 * Aurgh! To know where to stop expanding we
1785 for (l
= 1; l
< (fh
->cpd
- j
); l
++)
1786 if (pr
[l
].iline
!= -1)
1788 if (l
== (fh
->cpd
- j
))
1793 * When procedures are moved around the linenumbers
1794 * are attributed to the next procedure up
1796 if (pr
->iline
>= halt
) continue;
1798 base
= (unsigned char*)pr
->cbLineOffset
;
1799 l
= pr
->adr
>> 2; /* in words */
1800 halt
+= (pr
->adr
>> 2) - pr
->iline
;
1801 for (lineno
= pr
->lnLow
; l
< halt
;) {
1802 count
= *base
& 0x0f;
1803 delta
= *base
++ >> 4;
1807 delta
= (base
[0] << 8) | base
[1];
1808 if (delta
>= 0x8000)
1812 lineno
+= delta
;/* first delta is 0 */
1813 k
= add_line(lt
, lineno
, l
, k
);
1819 /* Master parsing procedure for first-pass reading of file symbols
1820 into a partial_symtab.
1822 Parses the symtab described by the global symbolic header CUR_HDR.
1823 END_OF_TEXT_SEG gives the address just after the text segment for
1824 the symtab we are reading. */
1827 parse_partial_symbols (end_of_text_seg
, objfile
)
1828 int end_of_text_seg
;
1829 struct objfile
*objfile
;
1832 HDRR
*hdr
= cur_hdr
;
1833 /* Running pointers */
1837 struct partial_symtab
*pst
;
1839 int past_first_source_file
= 0;
1841 /* List of current psymtab's include files */
1842 char **psymtab_include_list
;
1843 int includes_allocated
;
1846 struct pst_map
* fdr_to_pst
;
1847 /* Index within current psymtab dependency list */
1848 struct partial_symtab
**dependency_list
;
1849 int dependencies_used
, dependencies_allocated
;
1850 struct cleanup
*old_chain
;
1852 extern_tab
= (EXTR
**)obstack_alloc (&objfile
->psymbol_obstack
,
1853 sizeof(EXTR
*) * hdr
->iextMax
);
1855 includes_allocated
= 30;
1857 psymtab_include_list
= (char **) alloca (includes_allocated
*
1859 next_symbol_text_func
= mips_next_symbol_text
;
1861 dependencies_allocated
= 30;
1862 dependencies_used
= 0;
1864 (struct partial_symtab
**) alloca (dependencies_allocated
*
1865 sizeof (struct partial_symtab
*));
1867 last_source_file
= 0;
1872 * Only parse the Local and External symbols, and the Relative FDR.
1873 * Fixup enough of the loader symtab to be able to use it.
1874 * Allocate space only for the file's portions we need to
1879 max_glevel
= MIN_GLEVEL
;
1881 /* Allocate the map FDR -> PST.
1882 Minor hack: -O3 images might claim some global data belongs
1883 to FDR -1. We`ll go along with that */
1884 fdr_to_pst
= (struct pst_map
*)xzalloc((hdr
->ifdMax
+1) * sizeof *fdr_to_pst
);
1885 old_chain
= make_cleanup (free
, fdr_to_pst
);
1888 struct partial_symtab
* pst
= new_psymtab("", objfile
);
1889 fdr_to_pst
[-1].pst
= pst
;
1893 /* Pass 1 over external syms: Presize and partition the list */
1894 for (s_idx
= 0; s_idx
< hdr
->iextMax
; s_idx
++) {
1895 esh
= (EXTR
*) (hdr
->cbExtOffset
) + s_idx
;
1896 fdr_to_pst
[esh
->ifd
].n_globals
++;
1899 /* Pass 1.5 over files: partition out global symbol space */
1901 for (f_idx
= -1; f_idx
< hdr
->ifdMax
; f_idx
++) {
1902 fdr_to_pst
[f_idx
].globals_offset
= s_idx
;
1903 s_idx
+= fdr_to_pst
[f_idx
].n_globals
;
1904 fdr_to_pst
[f_idx
].n_globals
= 0;
1907 /* Pass 2 over external syms: fill in external symbols */
1908 for (s_idx
= 0; s_idx
< hdr
->iextMax
; s_idx
++) {
1909 enum minimal_symbol_type ms_type
= mst_text
;
1910 esh
= (EXTR
*) (hdr
->cbExtOffset
) + s_idx
;
1912 extern_tab
[fdr_to_pst
[esh
->ifd
].globals_offset
1913 + fdr_to_pst
[esh
->ifd
].n_globals
++] = esh
;
1915 if (esh
->asym
.sc
== scUndefined
|| esh
->asym
.sc
== scNil
)
1918 switch (esh
->asym
.st
) {
1927 ms_type
= mst_unknown
;
1928 complain (&unknown_ext_complaint
, (char *)esh
->asym
.iss
);
1930 prim_record_minimal_symbol ((char *)esh
->asym
.iss
,
1935 /* Pass 3 over files, over local syms: fill in static symbols */
1936 for (f_idx
= 0; f_idx
< hdr
->ifdMax
; f_idx
++) {
1937 struct partial_symtab
*save_pst
;
1939 cur_fdr
= fh
= f_idx
+ (FDR
*)(cur_hdr
->cbFdOffset
);
1941 if (fh
->csym
== 0) {
1942 fdr_to_pst
[f_idx
].pst
= NULL
;
1945 pst
= start_psymtab_common (objfile
, 0, (char*)fh
->rss
,
1946 fh
->cpd
? fh
->adr
: 0,
1947 objfile
->global_psymbols
.next
,
1948 objfile
->static_psymbols
.next
);
1949 pst
->read_symtab_private
= (char *)
1950 obstack_alloc (&objfile
->psymbol_obstack
, sizeof (struct symloc
));
1953 /* Make everything point to everything. */
1954 FDR_IDX(pst
) = f_idx
;
1955 fdr_to_pst
[f_idx
].pst
= pst
;
1956 fh
->ioptBase
= (int)pst
;
1958 CUR_HDR(pst
) = cur_hdr
;
1960 /* The way to turn this into a symtab is to call... */
1961 pst
->read_symtab
= mipscoff_psymtab_to_symtab
;
1963 pst
->texthigh
= pst
->textlow
;
1965 #if 0 /* This is done in start_psymtab_common */
1966 pst
->globals_offset
= global_psymbols
.next
- global_psymbols
.list
;
1967 pst
->statics_offset
= static_psymbols
.next
- static_psymbols
.list
;
1969 pst
->n_global_syms
= 0;
1970 pst
->n_static_syms
= 0;
1973 /* The second symbol must be @stab.
1974 This symbol is emitted by mips-tfile to signal
1975 that the current object file uses encapsulated stabs
1976 instead of mips ecoff for local symbols.
1977 (It is the second symbol because the first symbol is
1978 the stFile used to signal the start of a file). */
1980 && strcmp((char *)(((SYMR
*)fh
->isymBase
)[1].iss
),
1981 stabs_symbol
) == 0) {
1982 for (cur_sdx
= 2; cur_sdx
< fh
->csym
; cur_sdx
++) {
1985 sh
= cur_sdx
+ (SYMR
*) fh
->isymBase
;
1986 type_code
= MIPS_UNMARK_STAB(sh
->index
);
1987 if (!MIPS_IS_STAB(sh
)) {
1988 if (sh
->st
== stProc
|| sh
->st
== stStaticProc
) {
1989 long procaddr
= sh
->value
;
1990 sh
= AUX_GET_ISYM (fh
->fBigendian
,
1991 sh
->index
+ (union aux_ext
*)(fh
->iauxBase
))
1992 + (SYMR
*) fh
->isymBase
- 1;
1993 if (sh
->st
== stEnd
) {
1994 long high
= procaddr
+ sh
->value
;
1995 if (high
> pst
->texthigh
)
1996 pst
->texthigh
= high
;
2001 #define SET_NAMESTRING() namestring = (char*)sh->iss
2002 #define CUR_SYMBOL_TYPE type_code
2003 #define CUR_SYMBOL_VALUE sh->value
2004 #define START_PSYMTAB(ofile,addr,fname,low,symoff,global_syms,static_syms)\
2006 #define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps) (void)0
2007 #define addr 0 /* FIXME, should be offset of addresses */
2008 #define HANDLE_RBRAC(val) \
2009 if ((val) > save_pst->texthigh) save_pst->texthigh = (val);
2010 #include "partial-stab.h"
2015 for (cur_sdx
= 0; cur_sdx
< fh
->csym
; ) {
2017 enum address_class
class;
2018 sh
= cur_sdx
+ (SYMR
*) fh
->isymBase
;
2020 if (MIPS_IS_STAB(sh
)) {
2025 if (sh
->sc
== scUndefined
|| sh
->sc
== scNil
||
2026 sh
->index
== 0xfffff) {
2027 /* FIXME, premature? */
2032 name
= (char *)(sh
->iss
);
2039 case stProc
: /* Asm labels apparently */
2040 case stStaticProc
: /* Function */
2041 ADD_PSYMBOL_TO_LIST(name
, strlen(name
),
2042 VAR_NAMESPACE
, LOC_BLOCK
,
2043 objfile
->static_psymbols
, sh
->value
);
2044 /* Skip over procedure to next one. */
2045 if (sh
->index
>= hdr
->iauxMax
)
2047 /* Should not happen, but does when cross-compiling
2048 with the MIPS compiler. FIXME -- pull later. */
2049 complain (&index_complaint
, name
);
2050 new_sdx
= cur_sdx
+1; /* Don't skip at all */
2053 new_sdx
= AUX_GET_ISYM (fh
->fBigendian
,
2054 sh
->index
+ (union aux_ext
*)fh
->iauxBase
);
2055 procaddr
= sh
->value
;
2057 if (new_sdx
<= cur_sdx
)
2059 /* This should not happen either... FIXME. */
2060 complain (&aux_index_complaint
, name
);
2061 new_sdx
= cur_sdx
+ 1; /* Don't skip backward */
2065 sh
= cur_sdx
+ (SYMR
*) fh
->isymBase
- 1;
2066 if (sh
->st
!= stEnd
)
2068 high
= procaddr
+ sh
->value
;
2069 if (high
> pst
->texthigh
)
2070 pst
->texthigh
= high
;
2073 case stStatic
: /* Variable */
2077 case stTypedef
: /* Typedef */
2078 class = LOC_TYPEDEF
;
2081 case stConstant
: /* Constant decl */
2088 case stBlock
: /* { }, str, un, enum*/
2089 if (sh
->sc
== scInfo
) {
2090 ADD_PSYMBOL_TO_LIST(name
, strlen(name
),
2091 STRUCT_NAMESPACE
, LOC_TYPEDEF
,
2092 objfile
->static_psymbols
, sh
->value
);
2094 /* Skip over the block */
2095 cur_sdx
= sh
->index
;
2098 case stFile
: /* File headers */
2099 case stLabel
: /* Labels */
2100 case stEnd
: /* Ends of files */
2104 /* Both complaints are valid: one gives symbol name,
2105 the other the offending symbol type. */
2106 complain (&unknown_sym_complaint
, (char *)sh
->iss
);
2107 complain (&unknown_st_complaint
, (char *)sh
->st
);
2111 /* Use this gdb symbol */
2112 ADD_PSYMBOL_TO_LIST(name
, strlen(name
),
2113 VAR_NAMESPACE
, class,
2114 objfile
->static_psymbols
, sh
->value
);
2116 cur_sdx
++; /* Go to next file symbol */
2119 /* Now do enter the external symbols. */
2120 ext_ptr
= &extern_tab
[fdr_to_pst
[f_idx
].globals_offset
];
2121 cur_sdx
= fdr_to_pst
[f_idx
].n_globals
;
2122 PST_PRIVATE(save_pst
)->extern_count
= cur_sdx
;
2123 PST_PRIVATE(save_pst
)->extern_tab
= ext_ptr
;
2124 for (; --cur_sdx
>= 0; ext_ptr
++) {
2125 register struct partial_symbol
*psym
;
2126 enum address_class
class;
2128 if ((*ext_ptr
)->ifd
!= f_idx
)
2130 sh
= &(*ext_ptr
)->asym
;
2139 complain (&unknown_ext_complaint
, (char *)sh
->iss
);
2140 /* Fall through, pretend it's global. */
2145 if (objfile
->global_psymbols
.next
>=
2146 objfile
->global_psymbols
.list
+ objfile
->global_psymbols
.size
)
2147 extend_psymbol_list (&objfile
->global_psymbols
, objfile
);
2148 psym
= objfile
->global_psymbols
.next
++;
2149 SYMBOL_NAME (psym
) = (char*)sh
->iss
;
2150 SYMBOL_NAMESPACE (psym
) = VAR_NAMESPACE
;
2151 SYMBOL_CLASS (psym
) = class;
2152 SYMBOL_VALUE_ADDRESS (psym
) = (CORE_ADDR
)sh
->value
;
2156 end_psymtab (save_pst
, psymtab_include_list
, includes_used
,
2157 -1, save_pst
->texthigh
,
2158 dependency_list
, dependencies_used
);
2159 if (objfile
-> ei
.entry_point
>= save_pst
->textlow
&&
2160 objfile
-> ei
.entry_point
< save_pst
->texthigh
)
2162 objfile
-> ei
.entry_file_lowpc
= save_pst
->textlow
;
2163 objfile
-> ei
.entry_file_highpc
= save_pst
->texthigh
;
2167 /* Mark the last code address, and remember it for later */
2168 hdr
->cbDnOffset
= end_of_text_seg
;
2170 /* Now scan the FDRs for dependencies */
2171 for (f_idx
= 0; f_idx
< hdr
->ifdMax
; f_idx
++) {
2173 fh
= f_idx
+ (FDR
*)(cur_hdr
->cbFdOffset
);
2174 pst
= fdr_to_pst
[f_idx
].pst
;
2176 /* This should catch stabs-in-ecoff. */
2180 if (fh
->cpd
== 0) { /* If there are no functions defined here ... */
2181 /* ...then presumably a .h file: drop reverse depends .h->.c */
2182 for (; s_id0
< fh
->crfd
; s_id0
++) {
2183 RFDT
*rh
= (RFDT
*) (fh
->rfdBase
) + s_id0
;
2185 s_id0
++; /* Skip self-dependency */
2190 pst
->number_of_dependencies
= fh
->crfd
- s_id0
;
2191 pst
->dependencies
= (struct partial_symtab
**)
2192 obstack_alloc (&objfile
->psymbol_obstack
,
2193 pst
->number_of_dependencies
*
2194 sizeof (struct partial_symtab
*));
2195 for (s_idx
= s_id0
; s_idx
< fh
->crfd
; s_idx
++) {
2196 RFDT
*rh
= (RFDT
*) (fh
->rfdBase
) + s_idx
;
2197 if (*rh
< 0 || *rh
>= hdr
->ifdMax
)
2198 complain(&bad_file_number_complaint
, (char *)*rh
);
2200 pst
->dependencies
[s_idx
-s_id0
] = fdr_to_pst
[*rh
].pst
;
2203 do_cleanups (old_chain
);
2208 /* Do the initial analisys of the F_IDX-th file descriptor.
2209 Allocates a partial symtab for it, and builds the list
2210 of dependent files by recursion. LEV says at which level
2211 of recursion we are called (to pretty up debug traces) */
2213 static struct partial_symtab
*
2214 parse_fdr(f_idx
, lev
, objfile
)
2217 struct objfile
*objfile
;
2220 register struct partial_symtab
*pst
;
2223 fh
= (FDR
*) (cur_hdr
->cbFdOffset
) + f_idx
;
2225 /* Use this to indicate into which symtab this file was parsed */
2227 return (struct partial_symtab
*) fh
->ioptBase
;
2229 /* Debuggability level */
2230 if (compare_glevel(max_glevel
, fh
->glevel
) < 0)
2231 max_glevel
= fh
->glevel
;
2233 /* Make a new partial_symtab */
2234 pst
= new_psymtab(fh
->rss
, objfile
);
2239 pst
->textlow
= fh
->adr
;
2240 pst
->texthigh
= fh
->cpd
; /* To be fixed later */
2243 /* Make everything point to everything. */
2244 FDR_IDX(pst
) = f_idx
;
2245 fdr_to_pst
[f_idx
].pst
= pst
;
2246 fh
->ioptBase
= (int)pst
;
2248 /* Analyze its dependencies */
2253 if (fh
->cpd
== 0) { /* If there are no functions defined here ... */
2254 /* ...then presumably a .h file: drop reverse depends .h->.c */
2255 for (; s_id0
< fh
->crfd
; s_id0
++) {
2256 RFDT
*rh
= (RFDT
*) (fh
->rfdBase
) + s_id0
;
2258 s_id0
++; /* Skip self-dependency */
2263 pst
->number_of_dependencies
= fh
->crfd
- s_id0
;
2264 pst
->dependencies
= (struct partial_symtab
**)
2265 obstack_alloc (&objfile
->psymbol_obstack
,
2266 pst
->number_of_dependencies
*
2267 sizeof (struct partial_symtab
*));
2268 for (s_idx
= s_id0
; s_idx
< fh
->crfd
; s_idx
++) {
2269 RFDT
*rh
= (RFDT
*) (fh
->rfdBase
) + s_idx
;
2271 pst
->dependencies
[s_idx
-s_id0
] = parse_fdr(*rh
, lev
+1, objfile
);
2279 mips_next_symbol_text ()
2282 return (char*)((SYMR
*)cur_fdr
->isymBase
)[cur_sdx
].iss
;
2285 /* Ancillary function to psymtab_to_symtab(). Does all the work
2286 for turning the partial symtab PST into a symtab, recurring
2287 first on all dependent psymtabs. The argument FILENAME is
2288 only passed so we can see in debug stack traces what file
2291 This function has a split personality, based on whether the
2292 symbol table contains ordinary ecoff symbols, or stabs-in-ecoff.
2293 The flow of control and even the memory allocation differs. FIXME. */
2296 psymtab_to_symtab_1(pst
, filename
)
2297 struct partial_symtab
*pst
;
2303 struct linetable
*lines
;
2310 /* Read in all partial symbtabs on which this one is dependent.
2311 NOTE that we do have circular dependencies, sigh. We solved
2312 that by setting pst->readin before this point. */
2314 for (i
= 0; i
< pst
->number_of_dependencies
; i
++)
2315 if (!pst
->dependencies
[i
]->readin
) {
2316 /* Inform about additional files to be read in. */
2319 fputs_filtered (" ", stdout
);
2321 fputs_filtered ("and ", stdout
);
2323 printf_filtered ("%s...",
2324 pst
->dependencies
[i
]->filename
);
2325 wrap_here (""); /* Flush output */
2328 /* We only pass the filename for debug purposes */
2329 psymtab_to_symtab_1(pst
->dependencies
[i
],
2330 pst
->dependencies
[i
]->filename
);
2333 /* Now read the symbols for this symtab */
2335 current_objfile
= pst
->objfile
;
2336 cur_fd
= FDR_IDX(pst
);
2337 fh
= (cur_fd
== -1) ? 0 : (FDR
*) (cur_hdr
->cbFdOffset
) + FDR_IDX(pst
);
2340 /* BOUND is the highest core address of this file's procedures */
2341 bound
= (cur_fd
== cur_hdr
->ifdMax
- 1) ?
2342 cur_hdr
->cbDnOffset
:
2345 /* See comment in parse_partial_symbols about the @stabs sentinel. */
2346 if (fh
&& fh
->csym
>= 2
2347 && strcmp((char *)(((SYMR
*)fh
->isymBase
)[1].iss
), stabs_symbol
)
2351 * This symbol table contains stabs-in-ecoff entries.
2357 /* Parse local symbols first */
2359 if (fh
->csym
<= 2) /* FIXME, this blows psymtab->symtab ptr */
2361 current_objfile
= NULL
;
2364 for (cur_sdx
= 2; cur_sdx
< fh
->csym
; cur_sdx
++) {
2365 register SYMR
*sh
= cur_sdx
+ (SYMR
*) fh
->isymBase
;
2366 char *name
= (char*)sh
->iss
;
2367 CORE_ADDR valu
= sh
->value
;
2368 if (MIPS_IS_STAB(sh
)) {
2369 int type_code
= MIPS_UNMARK_STAB(sh
->index
);
2370 process_one_symbol (type_code
, 0, valu
, name
, /*FIXME*/ 0,
2372 if (type_code
== N_FUN
) {
2373 /* Make up special symbol to contain
2374 procedure specific info */
2375 struct mips_extra_func_info
*e
=
2376 (struct mips_extra_func_info
*)
2377 obstack_alloc(¤t_objfile
->symbol_obstack
,
2378 sizeof(struct mips_extra_func_info
));
2379 struct symbol
*s
= new_symbol(".gdbinfo.");
2380 SYMBOL_NAMESPACE(s
) = LABEL_NAMESPACE
;
2381 SYMBOL_CLASS(s
) = LOC_CONST
;
2382 SYMBOL_TYPE(s
) = builtin_type_void
;
2383 SYMBOL_VALUE(s
) = (int)e
;
2384 add_symbol_to_list (s
, &local_symbols
);
2387 else if (sh
->st
== stLabel
&& sh
->index
!= indexNil
) {
2388 /* Handle encoded stab line number. */
2389 record_line (current_subfile
, sh
->index
, valu
);
2391 else complain (&stab_unknown_complaint
, (char *)sh
->iss
);
2393 st
= end_symtab (pst
->texthigh
, 0, 0, pst
->objfile
);
2395 /* Sort the symbol table now, we are done adding symbols to it.
2396 We must do this before parse_procedure calls lookup_symbol. */
2397 sort_symtab_syms(st
);
2399 /* This may not be necessary for stabs symtabs. FIXME. */
2402 /* Fill in procedure info next. We need to look-ahead to
2403 find out where each procedure's code ends. */
2405 for (i
= 0; i
<= fh
->cpd
-1; i
++) {
2406 pr
= (PDR
*) (IPDFIRST(cur_hdr
, fh
)) + i
;
2407 parse_procedure (pr
, i
< fh
->cpd
-1 ? pr
[1].adr
: bound
, 1);
2412 * This symbol table contains ordinary ecoff entries.
2419 /* How many symbols will we need */
2420 /* FIXME, this does not count enum values. */
2421 f_max
= pst
->n_global_syms
+ pst
->n_static_syms
;
2424 st
= new_symtab ("unknown", f_max
, 0, pst
->objfile
);
2426 f_max
+= fh
->csym
+ fh
->cpd
;
2427 maxlines
= 2 * fh
->cline
;
2428 st
= new_symtab (pst
->filename
, 2 * f_max
, maxlines
, pst
->objfile
);
2431 lines
= LINETABLE(st
);
2432 pending_list
= (struct mips_pending
**) cur_hdr
->cbOptOffset
;
2433 if (pending_list
== 0) {
2434 pending_list
= (struct mips_pending
**)
2435 xzalloc(cur_hdr
->ifdMax
* sizeof(struct mips_pending
*));
2436 cur_hdr
->cbOptOffset
= (int)pending_list
;
2439 /* Get a new lexical context */
2442 top_stack
->cur_st
= st
;
2443 top_stack
->cur_block
= BLOCKVECTOR_BLOCK(BLOCKVECTOR(st
),
2445 BLOCK_START(top_stack
->cur_block
) = fh
? fh
->adr
: 0;
2446 BLOCK_END(top_stack
->cur_block
) = 0;
2447 top_stack
->blocktype
= stFile
;
2448 top_stack
->maxsyms
= 2*f_max
;
2449 top_stack
->cur_type
= 0;
2450 top_stack
->procadr
= 0;
2451 top_stack
->numargs
= 0;
2457 /* Parse local symbols first */
2459 for (cur_sdx
= 0; cur_sdx
< fh
->csym
; ) {
2460 sh
= (SYMR
*) (fh
->isymBase
) + cur_sdx
;
2461 cur_sdx
+= parse_symbol(sh
, (union aux_ent
*)fh
->iauxBase
,
2465 /* Linenumbers. At the end, check if we can save memory */
2467 parse_lines(fh
, lines
);
2468 if (lines
->nitems
< fh
->cline
)
2469 lines
= shrink_linetable(lines
);
2471 /* Fill in procedure info next. We need to look-ahead to
2472 find out where each procedure's code ends. */
2474 for (i
= 0; i
<= fh
->cpd
-1; i
++) {
2475 pr
= (PDR
*) (IPDFIRST(cur_hdr
, fh
)) + i
;
2476 parse_procedure(pr
, i
< fh
->cpd
-1 ? pr
[1].adr
: bound
, 0);
2480 LINETABLE(st
) = lines
;
2482 /* .. and our share of externals.
2483 XXX use the global list to speed up things here. how?
2484 FIXME, Maybe quit once we have found the right number of ext's? */
2485 top_stack
->cur_st
= st
;
2486 top_stack
->cur_block
= BLOCKVECTOR_BLOCK(BLOCKVECTOR(top_stack
->cur_st
),
2488 top_stack
->blocktype
= stFile
;
2489 top_stack
->maxsyms
=
2490 cur_hdr
->isymMax
+ cur_hdr
->ipdMax
+ cur_hdr
->iextMax
;
2492 ext_ptr
= PST_PRIVATE(pst
)->extern_tab
;
2493 for (i
= PST_PRIVATE(pst
)->extern_count
; --i
>= 0; ext_ptr
++)
2494 parse_external(*ext_ptr
, 1, fh
->fBigendian
);
2496 /* If there are undefined, tell the user */
2497 if (n_undef_symbols
) {
2498 printf_filtered("File %s contains %d unresolved references:",
2499 st
->filename
, n_undef_symbols
);
2500 printf_filtered("\n\t%4d variables\n\t%4d procedures\n\t%4d labels\n",
2501 n_undef_vars
, n_undef_procs
, n_undef_labels
);
2502 n_undef_symbols
= n_undef_labels
= n_undef_vars
= n_undef_procs
= 0;
2507 /* Sort the symbol table now, we are done adding symbols to it.*/
2508 sort_symtab_syms(st
);
2513 /* Now link the psymtab and the symtab. */
2516 current_objfile
= NULL
;
2519 /* Ancillary parsing procedures. */
2521 /* Lookup the type at relative index RN. Return it in TPP
2522 if found and in any event come up with its name PNAME.
2523 BIGEND says whether aux symbols are big-endian or not (from fh->fBigendian).
2524 Return value says how many aux symbols we ate. */
2527 cross_ref(ax
, tpp
, type_code
, pname
, bigend
)
2530 enum type_code type_code
; /* Use to alloc new type if none is found. */
2538 ecoff_swap_rndx_in (bigend
, ax
, rn
);
2540 /* Escape index means 'the next one' */
2541 if (rn
->rfd
== 0xfff) {
2543 rf
= AUX_GET_ISYM (bigend
, ax
+ 1);
2550 *pname
= "<undefined>";
2553 * Find the relative file descriptor and the symbol in it
2555 FDR
*fh
= get_rfd(cur_fd
, rf
);
2560 * If we have processed this symbol then we left a forwarding
2561 * pointer to the corresponding GDB symbol. If not, we`ll put
2562 * it in a list of pending symbols, to be processed later when
2563 * the file f will be. In any event, we collect the name for
2564 * the type here. Which is why we made a first pass at
2567 sh
= (SYMR
*) (fh
->isymBase
) + rn
->index
;
2569 /* Careful, we might be looking at .o files */
2570 *pname
= (UNSAFE_DATA_ADDR(sh
->iss
)) ? "<undefined>" :
2573 /* Have we parsed it ? */
2574 if ((!UNSAFE_DATA_ADDR(sh
->value
)) && (sh
->st
== stParsed
)) {
2575 t
= (struct type
*) sh
->value
;
2578 /* Avoid duplicates */
2579 struct mips_pending
*p
= is_pending_symbol(fh
, sh
);
2583 *tpp
= init_type(type_code
, 0, 0, 0, (struct objfile
*) NULL
);
2584 add_pending(fh
, sh
, *tpp
);
2589 /* We used one auxent normally, two if we got a "next one" rf. */
2594 /* Quick&dirty lookup procedure, to avoid the MI ones that require
2595 keeping the symtab sorted */
2597 static struct symbol
*
2598 mylookup_symbol (name
, block
, namespace, class)
2600 register struct block
*block
;
2601 enum namespace namespace;
2602 enum address_class
class;
2604 register int bot
, top
, inc
;
2605 register struct symbol
*sym
;
2608 top
= BLOCK_NSYMS(block
);
2611 sym
= BLOCK_SYM(block
, bot
);
2612 if (SYMBOL_NAME(sym
)[0] == inc
2613 && SYMBOL_NAMESPACE(sym
) == namespace
2614 && SYMBOL_CLASS(sym
) == class
2615 && !strcmp(SYMBOL_NAME(sym
), name
))
2619 block
= BLOCK_SUPERBLOCK (block
);
2621 return mylookup_symbol (name
, block
, namespace, class);
2626 /* Add a new symbol S to a block B.
2627 Infrequently, we will need to reallocate the block to make it bigger.
2628 We only detect this case when adding to top_stack->cur_block, since
2629 that's the only time we know how big the block is. FIXME. */
2636 int nsyms
= BLOCK_NSYMS(b
)++;
2637 struct block
*origb
;
2638 struct parse_stack
*stackp
;
2640 if (b
== top_stack
->cur_block
&&
2641 nsyms
>= top_stack
->maxsyms
) {
2642 complain (&block_overflow_complaint
, s
->name
);
2643 /* In this case shrink_block is actually grow_block, since
2644 BLOCK_NSYMS(b) is larger than its current size. */
2646 b
= shrink_block (top_stack
->cur_block
, top_stack
->cur_st
);
2648 /* Now run through the stack replacing pointers to the
2649 original block. shrink_block has already done this
2650 for the blockvector and BLOCK_FUNCTION. */
2651 for (stackp
= top_stack
; stackp
; stackp
= stackp
->next
) {
2652 if (stackp
->cur_block
== origb
) {
2653 stackp
->cur_block
= b
;
2654 stackp
->maxsyms
= BLOCK_NSYMS (b
);
2658 BLOCK_SYM(b
,nsyms
) = s
;
2661 /* Add a new block B to a symtab S */
2668 struct blockvector
*bv
= BLOCKVECTOR(s
);
2670 bv
= (struct blockvector
*)xrealloc((PTR
) bv
,
2671 sizeof(struct blockvector
) +
2672 BLOCKVECTOR_NBLOCKS(bv
)
2673 * sizeof(bv
->block
));
2674 if (bv
!= BLOCKVECTOR(s
))
2675 BLOCKVECTOR(s
) = bv
;
2677 BLOCKVECTOR_BLOCK(bv
, BLOCKVECTOR_NBLOCKS(bv
)++) = b
;
2680 /* Add a new linenumber entry (LINENO,ADR) to a linevector LT.
2681 MIPS' linenumber encoding might need more than one byte
2682 to describe it, LAST is used to detect these continuation lines */
2685 add_line(lt
, lineno
, adr
, last
)
2686 struct linetable
*lt
;
2692 last
= -2; /* make sure we record first line */
2694 if (last
== lineno
) /* skip continuation lines */
2697 lt
->item
[lt
->nitems
].line
= lineno
;
2698 lt
->item
[lt
->nitems
++].pc
= adr
<< 2;
2702 /* Sorting and reordering procedures */
2704 /* Blocks with a smaller low bound should come first */
2707 compare_blocks(arg1
, arg2
)
2708 const void *arg1
, *arg2
;
2710 register int addr_diff
;
2711 struct block
**b1
= (struct block
**) arg1
;
2712 struct block
**b2
= (struct block
**) arg2
;
2714 addr_diff
= (BLOCK_START((*b1
))) - (BLOCK_START((*b2
)));
2716 return (BLOCK_END((*b1
))) - (BLOCK_END((*b2
)));
2720 /* Sort the blocks of a symtab S.
2721 Reorder the blocks in the blockvector by code-address,
2722 as required by some MI search routines */
2728 struct blockvector
*bv
= BLOCKVECTOR(s
);
2730 if (BLOCKVECTOR_NBLOCKS(bv
) <= 2) {
2732 if (BLOCK_END(BLOCKVECTOR_BLOCK(bv
,GLOBAL_BLOCK
)) == 0)
2733 BLOCK_START(BLOCKVECTOR_BLOCK(bv
,GLOBAL_BLOCK
)) = 0;
2734 if (BLOCK_END(BLOCKVECTOR_BLOCK(bv
,STATIC_BLOCK
)) == 0)
2735 BLOCK_START(BLOCKVECTOR_BLOCK(bv
,STATIC_BLOCK
)) = 0;
2739 * This is very unfortunate: normally all functions are compiled in
2740 * the order they are found, but if the file is compiled -O3 things
2741 * are very different. It would be nice to find a reliable test
2742 * to detect -O3 images in advance.
2744 if (BLOCKVECTOR_NBLOCKS(bv
) > 3)
2745 qsort(&BLOCKVECTOR_BLOCK(bv
,FIRST_LOCAL_BLOCK
),
2746 BLOCKVECTOR_NBLOCKS(bv
) - FIRST_LOCAL_BLOCK
,
2747 sizeof(struct block
*),
2751 register CORE_ADDR high
= 0;
2752 register int i
, j
= BLOCKVECTOR_NBLOCKS(bv
);
2754 for (i
= FIRST_LOCAL_BLOCK
; i
< j
; i
++)
2755 if (high
< BLOCK_END(BLOCKVECTOR_BLOCK(bv
,i
)))
2756 high
= BLOCK_END(BLOCKVECTOR_BLOCK(bv
,i
));
2757 BLOCK_END(BLOCKVECTOR_BLOCK(bv
,GLOBAL_BLOCK
)) = high
;
2760 BLOCK_START(BLOCKVECTOR_BLOCK(bv
,GLOBAL_BLOCK
)) =
2761 BLOCK_START(BLOCKVECTOR_BLOCK(bv
,FIRST_LOCAL_BLOCK
));
2763 BLOCK_START(BLOCKVECTOR_BLOCK(bv
,STATIC_BLOCK
)) =
2764 BLOCK_START(BLOCKVECTOR_BLOCK(bv
,GLOBAL_BLOCK
));
2765 BLOCK_END (BLOCKVECTOR_BLOCK(bv
,STATIC_BLOCK
)) =
2766 BLOCK_END (BLOCKVECTOR_BLOCK(bv
,GLOBAL_BLOCK
));
2770 /* Constructor/restructor/destructor procedures */
2772 /* Allocate a new symtab for NAME. Needs an estimate of how many symbols
2773 MAXSYMS and linenumbers MAXLINES we'll put in it */
2775 static struct symtab
*
2776 new_symtab(name
, maxsyms
, maxlines
, objfile
)
2780 struct objfile
*objfile
;
2782 struct symtab
*s
= allocate_symtab (name
, objfile
);
2784 LINETABLE(s
) = new_linetable(maxlines
);
2786 /* All symtabs must have at least two blocks */
2787 BLOCKVECTOR(s
) = new_bvect(2);
2788 BLOCKVECTOR_BLOCK(BLOCKVECTOR(s
), GLOBAL_BLOCK
) = new_block(maxsyms
);
2789 BLOCKVECTOR_BLOCK(BLOCKVECTOR(s
), STATIC_BLOCK
) = new_block(maxsyms
);
2790 BLOCK_SUPERBLOCK( BLOCKVECTOR_BLOCK(BLOCKVECTOR(s
),STATIC_BLOCK
)) =
2791 BLOCKVECTOR_BLOCK(BLOCKVECTOR(s
), GLOBAL_BLOCK
);
2793 s
->free_code
= free_linetable
;
2798 /* Allocate a new partial_symtab NAME */
2800 static struct partial_symtab
*
2801 new_psymtab(name
, objfile
)
2803 struct objfile
*objfile
;
2805 struct partial_symtab
*psymtab
;
2807 /* FIXME -- why (char *) -1 rather than NULL? */
2808 psymtab
= allocate_psymtab (name
== (char *) -1 ? "<no name>" : name
,
2811 /* Keep a backpointer to the file's symbols */
2813 psymtab
-> read_symtab_private
= (char *)
2814 obstack_alloc (&objfile
->psymbol_obstack
, sizeof (struct symloc
));
2815 CUR_HDR(psymtab
) = cur_hdr
;
2817 /* The way to turn this into a symtab is to call... */
2818 psymtab
->read_symtab
= mipscoff_psymtab_to_symtab
;
2823 /* Allocate a linetable array of the given SIZE. Since the struct
2824 already includes one item, we subtract one when calculating the
2825 proper size to allocate. */
2827 static struct linetable
*
2831 struct linetable
*l
;
2833 size
= (size
-1) * sizeof(l
->item
) + sizeof(struct linetable
);
2834 l
= (struct linetable
*)xmalloc(size
);
2839 /* Oops, too big. Shrink it. This was important with the 2.4 linetables,
2840 I am not so sure about the 3.4 ones.
2842 Since the struct linetable already includes one item, we subtract one when
2843 calculating the proper size to allocate. */
2845 static struct linetable
*
2846 shrink_linetable(lt
)
2847 struct linetable
* lt
;
2850 return (struct linetable
*) xrealloc ((PTR
)lt
,
2851 sizeof(struct linetable
)
2852 + (lt
->nitems
- 1) * sizeof(lt
->item
));
2855 /* Allocate and zero a new blockvector of NBLOCKS blocks. */
2857 static struct blockvector
*
2861 struct blockvector
*bv
;
2864 size
= sizeof(struct blockvector
) + nblocks
* sizeof(struct block
*);
2865 bv
= (struct blockvector
*) xzalloc(size
);
2867 BLOCKVECTOR_NBLOCKS(bv
) = nblocks
;
2872 /* Allocate and zero a new block of MAXSYMS symbols */
2874 static struct block
*
2878 int size
= sizeof(struct block
) + (maxsyms
-1) * sizeof(struct symbol
*);
2880 return (struct block
*)xzalloc (size
);
2883 /* Ooops, too big. Shrink block B in symtab S to its minimal size.
2884 Shrink_block can also be used by add_symbol to grow a block. */
2886 static struct block
*
2892 struct blockvector
*bv
= BLOCKVECTOR(s
);
2895 /* Just reallocate it and fix references to the old one */
2897 new = (struct block
*) xrealloc ((PTR
)b
, sizeof(struct block
) +
2898 (BLOCK_NSYMS(b
)-1) * sizeof(struct symbol
*));
2900 /* Should chase pointers to old one. Fortunately, that`s just
2901 the block`s function and inferior blocks */
2902 if (BLOCK_FUNCTION(new) && SYMBOL_BLOCK_VALUE(BLOCK_FUNCTION(new)) == b
)
2903 SYMBOL_BLOCK_VALUE(BLOCK_FUNCTION(new)) = new;
2904 for (i
= 0; i
< BLOCKVECTOR_NBLOCKS(bv
); i
++)
2905 if (BLOCKVECTOR_BLOCK(bv
,i
) == b
)
2906 BLOCKVECTOR_BLOCK(bv
,i
) = new;
2907 else if (BLOCK_SUPERBLOCK(BLOCKVECTOR_BLOCK(bv
,i
)) == b
)
2908 BLOCK_SUPERBLOCK(BLOCKVECTOR_BLOCK(bv
,i
)) = new;
2912 /* Create a new symbol with printname NAME */
2914 static struct symbol
*
2918 struct symbol
*s
= (struct symbol
*)
2919 obstack_alloc (¤t_objfile
->symbol_obstack
, sizeof (struct symbol
));
2921 memset ((PTR
)s
, 0, sizeof (*s
));
2922 SYMBOL_NAME(s
) = name
;
2926 /* Create a new type with printname NAME */
2928 static struct type
*
2934 t
= alloc_type (current_objfile
);
2935 TYPE_NAME(t
) = name
;
2936 TYPE_CPLUS_SPECIFIC(t
) = (struct cplus_struct_type
*)
2937 &cplus_struct_default
;
2942 /* Things used for calling functions in the inferior.
2943 These functions are exported to our companion
2944 mips-tdep.c file and are here because they play
2945 with the symbol-table explicitly. */
2947 /* Sigtramp: make sure we have all the necessary information
2948 about the signal trampoline code. Since the official code
2949 from MIPS does not do so, we make up that information ourselves.
2950 If they fix the library (unlikely) this code will neutralize itself. */
2957 struct block
*b
, *b0
;
2959 sigtramp_address
= -1;
2961 /* We know it is sold as sigvec */
2962 s
= lookup_symbol("sigvec", 0, VAR_NAMESPACE
, 0, NULL
);
2964 /* Most programs do not play with signals */
2966 s
= lookup_symbol("_sigtramp", 0, VAR_NAMESPACE
, 0, NULL
);
2969 b0
= SYMBOL_BLOCK_VALUE(s
);
2971 /* A label of sigvec, to be more precise */
2972 s
= lookup_symbol("sigtramp", b0
, VAR_NAMESPACE
, 0, NULL
);
2975 /* But maybe this program uses its own version of sigvec */
2979 /* Did we or MIPSco fix the library ? */
2980 if (SYMBOL_CLASS(s
) == LOC_BLOCK
)
2982 sigtramp_address
= BLOCK_START(SYMBOL_BLOCK_VALUE(s
));
2983 sigtramp_end
= BLOCK_END(SYMBOL_BLOCK_VALUE(s
));
2987 sigtramp_address
= SYMBOL_VALUE(s
);
2988 sigtramp_end
= sigtramp_address
+ 0x88; /* black magic */
2990 /* But what symtab does it live in ? */
2991 st
= find_pc_symtab(SYMBOL_VALUE(s
));
2994 * Ok, there goes the fix: turn it into a procedure, with all the
2995 * needed info. Note we make it a nested procedure of sigvec,
2996 * which is the way the (assembly) code is actually written.
2998 SYMBOL_NAMESPACE(s
) = VAR_NAMESPACE
;
2999 SYMBOL_CLASS(s
) = LOC_BLOCK
;
3000 SYMBOL_TYPE(s
) = init_type(TYPE_CODE_FUNC
, 4, 0, 0, (struct objfile
*) NULL
);
3001 TYPE_TARGET_TYPE(SYMBOL_TYPE(s
)) = builtin_type_void
;
3003 /* Need a block to allocate .gdbinfo. in */
3005 SYMBOL_BLOCK_VALUE(s
) = b
;
3006 BLOCK_START(b
) = sigtramp_address
;
3007 BLOCK_END(b
) = sigtramp_end
;
3008 BLOCK_FUNCTION(b
) = s
;
3009 BLOCK_SUPERBLOCK(b
) = BLOCK_SUPERBLOCK(b0
);
3013 /* Make a .gdbinfo. for it */
3015 struct mips_extra_func_info
*e
=
3016 (struct mips_extra_func_info
*)
3017 xzalloc(sizeof(struct mips_extra_func_info
));
3019 e
->numargs
= 0; /* the kernel thinks otherwise */
3020 /* align_longword(sigcontext + SIGFRAME) */
3021 e
->pdr
.frameoffset
= 0x150;
3022 e
->pdr
.framereg
= SP_REGNUM
;
3024 e
->pdr
.regmask
= -2;
3025 e
->pdr
.regoffset
= -(41 * sizeof(int));
3026 e
->pdr
.fregmask
= -1;
3027 e
->pdr
.fregoffset
= -(37 * sizeof(int));
3028 e
->pdr
.isym
= (long)s
;
3030 current_objfile
= st
->objfile
; /* Keep new_symbol happy */
3031 s
= new_symbol(".gdbinfo.");
3032 SYMBOL_VALUE(s
) = (int) e
;
3033 SYMBOL_NAMESPACE(s
) = LABEL_NAMESPACE
;
3034 SYMBOL_CLASS(s
) = LOC_CONST
;
3035 SYMBOL_TYPE(s
) = builtin_type_void
;
3036 current_objfile
= NULL
;
3039 BLOCK_SYM(b
,BLOCK_NSYMS(b
)++) = s
;
3042 /* Initialization */
3044 static struct sym_fns ecoff_sym_fns
=
3046 "ecoff", /* sym_name: name or name prefix of BFD target type */
3047 5, /* sym_namelen: number of significant sym_name chars */
3048 mipscoff_new_init
, /* sym_new_init: init anything gbl to entire symtab */
3049 mipscoff_symfile_init
,/* sym_init: read initial info, setup for sym_read() */
3050 mipscoff_symfile_read
,/* sym_read: read a symbol file into symtab */
3051 mipscoff_symfile_finish
,/* sym_finish: finished with file, cleanup */
3052 NULL
/* next: pointer to next struct sym_fns */
3057 _initialize_mipsread ()
3059 add_symtab_fns (&ecoff_sym_fns
);
3061 /* Missing basic types */
3063 builtin_type_string
=
3064 init_type(TYPE_CODE_PASCAL_ARRAY
,
3065 TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
3067 (struct objfile
*) NULL
);
3068 builtin_type_complex
=
3069 init_type(TYPE_CODE_FLT
,
3070 TARGET_COMPLEX_BIT
/ TARGET_CHAR_BIT
,
3072 (struct objfile
*) NULL
);
3073 builtin_type_double_complex
=
3074 init_type(TYPE_CODE_FLT
,
3075 TARGET_DOUBLE_COMPLEX_BIT
/ TARGET_CHAR_BIT
,
3076 0, "double complex",
3077 (struct objfile
*) NULL
);
3078 builtin_type_fixed_dec
=
3079 init_type(TYPE_CODE_INT
,
3080 TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
3082 (struct objfile
*) NULL
);
3083 builtin_type_float_dec
=
3084 init_type(TYPE_CODE_FLT
,
3085 TARGET_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
3086 0, "floating decimal",
3087 (struct objfile
*) NULL
);