1 |
104 |
markom |
/* Read a symbol table in ECOFF format (Third-Eye).
|
2 |
|
|
Copyright 1986, 87, 89, 90, 91, 92, 93, 94, 95, 96, 97, 1998
|
3 |
|
|
Free Software Foundation, Inc.
|
4 |
|
|
Original version contributed by Alessandro Forin (af@cs.cmu.edu) at
|
5 |
|
|
CMU. Major work by Per Bothner, John Gilmore and Ian Lance Taylor
|
6 |
|
|
at Cygnus Support.
|
7 |
|
|
|
8 |
|
|
This file is part of GDB.
|
9 |
|
|
|
10 |
|
|
This program is free software; you can redistribute it and/or modify
|
11 |
|
|
it under the terms of the GNU General Public License as published by
|
12 |
|
|
the Free Software Foundation; either version 2 of the License, or
|
13 |
|
|
(at your option) any later version.
|
14 |
|
|
|
15 |
|
|
This program is distributed in the hope that it will be useful,
|
16 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
|
|
GNU General Public License for more details.
|
19 |
|
|
|
20 |
|
|
You should have received a copy of the GNU General Public License
|
21 |
|
|
along with this program; if not, write to the Free Software
|
22 |
|
|
Foundation, Inc., 59 Temple Place - Suite 330,
|
23 |
|
|
Boston, MA 02111-1307, USA. */
|
24 |
|
|
|
25 |
|
|
/* This module provides the function mdebug_build_psymtabs. It reads
|
26 |
|
|
ECOFF debugging information into partial symbol tables. The
|
27 |
|
|
debugging information is read from two structures. A struct
|
28 |
|
|
ecoff_debug_swap includes the sizes of each ECOFF structure and
|
29 |
|
|
swapping routines; these are fixed for a particular target. A
|
30 |
|
|
struct ecoff_debug_info points to the debugging information for a
|
31 |
|
|
particular object file.
|
32 |
|
|
|
33 |
|
|
ECOFF symbol tables are mostly written in the byte order of the
|
34 |
|
|
target machine. However, one section of the table (the auxiliary
|
35 |
|
|
symbol information) is written in the host byte order. There is a
|
36 |
|
|
bit in the other symbol info which describes which host byte order
|
37 |
|
|
was used. ECOFF thereby takes the trophy from Intel `b.out' for
|
38 |
|
|
the most brain-dead adaptation of a file format to byte order.
|
39 |
|
|
|
40 |
|
|
This module can read all four of the known byte-order combinations,
|
41 |
|
|
on any type of host. */
|
42 |
|
|
|
43 |
|
|
#include "defs.h"
|
44 |
|
|
#include "symtab.h"
|
45 |
|
|
#include "gdbtypes.h"
|
46 |
|
|
#include "gdbcore.h"
|
47 |
|
|
#include "symfile.h"
|
48 |
|
|
#include "objfiles.h"
|
49 |
|
|
#include "obstack.h"
|
50 |
|
|
#include "buildsym.h"
|
51 |
|
|
#include "stabsread.h"
|
52 |
|
|
#include "complaints.h"
|
53 |
|
|
#include "demangle.h"
|
54 |
|
|
|
55 |
|
|
/* These are needed if the tm.h file does not contain the necessary
|
56 |
|
|
mips specific definitions. */
|
57 |
|
|
|
58 |
|
|
#ifndef MIPS_EFI_SYMBOL_NAME
|
59 |
|
|
#define MIPS_EFI_SYMBOL_NAME "__GDB_EFI_INFO__"
|
60 |
|
|
extern void ecoff_relocate_efi PARAMS ((struct symbol *, CORE_ADDR));
|
61 |
|
|
#include "coff/sym.h"
|
62 |
|
|
#include "coff/symconst.h"
|
63 |
|
|
typedef struct mips_extra_func_info
|
64 |
|
|
{
|
65 |
|
|
long numargs;
|
66 |
|
|
PDR pdr;
|
67 |
|
|
}
|
68 |
|
|
*mips_extra_func_info_t;
|
69 |
|
|
#ifndef RA_REGNUM
|
70 |
|
|
#define RA_REGNUM 0
|
71 |
|
|
#endif
|
72 |
|
|
#endif
|
73 |
|
|
|
74 |
|
|
#ifdef USG
|
75 |
|
|
#include <sys/types.h>
|
76 |
|
|
#endif
|
77 |
|
|
|
78 |
|
|
#include "gdb_stat.h"
|
79 |
|
|
#include "gdb_string.h"
|
80 |
|
|
|
81 |
|
|
#include "gdb-stabs.h"
|
82 |
|
|
|
83 |
|
|
#include "bfd.h"
|
84 |
|
|
|
85 |
|
|
#include "coff/ecoff.h" /* COFF-like aspects of ecoff files */
|
86 |
|
|
|
87 |
|
|
#include "libaout.h" /* Private BFD a.out information. */
|
88 |
|
|
#include "aout/aout64.h"
|
89 |
|
|
#include "aout/stab_gnu.h" /* STABS information */
|
90 |
|
|
|
91 |
|
|
#include "expression.h"
|
92 |
|
|
#include "language.h" /* Needed inside partial-stab.h */
|
93 |
|
|
|
94 |
|
|
extern void _initialize_mdebugread PARAMS ((void));
|
95 |
|
|
|
96 |
|
|
/* Provide a default mapping from a ecoff register number to a gdb REGNUM. */
|
97 |
|
|
#ifndef ECOFF_REG_TO_REGNUM
|
98 |
|
|
#define ECOFF_REG_TO_REGNUM(num) (num)
|
99 |
|
|
#endif
|
100 |
|
|
|
101 |
|
|
/* Provide a way to test if we have both ECOFF and ELF symbol tables.
|
102 |
|
|
We use this define in order to know whether we should override a
|
103 |
|
|
symbol's ECOFF section with its ELF section. This is necessary in
|
104 |
|
|
case the symbol's ELF section could not be represented in ECOFF. */
|
105 |
|
|
#define ECOFF_IN_ELF(bfd) (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
|
106 |
|
|
&& bfd_get_section_by_name (bfd, ".mdebug") != NULL)
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
/* We put a pointer to this structure in the read_symtab_private field
|
110 |
|
|
of the psymtab. */
|
111 |
|
|
|
112 |
|
|
struct symloc
|
113 |
|
|
{
|
114 |
|
|
/* Index of the FDR that this psymtab represents. */
|
115 |
|
|
int fdr_idx;
|
116 |
|
|
/* The BFD that the psymtab was created from. */
|
117 |
|
|
bfd *cur_bfd;
|
118 |
|
|
const struct ecoff_debug_swap *debug_swap;
|
119 |
|
|
struct ecoff_debug_info *debug_info;
|
120 |
|
|
struct mdebug_pending **pending_list;
|
121 |
|
|
/* Pointer to external symbols for this file. */
|
122 |
|
|
EXTR *extern_tab;
|
123 |
|
|
/* Size of extern_tab. */
|
124 |
|
|
int extern_count;
|
125 |
|
|
enum language pst_language;
|
126 |
|
|
};
|
127 |
|
|
|
128 |
|
|
#define PST_PRIVATE(p) ((struct symloc *)(p)->read_symtab_private)
|
129 |
|
|
#define FDR_IDX(p) (PST_PRIVATE(p)->fdr_idx)
|
130 |
|
|
#define CUR_BFD(p) (PST_PRIVATE(p)->cur_bfd)
|
131 |
|
|
#define DEBUG_SWAP(p) (PST_PRIVATE(p)->debug_swap)
|
132 |
|
|
#define DEBUG_INFO(p) (PST_PRIVATE(p)->debug_info)
|
133 |
|
|
#define PENDING_LIST(p) (PST_PRIVATE(p)->pending_list)
|
134 |
|
|
|
135 |
|
|
#define SC_IS_TEXT(sc) ((sc) == scText \
|
136 |
|
|
|| (sc) == scRConst \
|
137 |
|
|
|| (sc) == scInit \
|
138 |
|
|
|| (sc) == scFini)
|
139 |
|
|
#define SC_IS_DATA(sc) ((sc) == scData \
|
140 |
|
|
|| (sc) == scSData \
|
141 |
|
|
|| (sc) == scRData \
|
142 |
|
|
|| (sc) == scPData \
|
143 |
|
|
|| (sc) == scXData)
|
144 |
|
|
#define SC_IS_COMMON(sc) ((sc) == scCommon || (sc) == scSCommon)
|
145 |
|
|
#define SC_IS_BSS(sc) ((sc) == scBss || (sc) == scSBss)
|
146 |
|
|
#define SC_IS_UNDEF(sc) ((sc) == scUndefined || (sc) == scSUndefined)
|
147 |
|
|
|
148 |
|
|
|
149 |
|
|
/* Things we import explicitly from other modules */
|
150 |
|
|
|
151 |
|
|
extern int info_verbose;
|
152 |
|
|
|
153 |
|
|
/* Various complaints about symbol reading that don't abort the process */
|
154 |
|
|
|
155 |
|
|
static struct complaint bad_file_number_complaint =
|
156 |
|
|
{"bad file number %d", 0, 0};
|
157 |
|
|
|
158 |
|
|
static struct complaint index_complaint =
|
159 |
|
|
{"bad aux index at symbol %s", 0, 0};
|
160 |
|
|
|
161 |
|
|
static struct complaint aux_index_complaint =
|
162 |
|
|
{"bad proc end in aux found from symbol %s", 0, 0};
|
163 |
|
|
|
164 |
|
|
static struct complaint block_index_complaint =
|
165 |
|
|
{"bad aux index at block symbol %s", 0, 0};
|
166 |
|
|
|
167 |
|
|
static struct complaint unknown_ext_complaint =
|
168 |
|
|
{"unknown external symbol %s", 0, 0};
|
169 |
|
|
|
170 |
|
|
static struct complaint unknown_sym_complaint =
|
171 |
|
|
{"unknown local symbol %s", 0, 0};
|
172 |
|
|
|
173 |
|
|
static struct complaint unknown_st_complaint =
|
174 |
|
|
{"with type %d", 0, 0};
|
175 |
|
|
|
176 |
|
|
static struct complaint block_overflow_complaint =
|
177 |
|
|
{"block containing %s overfilled", 0, 0};
|
178 |
|
|
|
179 |
|
|
static struct complaint basic_type_complaint =
|
180 |
|
|
{"cannot map ECOFF basic type 0x%x for %s", 0, 0};
|
181 |
|
|
|
182 |
|
|
static struct complaint unknown_type_qual_complaint =
|
183 |
|
|
{"unknown type qualifier 0x%x", 0, 0};
|
184 |
|
|
|
185 |
|
|
static struct complaint array_index_type_complaint =
|
186 |
|
|
{"illegal array index type for %s, assuming int", 0, 0};
|
187 |
|
|
|
188 |
|
|
static struct complaint bad_tag_guess_complaint =
|
189 |
|
|
{"guessed tag type of %s incorrectly", 0, 0};
|
190 |
|
|
|
191 |
|
|
static struct complaint block_member_complaint =
|
192 |
|
|
{"declaration block contains unhandled symbol type %d", 0, 0};
|
193 |
|
|
|
194 |
|
|
static struct complaint stEnd_complaint =
|
195 |
|
|
{"stEnd with storage class %d not handled", 0, 0};
|
196 |
|
|
|
197 |
|
|
static struct complaint unknown_mdebug_symtype_complaint =
|
198 |
|
|
{"unknown symbol type 0x%x", 0, 0};
|
199 |
|
|
|
200 |
|
|
static struct complaint stab_unknown_complaint =
|
201 |
|
|
{"unknown stabs symbol %s", 0, 0};
|
202 |
|
|
|
203 |
|
|
static struct complaint pdr_for_nonsymbol_complaint =
|
204 |
|
|
{"PDR for %s, but no symbol", 0, 0};
|
205 |
|
|
|
206 |
|
|
static struct complaint pdr_static_symbol_complaint =
|
207 |
|
|
{"can't handle PDR for static proc at 0x%lx", 0, 0};
|
208 |
|
|
|
209 |
|
|
static struct complaint bad_setjmp_pdr_complaint =
|
210 |
|
|
{"fixing bad setjmp PDR from libc", 0, 0};
|
211 |
|
|
|
212 |
|
|
static struct complaint bad_fbitfield_complaint =
|
213 |
|
|
{"can't handle TIR fBitfield for %s", 0, 0};
|
214 |
|
|
|
215 |
|
|
static struct complaint bad_continued_complaint =
|
216 |
|
|
{"illegal TIR continued for %s", 0, 0};
|
217 |
|
|
|
218 |
|
|
static struct complaint bad_rfd_entry_complaint =
|
219 |
|
|
{"bad rfd entry for %s: file %d, index %d", 0, 0};
|
220 |
|
|
|
221 |
|
|
static struct complaint unexpected_type_code_complaint =
|
222 |
|
|
{"unexpected type code for %s", 0, 0};
|
223 |
|
|
|
224 |
|
|
static struct complaint unable_to_cross_ref_complaint =
|
225 |
|
|
{"unable to cross ref btTypedef for %s", 0, 0};
|
226 |
|
|
|
227 |
|
|
static struct complaint bad_indirect_xref_complaint =
|
228 |
|
|
{"unable to cross ref btIndirect for %s", 0, 0};
|
229 |
|
|
|
230 |
|
|
static struct complaint illegal_forward_tq0_complaint =
|
231 |
|
|
{"illegal tq0 in forward typedef for %s", 0, 0};
|
232 |
|
|
|
233 |
|
|
static struct complaint illegal_forward_bt_complaint =
|
234 |
|
|
{"illegal bt %d in forward typedef for %s", 0, 0};
|
235 |
|
|
|
236 |
|
|
static struct complaint bad_linetable_guess_complaint =
|
237 |
|
|
{"guessed size of linetable for %s incorrectly", 0, 0};
|
238 |
|
|
|
239 |
|
|
static struct complaint bad_ext_ifd_complaint =
|
240 |
|
|
{"bad ifd for external symbol: %d (max %d)", 0, 0};
|
241 |
|
|
|
242 |
|
|
static struct complaint bad_ext_iss_complaint =
|
243 |
|
|
{"bad iss for external symbol: %ld (max %ld)", 0, 0};
|
244 |
|
|
|
245 |
|
|
/* Macros and extra defs */
|
246 |
|
|
|
247 |
|
|
/* Puns: hard to find whether -g was used and how */
|
248 |
|
|
|
249 |
|
|
#define MIN_GLEVEL GLEVEL_0
|
250 |
|
|
#define compare_glevel(a,b) \
|
251 |
|
|
(((a) == GLEVEL_3) ? ((b) < GLEVEL_3) : \
|
252 |
|
|
((b) == GLEVEL_3) ? -1 : (int)((b) - (a)))
|
253 |
|
|
|
254 |
|
|
/* Things that really are local to this module */
|
255 |
|
|
|
256 |
|
|
/* Remember what we deduced to be the source language of this psymtab. */
|
257 |
|
|
|
258 |
|
|
static enum language psymtab_language = language_unknown;
|
259 |
|
|
|
260 |
|
|
/* Current BFD. */
|
261 |
|
|
|
262 |
|
|
static bfd *cur_bfd;
|
263 |
|
|
|
264 |
|
|
/* How to parse debugging information for CUR_BFD. */
|
265 |
|
|
|
266 |
|
|
static const struct ecoff_debug_swap *debug_swap;
|
267 |
|
|
|
268 |
|
|
/* Pointers to debugging information for CUR_BFD. */
|
269 |
|
|
|
270 |
|
|
static struct ecoff_debug_info *debug_info;
|
271 |
|
|
|
272 |
|
|
/* Pointer to current file decriptor record, and its index */
|
273 |
|
|
|
274 |
|
|
static FDR *cur_fdr;
|
275 |
|
|
static int cur_fd;
|
276 |
|
|
|
277 |
|
|
/* Index of current symbol */
|
278 |
|
|
|
279 |
|
|
static int cur_sdx;
|
280 |
|
|
|
281 |
|
|
/* Note how much "debuggable" this image is. We would like
|
282 |
|
|
to see at least one FDR with full symbols */
|
283 |
|
|
|
284 |
|
|
static int max_gdbinfo;
|
285 |
|
|
static int max_glevel;
|
286 |
|
|
|
287 |
|
|
/* When examining .o files, report on undefined symbols */
|
288 |
|
|
|
289 |
|
|
static int n_undef_symbols, n_undef_labels, n_undef_vars, n_undef_procs;
|
290 |
|
|
|
291 |
|
|
/* Pseudo symbol to use when putting stabs into the symbol table. */
|
292 |
|
|
|
293 |
|
|
static char stabs_symbol[] = STABS_SYMBOL;
|
294 |
|
|
|
295 |
|
|
/* Types corresponding to mdebug format bt* basic types. */
|
296 |
|
|
|
297 |
|
|
static struct type *mdebug_type_void;
|
298 |
|
|
static struct type *mdebug_type_char;
|
299 |
|
|
static struct type *mdebug_type_short;
|
300 |
|
|
static struct type *mdebug_type_int_32;
|
301 |
|
|
#define mdebug_type_int mdebug_type_int_32
|
302 |
|
|
static struct type *mdebug_type_int_64;
|
303 |
|
|
static struct type *mdebug_type_long_32;
|
304 |
|
|
static struct type *mdebug_type_long_64;
|
305 |
|
|
static struct type *mdebug_type_long_long_64;
|
306 |
|
|
static struct type *mdebug_type_unsigned_char;
|
307 |
|
|
static struct type *mdebug_type_unsigned_short;
|
308 |
|
|
static struct type *mdebug_type_unsigned_int_32;
|
309 |
|
|
static struct type *mdebug_type_unsigned_int_64;
|
310 |
|
|
static struct type *mdebug_type_unsigned_long_32;
|
311 |
|
|
static struct type *mdebug_type_unsigned_long_64;
|
312 |
|
|
static struct type *mdebug_type_unsigned_long_long_64;
|
313 |
|
|
static struct type *mdebug_type_adr_32;
|
314 |
|
|
static struct type *mdebug_type_adr_64;
|
315 |
|
|
static struct type *mdebug_type_float;
|
316 |
|
|
static struct type *mdebug_type_double;
|
317 |
|
|
static struct type *mdebug_type_complex;
|
318 |
|
|
static struct type *mdebug_type_double_complex;
|
319 |
|
|
static struct type *mdebug_type_fixed_dec;
|
320 |
|
|
static struct type *mdebug_type_float_dec;
|
321 |
|
|
static struct type *mdebug_type_string;
|
322 |
|
|
|
323 |
|
|
/* Types for symbols from files compiled without debugging info. */
|
324 |
|
|
|
325 |
|
|
static struct type *nodebug_func_symbol_type;
|
326 |
|
|
static struct type *nodebug_var_symbol_type;
|
327 |
|
|
|
328 |
|
|
/* Nonzero if we have seen ecoff debugging info for a file. */
|
329 |
|
|
|
330 |
|
|
static int found_ecoff_debugging_info;
|
331 |
|
|
|
332 |
|
|
/* Forward declarations */
|
333 |
|
|
|
334 |
|
|
static void
|
335 |
|
|
add_pending PARAMS ((FDR *, char *, struct type *));
|
336 |
|
|
|
337 |
|
|
static struct mdebug_pending *
|
338 |
|
|
is_pending_symbol PARAMS ((FDR *, char *));
|
339 |
|
|
|
340 |
|
|
static void
|
341 |
|
|
pop_parse_stack PARAMS ((void));
|
342 |
|
|
|
343 |
|
|
static void
|
344 |
|
|
push_parse_stack PARAMS ((void));
|
345 |
|
|
|
346 |
|
|
static char *
|
347 |
|
|
fdr_name PARAMS ((FDR *));
|
348 |
|
|
|
349 |
|
|
static void
|
350 |
|
|
mdebug_psymtab_to_symtab PARAMS ((struct partial_symtab *));
|
351 |
|
|
|
352 |
|
|
static int
|
353 |
|
|
upgrade_type PARAMS ((int, struct type **, int, union aux_ext *, int, char *));
|
354 |
|
|
|
355 |
|
|
static void
|
356 |
|
|
parse_partial_symbols PARAMS ((struct objfile *));
|
357 |
|
|
|
358 |
|
|
static FDR
|
359 |
|
|
* get_rfd PARAMS ((int, int));
|
360 |
|
|
|
361 |
|
|
static int
|
362 |
|
|
has_opaque_xref PARAMS ((FDR *, SYMR *));
|
363 |
|
|
|
364 |
|
|
static int
|
365 |
|
|
cross_ref PARAMS ((int, union aux_ext *, struct type **, enum type_code,
|
366 |
|
|
char **, int, char *));
|
367 |
|
|
|
368 |
|
|
static struct symbol *
|
369 |
|
|
new_symbol PARAMS ((char *));
|
370 |
|
|
|
371 |
|
|
static struct type *
|
372 |
|
|
new_type PARAMS ((char *));
|
373 |
|
|
|
374 |
|
|
static struct block *
|
375 |
|
|
new_block PARAMS ((int));
|
376 |
|
|
|
377 |
|
|
static struct symtab *
|
378 |
|
|
new_symtab PARAMS ((char *, int, int, struct objfile *));
|
379 |
|
|
|
380 |
|
|
static struct linetable *
|
381 |
|
|
new_linetable PARAMS ((int));
|
382 |
|
|
|
383 |
|
|
static struct blockvector *
|
384 |
|
|
new_bvect PARAMS ((int));
|
385 |
|
|
|
386 |
|
|
static int
|
387 |
|
|
parse_symbol PARAMS ((SYMR *, union aux_ext *, char *, int, struct section_offsets *));
|
388 |
|
|
|
389 |
|
|
static struct type *
|
390 |
|
|
parse_type PARAMS ((int, union aux_ext *, unsigned int, int *, int, char *));
|
391 |
|
|
|
392 |
|
|
static struct symbol *
|
393 |
|
|
mylookup_symbol PARAMS ((char *, struct block *, namespace_enum,
|
394 |
|
|
enum address_class));
|
395 |
|
|
|
396 |
|
|
static struct block *
|
397 |
|
|
shrink_block PARAMS ((struct block *, struct symtab *));
|
398 |
|
|
|
399 |
|
|
static PTR
|
400 |
|
|
xzalloc PARAMS ((unsigned int));
|
401 |
|
|
|
402 |
|
|
static void
|
403 |
|
|
sort_blocks PARAMS ((struct symtab *));
|
404 |
|
|
|
405 |
|
|
static int
|
406 |
|
|
compare_blocks PARAMS ((const void *, const void *));
|
407 |
|
|
|
408 |
|
|
static struct partial_symtab *
|
409 |
|
|
new_psymtab PARAMS ((char *, struct objfile *));
|
410 |
|
|
|
411 |
|
|
static void
|
412 |
|
|
psymtab_to_symtab_1 PARAMS ((struct partial_symtab *, char *));
|
413 |
|
|
|
414 |
|
|
static void
|
415 |
|
|
add_block PARAMS ((struct block *, struct symtab *));
|
416 |
|
|
|
417 |
|
|
static void
|
418 |
|
|
add_symbol PARAMS ((struct symbol *, struct block *));
|
419 |
|
|
|
420 |
|
|
static int
|
421 |
|
|
add_line PARAMS ((struct linetable *, int, CORE_ADDR, int));
|
422 |
|
|
|
423 |
|
|
static struct linetable *
|
424 |
|
|
shrink_linetable PARAMS ((struct linetable *));
|
425 |
|
|
|
426 |
|
|
static void
|
427 |
|
|
handle_psymbol_enumerators PARAMS ((struct objfile *, FDR *, int, CORE_ADDR));
|
428 |
|
|
|
429 |
|
|
static char *
|
430 |
|
|
mdebug_next_symbol_text PARAMS ((struct objfile *));
|
431 |
|
|
|
432 |
|
|
/* Address bounds for the signal trampoline in inferior, if any */
|
433 |
|
|
|
434 |
|
|
CORE_ADDR sigtramp_address, sigtramp_end;
|
435 |
|
|
|
436 |
|
|
/* Allocate zeroed memory */
|
437 |
|
|
|
438 |
|
|
static PTR
|
439 |
|
|
xzalloc (size)
|
440 |
|
|
unsigned int size;
|
441 |
|
|
{
|
442 |
|
|
PTR p = xmalloc (size);
|
443 |
|
|
|
444 |
|
|
memset (p, 0, size);
|
445 |
|
|
return p;
|
446 |
|
|
}
|
447 |
|
|
|
448 |
|
|
/* Exported procedure: Builds a symtab from the PST partial one.
|
449 |
|
|
Restores the environment in effect when PST was created, delegates
|
450 |
|
|
most of the work to an ancillary procedure, and sorts
|
451 |
|
|
and reorders the symtab list at the end */
|
452 |
|
|
|
453 |
|
|
static void
|
454 |
|
|
mdebug_psymtab_to_symtab (pst)
|
455 |
|
|
struct partial_symtab *pst;
|
456 |
|
|
{
|
457 |
|
|
|
458 |
|
|
if (!pst)
|
459 |
|
|
return;
|
460 |
|
|
|
461 |
|
|
if (info_verbose)
|
462 |
|
|
{
|
463 |
|
|
printf_filtered ("Reading in symbols for %s...", pst->filename);
|
464 |
|
|
gdb_flush (gdb_stdout);
|
465 |
|
|
}
|
466 |
|
|
|
467 |
|
|
next_symbol_text_func = mdebug_next_symbol_text;
|
468 |
|
|
|
469 |
|
|
psymtab_to_symtab_1 (pst, pst->filename);
|
470 |
|
|
|
471 |
|
|
/* Match with global symbols. This only needs to be done once,
|
472 |
|
|
after all of the symtabs and dependencies have been read in. */
|
473 |
|
|
scan_file_globals (pst->objfile);
|
474 |
|
|
|
475 |
|
|
if (info_verbose)
|
476 |
|
|
printf_filtered ("done.\n");
|
477 |
|
|
}
|
478 |
|
|
|
479 |
|
|
/* File-level interface functions */
|
480 |
|
|
|
481 |
|
|
/* Find a file descriptor given its index RF relative to a file CF */
|
482 |
|
|
|
483 |
|
|
static FDR *
|
484 |
|
|
get_rfd (cf, rf)
|
485 |
|
|
int cf, rf;
|
486 |
|
|
{
|
487 |
|
|
FDR *fdrs;
|
488 |
|
|
register FDR *f;
|
489 |
|
|
RFDT rfd;
|
490 |
|
|
|
491 |
|
|
fdrs = debug_info->fdr;
|
492 |
|
|
f = fdrs + cf;
|
493 |
|
|
/* Object files do not have the RFD table, all refs are absolute */
|
494 |
|
|
if (f->rfdBase == 0)
|
495 |
|
|
return fdrs + rf;
|
496 |
|
|
(*debug_swap->swap_rfd_in) (cur_bfd,
|
497 |
|
|
((char *) debug_info->external_rfd
|
498 |
|
|
+ ((f->rfdBase + rf)
|
499 |
|
|
* debug_swap->external_rfd_size)),
|
500 |
|
|
&rfd);
|
501 |
|
|
return fdrs + rfd;
|
502 |
|
|
}
|
503 |
|
|
|
504 |
|
|
/* Return a safer print NAME for a file descriptor */
|
505 |
|
|
|
506 |
|
|
static char *
|
507 |
|
|
fdr_name (f)
|
508 |
|
|
FDR *f;
|
509 |
|
|
{
|
510 |
|
|
if (f->rss == -1)
|
511 |
|
|
return "<stripped file>";
|
512 |
|
|
if (f->rss == 0)
|
513 |
|
|
return "<NFY>";
|
514 |
|
|
return debug_info->ss + f->issBase + f->rss;
|
515 |
|
|
}
|
516 |
|
|
|
517 |
|
|
|
518 |
|
|
/* Read in and parse the symtab of the file OBJFILE. Symbols from
|
519 |
|
|
different sections are relocated via the SECTION_OFFSETS. */
|
520 |
|
|
|
521 |
|
|
void
|
522 |
|
|
mdebug_build_psymtabs (objfile, swap, info)
|
523 |
|
|
struct objfile *objfile;
|
524 |
|
|
const struct ecoff_debug_swap *swap;
|
525 |
|
|
struct ecoff_debug_info *info;
|
526 |
|
|
{
|
527 |
|
|
cur_bfd = objfile->obfd;
|
528 |
|
|
debug_swap = swap;
|
529 |
|
|
debug_info = info;
|
530 |
|
|
|
531 |
|
|
/* Make sure all the FDR information is swapped in. */
|
532 |
|
|
if (info->fdr == (FDR *) NULL)
|
533 |
|
|
{
|
534 |
|
|
char *fdr_src;
|
535 |
|
|
char *fdr_end;
|
536 |
|
|
FDR *fdr_ptr;
|
537 |
|
|
|
538 |
|
|
info->fdr = (FDR *) obstack_alloc (&objfile->psymbol_obstack,
|
539 |
|
|
(info->symbolic_header.ifdMax
|
540 |
|
|
* sizeof (FDR)));
|
541 |
|
|
fdr_src = info->external_fdr;
|
542 |
|
|
fdr_end = (fdr_src
|
543 |
|
|
+ info->symbolic_header.ifdMax * swap->external_fdr_size);
|
544 |
|
|
fdr_ptr = info->fdr;
|
545 |
|
|
for (; fdr_src < fdr_end; fdr_src += swap->external_fdr_size, fdr_ptr++)
|
546 |
|
|
(*swap->swap_fdr_in) (objfile->obfd, fdr_src, fdr_ptr);
|
547 |
|
|
}
|
548 |
|
|
|
549 |
|
|
parse_partial_symbols (objfile);
|
550 |
|
|
|
551 |
|
|
#if 0
|
552 |
|
|
/* Check to make sure file was compiled with -g. If not, warn the
|
553 |
|
|
user of this limitation. */
|
554 |
|
|
if (compare_glevel (max_glevel, GLEVEL_2) < 0)
|
555 |
|
|
{
|
556 |
|
|
if (max_gdbinfo == 0)
|
557 |
|
|
printf_unfiltered ("\n%s not compiled with -g, debugging support is limited.\n",
|
558 |
|
|
objfile->name);
|
559 |
|
|
printf_unfiltered ("You should compile with -g2 or -g3 for best debugging support.\n");
|
560 |
|
|
gdb_flush (gdb_stdout);
|
561 |
|
|
}
|
562 |
|
|
#endif
|
563 |
|
|
}
|
564 |
|
|
|
565 |
|
|
/* Local utilities */
|
566 |
|
|
|
567 |
|
|
/* Map of FDR indexes to partial symtabs */
|
568 |
|
|
|
569 |
|
|
struct pst_map
|
570 |
|
|
{
|
571 |
|
|
struct partial_symtab *pst; /* the psymtab proper */
|
572 |
|
|
long n_globals; /* exported globals (external symbols) */
|
573 |
|
|
long globals_offset; /* cumulative */
|
574 |
|
|
};
|
575 |
|
|
|
576 |
|
|
|
577 |
|
|
/* Utility stack, used to nest procedures and blocks properly.
|
578 |
|
|
It is a doubly linked list, to avoid too many alloc/free.
|
579 |
|
|
Since we might need it quite a few times it is NOT deallocated
|
580 |
|
|
after use. */
|
581 |
|
|
|
582 |
|
|
static struct parse_stack
|
583 |
|
|
{
|
584 |
|
|
struct parse_stack *next, *prev;
|
585 |
|
|
struct symtab *cur_st; /* Current symtab. */
|
586 |
|
|
struct block *cur_block; /* Block in it. */
|
587 |
|
|
|
588 |
|
|
/* What are we parsing. stFile, or stBlock are for files and
|
589 |
|
|
blocks. stProc or stStaticProc means we have seen the start of a
|
590 |
|
|
procedure, but not the start of the block within in. When we see
|
591 |
|
|
the start of that block, we change it to stNil, without pushing a
|
592 |
|
|
new block, i.e. stNil means both a procedure and a block. */
|
593 |
|
|
|
594 |
|
|
int blocktype;
|
595 |
|
|
|
596 |
|
|
int maxsyms; /* Max symbols in this block. */
|
597 |
|
|
struct type *cur_type; /* Type we parse fields for. */
|
598 |
|
|
int cur_field; /* Field number in cur_type. */
|
599 |
|
|
CORE_ADDR procadr; /* Start addres of this procedure */
|
600 |
|
|
int numargs; /* Its argument count */
|
601 |
|
|
}
|
602 |
|
|
|
603 |
|
|
*top_stack; /* Top stack ptr */
|
604 |
|
|
|
605 |
|
|
|
606 |
|
|
/* Enter a new lexical context */
|
607 |
|
|
|
608 |
|
|
static void
|
609 |
|
|
push_parse_stack ()
|
610 |
|
|
{
|
611 |
|
|
struct parse_stack *new;
|
612 |
|
|
|
613 |
|
|
/* Reuse frames if possible */
|
614 |
|
|
if (top_stack && top_stack->prev)
|
615 |
|
|
new = top_stack->prev;
|
616 |
|
|
else
|
617 |
|
|
new = (struct parse_stack *) xzalloc (sizeof (struct parse_stack));
|
618 |
|
|
/* Initialize new frame with previous content */
|
619 |
|
|
if (top_stack)
|
620 |
|
|
{
|
621 |
|
|
register struct parse_stack *prev = new->prev;
|
622 |
|
|
|
623 |
|
|
*new = *top_stack;
|
624 |
|
|
top_stack->prev = new;
|
625 |
|
|
new->prev = prev;
|
626 |
|
|
new->next = top_stack;
|
627 |
|
|
}
|
628 |
|
|
top_stack = new;
|
629 |
|
|
}
|
630 |
|
|
|
631 |
|
|
/* Exit a lexical context */
|
632 |
|
|
|
633 |
|
|
static void
|
634 |
|
|
pop_parse_stack ()
|
635 |
|
|
{
|
636 |
|
|
if (!top_stack)
|
637 |
|
|
return;
|
638 |
|
|
if (top_stack->next)
|
639 |
|
|
top_stack = top_stack->next;
|
640 |
|
|
}
|
641 |
|
|
|
642 |
|
|
|
643 |
|
|
/* Cross-references might be to things we haven't looked at
|
644 |
|
|
yet, e.g. type references. To avoid too many type
|
645 |
|
|
duplications we keep a quick fixup table, an array
|
646 |
|
|
of lists of references indexed by file descriptor */
|
647 |
|
|
|
648 |
|
|
struct mdebug_pending
|
649 |
|
|
{
|
650 |
|
|
struct mdebug_pending *next; /* link */
|
651 |
|
|
char *s; /* the unswapped symbol */
|
652 |
|
|
struct type *t; /* its partial type descriptor */
|
653 |
|
|
};
|
654 |
|
|
|
655 |
|
|
|
656 |
|
|
/* The pending information is kept for an entire object file, and used
|
657 |
|
|
to be in the sym_private field. I took it out when I split
|
658 |
|
|
mdebugread from mipsread, because this might not be the only type
|
659 |
|
|
of symbols read from an object file. Instead, we allocate the
|
660 |
|
|
pending information table when we create the partial symbols, and
|
661 |
|
|
we store a pointer to the single table in each psymtab. */
|
662 |
|
|
|
663 |
|
|
static struct mdebug_pending **pending_list;
|
664 |
|
|
|
665 |
|
|
/* Check whether we already saw symbol SH in file FH */
|
666 |
|
|
|
667 |
|
|
static struct mdebug_pending *
|
668 |
|
|
is_pending_symbol (fh, sh)
|
669 |
|
|
FDR *fh;
|
670 |
|
|
char *sh;
|
671 |
|
|
{
|
672 |
|
|
int f_idx = fh - debug_info->fdr;
|
673 |
|
|
register struct mdebug_pending *p;
|
674 |
|
|
|
675 |
|
|
/* Linear search is ok, list is typically no more than 10 deep */
|
676 |
|
|
for (p = pending_list[f_idx]; p; p = p->next)
|
677 |
|
|
if (p->s == sh)
|
678 |
|
|
break;
|
679 |
|
|
return p;
|
680 |
|
|
}
|
681 |
|
|
|
682 |
|
|
/* Add a new symbol SH of type T */
|
683 |
|
|
|
684 |
|
|
static void
|
685 |
|
|
add_pending (fh, sh, t)
|
686 |
|
|
FDR *fh;
|
687 |
|
|
char *sh;
|
688 |
|
|
struct type *t;
|
689 |
|
|
{
|
690 |
|
|
int f_idx = fh - debug_info->fdr;
|
691 |
|
|
struct mdebug_pending *p = is_pending_symbol (fh, sh);
|
692 |
|
|
|
693 |
|
|
/* Make sure we do not make duplicates */
|
694 |
|
|
if (!p)
|
695 |
|
|
{
|
696 |
|
|
p = ((struct mdebug_pending *)
|
697 |
|
|
obstack_alloc (¤t_objfile->psymbol_obstack,
|
698 |
|
|
sizeof (struct mdebug_pending)));
|
699 |
|
|
p->s = sh;
|
700 |
|
|
p->t = t;
|
701 |
|
|
p->next = pending_list[f_idx];
|
702 |
|
|
pending_list[f_idx] = p;
|
703 |
|
|
}
|
704 |
|
|
}
|
705 |
|
|
|
706 |
|
|
|
707 |
|
|
/* Parsing Routines proper. */
|
708 |
|
|
|
709 |
|
|
/* Parse a single symbol. Mostly just make up a GDB symbol for it.
|
710 |
|
|
For blocks, procedures and types we open a new lexical context.
|
711 |
|
|
This is basically just a big switch on the symbol's type. Argument
|
712 |
|
|
AX is the base pointer of aux symbols for this file (fh->iauxBase).
|
713 |
|
|
EXT_SH points to the unswapped symbol, which is needed for struct,
|
714 |
|
|
union, etc., types; it is NULL for an EXTR. BIGEND says whether
|
715 |
|
|
aux symbols are big-endian or little-endian. Return count of
|
716 |
|
|
SYMR's handled (normally one). */
|
717 |
|
|
|
718 |
|
|
static int
|
719 |
|
|
parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
|
720 |
|
|
SYMR *sh;
|
721 |
|
|
union aux_ext *ax;
|
722 |
|
|
char *ext_sh;
|
723 |
|
|
int bigend;
|
724 |
|
|
struct section_offsets *section_offsets;
|
725 |
|
|
{
|
726 |
|
|
const bfd_size_type external_sym_size = debug_swap->external_sym_size;
|
727 |
|
|
void (*const swap_sym_in) PARAMS ((bfd *, PTR, SYMR *)) =
|
728 |
|
|
debug_swap->swap_sym_in;
|
729 |
|
|
char *name;
|
730 |
|
|
struct symbol *s;
|
731 |
|
|
struct block *b;
|
732 |
|
|
struct mdebug_pending *pend;
|
733 |
|
|
struct type *t;
|
734 |
|
|
struct field *f;
|
735 |
|
|
int count = 1;
|
736 |
|
|
enum address_class class;
|
737 |
|
|
TIR tir;
|
738 |
|
|
long svalue = sh->value;
|
739 |
|
|
int bitsize;
|
740 |
|
|
|
741 |
|
|
if (ext_sh == (char *) NULL)
|
742 |
|
|
name = debug_info->ssext + sh->iss;
|
743 |
|
|
else
|
744 |
|
|
name = debug_info->ss + cur_fdr->issBase + sh->iss;
|
745 |
|
|
|
746 |
|
|
switch (sh->sc)
|
747 |
|
|
{
|
748 |
|
|
case scText:
|
749 |
|
|
case scRConst:
|
750 |
|
|
/* Do not relocate relative values.
|
751 |
|
|
The value of a stEnd symbol is the displacement from the
|
752 |
|
|
corresponding start symbol value.
|
753 |
|
|
The value of a stBlock symbol is the displacement from the
|
754 |
|
|
procedure address. */
|
755 |
|
|
if (sh->st != stEnd && sh->st != stBlock)
|
756 |
|
|
sh->value += ANOFFSET (section_offsets, SECT_OFF_TEXT);
|
757 |
|
|
break;
|
758 |
|
|
case scData:
|
759 |
|
|
case scSData:
|
760 |
|
|
case scRData:
|
761 |
|
|
case scPData:
|
762 |
|
|
case scXData:
|
763 |
|
|
sh->value += ANOFFSET (section_offsets, SECT_OFF_DATA);
|
764 |
|
|
break;
|
765 |
|
|
case scBss:
|
766 |
|
|
case scSBss:
|
767 |
|
|
sh->value += ANOFFSET (section_offsets, SECT_OFF_BSS);
|
768 |
|
|
break;
|
769 |
|
|
}
|
770 |
|
|
|
771 |
|
|
switch (sh->st)
|
772 |
|
|
{
|
773 |
|
|
case stNil:
|
774 |
|
|
break;
|
775 |
|
|
|
776 |
|
|
case stGlobal: /* external symbol, goes into global block */
|
777 |
|
|
class = LOC_STATIC;
|
778 |
|
|
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (top_stack->cur_st),
|
779 |
|
|
GLOBAL_BLOCK);
|
780 |
|
|
s = new_symbol (name);
|
781 |
|
|
SYMBOL_VALUE_ADDRESS (s) = (CORE_ADDR) sh->value;
|
782 |
|
|
goto data;
|
783 |
|
|
|
784 |
|
|
case stStatic: /* static data, goes into current block. */
|
785 |
|
|
class = LOC_STATIC;
|
786 |
|
|
b = top_stack->cur_block;
|
787 |
|
|
s = new_symbol (name);
|
788 |
|
|
if (SC_IS_COMMON (sh->sc))
|
789 |
|
|
{
|
790 |
|
|
/* It is a FORTRAN common block. At least for SGI Fortran the
|
791 |
|
|
address is not in the symbol; we need to fix it later in
|
792 |
|
|
scan_file_globals. */
|
793 |
|
|
int bucket = hashname (SYMBOL_NAME (s));
|
794 |
|
|
SYMBOL_VALUE_CHAIN (s) = global_sym_chain[bucket];
|
795 |
|
|
global_sym_chain[bucket] = s;
|
796 |
|
|
}
|
797 |
|
|
else
|
798 |
|
|
SYMBOL_VALUE_ADDRESS (s) = (CORE_ADDR) sh->value;
|
799 |
|
|
goto data;
|
800 |
|
|
|
801 |
|
|
case stLocal: /* local variable, goes into current block */
|
802 |
|
|
if (sh->sc == scRegister)
|
803 |
|
|
{
|
804 |
|
|
class = LOC_REGISTER;
|
805 |
|
|
svalue = ECOFF_REG_TO_REGNUM (svalue);
|
806 |
|
|
}
|
807 |
|
|
else
|
808 |
|
|
class = LOC_LOCAL;
|
809 |
|
|
b = top_stack->cur_block;
|
810 |
|
|
s = new_symbol (name);
|
811 |
|
|
SYMBOL_VALUE (s) = svalue;
|
812 |
|
|
|
813 |
|
|
data: /* Common code for symbols describing data */
|
814 |
|
|
SYMBOL_NAMESPACE (s) = VAR_NAMESPACE;
|
815 |
|
|
SYMBOL_CLASS (s) = class;
|
816 |
|
|
add_symbol (s, b);
|
817 |
|
|
|
818 |
|
|
/* Type could be missing if file is compiled without debugging info. */
|
819 |
|
|
if (SC_IS_UNDEF (sh->sc)
|
820 |
|
|
|| sh->sc == scNil || sh->index == indexNil)
|
821 |
|
|
SYMBOL_TYPE (s) = nodebug_var_symbol_type;
|
822 |
|
|
else
|
823 |
|
|
SYMBOL_TYPE (s) = parse_type (cur_fd, ax, sh->index, 0, bigend, name);
|
824 |
|
|
/* Value of a data symbol is its memory address */
|
825 |
|
|
break;
|
826 |
|
|
|
827 |
|
|
case stParam: /* arg to procedure, goes into current block */
|
828 |
|
|
max_gdbinfo++;
|
829 |
|
|
found_ecoff_debugging_info = 1;
|
830 |
|
|
top_stack->numargs++;
|
831 |
|
|
|
832 |
|
|
/* Special GNU C++ name. */
|
833 |
|
|
if (is_cplus_marker (name[0]) && name[1] == 't' && name[2] == 0)
|
834 |
|
|
name = "this"; /* FIXME, not alloc'd in obstack */
|
835 |
|
|
s = new_symbol (name);
|
836 |
|
|
|
837 |
|
|
SYMBOL_NAMESPACE (s) = VAR_NAMESPACE;
|
838 |
|
|
switch (sh->sc)
|
839 |
|
|
{
|
840 |
|
|
case scRegister:
|
841 |
|
|
/* Pass by value in register. */
|
842 |
|
|
SYMBOL_CLASS (s) = LOC_REGPARM;
|
843 |
|
|
svalue = ECOFF_REG_TO_REGNUM (svalue);
|
844 |
|
|
break;
|
845 |
|
|
case scVar:
|
846 |
|
|
/* Pass by reference on stack. */
|
847 |
|
|
SYMBOL_CLASS (s) = LOC_REF_ARG;
|
848 |
|
|
break;
|
849 |
|
|
case scVarRegister:
|
850 |
|
|
/* Pass by reference in register. */
|
851 |
|
|
SYMBOL_CLASS (s) = LOC_REGPARM_ADDR;
|
852 |
|
|
svalue = ECOFF_REG_TO_REGNUM (svalue);
|
853 |
|
|
break;
|
854 |
|
|
default:
|
855 |
|
|
/* Pass by value on stack. */
|
856 |
|
|
SYMBOL_CLASS (s) = LOC_ARG;
|
857 |
|
|
break;
|
858 |
|
|
}
|
859 |
|
|
SYMBOL_VALUE (s) = svalue;
|
860 |
|
|
SYMBOL_TYPE (s) = parse_type (cur_fd, ax, sh->index, 0, bigend, name);
|
861 |
|
|
add_symbol (s, top_stack->cur_block);
|
862 |
|
|
break;
|
863 |
|
|
|
864 |
|
|
case stLabel: /* label, goes into current block */
|
865 |
|
|
s = new_symbol (name);
|
866 |
|
|
SYMBOL_NAMESPACE (s) = VAR_NAMESPACE; /* so that it can be used */
|
867 |
|
|
SYMBOL_CLASS (s) = LOC_LABEL; /* but not misused */
|
868 |
|
|
SYMBOL_VALUE_ADDRESS (s) = (CORE_ADDR) sh->value;
|
869 |
|
|
SYMBOL_TYPE (s) = mdebug_type_int;
|
870 |
|
|
add_symbol (s, top_stack->cur_block);
|
871 |
|
|
break;
|
872 |
|
|
|
873 |
|
|
case stProc: /* Procedure, usually goes into global block */
|
874 |
|
|
case stStaticProc: /* Static procedure, goes into current block */
|
875 |
|
|
s = new_symbol (name);
|
876 |
|
|
SYMBOL_NAMESPACE (s) = VAR_NAMESPACE;
|
877 |
|
|
SYMBOL_CLASS (s) = LOC_BLOCK;
|
878 |
|
|
/* Type of the return value */
|
879 |
|
|
if (SC_IS_UNDEF (sh->sc) || sh->sc == scNil)
|
880 |
|
|
t = mdebug_type_int;
|
881 |
|
|
else
|
882 |
|
|
{
|
883 |
|
|
t = parse_type (cur_fd, ax, sh->index + 1, 0, bigend, name);
|
884 |
|
|
if (STREQ (name, "malloc") && t->code == TYPE_CODE_VOID)
|
885 |
|
|
{
|
886 |
|
|
/* I don't know why, but, at least under Alpha GNU/Linux,
|
887 |
|
|
when linking against a malloc without debugging
|
888 |
|
|
symbols, its read as a function returning void---this
|
889 |
|
|
is bad because it means we cannot call functions with
|
890 |
|
|
string arguments interactively; i.e., "call
|
891 |
|
|
printf("howdy\n")" would fail with the error message
|
892 |
|
|
"program has no memory available". To avoid this, we
|
893 |
|
|
patch up the type and make it void*
|
894 |
|
|
instead. (davidm@azstarnet.com)
|
895 |
|
|
*/
|
896 |
|
|
t = make_pointer_type (t, NULL);
|
897 |
|
|
}
|
898 |
|
|
}
|
899 |
|
|
b = top_stack->cur_block;
|
900 |
|
|
if (sh->st == stProc)
|
901 |
|
|
{
|
902 |
|
|
struct blockvector *bv = BLOCKVECTOR (top_stack->cur_st);
|
903 |
|
|
/* The next test should normally be true, but provides a
|
904 |
|
|
hook for nested functions (which we don't want to make
|
905 |
|
|
global). */
|
906 |
|
|
if (b == BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK))
|
907 |
|
|
b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
|
908 |
|
|
/* Irix 5 sometimes has duplicate names for the same
|
909 |
|
|
function. We want to add such names up at the global
|
910 |
|
|
level, not as a nested function. */
|
911 |
|
|
else if (sh->value == top_stack->procadr)
|
912 |
|
|
b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
|
913 |
|
|
}
|
914 |
|
|
add_symbol (s, b);
|
915 |
|
|
|
916 |
|
|
/* Make a type for the procedure itself */
|
917 |
|
|
SYMBOL_TYPE (s) = lookup_function_type (t);
|
918 |
|
|
|
919 |
|
|
/* Create and enter a new lexical context */
|
920 |
|
|
b = new_block (top_stack->maxsyms);
|
921 |
|
|
SYMBOL_BLOCK_VALUE (s) = b;
|
922 |
|
|
BLOCK_FUNCTION (b) = s;
|
923 |
|
|
BLOCK_START (b) = BLOCK_END (b) = sh->value;
|
924 |
|
|
BLOCK_SUPERBLOCK (b) = top_stack->cur_block;
|
925 |
|
|
add_block (b, top_stack->cur_st);
|
926 |
|
|
|
927 |
|
|
/* Not if we only have partial info */
|
928 |
|
|
if (SC_IS_UNDEF (sh->sc) || sh->sc == scNil)
|
929 |
|
|
break;
|
930 |
|
|
|
931 |
|
|
push_parse_stack ();
|
932 |
|
|
top_stack->cur_block = b;
|
933 |
|
|
top_stack->blocktype = sh->st;
|
934 |
|
|
top_stack->cur_type = SYMBOL_TYPE (s);
|
935 |
|
|
top_stack->cur_field = -1;
|
936 |
|
|
top_stack->procadr = sh->value;
|
937 |
|
|
top_stack->numargs = 0;
|
938 |
|
|
break;
|
939 |
|
|
|
940 |
|
|
/* Beginning of code for structure, union, and enum definitions.
|
941 |
|
|
They all share a common set of local variables, defined here. */
|
942 |
|
|
{
|
943 |
|
|
enum type_code type_code;
|
944 |
|
|
char *ext_tsym;
|
945 |
|
|
int nfields;
|
946 |
|
|
long max_value;
|
947 |
|
|
struct field *f;
|
948 |
|
|
|
949 |
|
|
case stStruct: /* Start a block defining a struct type */
|
950 |
|
|
type_code = TYPE_CODE_STRUCT;
|
951 |
|
|
goto structured_common;
|
952 |
|
|
|
953 |
|
|
case stUnion: /* Start a block defining a union type */
|
954 |
|
|
type_code = TYPE_CODE_UNION;
|
955 |
|
|
goto structured_common;
|
956 |
|
|
|
957 |
|
|
case stEnum: /* Start a block defining an enum type */
|
958 |
|
|
type_code = TYPE_CODE_ENUM;
|
959 |
|
|
goto structured_common;
|
960 |
|
|
|
961 |
|
|
case stBlock: /* Either a lexical block, or some type */
|
962 |
|
|
if (sh->sc != scInfo && !SC_IS_COMMON (sh->sc))
|
963 |
|
|
goto case_stBlock_code; /* Lexical block */
|
964 |
|
|
|
965 |
|
|
type_code = TYPE_CODE_UNDEF; /* We have a type. */
|
966 |
|
|
|
967 |
|
|
/* Common code for handling struct, union, enum, and/or as-yet-
|
968 |
|
|
unknown-type blocks of info about structured data. `type_code'
|
969 |
|
|
has been set to the proper TYPE_CODE, if we know it. */
|
970 |
|
|
structured_common:
|
971 |
|
|
found_ecoff_debugging_info = 1;
|
972 |
|
|
push_parse_stack ();
|
973 |
|
|
top_stack->blocktype = stBlock;
|
974 |
|
|
|
975 |
|
|
/* First count the number of fields and the highest value. */
|
976 |
|
|
nfields = 0;
|
977 |
|
|
max_value = 0;
|
978 |
|
|
for (ext_tsym = ext_sh + external_sym_size;
|
979 |
|
|
;
|
980 |
|
|
ext_tsym += external_sym_size)
|
981 |
|
|
{
|
982 |
|
|
SYMR tsym;
|
983 |
|
|
|
984 |
|
|
(*swap_sym_in) (cur_bfd, ext_tsym, &tsym);
|
985 |
|
|
|
986 |
|
|
switch (tsym.st)
|
987 |
|
|
{
|
988 |
|
|
case stEnd:
|
989 |
|
|
goto end_of_fields;
|
990 |
|
|
|
991 |
|
|
case stMember:
|
992 |
|
|
if (nfields == 0 && type_code == TYPE_CODE_UNDEF)
|
993 |
|
|
{
|
994 |
|
|
/* If the type of the member is Nil (or Void),
|
995 |
|
|
without qualifiers, assume the tag is an
|
996 |
|
|
enumeration.
|
997 |
|
|
Alpha cc -migrate enums are recognized by a zero
|
998 |
|
|
index and a zero symbol value.
|
999 |
|
|
DU 4.0 cc enums are recognized by a member type of
|
1000 |
|
|
btEnum without qualifiers and a zero symbol value. */
|
1001 |
|
|
if (tsym.index == indexNil
|
1002 |
|
|
|| (tsym.index == 0 && sh->value == 0))
|
1003 |
|
|
type_code = TYPE_CODE_ENUM;
|
1004 |
|
|
else
|
1005 |
|
|
{
|
1006 |
|
|
(*debug_swap->swap_tir_in) (bigend,
|
1007 |
|
|
&ax[tsym.index].a_ti,
|
1008 |
|
|
&tir);
|
1009 |
|
|
if ((tir.bt == btNil || tir.bt == btVoid
|
1010 |
|
|
|| (tir.bt == btEnum && sh->value == 0))
|
1011 |
|
|
&& tir.tq0 == tqNil)
|
1012 |
|
|
type_code = TYPE_CODE_ENUM;
|
1013 |
|
|
}
|
1014 |
|
|
}
|
1015 |
|
|
nfields++;
|
1016 |
|
|
if (tsym.value > max_value)
|
1017 |
|
|
max_value = tsym.value;
|
1018 |
|
|
break;
|
1019 |
|
|
|
1020 |
|
|
case stBlock:
|
1021 |
|
|
case stUnion:
|
1022 |
|
|
case stEnum:
|
1023 |
|
|
case stStruct:
|
1024 |
|
|
{
|
1025 |
|
|
#if 0
|
1026 |
|
|
/* This is a no-op; is it trying to tell us something
|
1027 |
|
|
we should be checking? */
|
1028 |
|
|
if (tsym.sc == scVariant); /*UNIMPLEMENTED */
|
1029 |
|
|
#endif
|
1030 |
|
|
if (tsym.index != 0)
|
1031 |
|
|
{
|
1032 |
|
|
/* This is something like a struct within a
|
1033 |
|
|
struct. Skip over the fields of the inner
|
1034 |
|
|
struct. The -1 is because the for loop will
|
1035 |
|
|
increment ext_tsym. */
|
1036 |
|
|
ext_tsym = ((char *) debug_info->external_sym
|
1037 |
|
|
+ ((cur_fdr->isymBase + tsym.index - 1)
|
1038 |
|
|
* external_sym_size));
|
1039 |
|
|
}
|
1040 |
|
|
}
|
1041 |
|
|
break;
|
1042 |
|
|
|
1043 |
|
|
case stTypedef:
|
1044 |
|
|
/* mips cc puts out a typedef for struct x if it is not yet
|
1045 |
|
|
defined when it encounters
|
1046 |
|
|
struct y { struct x *xp; };
|
1047 |
|
|
Just ignore it. */
|
1048 |
|
|
break;
|
1049 |
|
|
|
1050 |
|
|
case stIndirect:
|
1051 |
|
|
/* Irix5 cc puts out a stIndirect for struct x if it is not
|
1052 |
|
|
yet defined when it encounters
|
1053 |
|
|
struct y { struct x *xp; };
|
1054 |
|
|
Just ignore it. */
|
1055 |
|
|
break;
|
1056 |
|
|
|
1057 |
|
|
default:
|
1058 |
|
|
complain (&block_member_complaint, tsym.st);
|
1059 |
|
|
}
|
1060 |
|
|
}
|
1061 |
|
|
end_of_fields:;
|
1062 |
|
|
|
1063 |
|
|
/* In an stBlock, there is no way to distinguish structs,
|
1064 |
|
|
unions, and enums at this point. This is a bug in the
|
1065 |
|
|
original design (that has been fixed with the recent
|
1066 |
|
|
addition of the stStruct, stUnion, and stEnum symbol
|
1067 |
|
|
types.) The way you can tell is if/when you see a variable
|
1068 |
|
|
or field of that type. In that case the variable's type
|
1069 |
|
|
(in the AUX table) says if the type is struct, union, or
|
1070 |
|
|
enum, and points back to the stBlock here. So you can
|
1071 |
|
|
patch the tag kind up later - but only if there actually is
|
1072 |
|
|
a variable or field of that type.
|
1073 |
|
|
|
1074 |
|
|
So until we know for sure, we will guess at this point.
|
1075 |
|
|
The heuristic is:
|
1076 |
|
|
If the first member has index==indexNil or a void type,
|
1077 |
|
|
assume we have an enumeration.
|
1078 |
|
|
Otherwise, if there is more than one member, and all
|
1079 |
|
|
the members have offset 0, assume we have a union.
|
1080 |
|
|
Otherwise, assume we have a struct.
|
1081 |
|
|
|
1082 |
|
|
The heuristic could guess wrong in the case of of an
|
1083 |
|
|
enumeration with no members or a union with one (or zero)
|
1084 |
|
|
members, or when all except the last field of a struct have
|
1085 |
|
|
width zero. These are uncommon and/or illegal situations,
|
1086 |
|
|
and in any case guessing wrong probably doesn't matter
|
1087 |
|
|
much.
|
1088 |
|
|
|
1089 |
|
|
But if we later do find out we were wrong, we fixup the tag
|
1090 |
|
|
kind. Members of an enumeration must be handled
|
1091 |
|
|
differently from struct/union fields, and that is harder to
|
1092 |
|
|
patch up, but luckily we shouldn't need to. (If there are
|
1093 |
|
|
any enumeration members, we can tell for sure it's an enum
|
1094 |
|
|
here.) */
|
1095 |
|
|
|
1096 |
|
|
if (type_code == TYPE_CODE_UNDEF)
|
1097 |
|
|
{
|
1098 |
|
|
if (nfields > 1 && max_value == 0)
|
1099 |
|
|
type_code = TYPE_CODE_UNION;
|
1100 |
|
|
else
|
1101 |
|
|
type_code = TYPE_CODE_STRUCT;
|
1102 |
|
|
}
|
1103 |
|
|
|
1104 |
|
|
/* Create a new type or use the pending type. */
|
1105 |
|
|
pend = is_pending_symbol (cur_fdr, ext_sh);
|
1106 |
|
|
if (pend == (struct mdebug_pending *) NULL)
|
1107 |
|
|
{
|
1108 |
|
|
t = new_type (NULL);
|
1109 |
|
|
add_pending (cur_fdr, ext_sh, t);
|
1110 |
|
|
}
|
1111 |
|
|
else
|
1112 |
|
|
t = pend->t;
|
1113 |
|
|
|
1114 |
|
|
/* Do not set the tag name if it is a compiler generated tag name
|
1115 |
|
|
(.Fxx or .xxfake or empty) for unnamed struct/union/enums.
|
1116 |
|
|
Alpha cc puts out an sh->iss of zero for those. */
|
1117 |
|
|
if (sh->iss == 0 || name[0] == '.' || name[0] == '\0')
|
1118 |
|
|
TYPE_TAG_NAME (t) = NULL;
|
1119 |
|
|
else
|
1120 |
|
|
TYPE_TAG_NAME (t) = obconcat (¤t_objfile->symbol_obstack,
|
1121 |
|
|
"", "", name);
|
1122 |
|
|
|
1123 |
|
|
TYPE_CODE (t) = type_code;
|
1124 |
|
|
TYPE_LENGTH (t) = sh->value;
|
1125 |
|
|
TYPE_NFIELDS (t) = nfields;
|
1126 |
|
|
TYPE_FIELDS (t) = f = ((struct field *)
|
1127 |
|
|
TYPE_ALLOC (t,
|
1128 |
|
|
nfields * sizeof (struct field)));
|
1129 |
|
|
|
1130 |
|
|
if (type_code == TYPE_CODE_ENUM)
|
1131 |
|
|
{
|
1132 |
|
|
int unsigned_enum = 1;
|
1133 |
|
|
|
1134 |
|
|
/* This is a non-empty enum. */
|
1135 |
|
|
|
1136 |
|
|
/* DEC c89 has the number of enumerators in the sh.value field,
|
1137 |
|
|
not the type length, so we have to compensate for that
|
1138 |
|
|
incompatibility quirk.
|
1139 |
|
|
This might do the wrong thing for an enum with one or two
|
1140 |
|
|
enumerators and gcc -gcoff -fshort-enums, but these cases
|
1141 |
|
|
are hopefully rare enough.
|
1142 |
|
|
Alpha cc -migrate has a sh.value field of zero, we adjust
|
1143 |
|
|
that too. */
|
1144 |
|
|
if (TYPE_LENGTH (t) == TYPE_NFIELDS (t)
|
1145 |
|
|
|| TYPE_LENGTH (t) == 0)
|
1146 |
|
|
TYPE_LENGTH (t) = TARGET_INT_BIT / HOST_CHAR_BIT;
|
1147 |
|
|
for (ext_tsym = ext_sh + external_sym_size;
|
1148 |
|
|
;
|
1149 |
|
|
ext_tsym += external_sym_size)
|
1150 |
|
|
{
|
1151 |
|
|
SYMR tsym;
|
1152 |
|
|
struct symbol *enum_sym;
|
1153 |
|
|
|
1154 |
|
|
(*swap_sym_in) (cur_bfd, ext_tsym, &tsym);
|
1155 |
|
|
|
1156 |
|
|
if (tsym.st != stMember)
|
1157 |
|
|
break;
|
1158 |
|
|
|
1159 |
|
|
FIELD_BITPOS (*f) = tsym.value;
|
1160 |
|
|
FIELD_TYPE (*f) = t;
|
1161 |
|
|
FIELD_NAME (*f) = debug_info->ss + cur_fdr->issBase + tsym.iss;
|
1162 |
|
|
FIELD_BITSIZE (*f) = 0;
|
1163 |
|
|
|
1164 |
|
|
enum_sym = ((struct symbol *)
|
1165 |
|
|
obstack_alloc (¤t_objfile->symbol_obstack,
|
1166 |
|
|
sizeof (struct symbol)));
|
1167 |
|
|
memset ((PTR) enum_sym, 0, sizeof (struct symbol));
|
1168 |
|
|
SYMBOL_NAME (enum_sym) =
|
1169 |
|
|
obsavestring (f->name, strlen (f->name),
|
1170 |
|
|
¤t_objfile->symbol_obstack);
|
1171 |
|
|
SYMBOL_CLASS (enum_sym) = LOC_CONST;
|
1172 |
|
|
SYMBOL_TYPE (enum_sym) = t;
|
1173 |
|
|
SYMBOL_NAMESPACE (enum_sym) = VAR_NAMESPACE;
|
1174 |
|
|
SYMBOL_VALUE (enum_sym) = tsym.value;
|
1175 |
|
|
if (SYMBOL_VALUE (enum_sym) < 0)
|
1176 |
|
|
unsigned_enum = 0;
|
1177 |
|
|
add_symbol (enum_sym, top_stack->cur_block);
|
1178 |
|
|
|
1179 |
|
|
/* Skip the stMembers that we've handled. */
|
1180 |
|
|
count++;
|
1181 |
|
|
f++;
|
1182 |
|
|
}
|
1183 |
|
|
if (unsigned_enum)
|
1184 |
|
|
TYPE_FLAGS (t) |= TYPE_FLAG_UNSIGNED;
|
1185 |
|
|
}
|
1186 |
|
|
/* make this the current type */
|
1187 |
|
|
top_stack->cur_type = t;
|
1188 |
|
|
top_stack->cur_field = 0;
|
1189 |
|
|
|
1190 |
|
|
/* Do not create a symbol for alpha cc unnamed structs. */
|
1191 |
|
|
if (sh->iss == 0)
|
1192 |
|
|
break;
|
1193 |
|
|
|
1194 |
|
|
/* gcc puts out an empty struct for an opaque struct definitions,
|
1195 |
|
|
do not create a symbol for it either. */
|
1196 |
|
|
if (TYPE_NFIELDS (t) == 0)
|
1197 |
|
|
{
|
1198 |
|
|
TYPE_FLAGS (t) |= TYPE_FLAG_STUB;
|
1199 |
|
|
break;
|
1200 |
|
|
}
|
1201 |
|
|
|
1202 |
|
|
s = new_symbol (name);
|
1203 |
|
|
SYMBOL_NAMESPACE (s) = STRUCT_NAMESPACE;
|
1204 |
|
|
SYMBOL_CLASS (s) = LOC_TYPEDEF;
|
1205 |
|
|
SYMBOL_VALUE (s) = 0;
|
1206 |
|
|
SYMBOL_TYPE (s) = t;
|
1207 |
|
|
add_symbol (s, top_stack->cur_block);
|
1208 |
|
|
break;
|
1209 |
|
|
|
1210 |
|
|
/* End of local variables shared by struct, union, enum, and
|
1211 |
|
|
block (as yet unknown struct/union/enum) processing. */
|
1212 |
|
|
}
|
1213 |
|
|
|
1214 |
|
|
case_stBlock_code:
|
1215 |
|
|
found_ecoff_debugging_info = 1;
|
1216 |
|
|
/* beginnning of (code) block. Value of symbol
|
1217 |
|
|
is the displacement from procedure start */
|
1218 |
|
|
push_parse_stack ();
|
1219 |
|
|
|
1220 |
|
|
/* Do not start a new block if this is the outermost block of a
|
1221 |
|
|
procedure. This allows the LOC_BLOCK symbol to point to the
|
1222 |
|
|
block with the local variables, so funcname::var works. */
|
1223 |
|
|
if (top_stack->blocktype == stProc
|
1224 |
|
|
|| top_stack->blocktype == stStaticProc)
|
1225 |
|
|
{
|
1226 |
|
|
top_stack->blocktype = stNil;
|
1227 |
|
|
break;
|
1228 |
|
|
}
|
1229 |
|
|
|
1230 |
|
|
top_stack->blocktype = stBlock;
|
1231 |
|
|
b = new_block (top_stack->maxsyms);
|
1232 |
|
|
BLOCK_START (b) = sh->value + top_stack->procadr;
|
1233 |
|
|
BLOCK_SUPERBLOCK (b) = top_stack->cur_block;
|
1234 |
|
|
top_stack->cur_block = b;
|
1235 |
|
|
add_block (b, top_stack->cur_st);
|
1236 |
|
|
break;
|
1237 |
|
|
|
1238 |
|
|
case stEnd: /* end (of anything) */
|
1239 |
|
|
if (sh->sc == scInfo || SC_IS_COMMON (sh->sc))
|
1240 |
|
|
{
|
1241 |
|
|
/* Finished with type */
|
1242 |
|
|
top_stack->cur_type = 0;
|
1243 |
|
|
}
|
1244 |
|
|
else if (sh->sc == scText &&
|
1245 |
|
|
(top_stack->blocktype == stProc ||
|
1246 |
|
|
top_stack->blocktype == stStaticProc))
|
1247 |
|
|
{
|
1248 |
|
|
/* Finished with procedure */
|
1249 |
|
|
struct blockvector *bv = BLOCKVECTOR (top_stack->cur_st);
|
1250 |
|
|
struct mips_extra_func_info *e;
|
1251 |
|
|
struct block *b;
|
1252 |
|
|
struct type *ftype = top_stack->cur_type;
|
1253 |
|
|
int i;
|
1254 |
|
|
|
1255 |
|
|
BLOCK_END (top_stack->cur_block) += sh->value; /* size */
|
1256 |
|
|
|
1257 |
|
|
/* Make up special symbol to contain procedure specific info */
|
1258 |
|
|
s = new_symbol (MIPS_EFI_SYMBOL_NAME);
|
1259 |
|
|
SYMBOL_NAMESPACE (s) = LABEL_NAMESPACE;
|
1260 |
|
|
SYMBOL_CLASS (s) = LOC_CONST;
|
1261 |
|
|
SYMBOL_TYPE (s) = mdebug_type_void;
|
1262 |
|
|
e = ((struct mips_extra_func_info *)
|
1263 |
|
|
obstack_alloc (¤t_objfile->symbol_obstack,
|
1264 |
|
|
sizeof (struct mips_extra_func_info)));
|
1265 |
|
|
memset ((PTR) e, 0, sizeof (struct mips_extra_func_info));
|
1266 |
|
|
SYMBOL_VALUE (s) = (long) e;
|
1267 |
|
|
e->numargs = top_stack->numargs;
|
1268 |
|
|
e->pdr.framereg = -1;
|
1269 |
|
|
add_symbol (s, top_stack->cur_block);
|
1270 |
|
|
|
1271 |
|
|
/* Reallocate symbols, saving memory */
|
1272 |
|
|
b = shrink_block (top_stack->cur_block, top_stack->cur_st);
|
1273 |
|
|
|
1274 |
|
|
/* f77 emits proc-level with address bounds==[0,0],
|
1275 |
|
|
So look for such child blocks, and patch them. */
|
1276 |
|
|
for (i = 0; i < BLOCKVECTOR_NBLOCKS (bv); i++)
|
1277 |
|
|
{
|
1278 |
|
|
struct block *b_bad = BLOCKVECTOR_BLOCK (bv, i);
|
1279 |
|
|
if (BLOCK_SUPERBLOCK (b_bad) == b
|
1280 |
|
|
&& BLOCK_START (b_bad) == top_stack->procadr
|
1281 |
|
|
&& BLOCK_END (b_bad) == top_stack->procadr)
|
1282 |
|
|
{
|
1283 |
|
|
BLOCK_START (b_bad) = BLOCK_START (b);
|
1284 |
|
|
BLOCK_END (b_bad) = BLOCK_END (b);
|
1285 |
|
|
}
|
1286 |
|
|
}
|
1287 |
|
|
|
1288 |
|
|
if (TYPE_NFIELDS (ftype) <= 0)
|
1289 |
|
|
{
|
1290 |
|
|
/* No parameter type information is recorded with the function's
|
1291 |
|
|
type. Set that from the type of the parameter symbols. */
|
1292 |
|
|
int nparams = top_stack->numargs;
|
1293 |
|
|
int iparams;
|
1294 |
|
|
struct symbol *sym;
|
1295 |
|
|
|
1296 |
|
|
if (nparams > 0)
|
1297 |
|
|
{
|
1298 |
|
|
TYPE_NFIELDS (ftype) = nparams;
|
1299 |
|
|
TYPE_FIELDS (ftype) = (struct field *)
|
1300 |
|
|
TYPE_ALLOC (ftype, nparams * sizeof (struct field));
|
1301 |
|
|
|
1302 |
|
|
for (i = iparams = 0; iparams < nparams; i++)
|
1303 |
|
|
{
|
1304 |
|
|
sym = BLOCK_SYM (b, i);
|
1305 |
|
|
switch (SYMBOL_CLASS (sym))
|
1306 |
|
|
{
|
1307 |
|
|
case LOC_ARG:
|
1308 |
|
|
case LOC_REF_ARG:
|
1309 |
|
|
case LOC_REGPARM:
|
1310 |
|
|
case LOC_REGPARM_ADDR:
|
1311 |
|
|
TYPE_FIELD_TYPE (ftype, iparams) = SYMBOL_TYPE (sym);
|
1312 |
|
|
iparams++;
|
1313 |
|
|
break;
|
1314 |
|
|
default:
|
1315 |
|
|
break;
|
1316 |
|
|
}
|
1317 |
|
|
}
|
1318 |
|
|
}
|
1319 |
|
|
}
|
1320 |
|
|
}
|
1321 |
|
|
else if (sh->sc == scText && top_stack->blocktype == stBlock)
|
1322 |
|
|
{
|
1323 |
|
|
/* End of (code) block. The value of the symbol is the
|
1324 |
|
|
displacement from the procedure`s start address of the
|
1325 |
|
|
end of this block. */
|
1326 |
|
|
BLOCK_END (top_stack->cur_block) = sh->value + top_stack->procadr;
|
1327 |
|
|
shrink_block (top_stack->cur_block, top_stack->cur_st);
|
1328 |
|
|
}
|
1329 |
|
|
else if (sh->sc == scText && top_stack->blocktype == stNil)
|
1330 |
|
|
{
|
1331 |
|
|
/* End of outermost block. Pop parse stack and ignore. The
|
1332 |
|
|
following stEnd of stProc will take care of the block. */
|
1333 |
|
|
;
|
1334 |
|
|
}
|
1335 |
|
|
else if (sh->sc == scText && top_stack->blocktype == stFile)
|
1336 |
|
|
{
|
1337 |
|
|
/* End of file. Pop parse stack and ignore. Higher
|
1338 |
|
|
level code deals with this. */
|
1339 |
|
|
;
|
1340 |
|
|
}
|
1341 |
|
|
else
|
1342 |
|
|
complain (&stEnd_complaint, sh->sc);
|
1343 |
|
|
|
1344 |
|
|
pop_parse_stack (); /* restore previous lexical context */
|
1345 |
|
|
break;
|
1346 |
|
|
|
1347 |
|
|
case stMember: /* member of struct or union */
|
1348 |
|
|
f = &TYPE_FIELDS (top_stack->cur_type)[top_stack->cur_field++];
|
1349 |
|
|
FIELD_NAME (*f) = name;
|
1350 |
|
|
FIELD_BITPOS (*f) = sh->value;
|
1351 |
|
|
bitsize = 0;
|
1352 |
|
|
FIELD_TYPE (*f) = parse_type (cur_fd, ax, sh->index, &bitsize, bigend, name);
|
1353 |
|
|
FIELD_BITSIZE (*f) = bitsize;
|
1354 |
|
|
break;
|
1355 |
|
|
|
1356 |
|
|
case stIndirect: /* forward declaration on Irix5 */
|
1357 |
|
|
/* Forward declarations from Irix5 cc are handled by cross_ref,
|
1358 |
|
|
skip them. */
|
1359 |
|
|
break;
|
1360 |
|
|
|
1361 |
|
|
case stTypedef: /* type definition */
|
1362 |
|
|
found_ecoff_debugging_info = 1;
|
1363 |
|
|
|
1364 |
|
|
/* Typedefs for forward declarations and opaque structs from alpha cc
|
1365 |
|
|
are handled by cross_ref, skip them. */
|
1366 |
|
|
if (sh->iss == 0)
|
1367 |
|
|
break;
|
1368 |
|
|
|
1369 |
|
|
/* Parse the type or use the pending type. */
|
1370 |
|
|
pend = is_pending_symbol (cur_fdr, ext_sh);
|
1371 |
|
|
if (pend == (struct mdebug_pending *) NULL)
|
1372 |
|
|
{
|
1373 |
|
|
t = parse_type (cur_fd, ax, sh->index, (int *) NULL, bigend, name);
|
1374 |
|
|
add_pending (cur_fdr, ext_sh, t);
|
1375 |
|
|
}
|
1376 |
|
|
else
|
1377 |
|
|
t = pend->t;
|
1378 |
|
|
|
1379 |
|
|
/* mips cc puts out a typedef with the name of the struct for forward
|
1380 |
|
|
declarations. These should not go into the symbol table and
|
1381 |
|
|
TYPE_NAME should not be set for them.
|
1382 |
|
|
They can't be distinguished from an intentional typedef to
|
1383 |
|
|
the same name however:
|
1384 |
|
|
x.h:
|
1385 |
|
|
struct x { int ix; int jx; };
|
1386 |
|
|
struct xx;
|
1387 |
|
|
x.c:
|
1388 |
|
|
typedef struct x x;
|
1389 |
|
|
struct xx {int ixx; int jxx; };
|
1390 |
|
|
generates a cross referencing stTypedef for x and xx.
|
1391 |
|
|
The user visible effect of this is that the type of a pointer
|
1392 |
|
|
to struct foo sometimes is given as `foo *' instead of `struct foo *'.
|
1393 |
|
|
The problem is fixed with alpha cc and Irix5 cc. */
|
1394 |
|
|
|
1395 |
|
|
/* However if the typedef cross references to an opaque aggregate, it
|
1396 |
|
|
is safe to omit it from the symbol table. */
|
1397 |
|
|
|
1398 |
|
|
if (has_opaque_xref (cur_fdr, sh))
|
1399 |
|
|
break;
|
1400 |
|
|
s = new_symbol (name);
|
1401 |
|
|
SYMBOL_NAMESPACE (s) = VAR_NAMESPACE;
|
1402 |
|
|
SYMBOL_CLASS (s) = LOC_TYPEDEF;
|
1403 |
|
|
SYMBOL_BLOCK_VALUE (s) = top_stack->cur_block;
|
1404 |
|
|
SYMBOL_TYPE (s) = t;
|
1405 |
|
|
add_symbol (s, top_stack->cur_block);
|
1406 |
|
|
|
1407 |
|
|
/* Incomplete definitions of structs should not get a name. */
|
1408 |
|
|
if (TYPE_NAME (SYMBOL_TYPE (s)) == NULL
|
1409 |
|
|
&& (TYPE_NFIELDS (SYMBOL_TYPE (s)) != 0
|
1410 |
|
|
|| (TYPE_CODE (SYMBOL_TYPE (s)) != TYPE_CODE_STRUCT
|
1411 |
|
|
&& TYPE_CODE (SYMBOL_TYPE (s)) != TYPE_CODE_UNION)))
|
1412 |
|
|
{
|
1413 |
|
|
if (TYPE_CODE (SYMBOL_TYPE (s)) == TYPE_CODE_PTR
|
1414 |
|
|
|| TYPE_CODE (SYMBOL_TYPE (s)) == TYPE_CODE_FUNC)
|
1415 |
|
|
{
|
1416 |
|
|
/* If we are giving a name to a type such as "pointer to
|
1417 |
|
|
foo" or "function returning foo", we better not set
|
1418 |
|
|
the TYPE_NAME. If the program contains "typedef char
|
1419 |
|
|
*caddr_t;", we don't want all variables of type char
|
1420 |
|
|
* to print as caddr_t. This is not just a
|
1421 |
|
|
consequence of GDB's type management; CC and GCC (at
|
1422 |
|
|
least through version 2.4) both output variables of
|
1423 |
|
|
either type char * or caddr_t with the type
|
1424 |
|
|
refering to the stTypedef symbol for caddr_t. If a future
|
1425 |
|
|
compiler cleans this up it GDB is not ready for it
|
1426 |
|
|
yet, but if it becomes ready we somehow need to
|
1427 |
|
|
disable this check (without breaking the PCC/GCC2.4
|
1428 |
|
|
case).
|
1429 |
|
|
|
1430 |
|
|
Sigh.
|
1431 |
|
|
|
1432 |
|
|
Fortunately, this check seems not to be necessary
|
1433 |
|
|
for anything except pointers or functions. */
|
1434 |
|
|
}
|
1435 |
|
|
else
|
1436 |
|
|
TYPE_NAME (SYMBOL_TYPE (s)) = SYMBOL_NAME (s);
|
1437 |
|
|
}
|
1438 |
|
|
break;
|
1439 |
|
|
|
1440 |
|
|
case stFile: /* file name */
|
1441 |
|
|
push_parse_stack ();
|
1442 |
|
|
top_stack->blocktype = sh->st;
|
1443 |
|
|
break;
|
1444 |
|
|
|
1445 |
|
|
/* I`ve never seen these for C */
|
1446 |
|
|
case stRegReloc:
|
1447 |
|
|
break; /* register relocation */
|
1448 |
|
|
case stForward:
|
1449 |
|
|
break; /* forwarding address */
|
1450 |
|
|
case stConstant:
|
1451 |
|
|
break; /* constant */
|
1452 |
|
|
default:
|
1453 |
|
|
complain (&unknown_mdebug_symtype_complaint, sh->st);
|
1454 |
|
|
break;
|
1455 |
|
|
}
|
1456 |
|
|
|
1457 |
|
|
return count;
|
1458 |
|
|
}
|
1459 |
|
|
|
1460 |
|
|
/* Parse the type information provided in the raw AX entries for
|
1461 |
|
|
the symbol SH. Return the bitfield size in BS, in case.
|
1462 |
|
|
We must byte-swap the AX entries before we use them; BIGEND says whether
|
1463 |
|
|
they are big-endian or little-endian (from fh->fBigendian). */
|
1464 |
|
|
|
1465 |
|
|
static struct type *
|
1466 |
|
|
parse_type (fd, ax, aux_index, bs, bigend, sym_name)
|
1467 |
|
|
int fd;
|
1468 |
|
|
union aux_ext *ax;
|
1469 |
|
|
unsigned int aux_index;
|
1470 |
|
|
int *bs;
|
1471 |
|
|
int bigend;
|
1472 |
|
|
char *sym_name;
|
1473 |
|
|
{
|
1474 |
|
|
/* Null entries in this map are treated specially */
|
1475 |
|
|
static struct type **map_bt[] =
|
1476 |
|
|
{
|
1477 |
|
|
&mdebug_type_void, /* btNil */
|
1478 |
|
|
&mdebug_type_adr_32, /* btAdr */
|
1479 |
|
|
&mdebug_type_char, /* btChar */
|
1480 |
|
|
&mdebug_type_unsigned_char, /* btUChar */
|
1481 |
|
|
&mdebug_type_short, /* btShort */
|
1482 |
|
|
&mdebug_type_unsigned_short, /* btUShort */
|
1483 |
|
|
&mdebug_type_int_32, /* btInt */
|
1484 |
|
|
&mdebug_type_unsigned_int_32, /* btUInt */
|
1485 |
|
|
&mdebug_type_long_32, /* btLong */
|
1486 |
|
|
&mdebug_type_unsigned_long_32, /* btULong */
|
1487 |
|
|
&mdebug_type_float, /* btFloat */
|
1488 |
|
|
&mdebug_type_double, /* btDouble */
|
1489 |
|
|
0, /* btStruct */
|
1490 |
|
|
0, /* btUnion */
|
1491 |
|
|
0, /* btEnum */
|
1492 |
|
|
0, /* btTypedef */
|
1493 |
|
|
0, /* btRange */
|
1494 |
|
|
0, /* btSet */
|
1495 |
|
|
&mdebug_type_complex, /* btComplex */
|
1496 |
|
|
&mdebug_type_double_complex, /* btDComplex */
|
1497 |
|
|
0, /* btIndirect */
|
1498 |
|
|
&mdebug_type_fixed_dec, /* btFixedDec */
|
1499 |
|
|
&mdebug_type_float_dec, /* btFloatDec */
|
1500 |
|
|
&mdebug_type_string, /* btString */
|
1501 |
|
|
0, /* btBit */
|
1502 |
|
|
0, /* btPicture */
|
1503 |
|
|
&mdebug_type_void, /* btVoid */
|
1504 |
|
|
0, /* DEC C++: Pointer to member */
|
1505 |
|
|
0, /* DEC C++: Virtual function table */
|
1506 |
|
|
0, /* DEC C++: Class (Record) */
|
1507 |
|
|
&mdebug_type_long_64, /* btLong64 */
|
1508 |
|
|
&mdebug_type_unsigned_long_64, /* btULong64 */
|
1509 |
|
|
&mdebug_type_long_long_64, /* btLongLong64 */
|
1510 |
|
|
&mdebug_type_unsigned_long_long_64, /* btULongLong64 */
|
1511 |
|
|
&mdebug_type_adr_64, /* btAdr64 */
|
1512 |
|
|
&mdebug_type_int_64, /* btInt64 */
|
1513 |
|
|
&mdebug_type_unsigned_int_64, /* btUInt64 */
|
1514 |
|
|
};
|
1515 |
|
|
|
1516 |
|
|
TIR t[1];
|
1517 |
|
|
struct type *tp = 0;
|
1518 |
|
|
enum type_code type_code = TYPE_CODE_UNDEF;
|
1519 |
|
|
|
1520 |
|
|
/* Handle undefined types, they have indexNil. */
|
1521 |
|
|
if (aux_index == indexNil)
|
1522 |
|
|
return mdebug_type_int;
|
1523 |
|
|
|
1524 |
|
|
/* Handle corrupt aux indices. */
|
1525 |
|
|
if (aux_index >= (debug_info->fdr + fd)->caux)
|
1526 |
|
|
{
|
1527 |
|
|
complain (&index_complaint, sym_name);
|
1528 |
|
|
return mdebug_type_int;
|
1529 |
|
|
}
|
1530 |
|
|
ax += aux_index;
|
1531 |
|
|
|
1532 |
|
|
/* Use aux as a type information record, map its basic type. */
|
1533 |
|
|
(*debug_swap->swap_tir_in) (bigend, &ax->a_ti, t);
|
1534 |
|
|
if (t->bt >= (sizeof (map_bt) / sizeof (*map_bt)))
|
1535 |
|
|
{
|
1536 |
|
|
complain (&basic_type_complaint, t->bt, sym_name);
|
1537 |
|
|
return mdebug_type_int;
|
1538 |
|
|
}
|
1539 |
|
|
if (map_bt[t->bt])
|
1540 |
|
|
{
|
1541 |
|
|
tp = *map_bt[t->bt];
|
1542 |
|
|
}
|
1543 |
|
|
else
|
1544 |
|
|
{
|
1545 |
|
|
tp = NULL;
|
1546 |
|
|
/* Cannot use builtin types -- build our own */
|
1547 |
|
|
switch (t->bt)
|
1548 |
|
|
{
|
1549 |
|
|
case btStruct:
|
1550 |
|
|
type_code = TYPE_CODE_STRUCT;
|
1551 |
|
|
break;
|
1552 |
|
|
case btUnion:
|
1553 |
|
|
type_code = TYPE_CODE_UNION;
|
1554 |
|
|
break;
|
1555 |
|
|
case btEnum:
|
1556 |
|
|
type_code = TYPE_CODE_ENUM;
|
1557 |
|
|
break;
|
1558 |
|
|
case btRange:
|
1559 |
|
|
type_code = TYPE_CODE_RANGE;
|
1560 |
|
|
break;
|
1561 |
|
|
case btSet:
|
1562 |
|
|
type_code = TYPE_CODE_SET;
|
1563 |
|
|
break;
|
1564 |
|
|
case btIndirect:
|
1565 |
|
|
/* alpha cc -migrate uses this for typedefs. The true type will
|
1566 |
|
|
be obtained by crossreferencing below. */
|
1567 |
|
|
type_code = TYPE_CODE_ERROR;
|
1568 |
|
|
break;
|
1569 |
|
|
case btTypedef:
|
1570 |
|
|
/* alpha cc uses this for typedefs. The true type will be
|
1571 |
|
|
obtained by crossreferencing below. */
|
1572 |
|
|
type_code = TYPE_CODE_ERROR;
|
1573 |
|
|
break;
|
1574 |
|
|
default:
|
1575 |
|
|
complain (&basic_type_complaint, t->bt, sym_name);
|
1576 |
|
|
return mdebug_type_int;
|
1577 |
|
|
}
|
1578 |
|
|
}
|
1579 |
|
|
|
1580 |
|
|
/* Move on to next aux */
|
1581 |
|
|
ax++;
|
1582 |
|
|
|
1583 |
|
|
if (t->fBitfield)
|
1584 |
|
|
{
|
1585 |
|
|
int width = AUX_GET_WIDTH (bigend, ax);
|
1586 |
|
|
|
1587 |
|
|
/* Inhibit core dumps with some cfront generated objects that
|
1588 |
|
|
corrupt the TIR. */
|
1589 |
|
|
if (bs == (int *) NULL)
|
1590 |
|
|
{
|
1591 |
|
|
/* Alpha cc -migrate encodes char and unsigned char types
|
1592 |
|
|
as short and unsigned short types with a field width of 8.
|
1593 |
|
|
Enum types also have a field width which we ignore for now. */
|
1594 |
|
|
if (t->bt == btShort && width == 8)
|
1595 |
|
|
tp = mdebug_type_char;
|
1596 |
|
|
else if (t->bt == btUShort && width == 8)
|
1597 |
|
|
tp = mdebug_type_unsigned_char;
|
1598 |
|
|
else if (t->bt == btEnum)
|
1599 |
|
|
;
|
1600 |
|
|
else
|
1601 |
|
|
complain (&bad_fbitfield_complaint, sym_name);
|
1602 |
|
|
}
|
1603 |
|
|
else
|
1604 |
|
|
*bs = width;
|
1605 |
|
|
ax++;
|
1606 |
|
|
}
|
1607 |
|
|
|
1608 |
|
|
/* A btIndirect entry cross references to an aux entry containing
|
1609 |
|
|
the type. */
|
1610 |
|
|
if (t->bt == btIndirect)
|
1611 |
|
|
{
|
1612 |
|
|
RNDXR rn[1];
|
1613 |
|
|
int rf;
|
1614 |
|
|
FDR *xref_fh;
|
1615 |
|
|
int xref_fd;
|
1616 |
|
|
|
1617 |
|
|
(*debug_swap->swap_rndx_in) (bigend, &ax->a_rndx, rn);
|
1618 |
|
|
ax++;
|
1619 |
|
|
if (rn->rfd == 0xfff)
|
1620 |
|
|
{
|
1621 |
|
|
rf = AUX_GET_ISYM (bigend, ax);
|
1622 |
|
|
ax++;
|
1623 |
|
|
}
|
1624 |
|
|
else
|
1625 |
|
|
rf = rn->rfd;
|
1626 |
|
|
|
1627 |
|
|
if (rf == -1)
|
1628 |
|
|
{
|
1629 |
|
|
complain (&bad_indirect_xref_complaint, sym_name);
|
1630 |
|
|
return mdebug_type_int;
|
1631 |
|
|
}
|
1632 |
|
|
xref_fh = get_rfd (fd, rf);
|
1633 |
|
|
xref_fd = xref_fh - debug_info->fdr;
|
1634 |
|
|
tp = parse_type (xref_fd, debug_info->external_aux + xref_fh->iauxBase,
|
1635 |
|
|
rn->index, (int *) NULL, xref_fh->fBigendian, sym_name);
|
1636 |
|
|
}
|
1637 |
|
|
|
1638 |
|
|
/* All these types really point to some (common) MIPS type
|
1639 |
|
|
definition, and only the type-qualifiers fully identify
|
1640 |
|
|
them. We'll make the same effort at sharing. */
|
1641 |
|
|
if (t->bt == btStruct ||
|
1642 |
|
|
t->bt == btUnion ||
|
1643 |
|
|
t->bt == btEnum ||
|
1644 |
|
|
|
1645 |
|
|
/* btSet (I think) implies that the name is a tag name, not a typedef
|
1646 |
|
|
name. This apparently is a MIPS extension for C sets. */
|
1647 |
|
|
t->bt == btSet)
|
1648 |
|
|
{
|
1649 |
|
|
char *name;
|
1650 |
|
|
|
1651 |
|
|
/* Try to cross reference this type, build new type on failure. */
|
1652 |
|
|
ax += cross_ref (fd, ax, &tp, type_code, &name, bigend, sym_name);
|
1653 |
|
|
if (tp == (struct type *) NULL)
|
1654 |
|
|
tp = init_type (type_code, 0, 0, (char *) NULL, current_objfile);
|
1655 |
|
|
|
1656 |
|
|
/* DEC c89 produces cross references to qualified aggregate types,
|
1657 |
|
|
dereference them. */
|
1658 |
|
|
while (TYPE_CODE (tp) == TYPE_CODE_PTR
|
1659 |
|
|
|| TYPE_CODE (tp) == TYPE_CODE_ARRAY)
|
1660 |
|
|
tp = tp->target_type;
|
1661 |
|
|
|
1662 |
|
|
/* Make sure that TYPE_CODE(tp) has an expected type code.
|
1663 |
|
|
Any type may be returned from cross_ref if file indirect entries
|
1664 |
|
|
are corrupted. */
|
1665 |
|
|
if (TYPE_CODE (tp) != TYPE_CODE_STRUCT
|
1666 |
|
|
&& TYPE_CODE (tp) != TYPE_CODE_UNION
|
1667 |
|
|
&& TYPE_CODE (tp) != TYPE_CODE_ENUM)
|
1668 |
|
|
{
|
1669 |
|
|
complain (&unexpected_type_code_complaint, sym_name);
|
1670 |
|
|
}
|
1671 |
|
|
else
|
1672 |
|
|
{
|
1673 |
|
|
|
1674 |
|
|
/* Usually, TYPE_CODE(tp) is already type_code. The main
|
1675 |
|
|
exception is if we guessed wrong re struct/union/enum.
|
1676 |
|
|
But for struct vs. union a wrong guess is harmless, so
|
1677 |
|
|
don't complain(). */
|
1678 |
|
|
if ((TYPE_CODE (tp) == TYPE_CODE_ENUM
|
1679 |
|
|
&& type_code != TYPE_CODE_ENUM)
|
1680 |
|
|
|| (TYPE_CODE (tp) != TYPE_CODE_ENUM
|
1681 |
|
|
&& type_code == TYPE_CODE_ENUM))
|
1682 |
|
|
{
|
1683 |
|
|
complain (&bad_tag_guess_complaint, sym_name);
|
1684 |
|
|
}
|
1685 |
|
|
|
1686 |
|
|
if (TYPE_CODE (tp) != type_code)
|
1687 |
|
|
{
|
1688 |
|
|
TYPE_CODE (tp) = type_code;
|
1689 |
|
|
}
|
1690 |
|
|
|
1691 |
|
|
/* Do not set the tag name if it is a compiler generated tag name
|
1692 |
|
|
(.Fxx or .xxfake or empty) for unnamed struct/union/enums. */
|
1693 |
|
|
if (name[0] == '.' || name[0] == '\0')
|
1694 |
|
|
TYPE_TAG_NAME (tp) = NULL;
|
1695 |
|
|
else if (TYPE_TAG_NAME (tp) == NULL
|
1696 |
|
|
|| !STREQ (TYPE_TAG_NAME (tp), name))
|
1697 |
|
|
TYPE_TAG_NAME (tp) = obsavestring (name, strlen (name),
|
1698 |
|
|
¤t_objfile->type_obstack);
|
1699 |
|
|
}
|
1700 |
|
|
}
|
1701 |
|
|
|
1702 |
|
|
/* All these types really point to some (common) MIPS type
|
1703 |
|
|
definition, and only the type-qualifiers fully identify
|
1704 |
|
|
them. We'll make the same effort at sharing.
|
1705 |
|
|
FIXME: We are not doing any guessing on range types. */
|
1706 |
|
|
if (t->bt == btRange)
|
1707 |
|
|
{
|
1708 |
|
|
char *name;
|
1709 |
|
|
|
1710 |
|
|
/* Try to cross reference this type, build new type on failure. */
|
1711 |
|
|
ax += cross_ref (fd, ax, &tp, type_code, &name, bigend, sym_name);
|
1712 |
|
|
if (tp == (struct type *) NULL)
|
1713 |
|
|
tp = init_type (type_code, 0, 0, (char *) NULL, current_objfile);
|
1714 |
|
|
|
1715 |
|
|
/* Make sure that TYPE_CODE(tp) has an expected type code.
|
1716 |
|
|
Any type may be returned from cross_ref if file indirect entries
|
1717 |
|
|
are corrupted. */
|
1718 |
|
|
if (TYPE_CODE (tp) != TYPE_CODE_RANGE)
|
1719 |
|
|
{
|
1720 |
|
|
complain (&unexpected_type_code_complaint, sym_name);
|
1721 |
|
|
}
|
1722 |
|
|
else
|
1723 |
|
|
{
|
1724 |
|
|
/* Usually, TYPE_CODE(tp) is already type_code. The main
|
1725 |
|
|
exception is if we guessed wrong re struct/union/enum. */
|
1726 |
|
|
if (TYPE_CODE (tp) != type_code)
|
1727 |
|
|
{
|
1728 |
|
|
complain (&bad_tag_guess_complaint, sym_name);
|
1729 |
|
|
TYPE_CODE (tp) = type_code;
|
1730 |
|
|
}
|
1731 |
|
|
if (TYPE_NAME (tp) == NULL || !STREQ (TYPE_NAME (tp), name))
|
1732 |
|
|
TYPE_NAME (tp) = obsavestring (name, strlen (name),
|
1733 |
|
|
¤t_objfile->type_obstack);
|
1734 |
|
|
}
|
1735 |
|
|
}
|
1736 |
|
|
if (t->bt == btTypedef)
|
1737 |
|
|
{
|
1738 |
|
|
char *name;
|
1739 |
|
|
|
1740 |
|
|
/* Try to cross reference this type, it should succeed. */
|
1741 |
|
|
ax += cross_ref (fd, ax, &tp, type_code, &name, bigend, sym_name);
|
1742 |
|
|
if (tp == (struct type *) NULL)
|
1743 |
|
|
{
|
1744 |
|
|
complain (&unable_to_cross_ref_complaint, sym_name);
|
1745 |
|
|
tp = mdebug_type_int;
|
1746 |
|
|
}
|
1747 |
|
|
}
|
1748 |
|
|
|
1749 |
|
|
/* Deal with range types */
|
1750 |
|
|
if (t->bt == btRange)
|
1751 |
|
|
{
|
1752 |
|
|
TYPE_NFIELDS (tp) = 2;
|
1753 |
|
|
TYPE_FIELDS (tp) = ((struct field *)
|
1754 |
|
|
TYPE_ALLOC (tp, 2 * sizeof (struct field)));
|
1755 |
|
|
TYPE_FIELD_NAME (tp, 0) = obsavestring ("Low", strlen ("Low"),
|
1756 |
|
|
¤t_objfile->type_obstack);
|
1757 |
|
|
TYPE_FIELD_BITPOS (tp, 0) = AUX_GET_DNLOW (bigend, ax);
|
1758 |
|
|
ax++;
|
1759 |
|
|
TYPE_FIELD_NAME (tp, 1) = obsavestring ("High", strlen ("High"),
|
1760 |
|
|
¤t_objfile->type_obstack);
|
1761 |
|
|
TYPE_FIELD_BITPOS (tp, 1) = AUX_GET_DNHIGH (bigend, ax);
|
1762 |
|
|
ax++;
|
1763 |
|
|
}
|
1764 |
|
|
|
1765 |
|
|
/* Parse all the type qualifiers now. If there are more
|
1766 |
|
|
than 6 the game will continue in the next aux */
|
1767 |
|
|
|
1768 |
|
|
while (1)
|
1769 |
|
|
{
|
1770 |
|
|
#define PARSE_TQ(tq) \
|
1771 |
|
|
if (t->tq != tqNil) \
|
1772 |
|
|
ax += upgrade_type(fd, &tp, t->tq, ax, bigend, sym_name); \
|
1773 |
|
|
else \
|
1774 |
|
|
break;
|
1775 |
|
|
|
1776 |
|
|
PARSE_TQ (tq0);
|
1777 |
|
|
PARSE_TQ (tq1);
|
1778 |
|
|
PARSE_TQ (tq2);
|
1779 |
|
|
PARSE_TQ (tq3);
|
1780 |
|
|
PARSE_TQ (tq4);
|
1781 |
|
|
PARSE_TQ (tq5);
|
1782 |
|
|
#undef PARSE_TQ
|
1783 |
|
|
|
1784 |
|
|
/* mips cc 2.x and gcc never put out continued aux entries. */
|
1785 |
|
|
if (!t->continued)
|
1786 |
|
|
break;
|
1787 |
|
|
|
1788 |
|
|
(*debug_swap->swap_tir_in) (bigend, &ax->a_ti, t);
|
1789 |
|
|
ax++;
|
1790 |
|
|
}
|
1791 |
|
|
|
1792 |
|
|
/* Complain for illegal continuations due to corrupt aux entries. */
|
1793 |
|
|
if (t->continued)
|
1794 |
|
|
complain (&bad_continued_complaint, sym_name);
|
1795 |
|
|
|
1796 |
|
|
return tp;
|
1797 |
|
|
}
|
1798 |
|
|
|
1799 |
|
|
/* Make up a complex type from a basic one. Type is passed by
|
1800 |
|
|
reference in TPP and side-effected as necessary. The type
|
1801 |
|
|
qualifier TQ says how to handle the aux symbols at AX for
|
1802 |
|
|
the symbol SX we are currently analyzing. BIGEND says whether
|
1803 |
|
|
aux symbols are big-endian or little-endian.
|
1804 |
|
|
Returns the number of aux symbols we parsed. */
|
1805 |
|
|
|
1806 |
|
|
static int
|
1807 |
|
|
upgrade_type (fd, tpp, tq, ax, bigend, sym_name)
|
1808 |
|
|
int fd;
|
1809 |
|
|
struct type **tpp;
|
1810 |
|
|
int tq;
|
1811 |
|
|
union aux_ext *ax;
|
1812 |
|
|
int bigend;
|
1813 |
|
|
char *sym_name;
|
1814 |
|
|
{
|
1815 |
|
|
int off;
|
1816 |
|
|
struct type *t;
|
1817 |
|
|
|
1818 |
|
|
/* Used in array processing */
|
1819 |
|
|
int rf, id;
|
1820 |
|
|
FDR *fh;
|
1821 |
|
|
struct type *range;
|
1822 |
|
|
struct type *indx;
|
1823 |
|
|
int lower, upper;
|
1824 |
|
|
RNDXR rndx;
|
1825 |
|
|
|
1826 |
|
|
switch (tq)
|
1827 |
|
|
{
|
1828 |
|
|
case tqPtr:
|
1829 |
|
|
t = lookup_pointer_type (*tpp);
|
1830 |
|
|
*tpp = t;
|
1831 |
|
|
return 0;
|
1832 |
|
|
|
1833 |
|
|
case tqProc:
|
1834 |
|
|
t = lookup_function_type (*tpp);
|
1835 |
|
|
*tpp = t;
|
1836 |
|
|
return 0;
|
1837 |
|
|
|
1838 |
|
|
case tqArray:
|
1839 |
|
|
off = 0;
|
1840 |
|
|
|
1841 |
|
|
/* Determine and record the domain type (type of index) */
|
1842 |
|
|
(*debug_swap->swap_rndx_in) (bigend, &ax->a_rndx, &rndx);
|
1843 |
|
|
id = rndx.index;
|
1844 |
|
|
rf = rndx.rfd;
|
1845 |
|
|
if (rf == 0xfff)
|
1846 |
|
|
{
|
1847 |
|
|
ax++;
|
1848 |
|
|
rf = AUX_GET_ISYM (bigend, ax);
|
1849 |
|
|
off++;
|
1850 |
|
|
}
|
1851 |
|
|
fh = get_rfd (fd, rf);
|
1852 |
|
|
|
1853 |
|
|
indx = parse_type (fh - debug_info->fdr,
|
1854 |
|
|
debug_info->external_aux + fh->iauxBase,
|
1855 |
|
|
id, (int *) NULL, bigend, sym_name);
|
1856 |
|
|
|
1857 |
|
|
/* The bounds type should be an integer type, but might be anything
|
1858 |
|
|
else due to corrupt aux entries. */
|
1859 |
|
|
if (TYPE_CODE (indx) != TYPE_CODE_INT)
|
1860 |
|
|
{
|
1861 |
|
|
complain (&array_index_type_complaint, sym_name);
|
1862 |
|
|
indx = mdebug_type_int;
|
1863 |
|
|
}
|
1864 |
|
|
|
1865 |
|
|
/* Get the bounds, and create the array type. */
|
1866 |
|
|
ax++;
|
1867 |
|
|
lower = AUX_GET_DNLOW (bigend, ax);
|
1868 |
|
|
ax++;
|
1869 |
|
|
upper = AUX_GET_DNHIGH (bigend, ax);
|
1870 |
|
|
ax++;
|
1871 |
|
|
rf = AUX_GET_WIDTH (bigend, ax); /* bit size of array element */
|
1872 |
|
|
|
1873 |
|
|
range = create_range_type ((struct type *) NULL, indx,
|
1874 |
|
|
lower, upper);
|
1875 |
|
|
|
1876 |
|
|
t = create_array_type ((struct type *) NULL, *tpp, range);
|
1877 |
|
|
|
1878 |
|
|
/* We used to fill in the supplied array element bitsize
|
1879 |
|
|
here if the TYPE_LENGTH of the target type was zero.
|
1880 |
|
|
This happens for a `pointer to an array of anonymous structs',
|
1881 |
|
|
but in this case the array element bitsize is also zero,
|
1882 |
|
|
so nothing is gained.
|
1883 |
|
|
And we used to check the TYPE_LENGTH of the target type against
|
1884 |
|
|
the supplied array element bitsize.
|
1885 |
|
|
gcc causes a mismatch for `pointer to array of object',
|
1886 |
|
|
since the sdb directives it uses do not have a way of
|
1887 |
|
|
specifying the bitsize, but it does no harm (the
|
1888 |
|
|
TYPE_LENGTH should be correct) and we should be able to
|
1889 |
|
|
ignore the erroneous bitsize from the auxiliary entry safely.
|
1890 |
|
|
dbx seems to ignore it too. */
|
1891 |
|
|
|
1892 |
|
|
/* TYPE_FLAG_TARGET_STUB now takes care of the zero TYPE_LENGTH
|
1893 |
|
|
problem. */
|
1894 |
|
|
if (TYPE_LENGTH (*tpp) == 0)
|
1895 |
|
|
{
|
1896 |
|
|
TYPE_FLAGS (t) |= TYPE_FLAG_TARGET_STUB;
|
1897 |
|
|
}
|
1898 |
|
|
|
1899 |
|
|
*tpp = t;
|
1900 |
|
|
return 4 + off;
|
1901 |
|
|
|
1902 |
|
|
case tqVol:
|
1903 |
|
|
/* Volatile -- currently ignored */
|
1904 |
|
|
return 0;
|
1905 |
|
|
|
1906 |
|
|
case tqConst:
|
1907 |
|
|
/* Const -- currently ignored */
|
1908 |
|
|
return 0;
|
1909 |
|
|
|
1910 |
|
|
default:
|
1911 |
|
|
complain (&unknown_type_qual_complaint, tq);
|
1912 |
|
|
return 0;
|
1913 |
|
|
}
|
1914 |
|
|
}
|
1915 |
|
|
|
1916 |
|
|
|
1917 |
|
|
/* Parse a procedure descriptor record PR. Note that the procedure is
|
1918 |
|
|
parsed _after_ the local symbols, now we just insert the extra
|
1919 |
|
|
information we need into a MIPS_EFI_SYMBOL_NAME symbol that has
|
1920 |
|
|
already been placed in the procedure's main block. Note also that
|
1921 |
|
|
images that have been partially stripped (ld -x) have been deprived
|
1922 |
|
|
of local symbols, and we have to cope with them here. FIRST_OFF is
|
1923 |
|
|
the offset of the first procedure for this FDR; we adjust the
|
1924 |
|
|
address by this amount, but I don't know why. SEARCH_SYMTAB is the symtab
|
1925 |
|
|
to look for the function which contains the MIPS_EFI_SYMBOL_NAME symbol
|
1926 |
|
|
in question, or NULL to use top_stack->cur_block. */
|
1927 |
|
|
|
1928 |
|
|
static void parse_procedure PARAMS ((PDR *, struct symtab *,
|
1929 |
|
|
struct partial_symtab *));
|
1930 |
|
|
|
1931 |
|
|
static void
|
1932 |
|
|
parse_procedure (pr, search_symtab, pst)
|
1933 |
|
|
PDR *pr;
|
1934 |
|
|
struct symtab *search_symtab;
|
1935 |
|
|
struct partial_symtab *pst;
|
1936 |
|
|
{
|
1937 |
|
|
struct symbol *s, *i;
|
1938 |
|
|
struct block *b;
|
1939 |
|
|
struct mips_extra_func_info *e;
|
1940 |
|
|
char *sh_name;
|
1941 |
|
|
|
1942 |
|
|
/* Simple rule to find files linked "-x" */
|
1943 |
|
|
if (cur_fdr->rss == -1)
|
1944 |
|
|
{
|
1945 |
|
|
if (pr->isym == -1)
|
1946 |
|
|
{
|
1947 |
|
|
/* Static procedure at address pr->adr. Sigh. */
|
1948 |
|
|
/* FIXME-32x64. assuming pr->adr fits in long. */
|
1949 |
|
|
complain (&pdr_static_symbol_complaint, (unsigned long) pr->adr);
|
1950 |
|
|
return;
|
1951 |
|
|
}
|
1952 |
|
|
else
|
1953 |
|
|
{
|
1954 |
|
|
/* external */
|
1955 |
|
|
EXTR she;
|
1956 |
|
|
|
1957 |
|
|
(*debug_swap->swap_ext_in) (cur_bfd,
|
1958 |
|
|
((char *) debug_info->external_ext
|
1959 |
|
|
+ (pr->isym
|
1960 |
|
|
* debug_swap->external_ext_size)),
|
1961 |
|
|
&she);
|
1962 |
|
|
sh_name = debug_info->ssext + she.asym.iss;
|
1963 |
|
|
}
|
1964 |
|
|
}
|
1965 |
|
|
else
|
1966 |
|
|
{
|
1967 |
|
|
/* Full symbols */
|
1968 |
|
|
SYMR sh;
|
1969 |
|
|
|
1970 |
|
|
(*debug_swap->swap_sym_in) (cur_bfd,
|
1971 |
|
|
((char *) debug_info->external_sym
|
1972 |
|
|
+ ((cur_fdr->isymBase + pr->isym)
|
1973 |
|
|
* debug_swap->external_sym_size)),
|
1974 |
|
|
&sh);
|
1975 |
|
|
sh_name = debug_info->ss + cur_fdr->issBase + sh.iss;
|
1976 |
|
|
}
|
1977 |
|
|
|
1978 |
|
|
if (search_symtab != NULL)
|
1979 |
|
|
{
|
1980 |
|
|
#if 0
|
1981 |
|
|
/* This loses both in the case mentioned (want a static, find a global),
|
1982 |
|
|
but also if we are looking up a non-mangled name which happens to
|
1983 |
|
|
match the name of a mangled function. */
|
1984 |
|
|
/* We have to save the cur_fdr across the call to lookup_symbol.
|
1985 |
|
|
If the pdr is for a static function and if a global function with
|
1986 |
|
|
the same name exists, lookup_symbol will eventually read in the symtab
|
1987 |
|
|
for the global function and clobber cur_fdr. */
|
1988 |
|
|
FDR *save_cur_fdr = cur_fdr;
|
1989 |
|
|
s = lookup_symbol (sh_name, NULL, VAR_NAMESPACE, 0, NULL);
|
1990 |
|
|
cur_fdr = save_cur_fdr;
|
1991 |
|
|
#else
|
1992 |
|
|
s = mylookup_symbol
|
1993 |
|
|
(sh_name,
|
1994 |
|
|
BLOCKVECTOR_BLOCK (BLOCKVECTOR (search_symtab), STATIC_BLOCK),
|
1995 |
|
|
VAR_NAMESPACE,
|
1996 |
|
|
LOC_BLOCK);
|
1997 |
|
|
#endif
|
1998 |
|
|
}
|
1999 |
|
|
else
|
2000 |
|
|
s = mylookup_symbol (sh_name, top_stack->cur_block,
|
2001 |
|
|
VAR_NAMESPACE, LOC_BLOCK);
|
2002 |
|
|
|
2003 |
|
|
if (s != 0)
|
2004 |
|
|
{
|
2005 |
|
|
b = SYMBOL_BLOCK_VALUE (s);
|
2006 |
|
|
}
|
2007 |
|
|
else
|
2008 |
|
|
{
|
2009 |
|
|
complain (&pdr_for_nonsymbol_complaint, sh_name);
|
2010 |
|
|
#if 1
|
2011 |
|
|
return;
|
2012 |
|
|
#else
|
2013 |
|
|
/* FIXME -- delete. We can't do symbol allocation now; it's all done. */
|
2014 |
|
|
s = new_symbol (sh_name);
|
2015 |
|
|
SYMBOL_NAMESPACE (s) = VAR_NAMESPACE;
|
2016 |
|
|
SYMBOL_CLASS (s) = LOC_BLOCK;
|
2017 |
|
|
/* Donno its type, hope int is ok */
|
2018 |
|
|
SYMBOL_TYPE (s) = lookup_function_type (mdebug_type_int);
|
2019 |
|
|
add_symbol (s, top_stack->cur_block);
|
2020 |
|
|
/* Wont have symbols for this one */
|
2021 |
|
|
b = new_block (2);
|
2022 |
|
|
SYMBOL_BLOCK_VALUE (s) = b;
|
2023 |
|
|
BLOCK_FUNCTION (b) = s;
|
2024 |
|
|
BLOCK_START (b) = pr->adr;
|
2025 |
|
|
/* BOUND used to be the end of procedure's text, but the
|
2026 |
|
|
argument is no longer passed in. */
|
2027 |
|
|
BLOCK_END (b) = bound;
|
2028 |
|
|
BLOCK_SUPERBLOCK (b) = top_stack->cur_block;
|
2029 |
|
|
add_block (b, top_stack->cur_st);
|
2030 |
|
|
#endif
|
2031 |
|
|
}
|
2032 |
|
|
|
2033 |
|
|
i = mylookup_symbol (MIPS_EFI_SYMBOL_NAME, b, LABEL_NAMESPACE, LOC_CONST);
|
2034 |
|
|
|
2035 |
|
|
if (i)
|
2036 |
|
|
{
|
2037 |
|
|
e = (struct mips_extra_func_info *) SYMBOL_VALUE (i);
|
2038 |
|
|
e->pdr = *pr;
|
2039 |
|
|
e->pdr.isym = (long) s;
|
2040 |
|
|
|
2041 |
|
|
/* GDB expects the absolute function start address for the
|
2042 |
|
|
procedure descriptor in e->pdr.adr.
|
2043 |
|
|
As the address in the procedure descriptor is usually relative,
|
2044 |
|
|
we would have to relocate e->pdr.adr with cur_fdr->adr and
|
2045 |
|
|
ANOFFSET (pst->section_offsets, SECT_OFF_TEXT).
|
2046 |
|
|
Unfortunately cur_fdr->adr and e->pdr.adr are both absolute
|
2047 |
|
|
in shared libraries on some systems, and on other systems
|
2048 |
|
|
e->pdr.adr is sometimes offset by a bogus value.
|
2049 |
|
|
To work around these problems, we replace e->pdr.adr with
|
2050 |
|
|
the start address of the function. */
|
2051 |
|
|
e->pdr.adr = BLOCK_START (b);
|
2052 |
|
|
|
2053 |
|
|
/* Correct incorrect setjmp procedure descriptor from the library
|
2054 |
|
|
to make backtrace through setjmp work. */
|
2055 |
|
|
if (e->pdr.pcreg == 0 && STREQ (sh_name, "setjmp"))
|
2056 |
|
|
{
|
2057 |
|
|
complain (&bad_setjmp_pdr_complaint, 0);
|
2058 |
|
|
e->pdr.pcreg = RA_REGNUM;
|
2059 |
|
|
e->pdr.regmask = 0x80000000;
|
2060 |
|
|
e->pdr.regoffset = -4;
|
2061 |
|
|
}
|
2062 |
|
|
}
|
2063 |
|
|
|
2064 |
|
|
/* It would be reasonable that functions that have been compiled
|
2065 |
|
|
without debugging info have a btNil type for their return value,
|
2066 |
|
|
and functions that are void and are compiled with debugging info
|
2067 |
|
|
have btVoid.
|
2068 |
|
|
gcc and DEC f77 put out btNil types for both cases, so btNil is mapped
|
2069 |
|
|
to TYPE_CODE_VOID in parse_type to get the `compiled with debugging info'
|
2070 |
|
|
case right.
|
2071 |
|
|
The glevel field in cur_fdr could be used to determine the presence
|
2072 |
|
|
of debugging info, but GCC doesn't always pass the -g switch settings
|
2073 |
|
|
to the assembler and GAS doesn't set the glevel field from the -g switch
|
2074 |
|
|
settings.
|
2075 |
|
|
To work around these problems, the return value type of a TYPE_CODE_VOID
|
2076 |
|
|
function is adjusted accordingly if no debugging info was found in the
|
2077 |
|
|
compilation unit. */
|
2078 |
|
|
|
2079 |
|
|
if (processing_gcc_compilation == 0
|
2080 |
|
|
&& found_ecoff_debugging_info == 0
|
2081 |
|
|
&& TYPE_CODE (TYPE_TARGET_TYPE (SYMBOL_TYPE (s))) == TYPE_CODE_VOID)
|
2082 |
|
|
SYMBOL_TYPE (s) = nodebug_func_symbol_type;
|
2083 |
|
|
}
|
2084 |
|
|
|
2085 |
|
|
/* Relocate the extra function info pointed to by the symbol table. */
|
2086 |
|
|
|
2087 |
|
|
void
|
2088 |
|
|
ecoff_relocate_efi (sym, delta)
|
2089 |
|
|
struct symbol *sym;
|
2090 |
|
|
CORE_ADDR delta;
|
2091 |
|
|
{
|
2092 |
|
|
struct mips_extra_func_info *e;
|
2093 |
|
|
|
2094 |
|
|
e = (struct mips_extra_func_info *) SYMBOL_VALUE (sym);
|
2095 |
|
|
|
2096 |
|
|
e->pdr.adr += delta;
|
2097 |
|
|
}
|
2098 |
|
|
|
2099 |
|
|
/* Parse the external symbol ES. Just call parse_symbol() after
|
2100 |
|
|
making sure we know where the aux are for it.
|
2101 |
|
|
BIGEND says whether aux entries are big-endian or little-endian.
|
2102 |
|
|
|
2103 |
|
|
This routine clobbers top_stack->cur_block and ->cur_st. */
|
2104 |
|
|
|
2105 |
|
|
static void parse_external PARAMS ((EXTR *, int, struct section_offsets *));
|
2106 |
|
|
|
2107 |
|
|
static void
|
2108 |
|
|
parse_external (es, bigend, section_offsets)
|
2109 |
|
|
EXTR *es;
|
2110 |
|
|
int bigend;
|
2111 |
|
|
struct section_offsets *section_offsets;
|
2112 |
|
|
{
|
2113 |
|
|
union aux_ext *ax;
|
2114 |
|
|
|
2115 |
|
|
if (es->ifd != ifdNil)
|
2116 |
|
|
{
|
2117 |
|
|
cur_fd = es->ifd;
|
2118 |
|
|
cur_fdr = debug_info->fdr + cur_fd;
|
2119 |
|
|
ax = debug_info->external_aux + cur_fdr->iauxBase;
|
2120 |
|
|
}
|
2121 |
|
|
else
|
2122 |
|
|
{
|
2123 |
|
|
cur_fdr = debug_info->fdr;
|
2124 |
|
|
ax = 0;
|
2125 |
|
|
}
|
2126 |
|
|
|
2127 |
|
|
/* Reading .o files */
|
2128 |
|
|
if (SC_IS_UNDEF (es->asym.sc) || es->asym.sc == scNil)
|
2129 |
|
|
{
|
2130 |
|
|
char *what;
|
2131 |
|
|
switch (es->asym.st)
|
2132 |
|
|
{
|
2133 |
|
|
case stNil:
|
2134 |
|
|
/* These are generated for static symbols in .o files,
|
2135 |
|
|
ignore them. */
|
2136 |
|
|
return;
|
2137 |
|
|
case stStaticProc:
|
2138 |
|
|
case stProc:
|
2139 |
|
|
what = "procedure";
|
2140 |
|
|
n_undef_procs++;
|
2141 |
|
|
break;
|
2142 |
|
|
case stGlobal:
|
2143 |
|
|
what = "variable";
|
2144 |
|
|
n_undef_vars++;
|
2145 |
|
|
break;
|
2146 |
|
|
case stLabel:
|
2147 |
|
|
what = "label";
|
2148 |
|
|
n_undef_labels++;
|
2149 |
|
|
break;
|
2150 |
|
|
default:
|
2151 |
|
|
what = "symbol";
|
2152 |
|
|
break;
|
2153 |
|
|
}
|
2154 |
|
|
n_undef_symbols++;
|
2155 |
|
|
/* FIXME: Turn this into a complaint? */
|
2156 |
|
|
if (info_verbose)
|
2157 |
|
|
printf_filtered ("Warning: %s `%s' is undefined (in %s)\n",
|
2158 |
|
|
what, debug_info->ssext + es->asym.iss,
|
2159 |
|
|
fdr_name (cur_fdr));
|
2160 |
|
|
return;
|
2161 |
|
|
}
|
2162 |
|
|
|
2163 |
|
|
switch (es->asym.st)
|
2164 |
|
|
{
|
2165 |
|
|
case stProc:
|
2166 |
|
|
case stStaticProc:
|
2167 |
|
|
/* There is no need to parse the external procedure symbols.
|
2168 |
|
|
If they are from objects compiled without -g, their index will
|
2169 |
|
|
be indexNil, and the symbol definition from the minimal symbol
|
2170 |
|
|
is preferrable (yielding a function returning int instead of int).
|
2171 |
|
|
If the index points to a local procedure symbol, the local
|
2172 |
|
|
symbol already provides the correct type.
|
2173 |
|
|
Note that the index of the external procedure symbol points
|
2174 |
|
|
to the local procedure symbol in the local symbol table, and
|
2175 |
|
|
_not_ to the auxiliary symbol info. */
|
2176 |
|
|
break;
|
2177 |
|
|
case stGlobal:
|
2178 |
|
|
case stLabel:
|
2179 |
|
|
/* Global common symbols are resolved by the runtime loader,
|
2180 |
|
|
ignore them. */
|
2181 |
|
|
if (SC_IS_COMMON (es->asym.sc))
|
2182 |
|
|
break;
|
2183 |
|
|
|
2184 |
|
|
/* Note that the case of a symbol with indexNil must be handled
|
2185 |
|
|
anyways by parse_symbol(). */
|
2186 |
|
|
parse_symbol (&es->asym, ax, (char *) NULL, bigend, section_offsets);
|
2187 |
|
|
break;
|
2188 |
|
|
default:
|
2189 |
|
|
break;
|
2190 |
|
|
}
|
2191 |
|
|
}
|
2192 |
|
|
|
2193 |
|
|
/* Parse the line number info for file descriptor FH into
|
2194 |
|
|
GDB's linetable LT. MIPS' encoding requires a little bit
|
2195 |
|
|
of magic to get things out. Note also that MIPS' line
|
2196 |
|
|
numbers can go back and forth, apparently we can live
|
2197 |
|
|
with that and do not need to reorder our linetables */
|
2198 |
|
|
|
2199 |
|
|
static void parse_lines PARAMS ((FDR *, PDR *, struct linetable *, int,
|
2200 |
|
|
struct partial_symtab *, CORE_ADDR));
|
2201 |
|
|
|
2202 |
|
|
static void
|
2203 |
|
|
parse_lines (fh, pr, lt, maxlines, pst, lowest_pdr_addr)
|
2204 |
|
|
FDR *fh;
|
2205 |
|
|
PDR *pr;
|
2206 |
|
|
struct linetable *lt;
|
2207 |
|
|
int maxlines;
|
2208 |
|
|
struct partial_symtab *pst;
|
2209 |
|
|
CORE_ADDR lowest_pdr_addr;
|
2210 |
|
|
{
|
2211 |
|
|
unsigned char *base;
|
2212 |
|
|
int j, k;
|
2213 |
|
|
int delta, count, lineno = 0;
|
2214 |
|
|
|
2215 |
|
|
if (fh->cbLine == 0)
|
2216 |
|
|
return;
|
2217 |
|
|
|
2218 |
|
|
/* Scan by procedure descriptors */
|
2219 |
|
|
k = 0;
|
2220 |
|
|
for (j = 0; j < fh->cpd; j++, pr++)
|
2221 |
|
|
{
|
2222 |
|
|
CORE_ADDR l;
|
2223 |
|
|
CORE_ADDR adr;
|
2224 |
|
|
unsigned char *halt;
|
2225 |
|
|
|
2226 |
|
|
/* No code for this one */
|
2227 |
|
|
if (pr->iline == ilineNil ||
|
2228 |
|
|
pr->lnLow == -1 || pr->lnHigh == -1)
|
2229 |
|
|
continue;
|
2230 |
|
|
|
2231 |
|
|
/* Determine start and end address of compressed line bytes for
|
2232 |
|
|
this procedure. */
|
2233 |
|
|
base = debug_info->line + fh->cbLineOffset;
|
2234 |
|
|
if (j != (fh->cpd - 1))
|
2235 |
|
|
halt = base + pr[1].cbLineOffset;
|
2236 |
|
|
else
|
2237 |
|
|
halt = base + fh->cbLine;
|
2238 |
|
|
base += pr->cbLineOffset;
|
2239 |
|
|
|
2240 |
|
|
adr = pst->textlow + pr->adr - lowest_pdr_addr;
|
2241 |
|
|
|
2242 |
|
|
l = adr >> 2; /* in words */
|
2243 |
|
|
for (lineno = pr->lnLow; base < halt;)
|
2244 |
|
|
{
|
2245 |
|
|
count = *base & 0x0f;
|
2246 |
|
|
delta = *base++ >> 4;
|
2247 |
|
|
if (delta >= 8)
|
2248 |
|
|
delta -= 16;
|
2249 |
|
|
if (delta == -8)
|
2250 |
|
|
{
|
2251 |
|
|
delta = (base[0] << 8) | base[1];
|
2252 |
|
|
if (delta >= 0x8000)
|
2253 |
|
|
delta -= 0x10000;
|
2254 |
|
|
base += 2;
|
2255 |
|
|
}
|
2256 |
|
|
lineno += delta; /* first delta is 0 */
|
2257 |
|
|
|
2258 |
|
|
/* Complain if the line table overflows. Could happen
|
2259 |
|
|
with corrupt binaries. */
|
2260 |
|
|
if (lt->nitems >= maxlines)
|
2261 |
|
|
{
|
2262 |
|
|
complain (&bad_linetable_guess_complaint, fdr_name (fh));
|
2263 |
|
|
break;
|
2264 |
|
|
}
|
2265 |
|
|
k = add_line (lt, lineno, l, k);
|
2266 |
|
|
l += count + 1;
|
2267 |
|
|
}
|
2268 |
|
|
}
|
2269 |
|
|
}
|
2270 |
|
|
|
2271 |
|
|
/* Master parsing procedure for first-pass reading of file symbols
|
2272 |
|
|
into a partial_symtab. */
|
2273 |
|
|
|
2274 |
|
|
static void
|
2275 |
|
|
parse_partial_symbols (objfile)
|
2276 |
|
|
struct objfile *objfile;
|
2277 |
|
|
{
|
2278 |
|
|
const bfd_size_type external_sym_size = debug_swap->external_sym_size;
|
2279 |
|
|
const bfd_size_type external_rfd_size = debug_swap->external_rfd_size;
|
2280 |
|
|
const bfd_size_type external_ext_size = debug_swap->external_ext_size;
|
2281 |
|
|
void (*const swap_ext_in) PARAMS ((bfd *, PTR, EXTR *))
|
2282 |
|
|
= debug_swap->swap_ext_in;
|
2283 |
|
|
void (*const swap_sym_in) PARAMS ((bfd *, PTR, SYMR *))
|
2284 |
|
|
= debug_swap->swap_sym_in;
|
2285 |
|
|
void (*const swap_rfd_in) PARAMS ((bfd *, PTR, RFDT *))
|
2286 |
|
|
= debug_swap->swap_rfd_in;
|
2287 |
|
|
int f_idx, s_idx;
|
2288 |
|
|
HDRR *hdr = &debug_info->symbolic_header;
|
2289 |
|
|
/* Running pointers */
|
2290 |
|
|
FDR *fh;
|
2291 |
|
|
char *ext_out;
|
2292 |
|
|
char *ext_out_end;
|
2293 |
|
|
EXTR *ext_block;
|
2294 |
|
|
register EXTR *ext_in;
|
2295 |
|
|
EXTR *ext_in_end;
|
2296 |
|
|
SYMR sh;
|
2297 |
|
|
struct partial_symtab *pst;
|
2298 |
|
|
int textlow_not_set = 1;
|
2299 |
|
|
int past_first_source_file = 0;
|
2300 |
|
|
|
2301 |
|
|
/* List of current psymtab's include files */
|
2302 |
|
|
char **psymtab_include_list;
|
2303 |
|
|
int includes_allocated;
|
2304 |
|
|
int includes_used;
|
2305 |
|
|
EXTR *extern_tab;
|
2306 |
|
|
struct pst_map *fdr_to_pst;
|
2307 |
|
|
/* Index within current psymtab dependency list */
|
2308 |
|
|
struct partial_symtab **dependency_list;
|
2309 |
|
|
int dependencies_used, dependencies_allocated;
|
2310 |
|
|
struct cleanup *old_chain;
|
2311 |
|
|
char *name;
|
2312 |
|
|
enum language prev_language;
|
2313 |
|
|
asection *text_sect;
|
2314 |
|
|
int relocatable = 0;
|
2315 |
|
|
|
2316 |
|
|
/* Irix 5.2 shared libraries have a fh->adr field of zero, but
|
2317 |
|
|
the shared libraries are prelinked at a high memory address.
|
2318 |
|
|
We have to adjust the start address of the object file for this case,
|
2319 |
|
|
by setting it to the start address of the first procedure in the file.
|
2320 |
|
|
But we should do no adjustments if we are debugging a .o file, where
|
2321 |
|
|
the text section (and fh->adr) really starts at zero. */
|
2322 |
|
|
text_sect = bfd_get_section_by_name (cur_bfd, ".text");
|
2323 |
|
|
if (text_sect != NULL
|
2324 |
|
|
&& (bfd_get_section_flags (cur_bfd, text_sect) & SEC_RELOC))
|
2325 |
|
|
relocatable = 1;
|
2326 |
|
|
|
2327 |
|
|
extern_tab = (EXTR *) obstack_alloc (&objfile->psymbol_obstack,
|
2328 |
|
|
sizeof (EXTR) * hdr->iextMax);
|
2329 |
|
|
|
2330 |
|
|
includes_allocated = 30;
|
2331 |
|
|
includes_used = 0;
|
2332 |
|
|
psymtab_include_list = (char **) alloca (includes_allocated *
|
2333 |
|
|
sizeof (char *));
|
2334 |
|
|
next_symbol_text_func = mdebug_next_symbol_text;
|
2335 |
|
|
|
2336 |
|
|
dependencies_allocated = 30;
|
2337 |
|
|
dependencies_used = 0;
|
2338 |
|
|
dependency_list =
|
2339 |
|
|
(struct partial_symtab **) alloca (dependencies_allocated *
|
2340 |
|
|
sizeof (struct partial_symtab *));
|
2341 |
|
|
|
2342 |
|
|
last_source_file = NULL;
|
2343 |
|
|
|
2344 |
|
|
/*
|
2345 |
|
|
* Big plan:
|
2346 |
|
|
*
|
2347 |
|
|
* Only parse the Local and External symbols, and the Relative FDR.
|
2348 |
|
|
* Fixup enough of the loader symtab to be able to use it.
|
2349 |
|
|
* Allocate space only for the file's portions we need to
|
2350 |
|
|
* look at. (XXX)
|
2351 |
|
|
*/
|
2352 |
|
|
|
2353 |
|
|
max_gdbinfo = 0;
|
2354 |
|
|
max_glevel = MIN_GLEVEL;
|
2355 |
|
|
|
2356 |
|
|
/* Allocate the map FDR -> PST.
|
2357 |
|
|
Minor hack: -O3 images might claim some global data belongs
|
2358 |
|
|
to FDR -1. We`ll go along with that */
|
2359 |
|
|
fdr_to_pst = (struct pst_map *) xzalloc ((hdr->ifdMax + 1) * sizeof *fdr_to_pst);
|
2360 |
|
|
old_chain = make_cleanup (free, fdr_to_pst);
|
2361 |
|
|
fdr_to_pst++;
|
2362 |
|
|
{
|
2363 |
|
|
struct partial_symtab *pst = new_psymtab ("", objfile);
|
2364 |
|
|
fdr_to_pst[-1].pst = pst;
|
2365 |
|
|
FDR_IDX (pst) = -1;
|
2366 |
|
|
}
|
2367 |
|
|
|
2368 |
|
|
/* Allocate the global pending list. */
|
2369 |
|
|
pending_list =
|
2370 |
|
|
((struct mdebug_pending **)
|
2371 |
|
|
obstack_alloc (&objfile->psymbol_obstack,
|
2372 |
|
|
hdr->ifdMax * sizeof (struct mdebug_pending *)));
|
2373 |
|
|
memset ((PTR) pending_list, 0,
|
2374 |
|
|
hdr->ifdMax * sizeof (struct mdebug_pending *));
|
2375 |
|
|
|
2376 |
|
|
/* Pass 0 over external syms: swap them in. */
|
2377 |
|
|
ext_block = (EXTR *) xmalloc (hdr->iextMax * sizeof (EXTR));
|
2378 |
|
|
make_cleanup (free, ext_block);
|
2379 |
|
|
|
2380 |
|
|
ext_out = (char *) debug_info->external_ext;
|
2381 |
|
|
ext_out_end = ext_out + hdr->iextMax * external_ext_size;
|
2382 |
|
|
ext_in = ext_block;
|
2383 |
|
|
for (; ext_out < ext_out_end; ext_out += external_ext_size, ext_in++)
|
2384 |
|
|
(*swap_ext_in) (cur_bfd, ext_out, ext_in);
|
2385 |
|
|
|
2386 |
|
|
/* Pass 1 over external syms: Presize and partition the list */
|
2387 |
|
|
ext_in = ext_block;
|
2388 |
|
|
ext_in_end = ext_in + hdr->iextMax;
|
2389 |
|
|
for (; ext_in < ext_in_end; ext_in++)
|
2390 |
|
|
{
|
2391 |
|
|
/* See calls to complain below. */
|
2392 |
|
|
if (ext_in->ifd >= -1
|
2393 |
|
|
&& ext_in->ifd < hdr->ifdMax
|
2394 |
|
|
&& ext_in->asym.iss >= 0
|
2395 |
|
|
&& ext_in->asym.iss < hdr->issExtMax)
|
2396 |
|
|
fdr_to_pst[ext_in->ifd].n_globals++;
|
2397 |
|
|
}
|
2398 |
|
|
|
2399 |
|
|
/* Pass 1.5 over files: partition out global symbol space */
|
2400 |
|
|
s_idx = 0;
|
2401 |
|
|
for (f_idx = -1; f_idx < hdr->ifdMax; f_idx++)
|
2402 |
|
|
{
|
2403 |
|
|
fdr_to_pst[f_idx].globals_offset = s_idx;
|
2404 |
|
|
s_idx += fdr_to_pst[f_idx].n_globals;
|
2405 |
|
|
fdr_to_pst[f_idx].n_globals = 0;
|
2406 |
|
|
}
|
2407 |
|
|
|
2408 |
|
|
/* ECOFF in ELF:
|
2409 |
|
|
|
2410 |
|
|
For ECOFF in ELF, we skip the creation of the minimal symbols.
|
2411 |
|
|
The ECOFF symbols should be a subset of the Elf symbols, and the
|
2412 |
|
|
section information of the elf symbols will be more accurate.
|
2413 |
|
|
FIXME! What about Irix 5's native linker?
|
2414 |
|
|
|
2415 |
|
|
By default, Elf sections which don't exist in ECOFF
|
2416 |
|
|
get put in ECOFF's absolute section by the gnu linker.
|
2417 |
|
|
Since absolute sections don't get relocated, we
|
2418 |
|
|
end up calculating an address different from that of
|
2419 |
|
|
the symbol's minimal symbol (created earlier from the
|
2420 |
|
|
Elf symtab).
|
2421 |
|
|
|
2422 |
|
|
To fix this, either :
|
2423 |
|
|
1) don't create the duplicate symbol
|
2424 |
|
|
(assumes ECOFF symtab is a subset of the ELF symtab;
|
2425 |
|
|
assumes no side-effects result from ignoring ECOFF symbol)
|
2426 |
|
|
2) create it, only if lookup for existing symbol in ELF's minimal
|
2427 |
|
|
symbols fails
|
2428 |
|
|
(inefficient;
|
2429 |
|
|
assumes no side-effects result from ignoring ECOFF symbol)
|
2430 |
|
|
3) create it, but lookup ELF's minimal symbol and use it's section
|
2431 |
|
|
during relocation, then modify "uniqify" phase to merge and
|
2432 |
|
|
eliminate the duplicate symbol
|
2433 |
|
|
(highly inefficient)
|
2434 |
|
|
|
2435 |
|
|
I've implemented #1 here...
|
2436 |
|
|
Skip the creation of the minimal symbols based on the ECOFF
|
2437 |
|
|
symbol table. */
|
2438 |
|
|
|
2439 |
|
|
/* Pass 2 over external syms: fill in external symbols */
|
2440 |
|
|
ext_in = ext_block;
|
2441 |
|
|
ext_in_end = ext_in + hdr->iextMax;
|
2442 |
|
|
for (; ext_in < ext_in_end; ext_in++)
|
2443 |
|
|
{
|
2444 |
|
|
enum minimal_symbol_type ms_type = mst_text;
|
2445 |
|
|
CORE_ADDR svalue = ext_in->asym.value;
|
2446 |
|
|
|
2447 |
|
|
/* The Irix 5 native tools seem to sometimes generate bogus
|
2448 |
|
|
external symbols. */
|
2449 |
|
|
if (ext_in->ifd < -1 || ext_in->ifd >= hdr->ifdMax)
|
2450 |
|
|
{
|
2451 |
|
|
complain (&bad_ext_ifd_complaint, ext_in->ifd, hdr->ifdMax);
|
2452 |
|
|
continue;
|
2453 |
|
|
}
|
2454 |
|
|
if (ext_in->asym.iss < 0 || ext_in->asym.iss >= hdr->issExtMax)
|
2455 |
|
|
{
|
2456 |
|
|
complain (&bad_ext_iss_complaint, ext_in->asym.iss,
|
2457 |
|
|
hdr->issExtMax);
|
2458 |
|
|
continue;
|
2459 |
|
|
}
|
2460 |
|
|
|
2461 |
|
|
extern_tab[fdr_to_pst[ext_in->ifd].globals_offset
|
2462 |
|
|
+ fdr_to_pst[ext_in->ifd].n_globals++] = *ext_in;
|
2463 |
|
|
|
2464 |
|
|
|
2465 |
|
|
if (SC_IS_UNDEF (ext_in->asym.sc) || ext_in->asym.sc == scNil)
|
2466 |
|
|
continue;
|
2467 |
|
|
|
2468 |
|
|
|
2469 |
|
|
/* Pass 3 over files, over local syms: fill in static symbols */
|
2470 |
|
|
name = debug_info->ssext + ext_in->asym.iss;
|
2471 |
|
|
|
2472 |
|
|
/* Process ECOFF Symbol Types and Storage Classes */
|
2473 |
|
|
switch (ext_in->asym.st)
|
2474 |
|
|
{
|
2475 |
|
|
case stProc:
|
2476 |
|
|
/* Beginnning of Procedure */
|
2477 |
|
|
svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
|
2478 |
|
|
break;
|
2479 |
|
|
case stStaticProc:
|
2480 |
|
|
/* Load time only static procs */
|
2481 |
|
|
ms_type = mst_file_text;
|
2482 |
|
|
svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
|
2483 |
|
|
break;
|
2484 |
|
|
case stGlobal:
|
2485 |
|
|
/* External symbol */
|
2486 |
|
|
if (SC_IS_COMMON (ext_in->asym.sc))
|
2487 |
|
|
{
|
2488 |
|
|
/* The value of a common symbol is its size, not its address.
|
2489 |
|
|
Ignore it. */
|
2490 |
|
|
continue;
|
2491 |
|
|
}
|
2492 |
|
|
else if (SC_IS_DATA (ext_in->asym.sc))
|
2493 |
|
|
{
|
2494 |
|
|
ms_type = mst_data;
|
2495 |
|
|
svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA);
|
2496 |
|
|
}
|
2497 |
|
|
else if (SC_IS_BSS (ext_in->asym.sc))
|
2498 |
|
|
{
|
2499 |
|
|
ms_type = mst_bss;
|
2500 |
|
|
svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS);
|
2501 |
|
|
}
|
2502 |
|
|
else
|
2503 |
|
|
ms_type = mst_abs;
|
2504 |
|
|
break;
|
2505 |
|
|
case stLabel:
|
2506 |
|
|
/* Label */
|
2507 |
|
|
if (SC_IS_TEXT (ext_in->asym.sc))
|
2508 |
|
|
{
|
2509 |
|
|
ms_type = mst_file_text;
|
2510 |
|
|
svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
|
2511 |
|
|
}
|
2512 |
|
|
else if (SC_IS_DATA (ext_in->asym.sc))
|
2513 |
|
|
{
|
2514 |
|
|
ms_type = mst_file_data;
|
2515 |
|
|
svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA);
|
2516 |
|
|
}
|
2517 |
|
|
else if (SC_IS_BSS (ext_in->asym.sc))
|
2518 |
|
|
{
|
2519 |
|
|
ms_type = mst_file_bss;
|
2520 |
|
|
svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS);
|
2521 |
|
|
}
|
2522 |
|
|
else
|
2523 |
|
|
ms_type = mst_abs;
|
2524 |
|
|
break;
|
2525 |
|
|
case stLocal:
|
2526 |
|
|
case stNil:
|
2527 |
|
|
/* The alpha has the section start addresses in stLocal symbols
|
2528 |
|
|
whose name starts with a `.'. Skip those but complain for all
|
2529 |
|
|
other stLocal symbols.
|
2530 |
|
|
Irix6 puts the section start addresses in stNil symbols, skip
|
2531 |
|
|
those too. */
|
2532 |
|
|
if (name[0] == '.')
|
2533 |
|
|
continue;
|
2534 |
|
|
/* Fall through. */
|
2535 |
|
|
default:
|
2536 |
|
|
ms_type = mst_unknown;
|
2537 |
|
|
complain (&unknown_ext_complaint, name);
|
2538 |
|
|
}
|
2539 |
|
|
if (!ECOFF_IN_ELF (cur_bfd))
|
2540 |
|
|
prim_record_minimal_symbol (name, svalue, ms_type, objfile);
|
2541 |
|
|
}
|
2542 |
|
|
|
2543 |
|
|
/* Pass 3 over files, over local syms: fill in static symbols */
|
2544 |
|
|
for (f_idx = 0; f_idx < hdr->ifdMax; f_idx++)
|
2545 |
|
|
{
|
2546 |
|
|
struct partial_symtab *save_pst;
|
2547 |
|
|
EXTR *ext_ptr;
|
2548 |
|
|
CORE_ADDR textlow;
|
2549 |
|
|
|
2550 |
|
|
cur_fdr = fh = debug_info->fdr + f_idx;
|
2551 |
|
|
|
2552 |
|
|
if (fh->csym == 0)
|
2553 |
|
|
{
|
2554 |
|
|
fdr_to_pst[f_idx].pst = NULL;
|
2555 |
|
|
continue;
|
2556 |
|
|
}
|
2557 |
|
|
|
2558 |
|
|
/* Determine the start address for this object file from the
|
2559 |
|
|
file header and relocate it, except for Irix 5.2 zero fh->adr. */
|
2560 |
|
|
if (fh->cpd)
|
2561 |
|
|
{
|
2562 |
|
|
textlow = fh->adr;
|
2563 |
|
|
if (relocatable || textlow != 0)
|
2564 |
|
|
textlow += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
|
2565 |
|
|
}
|
2566 |
|
|
else
|
2567 |
|
|
textlow = 0;
|
2568 |
|
|
pst = start_psymtab_common (objfile, objfile->section_offsets,
|
2569 |
|
|
fdr_name (fh),
|
2570 |
|
|
textlow,
|
2571 |
|
|
objfile->global_psymbols.next,
|
2572 |
|
|
objfile->static_psymbols.next);
|
2573 |
|
|
pst->read_symtab_private = ((char *)
|
2574 |
|
|
obstack_alloc (&objfile->psymbol_obstack,
|
2575 |
|
|
sizeof (struct symloc)));
|
2576 |
|
|
memset ((PTR) pst->read_symtab_private, 0, sizeof (struct symloc));
|
2577 |
|
|
|
2578 |
|
|
save_pst = pst;
|
2579 |
|
|
FDR_IDX (pst) = f_idx;
|
2580 |
|
|
CUR_BFD (pst) = cur_bfd;
|
2581 |
|
|
DEBUG_SWAP (pst) = debug_swap;
|
2582 |
|
|
DEBUG_INFO (pst) = debug_info;
|
2583 |
|
|
PENDING_LIST (pst) = pending_list;
|
2584 |
|
|
|
2585 |
|
|
/* The way to turn this into a symtab is to call... */
|
2586 |
|
|
pst->read_symtab = mdebug_psymtab_to_symtab;
|
2587 |
|
|
|
2588 |
|
|
/* Set up language for the pst.
|
2589 |
|
|
The language from the FDR is used if it is unambigious (e.g. cfront
|
2590 |
|
|
with native cc and g++ will set the language to C).
|
2591 |
|
|
Otherwise we have to deduce the language from the filename.
|
2592 |
|
|
Native ecoff has every header file in a separate FDR, so
|
2593 |
|
|
deduce_language_from_filename will return language_unknown for
|
2594 |
|
|
a header file, which is not what we want.
|
2595 |
|
|
But the FDRs for the header files are after the FDR for the source
|
2596 |
|
|
file, so we can assign the language of the source file to the
|
2597 |
|
|
following header files. Then we save the language in the private
|
2598 |
|
|
pst data so that we can reuse it when building symtabs. */
|
2599 |
|
|
prev_language = psymtab_language;
|
2600 |
|
|
|
2601 |
|
|
switch (fh->lang)
|
2602 |
|
|
{
|
2603 |
|
|
case langCplusplusV2:
|
2604 |
|
|
psymtab_language = language_cplus;
|
2605 |
|
|
break;
|
2606 |
|
|
default:
|
2607 |
|
|
psymtab_language = deduce_language_from_filename (fdr_name (fh));
|
2608 |
|
|
break;
|
2609 |
|
|
}
|
2610 |
|
|
if (psymtab_language == language_unknown)
|
2611 |
|
|
psymtab_language = prev_language;
|
2612 |
|
|
PST_PRIVATE (pst)->pst_language = psymtab_language;
|
2613 |
|
|
|
2614 |
|
|
pst->texthigh = pst->textlow;
|
2615 |
|
|
|
2616 |
|
|
/* For stabs-in-ecoff files, the second symbol must be @stab.
|
2617 |
|
|
This symbol is emitted by mips-tfile to signal that the
|
2618 |
|
|
current object file uses encapsulated stabs instead of mips
|
2619 |
|
|
ecoff for local symbols. (It is the second symbol because
|
2620 |
|
|
the first symbol is the stFile used to signal the start of a
|
2621 |
|
|
file). */
|
2622 |
|
|
processing_gcc_compilation = 0;
|
2623 |
|
|
if (fh->csym >= 2)
|
2624 |
|
|
{
|
2625 |
|
|
(*swap_sym_in) (cur_bfd,
|
2626 |
|
|
((char *) debug_info->external_sym
|
2627 |
|
|
+ (fh->isymBase + 1) * external_sym_size),
|
2628 |
|
|
&sh);
|
2629 |
|
|
if (STREQ (debug_info->ss + fh->issBase + sh.iss, stabs_symbol))
|
2630 |
|
|
processing_gcc_compilation = 2;
|
2631 |
|
|
}
|
2632 |
|
|
|
2633 |
|
|
if (processing_gcc_compilation != 0)
|
2634 |
|
|
{
|
2635 |
|
|
for (cur_sdx = 2; cur_sdx < fh->csym; cur_sdx++)
|
2636 |
|
|
{
|
2637 |
|
|
int type_code;
|
2638 |
|
|
char *namestring;
|
2639 |
|
|
|
2640 |
|
|
(*swap_sym_in) (cur_bfd,
|
2641 |
|
|
(((char *) debug_info->external_sym)
|
2642 |
|
|
+ (fh->isymBase + cur_sdx) * external_sym_size),
|
2643 |
|
|
&sh);
|
2644 |
|
|
type_code = ECOFF_UNMARK_STAB (sh.index);
|
2645 |
|
|
if (!ECOFF_IS_STAB (&sh))
|
2646 |
|
|
{
|
2647 |
|
|
if (sh.st == stProc || sh.st == stStaticProc)
|
2648 |
|
|
{
|
2649 |
|
|
CORE_ADDR procaddr;
|
2650 |
|
|
long isym;
|
2651 |
|
|
|
2652 |
|
|
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
|
2653 |
|
|
if (sh.st == stStaticProc)
|
2654 |
|
|
{
|
2655 |
|
|
namestring = debug_info->ss + fh->issBase + sh.iss;
|
2656 |
|
|
prim_record_minimal_symbol_and_info (namestring,
|
2657 |
|
|
sh.value,
|
2658 |
|
|
mst_file_text,
|
2659 |
|
|
NULL,
|
2660 |
|
|
SECT_OFF_TEXT,
|
2661 |
|
|
NULL,
|
2662 |
|
|
objfile);
|
2663 |
|
|
}
|
2664 |
|
|
procaddr = sh.value;
|
2665 |
|
|
|
2666 |
|
|
isym = AUX_GET_ISYM (fh->fBigendian,
|
2667 |
|
|
(debug_info->external_aux
|
2668 |
|
|
+ fh->iauxBase
|
2669 |
|
|
+ sh.index));
|
2670 |
|
|
(*swap_sym_in) (cur_bfd,
|
2671 |
|
|
((char *) debug_info->external_sym
|
2672 |
|
|
+ ((fh->isymBase + isym - 1)
|
2673 |
|
|
* external_sym_size)),
|
2674 |
|
|
&sh);
|
2675 |
|
|
if (sh.st == stEnd)
|
2676 |
|
|
{
|
2677 |
|
|
CORE_ADDR high = procaddr + sh.value;
|
2678 |
|
|
|
2679 |
|
|
/* Kludge for Irix 5.2 zero fh->adr. */
|
2680 |
|
|
if (!relocatable
|
2681 |
|
|
&& (pst->textlow == 0 || procaddr < pst->textlow))
|
2682 |
|
|
pst->textlow = procaddr;
|
2683 |
|
|
if (high > pst->texthigh)
|
2684 |
|
|
pst->texthigh = high;
|
2685 |
|
|
}
|
2686 |
|
|
}
|
2687 |
|
|
else if (sh.st == stStatic)
|
2688 |
|
|
{
|
2689 |
|
|
switch (sh.sc)
|
2690 |
|
|
{
|
2691 |
|
|
case scUndefined:
|
2692 |
|
|
case scSUndefined:
|
2693 |
|
|
case scNil:
|
2694 |
|
|
case scAbs:
|
2695 |
|
|
break;
|
2696 |
|
|
|
2697 |
|
|
case scData:
|
2698 |
|
|
case scSData:
|
2699 |
|
|
case scRData:
|
2700 |
|
|
case scPData:
|
2701 |
|
|
case scXData:
|
2702 |
|
|
namestring = debug_info->ss + fh->issBase + sh.iss;
|
2703 |
|
|
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA);
|
2704 |
|
|
prim_record_minimal_symbol_and_info (namestring,
|
2705 |
|
|
sh.value,
|
2706 |
|
|
mst_file_data,
|
2707 |
|
|
NULL,
|
2708 |
|
|
SECT_OFF_DATA,
|
2709 |
|
|
NULL,
|
2710 |
|
|
objfile);
|
2711 |
|
|
break;
|
2712 |
|
|
|
2713 |
|
|
default:
|
2714 |
|
|
/* FIXME! Shouldn't this use cases for bss,
|
2715 |
|
|
then have the default be abs? */
|
2716 |
|
|
namestring = debug_info->ss + fh->issBase + sh.iss;
|
2717 |
|
|
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS);
|
2718 |
|
|
prim_record_minimal_symbol_and_info (namestring,
|
2719 |
|
|
sh.value,
|
2720 |
|
|
mst_file_bss,
|
2721 |
|
|
NULL,
|
2722 |
|
|
SECT_OFF_BSS,
|
2723 |
|
|
NULL,
|
2724 |
|
|
objfile);
|
2725 |
|
|
break;
|
2726 |
|
|
}
|
2727 |
|
|
}
|
2728 |
|
|
continue;
|
2729 |
|
|
}
|
2730 |
|
|
/* Handle stabs continuation */
|
2731 |
|
|
{
|
2732 |
|
|
char *stabstring = debug_info->ss + fh->issBase + sh.iss;
|
2733 |
|
|
int len = strlen (stabstring);
|
2734 |
|
|
while (stabstring[len - 1] == '\\')
|
2735 |
|
|
{
|
2736 |
|
|
SYMR sh2;
|
2737 |
|
|
char *stabstring1 = stabstring;
|
2738 |
|
|
char *stabstring2;
|
2739 |
|
|
int len2;
|
2740 |
|
|
|
2741 |
|
|
/* Ignore continuation char from 1st string */
|
2742 |
|
|
len--;
|
2743 |
|
|
|
2744 |
|
|
/* Read next stabstring */
|
2745 |
|
|
cur_sdx++;
|
2746 |
|
|
(*swap_sym_in) (cur_bfd,
|
2747 |
|
|
(((char *) debug_info->external_sym)
|
2748 |
|
|
+ (fh->isymBase + cur_sdx)
|
2749 |
|
|
* external_sym_size),
|
2750 |
|
|
&sh2);
|
2751 |
|
|
stabstring2 = debug_info->ss + fh->issBase + sh2.iss;
|
2752 |
|
|
len2 = strlen (stabstring2);
|
2753 |
|
|
|
2754 |
|
|
/* Concatinate stabstring2 with stabstring1 */
|
2755 |
|
|
if (stabstring
|
2756 |
|
|
&& stabstring != debug_info->ss + fh->issBase + sh.iss)
|
2757 |
|
|
stabstring = xrealloc (stabstring, len + len2 + 1);
|
2758 |
|
|
else
|
2759 |
|
|
stabstring = xmalloc (len + len2 + 1);
|
2760 |
|
|
strcpy (stabstring, stabstring1);
|
2761 |
|
|
strcpy (stabstring + len, stabstring2);
|
2762 |
|
|
len += len2;
|
2763 |
|
|
}
|
2764 |
|
|
|
2765 |
|
|
#define SET_NAMESTRING() \
|
2766 |
|
|
namestring = stabstring
|
2767 |
|
|
#define CUR_SYMBOL_TYPE type_code
|
2768 |
|
|
#define CUR_SYMBOL_VALUE sh.value
|
2769 |
|
|
#define START_PSYMTAB(ofile,fname,low,symoff,global_syms,static_syms)\
|
2770 |
|
|
(pst = save_pst)
|
2771 |
|
|
#define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps,textlow_not_set) (void)0
|
2772 |
|
|
#define HANDLE_RBRAC(val) \
|
2773 |
|
|
if ((val) > save_pst->texthigh) save_pst->texthigh = (val);
|
2774 |
|
|
#include "partial-stab.h"
|
2775 |
|
|
|
2776 |
|
|
if (stabstring
|
2777 |
|
|
&& stabstring != debug_info->ss + fh->issBase + sh.iss)
|
2778 |
|
|
free (stabstring);
|
2779 |
|
|
}
|
2780 |
|
|
/* end - Handle continuation */
|
2781 |
|
|
}
|
2782 |
|
|
}
|
2783 |
|
|
else
|
2784 |
|
|
{
|
2785 |
|
|
for (cur_sdx = 0; cur_sdx < fh->csym;)
|
2786 |
|
|
{
|
2787 |
|
|
char *name;
|
2788 |
|
|
enum address_class class;
|
2789 |
|
|
|
2790 |
|
|
(*swap_sym_in) (cur_bfd,
|
2791 |
|
|
((char *) debug_info->external_sym
|
2792 |
|
|
+ ((fh->isymBase + cur_sdx)
|
2793 |
|
|
* external_sym_size)),
|
2794 |
|
|
&sh);
|
2795 |
|
|
|
2796 |
|
|
if (ECOFF_IS_STAB (&sh))
|
2797 |
|
|
{
|
2798 |
|
|
cur_sdx++;
|
2799 |
|
|
continue;
|
2800 |
|
|
}
|
2801 |
|
|
|
2802 |
|
|
/* Non absolute static symbols go into the minimal table. */
|
2803 |
|
|
if (SC_IS_UNDEF (sh.sc) || sh.sc == scNil
|
2804 |
|
|
|| (sh.index == indexNil
|
2805 |
|
|
&& (sh.st != stStatic || sh.sc == scAbs)))
|
2806 |
|
|
{
|
2807 |
|
|
/* FIXME, premature? */
|
2808 |
|
|
cur_sdx++;
|
2809 |
|
|
continue;
|
2810 |
|
|
}
|
2811 |
|
|
|
2812 |
|
|
name = debug_info->ss + fh->issBase + sh.iss;
|
2813 |
|
|
|
2814 |
|
|
switch (sh.sc)
|
2815 |
|
|
{
|
2816 |
|
|
case scText:
|
2817 |
|
|
case scRConst:
|
2818 |
|
|
/* The value of a stEnd symbol is the displacement from the
|
2819 |
|
|
corresponding start symbol value, do not relocate it. */
|
2820 |
|
|
if (sh.st != stEnd)
|
2821 |
|
|
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
|
2822 |
|
|
break;
|
2823 |
|
|
case scData:
|
2824 |
|
|
case scSData:
|
2825 |
|
|
case scRData:
|
2826 |
|
|
case scPData:
|
2827 |
|
|
case scXData:
|
2828 |
|
|
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA);
|
2829 |
|
|
break;
|
2830 |
|
|
case scBss:
|
2831 |
|
|
case scSBss:
|
2832 |
|
|
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS);
|
2833 |
|
|
break;
|
2834 |
|
|
}
|
2835 |
|
|
|
2836 |
|
|
switch (sh.st)
|
2837 |
|
|
{
|
2838 |
|
|
CORE_ADDR high;
|
2839 |
|
|
CORE_ADDR procaddr;
|
2840 |
|
|
int new_sdx;
|
2841 |
|
|
|
2842 |
|
|
case stStaticProc:
|
2843 |
|
|
prim_record_minimal_symbol_and_info (name, sh.value,
|
2844 |
|
|
mst_file_text, NULL,
|
2845 |
|
|
SECT_OFF_TEXT, NULL,
|
2846 |
|
|
objfile);
|
2847 |
|
|
|
2848 |
|
|
/* FALLTHROUGH */
|
2849 |
|
|
|
2850 |
|
|
case stProc:
|
2851 |
|
|
/* Usually there is a local and a global stProc symbol
|
2852 |
|
|
for a function. This means that the function name
|
2853 |
|
|
has already been entered into the mimimal symbol table
|
2854 |
|
|
while processing the global symbols in pass 2 above.
|
2855 |
|
|
One notable exception is the PROGRAM name from
|
2856 |
|
|
f77 compiled executables, it is only put out as
|
2857 |
|
|
local stProc symbol, and a global MAIN__ stProc symbol
|
2858 |
|
|
points to it. It doesn't matter though, as gdb is
|
2859 |
|
|
still able to find the PROGRAM name via the partial
|
2860 |
|
|
symbol table, and the MAIN__ symbol via the minimal
|
2861 |
|
|
symbol table. */
|
2862 |
|
|
if (sh.st == stProc)
|
2863 |
|
|
add_psymbol_to_list (name, strlen (name),
|
2864 |
|
|
VAR_NAMESPACE, LOC_BLOCK,
|
2865 |
|
|
&objfile->global_psymbols,
|
2866 |
|
|
0, sh.value, psymtab_language, objfile);
|
2867 |
|
|
else
|
2868 |
|
|
add_psymbol_to_list (name, strlen (name),
|
2869 |
|
|
VAR_NAMESPACE, LOC_BLOCK,
|
2870 |
|
|
&objfile->static_psymbols,
|
2871 |
|
|
0, sh.value, psymtab_language, objfile);
|
2872 |
|
|
|
2873 |
|
|
/* Skip over procedure to next one. */
|
2874 |
|
|
if (sh.index >= hdr->iauxMax)
|
2875 |
|
|
{
|
2876 |
|
|
/* Should not happen, but does when cross-compiling
|
2877 |
|
|
with the MIPS compiler. FIXME -- pull later. */
|
2878 |
|
|
complain (&index_complaint, name);
|
2879 |
|
|
new_sdx = cur_sdx + 1; /* Don't skip at all */
|
2880 |
|
|
}
|
2881 |
|
|
else
|
2882 |
|
|
new_sdx = AUX_GET_ISYM (fh->fBigendian,
|
2883 |
|
|
(debug_info->external_aux
|
2884 |
|
|
+ fh->iauxBase
|
2885 |
|
|
+ sh.index));
|
2886 |
|
|
procaddr = sh.value;
|
2887 |
|
|
|
2888 |
|
|
if (new_sdx <= cur_sdx)
|
2889 |
|
|
{
|
2890 |
|
|
/* This should not happen either... FIXME. */
|
2891 |
|
|
complain (&aux_index_complaint, name);
|
2892 |
|
|
new_sdx = cur_sdx + 1; /* Don't skip backward */
|
2893 |
|
|
}
|
2894 |
|
|
|
2895 |
|
|
cur_sdx = new_sdx;
|
2896 |
|
|
(*swap_sym_in) (cur_bfd,
|
2897 |
|
|
((char *) debug_info->external_sym
|
2898 |
|
|
+ ((fh->isymBase + cur_sdx - 1)
|
2899 |
|
|
* external_sym_size)),
|
2900 |
|
|
&sh);
|
2901 |
|
|
if (sh.st != stEnd)
|
2902 |
|
|
continue;
|
2903 |
|
|
|
2904 |
|
|
/* Kludge for Irix 5.2 zero fh->adr. */
|
2905 |
|
|
if (!relocatable
|
2906 |
|
|
&& (pst->textlow == 0 || procaddr < pst->textlow))
|
2907 |
|
|
pst->textlow = procaddr;
|
2908 |
|
|
|
2909 |
|
|
high = procaddr + sh.value;
|
2910 |
|
|
if (high > pst->texthigh)
|
2911 |
|
|
pst->texthigh = high;
|
2912 |
|
|
continue;
|
2913 |
|
|
|
2914 |
|
|
case stStatic: /* Variable */
|
2915 |
|
|
if (SC_IS_DATA (sh.sc))
|
2916 |
|
|
prim_record_minimal_symbol_and_info (name, sh.value,
|
2917 |
|
|
mst_file_data, NULL,
|
2918 |
|
|
SECT_OFF_DATA,
|
2919 |
|
|
NULL,
|
2920 |
|
|
objfile);
|
2921 |
|
|
else
|
2922 |
|
|
prim_record_minimal_symbol_and_info (name, sh.value,
|
2923 |
|
|
mst_file_bss, NULL,
|
2924 |
|
|
SECT_OFF_BSS,
|
2925 |
|
|
NULL,
|
2926 |
|
|
objfile);
|
2927 |
|
|
class = LOC_STATIC;
|
2928 |
|
|
break;
|
2929 |
|
|
|
2930 |
|
|
case stIndirect: /* Irix5 forward declaration */
|
2931 |
|
|
/* Skip forward declarations from Irix5 cc */
|
2932 |
|
|
goto skip;
|
2933 |
|
|
|
2934 |
|
|
case stTypedef: /* Typedef */
|
2935 |
|
|
/* Skip typedefs for forward declarations and opaque
|
2936 |
|
|
structs from alpha and mips cc. */
|
2937 |
|
|
if (sh.iss == 0 || has_opaque_xref (fh, &sh))
|
2938 |
|
|
goto skip;
|
2939 |
|
|
class = LOC_TYPEDEF;
|
2940 |
|
|
break;
|
2941 |
|
|
|
2942 |
|
|
case stConstant: /* Constant decl */
|
2943 |
|
|
class = LOC_CONST;
|
2944 |
|
|
break;
|
2945 |
|
|
|
2946 |
|
|
case stUnion:
|
2947 |
|
|
case stStruct:
|
2948 |
|
|
case stEnum:
|
2949 |
|
|
case stBlock: /* { }, str, un, enum */
|
2950 |
|
|
/* Do not create a partial symbol for cc unnamed aggregates
|
2951 |
|
|
and gcc empty aggregates. */
|
2952 |
|
|
if ((sh.sc == scInfo
|
2953 |
|
|
|| SC_IS_COMMON (sh.sc))
|
2954 |
|
|
&& sh.iss != 0
|
2955 |
|
|
&& sh.index != cur_sdx + 2)
|
2956 |
|
|
{
|
2957 |
|
|
add_psymbol_to_list (name, strlen (name),
|
2958 |
|
|
STRUCT_NAMESPACE, LOC_TYPEDEF,
|
2959 |
|
|
&objfile->static_psymbols,
|
2960 |
|
|
0, (CORE_ADDR) 0,
|
2961 |
|
|
psymtab_language, objfile);
|
2962 |
|
|
}
|
2963 |
|
|
handle_psymbol_enumerators (objfile, fh, sh.st, sh.value);
|
2964 |
|
|
|
2965 |
|
|
/* Skip over the block */
|
2966 |
|
|
new_sdx = sh.index;
|
2967 |
|
|
if (new_sdx <= cur_sdx)
|
2968 |
|
|
{
|
2969 |
|
|
/* This happens with the Ultrix kernel. */
|
2970 |
|
|
complain (&block_index_complaint, name);
|
2971 |
|
|
new_sdx = cur_sdx + 1; /* Don't skip backward */
|
2972 |
|
|
}
|
2973 |
|
|
cur_sdx = new_sdx;
|
2974 |
|
|
continue;
|
2975 |
|
|
|
2976 |
|
|
case stFile: /* File headers */
|
2977 |
|
|
case stLabel: /* Labels */
|
2978 |
|
|
case stEnd: /* Ends of files */
|
2979 |
|
|
goto skip;
|
2980 |
|
|
|
2981 |
|
|
case stLocal: /* Local variables */
|
2982 |
|
|
/* Normally these are skipped because we skip over
|
2983 |
|
|
all blocks we see. However, these can occur
|
2984 |
|
|
as visible symbols in a .h file that contains code. */
|
2985 |
|
|
goto skip;
|
2986 |
|
|
|
2987 |
|
|
default:
|
2988 |
|
|
/* Both complaints are valid: one gives symbol name,
|
2989 |
|
|
the other the offending symbol type. */
|
2990 |
|
|
complain (&unknown_sym_complaint, name);
|
2991 |
|
|
complain (&unknown_st_complaint, sh.st);
|
2992 |
|
|
cur_sdx++;
|
2993 |
|
|
continue;
|
2994 |
|
|
}
|
2995 |
|
|
/* Use this gdb symbol */
|
2996 |
|
|
add_psymbol_to_list (name, strlen (name),
|
2997 |
|
|
VAR_NAMESPACE, class,
|
2998 |
|
|
&objfile->static_psymbols,
|
2999 |
|
|
0, sh.value, psymtab_language, objfile);
|
3000 |
|
|
skip:
|
3001 |
|
|
cur_sdx++; /* Go to next file symbol */
|
3002 |
|
|
}
|
3003 |
|
|
|
3004 |
|
|
/* Now do enter the external symbols. */
|
3005 |
|
|
ext_ptr = &extern_tab[fdr_to_pst[f_idx].globals_offset];
|
3006 |
|
|
cur_sdx = fdr_to_pst[f_idx].n_globals;
|
3007 |
|
|
PST_PRIVATE (save_pst)->extern_count = cur_sdx;
|
3008 |
|
|
PST_PRIVATE (save_pst)->extern_tab = ext_ptr;
|
3009 |
|
|
for (; --cur_sdx >= 0; ext_ptr++)
|
3010 |
|
|
{
|
3011 |
|
|
enum address_class class;
|
3012 |
|
|
SYMR *psh;
|
3013 |
|
|
char *name;
|
3014 |
|
|
CORE_ADDR svalue;
|
3015 |
|
|
|
3016 |
|
|
if (ext_ptr->ifd != f_idx)
|
3017 |
|
|
abort ();
|
3018 |
|
|
psh = &ext_ptr->asym;
|
3019 |
|
|
|
3020 |
|
|
/* Do not add undefined symbols to the partial symbol table. */
|
3021 |
|
|
if (SC_IS_UNDEF (psh->sc) || psh->sc == scNil)
|
3022 |
|
|
continue;
|
3023 |
|
|
|
3024 |
|
|
svalue = psh->value;
|
3025 |
|
|
switch (psh->sc)
|
3026 |
|
|
{
|
3027 |
|
|
case scText:
|
3028 |
|
|
case scRConst:
|
3029 |
|
|
svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
|
3030 |
|
|
break;
|
3031 |
|
|
case scData:
|
3032 |
|
|
case scSData:
|
3033 |
|
|
case scRData:
|
3034 |
|
|
case scPData:
|
3035 |
|
|
case scXData:
|
3036 |
|
|
svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA);
|
3037 |
|
|
break;
|
3038 |
|
|
case scBss:
|
3039 |
|
|
case scSBss:
|
3040 |
|
|
svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS);
|
3041 |
|
|
break;
|
3042 |
|
|
}
|
3043 |
|
|
|
3044 |
|
|
switch (psh->st)
|
3045 |
|
|
{
|
3046 |
|
|
case stNil:
|
3047 |
|
|
/* These are generated for static symbols in .o files,
|
3048 |
|
|
ignore them. */
|
3049 |
|
|
continue;
|
3050 |
|
|
case stProc:
|
3051 |
|
|
case stStaticProc:
|
3052 |
|
|
/* External procedure symbols have been entered
|
3053 |
|
|
into the minimal symbol table in pass 2 above.
|
3054 |
|
|
Ignore them, as parse_external will ignore them too. */
|
3055 |
|
|
continue;
|
3056 |
|
|
case stLabel:
|
3057 |
|
|
class = LOC_LABEL;
|
3058 |
|
|
break;
|
3059 |
|
|
default:
|
3060 |
|
|
complain (&unknown_ext_complaint,
|
3061 |
|
|
debug_info->ssext + psh->iss);
|
3062 |
|
|
/* Fall through, pretend it's global. */
|
3063 |
|
|
case stGlobal:
|
3064 |
|
|
/* Global common symbols are resolved by the runtime loader,
|
3065 |
|
|
ignore them. */
|
3066 |
|
|
if (SC_IS_COMMON (psh->sc))
|
3067 |
|
|
continue;
|
3068 |
|
|
|
3069 |
|
|
class = LOC_STATIC;
|
3070 |
|
|
break;
|
3071 |
|
|
}
|
3072 |
|
|
name = debug_info->ssext + psh->iss;
|
3073 |
|
|
add_psymbol_to_list (name, strlen (name),
|
3074 |
|
|
VAR_NAMESPACE, class,
|
3075 |
|
|
&objfile->global_psymbols,
|
3076 |
|
|
0, svalue,
|
3077 |
|
|
psymtab_language, objfile);
|
3078 |
|
|
}
|
3079 |
|
|
}
|
3080 |
|
|
|
3081 |
|
|
/* Link pst to FDR. end_psymtab returns NULL if the psymtab was
|
3082 |
|
|
empty and put on the free list. */
|
3083 |
|
|
fdr_to_pst[f_idx].pst = end_psymtab (save_pst,
|
3084 |
|
|
psymtab_include_list, includes_used,
|
3085 |
|
|
-1, save_pst->texthigh,
|
3086 |
|
|
dependency_list, dependencies_used, textlow_not_set);
|
3087 |
|
|
includes_used = 0;
|
3088 |
|
|
dependencies_used = 0;
|
3089 |
|
|
|
3090 |
|
|
if (objfile->ei.entry_point >= save_pst->textlow &&
|
3091 |
|
|
objfile->ei.entry_point < save_pst->texthigh)
|
3092 |
|
|
{
|
3093 |
|
|
objfile->ei.entry_file_lowpc = save_pst->textlow;
|
3094 |
|
|
objfile->ei.entry_file_highpc = save_pst->texthigh;
|
3095 |
|
|
}
|
3096 |
|
|
|
3097 |
|
|
/* The objfile has its functions reordered if this partial symbol
|
3098 |
|
|
table overlaps any other partial symbol table.
|
3099 |
|
|
We cannot assume a reordered objfile if a partial symbol table
|
3100 |
|
|
is contained within another partial symbol table, as partial symbol
|
3101 |
|
|
tables for include files with executable code are contained
|
3102 |
|
|
within the partial symbol table for the including source file,
|
3103 |
|
|
and we do not want to flag the objfile reordered for these cases.
|
3104 |
|
|
|
3105 |
|
|
This strategy works well for Irix-5.2 shared libraries, but we
|
3106 |
|
|
might have to use a more elaborate (and slower) algorithm for
|
3107 |
|
|
other cases. */
|
3108 |
|
|
save_pst = fdr_to_pst[f_idx].pst;
|
3109 |
|
|
if (save_pst != NULL
|
3110 |
|
|
&& save_pst->textlow != 0
|
3111 |
|
|
&& !(objfile->flags & OBJF_REORDERED))
|
3112 |
|
|
{
|
3113 |
|
|
ALL_OBJFILE_PSYMTABS (objfile, pst)
|
3114 |
|
|
{
|
3115 |
|
|
if (save_pst != pst
|
3116 |
|
|
&& save_pst->textlow >= pst->textlow
|
3117 |
|
|
&& save_pst->textlow < pst->texthigh
|
3118 |
|
|
&& save_pst->texthigh > pst->texthigh)
|
3119 |
|
|
{
|
3120 |
|
|
objfile->flags |= OBJF_REORDERED;
|
3121 |
|
|
break;
|
3122 |
|
|
}
|
3123 |
|
|
}
|
3124 |
|
|
}
|
3125 |
|
|
}
|
3126 |
|
|
|
3127 |
|
|
/* Now scan the FDRs for dependencies */
|
3128 |
|
|
for (f_idx = 0; f_idx < hdr->ifdMax; f_idx++)
|
3129 |
|
|
{
|
3130 |
|
|
fh = f_idx + debug_info->fdr;
|
3131 |
|
|
pst = fdr_to_pst[f_idx].pst;
|
3132 |
|
|
|
3133 |
|
|
if (pst == (struct partial_symtab *) NULL)
|
3134 |
|
|
continue;
|
3135 |
|
|
|
3136 |
|
|
/* This should catch stabs-in-ecoff. */
|
3137 |
|
|
if (fh->crfd <= 1)
|
3138 |
|
|
continue;
|
3139 |
|
|
|
3140 |
|
|
/* Skip the first file indirect entry as it is a self dependency
|
3141 |
|
|
for source files or a reverse .h -> .c dependency for header files. */
|
3142 |
|
|
pst->number_of_dependencies = 0;
|
3143 |
|
|
pst->dependencies =
|
3144 |
|
|
((struct partial_symtab **)
|
3145 |
|
|
obstack_alloc (&objfile->psymbol_obstack,
|
3146 |
|
|
((fh->crfd - 1)
|
3147 |
|
|
* sizeof (struct partial_symtab *))));
|
3148 |
|
|
for (s_idx = 1; s_idx < fh->crfd; s_idx++)
|
3149 |
|
|
{
|
3150 |
|
|
RFDT rh;
|
3151 |
|
|
|
3152 |
|
|
(*swap_rfd_in) (cur_bfd,
|
3153 |
|
|
((char *) debug_info->external_rfd
|
3154 |
|
|
+ (fh->rfdBase + s_idx) * external_rfd_size),
|
3155 |
|
|
&rh);
|
3156 |
|
|
if (rh < 0 || rh >= hdr->ifdMax)
|
3157 |
|
|
{
|
3158 |
|
|
complain (&bad_file_number_complaint, rh);
|
3159 |
|
|
continue;
|
3160 |
|
|
}
|
3161 |
|
|
|
3162 |
|
|
/* Skip self dependencies of header files. */
|
3163 |
|
|
if (rh == f_idx)
|
3164 |
|
|
continue;
|
3165 |
|
|
|
3166 |
|
|
/* Do not add to dependeny list if psymtab was empty. */
|
3167 |
|
|
if (fdr_to_pst[rh].pst == (struct partial_symtab *) NULL)
|
3168 |
|
|
continue;
|
3169 |
|
|
pst->dependencies[pst->number_of_dependencies++] = fdr_to_pst[rh].pst;
|
3170 |
|
|
}
|
3171 |
|
|
}
|
3172 |
|
|
|
3173 |
|
|
/* Remove the dummy psymtab created for -O3 images above, if it is
|
3174 |
|
|
still empty, to enable the detection of stripped executables. */
|
3175 |
|
|
if (objfile->psymtabs->next == NULL
|
3176 |
|
|
&& objfile->psymtabs->number_of_dependencies == 0
|
3177 |
|
|
&& objfile->psymtabs->n_global_syms == 0
|
3178 |
|
|
&& objfile->psymtabs->n_static_syms == 0)
|
3179 |
|
|
objfile->psymtabs = NULL;
|
3180 |
|
|
do_cleanups (old_chain);
|
3181 |
|
|
}
|
3182 |
|
|
|
3183 |
|
|
/* If the current psymbol has an enumerated type, we need to add
|
3184 |
|
|
all the the enum constants to the partial symbol table. */
|
3185 |
|
|
|
3186 |
|
|
static void
|
3187 |
|
|
handle_psymbol_enumerators (objfile, fh, stype, svalue)
|
3188 |
|
|
struct objfile *objfile;
|
3189 |
|
|
FDR *fh;
|
3190 |
|
|
int stype;
|
3191 |
|
|
CORE_ADDR svalue;
|
3192 |
|
|
{
|
3193 |
|
|
const bfd_size_type external_sym_size = debug_swap->external_sym_size;
|
3194 |
|
|
void (*const swap_sym_in) PARAMS ((bfd *, PTR, SYMR *))
|
3195 |
|
|
= debug_swap->swap_sym_in;
|
3196 |
|
|
char *ext_sym = ((char *) debug_info->external_sym
|
3197 |
|
|
+ ((fh->isymBase + cur_sdx + 1) * external_sym_size));
|
3198 |
|
|
SYMR sh;
|
3199 |
|
|
TIR tir;
|
3200 |
|
|
|
3201 |
|
|
switch (stype)
|
3202 |
|
|
{
|
3203 |
|
|
case stEnum:
|
3204 |
|
|
break;
|
3205 |
|
|
|
3206 |
|
|
case stBlock:
|
3207 |
|
|
/* It is an enumerated type if the next symbol entry is a stMember
|
3208 |
|
|
and its auxiliary index is indexNil or its auxiliary entry
|
3209 |
|
|
is a plain btNil or btVoid.
|
3210 |
|
|
Alpha cc -migrate enums are recognized by a zero index and
|
3211 |
|
|
a zero symbol value.
|
3212 |
|
|
DU 4.0 cc enums are recognized by a member type of btEnum without
|
3213 |
|
|
qualifiers and a zero symbol value. */
|
3214 |
|
|
(*swap_sym_in) (cur_bfd, ext_sym, &sh);
|
3215 |
|
|
if (sh.st != stMember)
|
3216 |
|
|
return;
|
3217 |
|
|
|
3218 |
|
|
if (sh.index == indexNil
|
3219 |
|
|
|| (sh.index == 0 && svalue == 0))
|
3220 |
|
|
break;
|
3221 |
|
|
(*debug_swap->swap_tir_in) (fh->fBigendian,
|
3222 |
|
|
&(debug_info->external_aux
|
3223 |
|
|
+ fh->iauxBase + sh.index)->a_ti,
|
3224 |
|
|
&tir);
|
3225 |
|
|
if ((tir.bt != btNil
|
3226 |
|
|
&& tir.bt != btVoid
|
3227 |
|
|
&& (tir.bt != btEnum || svalue != 0))
|
3228 |
|
|
|| tir.tq0 != tqNil)
|
3229 |
|
|
return;
|
3230 |
|
|
break;
|
3231 |
|
|
|
3232 |
|
|
default:
|
3233 |
|
|
return;
|
3234 |
|
|
}
|
3235 |
|
|
|
3236 |
|
|
for (;;)
|
3237 |
|
|
{
|
3238 |
|
|
char *name;
|
3239 |
|
|
|
3240 |
|
|
(*swap_sym_in) (cur_bfd, ext_sym, &sh);
|
3241 |
|
|
if (sh.st != stMember)
|
3242 |
|
|
break;
|
3243 |
|
|
name = debug_info->ss + cur_fdr->issBase + sh.iss;
|
3244 |
|
|
|
3245 |
|
|
/* Note that the value doesn't matter for enum constants
|
3246 |
|
|
in psymtabs, just in symtabs. */
|
3247 |
|
|
add_psymbol_to_list (name, strlen (name),
|
3248 |
|
|
VAR_NAMESPACE, LOC_CONST,
|
3249 |
|
|
&objfile->static_psymbols, 0,
|
3250 |
|
|
(CORE_ADDR) 0, psymtab_language, objfile);
|
3251 |
|
|
ext_sym += external_sym_size;
|
3252 |
|
|
}
|
3253 |
|
|
}
|
3254 |
|
|
|
3255 |
|
|
static char *
|
3256 |
|
|
mdebug_next_symbol_text (objfile)
|
3257 |
|
|
struct objfile *objfile; /* argument objfile is currently unused */
|
3258 |
|
|
{
|
3259 |
|
|
SYMR sh;
|
3260 |
|
|
|
3261 |
|
|
cur_sdx++;
|
3262 |
|
|
(*debug_swap->swap_sym_in) (cur_bfd,
|
3263 |
|
|
((char *) debug_info->external_sym
|
3264 |
|
|
+ ((cur_fdr->isymBase + cur_sdx)
|
3265 |
|
|
* debug_swap->external_sym_size)),
|
3266 |
|
|
&sh);
|
3267 |
|
|
return debug_info->ss + cur_fdr->issBase + sh.iss;
|
3268 |
|
|
}
|
3269 |
|
|
|
3270 |
|
|
/* Ancillary function to psymtab_to_symtab(). Does all the work
|
3271 |
|
|
for turning the partial symtab PST into a symtab, recurring
|
3272 |
|
|
first on all dependent psymtabs. The argument FILENAME is
|
3273 |
|
|
only passed so we can see in debug stack traces what file
|
3274 |
|
|
is being read.
|
3275 |
|
|
|
3276 |
|
|
This function has a split personality, based on whether the
|
3277 |
|
|
symbol table contains ordinary ecoff symbols, or stabs-in-ecoff.
|
3278 |
|
|
The flow of control and even the memory allocation differs. FIXME. */
|
3279 |
|
|
|
3280 |
|
|
static void
|
3281 |
|
|
psymtab_to_symtab_1 (pst, filename)
|
3282 |
|
|
struct partial_symtab *pst;
|
3283 |
|
|
char *filename;
|
3284 |
|
|
{
|
3285 |
|
|
bfd_size_type external_sym_size;
|
3286 |
|
|
bfd_size_type external_pdr_size;
|
3287 |
|
|
void (*swap_sym_in) PARAMS ((bfd *, PTR, SYMR *));
|
3288 |
|
|
void (*swap_pdr_in) PARAMS ((bfd *, PTR, PDR *));
|
3289 |
|
|
int i;
|
3290 |
|
|
struct symtab *st;
|
3291 |
|
|
FDR *fh;
|
3292 |
|
|
struct linetable *lines;
|
3293 |
|
|
CORE_ADDR lowest_pdr_addr = 0;
|
3294 |
|
|
|
3295 |
|
|
if (pst->readin)
|
3296 |
|
|
return;
|
3297 |
|
|
pst->readin = 1;
|
3298 |
|
|
|
3299 |
|
|
/* Read in all partial symbtabs on which this one is dependent.
|
3300 |
|
|
NOTE that we do have circular dependencies, sigh. We solved
|
3301 |
|
|
that by setting pst->readin before this point. */
|
3302 |
|
|
|
3303 |
|
|
for (i = 0; i < pst->number_of_dependencies; i++)
|
3304 |
|
|
if (!pst->dependencies[i]->readin)
|
3305 |
|
|
{
|
3306 |
|
|
/* Inform about additional files to be read in. */
|
3307 |
|
|
if (info_verbose)
|
3308 |
|
|
{
|
3309 |
|
|
fputs_filtered (" ", gdb_stdout);
|
3310 |
|
|
wrap_here ("");
|
3311 |
|
|
fputs_filtered ("and ", gdb_stdout);
|
3312 |
|
|
wrap_here ("");
|
3313 |
|
|
printf_filtered ("%s...",
|
3314 |
|
|
pst->dependencies[i]->filename);
|
3315 |
|
|
wrap_here (""); /* Flush output */
|
3316 |
|
|
gdb_flush (gdb_stdout);
|
3317 |
|
|
}
|
3318 |
|
|
/* We only pass the filename for debug purposes */
|
3319 |
|
|
psymtab_to_symtab_1 (pst->dependencies[i],
|
3320 |
|
|
pst->dependencies[i]->filename);
|
3321 |
|
|
}
|
3322 |
|
|
|
3323 |
|
|
/* Do nothing if this is a dummy psymtab. */
|
3324 |
|
|
|
3325 |
|
|
if (pst->n_global_syms == 0 && pst->n_static_syms == 0
|
3326 |
|
|
&& pst->textlow == 0 && pst->texthigh == 0)
|
3327 |
|
|
return;
|
3328 |
|
|
|
3329 |
|
|
/* Now read the symbols for this symtab */
|
3330 |
|
|
|
3331 |
|
|
cur_bfd = CUR_BFD (pst);
|
3332 |
|
|
debug_swap = DEBUG_SWAP (pst);
|
3333 |
|
|
debug_info = DEBUG_INFO (pst);
|
3334 |
|
|
pending_list = PENDING_LIST (pst);
|
3335 |
|
|
external_sym_size = debug_swap->external_sym_size;
|
3336 |
|
|
external_pdr_size = debug_swap->external_pdr_size;
|
3337 |
|
|
swap_sym_in = debug_swap->swap_sym_in;
|
3338 |
|
|
swap_pdr_in = debug_swap->swap_pdr_in;
|
3339 |
|
|
current_objfile = pst->objfile;
|
3340 |
|
|
cur_fd = FDR_IDX (pst);
|
3341 |
|
|
fh = ((cur_fd == -1)
|
3342 |
|
|
? (FDR *) NULL
|
3343 |
|
|
: debug_info->fdr + cur_fd);
|
3344 |
|
|
cur_fdr = fh;
|
3345 |
|
|
|
3346 |
|
|
/* See comment in parse_partial_symbols about the @stabs sentinel. */
|
3347 |
|
|
processing_gcc_compilation = 0;
|
3348 |
|
|
if (fh != (FDR *) NULL && fh->csym >= 2)
|
3349 |
|
|
{
|
3350 |
|
|
SYMR sh;
|
3351 |
|
|
|
3352 |
|
|
(*swap_sym_in) (cur_bfd,
|
3353 |
|
|
((char *) debug_info->external_sym
|
3354 |
|
|
+ (fh->isymBase + 1) * external_sym_size),
|
3355 |
|
|
&sh);
|
3356 |
|
|
if (STREQ (debug_info->ss + fh->issBase + sh.iss,
|
3357 |
|
|
stabs_symbol))
|
3358 |
|
|
{
|
3359 |
|
|
/* We indicate that this is a GCC compilation so that certain
|
3360 |
|
|
features will be enabled in stabsread/dbxread. */
|
3361 |
|
|
processing_gcc_compilation = 2;
|
3362 |
|
|
}
|
3363 |
|
|
}
|
3364 |
|
|
|
3365 |
|
|
if (processing_gcc_compilation != 0)
|
3366 |
|
|
{
|
3367 |
|
|
|
3368 |
|
|
/* This symbol table contains stabs-in-ecoff entries. */
|
3369 |
|
|
|
3370 |
|
|
/* Parse local symbols first */
|
3371 |
|
|
|
3372 |
|
|
if (fh->csym <= 2) /* FIXME, this blows psymtab->symtab ptr */
|
3373 |
|
|
{
|
3374 |
|
|
current_objfile = NULL;
|
3375 |
|
|
return;
|
3376 |
|
|
}
|
3377 |
|
|
for (cur_sdx = 2; cur_sdx < fh->csym; cur_sdx++)
|
3378 |
|
|
{
|
3379 |
|
|
SYMR sh;
|
3380 |
|
|
char *name;
|
3381 |
|
|
CORE_ADDR valu;
|
3382 |
|
|
|
3383 |
|
|
(*swap_sym_in) (cur_bfd,
|
3384 |
|
|
(((char *) debug_info->external_sym)
|
3385 |
|
|
+ (fh->isymBase + cur_sdx) * external_sym_size),
|
3386 |
|
|
&sh);
|
3387 |
|
|
name = debug_info->ss + fh->issBase + sh.iss;
|
3388 |
|
|
valu = sh.value;
|
3389 |
|
|
/* XXX This is a hack. It will go away! */
|
3390 |
|
|
if (ECOFF_IS_STAB (&sh) || (name[0] == '#'))
|
3391 |
|
|
{
|
3392 |
|
|
int type_code = ECOFF_UNMARK_STAB (sh.index);
|
3393 |
|
|
|
3394 |
|
|
/* We should never get non N_STAB symbols here, but they
|
3395 |
|
|
should be harmless, so keep process_one_symbol from
|
3396 |
|
|
complaining about them. */
|
3397 |
|
|
if (type_code & N_STAB)
|
3398 |
|
|
{
|
3399 |
|
|
process_one_symbol (type_code, 0, valu, name,
|
3400 |
|
|
pst->section_offsets, pst->objfile);
|
3401 |
|
|
}
|
3402 |
|
|
/* Similarly a hack. */
|
3403 |
|
|
else if (name[0] == '#')
|
3404 |
|
|
{
|
3405 |
|
|
process_one_symbol (N_SLINE, 0, valu, name,
|
3406 |
|
|
pst->section_offsets, pst->objfile);
|
3407 |
|
|
}
|
3408 |
|
|
if (type_code == N_FUN)
|
3409 |
|
|
{
|
3410 |
|
|
/* Make up special symbol to contain
|
3411 |
|
|
procedure specific info */
|
3412 |
|
|
struct mips_extra_func_info *e =
|
3413 |
|
|
((struct mips_extra_func_info *)
|
3414 |
|
|
obstack_alloc (¤t_objfile->symbol_obstack,
|
3415 |
|
|
sizeof (struct mips_extra_func_info)));
|
3416 |
|
|
struct symbol *s = new_symbol (MIPS_EFI_SYMBOL_NAME);
|
3417 |
|
|
|
3418 |
|
|
memset ((PTR) e, 0, sizeof (struct mips_extra_func_info));
|
3419 |
|
|
SYMBOL_NAMESPACE (s) = LABEL_NAMESPACE;
|
3420 |
|
|
SYMBOL_CLASS (s) = LOC_CONST;
|
3421 |
|
|
SYMBOL_TYPE (s) = mdebug_type_void;
|
3422 |
|
|
SYMBOL_VALUE (s) = (long) e;
|
3423 |
|
|
e->pdr.framereg = -1;
|
3424 |
|
|
add_symbol_to_list (s, &local_symbols);
|
3425 |
|
|
}
|
3426 |
|
|
}
|
3427 |
|
|
else if (sh.st == stLabel)
|
3428 |
|
|
{
|
3429 |
|
|
if (sh.index == indexNil)
|
3430 |
|
|
{
|
3431 |
|
|
/* This is what the gcc2_compiled and __gnu_compiled_*
|
3432 |
|
|
show up as. So don't complain. */
|
3433 |
|
|
;
|
3434 |
|
|
}
|
3435 |
|
|
else
|
3436 |
|
|
{
|
3437 |
|
|
/* Handle encoded stab line number. */
|
3438 |
|
|
valu += ANOFFSET (pst->section_offsets, SECT_OFF_TEXT);
|
3439 |
|
|
record_line (current_subfile, sh.index, valu);
|
3440 |
|
|
}
|
3441 |
|
|
}
|
3442 |
|
|
else if (sh.st == stProc || sh.st == stStaticProc
|
3443 |
|
|
|| sh.st == stStatic || sh.st == stEnd)
|
3444 |
|
|
/* These are generated by gcc-2.x, do not complain */
|
3445 |
|
|
;
|
3446 |
|
|
else
|
3447 |
|
|
complain (&stab_unknown_complaint, name);
|
3448 |
|
|
}
|
3449 |
|
|
st = end_symtab (pst->texthigh, pst->objfile, SECT_OFF_TEXT);
|
3450 |
|
|
end_stabs ();
|
3451 |
|
|
|
3452 |
|
|
/* Sort the symbol table now, we are done adding symbols to it.
|
3453 |
|
|
We must do this before parse_procedure calls lookup_symbol. */
|
3454 |
|
|
sort_symtab_syms (st);
|
3455 |
|
|
|
3456 |
|
|
/* There used to be a call to sort_blocks here, but this should not
|
3457 |
|
|
be necessary for stabs symtabs. And as sort_blocks modifies the
|
3458 |
|
|
start address of the GLOBAL_BLOCK to the FIRST_LOCAL_BLOCK,
|
3459 |
|
|
it did the wrong thing if the first procedure in a file was
|
3460 |
|
|
generated via asm statements. */
|
3461 |
|
|
|
3462 |
|
|
/* Fill in procedure info next. */
|
3463 |
|
|
if (fh->cpd > 0)
|
3464 |
|
|
{
|
3465 |
|
|
PDR *pr_block;
|
3466 |
|
|
struct cleanup *old_chain;
|
3467 |
|
|
char *pdr_ptr;
|
3468 |
|
|
char *pdr_end;
|
3469 |
|
|
PDR *pdr_in;
|
3470 |
|
|
PDR *pdr_in_end;
|
3471 |
|
|
|
3472 |
|
|
pr_block = (PDR *) xmalloc (fh->cpd * sizeof (PDR));
|
3473 |
|
|
old_chain = make_cleanup (free, pr_block);
|
3474 |
|
|
|
3475 |
|
|
pdr_ptr = ((char *) debug_info->external_pdr
|
3476 |
|
|
+ fh->ipdFirst * external_pdr_size);
|
3477 |
|
|
pdr_end = pdr_ptr + fh->cpd * external_pdr_size;
|
3478 |
|
|
pdr_in = pr_block;
|
3479 |
|
|
for (;
|
3480 |
|
|
pdr_ptr < pdr_end;
|
3481 |
|
|
pdr_ptr += external_pdr_size, pdr_in++)
|
3482 |
|
|
{
|
3483 |
|
|
(*swap_pdr_in) (cur_bfd, pdr_ptr, pdr_in);
|
3484 |
|
|
|
3485 |
|
|
/* Determine lowest PDR address, the PDRs are not always
|
3486 |
|
|
sorted. */
|
3487 |
|
|
if (pdr_in == pr_block)
|
3488 |
|
|
lowest_pdr_addr = pdr_in->adr;
|
3489 |
|
|
else if (pdr_in->adr < lowest_pdr_addr)
|
3490 |
|
|
lowest_pdr_addr = pdr_in->adr;
|
3491 |
|
|
}
|
3492 |
|
|
|
3493 |
|
|
pdr_in = pr_block;
|
3494 |
|
|
pdr_in_end = pdr_in + fh->cpd;
|
3495 |
|
|
for (; pdr_in < pdr_in_end; pdr_in++)
|
3496 |
|
|
parse_procedure (pdr_in, st, pst);
|
3497 |
|
|
|
3498 |
|
|
do_cleanups (old_chain);
|
3499 |
|
|
}
|
3500 |
|
|
}
|
3501 |
|
|
else
|
3502 |
|
|
{
|
3503 |
|
|
/* This symbol table contains ordinary ecoff entries. */
|
3504 |
|
|
|
3505 |
|
|
int f_max;
|
3506 |
|
|
int maxlines;
|
3507 |
|
|
EXTR *ext_ptr;
|
3508 |
|
|
|
3509 |
|
|
/* How many symbols will we need */
|
3510 |
|
|
/* FIXME, this does not count enum values. */
|
3511 |
|
|
f_max = pst->n_global_syms + pst->n_static_syms;
|
3512 |
|
|
if (fh == 0)
|
3513 |
|
|
{
|
3514 |
|
|
maxlines = 0;
|
3515 |
|
|
st = new_symtab ("unknown", f_max, 0, pst->objfile);
|
3516 |
|
|
}
|
3517 |
|
|
else
|
3518 |
|
|
{
|
3519 |
|
|
f_max += fh->csym + fh->cpd;
|
3520 |
|
|
maxlines = 2 * fh->cline;
|
3521 |
|
|
st = new_symtab (pst->filename, 2 * f_max, maxlines, pst->objfile);
|
3522 |
|
|
|
3523 |
|
|
/* The proper language was already determined when building
|
3524 |
|
|
the psymtab, use it. */
|
3525 |
|
|
st->language = PST_PRIVATE (pst)->pst_language;
|
3526 |
|
|
}
|
3527 |
|
|
|
3528 |
|
|
psymtab_language = st->language;
|
3529 |
|
|
|
3530 |
|
|
lines = LINETABLE (st);
|
3531 |
|
|
|
3532 |
|
|
/* Get a new lexical context */
|
3533 |
|
|
|
3534 |
|
|
push_parse_stack ();
|
3535 |
|
|
top_stack->cur_st = st;
|
3536 |
|
|
top_stack->cur_block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (st),
|
3537 |
|
|
STATIC_BLOCK);
|
3538 |
|
|
BLOCK_START (top_stack->cur_block) = pst->textlow;
|
3539 |
|
|
BLOCK_END (top_stack->cur_block) = 0;
|
3540 |
|
|
top_stack->blocktype = stFile;
|
3541 |
|
|
top_stack->maxsyms = 2 * f_max;
|
3542 |
|
|
top_stack->cur_type = 0;
|
3543 |
|
|
top_stack->procadr = 0;
|
3544 |
|
|
top_stack->numargs = 0;
|
3545 |
|
|
found_ecoff_debugging_info = 0;
|
3546 |
|
|
|
3547 |
|
|
if (fh)
|
3548 |
|
|
{
|
3549 |
|
|
char *sym_ptr;
|
3550 |
|
|
char *sym_end;
|
3551 |
|
|
|
3552 |
|
|
/* Parse local symbols first */
|
3553 |
|
|
sym_ptr = ((char *) debug_info->external_sym
|
3554 |
|
|
+ fh->isymBase * external_sym_size);
|
3555 |
|
|
sym_end = sym_ptr + fh->csym * external_sym_size;
|
3556 |
|
|
while (sym_ptr < sym_end)
|
3557 |
|
|
{
|
3558 |
|
|
SYMR sh;
|
3559 |
|
|
int c;
|
3560 |
|
|
|
3561 |
|
|
(*swap_sym_in) (cur_bfd, sym_ptr, &sh);
|
3562 |
|
|
c = parse_symbol (&sh,
|
3563 |
|
|
debug_info->external_aux + fh->iauxBase,
|
3564 |
|
|
sym_ptr, fh->fBigendian, pst->section_offsets);
|
3565 |
|
|
sym_ptr += c * external_sym_size;
|
3566 |
|
|
}
|
3567 |
|
|
|
3568 |
|
|
/* Linenumbers. At the end, check if we can save memory.
|
3569 |
|
|
parse_lines has to look ahead an arbitrary number of PDR
|
3570 |
|
|
structures, so we swap them all first. */
|
3571 |
|
|
if (fh->cpd > 0)
|
3572 |
|
|
{
|
3573 |
|
|
PDR *pr_block;
|
3574 |
|
|
struct cleanup *old_chain;
|
3575 |
|
|
char *pdr_ptr;
|
3576 |
|
|
char *pdr_end;
|
3577 |
|
|
PDR *pdr_in;
|
3578 |
|
|
PDR *pdr_in_end;
|
3579 |
|
|
|
3580 |
|
|
pr_block = (PDR *) xmalloc (fh->cpd * sizeof (PDR));
|
3581 |
|
|
|
3582 |
|
|
old_chain = make_cleanup (free, pr_block);
|
3583 |
|
|
|
3584 |
|
|
pdr_ptr = ((char *) debug_info->external_pdr
|
3585 |
|
|
+ fh->ipdFirst * external_pdr_size);
|
3586 |
|
|
pdr_end = pdr_ptr + fh->cpd * external_pdr_size;
|
3587 |
|
|
pdr_in = pr_block;
|
3588 |
|
|
for (;
|
3589 |
|
|
pdr_ptr < pdr_end;
|
3590 |
|
|
pdr_ptr += external_pdr_size, pdr_in++)
|
3591 |
|
|
{
|
3592 |
|
|
(*swap_pdr_in) (cur_bfd, pdr_ptr, pdr_in);
|
3593 |
|
|
|
3594 |
|
|
/* Determine lowest PDR address, the PDRs are not always
|
3595 |
|
|
sorted. */
|
3596 |
|
|
if (pdr_in == pr_block)
|
3597 |
|
|
lowest_pdr_addr = pdr_in->adr;
|
3598 |
|
|
else if (pdr_in->adr < lowest_pdr_addr)
|
3599 |
|
|
lowest_pdr_addr = pdr_in->adr;
|
3600 |
|
|
}
|
3601 |
|
|
|
3602 |
|
|
parse_lines (fh, pr_block, lines, maxlines, pst, lowest_pdr_addr);
|
3603 |
|
|
if (lines->nitems < fh->cline)
|
3604 |
|
|
lines = shrink_linetable (lines);
|
3605 |
|
|
|
3606 |
|
|
/* Fill in procedure info next. */
|
3607 |
|
|
pdr_in = pr_block;
|
3608 |
|
|
pdr_in_end = pdr_in + fh->cpd;
|
3609 |
|
|
for (; pdr_in < pdr_in_end; pdr_in++)
|
3610 |
|
|
parse_procedure (pdr_in, 0, pst);
|
3611 |
|
|
|
3612 |
|
|
do_cleanups (old_chain);
|
3613 |
|
|
}
|
3614 |
|
|
}
|
3615 |
|
|
|
3616 |
|
|
LINETABLE (st) = lines;
|
3617 |
|
|
|
3618 |
|
|
/* .. and our share of externals.
|
3619 |
|
|
XXX use the global list to speed up things here. how?
|
3620 |
|
|
FIXME, Maybe quit once we have found the right number of ext's? */
|
3621 |
|
|
top_stack->cur_st = st;
|
3622 |
|
|
top_stack->cur_block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (top_stack->cur_st),
|
3623 |
|
|
GLOBAL_BLOCK);
|
3624 |
|
|
top_stack->blocktype = stFile;
|
3625 |
|
|
top_stack->maxsyms
|
3626 |
|
|
= (debug_info->symbolic_header.isymMax
|
3627 |
|
|
+ debug_info->symbolic_header.ipdMax
|
3628 |
|
|
+ debug_info->symbolic_header.iextMax);
|
3629 |
|
|
|
3630 |
|
|
ext_ptr = PST_PRIVATE (pst)->extern_tab;
|
3631 |
|
|
for (i = PST_PRIVATE (pst)->extern_count; --i >= 0; ext_ptr++)
|
3632 |
|
|
parse_external (ext_ptr, fh->fBigendian, pst->section_offsets);
|
3633 |
|
|
|
3634 |
|
|
/* If there are undefined symbols, tell the user.
|
3635 |
|
|
The alpha has an undefined symbol for every symbol that is
|
3636 |
|
|
from a shared library, so tell the user only if verbose is on. */
|
3637 |
|
|
if (info_verbose && n_undef_symbols)
|
3638 |
|
|
{
|
3639 |
|
|
printf_filtered ("File %s contains %d unresolved references:",
|
3640 |
|
|
st->filename, n_undef_symbols);
|
3641 |
|
|
printf_filtered ("\n\t%4d variables\n\t%4d procedures\n\t%4d labels\n",
|
3642 |
|
|
n_undef_vars, n_undef_procs, n_undef_labels);
|
3643 |
|
|
n_undef_symbols = n_undef_labels = n_undef_vars = n_undef_procs = 0;
|
3644 |
|
|
|
3645 |
|
|
}
|
3646 |
|
|
pop_parse_stack ();
|
3647 |
|
|
|
3648 |
|
|
st->primary = 1;
|
3649 |
|
|
|
3650 |
|
|
/* Sort the symbol table now, we are done adding symbols to it. */
|
3651 |
|
|
sort_symtab_syms (st);
|
3652 |
|
|
|
3653 |
|
|
sort_blocks (st);
|
3654 |
|
|
}
|
3655 |
|
|
|
3656 |
|
|
/* Now link the psymtab and the symtab. */
|
3657 |
|
|
pst->symtab = st;
|
3658 |
|
|
|
3659 |
|
|
current_objfile = NULL;
|
3660 |
|
|
}
|
3661 |
|
|
|
3662 |
|
|
/* Ancillary parsing procedures. */
|
3663 |
|
|
|
3664 |
|
|
/* Return 1 if the symbol pointed to by SH has a cross reference
|
3665 |
|
|
to an opaque aggregate type, else 0. */
|
3666 |
|
|
|
3667 |
|
|
static int
|
3668 |
|
|
has_opaque_xref (fh, sh)
|
3669 |
|
|
FDR *fh;
|
3670 |
|
|
SYMR *sh;
|
3671 |
|
|
{
|
3672 |
|
|
TIR tir;
|
3673 |
|
|
union aux_ext *ax;
|
3674 |
|
|
RNDXR rn[1];
|
3675 |
|
|
unsigned int rf;
|
3676 |
|
|
|
3677 |
|
|
if (sh->index == indexNil)
|
3678 |
|
|
return 0;
|
3679 |
|
|
|
3680 |
|
|
ax = debug_info->external_aux + fh->iauxBase + sh->index;
|
3681 |
|
|
(*debug_swap->swap_tir_in) (fh->fBigendian, &ax->a_ti, &tir);
|
3682 |
|
|
if (tir.bt != btStruct && tir.bt != btUnion && tir.bt != btEnum)
|
3683 |
|
|
return 0;
|
3684 |
|
|
|
3685 |
|
|
ax++;
|
3686 |
|
|
(*debug_swap->swap_rndx_in) (fh->fBigendian, &ax->a_rndx, rn);
|
3687 |
|
|
if (rn->rfd == 0xfff)
|
3688 |
|
|
rf = AUX_GET_ISYM (fh->fBigendian, ax + 1);
|
3689 |
|
|
else
|
3690 |
|
|
rf = rn->rfd;
|
3691 |
|
|
if (rf != -1)
|
3692 |
|
|
return 0;
|
3693 |
|
|
return 1;
|
3694 |
|
|
}
|
3695 |
|
|
|
3696 |
|
|
/* Lookup the type at relative index RN. Return it in TPP
|
3697 |
|
|
if found and in any event come up with its name PNAME.
|
3698 |
|
|
BIGEND says whether aux symbols are big-endian or not (from fh->fBigendian).
|
3699 |
|
|
Return value says how many aux symbols we ate. */
|
3700 |
|
|
|
3701 |
|
|
static int
|
3702 |
|
|
cross_ref (fd, ax, tpp, type_code, pname, bigend, sym_name)
|
3703 |
|
|
int fd;
|
3704 |
|
|
union aux_ext *ax;
|
3705 |
|
|
struct type **tpp;
|
3706 |
|
|
enum type_code type_code; /* Use to alloc new type if none is found. */
|
3707 |
|
|
char **pname;
|
3708 |
|
|
int bigend;
|
3709 |
|
|
char *sym_name;
|
3710 |
|
|
{
|
3711 |
|
|
RNDXR rn[1];
|
3712 |
|
|
unsigned int rf;
|
3713 |
|
|
int result = 1;
|
3714 |
|
|
FDR *fh;
|
3715 |
|
|
char *esh;
|
3716 |
|
|
SYMR sh;
|
3717 |
|
|
int xref_fd;
|
3718 |
|
|
struct mdebug_pending *pend;
|
3719 |
|
|
|
3720 |
|
|
*tpp = (struct type *) NULL;
|
3721 |
|
|
|
3722 |
|
|
(*debug_swap->swap_rndx_in) (bigend, &ax->a_rndx, rn);
|
3723 |
|
|
|
3724 |
|
|
/* Escape index means 'the next one' */
|
3725 |
|
|
if (rn->rfd == 0xfff)
|
3726 |
|
|
{
|
3727 |
|
|
result++;
|
3728 |
|
|
rf = AUX_GET_ISYM (bigend, ax + 1);
|
3729 |
|
|
}
|
3730 |
|
|
else
|
3731 |
|
|
{
|
3732 |
|
|
rf = rn->rfd;
|
3733 |
|
|
}
|
3734 |
|
|
|
3735 |
|
|
/* mips cc uses a rf of -1 for opaque struct definitions.
|
3736 |
|
|
Set TYPE_FLAG_STUB for these types so that check_typedef will
|
3737 |
|
|
resolve them if the struct gets defined in another compilation unit. */
|
3738 |
|
|
if (rf == -1)
|
3739 |
|
|
{
|
3740 |
|
|
*pname = "<undefined>";
|
3741 |
|
|
*tpp = init_type (type_code, 0, 0, (char *) NULL, current_objfile);
|
3742 |
|
|
TYPE_FLAGS (*tpp) |= TYPE_FLAG_STUB;
|
3743 |
|
|
return result;
|
3744 |
|
|
}
|
3745 |
|
|
|
3746 |
|
|
/* mips cc uses an escaped rn->index of 0 for struct return types
|
3747 |
|
|
of procedures that were compiled without -g. These will always remain
|
3748 |
|
|
undefined. */
|
3749 |
|
|
if (rn->rfd == 0xfff && rn->index == 0)
|
3750 |
|
|
{
|
3751 |
|
|
*pname = "<undefined>";
|
3752 |
|
|
return result;
|
3753 |
|
|
}
|
3754 |
|
|
|
3755 |
|
|
/* Find the relative file descriptor and the symbol in it. */
|
3756 |
|
|
fh = get_rfd (fd, rf);
|
3757 |
|
|
xref_fd = fh - debug_info->fdr;
|
3758 |
|
|
|
3759 |
|
|
if (rn->index >= fh->csym)
|
3760 |
|
|
{
|
3761 |
|
|
/* File indirect entry is corrupt. */
|
3762 |
|
|
*pname = "<illegal>";
|
3763 |
|
|
complain (&bad_rfd_entry_complaint,
|
3764 |
|
|
sym_name, xref_fd, rn->index);
|
3765 |
|
|
return result;
|
3766 |
|
|
}
|
3767 |
|
|
|
3768 |
|
|
/* If we have processed this symbol then we left a forwarding
|
3769 |
|
|
pointer to the type in the pending list. If not, we`ll put
|
3770 |
|
|
it in a list of pending types, to be processed later when
|
3771 |
|
|
the file will be. In any event, we collect the name for the
|
3772 |
|
|
type here. */
|
3773 |
|
|
|
3774 |
|
|
esh = ((char *) debug_info->external_sym
|
3775 |
|
|
+ ((fh->isymBase + rn->index)
|
3776 |
|
|
* debug_swap->external_sym_size));
|
3777 |
|
|
(*debug_swap->swap_sym_in) (cur_bfd, esh, &sh);
|
3778 |
|
|
|
3779 |
|
|
/* Make sure that this type of cross reference can be handled. */
|
3780 |
|
|
if ((sh.sc != scInfo
|
3781 |
|
|
|| (sh.st != stBlock && sh.st != stTypedef && sh.st != stIndirect
|
3782 |
|
|
&& sh.st != stStruct && sh.st != stUnion
|
3783 |
|
|
&& sh.st != stEnum))
|
3784 |
|
|
&& (sh.st != stBlock || !SC_IS_COMMON (sh.sc)))
|
3785 |
|
|
{
|
3786 |
|
|
/* File indirect entry is corrupt. */
|
3787 |
|
|
*pname = "<illegal>";
|
3788 |
|
|
complain (&bad_rfd_entry_complaint,
|
3789 |
|
|
sym_name, xref_fd, rn->index);
|
3790 |
|
|
return result;
|
3791 |
|
|
}
|
3792 |
|
|
|
3793 |
|
|
*pname = debug_info->ss + fh->issBase + sh.iss;
|
3794 |
|
|
|
3795 |
|
|
pend = is_pending_symbol (fh, esh);
|
3796 |
|
|
if (pend)
|
3797 |
|
|
*tpp = pend->t;
|
3798 |
|
|
else
|
3799 |
|
|
{
|
3800 |
|
|
/* We have not yet seen this type. */
|
3801 |
|
|
|
3802 |
|
|
if ((sh.iss == 0 && sh.st == stTypedef) || sh.st == stIndirect)
|
3803 |
|
|
{
|
3804 |
|
|
TIR tir;
|
3805 |
|
|
|
3806 |
|
|
/* alpha cc puts out a stTypedef with a sh.iss of zero for
|
3807 |
|
|
two cases:
|
3808 |
|
|
a) forward declarations of structs/unions/enums which are not
|
3809 |
|
|
defined in this compilation unit.
|
3810 |
|
|
For these the type will be void. This is a bad design decision
|
3811 |
|
|
as cross referencing across compilation units is impossible
|
3812 |
|
|
due to the missing name.
|
3813 |
|
|
b) forward declarations of structs/unions/enums/typedefs which
|
3814 |
|
|
are defined later in this file or in another file in the same
|
3815 |
|
|
compilation unit. Irix5 cc uses a stIndirect symbol for this.
|
3816 |
|
|
Simply cross reference those again to get the true type.
|
3817 |
|
|
The forward references are not entered in the pending list and
|
3818 |
|
|
in the symbol table. */
|
3819 |
|
|
|
3820 |
|
|
(*debug_swap->swap_tir_in) (bigend,
|
3821 |
|
|
&(debug_info->external_aux
|
3822 |
|
|
+ fh->iauxBase + sh.index)->a_ti,
|
3823 |
|
|
&tir);
|
3824 |
|
|
if (tir.tq0 != tqNil)
|
3825 |
|
|
complain (&illegal_forward_tq0_complaint, sym_name);
|
3826 |
|
|
switch (tir.bt)
|
3827 |
|
|
{
|
3828 |
|
|
case btVoid:
|
3829 |
|
|
*tpp = init_type (type_code, 0, 0, (char *) NULL,
|
3830 |
|
|
current_objfile);
|
3831 |
|
|
*pname = "<undefined>";
|
3832 |
|
|
break;
|
3833 |
|
|
|
3834 |
|
|
case btStruct:
|
3835 |
|
|
case btUnion:
|
3836 |
|
|
case btEnum:
|
3837 |
|
|
cross_ref (xref_fd,
|
3838 |
|
|
(debug_info->external_aux
|
3839 |
|
|
+ fh->iauxBase + sh.index + 1),
|
3840 |
|
|
tpp, type_code, pname,
|
3841 |
|
|
fh->fBigendian, sym_name);
|
3842 |
|
|
break;
|
3843 |
|
|
|
3844 |
|
|
case btTypedef:
|
3845 |
|
|
/* Follow a forward typedef. This might recursively
|
3846 |
|
|
call cross_ref till we get a non typedef'ed type.
|
3847 |
|
|
FIXME: This is not correct behaviour, but gdb currently
|
3848 |
|
|
cannot handle typedefs without type copying. Type
|
3849 |
|
|
copying is impossible as we might have mutual forward
|
3850 |
|
|
references between two files and the copied type would not
|
3851 |
|
|
get filled in when we later parse its definition. */
|
3852 |
|
|
*tpp = parse_type (xref_fd,
|
3853 |
|
|
debug_info->external_aux + fh->iauxBase,
|
3854 |
|
|
sh.index,
|
3855 |
|
|
(int *) NULL,
|
3856 |
|
|
fh->fBigendian,
|
3857 |
|
|
debug_info->ss + fh->issBase + sh.iss);
|
3858 |
|
|
add_pending (fh, esh, *tpp);
|
3859 |
|
|
break;
|
3860 |
|
|
|
3861 |
|
|
default:
|
3862 |
|
|
complain (&illegal_forward_bt_complaint, tir.bt, sym_name);
|
3863 |
|
|
*tpp = init_type (type_code, 0, 0, (char *) NULL,
|
3864 |
|
|
current_objfile);
|
3865 |
|
|
break;
|
3866 |
|
|
}
|
3867 |
|
|
return result;
|
3868 |
|
|
}
|
3869 |
|
|
else if (sh.st == stTypedef)
|
3870 |
|
|
{
|
3871 |
|
|
/* Parse the type for a normal typedef. This might recursively call
|
3872 |
|
|
cross_ref till we get a non typedef'ed type.
|
3873 |
|
|
FIXME: This is not correct behaviour, but gdb currently
|
3874 |
|
|
cannot handle typedefs without type copying. But type copying is
|
3875 |
|
|
impossible as we might have mutual forward references between
|
3876 |
|
|
two files and the copied type would not get filled in when
|
3877 |
|
|
we later parse its definition. */
|
3878 |
|
|
*tpp = parse_type (xref_fd,
|
3879 |
|
|
debug_info->external_aux + fh->iauxBase,
|
3880 |
|
|
sh.index,
|
3881 |
|
|
(int *) NULL,
|
3882 |
|
|
fh->fBigendian,
|
3883 |
|
|
debug_info->ss + fh->issBase + sh.iss);
|
3884 |
|
|
}
|
3885 |
|
|
else
|
3886 |
|
|
{
|
3887 |
|
|
/* Cross reference to a struct/union/enum which is defined
|
3888 |
|
|
in another file in the same compilation unit but that file
|
3889 |
|
|
has not been parsed yet.
|
3890 |
|
|
Initialize the type only, it will be filled in when
|
3891 |
|
|
it's definition is parsed. */
|
3892 |
|
|
*tpp = init_type (type_code, 0, 0, (char *) NULL, current_objfile);
|
3893 |
|
|
}
|
3894 |
|
|
add_pending (fh, esh, *tpp);
|
3895 |
|
|
}
|
3896 |
|
|
|
3897 |
|
|
/* We used one auxent normally, two if we got a "next one" rf. */
|
3898 |
|
|
return result;
|
3899 |
|
|
}
|
3900 |
|
|
|
3901 |
|
|
|
3902 |
|
|
/* Quick&dirty lookup procedure, to avoid the MI ones that require
|
3903 |
|
|
keeping the symtab sorted */
|
3904 |
|
|
|
3905 |
|
|
static struct symbol *
|
3906 |
|
|
mylookup_symbol (name, block, namespace, class)
|
3907 |
|
|
char *name;
|
3908 |
|
|
register struct block *block;
|
3909 |
|
|
namespace_enum namespace;
|
3910 |
|
|
enum address_class class;
|
3911 |
|
|
{
|
3912 |
|
|
register int bot, top, inc;
|
3913 |
|
|
register struct symbol *sym;
|
3914 |
|
|
|
3915 |
|
|
bot = 0;
|
3916 |
|
|
top = BLOCK_NSYMS (block);
|
3917 |
|
|
inc = name[0];
|
3918 |
|
|
while (bot < top)
|
3919 |
|
|
{
|
3920 |
|
|
sym = BLOCK_SYM (block, bot);
|
3921 |
|
|
if (SYMBOL_NAME (sym)[0] == inc
|
3922 |
|
|
&& SYMBOL_NAMESPACE (sym) == namespace
|
3923 |
|
|
&& SYMBOL_CLASS (sym) == class
|
3924 |
|
|
&& strcmp (SYMBOL_NAME (sym), name) == 0)
|
3925 |
|
|
return sym;
|
3926 |
|
|
bot++;
|
3927 |
|
|
}
|
3928 |
|
|
block = BLOCK_SUPERBLOCK (block);
|
3929 |
|
|
if (block)
|
3930 |
|
|
return mylookup_symbol (name, block, namespace, class);
|
3931 |
|
|
return 0;
|
3932 |
|
|
}
|
3933 |
|
|
|
3934 |
|
|
|
3935 |
|
|
/* Add a new symbol S to a block B.
|
3936 |
|
|
Infrequently, we will need to reallocate the block to make it bigger.
|
3937 |
|
|
We only detect this case when adding to top_stack->cur_block, since
|
3938 |
|
|
that's the only time we know how big the block is. FIXME. */
|
3939 |
|
|
|
3940 |
|
|
static void
|
3941 |
|
|
add_symbol (s, b)
|
3942 |
|
|
struct symbol *s;
|
3943 |
|
|
struct block *b;
|
3944 |
|
|
{
|
3945 |
|
|
int nsyms = BLOCK_NSYMS (b)++;
|
3946 |
|
|
struct block *origb;
|
3947 |
|
|
struct parse_stack *stackp;
|
3948 |
|
|
|
3949 |
|
|
if (b == top_stack->cur_block &&
|
3950 |
|
|
nsyms >= top_stack->maxsyms)
|
3951 |
|
|
{
|
3952 |
|
|
complain (&block_overflow_complaint, SYMBOL_NAME (s));
|
3953 |
|
|
/* In this case shrink_block is actually grow_block, since
|
3954 |
|
|
BLOCK_NSYMS(b) is larger than its current size. */
|
3955 |
|
|
origb = b;
|
3956 |
|
|
b = shrink_block (top_stack->cur_block, top_stack->cur_st);
|
3957 |
|
|
|
3958 |
|
|
/* Now run through the stack replacing pointers to the
|
3959 |
|
|
original block. shrink_block has already done this
|
3960 |
|
|
for the blockvector and BLOCK_FUNCTION. */
|
3961 |
|
|
for (stackp = top_stack; stackp; stackp = stackp->next)
|
3962 |
|
|
{
|
3963 |
|
|
if (stackp->cur_block == origb)
|
3964 |
|
|
{
|
3965 |
|
|
stackp->cur_block = b;
|
3966 |
|
|
stackp->maxsyms = BLOCK_NSYMS (b);
|
3967 |
|
|
}
|
3968 |
|
|
}
|
3969 |
|
|
}
|
3970 |
|
|
BLOCK_SYM (b, nsyms) = s;
|
3971 |
|
|
}
|
3972 |
|
|
|
3973 |
|
|
/* Add a new block B to a symtab S */
|
3974 |
|
|
|
3975 |
|
|
static void
|
3976 |
|
|
add_block (b, s)
|
3977 |
|
|
struct block *b;
|
3978 |
|
|
struct symtab *s;
|
3979 |
|
|
{
|
3980 |
|
|
struct blockvector *bv = BLOCKVECTOR (s);
|
3981 |
|
|
|
3982 |
|
|
bv = (struct blockvector *) xrealloc ((PTR) bv,
|
3983 |
|
|
(sizeof (struct blockvector)
|
3984 |
|
|
+ BLOCKVECTOR_NBLOCKS (bv)
|
3985 |
|
|
* sizeof (bv->block)));
|
3986 |
|
|
if (bv != BLOCKVECTOR (s))
|
3987 |
|
|
BLOCKVECTOR (s) = bv;
|
3988 |
|
|
|
3989 |
|
|
BLOCKVECTOR_BLOCK (bv, BLOCKVECTOR_NBLOCKS (bv)++) = b;
|
3990 |
|
|
}
|
3991 |
|
|
|
3992 |
|
|
/* Add a new linenumber entry (LINENO,ADR) to a linevector LT.
|
3993 |
|
|
MIPS' linenumber encoding might need more than one byte
|
3994 |
|
|
to describe it, LAST is used to detect these continuation lines.
|
3995 |
|
|
|
3996 |
|
|
Combining lines with the same line number seems like a bad idea.
|
3997 |
|
|
E.g: There could be a line number entry with the same line number after the
|
3998 |
|
|
prologue and GDB should not ignore it (this is a better way to find
|
3999 |
|
|
a prologue than mips_skip_prologue).
|
4000 |
|
|
But due to the compressed line table format there are line number entries
|
4001 |
|
|
for the same line which are needed to bridge the gap to the next
|
4002 |
|
|
line number entry. These entries have a bogus address info with them
|
4003 |
|
|
and we are unable to tell them from intended duplicate line number
|
4004 |
|
|
entries.
|
4005 |
|
|
This is another reason why -ggdb debugging format is preferable. */
|
4006 |
|
|
|
4007 |
|
|
static int
|
4008 |
|
|
add_line (lt, lineno, adr, last)
|
4009 |
|
|
struct linetable *lt;
|
4010 |
|
|
int lineno;
|
4011 |
|
|
CORE_ADDR adr;
|
4012 |
|
|
int last;
|
4013 |
|
|
{
|
4014 |
|
|
/* DEC c89 sometimes produces zero linenos which confuse gdb.
|
4015 |
|
|
Change them to something sensible. */
|
4016 |
|
|
if (lineno == 0)
|
4017 |
|
|
lineno = 1;
|
4018 |
|
|
if (last == 0)
|
4019 |
|
|
last = -2; /* make sure we record first line */
|
4020 |
|
|
|
4021 |
|
|
if (last == lineno) /* skip continuation lines */
|
4022 |
|
|
return lineno;
|
4023 |
|
|
|
4024 |
|
|
lt->item[lt->nitems].line = lineno;
|
4025 |
|
|
lt->item[lt->nitems++].pc = adr << 2;
|
4026 |
|
|
return lineno;
|
4027 |
|
|
}
|
4028 |
|
|
|
4029 |
|
|
/* Sorting and reordering procedures */
|
4030 |
|
|
|
4031 |
|
|
/* Blocks with a smaller low bound should come first */
|
4032 |
|
|
|
4033 |
|
|
static int
|
4034 |
|
|
compare_blocks (arg1, arg2)
|
4035 |
|
|
const PTR arg1;
|
4036 |
|
|
const PTR arg2;
|
4037 |
|
|
{
|
4038 |
|
|
register int addr_diff;
|
4039 |
|
|
struct block **b1 = (struct block **) arg1;
|
4040 |
|
|
struct block **b2 = (struct block **) arg2;
|
4041 |
|
|
|
4042 |
|
|
addr_diff = (BLOCK_START ((*b1))) - (BLOCK_START ((*b2)));
|
4043 |
|
|
if (addr_diff == 0)
|
4044 |
|
|
return (BLOCK_END ((*b2))) - (BLOCK_END ((*b1)));
|
4045 |
|
|
return addr_diff;
|
4046 |
|
|
}
|
4047 |
|
|
|
4048 |
|
|
/* Sort the blocks of a symtab S.
|
4049 |
|
|
Reorder the blocks in the blockvector by code-address,
|
4050 |
|
|
as required by some MI search routines */
|
4051 |
|
|
|
4052 |
|
|
static void
|
4053 |
|
|
sort_blocks (s)
|
4054 |
|
|
struct symtab *s;
|
4055 |
|
|
{
|
4056 |
|
|
struct blockvector *bv = BLOCKVECTOR (s);
|
4057 |
|
|
|
4058 |
|
|
if (BLOCKVECTOR_NBLOCKS (bv) <= 2)
|
4059 |
|
|
{
|
4060 |
|
|
/* Cosmetic */
|
4061 |
|
|
if (BLOCK_END (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) == 0)
|
4062 |
|
|
BLOCK_START (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) = 0;
|
4063 |
|
|
if (BLOCK_END (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) == 0)
|
4064 |
|
|
BLOCK_START (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) = 0;
|
4065 |
|
|
return;
|
4066 |
|
|
}
|
4067 |
|
|
/*
|
4068 |
|
|
* This is very unfortunate: normally all functions are compiled in
|
4069 |
|
|
* the order they are found, but if the file is compiled -O3 things
|
4070 |
|
|
* are very different. It would be nice to find a reliable test
|
4071 |
|
|
* to detect -O3 images in advance.
|
4072 |
|
|
*/
|
4073 |
|
|
if (BLOCKVECTOR_NBLOCKS (bv) > 3)
|
4074 |
|
|
qsort (&BLOCKVECTOR_BLOCK (bv, FIRST_LOCAL_BLOCK),
|
4075 |
|
|
BLOCKVECTOR_NBLOCKS (bv) - FIRST_LOCAL_BLOCK,
|
4076 |
|
|
sizeof (struct block *),
|
4077 |
|
|
compare_blocks);
|
4078 |
|
|
|
4079 |
|
|
{
|
4080 |
|
|
register CORE_ADDR high = 0;
|
4081 |
|
|
register int i, j = BLOCKVECTOR_NBLOCKS (bv);
|
4082 |
|
|
|
4083 |
|
|
for (i = FIRST_LOCAL_BLOCK; i < j; i++)
|
4084 |
|
|
if (high < BLOCK_END (BLOCKVECTOR_BLOCK (bv, i)))
|
4085 |
|
|
high = BLOCK_END (BLOCKVECTOR_BLOCK (bv, i));
|
4086 |
|
|
BLOCK_END (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) = high;
|
4087 |
|
|
}
|
4088 |
|
|
|
4089 |
|
|
BLOCK_START (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) =
|
4090 |
|
|
BLOCK_START (BLOCKVECTOR_BLOCK (bv, FIRST_LOCAL_BLOCK));
|
4091 |
|
|
|
4092 |
|
|
BLOCK_START (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) =
|
4093 |
|
|
BLOCK_START (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK));
|
4094 |
|
|
BLOCK_END (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) =
|
4095 |
|
|
BLOCK_END (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK));
|
4096 |
|
|
}
|
4097 |
|
|
|
4098 |
|
|
|
4099 |
|
|
/* Constructor/restructor/destructor procedures */
|
4100 |
|
|
|
4101 |
|
|
/* Allocate a new symtab for NAME. Needs an estimate of how many symbols
|
4102 |
|
|
MAXSYMS and linenumbers MAXLINES we'll put in it */
|
4103 |
|
|
|
4104 |
|
|
static struct symtab *
|
4105 |
|
|
new_symtab (name, maxsyms, maxlines, objfile)
|
4106 |
|
|
char *name;
|
4107 |
|
|
int maxsyms;
|
4108 |
|
|
int maxlines;
|
4109 |
|
|
struct objfile *objfile;
|
4110 |
|
|
{
|
4111 |
|
|
struct symtab *s = allocate_symtab (name, objfile);
|
4112 |
|
|
|
4113 |
|
|
LINETABLE (s) = new_linetable (maxlines);
|
4114 |
|
|
|
4115 |
|
|
/* All symtabs must have at least two blocks */
|
4116 |
|
|
BLOCKVECTOR (s) = new_bvect (2);
|
4117 |
|
|
BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK) = new_block (maxsyms);
|
4118 |
|
|
BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK) = new_block (maxsyms);
|
4119 |
|
|
BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK)) =
|
4120 |
|
|
BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
|
4121 |
|
|
|
4122 |
|
|
s->free_code = free_linetable;
|
4123 |
|
|
s->debugformat = obsavestring ("ECOFF", 5,
|
4124 |
|
|
&objfile->symbol_obstack);
|
4125 |
|
|
return (s);
|
4126 |
|
|
}
|
4127 |
|
|
|
4128 |
|
|
/* Allocate a new partial_symtab NAME */
|
4129 |
|
|
|
4130 |
|
|
static struct partial_symtab *
|
4131 |
|
|
new_psymtab (name, objfile)
|
4132 |
|
|
char *name;
|
4133 |
|
|
struct objfile *objfile;
|
4134 |
|
|
{
|
4135 |
|
|
struct partial_symtab *psymtab;
|
4136 |
|
|
|
4137 |
|
|
psymtab = allocate_psymtab (name, objfile);
|
4138 |
|
|
psymtab->section_offsets = objfile->section_offsets;
|
4139 |
|
|
|
4140 |
|
|
/* Keep a backpointer to the file's symbols */
|
4141 |
|
|
|
4142 |
|
|
psymtab->read_symtab_private = ((char *)
|
4143 |
|
|
obstack_alloc (&objfile->psymbol_obstack,
|
4144 |
|
|
sizeof (struct symloc)));
|
4145 |
|
|
memset ((PTR) psymtab->read_symtab_private, 0, sizeof (struct symloc));
|
4146 |
|
|
CUR_BFD (psymtab) = cur_bfd;
|
4147 |
|
|
DEBUG_SWAP (psymtab) = debug_swap;
|
4148 |
|
|
DEBUG_INFO (psymtab) = debug_info;
|
4149 |
|
|
PENDING_LIST (psymtab) = pending_list;
|
4150 |
|
|
|
4151 |
|
|
/* The way to turn this into a symtab is to call... */
|
4152 |
|
|
psymtab->read_symtab = mdebug_psymtab_to_symtab;
|
4153 |
|
|
return (psymtab);
|
4154 |
|
|
}
|
4155 |
|
|
|
4156 |
|
|
|
4157 |
|
|
/* Allocate a linetable array of the given SIZE. Since the struct
|
4158 |
|
|
already includes one item, we subtract one when calculating the
|
4159 |
|
|
proper size to allocate. */
|
4160 |
|
|
|
4161 |
|
|
static struct linetable *
|
4162 |
|
|
new_linetable (size)
|
4163 |
|
|
int size;
|
4164 |
|
|
{
|
4165 |
|
|
struct linetable *l;
|
4166 |
|
|
|
4167 |
|
|
size = (size - 1) * sizeof (l->item) + sizeof (struct linetable);
|
4168 |
|
|
l = (struct linetable *) xmalloc (size);
|
4169 |
|
|
l->nitems = 0;
|
4170 |
|
|
return l;
|
4171 |
|
|
}
|
4172 |
|
|
|
4173 |
|
|
/* Oops, too big. Shrink it. This was important with the 2.4 linetables,
|
4174 |
|
|
I am not so sure about the 3.4 ones.
|
4175 |
|
|
|
4176 |
|
|
Since the struct linetable already includes one item, we subtract one when
|
4177 |
|
|
calculating the proper size to allocate. */
|
4178 |
|
|
|
4179 |
|
|
static struct linetable *
|
4180 |
|
|
shrink_linetable (lt)
|
4181 |
|
|
struct linetable *lt;
|
4182 |
|
|
{
|
4183 |
|
|
|
4184 |
|
|
return (struct linetable *) xrealloc ((PTR) lt,
|
4185 |
|
|
(sizeof (struct linetable)
|
4186 |
|
|
+ ((lt->nitems - 1)
|
4187 |
|
|
* sizeof (lt->item))));
|
4188 |
|
|
}
|
4189 |
|
|
|
4190 |
|
|
/* Allocate and zero a new blockvector of NBLOCKS blocks. */
|
4191 |
|
|
|
4192 |
|
|
static struct blockvector *
|
4193 |
|
|
new_bvect (nblocks)
|
4194 |
|
|
int nblocks;
|
4195 |
|
|
{
|
4196 |
|
|
struct blockvector *bv;
|
4197 |
|
|
int size;
|
4198 |
|
|
|
4199 |
|
|
size = sizeof (struct blockvector) + nblocks * sizeof (struct block *);
|
4200 |
|
|
bv = (struct blockvector *) xzalloc (size);
|
4201 |
|
|
|
4202 |
|
|
BLOCKVECTOR_NBLOCKS (bv) = nblocks;
|
4203 |
|
|
|
4204 |
|
|
return bv;
|
4205 |
|
|
}
|
4206 |
|
|
|
4207 |
|
|
/* Allocate and zero a new block of MAXSYMS symbols */
|
4208 |
|
|
|
4209 |
|
|
static struct block *
|
4210 |
|
|
new_block (maxsyms)
|
4211 |
|
|
int maxsyms;
|
4212 |
|
|
{
|
4213 |
|
|
int size = sizeof (struct block) + (maxsyms - 1) * sizeof (struct symbol *);
|
4214 |
|
|
|
4215 |
|
|
return (struct block *) xzalloc (size);
|
4216 |
|
|
}
|
4217 |
|
|
|
4218 |
|
|
/* Ooops, too big. Shrink block B in symtab S to its minimal size.
|
4219 |
|
|
Shrink_block can also be used by add_symbol to grow a block. */
|
4220 |
|
|
|
4221 |
|
|
static struct block *
|
4222 |
|
|
shrink_block (b, s)
|
4223 |
|
|
struct block *b;
|
4224 |
|
|
struct symtab *s;
|
4225 |
|
|
{
|
4226 |
|
|
struct block *new;
|
4227 |
|
|
struct blockvector *bv = BLOCKVECTOR (s);
|
4228 |
|
|
int i;
|
4229 |
|
|
|
4230 |
|
|
/* Just reallocate it and fix references to the old one */
|
4231 |
|
|
|
4232 |
|
|
new = (struct block *) xrealloc ((PTR) b,
|
4233 |
|
|
(sizeof (struct block)
|
4234 |
|
|
+ ((BLOCK_NSYMS (b) - 1)
|
4235 |
|
|
* sizeof (struct symbol *))));
|
4236 |
|
|
|
4237 |
|
|
/* Should chase pointers to old one. Fortunately, that`s just
|
4238 |
|
|
the block`s function and inferior blocks */
|
4239 |
|
|
if (BLOCK_FUNCTION (new) && SYMBOL_BLOCK_VALUE (BLOCK_FUNCTION (new)) == b)
|
4240 |
|
|
SYMBOL_BLOCK_VALUE (BLOCK_FUNCTION (new)) = new;
|
4241 |
|
|
for (i = 0; i < BLOCKVECTOR_NBLOCKS (bv); i++)
|
4242 |
|
|
if (BLOCKVECTOR_BLOCK (bv, i) == b)
|
4243 |
|
|
BLOCKVECTOR_BLOCK (bv, i) = new;
|
4244 |
|
|
else if (BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (bv, i)) == b)
|
4245 |
|
|
BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (bv, i)) = new;
|
4246 |
|
|
return new;
|
4247 |
|
|
}
|
4248 |
|
|
|
4249 |
|
|
/* Create a new symbol with printname NAME */
|
4250 |
|
|
|
4251 |
|
|
static struct symbol *
|
4252 |
|
|
new_symbol (name)
|
4253 |
|
|
char *name;
|
4254 |
|
|
{
|
4255 |
|
|
struct symbol *s = ((struct symbol *)
|
4256 |
|
|
obstack_alloc (¤t_objfile->symbol_obstack,
|
4257 |
|
|
sizeof (struct symbol)));
|
4258 |
|
|
|
4259 |
|
|
memset ((PTR) s, 0, sizeof (*s));
|
4260 |
|
|
SYMBOL_NAME (s) = obsavestring (name, strlen (name),
|
4261 |
|
|
¤t_objfile->symbol_obstack);
|
4262 |
|
|
SYMBOL_LANGUAGE (s) = psymtab_language;
|
4263 |
|
|
SYMBOL_INIT_DEMANGLED_NAME (s, ¤t_objfile->symbol_obstack);
|
4264 |
|
|
return s;
|
4265 |
|
|
}
|
4266 |
|
|
|
4267 |
|
|
/* Create a new type with printname NAME */
|
4268 |
|
|
|
4269 |
|
|
static struct type *
|
4270 |
|
|
new_type (name)
|
4271 |
|
|
char *name;
|
4272 |
|
|
{
|
4273 |
|
|
struct type *t;
|
4274 |
|
|
|
4275 |
|
|
t = alloc_type (current_objfile);
|
4276 |
|
|
TYPE_NAME (t) = name;
|
4277 |
|
|
TYPE_CPLUS_SPECIFIC (t) = (struct cplus_struct_type *) &cplus_struct_default;
|
4278 |
|
|
return t;
|
4279 |
|
|
}
|
4280 |
|
|
|
4281 |
|
|
/* Read ECOFF debugging information from a BFD section. This is
|
4282 |
|
|
called from elfread.c. It parses the section into a
|
4283 |
|
|
ecoff_debug_info struct, and then lets the rest of the file handle
|
4284 |
|
|
it as normal. */
|
4285 |
|
|
|
4286 |
|
|
void
|
4287 |
|
|
elfmdebug_build_psymtabs (objfile, swap, sec)
|
4288 |
|
|
struct objfile *objfile;
|
4289 |
|
|
const struct ecoff_debug_swap *swap;
|
4290 |
|
|
asection *sec;
|
4291 |
|
|
{
|
4292 |
|
|
bfd *abfd = objfile->obfd;
|
4293 |
|
|
struct ecoff_debug_info *info;
|
4294 |
|
|
|
4295 |
|
|
info = ((struct ecoff_debug_info *)
|
4296 |
|
|
obstack_alloc (&objfile->psymbol_obstack,
|
4297 |
|
|
sizeof (struct ecoff_debug_info)));
|
4298 |
|
|
|
4299 |
|
|
if (!(*swap->read_debug_info) (abfd, sec, info))
|
4300 |
|
|
error ("Error reading ECOFF debugging information: %s",
|
4301 |
|
|
bfd_errmsg (bfd_get_error ()));
|
4302 |
|
|
|
4303 |
|
|
mdebug_build_psymtabs (objfile, swap, info);
|
4304 |
|
|
}
|
4305 |
|
|
|
4306 |
|
|
|
4307 |
|
|
/* Things used for calling functions in the inferior.
|
4308 |
|
|
These functions are exported to our companion
|
4309 |
|
|
mips-tdep.c file and are here because they play
|
4310 |
|
|
with the symbol-table explicitly. */
|
4311 |
|
|
|
4312 |
|
|
/* Sigtramp: make sure we have all the necessary information
|
4313 |
|
|
about the signal trampoline code. Since the official code
|
4314 |
|
|
from MIPS does not do so, we make up that information ourselves.
|
4315 |
|
|
If they fix the library (unlikely) this code will neutralize itself. */
|
4316 |
|
|
|
4317 |
|
|
/* FIXME: This function is called only by mips-tdep.c. It needs to be
|
4318 |
|
|
here because it calls functions defined in this file, but perhaps
|
4319 |
|
|
this could be handled in a better way. Only compile it in when
|
4320 |
|
|
tm-mips.h is included. */
|
4321 |
|
|
|
4322 |
|
|
#ifdef TM_MIPS_H
|
4323 |
|
|
|
4324 |
|
|
void
|
4325 |
|
|
fixup_sigtramp ()
|
4326 |
|
|
{
|
4327 |
|
|
struct symbol *s;
|
4328 |
|
|
struct symtab *st;
|
4329 |
|
|
struct block *b, *b0 = NULL;
|
4330 |
|
|
|
4331 |
|
|
sigtramp_address = -1;
|
4332 |
|
|
|
4333 |
|
|
/* We have to handle the following cases here:
|
4334 |
|
|
a) The Mips library has a sigtramp label within sigvec.
|
4335 |
|
|
b) Irix has a _sigtramp which we want to use, but it also has sigvec. */
|
4336 |
|
|
s = lookup_symbol ("sigvec", 0, VAR_NAMESPACE, 0, NULL);
|
4337 |
|
|
if (s != 0)
|
4338 |
|
|
{
|
4339 |
|
|
b0 = SYMBOL_BLOCK_VALUE (s);
|
4340 |
|
|
s = lookup_symbol ("sigtramp", b0, VAR_NAMESPACE, 0, NULL);
|
4341 |
|
|
}
|
4342 |
|
|
if (s == 0)
|
4343 |
|
|
{
|
4344 |
|
|
/* No sigvec or no sigtramp inside sigvec, try _sigtramp. */
|
4345 |
|
|
s = lookup_symbol ("_sigtramp", 0, VAR_NAMESPACE, 0, NULL);
|
4346 |
|
|
}
|
4347 |
|
|
|
4348 |
|
|
/* But maybe this program uses its own version of sigvec */
|
4349 |
|
|
if (s == 0)
|
4350 |
|
|
return;
|
4351 |
|
|
|
4352 |
|
|
/* Did we or MIPSco fix the library ? */
|
4353 |
|
|
if (SYMBOL_CLASS (s) == LOC_BLOCK)
|
4354 |
|
|
{
|
4355 |
|
|
sigtramp_address = BLOCK_START (SYMBOL_BLOCK_VALUE (s));
|
4356 |
|
|
sigtramp_end = BLOCK_END (SYMBOL_BLOCK_VALUE (s));
|
4357 |
|
|
return;
|
4358 |
|
|
}
|
4359 |
|
|
|
4360 |
|
|
sigtramp_address = SYMBOL_VALUE (s);
|
4361 |
|
|
sigtramp_end = sigtramp_address + 0x88; /* black magic */
|
4362 |
|
|
|
4363 |
|
|
/* But what symtab does it live in ? */
|
4364 |
|
|
st = find_pc_symtab (SYMBOL_VALUE (s));
|
4365 |
|
|
|
4366 |
|
|
/*
|
4367 |
|
|
* Ok, there goes the fix: turn it into a procedure, with all the
|
4368 |
|
|
* needed info. Note we make it a nested procedure of sigvec,
|
4369 |
|
|
* which is the way the (assembly) code is actually written.
|
4370 |
|
|
*/
|
4371 |
|
|
SYMBOL_NAMESPACE (s) = VAR_NAMESPACE;
|
4372 |
|
|
SYMBOL_CLASS (s) = LOC_BLOCK;
|
4373 |
|
|
SYMBOL_TYPE (s) = init_type (TYPE_CODE_FUNC, 4, 0, (char *) NULL,
|
4374 |
|
|
st->objfile);
|
4375 |
|
|
TYPE_TARGET_TYPE (SYMBOL_TYPE (s)) = mdebug_type_void;
|
4376 |
|
|
|
4377 |
|
|
/* Need a block to allocate MIPS_EFI_SYMBOL_NAME in */
|
4378 |
|
|
b = new_block (1);
|
4379 |
|
|
SYMBOL_BLOCK_VALUE (s) = b;
|
4380 |
|
|
BLOCK_START (b) = sigtramp_address;
|
4381 |
|
|
BLOCK_END (b) = sigtramp_end;
|
4382 |
|
|
BLOCK_FUNCTION (b) = s;
|
4383 |
|
|
BLOCK_SUPERBLOCK (b) = BLOCK_SUPERBLOCK (b0);
|
4384 |
|
|
add_block (b, st);
|
4385 |
|
|
sort_blocks (st);
|
4386 |
|
|
|
4387 |
|
|
/* Make a MIPS_EFI_SYMBOL_NAME entry for it */
|
4388 |
|
|
{
|
4389 |
|
|
struct mips_extra_func_info *e =
|
4390 |
|
|
((struct mips_extra_func_info *)
|
4391 |
|
|
xzalloc (sizeof (struct mips_extra_func_info)));
|
4392 |
|
|
|
4393 |
|
|
e->numargs = 0; /* the kernel thinks otherwise */
|
4394 |
|
|
e->pdr.frameoffset = 32;
|
4395 |
|
|
e->pdr.framereg = SP_REGNUM;
|
4396 |
|
|
/* Note that setting pcreg is no longer strictly necessary as
|
4397 |
|
|
mips_frame_saved_pc is now aware of signal handler frames. */
|
4398 |
|
|
e->pdr.pcreg = PC_REGNUM;
|
4399 |
|
|
e->pdr.regmask = -2;
|
4400 |
|
|
/* Offset to saved r31, in the sigtramp case the saved registers
|
4401 |
|
|
are above the frame in the sigcontext.
|
4402 |
|
|
We have 4 alignment bytes, 12 bytes for onstack, mask and pc,
|
4403 |
|
|
32 * 4 bytes for the general registers, 12 bytes for mdhi, mdlo, ownedfp
|
4404 |
|
|
and 32 * 4 bytes for the floating point registers. */
|
4405 |
|
|
e->pdr.regoffset = 4 + 12 + 31 * 4;
|
4406 |
|
|
e->pdr.fregmask = -1;
|
4407 |
|
|
/* Offset to saved f30 (first saved *double* register). */
|
4408 |
|
|
e->pdr.fregoffset = 4 + 12 + 32 * 4 + 12 + 30 * 4;
|
4409 |
|
|
e->pdr.isym = (long) s;
|
4410 |
|
|
e->pdr.adr = sigtramp_address;
|
4411 |
|
|
|
4412 |
|
|
current_objfile = st->objfile; /* Keep new_symbol happy */
|
4413 |
|
|
s = new_symbol (MIPS_EFI_SYMBOL_NAME);
|
4414 |
|
|
SYMBOL_VALUE (s) = (long) e;
|
4415 |
|
|
SYMBOL_NAMESPACE (s) = LABEL_NAMESPACE;
|
4416 |
|
|
SYMBOL_CLASS (s) = LOC_CONST;
|
4417 |
|
|
SYMBOL_TYPE (s) = mdebug_type_void;
|
4418 |
|
|
current_objfile = NULL;
|
4419 |
|
|
}
|
4420 |
|
|
|
4421 |
|
|
BLOCK_SYM (b, BLOCK_NSYMS (b)++) = s;
|
4422 |
|
|
}
|
4423 |
|
|
|
4424 |
|
|
#endif /* TM_MIPS_H */
|
4425 |
|
|
|
4426 |
|
|
void
|
4427 |
|
|
_initialize_mdebugread ()
|
4428 |
|
|
{
|
4429 |
|
|
mdebug_type_void =
|
4430 |
|
|
init_type (TYPE_CODE_VOID, 1,
|
4431 |
|
|
0,
|
4432 |
|
|
"void", (struct objfile *) NULL);
|
4433 |
|
|
mdebug_type_char =
|
4434 |
|
|
init_type (TYPE_CODE_INT, 1,
|
4435 |
|
|
0,
|
4436 |
|
|
"char", (struct objfile *) NULL);
|
4437 |
|
|
mdebug_type_unsigned_char =
|
4438 |
|
|
init_type (TYPE_CODE_INT, 1,
|
4439 |
|
|
TYPE_FLAG_UNSIGNED,
|
4440 |
|
|
"unsigned char", (struct objfile *) NULL);
|
4441 |
|
|
mdebug_type_short =
|
4442 |
|
|
init_type (TYPE_CODE_INT, 2,
|
4443 |
|
|
0,
|
4444 |
|
|
"short", (struct objfile *) NULL);
|
4445 |
|
|
mdebug_type_unsigned_short =
|
4446 |
|
|
init_type (TYPE_CODE_INT, 2,
|
4447 |
|
|
TYPE_FLAG_UNSIGNED,
|
4448 |
|
|
"unsigned short", (struct objfile *) NULL);
|
4449 |
|
|
mdebug_type_int_32 =
|
4450 |
|
|
init_type (TYPE_CODE_INT, 4,
|
4451 |
|
|
0,
|
4452 |
|
|
"int", (struct objfile *) NULL);
|
4453 |
|
|
mdebug_type_unsigned_int_32 =
|
4454 |
|
|
init_type (TYPE_CODE_INT, 4,
|
4455 |
|
|
TYPE_FLAG_UNSIGNED,
|
4456 |
|
|
"unsigned int", (struct objfile *) NULL);
|
4457 |
|
|
mdebug_type_int_64 =
|
4458 |
|
|
init_type (TYPE_CODE_INT, 8,
|
4459 |
|
|
0,
|
4460 |
|
|
"int", (struct objfile *) NULL);
|
4461 |
|
|
mdebug_type_unsigned_int_64 =
|
4462 |
|
|
init_type (TYPE_CODE_INT, 8,
|
4463 |
|
|
TYPE_FLAG_UNSIGNED,
|
4464 |
|
|
"unsigned int", (struct objfile *) NULL);
|
4465 |
|
|
mdebug_type_long_32 =
|
4466 |
|
|
init_type (TYPE_CODE_INT, 4,
|
4467 |
|
|
0,
|
4468 |
|
|
"long", (struct objfile *) NULL);
|
4469 |
|
|
mdebug_type_unsigned_long_32 =
|
4470 |
|
|
init_type (TYPE_CODE_INT, 4,
|
4471 |
|
|
TYPE_FLAG_UNSIGNED,
|
4472 |
|
|
"unsigned long", (struct objfile *) NULL);
|
4473 |
|
|
mdebug_type_long_64 =
|
4474 |
|
|
init_type (TYPE_CODE_INT, 8,
|
4475 |
|
|
0,
|
4476 |
|
|
"long", (struct objfile *) NULL);
|
4477 |
|
|
mdebug_type_unsigned_long_64 =
|
4478 |
|
|
init_type (TYPE_CODE_INT, 8,
|
4479 |
|
|
TYPE_FLAG_UNSIGNED,
|
4480 |
|
|
"unsigned long", (struct objfile *) NULL);
|
4481 |
|
|
mdebug_type_long_long_64 =
|
4482 |
|
|
init_type (TYPE_CODE_INT, 8,
|
4483 |
|
|
0,
|
4484 |
|
|
"long long", (struct objfile *) NULL);
|
4485 |
|
|
mdebug_type_unsigned_long_long_64 =
|
4486 |
|
|
init_type (TYPE_CODE_INT, 8,
|
4487 |
|
|
TYPE_FLAG_UNSIGNED,
|
4488 |
|
|
"unsigned long long", (struct objfile *) NULL);
|
4489 |
|
|
mdebug_type_adr_32 =
|
4490 |
|
|
init_type (TYPE_CODE_PTR, 4,
|
4491 |
|
|
TYPE_FLAG_UNSIGNED,
|
4492 |
|
|
"adr_32", (struct objfile *) NULL);
|
4493 |
|
|
TYPE_TARGET_TYPE (mdebug_type_adr_32) = mdebug_type_void;
|
4494 |
|
|
mdebug_type_adr_64 =
|
4495 |
|
|
init_type (TYPE_CODE_PTR, 8,
|
4496 |
|
|
TYPE_FLAG_UNSIGNED,
|
4497 |
|
|
"adr_64", (struct objfile *) NULL);
|
4498 |
|
|
TYPE_TARGET_TYPE (mdebug_type_adr_64) = mdebug_type_void;
|
4499 |
|
|
mdebug_type_float =
|
4500 |
|
|
init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
|
4501 |
|
|
0,
|
4502 |
|
|
"float", (struct objfile *) NULL);
|
4503 |
|
|
mdebug_type_double =
|
4504 |
|
|
init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
|
4505 |
|
|
0,
|
4506 |
|
|
"double", (struct objfile *) NULL);
|
4507 |
|
|
mdebug_type_complex =
|
4508 |
|
|
init_type (TYPE_CODE_COMPLEX, 2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
|
4509 |
|
|
0,
|
4510 |
|
|
"complex", (struct objfile *) NULL);
|
4511 |
|
|
TYPE_TARGET_TYPE (mdebug_type_complex) = mdebug_type_float;
|
4512 |
|
|
mdebug_type_double_complex =
|
4513 |
|
|
init_type (TYPE_CODE_COMPLEX, 2 * TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
|
4514 |
|
|
0,
|
4515 |
|
|
"double complex", (struct objfile *) NULL);
|
4516 |
|
|
TYPE_TARGET_TYPE (mdebug_type_double_complex) = mdebug_type_double;
|
4517 |
|
|
|
4518 |
|
|
/* Is a "string" the way btString means it the same as TYPE_CODE_STRING?
|
4519 |
|
|
FIXME. */
|
4520 |
|
|
mdebug_type_string =
|
4521 |
|
|
init_type (TYPE_CODE_STRING,
|
4522 |
|
|
TARGET_CHAR_BIT / TARGET_CHAR_BIT,
|
4523 |
|
|
0, "string",
|
4524 |
|
|
(struct objfile *) NULL);
|
4525 |
|
|
|
4526 |
|
|
/* We use TYPE_CODE_INT to print these as integers. Does this do any
|
4527 |
|
|
good? Would we be better off with TYPE_CODE_ERROR? Should
|
4528 |
|
|
TYPE_CODE_ERROR print things in hex if it knows the size? */
|
4529 |
|
|
mdebug_type_fixed_dec =
|
4530 |
|
|
init_type (TYPE_CODE_INT,
|
4531 |
|
|
TARGET_INT_BIT / TARGET_CHAR_BIT,
|
4532 |
|
|
0, "fixed decimal",
|
4533 |
|
|
(struct objfile *) NULL);
|
4534 |
|
|
|
4535 |
|
|
mdebug_type_float_dec =
|
4536 |
|
|
init_type (TYPE_CODE_ERROR,
|
4537 |
|
|
TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
|
4538 |
|
|
0, "floating decimal",
|
4539 |
|
|
(struct objfile *) NULL);
|
4540 |
|
|
|
4541 |
|
|
nodebug_func_symbol_type = init_type (TYPE_CODE_FUNC, 1, 0,
|
4542 |
|
|
"<function, no debug info>", NULL);
|
4543 |
|
|
TYPE_TARGET_TYPE (nodebug_func_symbol_type) = mdebug_type_int;
|
4544 |
|
|
nodebug_var_symbol_type =
|
4545 |
|
|
init_type (TYPE_CODE_INT, TARGET_INT_BIT / HOST_CHAR_BIT, 0,
|
4546 |
|
|
"<variable, no debug info>", NULL);
|
4547 |
|
|
}
|