1 /* Read a symbol table in ECOFF format (Third-Eye).
2 Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
3 1997, 1998, 1999, 2000, 2001
4 Free Software Foundation, Inc.
5 Original version contributed by Alessandro Forin (af@cs.cmu.edu) at
6 CMU. Major work by Per Bothner, John Gilmore and Ian Lance Taylor
9 This file is part of GDB.
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA. */
26 /* This module provides the function mdebug_build_psymtabs. It reads
27 ECOFF debugging information into partial symbol tables. The
28 debugging information is read from two structures. A struct
29 ecoff_debug_swap includes the sizes of each ECOFF structure and
30 swapping routines; these are fixed for a particular target. A
31 struct ecoff_debug_info points to the debugging information for a
32 particular object file.
34 ECOFF symbol tables are mostly written in the byte order of the
35 target machine. However, one section of the table (the auxiliary
36 symbol information) is written in the host byte order. There is a
37 bit in the other symbol info which describes which host byte order
38 was used. ECOFF thereby takes the trophy from Intel `b.out' for
39 the most brain-dead adaptation of a file format to byte order.
41 This module can read all four of the known byte-order combinations,
42 on any type of host. */
52 #include "stabsread.h"
53 #include "complaints.h"
56 /* These are needed if the tm.h file does not contain the necessary
57 mips specific definitions. */
59 #ifndef MIPS_EFI_SYMBOL_NAME
60 #define MIPS_EFI_SYMBOL_NAME "__GDB_EFI_INFO__"
61 extern void ecoff_relocate_efi (struct symbol
*, CORE_ADDR
);
63 #include "coff/symconst.h"
64 typedef struct mips_extra_func_info
69 *mips_extra_func_info_t
;
76 #include <sys/types.h>
80 #include "gdb_string.h"
84 #include "coff/ecoff.h" /* COFF-like aspects of ecoff files */
86 #include "libaout.h" /* Private BFD a.out information. */
87 #include "aout/aout64.h"
88 #include "aout/stab_gnu.h" /* STABS information */
90 #include "expression.h"
91 #include "language.h" /* Needed inside partial-stab.h */
93 extern void _initialize_mdebugread (void);
95 /* Provide a way to test if we have both ECOFF and ELF symbol tables.
96 We use this define in order to know whether we should override a
97 symbol's ECOFF section with its ELF section. This is necessary in
98 case the symbol's ELF section could not be represented in ECOFF. */
99 #define ECOFF_IN_ELF(bfd) (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
100 && bfd_get_section_by_name (bfd, ".mdebug") != NULL)
103 /* We put a pointer to this structure in the read_symtab_private field
108 /* Our running best guess as to the range of text addresses for
109 this psymtab. After we've read everything in, we use this to
110 build pst->text_addrs. */
111 CORE_ADDR textlow
, texthigh
;
113 /* Index of the FDR that this psymtab represents. */
115 /* The BFD that the psymtab was created from. */
117 const struct ecoff_debug_swap
*debug_swap
;
118 struct ecoff_debug_info
*debug_info
;
119 struct mdebug_pending
**pending_list
;
120 /* Pointer to external symbols for this file. */
122 /* Size of extern_tab. */
124 enum language pst_language
;
127 #define PST_PRIVATE(p) ((struct symloc *)(p)->read_symtab_private)
128 #define TEXTLOW(p) (PST_PRIVATE(p)->textlow)
129 #define TEXTHIGH(p) (PST_PRIVATE(p)->texthigh)
130 #define FDR_IDX(p) (PST_PRIVATE(p)->fdr_idx)
131 #define CUR_BFD(p) (PST_PRIVATE(p)->cur_bfd)
132 #define DEBUG_SWAP(p) (PST_PRIVATE(p)->debug_swap)
133 #define DEBUG_INFO(p) (PST_PRIVATE(p)->debug_info)
134 #define PENDING_LIST(p) (PST_PRIVATE(p)->pending_list)
136 #define SC_IS_TEXT(sc) ((sc) == scText \
137 || (sc) == scRConst \
140 #define SC_IS_DATA(sc) ((sc) == scData \
145 #define SC_IS_COMMON(sc) ((sc) == scCommon || (sc) == scSCommon)
146 #define SC_IS_BSS(sc) ((sc) == scBss || (sc) == scSBss)
147 #define SC_IS_UNDEF(sc) ((sc) == scUndefined || (sc) == scSUndefined)
150 /* Things we import explicitly from other modules */
152 extern int info_verbose
;
154 /* Various complaints about symbol reading that don't abort the process */
156 static struct complaint bad_file_number_complaint
=
157 {"bad file number %d", 0, 0};
159 static struct complaint index_complaint
=
160 {"bad aux index at symbol %s", 0, 0};
162 static struct complaint aux_index_complaint
=
163 {"bad proc end in aux found from symbol %s", 0, 0};
165 static struct complaint block_index_complaint
=
166 {"bad aux index at block symbol %s", 0, 0};
168 static struct complaint unknown_ext_complaint
=
169 {"unknown external symbol %s", 0, 0};
171 static struct complaint unknown_sym_complaint
=
172 {"unknown local symbol %s", 0, 0};
174 static struct complaint unknown_st_complaint
=
175 {"with type %d", 0, 0};
177 static struct complaint block_overflow_complaint
=
178 {"block containing %s overfilled", 0, 0};
180 static struct complaint basic_type_complaint
=
181 {"cannot map ECOFF basic type 0x%x for %s", 0, 0};
183 static struct complaint unknown_type_qual_complaint
=
184 {"unknown type qualifier 0x%x", 0, 0};
186 static struct complaint array_index_type_complaint
=
187 {"illegal array index type for %s, assuming int", 0, 0};
189 static struct complaint bad_tag_guess_complaint
=
190 {"guessed tag type of %s incorrectly", 0, 0};
192 static struct complaint block_member_complaint
=
193 {"declaration block contains unhandled symbol type %d", 0, 0};
195 static struct complaint stEnd_complaint
=
196 {"stEnd with storage class %d not handled", 0, 0};
198 static struct complaint unknown_mdebug_symtype_complaint
=
199 {"unknown symbol type 0x%x", 0, 0};
201 static struct complaint stab_unknown_complaint
=
202 {"unknown stabs symbol %s", 0, 0};
204 static struct complaint pdr_for_nonsymbol_complaint
=
205 {"PDR for %s, but no symbol", 0, 0};
207 static struct complaint pdr_static_symbol_complaint
=
208 {"can't handle PDR for static proc at 0x%lx", 0, 0};
210 static struct complaint bad_setjmp_pdr_complaint
=
211 {"fixing bad setjmp PDR from libc", 0, 0};
213 static struct complaint bad_fbitfield_complaint
=
214 {"can't handle TIR fBitfield for %s", 0, 0};
216 static struct complaint bad_continued_complaint
=
217 {"illegal TIR continued for %s", 0, 0};
219 static struct complaint bad_rfd_entry_complaint
=
220 {"bad rfd entry for %s: file %d, index %d", 0, 0};
222 static struct complaint unexpected_type_code_complaint
=
223 {"unexpected type code for %s", 0, 0};
225 static struct complaint unable_to_cross_ref_complaint
=
226 {"unable to cross ref btTypedef for %s", 0, 0};
228 static struct complaint bad_indirect_xref_complaint
=
229 {"unable to cross ref btIndirect for %s", 0, 0};
231 static struct complaint illegal_forward_tq0_complaint
=
232 {"illegal tq0 in forward typedef for %s", 0, 0};
234 static struct complaint illegal_forward_bt_complaint
=
235 {"illegal bt %d in forward typedef for %s", 0, 0};
237 static struct complaint bad_linetable_guess_complaint
=
238 {"guessed size of linetable for %s incorrectly", 0, 0};
240 static struct complaint bad_ext_ifd_complaint
=
241 {"bad ifd for external symbol: %d (max %d)", 0, 0};
243 static struct complaint bad_ext_iss_complaint
=
244 {"bad iss for external symbol: %ld (max %ld)", 0, 0};
246 /* Macros and extra defs */
248 /* Puns: hard to find whether -g was used and how */
250 #define MIN_GLEVEL GLEVEL_0
251 #define compare_glevel(a,b) \
252 (((a) == GLEVEL_3) ? ((b) < GLEVEL_3) : \
253 ((b) == GLEVEL_3) ? -1 : (int)((b) - (a)))
255 /* Things that really are local to this module */
257 /* Remember what we deduced to be the source language of this psymtab. */
259 static enum language psymtab_language
= language_unknown
;
265 /* How to parse debugging information for CUR_BFD. */
267 static const struct ecoff_debug_swap
*debug_swap
;
269 /* Pointers to debugging information for CUR_BFD. */
271 static struct ecoff_debug_info
*debug_info
;
273 /* Pointer to current file decriptor record, and its index */
278 /* Index of current symbol */
282 /* Note how much "debuggable" this image is. We would like
283 to see at least one FDR with full symbols */
285 static int max_gdbinfo
;
286 static int max_glevel
;
288 /* When examining .o files, report on undefined symbols */
290 static int n_undef_symbols
, n_undef_labels
, n_undef_vars
, n_undef_procs
;
292 /* Pseudo symbol to use when putting stabs into the symbol table. */
294 static char stabs_symbol
[] = STABS_SYMBOL
;
296 /* Types corresponding to mdebug format bt* basic types. */
298 static struct type
*mdebug_type_void
;
299 static struct type
*mdebug_type_char
;
300 static struct type
*mdebug_type_short
;
301 static struct type
*mdebug_type_int_32
;
302 #define mdebug_type_int mdebug_type_int_32
303 static struct type
*mdebug_type_int_64
;
304 static struct type
*mdebug_type_long_32
;
305 static struct type
*mdebug_type_long_64
;
306 static struct type
*mdebug_type_long_long_64
;
307 static struct type
*mdebug_type_unsigned_char
;
308 static struct type
*mdebug_type_unsigned_short
;
309 static struct type
*mdebug_type_unsigned_int_32
;
310 static struct type
*mdebug_type_unsigned_int_64
;
311 static struct type
*mdebug_type_unsigned_long_32
;
312 static struct type
*mdebug_type_unsigned_long_64
;
313 static struct type
*mdebug_type_unsigned_long_long_64
;
314 static struct type
*mdebug_type_adr_32
;
315 static struct type
*mdebug_type_adr_64
;
316 static struct type
*mdebug_type_float
;
317 static struct type
*mdebug_type_double
;
318 static struct type
*mdebug_type_complex
;
319 static struct type
*mdebug_type_double_complex
;
320 static struct type
*mdebug_type_fixed_dec
;
321 static struct type
*mdebug_type_float_dec
;
322 static struct type
*mdebug_type_string
;
324 /* Types for symbols from files compiled without debugging info. */
326 static struct type
*nodebug_func_symbol_type
;
327 static struct type
*nodebug_var_symbol_type
;
329 /* Nonzero if we have seen ecoff debugging info for a file. */
331 static int found_ecoff_debugging_info
;
333 /* Forward declarations */
335 static void add_pending (FDR
*, char *, struct type
*);
337 static struct mdebug_pending
*is_pending_symbol (FDR
*, char *);
339 static void pop_parse_stack (void);
341 static void push_parse_stack (void);
343 static char *fdr_name (FDR
*);
345 static void mdebug_psymtab_to_symtab (struct partial_symtab
*);
348 upgrade_type (int, struct type
**, int, union aux_ext
*, int, char *);
350 static void parse_partial_symbols (struct objfile
*);
352 static FDR
* get_rfd (int, int);
354 static int has_opaque_xref (FDR
*, SYMR
*);
357 cross_ref (int, union aux_ext
*, struct type
**, enum type_code
,
358 char **, int, char *);
360 static struct symbol
*new_symbol (char *);
362 static struct type
*new_type (char *);
364 static struct block
*new_block (int);
366 static struct symtab
*new_symtab (char *, int, int, struct objfile
*);
368 static struct linetable
*new_linetable (int);
370 static struct blockvector
*new_bvect (int);
373 parse_symbol (SYMR
*, union aux_ext
*, char *, int, struct section_offsets
*,
376 static struct type
*parse_type (int, union aux_ext
*, unsigned int, int *,
379 static struct symbol
*mylookup_symbol (char *, struct block
*, namespace_enum
,
382 static struct block
*shrink_block (struct block
*, struct symtab
*);
384 static PTR
xzalloc (unsigned int);
386 static void sort_blocks (struct symtab
*);
388 static int compare_blocks (const PTR
, const PTR
);
390 static struct partial_symtab
*new_psymtab (char *, struct objfile
*);
392 static void psymtab_to_symtab_1 (struct partial_symtab
*, char *);
394 static void add_block (struct block
*, struct symtab
*);
396 static void add_symbol (struct symbol
*, struct block
*);
398 static int add_line (struct linetable
*, int, CORE_ADDR
, int);
400 static struct linetable
*shrink_linetable (struct linetable
*);
403 handle_psymbol_enumerators (struct objfile
*, FDR
*, int, CORE_ADDR
);
405 static char *mdebug_next_symbol_text (struct objfile
*);
407 /* Address bounds for the signal trampoline in inferior, if any */
409 CORE_ADDR sigtramp_address
, sigtramp_end
;
411 /* Allocate zeroed memory */
414 xzalloc (unsigned int size
)
416 PTR p
= xmalloc (size
);
422 /* Exported procedure: Builds a symtab from the PST partial one.
423 Restores the environment in effect when PST was created, delegates
424 most of the work to an ancillary procedure, and sorts
425 and reorders the symtab list at the end */
428 mdebug_psymtab_to_symtab (struct partial_symtab
*pst
)
436 printf_filtered ("Reading in symbols for %s...", pst
->filename
);
437 gdb_flush (gdb_stdout
);
440 next_symbol_text_func
= mdebug_next_symbol_text
;
442 psymtab_to_symtab_1 (pst
, pst
->filename
);
444 /* Match with global symbols. This only needs to be done once,
445 after all of the symtabs and dependencies have been read in. */
446 scan_file_globals (pst
->objfile
);
449 printf_filtered ("done.\n");
452 /* File-level interface functions */
454 /* Find a file descriptor given its index RF relative to a file CF */
457 get_rfd (int cf
, int rf
)
463 fdrs
= debug_info
->fdr
;
465 /* Object files do not have the RFD table, all refs are absolute */
468 (*debug_swap
->swap_rfd_in
) (cur_bfd
,
469 ((char *) debug_info
->external_rfd
471 * debug_swap
->external_rfd_size
)),
476 /* Return a safer print NAME for a file descriptor */
482 return "<stripped file>";
485 return debug_info
->ss
+ f
->issBase
+ f
->rss
;
489 /* Read in and parse the symtab of the file OBJFILE. Symbols from
490 different sections are relocated via the SECTION_OFFSETS. */
493 mdebug_build_psymtabs (struct objfile
*objfile
,
494 const struct ecoff_debug_swap
*swap
,
495 struct ecoff_debug_info
*info
)
497 cur_bfd
= objfile
->obfd
;
501 stabsread_new_init ();
502 buildsym_new_init ();
503 free_header_files ();
504 init_header_files ();
506 /* Make sure all the FDR information is swapped in. */
507 if (info
->fdr
== (FDR
*) NULL
)
513 info
->fdr
= (FDR
*) obstack_alloc (&objfile
->psymbol_obstack
,
514 (info
->symbolic_header
.ifdMax
516 fdr_src
= info
->external_fdr
;
518 + info
->symbolic_header
.ifdMax
* swap
->external_fdr_size
);
520 for (; fdr_src
< fdr_end
; fdr_src
+= swap
->external_fdr_size
, fdr_ptr
++)
521 (*swap
->swap_fdr_in
) (objfile
->obfd
, fdr_src
, fdr_ptr
);
524 parse_partial_symbols (objfile
);
526 /* Take the text ranges the partial symbol scanner computed for each
527 of the psymtabs and convert it into the canonical form for
530 struct partial_symtab
*p
;
532 ALL_OBJFILE_PSYMTABS (objfile
, p
)
534 p
->textlow
= TEXTLOW (p
);
535 p
->texthigh
= TEXTHIGH (p
);
540 /* Check to make sure file was compiled with -g. If not, warn the
541 user of this limitation. */
542 if (compare_glevel (max_glevel
, GLEVEL_2
) < 0)
544 if (max_gdbinfo
== 0)
545 printf_unfiltered ("\n%s not compiled with -g, debugging support is limited.\n",
547 printf_unfiltered ("You should compile with -g2 or -g3 for best debugging support.\n");
548 gdb_flush (gdb_stdout
);
553 /* Local utilities */
555 /* Map of FDR indexes to partial symtabs */
559 struct partial_symtab
*pst
; /* the psymtab proper */
560 long n_globals
; /* exported globals (external symbols) */
561 long globals_offset
; /* cumulative */
565 /* Utility stack, used to nest procedures and blocks properly.
566 It is a doubly linked list, to avoid too many alloc/free.
567 Since we might need it quite a few times it is NOT deallocated
570 static struct parse_stack
572 struct parse_stack
*next
, *prev
;
573 struct symtab
*cur_st
; /* Current symtab. */
574 struct block
*cur_block
; /* Block in it. */
576 /* What are we parsing. stFile, or stBlock are for files and
577 blocks. stProc or stStaticProc means we have seen the start of a
578 procedure, but not the start of the block within in. When we see
579 the start of that block, we change it to stNil, without pushing a
580 new block, i.e. stNil means both a procedure and a block. */
584 int maxsyms
; /* Max symbols in this block. */
585 struct type
*cur_type
; /* Type we parse fields for. */
586 int cur_field
; /* Field number in cur_type. */
587 CORE_ADDR procadr
; /* Start addres of this procedure */
588 int numargs
; /* Its argument count */
591 *top_stack
; /* Top stack ptr */
594 /* Enter a new lexical context */
597 push_parse_stack (void)
599 struct parse_stack
*new;
601 /* Reuse frames if possible */
602 if (top_stack
&& top_stack
->prev
)
603 new = top_stack
->prev
;
605 new = (struct parse_stack
*) xzalloc (sizeof (struct parse_stack
));
606 /* Initialize new frame with previous content */
609 register struct parse_stack
*prev
= new->prev
;
612 top_stack
->prev
= new;
614 new->next
= top_stack
;
619 /* Exit a lexical context */
622 pop_parse_stack (void)
627 top_stack
= top_stack
->next
;
631 /* Cross-references might be to things we haven't looked at
632 yet, e.g. type references. To avoid too many type
633 duplications we keep a quick fixup table, an array
634 of lists of references indexed by file descriptor */
636 struct mdebug_pending
638 struct mdebug_pending
*next
; /* link */
639 char *s
; /* the unswapped symbol */
640 struct type
*t
; /* its partial type descriptor */
644 /* The pending information is kept for an entire object file, and used
645 to be in the sym_private field. I took it out when I split
646 mdebugread from mipsread, because this might not be the only type
647 of symbols read from an object file. Instead, we allocate the
648 pending information table when we create the partial symbols, and
649 we store a pointer to the single table in each psymtab. */
651 static struct mdebug_pending
**pending_list
;
653 /* Check whether we already saw symbol SH in file FH */
655 static struct mdebug_pending
*
656 is_pending_symbol (FDR
*fh
, char *sh
)
658 int f_idx
= fh
- debug_info
->fdr
;
659 register struct mdebug_pending
*p
;
661 /* Linear search is ok, list is typically no more than 10 deep */
662 for (p
= pending_list
[f_idx
]; p
; p
= p
->next
)
668 /* Add a new symbol SH of type T */
671 add_pending (FDR
*fh
, char *sh
, struct type
*t
)
673 int f_idx
= fh
- debug_info
->fdr
;
674 struct mdebug_pending
*p
= is_pending_symbol (fh
, sh
);
676 /* Make sure we do not make duplicates */
679 p
= ((struct mdebug_pending
*)
680 obstack_alloc (¤t_objfile
->psymbol_obstack
,
681 sizeof (struct mdebug_pending
)));
684 p
->next
= pending_list
[f_idx
];
685 pending_list
[f_idx
] = p
;
690 /* Parsing Routines proper. */
692 /* Parse a single symbol. Mostly just make up a GDB symbol for it.
693 For blocks, procedures and types we open a new lexical context.
694 This is basically just a big switch on the symbol's type. Argument
695 AX is the base pointer of aux symbols for this file (fh->iauxBase).
696 EXT_SH points to the unswapped symbol, which is needed for struct,
697 union, etc., types; it is NULL for an EXTR. BIGEND says whether
698 aux symbols are big-endian or little-endian. Return count of
699 SYMR's handled (normally one). */
702 parse_symbol (SYMR
*sh
, union aux_ext
*ax
, char *ext_sh
, int bigend
,
703 struct section_offsets
*section_offsets
, struct objfile
*objfile
)
705 const bfd_size_type external_sym_size
= debug_swap
->external_sym_size
;
706 void (*const swap_sym_in
) (bfd
*, PTR
, SYMR
*) = debug_swap
->swap_sym_in
;
710 struct mdebug_pending
*pend
;
714 enum address_class
class;
716 long svalue
= sh
->value
;
719 if (ext_sh
== (char *) NULL
)
720 name
= debug_info
->ssext
+ sh
->iss
;
722 name
= debug_info
->ss
+ cur_fdr
->issBase
+ sh
->iss
;
728 /* Do not relocate relative values.
729 The value of a stEnd symbol is the displacement from the
730 corresponding start symbol value.
731 The value of a stBlock symbol is the displacement from the
732 procedure address. */
733 if (sh
->st
!= stEnd
&& sh
->st
!= stBlock
)
734 sh
->value
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT (objfile
));
741 sh
->value
+= ANOFFSET (section_offsets
, SECT_OFF_DATA (objfile
));
745 sh
->value
+= ANOFFSET (section_offsets
, SECT_OFF_BSS (objfile
));
754 case stGlobal
: /* external symbol, goes into global block */
756 b
= BLOCKVECTOR_BLOCK (BLOCKVECTOR (top_stack
->cur_st
),
758 s
= new_symbol (name
);
759 SYMBOL_VALUE_ADDRESS (s
) = (CORE_ADDR
) sh
->value
;
762 case stStatic
: /* static data, goes into current block. */
764 b
= top_stack
->cur_block
;
765 s
= new_symbol (name
);
766 if (SC_IS_COMMON (sh
->sc
))
768 /* It is a FORTRAN common block. At least for SGI Fortran the
769 address is not in the symbol; we need to fix it later in
770 scan_file_globals. */
771 int bucket
= hashname (SYMBOL_NAME (s
));
772 SYMBOL_VALUE_CHAIN (s
) = global_sym_chain
[bucket
];
773 global_sym_chain
[bucket
] = s
;
776 SYMBOL_VALUE_ADDRESS (s
) = (CORE_ADDR
) sh
->value
;
779 case stLocal
: /* local variable, goes into current block */
780 if (sh
->sc
== scRegister
)
782 class = LOC_REGISTER
;
783 svalue
= ECOFF_REG_TO_REGNUM (svalue
);
787 b
= top_stack
->cur_block
;
788 s
= new_symbol (name
);
789 SYMBOL_VALUE (s
) = svalue
;
791 data
: /* Common code for symbols describing data */
792 SYMBOL_NAMESPACE (s
) = VAR_NAMESPACE
;
793 SYMBOL_CLASS (s
) = class;
796 /* Type could be missing if file is compiled without debugging info. */
797 if (SC_IS_UNDEF (sh
->sc
)
798 || sh
->sc
== scNil
|| sh
->index
== indexNil
)
799 SYMBOL_TYPE (s
) = nodebug_var_symbol_type
;
801 SYMBOL_TYPE (s
) = parse_type (cur_fd
, ax
, sh
->index
, 0, bigend
, name
);
802 /* Value of a data symbol is its memory address */
805 case stParam
: /* arg to procedure, goes into current block */
807 found_ecoff_debugging_info
= 1;
808 top_stack
->numargs
++;
810 /* Special GNU C++ name. */
811 if (is_cplus_marker (name
[0]) && name
[1] == 't' && name
[2] == 0)
812 name
= "this"; /* FIXME, not alloc'd in obstack */
813 s
= new_symbol (name
);
815 SYMBOL_NAMESPACE (s
) = VAR_NAMESPACE
;
819 /* Pass by value in register. */
820 SYMBOL_CLASS (s
) = LOC_REGPARM
;
821 svalue
= ECOFF_REG_TO_REGNUM (svalue
);
824 /* Pass by reference on stack. */
825 SYMBOL_CLASS (s
) = LOC_REF_ARG
;
828 /* Pass by reference in register. */
829 SYMBOL_CLASS (s
) = LOC_REGPARM_ADDR
;
830 svalue
= ECOFF_REG_TO_REGNUM (svalue
);
833 /* Pass by value on stack. */
834 SYMBOL_CLASS (s
) = LOC_ARG
;
837 SYMBOL_VALUE (s
) = svalue
;
838 SYMBOL_TYPE (s
) = parse_type (cur_fd
, ax
, sh
->index
, 0, bigend
, name
);
839 add_symbol (s
, top_stack
->cur_block
);
842 case stLabel
: /* label, goes into current block */
843 s
= new_symbol (name
);
844 SYMBOL_NAMESPACE (s
) = VAR_NAMESPACE
; /* so that it can be used */
845 SYMBOL_CLASS (s
) = LOC_LABEL
; /* but not misused */
846 SYMBOL_VALUE_ADDRESS (s
) = (CORE_ADDR
) sh
->value
;
847 SYMBOL_TYPE (s
) = mdebug_type_int
;
848 add_symbol (s
, top_stack
->cur_block
);
851 case stProc
: /* Procedure, usually goes into global block */
852 case stStaticProc
: /* Static procedure, goes into current block */
853 s
= new_symbol (name
);
854 SYMBOL_NAMESPACE (s
) = VAR_NAMESPACE
;
855 SYMBOL_CLASS (s
) = LOC_BLOCK
;
856 /* Type of the return value */
857 if (SC_IS_UNDEF (sh
->sc
) || sh
->sc
== scNil
)
861 t
= parse_type (cur_fd
, ax
, sh
->index
+ 1, 0, bigend
, name
);
862 if (STREQ (name
, "malloc") && t
->code
== TYPE_CODE_VOID
)
864 /* I don't know why, but, at least under Alpha GNU/Linux,
865 when linking against a malloc without debugging
866 symbols, its read as a function returning void---this
867 is bad because it means we cannot call functions with
868 string arguments interactively; i.e., "call
869 printf("howdy\n")" would fail with the error message
870 "program has no memory available". To avoid this, we
871 patch up the type and make it void*
872 instead. (davidm@azstarnet.com)
874 t
= make_pointer_type (t
, NULL
);
877 b
= top_stack
->cur_block
;
878 if (sh
->st
== stProc
)
880 struct blockvector
*bv
= BLOCKVECTOR (top_stack
->cur_st
);
881 /* The next test should normally be true, but provides a
882 hook for nested functions (which we don't want to make
884 if (b
== BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
))
885 b
= BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
);
886 /* Irix 5 sometimes has duplicate names for the same
887 function. We want to add such names up at the global
888 level, not as a nested function. */
889 else if (sh
->value
== top_stack
->procadr
)
890 b
= BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
);
894 /* Make a type for the procedure itself */
895 SYMBOL_TYPE (s
) = lookup_function_type (t
);
897 /* Create and enter a new lexical context */
898 b
= new_block (top_stack
->maxsyms
);
899 SYMBOL_BLOCK_VALUE (s
) = b
;
900 BLOCK_FUNCTION (b
) = s
;
901 BLOCK_START (b
) = BLOCK_END (b
) = sh
->value
;
902 BLOCK_SUPERBLOCK (b
) = top_stack
->cur_block
;
903 add_block (b
, top_stack
->cur_st
);
905 /* Not if we only have partial info */
906 if (SC_IS_UNDEF (sh
->sc
) || sh
->sc
== scNil
)
910 top_stack
->cur_block
= b
;
911 top_stack
->blocktype
= sh
->st
;
912 top_stack
->cur_type
= SYMBOL_TYPE (s
);
913 top_stack
->cur_field
= -1;
914 top_stack
->procadr
= sh
->value
;
915 top_stack
->numargs
= 0;
918 /* Beginning of code for structure, union, and enum definitions.
919 They all share a common set of local variables, defined here. */
921 enum type_code type_code
;
927 case stStruct
: /* Start a block defining a struct type */
928 type_code
= TYPE_CODE_STRUCT
;
929 goto structured_common
;
931 case stUnion
: /* Start a block defining a union type */
932 type_code
= TYPE_CODE_UNION
;
933 goto structured_common
;
935 case stEnum
: /* Start a block defining an enum type */
936 type_code
= TYPE_CODE_ENUM
;
937 goto structured_common
;
939 case stBlock
: /* Either a lexical block, or some type */
940 if (sh
->sc
!= scInfo
&& !SC_IS_COMMON (sh
->sc
))
941 goto case_stBlock_code
; /* Lexical block */
943 type_code
= TYPE_CODE_UNDEF
; /* We have a type. */
945 /* Common code for handling struct, union, enum, and/or as-yet-
946 unknown-type blocks of info about structured data. `type_code'
947 has been set to the proper TYPE_CODE, if we know it. */
949 found_ecoff_debugging_info
= 1;
951 top_stack
->blocktype
= stBlock
;
953 /* First count the number of fields and the highest value. */
956 for (ext_tsym
= ext_sh
+ external_sym_size
;
958 ext_tsym
+= external_sym_size
)
962 (*swap_sym_in
) (cur_bfd
, ext_tsym
, &tsym
);
970 if (nfields
== 0 && type_code
== TYPE_CODE_UNDEF
)
972 /* If the type of the member is Nil (or Void),
973 without qualifiers, assume the tag is an
975 Alpha cc -migrate enums are recognized by a zero
976 index and a zero symbol value.
977 DU 4.0 cc enums are recognized by a member type of
978 btEnum without qualifiers and a zero symbol value. */
979 if (tsym
.index
== indexNil
980 || (tsym
.index
== 0 && sh
->value
== 0))
981 type_code
= TYPE_CODE_ENUM
;
984 (*debug_swap
->swap_tir_in
) (bigend
,
985 &ax
[tsym
.index
].a_ti
,
987 if ((tir
.bt
== btNil
|| tir
.bt
== btVoid
988 || (tir
.bt
== btEnum
&& sh
->value
== 0))
990 type_code
= TYPE_CODE_ENUM
;
994 if (tsym
.value
> max_value
)
995 max_value
= tsym
.value
;
1004 /* This is a no-op; is it trying to tell us something
1005 we should be checking? */
1006 if (tsym
.sc
== scVariant
); /*UNIMPLEMENTED */
1008 if (tsym
.index
!= 0)
1010 /* This is something like a struct within a
1011 struct. Skip over the fields of the inner
1012 struct. The -1 is because the for loop will
1013 increment ext_tsym. */
1014 ext_tsym
= ((char *) debug_info
->external_sym
1015 + ((cur_fdr
->isymBase
+ tsym
.index
- 1)
1016 * external_sym_size
));
1022 /* mips cc puts out a typedef for struct x if it is not yet
1023 defined when it encounters
1024 struct y { struct x *xp; };
1029 /* Irix5 cc puts out a stIndirect for struct x if it is not
1030 yet defined when it encounters
1031 struct y { struct x *xp; };
1036 complain (&block_member_complaint
, tsym
.st
);
1041 /* In an stBlock, there is no way to distinguish structs,
1042 unions, and enums at this point. This is a bug in the
1043 original design (that has been fixed with the recent
1044 addition of the stStruct, stUnion, and stEnum symbol
1045 types.) The way you can tell is if/when you see a variable
1046 or field of that type. In that case the variable's type
1047 (in the AUX table) says if the type is struct, union, or
1048 enum, and points back to the stBlock here. So you can
1049 patch the tag kind up later - but only if there actually is
1050 a variable or field of that type.
1052 So until we know for sure, we will guess at this point.
1054 If the first member has index==indexNil or a void type,
1055 assume we have an enumeration.
1056 Otherwise, if there is more than one member, and all
1057 the members have offset 0, assume we have a union.
1058 Otherwise, assume we have a struct.
1060 The heuristic could guess wrong in the case of of an
1061 enumeration with no members or a union with one (or zero)
1062 members, or when all except the last field of a struct have
1063 width zero. These are uncommon and/or illegal situations,
1064 and in any case guessing wrong probably doesn't matter
1067 But if we later do find out we were wrong, we fixup the tag
1068 kind. Members of an enumeration must be handled
1069 differently from struct/union fields, and that is harder to
1070 patch up, but luckily we shouldn't need to. (If there are
1071 any enumeration members, we can tell for sure it's an enum
1074 if (type_code
== TYPE_CODE_UNDEF
)
1076 if (nfields
> 1 && max_value
== 0)
1077 type_code
= TYPE_CODE_UNION
;
1079 type_code
= TYPE_CODE_STRUCT
;
1082 /* Create a new type or use the pending type. */
1083 pend
= is_pending_symbol (cur_fdr
, ext_sh
);
1084 if (pend
== (struct mdebug_pending
*) NULL
)
1086 t
= new_type (NULL
);
1087 add_pending (cur_fdr
, ext_sh
, t
);
1092 /* Do not set the tag name if it is a compiler generated tag name
1093 (.Fxx or .xxfake or empty) for unnamed struct/union/enums.
1094 Alpha cc puts out an sh->iss of zero for those. */
1095 if (sh
->iss
== 0 || name
[0] == '.' || name
[0] == '\0')
1096 TYPE_TAG_NAME (t
) = NULL
;
1098 TYPE_TAG_NAME (t
) = obconcat (¤t_objfile
->symbol_obstack
,
1101 TYPE_CODE (t
) = type_code
;
1102 TYPE_LENGTH (t
) = sh
->value
;
1103 TYPE_NFIELDS (t
) = nfields
;
1104 TYPE_FIELDS (t
) = f
= ((struct field
*)
1106 nfields
* sizeof (struct field
)));
1108 if (type_code
== TYPE_CODE_ENUM
)
1110 int unsigned_enum
= 1;
1112 /* This is a non-empty enum. */
1114 /* DEC c89 has the number of enumerators in the sh.value field,
1115 not the type length, so we have to compensate for that
1116 incompatibility quirk.
1117 This might do the wrong thing for an enum with one or two
1118 enumerators and gcc -gcoff -fshort-enums, but these cases
1119 are hopefully rare enough.
1120 Alpha cc -migrate has a sh.value field of zero, we adjust
1122 if (TYPE_LENGTH (t
) == TYPE_NFIELDS (t
)
1123 || TYPE_LENGTH (t
) == 0)
1124 TYPE_LENGTH (t
) = TARGET_INT_BIT
/ HOST_CHAR_BIT
;
1125 for (ext_tsym
= ext_sh
+ external_sym_size
;
1127 ext_tsym
+= external_sym_size
)
1130 struct symbol
*enum_sym
;
1132 (*swap_sym_in
) (cur_bfd
, ext_tsym
, &tsym
);
1134 if (tsym
.st
!= stMember
)
1137 FIELD_BITPOS (*f
) = tsym
.value
;
1138 FIELD_TYPE (*f
) = t
;
1139 FIELD_NAME (*f
) = debug_info
->ss
+ cur_fdr
->issBase
+ tsym
.iss
;
1140 FIELD_BITSIZE (*f
) = 0;
1142 enum_sym
= ((struct symbol
*)
1143 obstack_alloc (¤t_objfile
->symbol_obstack
,
1144 sizeof (struct symbol
)));
1145 memset ((PTR
) enum_sym
, 0, sizeof (struct symbol
));
1146 SYMBOL_NAME (enum_sym
) =
1147 obsavestring (f
->name
, strlen (f
->name
),
1148 ¤t_objfile
->symbol_obstack
);
1149 SYMBOL_CLASS (enum_sym
) = LOC_CONST
;
1150 SYMBOL_TYPE (enum_sym
) = t
;
1151 SYMBOL_NAMESPACE (enum_sym
) = VAR_NAMESPACE
;
1152 SYMBOL_VALUE (enum_sym
) = tsym
.value
;
1153 if (SYMBOL_VALUE (enum_sym
) < 0)
1155 add_symbol (enum_sym
, top_stack
->cur_block
);
1157 /* Skip the stMembers that we've handled. */
1162 TYPE_FLAGS (t
) |= TYPE_FLAG_UNSIGNED
;
1164 /* make this the current type */
1165 top_stack
->cur_type
= t
;
1166 top_stack
->cur_field
= 0;
1168 /* Do not create a symbol for alpha cc unnamed structs. */
1172 /* gcc puts out an empty struct for an opaque struct definitions,
1173 do not create a symbol for it either. */
1174 if (TYPE_NFIELDS (t
) == 0)
1176 TYPE_FLAGS (t
) |= TYPE_FLAG_STUB
;
1180 s
= new_symbol (name
);
1181 SYMBOL_NAMESPACE (s
) = STRUCT_NAMESPACE
;
1182 SYMBOL_CLASS (s
) = LOC_TYPEDEF
;
1183 SYMBOL_VALUE (s
) = 0;
1184 SYMBOL_TYPE (s
) = t
;
1185 add_symbol (s
, top_stack
->cur_block
);
1188 /* End of local variables shared by struct, union, enum, and
1189 block (as yet unknown struct/union/enum) processing. */
1193 found_ecoff_debugging_info
= 1;
1194 /* beginnning of (code) block. Value of symbol
1195 is the displacement from procedure start */
1196 push_parse_stack ();
1198 /* Do not start a new block if this is the outermost block of a
1199 procedure. This allows the LOC_BLOCK symbol to point to the
1200 block with the local variables, so funcname::var works. */
1201 if (top_stack
->blocktype
== stProc
1202 || top_stack
->blocktype
== stStaticProc
)
1204 top_stack
->blocktype
= stNil
;
1208 top_stack
->blocktype
= stBlock
;
1209 b
= new_block (top_stack
->maxsyms
);
1210 BLOCK_START (b
) = sh
->value
+ top_stack
->procadr
;
1211 BLOCK_SUPERBLOCK (b
) = top_stack
->cur_block
;
1212 top_stack
->cur_block
= b
;
1213 add_block (b
, top_stack
->cur_st
);
1216 case stEnd
: /* end (of anything) */
1217 if (sh
->sc
== scInfo
|| SC_IS_COMMON (sh
->sc
))
1219 /* Finished with type */
1220 top_stack
->cur_type
= 0;
1222 else if (sh
->sc
== scText
&&
1223 (top_stack
->blocktype
== stProc
||
1224 top_stack
->blocktype
== stStaticProc
))
1226 /* Finished with procedure */
1227 struct blockvector
*bv
= BLOCKVECTOR (top_stack
->cur_st
);
1228 struct mips_extra_func_info
*e
;
1230 struct type
*ftype
= top_stack
->cur_type
;
1233 BLOCK_END (top_stack
->cur_block
) += sh
->value
; /* size */
1235 /* Make up special symbol to contain procedure specific info */
1236 s
= new_symbol (MIPS_EFI_SYMBOL_NAME
);
1237 SYMBOL_NAMESPACE (s
) = LABEL_NAMESPACE
;
1238 SYMBOL_CLASS (s
) = LOC_CONST
;
1239 SYMBOL_TYPE (s
) = mdebug_type_void
;
1240 e
= ((struct mips_extra_func_info
*)
1241 obstack_alloc (¤t_objfile
->symbol_obstack
,
1242 sizeof (struct mips_extra_func_info
)));
1243 memset ((PTR
) e
, 0, sizeof (struct mips_extra_func_info
));
1244 SYMBOL_VALUE (s
) = (long) e
;
1245 e
->numargs
= top_stack
->numargs
;
1246 e
->pdr
.framereg
= -1;
1247 add_symbol (s
, top_stack
->cur_block
);
1249 /* Reallocate symbols, saving memory */
1250 b
= shrink_block (top_stack
->cur_block
, top_stack
->cur_st
);
1252 /* f77 emits proc-level with address bounds==[0,0],
1253 So look for such child blocks, and patch them. */
1254 for (i
= 0; i
< BLOCKVECTOR_NBLOCKS (bv
); i
++)
1256 struct block
*b_bad
= BLOCKVECTOR_BLOCK (bv
, i
);
1257 if (BLOCK_SUPERBLOCK (b_bad
) == b
1258 && BLOCK_START (b_bad
) == top_stack
->procadr
1259 && BLOCK_END (b_bad
) == top_stack
->procadr
)
1261 BLOCK_START (b_bad
) = BLOCK_START (b
);
1262 BLOCK_END (b_bad
) = BLOCK_END (b
);
1266 if (TYPE_NFIELDS (ftype
) <= 0)
1268 /* No parameter type information is recorded with the function's
1269 type. Set that from the type of the parameter symbols. */
1270 int nparams
= top_stack
->numargs
;
1276 TYPE_NFIELDS (ftype
) = nparams
;
1277 TYPE_FIELDS (ftype
) = (struct field
*)
1278 TYPE_ALLOC (ftype
, nparams
* sizeof (struct field
));
1280 for (i
= iparams
= 0; iparams
< nparams
; i
++)
1282 sym
= BLOCK_SYM (b
, i
);
1283 switch (SYMBOL_CLASS (sym
))
1288 case LOC_REGPARM_ADDR
:
1289 TYPE_FIELD_TYPE (ftype
, iparams
) = SYMBOL_TYPE (sym
);
1299 else if (sh
->sc
== scText
&& top_stack
->blocktype
== stBlock
)
1301 /* End of (code) block. The value of the symbol is the
1302 displacement from the procedure`s start address of the
1303 end of this block. */
1304 BLOCK_END (top_stack
->cur_block
) = sh
->value
+ top_stack
->procadr
;
1305 shrink_block (top_stack
->cur_block
, top_stack
->cur_st
);
1307 else if (sh
->sc
== scText
&& top_stack
->blocktype
== stNil
)
1309 /* End of outermost block. Pop parse stack and ignore. The
1310 following stEnd of stProc will take care of the block. */
1313 else if (sh
->sc
== scText
&& top_stack
->blocktype
== stFile
)
1315 /* End of file. Pop parse stack and ignore. Higher
1316 level code deals with this. */
1320 complain (&stEnd_complaint
, sh
->sc
);
1322 pop_parse_stack (); /* restore previous lexical context */
1325 case stMember
: /* member of struct or union */
1326 f
= &TYPE_FIELDS (top_stack
->cur_type
)[top_stack
->cur_field
++];
1327 FIELD_NAME (*f
) = name
;
1328 FIELD_BITPOS (*f
) = sh
->value
;
1330 FIELD_TYPE (*f
) = parse_type (cur_fd
, ax
, sh
->index
, &bitsize
, bigend
, name
);
1331 FIELD_BITSIZE (*f
) = bitsize
;
1334 case stIndirect
: /* forward declaration on Irix5 */
1335 /* Forward declarations from Irix5 cc are handled by cross_ref,
1339 case stTypedef
: /* type definition */
1340 found_ecoff_debugging_info
= 1;
1342 /* Typedefs for forward declarations and opaque structs from alpha cc
1343 are handled by cross_ref, skip them. */
1347 /* Parse the type or use the pending type. */
1348 pend
= is_pending_symbol (cur_fdr
, ext_sh
);
1349 if (pend
== (struct mdebug_pending
*) NULL
)
1351 t
= parse_type (cur_fd
, ax
, sh
->index
, (int *) NULL
, bigend
, name
);
1352 add_pending (cur_fdr
, ext_sh
, t
);
1357 /* mips cc puts out a typedef with the name of the struct for forward
1358 declarations. These should not go into the symbol table and
1359 TYPE_NAME should not be set for them.
1360 They can't be distinguished from an intentional typedef to
1361 the same name however:
1363 struct x { int ix; int jx; };
1367 struct xx {int ixx; int jxx; };
1368 generates a cross referencing stTypedef for x and xx.
1369 The user visible effect of this is that the type of a pointer
1370 to struct foo sometimes is given as `foo *' instead of `struct foo *'.
1371 The problem is fixed with alpha cc and Irix5 cc. */
1373 /* However if the typedef cross references to an opaque aggregate, it
1374 is safe to omit it from the symbol table. */
1376 if (has_opaque_xref (cur_fdr
, sh
))
1378 s
= new_symbol (name
);
1379 SYMBOL_NAMESPACE (s
) = VAR_NAMESPACE
;
1380 SYMBOL_CLASS (s
) = LOC_TYPEDEF
;
1381 SYMBOL_BLOCK_VALUE (s
) = top_stack
->cur_block
;
1382 SYMBOL_TYPE (s
) = t
;
1383 add_symbol (s
, top_stack
->cur_block
);
1385 /* Incomplete definitions of structs should not get a name. */
1386 if (TYPE_NAME (SYMBOL_TYPE (s
)) == NULL
1387 && (TYPE_NFIELDS (SYMBOL_TYPE (s
)) != 0
1388 || (TYPE_CODE (SYMBOL_TYPE (s
)) != TYPE_CODE_STRUCT
1389 && TYPE_CODE (SYMBOL_TYPE (s
)) != TYPE_CODE_UNION
)))
1391 if (TYPE_CODE (SYMBOL_TYPE (s
)) == TYPE_CODE_PTR
1392 || TYPE_CODE (SYMBOL_TYPE (s
)) == TYPE_CODE_FUNC
)
1394 /* If we are giving a name to a type such as "pointer to
1395 foo" or "function returning foo", we better not set
1396 the TYPE_NAME. If the program contains "typedef char
1397 *caddr_t;", we don't want all variables of type char
1398 * to print as caddr_t. This is not just a
1399 consequence of GDB's type management; CC and GCC (at
1400 least through version 2.4) both output variables of
1401 either type char * or caddr_t with the type
1402 refering to the stTypedef symbol for caddr_t. If a future
1403 compiler cleans this up it GDB is not ready for it
1404 yet, but if it becomes ready we somehow need to
1405 disable this check (without breaking the PCC/GCC2.4
1410 Fortunately, this check seems not to be necessary
1411 for anything except pointers or functions. */
1414 TYPE_NAME (SYMBOL_TYPE (s
)) = SYMBOL_NAME (s
);
1418 case stFile
: /* file name */
1419 push_parse_stack ();
1420 top_stack
->blocktype
= sh
->st
;
1423 /* I`ve never seen these for C */
1425 break; /* register relocation */
1427 break; /* forwarding address */
1429 break; /* constant */
1431 complain (&unknown_mdebug_symtype_complaint
, sh
->st
);
1438 /* Parse the type information provided in the raw AX entries for
1439 the symbol SH. Return the bitfield size in BS, in case.
1440 We must byte-swap the AX entries before we use them; BIGEND says whether
1441 they are big-endian or little-endian (from fh->fBigendian). */
1443 static struct type
*
1444 parse_type (int fd
, union aux_ext
*ax
, unsigned int aux_index
, int *bs
,
1445 int bigend
, char *sym_name
)
1447 /* Null entries in this map are treated specially */
1448 static struct type
**map_bt
[] =
1450 &mdebug_type_void
, /* btNil */
1451 &mdebug_type_adr_32
, /* btAdr */
1452 &mdebug_type_char
, /* btChar */
1453 &mdebug_type_unsigned_char
, /* btUChar */
1454 &mdebug_type_short
, /* btShort */
1455 &mdebug_type_unsigned_short
, /* btUShort */
1456 &mdebug_type_int_32
, /* btInt */
1457 &mdebug_type_unsigned_int_32
, /* btUInt */
1458 &mdebug_type_long_32
, /* btLong */
1459 &mdebug_type_unsigned_long_32
, /* btULong */
1460 &mdebug_type_float
, /* btFloat */
1461 &mdebug_type_double
, /* btDouble */
1468 &mdebug_type_complex
, /* btComplex */
1469 &mdebug_type_double_complex
, /* btDComplex */
1471 &mdebug_type_fixed_dec
, /* btFixedDec */
1472 &mdebug_type_float_dec
, /* btFloatDec */
1473 &mdebug_type_string
, /* btString */
1476 &mdebug_type_void
, /* btVoid */
1477 0, /* DEC C++: Pointer to member */
1478 0, /* DEC C++: Virtual function table */
1479 0, /* DEC C++: Class (Record) */
1480 &mdebug_type_long_64
, /* btLong64 */
1481 &mdebug_type_unsigned_long_64
, /* btULong64 */
1482 &mdebug_type_long_long_64
, /* btLongLong64 */
1483 &mdebug_type_unsigned_long_long_64
, /* btULongLong64 */
1484 &mdebug_type_adr_64
, /* btAdr64 */
1485 &mdebug_type_int_64
, /* btInt64 */
1486 &mdebug_type_unsigned_int_64
, /* btUInt64 */
1490 struct type
*tp
= 0;
1491 enum type_code type_code
= TYPE_CODE_UNDEF
;
1493 /* Handle undefined types, they have indexNil. */
1494 if (aux_index
== indexNil
)
1495 return mdebug_type_int
;
1497 /* Handle corrupt aux indices. */
1498 if (aux_index
>= (debug_info
->fdr
+ fd
)->caux
)
1500 complain (&index_complaint
, sym_name
);
1501 return mdebug_type_int
;
1505 /* Use aux as a type information record, map its basic type. */
1506 (*debug_swap
->swap_tir_in
) (bigend
, &ax
->a_ti
, t
);
1507 if (t
->bt
>= (sizeof (map_bt
) / sizeof (*map_bt
)))
1509 complain (&basic_type_complaint
, t
->bt
, sym_name
);
1510 return mdebug_type_int
;
1514 tp
= *map_bt
[t
->bt
];
1519 /* Cannot use builtin types -- build our own */
1523 type_code
= TYPE_CODE_STRUCT
;
1526 type_code
= TYPE_CODE_UNION
;
1529 type_code
= TYPE_CODE_ENUM
;
1532 type_code
= TYPE_CODE_RANGE
;
1535 type_code
= TYPE_CODE_SET
;
1538 /* alpha cc -migrate uses this for typedefs. The true type will
1539 be obtained by crossreferencing below. */
1540 type_code
= TYPE_CODE_ERROR
;
1543 /* alpha cc uses this for typedefs. The true type will be
1544 obtained by crossreferencing below. */
1545 type_code
= TYPE_CODE_ERROR
;
1548 complain (&basic_type_complaint
, t
->bt
, sym_name
);
1549 return mdebug_type_int
;
1553 /* Move on to next aux */
1558 int width
= AUX_GET_WIDTH (bigend
, ax
);
1560 /* Inhibit core dumps with some cfront generated objects that
1562 if (bs
== (int *) NULL
)
1564 /* Alpha cc -migrate encodes char and unsigned char types
1565 as short and unsigned short types with a field width of 8.
1566 Enum types also have a field width which we ignore for now. */
1567 if (t
->bt
== btShort
&& width
== 8)
1568 tp
= mdebug_type_char
;
1569 else if (t
->bt
== btUShort
&& width
== 8)
1570 tp
= mdebug_type_unsigned_char
;
1571 else if (t
->bt
== btEnum
)
1574 complain (&bad_fbitfield_complaint
, sym_name
);
1581 /* A btIndirect entry cross references to an aux entry containing
1583 if (t
->bt
== btIndirect
)
1590 (*debug_swap
->swap_rndx_in
) (bigend
, &ax
->a_rndx
, rn
);
1592 if (rn
->rfd
== 0xfff)
1594 rf
= AUX_GET_ISYM (bigend
, ax
);
1602 complain (&bad_indirect_xref_complaint
, sym_name
);
1603 return mdebug_type_int
;
1605 xref_fh
= get_rfd (fd
, rf
);
1606 xref_fd
= xref_fh
- debug_info
->fdr
;
1607 tp
= parse_type (xref_fd
, debug_info
->external_aux
+ xref_fh
->iauxBase
,
1608 rn
->index
, (int *) NULL
, xref_fh
->fBigendian
, sym_name
);
1611 /* All these types really point to some (common) MIPS type
1612 definition, and only the type-qualifiers fully identify
1613 them. We'll make the same effort at sharing. */
1614 if (t
->bt
== btStruct
||
1618 /* btSet (I think) implies that the name is a tag name, not a typedef
1619 name. This apparently is a MIPS extension for C sets. */
1624 /* Try to cross reference this type, build new type on failure. */
1625 ax
+= cross_ref (fd
, ax
, &tp
, type_code
, &name
, bigend
, sym_name
);
1626 if (tp
== (struct type
*) NULL
)
1627 tp
= init_type (type_code
, 0, 0, (char *) NULL
, current_objfile
);
1629 /* DEC c89 produces cross references to qualified aggregate types,
1630 dereference them. */
1631 while (TYPE_CODE (tp
) == TYPE_CODE_PTR
1632 || TYPE_CODE (tp
) == TYPE_CODE_ARRAY
)
1633 tp
= tp
->target_type
;
1635 /* Make sure that TYPE_CODE(tp) has an expected type code.
1636 Any type may be returned from cross_ref if file indirect entries
1638 if (TYPE_CODE (tp
) != TYPE_CODE_STRUCT
1639 && TYPE_CODE (tp
) != TYPE_CODE_UNION
1640 && TYPE_CODE (tp
) != TYPE_CODE_ENUM
)
1642 complain (&unexpected_type_code_complaint
, sym_name
);
1647 /* Usually, TYPE_CODE(tp) is already type_code. The main
1648 exception is if we guessed wrong re struct/union/enum.
1649 But for struct vs. union a wrong guess is harmless, so
1650 don't complain(). */
1651 if ((TYPE_CODE (tp
) == TYPE_CODE_ENUM
1652 && type_code
!= TYPE_CODE_ENUM
)
1653 || (TYPE_CODE (tp
) != TYPE_CODE_ENUM
1654 && type_code
== TYPE_CODE_ENUM
))
1656 complain (&bad_tag_guess_complaint
, sym_name
);
1659 if (TYPE_CODE (tp
) != type_code
)
1661 TYPE_CODE (tp
) = type_code
;
1664 /* Do not set the tag name if it is a compiler generated tag name
1665 (.Fxx or .xxfake or empty) for unnamed struct/union/enums. */
1666 if (name
[0] == '.' || name
[0] == '\0')
1667 TYPE_TAG_NAME (tp
) = NULL
;
1668 else if (TYPE_TAG_NAME (tp
) == NULL
1669 || !STREQ (TYPE_TAG_NAME (tp
), name
))
1670 TYPE_TAG_NAME (tp
) = obsavestring (name
, strlen (name
),
1671 ¤t_objfile
->type_obstack
);
1675 /* All these types really point to some (common) MIPS type
1676 definition, and only the type-qualifiers fully identify
1677 them. We'll make the same effort at sharing.
1678 FIXME: We are not doing any guessing on range types. */
1679 if (t
->bt
== btRange
)
1683 /* Try to cross reference this type, build new type on failure. */
1684 ax
+= cross_ref (fd
, ax
, &tp
, type_code
, &name
, bigend
, sym_name
);
1685 if (tp
== (struct type
*) NULL
)
1686 tp
= init_type (type_code
, 0, 0, (char *) NULL
, current_objfile
);
1688 /* Make sure that TYPE_CODE(tp) has an expected type code.
1689 Any type may be returned from cross_ref if file indirect entries
1691 if (TYPE_CODE (tp
) != TYPE_CODE_RANGE
)
1693 complain (&unexpected_type_code_complaint
, sym_name
);
1697 /* Usually, TYPE_CODE(tp) is already type_code. The main
1698 exception is if we guessed wrong re struct/union/enum. */
1699 if (TYPE_CODE (tp
) != type_code
)
1701 complain (&bad_tag_guess_complaint
, sym_name
);
1702 TYPE_CODE (tp
) = type_code
;
1704 if (TYPE_NAME (tp
) == NULL
|| !STREQ (TYPE_NAME (tp
), name
))
1705 TYPE_NAME (tp
) = obsavestring (name
, strlen (name
),
1706 ¤t_objfile
->type_obstack
);
1709 if (t
->bt
== btTypedef
)
1713 /* Try to cross reference this type, it should succeed. */
1714 ax
+= cross_ref (fd
, ax
, &tp
, type_code
, &name
, bigend
, sym_name
);
1715 if (tp
== (struct type
*) NULL
)
1717 complain (&unable_to_cross_ref_complaint
, sym_name
);
1718 tp
= mdebug_type_int
;
1722 /* Deal with range types */
1723 if (t
->bt
== btRange
)
1725 TYPE_NFIELDS (tp
) = 2;
1726 TYPE_FIELDS (tp
) = ((struct field
*)
1727 TYPE_ALLOC (tp
, 2 * sizeof (struct field
)));
1728 TYPE_FIELD_NAME (tp
, 0) = obsavestring ("Low", strlen ("Low"),
1729 ¤t_objfile
->type_obstack
);
1730 TYPE_FIELD_BITPOS (tp
, 0) = AUX_GET_DNLOW (bigend
, ax
);
1732 TYPE_FIELD_NAME (tp
, 1) = obsavestring ("High", strlen ("High"),
1733 ¤t_objfile
->type_obstack
);
1734 TYPE_FIELD_BITPOS (tp
, 1) = AUX_GET_DNHIGH (bigend
, ax
);
1738 /* Parse all the type qualifiers now. If there are more
1739 than 6 the game will continue in the next aux */
1743 #define PARSE_TQ(tq) \
1744 if (t->tq != tqNil) \
1745 ax += upgrade_type(fd, &tp, t->tq, ax, bigend, sym_name); \
1757 /* mips cc 2.x and gcc never put out continued aux entries. */
1761 (*debug_swap
->swap_tir_in
) (bigend
, &ax
->a_ti
, t
);
1765 /* Complain for illegal continuations due to corrupt aux entries. */
1767 complain (&bad_continued_complaint
, sym_name
);
1772 /* Make up a complex type from a basic one. Type is passed by
1773 reference in TPP and side-effected as necessary. The type
1774 qualifier TQ says how to handle the aux symbols at AX for
1775 the symbol SX we are currently analyzing. BIGEND says whether
1776 aux symbols are big-endian or little-endian.
1777 Returns the number of aux symbols we parsed. */
1780 upgrade_type (int fd
, struct type
**tpp
, int tq
, union aux_ext
*ax
, int bigend
,
1786 /* Used in array processing */
1797 t
= lookup_pointer_type (*tpp
);
1802 t
= lookup_function_type (*tpp
);
1809 /* Determine and record the domain type (type of index) */
1810 (*debug_swap
->swap_rndx_in
) (bigend
, &ax
->a_rndx
, &rndx
);
1816 rf
= AUX_GET_ISYM (bigend
, ax
);
1819 fh
= get_rfd (fd
, rf
);
1821 indx
= parse_type (fh
- debug_info
->fdr
,
1822 debug_info
->external_aux
+ fh
->iauxBase
,
1823 id
, (int *) NULL
, bigend
, sym_name
);
1825 /* The bounds type should be an integer type, but might be anything
1826 else due to corrupt aux entries. */
1827 if (TYPE_CODE (indx
) != TYPE_CODE_INT
)
1829 complain (&array_index_type_complaint
, sym_name
);
1830 indx
= mdebug_type_int
;
1833 /* Get the bounds, and create the array type. */
1835 lower
= AUX_GET_DNLOW (bigend
, ax
);
1837 upper
= AUX_GET_DNHIGH (bigend
, ax
);
1839 rf
= AUX_GET_WIDTH (bigend
, ax
); /* bit size of array element */
1841 range
= create_range_type ((struct type
*) NULL
, indx
,
1844 t
= create_array_type ((struct type
*) NULL
, *tpp
, range
);
1846 /* We used to fill in the supplied array element bitsize
1847 here if the TYPE_LENGTH of the target type was zero.
1848 This happens for a `pointer to an array of anonymous structs',
1849 but in this case the array element bitsize is also zero,
1850 so nothing is gained.
1851 And we used to check the TYPE_LENGTH of the target type against
1852 the supplied array element bitsize.
1853 gcc causes a mismatch for `pointer to array of object',
1854 since the sdb directives it uses do not have a way of
1855 specifying the bitsize, but it does no harm (the
1856 TYPE_LENGTH should be correct) and we should be able to
1857 ignore the erroneous bitsize from the auxiliary entry safely.
1858 dbx seems to ignore it too. */
1860 /* TYPE_FLAG_TARGET_STUB now takes care of the zero TYPE_LENGTH
1862 if (TYPE_LENGTH (*tpp
) == 0)
1864 TYPE_FLAGS (t
) |= TYPE_FLAG_TARGET_STUB
;
1871 /* Volatile -- currently ignored */
1875 /* Const -- currently ignored */
1879 complain (&unknown_type_qual_complaint
, tq
);
1885 /* Parse a procedure descriptor record PR. Note that the procedure is
1886 parsed _after_ the local symbols, now we just insert the extra
1887 information we need into a MIPS_EFI_SYMBOL_NAME symbol that has
1888 already been placed in the procedure's main block. Note also that
1889 images that have been partially stripped (ld -x) have been deprived
1890 of local symbols, and we have to cope with them here. FIRST_OFF is
1891 the offset of the first procedure for this FDR; we adjust the
1892 address by this amount, but I don't know why. SEARCH_SYMTAB is the symtab
1893 to look for the function which contains the MIPS_EFI_SYMBOL_NAME symbol
1894 in question, or NULL to use top_stack->cur_block. */
1896 static void parse_procedure (PDR
*, struct symtab
*, struct partial_symtab
*);
1899 parse_procedure (PDR
*pr
, struct symtab
*search_symtab
,
1900 struct partial_symtab
*pst
)
1902 struct symbol
*s
, *i
;
1904 struct mips_extra_func_info
*e
;
1907 /* Simple rule to find files linked "-x" */
1908 if (cur_fdr
->rss
== -1)
1912 /* Static procedure at address pr->adr. Sigh. */
1913 /* FIXME-32x64. assuming pr->adr fits in long. */
1914 complain (&pdr_static_symbol_complaint
, (unsigned long) pr
->adr
);
1922 (*debug_swap
->swap_ext_in
) (cur_bfd
,
1923 ((char *) debug_info
->external_ext
1925 * debug_swap
->external_ext_size
)),
1927 sh_name
= debug_info
->ssext
+ she
.asym
.iss
;
1935 (*debug_swap
->swap_sym_in
) (cur_bfd
,
1936 ((char *) debug_info
->external_sym
1937 + ((cur_fdr
->isymBase
+ pr
->isym
)
1938 * debug_swap
->external_sym_size
)),
1940 sh_name
= debug_info
->ss
+ cur_fdr
->issBase
+ sh
.iss
;
1943 if (search_symtab
!= NULL
)
1946 /* This loses both in the case mentioned (want a static, find a global),
1947 but also if we are looking up a non-mangled name which happens to
1948 match the name of a mangled function. */
1949 /* We have to save the cur_fdr across the call to lookup_symbol.
1950 If the pdr is for a static function and if a global function with
1951 the same name exists, lookup_symbol will eventually read in the symtab
1952 for the global function and clobber cur_fdr. */
1953 FDR
*save_cur_fdr
= cur_fdr
;
1954 s
= lookup_symbol (sh_name
, NULL
, VAR_NAMESPACE
, 0, NULL
);
1955 cur_fdr
= save_cur_fdr
;
1959 BLOCKVECTOR_BLOCK (BLOCKVECTOR (search_symtab
), STATIC_BLOCK
),
1965 s
= mylookup_symbol (sh_name
, top_stack
->cur_block
,
1966 VAR_NAMESPACE
, LOC_BLOCK
);
1970 b
= SYMBOL_BLOCK_VALUE (s
);
1974 complain (&pdr_for_nonsymbol_complaint
, sh_name
);
1978 /* FIXME -- delete. We can't do symbol allocation now; it's all done. */
1979 s
= new_symbol (sh_name
);
1980 SYMBOL_NAMESPACE (s
) = VAR_NAMESPACE
;
1981 SYMBOL_CLASS (s
) = LOC_BLOCK
;
1982 /* Donno its type, hope int is ok */
1983 SYMBOL_TYPE (s
) = lookup_function_type (mdebug_type_int
);
1984 add_symbol (s
, top_stack
->cur_block
);
1985 /* Wont have symbols for this one */
1987 SYMBOL_BLOCK_VALUE (s
) = b
;
1988 BLOCK_FUNCTION (b
) = s
;
1989 BLOCK_START (b
) = pr
->adr
;
1990 /* BOUND used to be the end of procedure's text, but the
1991 argument is no longer passed in. */
1992 BLOCK_END (b
) = bound
;
1993 BLOCK_SUPERBLOCK (b
) = top_stack
->cur_block
;
1994 add_block (b
, top_stack
->cur_st
);
1998 i
= mylookup_symbol (MIPS_EFI_SYMBOL_NAME
, b
, LABEL_NAMESPACE
, LOC_CONST
);
2002 e
= (struct mips_extra_func_info
*) SYMBOL_VALUE (i
);
2004 e
->pdr
.isym
= (long) s
;
2006 /* GDB expects the absolute function start address for the
2007 procedure descriptor in e->pdr.adr.
2008 As the address in the procedure descriptor is usually relative,
2009 we would have to relocate e->pdr.adr with cur_fdr->adr and
2010 ANOFFSET (pst->section_offsets, SECT_OFF_TEXT (pst->objfile)).
2011 Unfortunately cur_fdr->adr and e->pdr.adr are both absolute
2012 in shared libraries on some systems, and on other systems
2013 e->pdr.adr is sometimes offset by a bogus value.
2014 To work around these problems, we replace e->pdr.adr with
2015 the start address of the function. */
2016 e
->pdr
.adr
= BLOCK_START (b
);
2018 /* Correct incorrect setjmp procedure descriptor from the library
2019 to make backtrace through setjmp work. */
2020 if (e
->pdr
.pcreg
== 0 && STREQ (sh_name
, "setjmp"))
2022 complain (&bad_setjmp_pdr_complaint
, 0);
2023 e
->pdr
.pcreg
= RA_REGNUM
;
2024 e
->pdr
.regmask
= 0x80000000;
2025 e
->pdr
.regoffset
= -4;
2029 /* It would be reasonable that functions that have been compiled
2030 without debugging info have a btNil type for their return value,
2031 and functions that are void and are compiled with debugging info
2033 gcc and DEC f77 put out btNil types for both cases, so btNil is mapped
2034 to TYPE_CODE_VOID in parse_type to get the `compiled with debugging info'
2036 The glevel field in cur_fdr could be used to determine the presence
2037 of debugging info, but GCC doesn't always pass the -g switch settings
2038 to the assembler and GAS doesn't set the glevel field from the -g switch
2040 To work around these problems, the return value type of a TYPE_CODE_VOID
2041 function is adjusted accordingly if no debugging info was found in the
2042 compilation unit. */
2044 if (processing_gcc_compilation
== 0
2045 && found_ecoff_debugging_info
== 0
2046 && TYPE_CODE (TYPE_TARGET_TYPE (SYMBOL_TYPE (s
))) == TYPE_CODE_VOID
)
2047 SYMBOL_TYPE (s
) = nodebug_func_symbol_type
;
2050 /* Relocate the extra function info pointed to by the symbol table. */
2053 ecoff_relocate_efi (struct symbol
*sym
, CORE_ADDR delta
)
2055 struct mips_extra_func_info
*e
;
2057 e
= (struct mips_extra_func_info
*) SYMBOL_VALUE (sym
);
2059 e
->pdr
.adr
+= delta
;
2062 /* Parse the external symbol ES. Just call parse_symbol() after
2063 making sure we know where the aux are for it.
2064 BIGEND says whether aux entries are big-endian or little-endian.
2066 This routine clobbers top_stack->cur_block and ->cur_st. */
2068 static void parse_external (EXTR
*, int, struct section_offsets
*,
2072 parse_external (EXTR
*es
, int bigend
, struct section_offsets
*section_offsets
,
2073 struct objfile
*objfile
)
2077 if (es
->ifd
!= ifdNil
)
2080 cur_fdr
= debug_info
->fdr
+ cur_fd
;
2081 ax
= debug_info
->external_aux
+ cur_fdr
->iauxBase
;
2085 cur_fdr
= debug_info
->fdr
;
2089 /* Reading .o files */
2090 if (SC_IS_UNDEF (es
->asym
.sc
) || es
->asym
.sc
== scNil
)
2093 switch (es
->asym
.st
)
2096 /* These are generated for static symbols in .o files,
2117 /* FIXME: Turn this into a complaint? */
2119 printf_filtered ("Warning: %s `%s' is undefined (in %s)\n",
2120 what
, debug_info
->ssext
+ es
->asym
.iss
,
2121 fdr_name (cur_fdr
));
2125 switch (es
->asym
.st
)
2129 /* There is no need to parse the external procedure symbols.
2130 If they are from objects compiled without -g, their index will
2131 be indexNil, and the symbol definition from the minimal symbol
2132 is preferrable (yielding a function returning int instead of int).
2133 If the index points to a local procedure symbol, the local
2134 symbol already provides the correct type.
2135 Note that the index of the external procedure symbol points
2136 to the local procedure symbol in the local symbol table, and
2137 _not_ to the auxiliary symbol info. */
2141 /* Global common symbols are resolved by the runtime loader,
2143 if (SC_IS_COMMON (es
->asym
.sc
))
2146 /* Note that the case of a symbol with indexNil must be handled
2147 anyways by parse_symbol(). */
2148 parse_symbol (&es
->asym
, ax
, (char *) NULL
, bigend
, section_offsets
, objfile
);
2155 /* Parse the line number info for file descriptor FH into
2156 GDB's linetable LT. MIPS' encoding requires a little bit
2157 of magic to get things out. Note also that MIPS' line
2158 numbers can go back and forth, apparently we can live
2159 with that and do not need to reorder our linetables */
2161 static void parse_lines (FDR
*, PDR
*, struct linetable
*, int,
2162 struct partial_symtab
*, CORE_ADDR
);
2165 parse_lines (FDR
*fh
, PDR
*pr
, struct linetable
*lt
, int maxlines
,
2166 struct partial_symtab
*pst
, CORE_ADDR lowest_pdr_addr
)
2168 unsigned char *base
;
2170 int delta
, count
, lineno
= 0;
2172 if (fh
->cbLine
== 0)
2175 /* Scan by procedure descriptors */
2177 for (j
= 0; j
< fh
->cpd
; j
++, pr
++)
2181 unsigned char *halt
;
2183 /* No code for this one */
2184 if (pr
->iline
== ilineNil
||
2185 pr
->lnLow
== -1 || pr
->lnHigh
== -1)
2188 /* Determine start and end address of compressed line bytes for
2190 base
= debug_info
->line
+ fh
->cbLineOffset
;
2191 if (j
!= (fh
->cpd
- 1))
2192 halt
= base
+ pr
[1].cbLineOffset
;
2194 halt
= base
+ fh
->cbLine
;
2195 base
+= pr
->cbLineOffset
;
2197 adr
= TEXTLOW (pst
) + pr
->adr
- lowest_pdr_addr
;
2199 l
= adr
>> 2; /* in words */
2200 for (lineno
= pr
->lnLow
; base
< halt
;)
2202 count
= *base
& 0x0f;
2203 delta
= *base
++ >> 4;
2208 delta
= (base
[0] << 8) | base
[1];
2209 if (delta
>= 0x8000)
2213 lineno
+= delta
; /* first delta is 0 */
2215 /* Complain if the line table overflows. Could happen
2216 with corrupt binaries. */
2217 if (lt
->nitems
>= maxlines
)
2219 complain (&bad_linetable_guess_complaint
, fdr_name (fh
));
2222 k
= add_line (lt
, lineno
, l
, k
);
2228 /* Master parsing procedure for first-pass reading of file symbols
2229 into a partial_symtab. */
2232 parse_partial_symbols (struct objfile
*objfile
)
2234 const bfd_size_type external_sym_size
= debug_swap
->external_sym_size
;
2235 const bfd_size_type external_rfd_size
= debug_swap
->external_rfd_size
;
2236 const bfd_size_type external_ext_size
= debug_swap
->external_ext_size
;
2237 void (*const swap_ext_in
) (bfd
*, PTR
, EXTR
*) = debug_swap
->swap_ext_in
;
2238 void (*const swap_sym_in
) (bfd
*, PTR
, SYMR
*) = debug_swap
->swap_sym_in
;
2239 void (*const swap_rfd_in
) (bfd
*, PTR
, RFDT
*) = debug_swap
->swap_rfd_in
;
2241 HDRR
*hdr
= &debug_info
->symbolic_header
;
2242 /* Running pointers */
2247 register EXTR
*ext_in
;
2250 struct partial_symtab
*pst
;
2251 int textlow_not_set
= 1;
2252 int past_first_source_file
= 0;
2254 /* List of current psymtab's include files */
2255 char **psymtab_include_list
;
2256 int includes_allocated
;
2259 struct pst_map
*fdr_to_pst
;
2260 /* Index within current psymtab dependency list */
2261 struct partial_symtab
**dependency_list
;
2262 int dependencies_used
, dependencies_allocated
;
2263 struct cleanup
*old_chain
;
2265 enum language prev_language
;
2266 asection
*text_sect
;
2267 int relocatable
= 0;
2269 /* Irix 5.2 shared libraries have a fh->adr field of zero, but
2270 the shared libraries are prelinked at a high memory address.
2271 We have to adjust the start address of the object file for this case,
2272 by setting it to the start address of the first procedure in the file.
2273 But we should do no adjustments if we are debugging a .o file, where
2274 the text section (and fh->adr) really starts at zero. */
2275 text_sect
= bfd_get_section_by_name (cur_bfd
, ".text");
2276 if (text_sect
!= NULL
2277 && (bfd_get_section_flags (cur_bfd
, text_sect
) & SEC_RELOC
))
2280 extern_tab
= (EXTR
*) obstack_alloc (&objfile
->psymbol_obstack
,
2281 sizeof (EXTR
) * hdr
->iextMax
);
2283 includes_allocated
= 30;
2285 psymtab_include_list
= (char **) alloca (includes_allocated
*
2287 next_symbol_text_func
= mdebug_next_symbol_text
;
2289 dependencies_allocated
= 30;
2290 dependencies_used
= 0;
2292 (struct partial_symtab
**) alloca (dependencies_allocated
*
2293 sizeof (struct partial_symtab
*));
2295 last_source_file
= NULL
;
2300 * Only parse the Local and External symbols, and the Relative FDR.
2301 * Fixup enough of the loader symtab to be able to use it.
2302 * Allocate space only for the file's portions we need to
2307 max_glevel
= MIN_GLEVEL
;
2309 /* Allocate the map FDR -> PST.
2310 Minor hack: -O3 images might claim some global data belongs
2311 to FDR -1. We`ll go along with that */
2312 fdr_to_pst
= (struct pst_map
*) xzalloc ((hdr
->ifdMax
+ 1) * sizeof *fdr_to_pst
);
2313 old_chain
= make_cleanup (xfree
, fdr_to_pst
);
2316 struct partial_symtab
*pst
= new_psymtab ("", objfile
);
2317 fdr_to_pst
[-1].pst
= pst
;
2321 /* Allocate the global pending list. */
2323 ((struct mdebug_pending
**)
2324 obstack_alloc (&objfile
->psymbol_obstack
,
2325 hdr
->ifdMax
* sizeof (struct mdebug_pending
*)));
2326 memset ((PTR
) pending_list
, 0,
2327 hdr
->ifdMax
* sizeof (struct mdebug_pending
*));
2329 /* Pass 0 over external syms: swap them in. */
2330 ext_block
= (EXTR
*) xmalloc (hdr
->iextMax
* sizeof (EXTR
));
2331 make_cleanup (xfree
, ext_block
);
2333 ext_out
= (char *) debug_info
->external_ext
;
2334 ext_out_end
= ext_out
+ hdr
->iextMax
* external_ext_size
;
2336 for (; ext_out
< ext_out_end
; ext_out
+= external_ext_size
, ext_in
++)
2337 (*swap_ext_in
) (cur_bfd
, ext_out
, ext_in
);
2339 /* Pass 1 over external syms: Presize and partition the list */
2341 ext_in_end
= ext_in
+ hdr
->iextMax
;
2342 for (; ext_in
< ext_in_end
; ext_in
++)
2344 /* See calls to complain below. */
2345 if (ext_in
->ifd
>= -1
2346 && ext_in
->ifd
< hdr
->ifdMax
2347 && ext_in
->asym
.iss
>= 0
2348 && ext_in
->asym
.iss
< hdr
->issExtMax
)
2349 fdr_to_pst
[ext_in
->ifd
].n_globals
++;
2352 /* Pass 1.5 over files: partition out global symbol space */
2354 for (f_idx
= -1; f_idx
< hdr
->ifdMax
; f_idx
++)
2356 fdr_to_pst
[f_idx
].globals_offset
= s_idx
;
2357 s_idx
+= fdr_to_pst
[f_idx
].n_globals
;
2358 fdr_to_pst
[f_idx
].n_globals
= 0;
2363 For ECOFF in ELF, we skip the creation of the minimal symbols.
2364 The ECOFF symbols should be a subset of the Elf symbols, and the
2365 section information of the elf symbols will be more accurate.
2366 FIXME! What about Irix 5's native linker?
2368 By default, Elf sections which don't exist in ECOFF
2369 get put in ECOFF's absolute section by the gnu linker.
2370 Since absolute sections don't get relocated, we
2371 end up calculating an address different from that of
2372 the symbol's minimal symbol (created earlier from the
2375 To fix this, either :
2376 1) don't create the duplicate symbol
2377 (assumes ECOFF symtab is a subset of the ELF symtab;
2378 assumes no side-effects result from ignoring ECOFF symbol)
2379 2) create it, only if lookup for existing symbol in ELF's minimal
2382 assumes no side-effects result from ignoring ECOFF symbol)
2383 3) create it, but lookup ELF's minimal symbol and use it's section
2384 during relocation, then modify "uniqify" phase to merge and
2385 eliminate the duplicate symbol
2386 (highly inefficient)
2388 I've implemented #1 here...
2389 Skip the creation of the minimal symbols based on the ECOFF
2392 /* Pass 2 over external syms: fill in external symbols */
2394 ext_in_end
= ext_in
+ hdr
->iextMax
;
2395 for (; ext_in
< ext_in_end
; ext_in
++)
2397 enum minimal_symbol_type ms_type
= mst_text
;
2398 CORE_ADDR svalue
= ext_in
->asym
.value
;
2400 /* The Irix 5 native tools seem to sometimes generate bogus
2401 external symbols. */
2402 if (ext_in
->ifd
< -1 || ext_in
->ifd
>= hdr
->ifdMax
)
2404 complain (&bad_ext_ifd_complaint
, ext_in
->ifd
, hdr
->ifdMax
);
2407 if (ext_in
->asym
.iss
< 0 || ext_in
->asym
.iss
>= hdr
->issExtMax
)
2409 complain (&bad_ext_iss_complaint
, ext_in
->asym
.iss
,
2414 extern_tab
[fdr_to_pst
[ext_in
->ifd
].globals_offset
2415 + fdr_to_pst
[ext_in
->ifd
].n_globals
++] = *ext_in
;
2418 if (SC_IS_UNDEF (ext_in
->asym
.sc
) || ext_in
->asym
.sc
== scNil
)
2422 /* Pass 3 over files, over local syms: fill in static symbols */
2423 name
= debug_info
->ssext
+ ext_in
->asym
.iss
;
2425 /* Process ECOFF Symbol Types and Storage Classes */
2426 switch (ext_in
->asym
.st
)
2429 /* Beginnning of Procedure */
2430 svalue
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT (objfile
));
2433 /* Load time only static procs */
2434 ms_type
= mst_file_text
;
2435 svalue
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT (objfile
));
2438 /* External symbol */
2439 if (SC_IS_COMMON (ext_in
->asym
.sc
))
2441 /* The value of a common symbol is its size, not its address.
2445 else if (SC_IS_DATA (ext_in
->asym
.sc
))
2448 svalue
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_DATA (objfile
));
2450 else if (SC_IS_BSS (ext_in
->asym
.sc
))
2453 svalue
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_BSS (objfile
));
2460 if (SC_IS_TEXT (ext_in
->asym
.sc
))
2462 ms_type
= mst_file_text
;
2463 svalue
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT (objfile
));
2465 else if (SC_IS_DATA (ext_in
->asym
.sc
))
2467 ms_type
= mst_file_data
;
2468 svalue
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_DATA (objfile
));
2470 else if (SC_IS_BSS (ext_in
->asym
.sc
))
2472 ms_type
= mst_file_bss
;
2473 svalue
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_BSS (objfile
));
2480 /* The alpha has the section start addresses in stLocal symbols
2481 whose name starts with a `.'. Skip those but complain for all
2482 other stLocal symbols.
2483 Irix6 puts the section start addresses in stNil symbols, skip
2489 ms_type
= mst_unknown
;
2490 complain (&unknown_ext_complaint
, name
);
2492 if (!ECOFF_IN_ELF (cur_bfd
))
2493 prim_record_minimal_symbol (name
, svalue
, ms_type
, objfile
);
2496 /* Pass 3 over files, over local syms: fill in static symbols */
2497 for (f_idx
= 0; f_idx
< hdr
->ifdMax
; f_idx
++)
2499 struct partial_symtab
*save_pst
;
2503 cur_fdr
= fh
= debug_info
->fdr
+ f_idx
;
2507 fdr_to_pst
[f_idx
].pst
= NULL
;
2511 /* Determine the start address for this object file from the
2512 file header and relocate it, except for Irix 5.2 zero fh->adr. */
2516 if (relocatable
|| textlow
!= 0)
2517 textlow
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT (objfile
));
2521 pst
= start_psymtab_common (objfile
, objfile
->section_offsets
,
2524 objfile
->global_psymbols
.next
,
2525 objfile
->static_psymbols
.next
);
2526 pst
->read_symtab_private
= ((char *)
2527 obstack_alloc (&objfile
->psymbol_obstack
,
2528 sizeof (struct symloc
)));
2529 memset ((PTR
) pst
->read_symtab_private
, 0, sizeof (struct symloc
));
2532 TEXTLOW (pst
) = pst
->textlow
;
2533 TEXTHIGH (pst
) = pst
->texthigh
;
2534 FDR_IDX (pst
) = f_idx
;
2535 CUR_BFD (pst
) = cur_bfd
;
2536 DEBUG_SWAP (pst
) = debug_swap
;
2537 DEBUG_INFO (pst
) = debug_info
;
2538 PENDING_LIST (pst
) = pending_list
;
2540 /* The way to turn this into a symtab is to call... */
2541 pst
->read_symtab
= mdebug_psymtab_to_symtab
;
2543 /* Set up language for the pst.
2544 The language from the FDR is used if it is unambigious (e.g. cfront
2545 with native cc and g++ will set the language to C).
2546 Otherwise we have to deduce the language from the filename.
2547 Native ecoff has every header file in a separate FDR, so
2548 deduce_language_from_filename will return language_unknown for
2549 a header file, which is not what we want.
2550 But the FDRs for the header files are after the FDR for the source
2551 file, so we can assign the language of the source file to the
2552 following header files. Then we save the language in the private
2553 pst data so that we can reuse it when building symtabs. */
2554 prev_language
= psymtab_language
;
2558 case langCplusplusV2
:
2559 psymtab_language
= language_cplus
;
2562 psymtab_language
= deduce_language_from_filename (fdr_name (fh
));
2565 if (psymtab_language
== language_unknown
)
2566 psymtab_language
= prev_language
;
2567 PST_PRIVATE (pst
)->pst_language
= psymtab_language
;
2569 TEXTHIGH (pst
) = TEXTLOW (pst
);
2571 /* For stabs-in-ecoff files, the second symbol must be @stab.
2572 This symbol is emitted by mips-tfile to signal that the
2573 current object file uses encapsulated stabs instead of mips
2574 ecoff for local symbols. (It is the second symbol because
2575 the first symbol is the stFile used to signal the start of a
2577 processing_gcc_compilation
= 0;
2580 (*swap_sym_in
) (cur_bfd
,
2581 ((char *) debug_info
->external_sym
2582 + (fh
->isymBase
+ 1) * external_sym_size
),
2584 if (STREQ (debug_info
->ss
+ fh
->issBase
+ sh
.iss
, stabs_symbol
))
2585 processing_gcc_compilation
= 2;
2588 if (processing_gcc_compilation
!= 0)
2590 for (cur_sdx
= 2; cur_sdx
< fh
->csym
; cur_sdx
++)
2595 (*swap_sym_in
) (cur_bfd
,
2596 (((char *) debug_info
->external_sym
)
2597 + (fh
->isymBase
+ cur_sdx
) * external_sym_size
),
2599 type_code
= ECOFF_UNMARK_STAB (sh
.index
);
2600 if (!ECOFF_IS_STAB (&sh
))
2602 if (sh
.st
== stProc
|| sh
.st
== stStaticProc
)
2607 sh
.value
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT (objfile
));
2608 if (sh
.st
== stStaticProc
)
2610 namestring
= debug_info
->ss
+ fh
->issBase
+ sh
.iss
;
2611 prim_record_minimal_symbol_and_info (namestring
,
2615 SECT_OFF_TEXT (objfile
),
2619 procaddr
= sh
.value
;
2621 isym
= AUX_GET_ISYM (fh
->fBigendian
,
2622 (debug_info
->external_aux
2625 (*swap_sym_in
) (cur_bfd
,
2626 ((char *) debug_info
->external_sym
2627 + ((fh
->isymBase
+ isym
- 1)
2628 * external_sym_size
)),
2632 CORE_ADDR high
= procaddr
+ sh
.value
;
2634 /* Kludge for Irix 5.2 zero fh->adr. */
2636 && (TEXTLOW (pst
) == 0 || procaddr
< TEXTLOW (pst
)))
2637 TEXTLOW (pst
) = procaddr
;
2638 if (high
> TEXTHIGH (pst
))
2639 TEXTHIGH (pst
) = high
;
2642 else if (sh
.st
== stStatic
)
2657 namestring
= debug_info
->ss
+ fh
->issBase
+ sh
.iss
;
2658 sh
.value
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_DATA (objfile
));
2659 prim_record_minimal_symbol_and_info (namestring
,
2663 SECT_OFF_DATA (objfile
),
2669 /* FIXME! Shouldn't this use cases for bss,
2670 then have the default be abs? */
2671 namestring
= debug_info
->ss
+ fh
->issBase
+ sh
.iss
;
2672 sh
.value
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_BSS (objfile
));
2673 prim_record_minimal_symbol_and_info (namestring
,
2677 SECT_OFF_BSS (objfile
),
2685 /* Handle stabs continuation */
2687 char *stabstring
= debug_info
->ss
+ fh
->issBase
+ sh
.iss
;
2688 int len
= strlen (stabstring
);
2689 while (stabstring
[len
- 1] == '\\')
2692 char *stabstring1
= stabstring
;
2696 /* Ignore continuation char from 1st string */
2699 /* Read next stabstring */
2701 (*swap_sym_in
) (cur_bfd
,
2702 (((char *) debug_info
->external_sym
)
2703 + (fh
->isymBase
+ cur_sdx
)
2704 * external_sym_size
),
2706 stabstring2
= debug_info
->ss
+ fh
->issBase
+ sh2
.iss
;
2707 len2
= strlen (stabstring2
);
2709 /* Concatinate stabstring2 with stabstring1 */
2711 && stabstring
!= debug_info
->ss
+ fh
->issBase
+ sh
.iss
)
2712 stabstring
= xrealloc (stabstring
, len
+ len2
+ 1);
2714 stabstring
= xmalloc (len
+ len2
+ 1);
2715 strcpy (stabstring
, stabstring1
);
2716 strcpy (stabstring
+ len
, stabstring2
);
2720 #define SET_NAMESTRING() \
2721 namestring = stabstring
2722 #define CUR_SYMBOL_TYPE type_code
2723 #define CUR_SYMBOL_VALUE sh.value
2724 #define START_PSYMTAB(ofile,fname,low,symoff,global_syms,static_syms)\
2726 #define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps,textlow_not_set) (void)0
2727 #define HANDLE_RBRAC(val) \
2728 if ((val) > TEXTHIGH (save_pst)) TEXTHIGH (save_pst) = (val);
2729 #include "partial-stab.h"
2732 && stabstring
!= debug_info
->ss
+ fh
->issBase
+ sh
.iss
)
2735 /* end - Handle continuation */
2740 for (cur_sdx
= 0; cur_sdx
< fh
->csym
;)
2743 enum address_class
class;
2745 (*swap_sym_in
) (cur_bfd
,
2746 ((char *) debug_info
->external_sym
2747 + ((fh
->isymBase
+ cur_sdx
)
2748 * external_sym_size
)),
2751 if (ECOFF_IS_STAB (&sh
))
2757 /* Non absolute static symbols go into the minimal table. */
2758 if (SC_IS_UNDEF (sh
.sc
) || sh
.sc
== scNil
2759 || (sh
.index
== indexNil
2760 && (sh
.st
!= stStatic
|| sh
.sc
== scAbs
)))
2762 /* FIXME, premature? */
2767 name
= debug_info
->ss
+ fh
->issBase
+ sh
.iss
;
2773 /* The value of a stEnd symbol is the displacement from the
2774 corresponding start symbol value, do not relocate it. */
2776 sh
.value
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT (objfile
));
2783 sh
.value
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_DATA (objfile
));
2787 sh
.value
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_BSS (objfile
));
2798 prim_record_minimal_symbol_and_info (name
, sh
.value
,
2799 mst_file_text
, NULL
,
2800 SECT_OFF_TEXT (objfile
), NULL
,
2806 /* Usually there is a local and a global stProc symbol
2807 for a function. This means that the function name
2808 has already been entered into the mimimal symbol table
2809 while processing the global symbols in pass 2 above.
2810 One notable exception is the PROGRAM name from
2811 f77 compiled executables, it is only put out as
2812 local stProc symbol, and a global MAIN__ stProc symbol
2813 points to it. It doesn't matter though, as gdb is
2814 still able to find the PROGRAM name via the partial
2815 symbol table, and the MAIN__ symbol via the minimal
2817 if (sh
.st
== stProc
)
2818 add_psymbol_to_list (name
, strlen (name
),
2819 VAR_NAMESPACE
, LOC_BLOCK
,
2820 &objfile
->global_psymbols
,
2821 0, sh
.value
, psymtab_language
, objfile
);
2823 add_psymbol_to_list (name
, strlen (name
),
2824 VAR_NAMESPACE
, LOC_BLOCK
,
2825 &objfile
->static_psymbols
,
2826 0, sh
.value
, psymtab_language
, objfile
);
2828 /* Skip over procedure to next one. */
2829 if (sh
.index
>= hdr
->iauxMax
)
2831 /* Should not happen, but does when cross-compiling
2832 with the MIPS compiler. FIXME -- pull later. */
2833 complain (&index_complaint
, name
);
2834 new_sdx
= cur_sdx
+ 1; /* Don't skip at all */
2837 new_sdx
= AUX_GET_ISYM (fh
->fBigendian
,
2838 (debug_info
->external_aux
2841 procaddr
= sh
.value
;
2843 if (new_sdx
<= cur_sdx
)
2845 /* This should not happen either... FIXME. */
2846 complain (&aux_index_complaint
, name
);
2847 new_sdx
= cur_sdx
+ 1; /* Don't skip backward */
2851 (*swap_sym_in
) (cur_bfd
,
2852 ((char *) debug_info
->external_sym
2853 + ((fh
->isymBase
+ cur_sdx
- 1)
2854 * external_sym_size
)),
2859 /* Kludge for Irix 5.2 zero fh->adr. */
2861 && (TEXTLOW (pst
) == 0 || procaddr
< TEXTLOW (pst
)))
2862 TEXTLOW (pst
) = procaddr
;
2864 high
= procaddr
+ sh
.value
;
2865 if (high
> TEXTHIGH (pst
))
2866 TEXTHIGH (pst
) = high
;
2869 case stStatic
: /* Variable */
2870 if (SC_IS_DATA (sh
.sc
))
2871 prim_record_minimal_symbol_and_info (name
, sh
.value
,
2872 mst_file_data
, NULL
,
2873 SECT_OFF_DATA (objfile
),
2877 prim_record_minimal_symbol_and_info (name
, sh
.value
,
2879 SECT_OFF_BSS (objfile
),
2885 case stIndirect
: /* Irix5 forward declaration */
2886 /* Skip forward declarations from Irix5 cc */
2889 case stTypedef
: /* Typedef */
2890 /* Skip typedefs for forward declarations and opaque
2891 structs from alpha and mips cc. */
2892 if (sh
.iss
== 0 || has_opaque_xref (fh
, &sh
))
2894 class = LOC_TYPEDEF
;
2897 case stConstant
: /* Constant decl */
2904 case stBlock
: /* { }, str, un, enum */
2905 /* Do not create a partial symbol for cc unnamed aggregates
2906 and gcc empty aggregates. */
2907 if ((sh
.sc
== scInfo
2908 || SC_IS_COMMON (sh
.sc
))
2910 && sh
.index
!= cur_sdx
+ 2)
2912 add_psymbol_to_list (name
, strlen (name
),
2913 STRUCT_NAMESPACE
, LOC_TYPEDEF
,
2914 &objfile
->static_psymbols
,
2916 psymtab_language
, objfile
);
2918 handle_psymbol_enumerators (objfile
, fh
, sh
.st
, sh
.value
);
2920 /* Skip over the block */
2922 if (new_sdx
<= cur_sdx
)
2924 /* This happens with the Ultrix kernel. */
2925 complain (&block_index_complaint
, name
);
2926 new_sdx
= cur_sdx
+ 1; /* Don't skip backward */
2931 case stFile
: /* File headers */
2932 case stLabel
: /* Labels */
2933 case stEnd
: /* Ends of files */
2936 case stLocal
: /* Local variables */
2937 /* Normally these are skipped because we skip over
2938 all blocks we see. However, these can occur
2939 as visible symbols in a .h file that contains code. */
2943 /* Both complaints are valid: one gives symbol name,
2944 the other the offending symbol type. */
2945 complain (&unknown_sym_complaint
, name
);
2946 complain (&unknown_st_complaint
, sh
.st
);
2950 /* Use this gdb symbol */
2951 add_psymbol_to_list (name
, strlen (name
),
2952 VAR_NAMESPACE
, class,
2953 &objfile
->static_psymbols
,
2954 0, sh
.value
, psymtab_language
, objfile
);
2956 cur_sdx
++; /* Go to next file symbol */
2959 /* Now do enter the external symbols. */
2960 ext_ptr
= &extern_tab
[fdr_to_pst
[f_idx
].globals_offset
];
2961 cur_sdx
= fdr_to_pst
[f_idx
].n_globals
;
2962 PST_PRIVATE (save_pst
)->extern_count
= cur_sdx
;
2963 PST_PRIVATE (save_pst
)->extern_tab
= ext_ptr
;
2964 for (; --cur_sdx
>= 0; ext_ptr
++)
2966 enum address_class
class;
2971 if (ext_ptr
->ifd
!= f_idx
)
2972 internal_error (__FILE__
, __LINE__
, "failed internal consistency check");
2973 psh
= &ext_ptr
->asym
;
2975 /* Do not add undefined symbols to the partial symbol table. */
2976 if (SC_IS_UNDEF (psh
->sc
) || psh
->sc
== scNil
)
2979 svalue
= psh
->value
;
2984 svalue
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT (objfile
));
2991 svalue
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_DATA (objfile
));
2995 svalue
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_BSS (objfile
));
3002 /* These are generated for static symbols in .o files,
3007 /* External procedure symbols have been entered
3008 into the minimal symbol table in pass 2 above.
3009 Ignore them, as parse_external will ignore them too. */
3015 complain (&unknown_ext_complaint
,
3016 debug_info
->ssext
+ psh
->iss
);
3017 /* Fall through, pretend it's global. */
3019 /* Global common symbols are resolved by the runtime loader,
3021 if (SC_IS_COMMON (psh
->sc
))
3027 name
= debug_info
->ssext
+ psh
->iss
;
3028 add_psymbol_to_list (name
, strlen (name
),
3029 VAR_NAMESPACE
, class,
3030 &objfile
->global_psymbols
,
3032 psymtab_language
, objfile
);
3036 /* Link pst to FDR. end_psymtab returns NULL if the psymtab was
3037 empty and put on the free list. */
3038 fdr_to_pst
[f_idx
].pst
= end_psymtab (save_pst
,
3039 psymtab_include_list
, includes_used
,
3040 -1, TEXTHIGH (save_pst
),
3041 dependency_list
, dependencies_used
, textlow_not_set
);
3043 dependencies_used
= 0;
3045 if (objfile
->ei
.entry_point
>= TEXTLOW (save_pst
) &&
3046 objfile
->ei
.entry_point
< TEXTHIGH (save_pst
))
3048 objfile
->ei
.entry_file_lowpc
= TEXTLOW (save_pst
);
3049 objfile
->ei
.entry_file_highpc
= TEXTHIGH (save_pst
);
3052 /* The objfile has its functions reordered if this partial symbol
3053 table overlaps any other partial symbol table.
3054 We cannot assume a reordered objfile if a partial symbol table
3055 is contained within another partial symbol table, as partial symbol
3056 tables for include files with executable code are contained
3057 within the partial symbol table for the including source file,
3058 and we do not want to flag the objfile reordered for these cases.
3060 This strategy works well for Irix-5.2 shared libraries, but we
3061 might have to use a more elaborate (and slower) algorithm for
3063 save_pst
= fdr_to_pst
[f_idx
].pst
;
3064 if (save_pst
!= NULL
3065 && TEXTLOW (save_pst
) != 0
3066 && !(objfile
->flags
& OBJF_REORDERED
))
3068 ALL_OBJFILE_PSYMTABS (objfile
, pst
)
3071 && TEXTLOW (save_pst
) >= TEXTLOW (pst
)
3072 && TEXTLOW (save_pst
) < TEXTHIGH (pst
)
3073 && TEXTHIGH (save_pst
) > TEXTHIGH (pst
))
3075 objfile
->flags
|= OBJF_REORDERED
;
3082 /* Now scan the FDRs for dependencies */
3083 for (f_idx
= 0; f_idx
< hdr
->ifdMax
; f_idx
++)
3085 fh
= f_idx
+ debug_info
->fdr
;
3086 pst
= fdr_to_pst
[f_idx
].pst
;
3088 if (pst
== (struct partial_symtab
*) NULL
)
3091 /* This should catch stabs-in-ecoff. */
3095 /* Skip the first file indirect entry as it is a self dependency
3096 for source files or a reverse .h -> .c dependency for header files. */
3097 pst
->number_of_dependencies
= 0;
3099 ((struct partial_symtab
**)
3100 obstack_alloc (&objfile
->psymbol_obstack
,
3102 * sizeof (struct partial_symtab
*))));
3103 for (s_idx
= 1; s_idx
< fh
->crfd
; s_idx
++)
3107 (*swap_rfd_in
) (cur_bfd
,
3108 ((char *) debug_info
->external_rfd
3109 + (fh
->rfdBase
+ s_idx
) * external_rfd_size
),
3111 if (rh
< 0 || rh
>= hdr
->ifdMax
)
3113 complain (&bad_file_number_complaint
, rh
);
3117 /* Skip self dependencies of header files. */
3121 /* Do not add to dependeny list if psymtab was empty. */
3122 if (fdr_to_pst
[rh
].pst
== (struct partial_symtab
*) NULL
)
3124 pst
->dependencies
[pst
->number_of_dependencies
++] = fdr_to_pst
[rh
].pst
;
3128 /* Remove the dummy psymtab created for -O3 images above, if it is
3129 still empty, to enable the detection of stripped executables. */
3130 if (objfile
->psymtabs
->next
== NULL
3131 && objfile
->psymtabs
->number_of_dependencies
== 0
3132 && objfile
->psymtabs
->n_global_syms
== 0
3133 && objfile
->psymtabs
->n_static_syms
== 0)
3134 objfile
->psymtabs
= NULL
;
3135 do_cleanups (old_chain
);
3138 /* If the current psymbol has an enumerated type, we need to add
3139 all the the enum constants to the partial symbol table. */
3142 handle_psymbol_enumerators (struct objfile
*objfile
, FDR
*fh
, int stype
,
3145 const bfd_size_type external_sym_size
= debug_swap
->external_sym_size
;
3146 void (*const swap_sym_in
) (bfd
*, PTR
, SYMR
*) = debug_swap
->swap_sym_in
;
3147 char *ext_sym
= ((char *) debug_info
->external_sym
3148 + ((fh
->isymBase
+ cur_sdx
+ 1) * external_sym_size
));
3158 /* It is an enumerated type if the next symbol entry is a stMember
3159 and its auxiliary index is indexNil or its auxiliary entry
3160 is a plain btNil or btVoid.
3161 Alpha cc -migrate enums are recognized by a zero index and
3162 a zero symbol value.
3163 DU 4.0 cc enums are recognized by a member type of btEnum without
3164 qualifiers and a zero symbol value. */
3165 (*swap_sym_in
) (cur_bfd
, ext_sym
, &sh
);
3166 if (sh
.st
!= stMember
)
3169 if (sh
.index
== indexNil
3170 || (sh
.index
== 0 && svalue
== 0))
3172 (*debug_swap
->swap_tir_in
) (fh
->fBigendian
,
3173 &(debug_info
->external_aux
3174 + fh
->iauxBase
+ sh
.index
)->a_ti
,
3176 if ((tir
.bt
!= btNil
3178 && (tir
.bt
!= btEnum
|| svalue
!= 0))
3179 || tir
.tq0
!= tqNil
)
3191 (*swap_sym_in
) (cur_bfd
, ext_sym
, &sh
);
3192 if (sh
.st
!= stMember
)
3194 name
= debug_info
->ss
+ cur_fdr
->issBase
+ sh
.iss
;
3196 /* Note that the value doesn't matter for enum constants
3197 in psymtabs, just in symtabs. */
3198 add_psymbol_to_list (name
, strlen (name
),
3199 VAR_NAMESPACE
, LOC_CONST
,
3200 &objfile
->static_psymbols
, 0,
3201 (CORE_ADDR
) 0, psymtab_language
, objfile
);
3202 ext_sym
+= external_sym_size
;
3206 /* Get the next symbol. OBJFILE is unused. */
3209 mdebug_next_symbol_text (struct objfile
*objfile
)
3214 (*debug_swap
->swap_sym_in
) (cur_bfd
,
3215 ((char *) debug_info
->external_sym
3216 + ((cur_fdr
->isymBase
+ cur_sdx
)
3217 * debug_swap
->external_sym_size
)),
3219 return debug_info
->ss
+ cur_fdr
->issBase
+ sh
.iss
;
3222 /* Ancillary function to psymtab_to_symtab(). Does all the work
3223 for turning the partial symtab PST into a symtab, recurring
3224 first on all dependent psymtabs. The argument FILENAME is
3225 only passed so we can see in debug stack traces what file
3228 This function has a split personality, based on whether the
3229 symbol table contains ordinary ecoff symbols, or stabs-in-ecoff.
3230 The flow of control and even the memory allocation differs. FIXME. */
3233 psymtab_to_symtab_1 (struct partial_symtab
*pst
, char *filename
)
3235 bfd_size_type external_sym_size
;
3236 bfd_size_type external_pdr_size
;
3237 void (*swap_sym_in
) (bfd
*, PTR
, SYMR
*);
3238 void (*swap_pdr_in
) (bfd
*, PTR
, PDR
*);
3240 struct symtab
*st
= NULL
;
3242 struct linetable
*lines
;
3243 CORE_ADDR lowest_pdr_addr
= 0;
3244 int last_symtab_ended
= 0;
3250 /* Read in all partial symbtabs on which this one is dependent.
3251 NOTE that we do have circular dependencies, sigh. We solved
3252 that by setting pst->readin before this point. */
3254 for (i
= 0; i
< pst
->number_of_dependencies
; i
++)
3255 if (!pst
->dependencies
[i
]->readin
)
3257 /* Inform about additional files to be read in. */
3260 fputs_filtered (" ", gdb_stdout
);
3262 fputs_filtered ("and ", gdb_stdout
);
3264 printf_filtered ("%s...",
3265 pst
->dependencies
[i
]->filename
);
3266 wrap_here (""); /* Flush output */
3267 gdb_flush (gdb_stdout
);
3269 /* We only pass the filename for debug purposes */
3270 psymtab_to_symtab_1 (pst
->dependencies
[i
],
3271 pst
->dependencies
[i
]->filename
);
3274 /* Do nothing if this is a dummy psymtab. */
3276 if (pst
->n_global_syms
== 0 && pst
->n_static_syms
== 0
3277 && TEXTLOW (pst
) == 0 && TEXTHIGH (pst
) == 0)
3280 /* Now read the symbols for this symtab */
3282 cur_bfd
= CUR_BFD (pst
);
3283 debug_swap
= DEBUG_SWAP (pst
);
3284 debug_info
= DEBUG_INFO (pst
);
3285 pending_list
= PENDING_LIST (pst
);
3286 external_sym_size
= debug_swap
->external_sym_size
;
3287 external_pdr_size
= debug_swap
->external_pdr_size
;
3288 swap_sym_in
= debug_swap
->swap_sym_in
;
3289 swap_pdr_in
= debug_swap
->swap_pdr_in
;
3290 current_objfile
= pst
->objfile
;
3291 cur_fd
= FDR_IDX (pst
);
3292 fh
= ((cur_fd
== -1)
3294 : debug_info
->fdr
+ cur_fd
);
3297 /* See comment in parse_partial_symbols about the @stabs sentinel. */
3298 processing_gcc_compilation
= 0;
3299 if (fh
!= (FDR
*) NULL
&& fh
->csym
>= 2)
3303 (*swap_sym_in
) (cur_bfd
,
3304 ((char *) debug_info
->external_sym
3305 + (fh
->isymBase
+ 1) * external_sym_size
),
3307 if (STREQ (debug_info
->ss
+ fh
->issBase
+ sh
.iss
,
3310 /* We indicate that this is a GCC compilation so that certain
3311 features will be enabled in stabsread/dbxread. */
3312 processing_gcc_compilation
= 2;
3316 if (processing_gcc_compilation
!= 0)
3319 /* This symbol table contains stabs-in-ecoff entries. */
3321 /* Parse local symbols first */
3323 if (fh
->csym
<= 2) /* FIXME, this blows psymtab->symtab ptr */
3325 current_objfile
= NULL
;
3328 for (cur_sdx
= 2; cur_sdx
< fh
->csym
; cur_sdx
++)
3334 (*swap_sym_in
) (cur_bfd
,
3335 (((char *) debug_info
->external_sym
)
3336 + (fh
->isymBase
+ cur_sdx
) * external_sym_size
),
3338 name
= debug_info
->ss
+ fh
->issBase
+ sh
.iss
;
3340 /* XXX This is a hack. It will go away! */
3341 if (ECOFF_IS_STAB (&sh
) || (name
[0] == '#'))
3343 int type_code
= ECOFF_UNMARK_STAB (sh
.index
);
3345 /* We should never get non N_STAB symbols here, but they
3346 should be harmless, so keep process_one_symbol from
3347 complaining about them. */
3348 if (type_code
& N_STAB
)
3350 /* If we found a trailing N_SO with no name, process
3351 it here instead of in process_one_symbol, so we
3352 can keep a handle to its symtab. The symtab
3353 would otherwise be ended twice, once in
3354 process_one_symbol, and once after this loop. */
3355 if (type_code
== N_SO
3357 && previous_stab_code
!= (unsigned char) N_SO
3360 valu
+= ANOFFSET (pst
->section_offsets
,
3361 SECT_OFF_TEXT (pst
->objfile
));
3362 previous_stab_code
= N_SO
;
3363 st
= end_symtab (valu
, pst
->objfile
,
3364 SECT_OFF_TEXT (pst
->objfile
));
3366 last_symtab_ended
= 1;
3370 last_symtab_ended
= 0;
3371 process_one_symbol (type_code
, 0, valu
, name
,
3372 pst
->section_offsets
, pst
->objfile
);
3375 /* Similarly a hack. */
3376 else if (name
[0] == '#')
3378 process_one_symbol (N_SLINE
, 0, valu
, name
,
3379 pst
->section_offsets
, pst
->objfile
);
3381 if (type_code
== N_FUN
)
3383 /* Make up special symbol to contain
3384 procedure specific info */
3385 struct mips_extra_func_info
*e
=
3386 ((struct mips_extra_func_info
*)
3387 obstack_alloc (¤t_objfile
->symbol_obstack
,
3388 sizeof (struct mips_extra_func_info
)));
3389 struct symbol
*s
= new_symbol (MIPS_EFI_SYMBOL_NAME
);
3391 memset ((PTR
) e
, 0, sizeof (struct mips_extra_func_info
));
3392 SYMBOL_NAMESPACE (s
) = LABEL_NAMESPACE
;
3393 SYMBOL_CLASS (s
) = LOC_CONST
;
3394 SYMBOL_TYPE (s
) = mdebug_type_void
;
3395 SYMBOL_VALUE (s
) = (long) e
;
3396 e
->pdr
.framereg
= -1;
3397 add_symbol_to_list (s
, &local_symbols
);
3400 else if (sh
.st
== stLabel
)
3402 if (sh
.index
== indexNil
)
3404 /* This is what the gcc2_compiled and __gnu_compiled_*
3405 show up as. So don't complain. */
3410 /* Handle encoded stab line number. */
3411 valu
+= ANOFFSET (pst
->section_offsets
, SECT_OFF_TEXT (pst
->objfile
));
3412 record_line (current_subfile
, sh
.index
, valu
);
3415 else if (sh
.st
== stProc
|| sh
.st
== stStaticProc
3416 || sh
.st
== stStatic
|| sh
.st
== stEnd
)
3417 /* These are generated by gcc-2.x, do not complain */
3420 complain (&stab_unknown_complaint
, name
);
3423 if (! last_symtab_ended
)
3425 st
= end_symtab (TEXTHIGH (pst
), pst
->objfile
, SECT_OFF_TEXT (pst
->objfile
));
3429 /* Sort the symbol table now, we are done adding symbols to it.
3430 We must do this before parse_procedure calls lookup_symbol. */
3431 sort_symtab_syms (st
);
3433 /* There used to be a call to sort_blocks here, but this should not
3434 be necessary for stabs symtabs. And as sort_blocks modifies the
3435 start address of the GLOBAL_BLOCK to the FIRST_LOCAL_BLOCK,
3436 it did the wrong thing if the first procedure in a file was
3437 generated via asm statements. */
3439 /* Fill in procedure info next. */
3443 struct cleanup
*old_chain
;
3449 pr_block
= (PDR
*) xmalloc (fh
->cpd
* sizeof (PDR
));
3450 old_chain
= make_cleanup (xfree
, pr_block
);
3452 pdr_ptr
= ((char *) debug_info
->external_pdr
3453 + fh
->ipdFirst
* external_pdr_size
);
3454 pdr_end
= pdr_ptr
+ fh
->cpd
* external_pdr_size
;
3458 pdr_ptr
+= external_pdr_size
, pdr_in
++)
3460 (*swap_pdr_in
) (cur_bfd
, pdr_ptr
, pdr_in
);
3462 /* Determine lowest PDR address, the PDRs are not always
3464 if (pdr_in
== pr_block
)
3465 lowest_pdr_addr
= pdr_in
->adr
;
3466 else if (pdr_in
->adr
< lowest_pdr_addr
)
3467 lowest_pdr_addr
= pdr_in
->adr
;
3471 pdr_in_end
= pdr_in
+ fh
->cpd
;
3472 for (; pdr_in
< pdr_in_end
; pdr_in
++)
3473 parse_procedure (pdr_in
, st
, pst
);
3475 do_cleanups (old_chain
);
3480 /* This symbol table contains ordinary ecoff entries. */
3486 /* How many symbols will we need */
3487 /* FIXME, this does not count enum values. */
3488 f_max
= pst
->n_global_syms
+ pst
->n_static_syms
;
3492 st
= new_symtab ("unknown", f_max
, 0, pst
->objfile
);
3496 f_max
+= fh
->csym
+ fh
->cpd
;
3497 maxlines
= 2 * fh
->cline
;
3498 st
= new_symtab (pst
->filename
, 2 * f_max
, maxlines
, pst
->objfile
);
3500 /* The proper language was already determined when building
3501 the psymtab, use it. */
3502 st
->language
= PST_PRIVATE (pst
)->pst_language
;
3505 psymtab_language
= st
->language
;
3507 lines
= LINETABLE (st
);
3509 /* Get a new lexical context */
3511 push_parse_stack ();
3512 top_stack
->cur_st
= st
;
3513 top_stack
->cur_block
= BLOCKVECTOR_BLOCK (BLOCKVECTOR (st
),
3515 BLOCK_START (top_stack
->cur_block
) = TEXTLOW (pst
);
3516 BLOCK_END (top_stack
->cur_block
) = 0;
3517 top_stack
->blocktype
= stFile
;
3518 top_stack
->maxsyms
= 2 * f_max
;
3519 top_stack
->cur_type
= 0;
3520 top_stack
->procadr
= 0;
3521 top_stack
->numargs
= 0;
3522 found_ecoff_debugging_info
= 0;
3529 /* Parse local symbols first */
3530 sym_ptr
= ((char *) debug_info
->external_sym
3531 + fh
->isymBase
* external_sym_size
);
3532 sym_end
= sym_ptr
+ fh
->csym
* external_sym_size
;
3533 while (sym_ptr
< sym_end
)
3538 (*swap_sym_in
) (cur_bfd
, sym_ptr
, &sh
);
3539 c
= parse_symbol (&sh
,
3540 debug_info
->external_aux
+ fh
->iauxBase
,
3541 sym_ptr
, fh
->fBigendian
, pst
->section_offsets
, pst
->objfile
);
3542 sym_ptr
+= c
* external_sym_size
;
3545 /* Linenumbers. At the end, check if we can save memory.
3546 parse_lines has to look ahead an arbitrary number of PDR
3547 structures, so we swap them all first. */
3551 struct cleanup
*old_chain
;
3557 pr_block
= (PDR
*) xmalloc (fh
->cpd
* sizeof (PDR
));
3559 old_chain
= make_cleanup (xfree
, pr_block
);
3561 pdr_ptr
= ((char *) debug_info
->external_pdr
3562 + fh
->ipdFirst
* external_pdr_size
);
3563 pdr_end
= pdr_ptr
+ fh
->cpd
* external_pdr_size
;
3567 pdr_ptr
+= external_pdr_size
, pdr_in
++)
3569 (*swap_pdr_in
) (cur_bfd
, pdr_ptr
, pdr_in
);
3571 /* Determine lowest PDR address, the PDRs are not always
3573 if (pdr_in
== pr_block
)
3574 lowest_pdr_addr
= pdr_in
->adr
;
3575 else if (pdr_in
->adr
< lowest_pdr_addr
)
3576 lowest_pdr_addr
= pdr_in
->adr
;
3579 parse_lines (fh
, pr_block
, lines
, maxlines
, pst
, lowest_pdr_addr
);
3580 if (lines
->nitems
< fh
->cline
)
3581 lines
= shrink_linetable (lines
);
3583 /* Fill in procedure info next. */
3585 pdr_in_end
= pdr_in
+ fh
->cpd
;
3586 for (; pdr_in
< pdr_in_end
; pdr_in
++)
3587 parse_procedure (pdr_in
, 0, pst
);
3589 do_cleanups (old_chain
);
3593 LINETABLE (st
) = lines
;
3595 /* .. and our share of externals.
3596 XXX use the global list to speed up things here. how?
3597 FIXME, Maybe quit once we have found the right number of ext's? */
3598 top_stack
->cur_st
= st
;
3599 top_stack
->cur_block
= BLOCKVECTOR_BLOCK (BLOCKVECTOR (top_stack
->cur_st
),
3601 top_stack
->blocktype
= stFile
;
3603 = (debug_info
->symbolic_header
.isymMax
3604 + debug_info
->symbolic_header
.ipdMax
3605 + debug_info
->symbolic_header
.iextMax
);
3607 ext_ptr
= PST_PRIVATE (pst
)->extern_tab
;
3608 for (i
= PST_PRIVATE (pst
)->extern_count
; --i
>= 0; ext_ptr
++)
3609 parse_external (ext_ptr
, fh
->fBigendian
, pst
->section_offsets
, pst
->objfile
);
3611 /* If there are undefined symbols, tell the user.
3612 The alpha has an undefined symbol for every symbol that is
3613 from a shared library, so tell the user only if verbose is on. */
3614 if (info_verbose
&& n_undef_symbols
)
3616 printf_filtered ("File %s contains %d unresolved references:",
3617 st
->filename
, n_undef_symbols
);
3618 printf_filtered ("\n\t%4d variables\n\t%4d procedures\n\t%4d labels\n",
3619 n_undef_vars
, n_undef_procs
, n_undef_labels
);
3620 n_undef_symbols
= n_undef_labels
= n_undef_vars
= n_undef_procs
= 0;
3627 /* Sort the symbol table now, we are done adding symbols to it. */
3628 sort_symtab_syms (st
);
3633 /* Now link the psymtab and the symtab. */
3636 current_objfile
= NULL
;
3639 /* Ancillary parsing procedures. */
3641 /* Return 1 if the symbol pointed to by SH has a cross reference
3642 to an opaque aggregate type, else 0. */
3645 has_opaque_xref (FDR
*fh
, SYMR
*sh
)
3652 if (sh
->index
== indexNil
)
3655 ax
= debug_info
->external_aux
+ fh
->iauxBase
+ sh
->index
;
3656 (*debug_swap
->swap_tir_in
) (fh
->fBigendian
, &ax
->a_ti
, &tir
);
3657 if (tir
.bt
!= btStruct
&& tir
.bt
!= btUnion
&& tir
.bt
!= btEnum
)
3661 (*debug_swap
->swap_rndx_in
) (fh
->fBigendian
, &ax
->a_rndx
, rn
);
3662 if (rn
->rfd
== 0xfff)
3663 rf
= AUX_GET_ISYM (fh
->fBigendian
, ax
+ 1);
3671 /* Lookup the type at relative index RN. Return it in TPP
3672 if found and in any event come up with its name PNAME.
3673 BIGEND says whether aux symbols are big-endian or not (from fh->fBigendian).
3674 Return value says how many aux symbols we ate. */
3677 cross_ref (int fd
, union aux_ext
*ax
, struct type
**tpp
, enum type_code type_code
, /* Use to alloc new type if none is found. */
3678 char **pname
, int bigend
, char *sym_name
)
3687 struct mdebug_pending
*pend
;
3689 *tpp
= (struct type
*) NULL
;
3691 (*debug_swap
->swap_rndx_in
) (bigend
, &ax
->a_rndx
, rn
);
3693 /* Escape index means 'the next one' */
3694 if (rn
->rfd
== 0xfff)
3697 rf
= AUX_GET_ISYM (bigend
, ax
+ 1);
3704 /* mips cc uses a rf of -1 for opaque struct definitions.
3705 Set TYPE_FLAG_STUB for these types so that check_typedef will
3706 resolve them if the struct gets defined in another compilation unit. */
3709 *pname
= "<undefined>";
3710 *tpp
= init_type (type_code
, 0, 0, (char *) NULL
, current_objfile
);
3711 TYPE_FLAGS (*tpp
) |= TYPE_FLAG_STUB
;
3715 /* mips cc uses an escaped rn->index of 0 for struct return types
3716 of procedures that were compiled without -g. These will always remain
3718 if (rn
->rfd
== 0xfff && rn
->index
== 0)
3720 *pname
= "<undefined>";
3724 /* Find the relative file descriptor and the symbol in it. */
3725 fh
= get_rfd (fd
, rf
);
3726 xref_fd
= fh
- debug_info
->fdr
;
3728 if (rn
->index
>= fh
->csym
)
3730 /* File indirect entry is corrupt. */
3731 *pname
= "<illegal>";
3732 complain (&bad_rfd_entry_complaint
,
3733 sym_name
, xref_fd
, rn
->index
);
3737 /* If we have processed this symbol then we left a forwarding
3738 pointer to the type in the pending list. If not, we`ll put
3739 it in a list of pending types, to be processed later when
3740 the file will be. In any event, we collect the name for the
3743 esh
= ((char *) debug_info
->external_sym
3744 + ((fh
->isymBase
+ rn
->index
)
3745 * debug_swap
->external_sym_size
));
3746 (*debug_swap
->swap_sym_in
) (cur_bfd
, esh
, &sh
);
3748 /* Make sure that this type of cross reference can be handled. */
3749 if ((sh
.sc
!= scInfo
3750 || (sh
.st
!= stBlock
&& sh
.st
!= stTypedef
&& sh
.st
!= stIndirect
3751 && sh
.st
!= stStruct
&& sh
.st
!= stUnion
3752 && sh
.st
!= stEnum
))
3753 && (sh
.st
!= stBlock
|| !SC_IS_COMMON (sh
.sc
)))
3755 /* File indirect entry is corrupt. */
3756 *pname
= "<illegal>";
3757 complain (&bad_rfd_entry_complaint
,
3758 sym_name
, xref_fd
, rn
->index
);
3762 *pname
= debug_info
->ss
+ fh
->issBase
+ sh
.iss
;
3764 pend
= is_pending_symbol (fh
, esh
);
3769 /* We have not yet seen this type. */
3771 if ((sh
.iss
== 0 && sh
.st
== stTypedef
) || sh
.st
== stIndirect
)
3775 /* alpha cc puts out a stTypedef with a sh.iss of zero for
3777 a) forward declarations of structs/unions/enums which are not
3778 defined in this compilation unit.
3779 For these the type will be void. This is a bad design decision
3780 as cross referencing across compilation units is impossible
3781 due to the missing name.
3782 b) forward declarations of structs/unions/enums/typedefs which
3783 are defined later in this file or in another file in the same
3784 compilation unit. Irix5 cc uses a stIndirect symbol for this.
3785 Simply cross reference those again to get the true type.
3786 The forward references are not entered in the pending list and
3787 in the symbol table. */
3789 (*debug_swap
->swap_tir_in
) (bigend
,
3790 &(debug_info
->external_aux
3791 + fh
->iauxBase
+ sh
.index
)->a_ti
,
3793 if (tir
.tq0
!= tqNil
)
3794 complain (&illegal_forward_tq0_complaint
, sym_name
);
3798 *tpp
= init_type (type_code
, 0, 0, (char *) NULL
,
3800 *pname
= "<undefined>";
3807 (debug_info
->external_aux
3808 + fh
->iauxBase
+ sh
.index
+ 1),
3809 tpp
, type_code
, pname
,
3810 fh
->fBigendian
, sym_name
);
3814 /* Follow a forward typedef. This might recursively
3815 call cross_ref till we get a non typedef'ed type.
3816 FIXME: This is not correct behaviour, but gdb currently
3817 cannot handle typedefs without type copying. Type
3818 copying is impossible as we might have mutual forward
3819 references between two files and the copied type would not
3820 get filled in when we later parse its definition. */
3821 *tpp
= parse_type (xref_fd
,
3822 debug_info
->external_aux
+ fh
->iauxBase
,
3826 debug_info
->ss
+ fh
->issBase
+ sh
.iss
);
3827 add_pending (fh
, esh
, *tpp
);
3831 complain (&illegal_forward_bt_complaint
, tir
.bt
, sym_name
);
3832 *tpp
= init_type (type_code
, 0, 0, (char *) NULL
,
3838 else if (sh
.st
== stTypedef
)
3840 /* Parse the type for a normal typedef. This might recursively call
3841 cross_ref till we get a non typedef'ed type.
3842 FIXME: This is not correct behaviour, but gdb currently
3843 cannot handle typedefs without type copying. But type copying is
3844 impossible as we might have mutual forward references between
3845 two files and the copied type would not get filled in when
3846 we later parse its definition. */
3847 *tpp
= parse_type (xref_fd
,
3848 debug_info
->external_aux
+ fh
->iauxBase
,
3852 debug_info
->ss
+ fh
->issBase
+ sh
.iss
);
3856 /* Cross reference to a struct/union/enum which is defined
3857 in another file in the same compilation unit but that file
3858 has not been parsed yet.
3859 Initialize the type only, it will be filled in when
3860 it's definition is parsed. */
3861 *tpp
= init_type (type_code
, 0, 0, (char *) NULL
, current_objfile
);
3863 add_pending (fh
, esh
, *tpp
);
3866 /* We used one auxent normally, two if we got a "next one" rf. */
3871 /* Quick&dirty lookup procedure, to avoid the MI ones that require
3872 keeping the symtab sorted */
3874 static struct symbol
*
3875 mylookup_symbol (char *name
, register struct block
*block
,
3876 namespace_enum
namespace, enum address_class
class)
3882 ALL_BLOCK_SYMBOLS (block
, i
, sym
)
3884 if (SYMBOL_NAME (sym
)[0] == inc
3885 && SYMBOL_NAMESPACE (sym
) == namespace
3886 && SYMBOL_CLASS (sym
) == class
3887 && strcmp (SYMBOL_NAME (sym
), name
) == 0)
3891 block
= BLOCK_SUPERBLOCK (block
);
3893 return mylookup_symbol (name
, block
, namespace, class);
3898 /* Add a new symbol S to a block B.
3899 Infrequently, we will need to reallocate the block to make it bigger.
3900 We only detect this case when adding to top_stack->cur_block, since
3901 that's the only time we know how big the block is. FIXME. */
3904 add_symbol (struct symbol
*s
, struct block
*b
)
3906 int nsyms
= BLOCK_NSYMS (b
)++;
3907 struct block
*origb
;
3908 struct parse_stack
*stackp
;
3910 if (b
== top_stack
->cur_block
&&
3911 nsyms
>= top_stack
->maxsyms
)
3913 complain (&block_overflow_complaint
, SYMBOL_NAME (s
));
3914 /* In this case shrink_block is actually grow_block, since
3915 BLOCK_NSYMS(b) is larger than its current size. */
3917 b
= shrink_block (top_stack
->cur_block
, top_stack
->cur_st
);
3919 /* Now run through the stack replacing pointers to the
3920 original block. shrink_block has already done this
3921 for the blockvector and BLOCK_FUNCTION. */
3922 for (stackp
= top_stack
; stackp
; stackp
= stackp
->next
)
3924 if (stackp
->cur_block
== origb
)
3926 stackp
->cur_block
= b
;
3927 stackp
->maxsyms
= BLOCK_NSYMS (b
);
3931 BLOCK_SYM (b
, nsyms
) = s
;
3934 /* Add a new block B to a symtab S */
3937 add_block (struct block
*b
, struct symtab
*s
)
3939 struct blockvector
*bv
= BLOCKVECTOR (s
);
3941 bv
= (struct blockvector
*) xrealloc ((PTR
) bv
,
3942 (sizeof (struct blockvector
)
3943 + BLOCKVECTOR_NBLOCKS (bv
)
3944 * sizeof (bv
->block
)));
3945 if (bv
!= BLOCKVECTOR (s
))
3946 BLOCKVECTOR (s
) = bv
;
3948 BLOCKVECTOR_BLOCK (bv
, BLOCKVECTOR_NBLOCKS (bv
)++) = b
;
3951 /* Add a new linenumber entry (LINENO,ADR) to a linevector LT.
3952 MIPS' linenumber encoding might need more than one byte
3953 to describe it, LAST is used to detect these continuation lines.
3955 Combining lines with the same line number seems like a bad idea.
3956 E.g: There could be a line number entry with the same line number after the
3957 prologue and GDB should not ignore it (this is a better way to find
3958 a prologue than mips_skip_prologue).
3959 But due to the compressed line table format there are line number entries
3960 for the same line which are needed to bridge the gap to the next
3961 line number entry. These entries have a bogus address info with them
3962 and we are unable to tell them from intended duplicate line number
3964 This is another reason why -ggdb debugging format is preferable. */
3967 add_line (struct linetable
*lt
, int lineno
, CORE_ADDR adr
, int last
)
3969 /* DEC c89 sometimes produces zero linenos which confuse gdb.
3970 Change them to something sensible. */
3974 last
= -2; /* make sure we record first line */
3976 if (last
== lineno
) /* skip continuation lines */
3979 lt
->item
[lt
->nitems
].line
= lineno
;
3980 lt
->item
[lt
->nitems
++].pc
= adr
<< 2;
3984 /* Sorting and reordering procedures */
3986 /* Blocks with a smaller low bound should come first */
3989 compare_blocks (const PTR arg1
, const PTR arg2
)
3991 register int addr_diff
;
3992 struct block
**b1
= (struct block
**) arg1
;
3993 struct block
**b2
= (struct block
**) arg2
;
3995 addr_diff
= (BLOCK_START ((*b1
))) - (BLOCK_START ((*b2
)));
3997 return (BLOCK_END ((*b2
))) - (BLOCK_END ((*b1
)));
4001 /* Sort the blocks of a symtab S.
4002 Reorder the blocks in the blockvector by code-address,
4003 as required by some MI search routines */
4006 sort_blocks (struct symtab
*s
)
4008 struct blockvector
*bv
= BLOCKVECTOR (s
);
4010 if (BLOCKVECTOR_NBLOCKS (bv
) <= 2)
4013 if (BLOCK_END (BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
)) == 0)
4014 BLOCK_START (BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
)) = 0;
4015 if (BLOCK_END (BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
)) == 0)
4016 BLOCK_START (BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
)) = 0;
4020 * This is very unfortunate: normally all functions are compiled in
4021 * the order they are found, but if the file is compiled -O3 things
4022 * are very different. It would be nice to find a reliable test
4023 * to detect -O3 images in advance.
4025 if (BLOCKVECTOR_NBLOCKS (bv
) > 3)
4026 qsort (&BLOCKVECTOR_BLOCK (bv
, FIRST_LOCAL_BLOCK
),
4027 BLOCKVECTOR_NBLOCKS (bv
) - FIRST_LOCAL_BLOCK
,
4028 sizeof (struct block
*),
4032 register CORE_ADDR high
= 0;
4033 register int i
, j
= BLOCKVECTOR_NBLOCKS (bv
);
4035 for (i
= FIRST_LOCAL_BLOCK
; i
< j
; i
++)
4036 if (high
< BLOCK_END (BLOCKVECTOR_BLOCK (bv
, i
)))
4037 high
= BLOCK_END (BLOCKVECTOR_BLOCK (bv
, i
));
4038 BLOCK_END (BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
)) = high
;
4041 BLOCK_START (BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
)) =
4042 BLOCK_START (BLOCKVECTOR_BLOCK (bv
, FIRST_LOCAL_BLOCK
));
4044 BLOCK_START (BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
)) =
4045 BLOCK_START (BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
));
4046 BLOCK_END (BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
)) =
4047 BLOCK_END (BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
));
4051 /* Constructor/restructor/destructor procedures */
4053 /* Allocate a new symtab for NAME. Needs an estimate of how many symbols
4054 MAXSYMS and linenumbers MAXLINES we'll put in it */
4056 static struct symtab
*
4057 new_symtab (char *name
, int maxsyms
, int maxlines
, struct objfile
*objfile
)
4059 struct symtab
*s
= allocate_symtab (name
, objfile
);
4061 LINETABLE (s
) = new_linetable (maxlines
);
4063 /* All symtabs must have at least two blocks */
4064 BLOCKVECTOR (s
) = new_bvect (2);
4065 BLOCKVECTOR_BLOCK (BLOCKVECTOR (s
), GLOBAL_BLOCK
) = new_block (maxsyms
);
4066 BLOCKVECTOR_BLOCK (BLOCKVECTOR (s
), STATIC_BLOCK
) = new_block (maxsyms
);
4067 BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (BLOCKVECTOR (s
), STATIC_BLOCK
)) =
4068 BLOCKVECTOR_BLOCK (BLOCKVECTOR (s
), GLOBAL_BLOCK
);
4070 s
->free_code
= free_linetable
;
4071 s
->debugformat
= obsavestring ("ECOFF", 5,
4072 &objfile
->symbol_obstack
);
4076 /* Allocate a new partial_symtab NAME */
4078 static struct partial_symtab
*
4079 new_psymtab (char *name
, struct objfile
*objfile
)
4081 struct partial_symtab
*psymtab
;
4083 psymtab
= allocate_psymtab (name
, objfile
);
4084 psymtab
->section_offsets
= objfile
->section_offsets
;
4086 /* Keep a backpointer to the file's symbols */
4088 psymtab
->read_symtab_private
= ((char *)
4089 obstack_alloc (&objfile
->psymbol_obstack
,
4090 sizeof (struct symloc
)));
4091 memset ((PTR
) psymtab
->read_symtab_private
, 0, sizeof (struct symloc
));
4092 CUR_BFD (psymtab
) = cur_bfd
;
4093 DEBUG_SWAP (psymtab
) = debug_swap
;
4094 DEBUG_INFO (psymtab
) = debug_info
;
4095 PENDING_LIST (psymtab
) = pending_list
;
4097 /* The way to turn this into a symtab is to call... */
4098 psymtab
->read_symtab
= mdebug_psymtab_to_symtab
;
4103 /* Allocate a linetable array of the given SIZE. Since the struct
4104 already includes one item, we subtract one when calculating the
4105 proper size to allocate. */
4107 static struct linetable
*
4108 new_linetable (int size
)
4110 struct linetable
*l
;
4112 size
= (size
- 1) * sizeof (l
->item
) + sizeof (struct linetable
);
4113 l
= (struct linetable
*) xmalloc (size
);
4118 /* Oops, too big. Shrink it. This was important with the 2.4 linetables,
4119 I am not so sure about the 3.4 ones.
4121 Since the struct linetable already includes one item, we subtract one when
4122 calculating the proper size to allocate. */
4124 static struct linetable
*
4125 shrink_linetable (struct linetable
*lt
)
4128 return (struct linetable
*) xrealloc ((PTR
) lt
,
4129 (sizeof (struct linetable
)
4131 * sizeof (lt
->item
))));
4134 /* Allocate and zero a new blockvector of NBLOCKS blocks. */
4136 static struct blockvector
*
4137 new_bvect (int nblocks
)
4139 struct blockvector
*bv
;
4142 size
= sizeof (struct blockvector
) + nblocks
* sizeof (struct block
*);
4143 bv
= (struct blockvector
*) xzalloc (size
);
4145 BLOCKVECTOR_NBLOCKS (bv
) = nblocks
;
4150 /* Allocate and zero a new block of MAXSYMS symbols */
4152 static struct block
*
4153 new_block (int maxsyms
)
4155 int size
= sizeof (struct block
) + (maxsyms
- 1) * sizeof (struct symbol
*);
4157 return (struct block
*) xzalloc (size
);
4160 /* Ooops, too big. Shrink block B in symtab S to its minimal size.
4161 Shrink_block can also be used by add_symbol to grow a block. */
4163 static struct block
*
4164 shrink_block (struct block
*b
, struct symtab
*s
)
4167 struct blockvector
*bv
= BLOCKVECTOR (s
);
4170 /* Just reallocate it and fix references to the old one */
4172 new = (struct block
*) xrealloc ((PTR
) b
,
4173 (sizeof (struct block
)
4174 + ((BLOCK_NSYMS (b
) - 1)
4175 * sizeof (struct symbol
*))));
4177 /* Should chase pointers to old one. Fortunately, that`s just
4178 the block`s function and inferior blocks */
4179 if (BLOCK_FUNCTION (new) && SYMBOL_BLOCK_VALUE (BLOCK_FUNCTION (new)) == b
)
4180 SYMBOL_BLOCK_VALUE (BLOCK_FUNCTION (new)) = new;
4181 for (i
= 0; i
< BLOCKVECTOR_NBLOCKS (bv
); i
++)
4182 if (BLOCKVECTOR_BLOCK (bv
, i
) == b
)
4183 BLOCKVECTOR_BLOCK (bv
, i
) = new;
4184 else if (BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (bv
, i
)) == b
)
4185 BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (bv
, i
)) = new;
4189 /* Create a new symbol with printname NAME */
4191 static struct symbol
*
4192 new_symbol (char *name
)
4194 struct symbol
*s
= ((struct symbol
*)
4195 obstack_alloc (¤t_objfile
->symbol_obstack
,
4196 sizeof (struct symbol
)));
4198 memset ((PTR
) s
, 0, sizeof (*s
));
4199 SYMBOL_NAME (s
) = obsavestring (name
, strlen (name
),
4200 ¤t_objfile
->symbol_obstack
);
4201 SYMBOL_LANGUAGE (s
) = psymtab_language
;
4202 SYMBOL_INIT_DEMANGLED_NAME (s
, ¤t_objfile
->symbol_obstack
);
4206 /* Create a new type with printname NAME */
4208 static struct type
*
4209 new_type (char *name
)
4213 t
= alloc_type (current_objfile
);
4214 TYPE_NAME (t
) = name
;
4215 TYPE_CPLUS_SPECIFIC (t
) = (struct cplus_struct_type
*) &cplus_struct_default
;
4219 /* Read ECOFF debugging information from a BFD section. This is
4220 called from elfread.c. It parses the section into a
4221 ecoff_debug_info struct, and then lets the rest of the file handle
4225 elfmdebug_build_psymtabs (struct objfile
*objfile
,
4226 const struct ecoff_debug_swap
*swap
, asection
*sec
)
4228 bfd
*abfd
= objfile
->obfd
;
4229 struct ecoff_debug_info
*info
;
4231 info
= ((struct ecoff_debug_info
*)
4232 obstack_alloc (&objfile
->psymbol_obstack
,
4233 sizeof (struct ecoff_debug_info
)));
4235 if (!(*swap
->read_debug_info
) (abfd
, sec
, info
))
4236 error ("Error reading ECOFF debugging information: %s",
4237 bfd_errmsg (bfd_get_error ()));
4239 mdebug_build_psymtabs (objfile
, swap
, info
);
4243 /* Things used for calling functions in the inferior.
4244 These functions are exported to our companion
4245 mips-tdep.c file and are here because they play
4246 with the symbol-table explicitly. */
4248 /* Sigtramp: make sure we have all the necessary information
4249 about the signal trampoline code. Since the official code
4250 from MIPS does not do so, we make up that information ourselves.
4251 If they fix the library (unlikely) this code will neutralize itself. */
4253 /* FIXME: This function is called only by mips-tdep.c. It needs to be
4254 here because it calls functions defined in this file, but perhaps
4255 this could be handled in a better way. Only compile it in when
4256 tm-mips.h is included. */
4261 fixup_sigtramp (void)
4265 struct block
*b
, *b0
= NULL
;
4267 sigtramp_address
= -1;
4269 /* We have to handle the following cases here:
4270 a) The Mips library has a sigtramp label within sigvec.
4271 b) Irix has a _sigtramp which we want to use, but it also has sigvec. */
4272 s
= lookup_symbol ("sigvec", 0, VAR_NAMESPACE
, 0, NULL
);
4275 b0
= SYMBOL_BLOCK_VALUE (s
);
4276 s
= lookup_symbol ("sigtramp", b0
, VAR_NAMESPACE
, 0, NULL
);
4280 /* No sigvec or no sigtramp inside sigvec, try _sigtramp. */
4281 s
= lookup_symbol ("_sigtramp", 0, VAR_NAMESPACE
, 0, NULL
);
4284 /* But maybe this program uses its own version of sigvec */
4288 /* Did we or MIPSco fix the library ? */
4289 if (SYMBOL_CLASS (s
) == LOC_BLOCK
)
4291 sigtramp_address
= BLOCK_START (SYMBOL_BLOCK_VALUE (s
));
4292 sigtramp_end
= BLOCK_END (SYMBOL_BLOCK_VALUE (s
));
4296 sigtramp_address
= SYMBOL_VALUE (s
);
4297 sigtramp_end
= sigtramp_address
+ 0x88; /* black magic */
4299 /* But what symtab does it live in ? */
4300 st
= find_pc_symtab (SYMBOL_VALUE (s
));
4303 * Ok, there goes the fix: turn it into a procedure, with all the
4304 * needed info. Note we make it a nested procedure of sigvec,
4305 * which is the way the (assembly) code is actually written.
4307 SYMBOL_NAMESPACE (s
) = VAR_NAMESPACE
;
4308 SYMBOL_CLASS (s
) = LOC_BLOCK
;
4309 SYMBOL_TYPE (s
) = init_type (TYPE_CODE_FUNC
, 4, 0, (char *) NULL
,
4311 TYPE_TARGET_TYPE (SYMBOL_TYPE (s
)) = mdebug_type_void
;
4313 /* Need a block to allocate MIPS_EFI_SYMBOL_NAME in */
4315 SYMBOL_BLOCK_VALUE (s
) = b
;
4316 BLOCK_START (b
) = sigtramp_address
;
4317 BLOCK_END (b
) = sigtramp_end
;
4318 BLOCK_FUNCTION (b
) = s
;
4319 BLOCK_SUPERBLOCK (b
) = BLOCK_SUPERBLOCK (b0
);
4323 /* Make a MIPS_EFI_SYMBOL_NAME entry for it */
4325 struct mips_extra_func_info
*e
=
4326 ((struct mips_extra_func_info
*)
4327 xzalloc (sizeof (struct mips_extra_func_info
)));
4329 e
->numargs
= 0; /* the kernel thinks otherwise */
4330 e
->pdr
.frameoffset
= 32;
4331 e
->pdr
.framereg
= SP_REGNUM
;
4332 /* Note that setting pcreg is no longer strictly necessary as
4333 mips_frame_saved_pc is now aware of signal handler frames. */
4334 e
->pdr
.pcreg
= PC_REGNUM
;
4335 e
->pdr
.regmask
= -2;
4336 /* Offset to saved r31, in the sigtramp case the saved registers
4337 are above the frame in the sigcontext.
4338 We have 4 alignment bytes, 12 bytes for onstack, mask and pc,
4339 32 * 4 bytes for the general registers, 12 bytes for mdhi, mdlo, ownedfp
4340 and 32 * 4 bytes for the floating point registers. */
4341 e
->pdr
.regoffset
= 4 + 12 + 31 * 4;
4342 e
->pdr
.fregmask
= -1;
4343 /* Offset to saved f30 (first saved *double* register). */
4344 e
->pdr
.fregoffset
= 4 + 12 + 32 * 4 + 12 + 30 * 4;
4345 e
->pdr
.isym
= (long) s
;
4346 e
->pdr
.adr
= sigtramp_address
;
4348 current_objfile
= st
->objfile
; /* Keep new_symbol happy */
4349 s
= new_symbol (MIPS_EFI_SYMBOL_NAME
);
4350 SYMBOL_VALUE (s
) = (long) e
;
4351 SYMBOL_NAMESPACE (s
) = LABEL_NAMESPACE
;
4352 SYMBOL_CLASS (s
) = LOC_CONST
;
4353 SYMBOL_TYPE (s
) = mdebug_type_void
;
4354 current_objfile
= NULL
;
4357 BLOCK_SYM (b
, BLOCK_NSYMS (b
)++) = s
;
4360 #endif /* TM_MIPS_H */
4363 _initialize_mdebugread (void)
4366 init_type (TYPE_CODE_VOID
, 1,
4368 "void", (struct objfile
*) NULL
);
4370 init_type (TYPE_CODE_INT
, 1,
4372 "char", (struct objfile
*) NULL
);
4373 mdebug_type_unsigned_char
=
4374 init_type (TYPE_CODE_INT
, 1,
4376 "unsigned char", (struct objfile
*) NULL
);
4378 init_type (TYPE_CODE_INT
, 2,
4380 "short", (struct objfile
*) NULL
);
4381 mdebug_type_unsigned_short
=
4382 init_type (TYPE_CODE_INT
, 2,
4384 "unsigned short", (struct objfile
*) NULL
);
4385 mdebug_type_int_32
=
4386 init_type (TYPE_CODE_INT
, 4,
4388 "int", (struct objfile
*) NULL
);
4389 mdebug_type_unsigned_int_32
=
4390 init_type (TYPE_CODE_INT
, 4,
4392 "unsigned int", (struct objfile
*) NULL
);
4393 mdebug_type_int_64
=
4394 init_type (TYPE_CODE_INT
, 8,
4396 "int", (struct objfile
*) NULL
);
4397 mdebug_type_unsigned_int_64
=
4398 init_type (TYPE_CODE_INT
, 8,
4400 "unsigned int", (struct objfile
*) NULL
);
4401 mdebug_type_long_32
=
4402 init_type (TYPE_CODE_INT
, 4,
4404 "long", (struct objfile
*) NULL
);
4405 mdebug_type_unsigned_long_32
=
4406 init_type (TYPE_CODE_INT
, 4,
4408 "unsigned long", (struct objfile
*) NULL
);
4409 mdebug_type_long_64
=
4410 init_type (TYPE_CODE_INT
, 8,
4412 "long", (struct objfile
*) NULL
);
4413 mdebug_type_unsigned_long_64
=
4414 init_type (TYPE_CODE_INT
, 8,
4416 "unsigned long", (struct objfile
*) NULL
);
4417 mdebug_type_long_long_64
=
4418 init_type (TYPE_CODE_INT
, 8,
4420 "long long", (struct objfile
*) NULL
);
4421 mdebug_type_unsigned_long_long_64
=
4422 init_type (TYPE_CODE_INT
, 8,
4424 "unsigned long long", (struct objfile
*) NULL
);
4425 mdebug_type_adr_32
=
4426 init_type (TYPE_CODE_PTR
, 4,
4428 "adr_32", (struct objfile
*) NULL
);
4429 TYPE_TARGET_TYPE (mdebug_type_adr_32
) = mdebug_type_void
;
4430 mdebug_type_adr_64
=
4431 init_type (TYPE_CODE_PTR
, 8,
4433 "adr_64", (struct objfile
*) NULL
);
4434 TYPE_TARGET_TYPE (mdebug_type_adr_64
) = mdebug_type_void
;
4436 init_type (TYPE_CODE_FLT
, TARGET_FLOAT_BIT
/ TARGET_CHAR_BIT
,
4438 "float", (struct objfile
*) NULL
);
4439 mdebug_type_double
=
4440 init_type (TYPE_CODE_FLT
, TARGET_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
4442 "double", (struct objfile
*) NULL
);
4443 mdebug_type_complex
=
4444 init_type (TYPE_CODE_COMPLEX
, 2 * TARGET_FLOAT_BIT
/ TARGET_CHAR_BIT
,
4446 "complex", (struct objfile
*) NULL
);
4447 TYPE_TARGET_TYPE (mdebug_type_complex
) = mdebug_type_float
;
4448 mdebug_type_double_complex
=
4449 init_type (TYPE_CODE_COMPLEX
, 2 * TARGET_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
4451 "double complex", (struct objfile
*) NULL
);
4452 TYPE_TARGET_TYPE (mdebug_type_double_complex
) = mdebug_type_double
;
4454 /* Is a "string" the way btString means it the same as TYPE_CODE_STRING?
4456 mdebug_type_string
=
4457 init_type (TYPE_CODE_STRING
,
4458 TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
4460 (struct objfile
*) NULL
);
4462 /* We use TYPE_CODE_INT to print these as integers. Does this do any
4463 good? Would we be better off with TYPE_CODE_ERROR? Should
4464 TYPE_CODE_ERROR print things in hex if it knows the size? */
4465 mdebug_type_fixed_dec
=
4466 init_type (TYPE_CODE_INT
,
4467 TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
4469 (struct objfile
*) NULL
);
4471 mdebug_type_float_dec
=
4472 init_type (TYPE_CODE_ERROR
,
4473 TARGET_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
4474 0, "floating decimal",
4475 (struct objfile
*) NULL
);
4477 nodebug_func_symbol_type
= init_type (TYPE_CODE_FUNC
, 1, 0,
4478 "<function, no debug info>", NULL
);
4479 TYPE_TARGET_TYPE (nodebug_func_symbol_type
) = mdebug_type_int
;
4480 nodebug_var_symbol_type
=
4481 init_type (TYPE_CODE_INT
, TARGET_INT_BIT
/ HOST_CHAR_BIT
, 0,
4482 "<variable, no debug info>", NULL
);