1 |
104 |
markom |
/* Support routines for decoding "stabs" debugging information format.
|
2 |
|
|
Copyright 1986, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 1998
|
3 |
|
|
Free Software Foundation, Inc.
|
4 |
|
|
|
5 |
|
|
This file is part of GDB.
|
6 |
|
|
|
7 |
|
|
This program is free software; you can redistribute it and/or modify
|
8 |
|
|
it under the terms of the GNU General Public License as published by
|
9 |
|
|
the Free Software Foundation; either version 2 of the License, or
|
10 |
|
|
(at your option) any later version.
|
11 |
|
|
|
12 |
|
|
This program is distributed in the hope that it will be useful,
|
13 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
|
|
GNU General Public License for more details.
|
16 |
|
|
|
17 |
|
|
You should have received a copy of the GNU General Public License
|
18 |
|
|
along with this program; if not, write to the Free Software
|
19 |
|
|
Foundation, Inc., 59 Temple Place - Suite 330,
|
20 |
|
|
Boston, MA 02111-1307, USA. */
|
21 |
|
|
|
22 |
|
|
/* Support routines for reading and decoding debugging information in
|
23 |
|
|
the "stabs" format. This format is used with many systems that use
|
24 |
|
|
the a.out object file format, as well as some systems that use
|
25 |
|
|
COFF or ELF where the stabs data is placed in a special section.
|
26 |
|
|
Avoid placing any object file format specific code in this file. */
|
27 |
|
|
|
28 |
|
|
#include "defs.h"
|
29 |
|
|
#include "gdb_string.h"
|
30 |
|
|
#include "bfd.h"
|
31 |
|
|
#include "obstack.h"
|
32 |
|
|
#include "symtab.h"
|
33 |
|
|
#include "gdbtypes.h"
|
34 |
|
|
#include "expression.h"
|
35 |
|
|
#include "symfile.h"
|
36 |
|
|
#include "objfiles.h"
|
37 |
|
|
#include "aout/stab_gnu.h" /* We always use GNU stabs, not native */
|
38 |
|
|
#include "libaout.h"
|
39 |
|
|
#include "aout/aout64.h"
|
40 |
|
|
#include "gdb-stabs.h"
|
41 |
|
|
#include "buildsym.h"
|
42 |
|
|
#include "complaints.h"
|
43 |
|
|
#include "demangle.h"
|
44 |
|
|
#include "language.h"
|
45 |
|
|
|
46 |
|
|
#include <ctype.h>
|
47 |
|
|
|
48 |
|
|
/* Ask stabsread.h to define the vars it normally declares `extern'. */
|
49 |
|
|
#define EXTERN
|
50 |
|
|
/**/
|
51 |
|
|
#include "stabsread.h" /* Our own declarations */
|
52 |
|
|
#undef EXTERN
|
53 |
|
|
|
54 |
|
|
extern void _initialize_stabsread PARAMS ((void));
|
55 |
|
|
|
56 |
|
|
/* The routines that read and process a complete stabs for a C struct or
|
57 |
|
|
C++ class pass lists of data member fields and lists of member function
|
58 |
|
|
fields in an instance of a field_info structure, as defined below.
|
59 |
|
|
This is part of some reorganization of low level C++ support and is
|
60 |
|
|
expected to eventually go away... (FIXME) */
|
61 |
|
|
|
62 |
|
|
struct field_info
|
63 |
|
|
{
|
64 |
|
|
struct nextfield
|
65 |
|
|
{
|
66 |
|
|
struct nextfield *next;
|
67 |
|
|
|
68 |
|
|
/* This is the raw visibility from the stab. It is not checked
|
69 |
|
|
for being one of the visibilities we recognize, so code which
|
70 |
|
|
examines this field better be able to deal. */
|
71 |
|
|
int visibility;
|
72 |
|
|
|
73 |
|
|
struct field field;
|
74 |
|
|
}
|
75 |
|
|
*list;
|
76 |
|
|
struct next_fnfieldlist
|
77 |
|
|
{
|
78 |
|
|
struct next_fnfieldlist *next;
|
79 |
|
|
struct fn_fieldlist fn_fieldlist;
|
80 |
|
|
}
|
81 |
|
|
*fnlist;
|
82 |
|
|
};
|
83 |
|
|
|
84 |
|
|
static void
|
85 |
|
|
read_one_struct_field PARAMS ((struct field_info *, char **, char *,
|
86 |
|
|
struct type *, struct objfile *));
|
87 |
|
|
|
88 |
|
|
static char *
|
89 |
|
|
get_substring PARAMS ((char **, int));
|
90 |
|
|
|
91 |
|
|
static struct type *
|
92 |
|
|
dbx_alloc_type PARAMS ((int[2], struct objfile *));
|
93 |
|
|
|
94 |
|
|
static long read_huge_number PARAMS ((char **, int, int *));
|
95 |
|
|
|
96 |
|
|
static struct type *error_type PARAMS ((char **, struct objfile *));
|
97 |
|
|
|
98 |
|
|
static void
|
99 |
|
|
patch_block_stabs PARAMS ((struct pending *, struct pending_stabs *,
|
100 |
|
|
struct objfile *));
|
101 |
|
|
|
102 |
|
|
static void
|
103 |
|
|
fix_common_block PARAMS ((struct symbol *, int));
|
104 |
|
|
|
105 |
|
|
static int
|
106 |
|
|
read_type_number PARAMS ((char **, int *));
|
107 |
|
|
|
108 |
|
|
static struct type *
|
109 |
|
|
read_range_type PARAMS ((char **, int[2], struct objfile *));
|
110 |
|
|
|
111 |
|
|
static struct type *
|
112 |
|
|
read_sun_builtin_type PARAMS ((char **, int[2], struct objfile *));
|
113 |
|
|
|
114 |
|
|
static struct type *
|
115 |
|
|
read_sun_floating_type PARAMS ((char **, int[2], struct objfile *));
|
116 |
|
|
|
117 |
|
|
static struct type *
|
118 |
|
|
read_enum_type PARAMS ((char **, struct type *, struct objfile *));
|
119 |
|
|
|
120 |
|
|
static struct type *
|
121 |
|
|
rs6000_builtin_type PARAMS ((int));
|
122 |
|
|
|
123 |
|
|
static int
|
124 |
|
|
read_member_functions PARAMS ((struct field_info *, char **, struct type *,
|
125 |
|
|
struct objfile *));
|
126 |
|
|
|
127 |
|
|
static int
|
128 |
|
|
read_struct_fields PARAMS ((struct field_info *, char **, struct type *,
|
129 |
|
|
struct objfile *));
|
130 |
|
|
|
131 |
|
|
static int
|
132 |
|
|
read_baseclasses PARAMS ((struct field_info *, char **, struct type *,
|
133 |
|
|
struct objfile *));
|
134 |
|
|
|
135 |
|
|
static int
|
136 |
|
|
read_tilde_fields PARAMS ((struct field_info *, char **, struct type *,
|
137 |
|
|
struct objfile *));
|
138 |
|
|
|
139 |
|
|
static int
|
140 |
|
|
attach_fn_fields_to_type PARAMS ((struct field_info *, struct type *));
|
141 |
|
|
|
142 |
|
|
static int
|
143 |
|
|
attach_fields_to_type PARAMS ((struct field_info *, struct type *,
|
144 |
|
|
struct objfile *));
|
145 |
|
|
|
146 |
|
|
static struct type *
|
147 |
|
|
read_struct_type PARAMS ((char **, struct type *, struct objfile *));
|
148 |
|
|
|
149 |
|
|
static struct type *
|
150 |
|
|
read_array_type PARAMS ((char **, struct type *, struct objfile *));
|
151 |
|
|
|
152 |
|
|
static struct type **
|
153 |
|
|
read_args PARAMS ((char **, int, struct objfile *));
|
154 |
|
|
|
155 |
|
|
static int
|
156 |
|
|
read_cpp_abbrev PARAMS ((struct field_info *, char **, struct type *,
|
157 |
|
|
struct objfile *));
|
158 |
|
|
|
159 |
|
|
/* new functions added for cfront support */
|
160 |
|
|
|
161 |
|
|
static int
|
162 |
|
|
copy_cfront_struct_fields PARAMS ((struct field_info *, struct type *,
|
163 |
|
|
struct objfile *));
|
164 |
|
|
|
165 |
|
|
static char *
|
166 |
|
|
get_cfront_method_physname PARAMS ((char *));
|
167 |
|
|
|
168 |
|
|
static int
|
169 |
|
|
read_cfront_baseclasses PARAMS ((struct field_info *, char **,
|
170 |
|
|
struct type *, struct objfile *));
|
171 |
|
|
|
172 |
|
|
static int
|
173 |
|
|
read_cfront_static_fields PARAMS ((struct field_info *, char **,
|
174 |
|
|
struct type *, struct objfile *));
|
175 |
|
|
static int
|
176 |
|
|
read_cfront_member_functions PARAMS ((struct field_info *, char **,
|
177 |
|
|
struct type *, struct objfile *));
|
178 |
|
|
|
179 |
|
|
/* end new functions added for cfront support */
|
180 |
|
|
|
181 |
|
|
static void
|
182 |
|
|
add_live_range PARAMS ((struct objfile *, struct symbol *,
|
183 |
|
|
CORE_ADDR, CORE_ADDR));
|
184 |
|
|
|
185 |
|
|
static int
|
186 |
|
|
resolve_live_range PARAMS ((struct objfile *, struct symbol *, char *));
|
187 |
|
|
|
188 |
|
|
static int
|
189 |
|
|
process_reference PARAMS ((char **string));
|
190 |
|
|
|
191 |
|
|
static CORE_ADDR
|
192 |
|
|
ref_search_value PARAMS ((int refnum));
|
193 |
|
|
|
194 |
|
|
static int
|
195 |
|
|
resolve_symbol_reference PARAMS ((struct objfile *, struct symbol *, char *));
|
196 |
|
|
|
197 |
|
|
void stabsread_clear_cache PARAMS ((void));
|
198 |
|
|
|
199 |
|
|
static const char vptr_name[] =
|
200 |
|
|
{'_', 'v', 'p', 't', 'r', CPLUS_MARKER, '\0'};
|
201 |
|
|
static const char vb_name[] =
|
202 |
|
|
{'_', 'v', 'b', CPLUS_MARKER, '\0'};
|
203 |
|
|
|
204 |
|
|
/* Define this as 1 if a pcc declaration of a char or short argument
|
205 |
|
|
gives the correct address. Otherwise assume pcc gives the
|
206 |
|
|
address of the corresponding int, which is not the same on a
|
207 |
|
|
big-endian machine. */
|
208 |
|
|
|
209 |
|
|
#if !defined (BELIEVE_PCC_PROMOTION)
|
210 |
|
|
#define BELIEVE_PCC_PROMOTION 0
|
211 |
|
|
#endif
|
212 |
|
|
#if !defined (BELIEVE_PCC_PROMOTION_TYPE)
|
213 |
|
|
#define BELIEVE_PCC_PROMOTION_TYPE 0
|
214 |
|
|
#endif
|
215 |
|
|
|
216 |
|
|
static struct complaint invalid_cpp_abbrev_complaint =
|
217 |
|
|
{"invalid C++ abbreviation `%s'", 0, 0};
|
218 |
|
|
|
219 |
|
|
static struct complaint invalid_cpp_type_complaint =
|
220 |
|
|
{"C++ abbreviated type name unknown at symtab pos %d", 0, 0};
|
221 |
|
|
|
222 |
|
|
static struct complaint member_fn_complaint =
|
223 |
|
|
{"member function type missing, got '%c'", 0, 0};
|
224 |
|
|
|
225 |
|
|
static struct complaint const_vol_complaint =
|
226 |
|
|
{"const/volatile indicator missing, got '%c'", 0, 0};
|
227 |
|
|
|
228 |
|
|
static struct complaint error_type_complaint =
|
229 |
|
|
{"debug info mismatch between compiler and debugger", 0, 0};
|
230 |
|
|
|
231 |
|
|
static struct complaint invalid_member_complaint =
|
232 |
|
|
{"invalid (minimal) member type data format at symtab pos %d.", 0, 0};
|
233 |
|
|
|
234 |
|
|
static struct complaint range_type_base_complaint =
|
235 |
|
|
{"base type %d of range type is not defined", 0, 0};
|
236 |
|
|
|
237 |
|
|
static struct complaint reg_value_complaint =
|
238 |
|
|
{"register number %d too large (max %d) in symbol %s", 0, 0};
|
239 |
|
|
|
240 |
|
|
static struct complaint vtbl_notfound_complaint =
|
241 |
|
|
{"virtual function table pointer not found when defining class `%s'", 0, 0};
|
242 |
|
|
|
243 |
|
|
static struct complaint unrecognized_cplus_name_complaint =
|
244 |
|
|
{"Unknown C++ symbol name `%s'", 0, 0};
|
245 |
|
|
|
246 |
|
|
static struct complaint rs6000_builtin_complaint =
|
247 |
|
|
{"Unknown builtin type %d", 0, 0};
|
248 |
|
|
|
249 |
|
|
static struct complaint unresolved_sym_chain_complaint =
|
250 |
|
|
{"%s: common block `%s' from global_sym_chain unresolved", 0, 0};
|
251 |
|
|
|
252 |
|
|
static struct complaint stabs_general_complaint =
|
253 |
|
|
{"%s", 0, 0};
|
254 |
|
|
|
255 |
|
|
static struct complaint lrs_general_complaint =
|
256 |
|
|
{"%s", 0, 0};
|
257 |
|
|
|
258 |
|
|
/* Make a list of forward references which haven't been defined. */
|
259 |
|
|
|
260 |
|
|
static struct type **undef_types;
|
261 |
|
|
static int undef_types_allocated;
|
262 |
|
|
static int undef_types_length;
|
263 |
|
|
static struct symbol *current_symbol = NULL;
|
264 |
|
|
|
265 |
|
|
/* Check for and handle cretinous stabs symbol name continuation! */
|
266 |
|
|
#define STABS_CONTINUE(pp,objfile) \
|
267 |
|
|
do { \
|
268 |
|
|
if (**(pp) == '\\' || (**(pp) == '?' && (*(pp))[1] == '\0')) \
|
269 |
|
|
*(pp) = next_symbol_text (objfile); \
|
270 |
|
|
} while (0)
|
271 |
|
|
|
272 |
|
|
/* FIXME: These probably should be our own types (like rs6000_builtin_type
|
273 |
|
|
has its own types) rather than builtin_type_*. */
|
274 |
|
|
static struct type **os9k_type_vector[] =
|
275 |
|
|
{
|
276 |
|
|
0,
|
277 |
|
|
&builtin_type_int,
|
278 |
|
|
&builtin_type_char,
|
279 |
|
|
&builtin_type_long,
|
280 |
|
|
&builtin_type_short,
|
281 |
|
|
&builtin_type_unsigned_char,
|
282 |
|
|
&builtin_type_unsigned_short,
|
283 |
|
|
&builtin_type_unsigned_long,
|
284 |
|
|
&builtin_type_unsigned_int,
|
285 |
|
|
&builtin_type_float,
|
286 |
|
|
&builtin_type_double,
|
287 |
|
|
&builtin_type_void,
|
288 |
|
|
&builtin_type_long_double
|
289 |
|
|
};
|
290 |
|
|
|
291 |
|
|
static void os9k_init_type_vector PARAMS ((struct type **));
|
292 |
|
|
|
293 |
|
|
static void
|
294 |
|
|
os9k_init_type_vector (tv)
|
295 |
|
|
struct type **tv;
|
296 |
|
|
{
|
297 |
|
|
unsigned int i;
|
298 |
|
|
for (i = 0; i < sizeof (os9k_type_vector) / sizeof (struct type **); i++)
|
299 |
|
|
tv[i] = (os9k_type_vector[i] == 0 ? 0 : *(os9k_type_vector[i]));
|
300 |
|
|
}
|
301 |
|
|
|
302 |
|
|
/* Look up a dbx type-number pair. Return the address of the slot
|
303 |
|
|
where the type for that number-pair is stored.
|
304 |
|
|
The number-pair is in TYPENUMS.
|
305 |
|
|
|
306 |
|
|
This can be used for finding the type associated with that pair
|
307 |
|
|
or for associating a new type with the pair. */
|
308 |
|
|
|
309 |
|
|
struct type **
|
310 |
|
|
dbx_lookup_type (typenums)
|
311 |
|
|
int typenums[2];
|
312 |
|
|
{
|
313 |
|
|
register int filenum = typenums[0];
|
314 |
|
|
register int index = typenums[1];
|
315 |
|
|
unsigned old_len;
|
316 |
|
|
register int real_filenum;
|
317 |
|
|
register struct header_file *f;
|
318 |
|
|
int f_orig_length;
|
319 |
|
|
|
320 |
|
|
if (filenum == -1) /* -1,-1 is for temporary types. */
|
321 |
|
|
return 0;
|
322 |
|
|
|
323 |
|
|
if (filenum < 0 || filenum >= n_this_object_header_files)
|
324 |
|
|
{
|
325 |
|
|
static struct complaint msg =
|
326 |
|
|
{"\
|
327 |
|
|
Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.",
|
328 |
|
|
0, 0};
|
329 |
|
|
complain (&msg, filenum, index, symnum);
|
330 |
|
|
goto error_return;
|
331 |
|
|
}
|
332 |
|
|
|
333 |
|
|
if (filenum == 0)
|
334 |
|
|
{
|
335 |
|
|
if (index < 0)
|
336 |
|
|
{
|
337 |
|
|
/* Caller wants address of address of type. We think
|
338 |
|
|
that negative (rs6k builtin) types will never appear as
|
339 |
|
|
"lvalues", (nor should they), so we stuff the real type
|
340 |
|
|
pointer into a temp, and return its address. If referenced,
|
341 |
|
|
this will do the right thing. */
|
342 |
|
|
static struct type *temp_type;
|
343 |
|
|
|
344 |
|
|
temp_type = rs6000_builtin_type (index);
|
345 |
|
|
return &temp_type;
|
346 |
|
|
}
|
347 |
|
|
|
348 |
|
|
/* Type is defined outside of header files.
|
349 |
|
|
Find it in this object file's type vector. */
|
350 |
|
|
if (index >= type_vector_length)
|
351 |
|
|
{
|
352 |
|
|
old_len = type_vector_length;
|
353 |
|
|
if (old_len == 0)
|
354 |
|
|
{
|
355 |
|
|
type_vector_length = INITIAL_TYPE_VECTOR_LENGTH;
|
356 |
|
|
type_vector = (struct type **)
|
357 |
|
|
xmalloc (type_vector_length * sizeof (struct type *));
|
358 |
|
|
}
|
359 |
|
|
while (index >= type_vector_length)
|
360 |
|
|
{
|
361 |
|
|
type_vector_length *= 2;
|
362 |
|
|
}
|
363 |
|
|
type_vector = (struct type **)
|
364 |
|
|
xrealloc ((char *) type_vector,
|
365 |
|
|
(type_vector_length * sizeof (struct type *)));
|
366 |
|
|
memset (&type_vector[old_len], 0,
|
367 |
|
|
(type_vector_length - old_len) * sizeof (struct type *));
|
368 |
|
|
|
369 |
|
|
if (os9k_stabs)
|
370 |
|
|
/* Deal with OS9000 fundamental types. */
|
371 |
|
|
os9k_init_type_vector (type_vector);
|
372 |
|
|
}
|
373 |
|
|
return (&type_vector[index]);
|
374 |
|
|
}
|
375 |
|
|
else
|
376 |
|
|
{
|
377 |
|
|
real_filenum = this_object_header_files[filenum];
|
378 |
|
|
|
379 |
|
|
if (real_filenum >= N_HEADER_FILES (current_objfile))
|
380 |
|
|
{
|
381 |
|
|
struct type *temp_type;
|
382 |
|
|
struct type **temp_type_p;
|
383 |
|
|
|
384 |
|
|
warning ("GDB internal error: bad real_filenum");
|
385 |
|
|
|
386 |
|
|
error_return:
|
387 |
|
|
temp_type = init_type (TYPE_CODE_ERROR, 0, 0, NULL, NULL);
|
388 |
|
|
temp_type_p = (struct type **) xmalloc (sizeof (struct type *));
|
389 |
|
|
*temp_type_p = temp_type;
|
390 |
|
|
return temp_type_p;
|
391 |
|
|
}
|
392 |
|
|
|
393 |
|
|
f = HEADER_FILES (current_objfile) + real_filenum;
|
394 |
|
|
|
395 |
|
|
f_orig_length = f->length;
|
396 |
|
|
if (index >= f_orig_length)
|
397 |
|
|
{
|
398 |
|
|
while (index >= f->length)
|
399 |
|
|
{
|
400 |
|
|
f->length *= 2;
|
401 |
|
|
}
|
402 |
|
|
f->vector = (struct type **)
|
403 |
|
|
xrealloc ((char *) f->vector, f->length * sizeof (struct type *));
|
404 |
|
|
memset (&f->vector[f_orig_length], 0,
|
405 |
|
|
(f->length - f_orig_length) * sizeof (struct type *));
|
406 |
|
|
}
|
407 |
|
|
return (&f->vector[index]);
|
408 |
|
|
}
|
409 |
|
|
}
|
410 |
|
|
|
411 |
|
|
/* Make sure there is a type allocated for type numbers TYPENUMS
|
412 |
|
|
and return the type object.
|
413 |
|
|
This can create an empty (zeroed) type object.
|
414 |
|
|
TYPENUMS may be (-1, -1) to return a new type object that is not
|
415 |
|
|
put into the type vector, and so may not be referred to by number. */
|
416 |
|
|
|
417 |
|
|
static struct type *
|
418 |
|
|
dbx_alloc_type (typenums, objfile)
|
419 |
|
|
int typenums[2];
|
420 |
|
|
struct objfile *objfile;
|
421 |
|
|
{
|
422 |
|
|
register struct type **type_addr;
|
423 |
|
|
|
424 |
|
|
if (typenums[0] == -1)
|
425 |
|
|
{
|
426 |
|
|
return (alloc_type (objfile));
|
427 |
|
|
}
|
428 |
|
|
|
429 |
|
|
type_addr = dbx_lookup_type (typenums);
|
430 |
|
|
|
431 |
|
|
/* If we are referring to a type not known at all yet,
|
432 |
|
|
allocate an empty type for it.
|
433 |
|
|
We will fill it in later if we find out how. */
|
434 |
|
|
if (*type_addr == 0)
|
435 |
|
|
{
|
436 |
|
|
*type_addr = alloc_type (objfile);
|
437 |
|
|
}
|
438 |
|
|
|
439 |
|
|
return (*type_addr);
|
440 |
|
|
}
|
441 |
|
|
|
442 |
|
|
/* for all the stabs in a given stab vector, build appropriate types
|
443 |
|
|
and fix their symbols in given symbol vector. */
|
444 |
|
|
|
445 |
|
|
static void
|
446 |
|
|
patch_block_stabs (symbols, stabs, objfile)
|
447 |
|
|
struct pending *symbols;
|
448 |
|
|
struct pending_stabs *stabs;
|
449 |
|
|
struct objfile *objfile;
|
450 |
|
|
{
|
451 |
|
|
int ii;
|
452 |
|
|
char *name;
|
453 |
|
|
char *pp;
|
454 |
|
|
struct symbol *sym;
|
455 |
|
|
|
456 |
|
|
if (stabs)
|
457 |
|
|
{
|
458 |
|
|
|
459 |
|
|
/* for all the stab entries, find their corresponding symbols and
|
460 |
|
|
patch their types! */
|
461 |
|
|
|
462 |
|
|
for (ii = 0; ii < stabs->count; ++ii)
|
463 |
|
|
{
|
464 |
|
|
name = stabs->stab[ii];
|
465 |
|
|
pp = (char *) strchr (name, ':');
|
466 |
|
|
while (pp[1] == ':')
|
467 |
|
|
{
|
468 |
|
|
pp += 2;
|
469 |
|
|
pp = (char *) strchr (pp, ':');
|
470 |
|
|
}
|
471 |
|
|
sym = find_symbol_in_list (symbols, name, pp - name);
|
472 |
|
|
if (!sym)
|
473 |
|
|
{
|
474 |
|
|
/* FIXME-maybe: it would be nice if we noticed whether
|
475 |
|
|
the variable was defined *anywhere*, not just whether
|
476 |
|
|
it is defined in this compilation unit. But neither
|
477 |
|
|
xlc or GCC seem to need such a definition, and until
|
478 |
|
|
we do psymtabs (so that the minimal symbols from all
|
479 |
|
|
compilation units are available now), I'm not sure
|
480 |
|
|
how to get the information. */
|
481 |
|
|
|
482 |
|
|
/* On xcoff, if a global is defined and never referenced,
|
483 |
|
|
ld will remove it from the executable. There is then
|
484 |
|
|
a N_GSYM stab for it, but no regular (C_EXT) symbol. */
|
485 |
|
|
sym = (struct symbol *)
|
486 |
|
|
obstack_alloc (&objfile->symbol_obstack,
|
487 |
|
|
sizeof (struct symbol));
|
488 |
|
|
|
489 |
|
|
memset (sym, 0, sizeof (struct symbol));
|
490 |
|
|
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
|
491 |
|
|
SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT;
|
492 |
|
|
SYMBOL_NAME (sym) =
|
493 |
|
|
obsavestring (name, pp - name, &objfile->symbol_obstack);
|
494 |
|
|
pp += 2;
|
495 |
|
|
if (*(pp - 1) == 'F' || *(pp - 1) == 'f')
|
496 |
|
|
{
|
497 |
|
|
/* I don't think the linker does this with functions,
|
498 |
|
|
so as far as I know this is never executed.
|
499 |
|
|
But it doesn't hurt to check. */
|
500 |
|
|
SYMBOL_TYPE (sym) =
|
501 |
|
|
lookup_function_type (read_type (&pp, objfile));
|
502 |
|
|
}
|
503 |
|
|
else
|
504 |
|
|
{
|
505 |
|
|
SYMBOL_TYPE (sym) = read_type (&pp, objfile);
|
506 |
|
|
}
|
507 |
|
|
add_symbol_to_list (sym, &global_symbols);
|
508 |
|
|
}
|
509 |
|
|
else
|
510 |
|
|
{
|
511 |
|
|
pp += 2;
|
512 |
|
|
if (*(pp - 1) == 'F' || *(pp - 1) == 'f')
|
513 |
|
|
{
|
514 |
|
|
SYMBOL_TYPE (sym) =
|
515 |
|
|
lookup_function_type (read_type (&pp, objfile));
|
516 |
|
|
}
|
517 |
|
|
else
|
518 |
|
|
{
|
519 |
|
|
SYMBOL_TYPE (sym) = read_type (&pp, objfile);
|
520 |
|
|
}
|
521 |
|
|
}
|
522 |
|
|
}
|
523 |
|
|
}
|
524 |
|
|
}
|
525 |
|
|
|
526 |
|
|
|
527 |
|
|
/* Read a number by which a type is referred to in dbx data,
|
528 |
|
|
or perhaps read a pair (FILENUM, TYPENUM) in parentheses.
|
529 |
|
|
Just a single number N is equivalent to (0,N).
|
530 |
|
|
Return the two numbers by storing them in the vector TYPENUMS.
|
531 |
|
|
TYPENUMS will then be used as an argument to dbx_lookup_type.
|
532 |
|
|
|
533 |
|
|
Returns 0 for success, -1 for error. */
|
534 |
|
|
|
535 |
|
|
static int
|
536 |
|
|
read_type_number (pp, typenums)
|
537 |
|
|
register char **pp;
|
538 |
|
|
register int *typenums;
|
539 |
|
|
{
|
540 |
|
|
int nbits;
|
541 |
|
|
if (**pp == '(')
|
542 |
|
|
{
|
543 |
|
|
(*pp)++;
|
544 |
|
|
typenums[0] = read_huge_number (pp, ',', &nbits);
|
545 |
|
|
if (nbits != 0)
|
546 |
|
|
return -1;
|
547 |
|
|
typenums[1] = read_huge_number (pp, ')', &nbits);
|
548 |
|
|
if (nbits != 0)
|
549 |
|
|
return -1;
|
550 |
|
|
}
|
551 |
|
|
else
|
552 |
|
|
{
|
553 |
|
|
typenums[0] = 0;
|
554 |
|
|
typenums[1] = read_huge_number (pp, 0, &nbits);
|
555 |
|
|
if (nbits != 0)
|
556 |
|
|
return -1;
|
557 |
|
|
}
|
558 |
|
|
return 0;
|
559 |
|
|
}
|
560 |
|
|
|
561 |
|
|
|
562 |
|
|
#if !defined (REG_STRUCT_HAS_ADDR)
|
563 |
|
|
#define REG_STRUCT_HAS_ADDR(gcc_p,type) 0
|
564 |
|
|
#endif
|
565 |
|
|
|
566 |
|
|
#define VISIBILITY_PRIVATE '0' /* Stabs character for private field */
|
567 |
|
|
#define VISIBILITY_PROTECTED '1' /* Stabs character for protected fld */
|
568 |
|
|
#define VISIBILITY_PUBLIC '2' /* Stabs character for public field */
|
569 |
|
|
#define VISIBILITY_IGNORE '9' /* Optimized out or zero length */
|
570 |
|
|
|
571 |
|
|
#define CFRONT_VISIBILITY_PRIVATE '2' /* Stabs character for private field */
|
572 |
|
|
#define CFRONT_VISIBILITY_PUBLIC '1' /* Stabs character for public field */
|
573 |
|
|
|
574 |
|
|
/* This code added to support parsing of ARM/Cfront stabs strings */
|
575 |
|
|
|
576 |
|
|
/* Get substring from string up to char c, advance string pointer past
|
577 |
|
|
suibstring. */
|
578 |
|
|
|
579 |
|
|
static char *
|
580 |
|
|
get_substring (p, c)
|
581 |
|
|
char **p;
|
582 |
|
|
int c;
|
583 |
|
|
{
|
584 |
|
|
char *str;
|
585 |
|
|
str = *p;
|
586 |
|
|
*p = strchr (*p, c);
|
587 |
|
|
if (*p)
|
588 |
|
|
{
|
589 |
|
|
**p = 0;
|
590 |
|
|
(*p)++;
|
591 |
|
|
}
|
592 |
|
|
else
|
593 |
|
|
str = 0;
|
594 |
|
|
return str;
|
595 |
|
|
}
|
596 |
|
|
|
597 |
|
|
/* Physname gets strcat'd onto sname in order to recreate the mangled
|
598 |
|
|
name (see funtion gdb_mangle_name in gdbtypes.c). For cfront, make
|
599 |
|
|
the physname look like that of g++ - take out the initial mangling
|
600 |
|
|
eg: for sname="a" and fname="foo__1aFPFs_i" return "FPFs_i" */
|
601 |
|
|
|
602 |
|
|
static char *
|
603 |
|
|
get_cfront_method_physname (fname)
|
604 |
|
|
char *fname;
|
605 |
|
|
{
|
606 |
|
|
int len = 0;
|
607 |
|
|
/* FIXME would like to make this generic for g++ too, but
|
608 |
|
|
that is already handled in read_member_funcctions */
|
609 |
|
|
char *p = fname;
|
610 |
|
|
|
611 |
|
|
/* search ahead to find the start of the mangled suffix */
|
612 |
|
|
if (*p == '_' && *(p + 1) == '_') /* compiler generated; probably a ctor/dtor */
|
613 |
|
|
p += 2;
|
614 |
|
|
while (p && (unsigned) ((p + 1) - fname) < strlen (fname) && *(p + 1) != '_')
|
615 |
|
|
p = strchr (p, '_');
|
616 |
|
|
if (!(p && *p == '_' && *(p + 1) == '_'))
|
617 |
|
|
error ("Invalid mangled function name %s", fname);
|
618 |
|
|
p += 2; /* advance past '__' */
|
619 |
|
|
|
620 |
|
|
/* struct name length and name of type should come next; advance past it */
|
621 |
|
|
while (isdigit (*p))
|
622 |
|
|
{
|
623 |
|
|
len = len * 10 + (*p - '0');
|
624 |
|
|
p++;
|
625 |
|
|
}
|
626 |
|
|
p += len;
|
627 |
|
|
|
628 |
|
|
return p;
|
629 |
|
|
}
|
630 |
|
|
|
631 |
|
|
/* Read base classes within cfront class definition.
|
632 |
|
|
eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;;
|
633 |
|
|
^^^^^^^^^^^^^^^^^^
|
634 |
|
|
|
635 |
|
|
A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;;
|
636 |
|
|
^
|
637 |
|
|
*/
|
638 |
|
|
|
639 |
|
|
static int
|
640 |
|
|
read_cfront_baseclasses (fip, pp, type, objfile)
|
641 |
|
|
struct field_info *fip;
|
642 |
|
|
struct objfile *objfile;
|
643 |
|
|
char **pp;
|
644 |
|
|
struct type *type;
|
645 |
|
|
{
|
646 |
|
|
static struct complaint msg_unknown =
|
647 |
|
|
{"\
|
648 |
|
|
Unsupported token in stabs string %s.\n",
|
649 |
|
|
0, 0};
|
650 |
|
|
static struct complaint msg_notfound =
|
651 |
|
|
{"\
|
652 |
|
|
Unable to find base type for %s.\n",
|
653 |
|
|
0, 0};
|
654 |
|
|
int bnum = 0;
|
655 |
|
|
char *p;
|
656 |
|
|
int i;
|
657 |
|
|
struct nextfield *new;
|
658 |
|
|
|
659 |
|
|
if (**pp == ';') /* no base classes; return */
|
660 |
|
|
{
|
661 |
|
|
++(*pp);
|
662 |
|
|
return 1;
|
663 |
|
|
}
|
664 |
|
|
|
665 |
|
|
/* first count base classes so we can allocate space before parsing */
|
666 |
|
|
for (p = *pp; p && *p && *p != ';'; p++)
|
667 |
|
|
{
|
668 |
|
|
if (*p == ' ')
|
669 |
|
|
bnum++;
|
670 |
|
|
}
|
671 |
|
|
bnum++; /* add one more for last one */
|
672 |
|
|
|
673 |
|
|
/* now parse the base classes until we get to the start of the methods
|
674 |
|
|
(code extracted and munged from read_baseclasses) */
|
675 |
|
|
ALLOCATE_CPLUS_STRUCT_TYPE (type);
|
676 |
|
|
TYPE_N_BASECLASSES (type) = bnum;
|
677 |
|
|
|
678 |
|
|
/* allocate space */
|
679 |
|
|
{
|
680 |
|
|
int num_bytes = B_BYTES (TYPE_N_BASECLASSES (type));
|
681 |
|
|
char *pointer;
|
682 |
|
|
|
683 |
|
|
pointer = (char *) TYPE_ALLOC (type, num_bytes);
|
684 |
|
|
TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *) pointer;
|
685 |
|
|
}
|
686 |
|
|
B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), TYPE_N_BASECLASSES (type));
|
687 |
|
|
|
688 |
|
|
for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
|
689 |
|
|
{
|
690 |
|
|
new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
|
691 |
|
|
make_cleanup (free, new);
|
692 |
|
|
memset (new, 0, sizeof (struct nextfield));
|
693 |
|
|
new->next = fip->list;
|
694 |
|
|
fip->list = new;
|
695 |
|
|
FIELD_BITSIZE (new->field) = 0; /* this should be an unpacked field! */
|
696 |
|
|
|
697 |
|
|
STABS_CONTINUE (pp, objfile);
|
698 |
|
|
|
699 |
|
|
/* virtual? eg: v2@Bvir */
|
700 |
|
|
if (**pp == 'v')
|
701 |
|
|
{
|
702 |
|
|
SET_TYPE_FIELD_VIRTUAL (type, i);
|
703 |
|
|
++(*pp);
|
704 |
|
|
}
|
705 |
|
|
|
706 |
|
|
/* access? eg: 2@Bvir */
|
707 |
|
|
/* Note: protected inheritance not supported in cfront */
|
708 |
|
|
switch (*(*pp)++)
|
709 |
|
|
{
|
710 |
|
|
case CFRONT_VISIBILITY_PRIVATE:
|
711 |
|
|
new->visibility = VISIBILITY_PRIVATE;
|
712 |
|
|
break;
|
713 |
|
|
case CFRONT_VISIBILITY_PUBLIC:
|
714 |
|
|
new->visibility = VISIBILITY_PUBLIC;
|
715 |
|
|
break;
|
716 |
|
|
default:
|
717 |
|
|
/* Bad visibility format. Complain and treat it as
|
718 |
|
|
public. */
|
719 |
|
|
{
|
720 |
|
|
static struct complaint msg =
|
721 |
|
|
{
|
722 |
|
|
"Unknown visibility `%c' for baseclass", 0, 0};
|
723 |
|
|
complain (&msg, new->visibility);
|
724 |
|
|
new->visibility = VISIBILITY_PUBLIC;
|
725 |
|
|
}
|
726 |
|
|
}
|
727 |
|
|
|
728 |
|
|
/* "@" comes next - eg: @Bvir */
|
729 |
|
|
if (**pp != '@')
|
730 |
|
|
{
|
731 |
|
|
complain (&msg_unknown, *pp);
|
732 |
|
|
return 1;
|
733 |
|
|
}
|
734 |
|
|
++(*pp);
|
735 |
|
|
|
736 |
|
|
|
737 |
|
|
/* Set the bit offset of the portion of the object corresponding
|
738 |
|
|
to this baseclass. Always zero in the absence of
|
739 |
|
|
multiple inheritance. */
|
740 |
|
|
/* Unable to read bit position from stabs;
|
741 |
|
|
Assuming no multiple inheritance for now FIXME! */
|
742 |
|
|
/* We may have read this in the structure definition;
|
743 |
|
|
now we should fixup the members to be the actual base classes */
|
744 |
|
|
FIELD_BITPOS (new->field) = 0;
|
745 |
|
|
|
746 |
|
|
/* Get the base class name and type */
|
747 |
|
|
{
|
748 |
|
|
char *bname; /* base class name */
|
749 |
|
|
struct symbol *bsym; /* base class */
|
750 |
|
|
char *p1, *p2;
|
751 |
|
|
p1 = strchr (*pp, ' ');
|
752 |
|
|
p2 = strchr (*pp, ';');
|
753 |
|
|
if (p1 < p2)
|
754 |
|
|
bname = get_substring (pp, ' ');
|
755 |
|
|
else
|
756 |
|
|
bname = get_substring (pp, ';');
|
757 |
|
|
if (!bname || !*bname)
|
758 |
|
|
{
|
759 |
|
|
complain (&msg_unknown, *pp);
|
760 |
|
|
return 1;
|
761 |
|
|
}
|
762 |
|
|
/* FIXME! attach base info to type */
|
763 |
|
|
bsym = lookup_symbol (bname, 0, STRUCT_NAMESPACE, 0, 0); /*demangled_name */
|
764 |
|
|
if (bsym)
|
765 |
|
|
{
|
766 |
|
|
new->field.type = SYMBOL_TYPE (bsym);
|
767 |
|
|
new->field.name = type_name_no_tag (new->field.type);
|
768 |
|
|
}
|
769 |
|
|
else
|
770 |
|
|
{
|
771 |
|
|
complain (&msg_notfound, *pp);
|
772 |
|
|
return 1;
|
773 |
|
|
}
|
774 |
|
|
}
|
775 |
|
|
|
776 |
|
|
/* If more base classes to parse, loop again.
|
777 |
|
|
We ate the last ' ' or ';' in get_substring,
|
778 |
|
|
so on exit we will have skipped the trailing ';' */
|
779 |
|
|
/* if invalid, return 0; add code to detect - FIXME! */
|
780 |
|
|
}
|
781 |
|
|
return 1;
|
782 |
|
|
}
|
783 |
|
|
|
784 |
|
|
/* read cfront member functions.
|
785 |
|
|
pp points to string starting with list of functions
|
786 |
|
|
eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;;
|
787 |
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
788 |
|
|
A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;;
|
789 |
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
790 |
|
|
*/
|
791 |
|
|
|
792 |
|
|
static int
|
793 |
|
|
read_cfront_member_functions (fip, pp, type, objfile)
|
794 |
|
|
struct field_info *fip;
|
795 |
|
|
char **pp;
|
796 |
|
|
struct type *type;
|
797 |
|
|
struct objfile *objfile;
|
798 |
|
|
{
|
799 |
|
|
/* This code extracted from read_member_functions
|
800 |
|
|
so as to do the similar thing for our funcs */
|
801 |
|
|
|
802 |
|
|
int nfn_fields = 0;
|
803 |
|
|
int length = 0;
|
804 |
|
|
/* Total number of member functions defined in this class. If the class
|
805 |
|
|
defines two `f' functions, and one `g' function, then this will have
|
806 |
|
|
the value 3. */
|
807 |
|
|
int total_length = 0;
|
808 |
|
|
int i;
|
809 |
|
|
struct next_fnfield
|
810 |
|
|
{
|
811 |
|
|
struct next_fnfield *next;
|
812 |
|
|
struct fn_field fn_field;
|
813 |
|
|
}
|
814 |
|
|
*sublist;
|
815 |
|
|
struct type *look_ahead_type;
|
816 |
|
|
struct next_fnfieldlist *new_fnlist;
|
817 |
|
|
struct next_fnfield *new_sublist;
|
818 |
|
|
char *main_fn_name;
|
819 |
|
|
char *fname;
|
820 |
|
|
struct symbol *ref_func = 0;
|
821 |
|
|
|
822 |
|
|
/* Process each list until we find the end of the member functions.
|
823 |
|
|
eg: p = "__ct__1AFv foo__1AFv ;;;" */
|
824 |
|
|
|
825 |
|
|
STABS_CONTINUE (pp, objfile); /* handle \\ */
|
826 |
|
|
|
827 |
|
|
while (**pp != ';' && (fname = get_substring (pp, ' '), fname))
|
828 |
|
|
{
|
829 |
|
|
int is_static = 0;
|
830 |
|
|
int sublist_count = 0;
|
831 |
|
|
char *pname;
|
832 |
|
|
if (fname[0] == '*') /* static member */
|
833 |
|
|
{
|
834 |
|
|
is_static = 1;
|
835 |
|
|
sublist_count++;
|
836 |
|
|
fname++;
|
837 |
|
|
}
|
838 |
|
|
ref_func = lookup_symbol (fname, 0, VAR_NAMESPACE, 0, 0); /* demangled name */
|
839 |
|
|
if (!ref_func)
|
840 |
|
|
{
|
841 |
|
|
static struct complaint msg =
|
842 |
|
|
{"\
|
843 |
|
|
Unable to find function symbol for %s\n",
|
844 |
|
|
0, 0};
|
845 |
|
|
complain (&msg, fname);
|
846 |
|
|
continue;
|
847 |
|
|
}
|
848 |
|
|
sublist = NULL;
|
849 |
|
|
look_ahead_type = NULL;
|
850 |
|
|
length = 0;
|
851 |
|
|
|
852 |
|
|
new_fnlist = (struct next_fnfieldlist *)
|
853 |
|
|
xmalloc (sizeof (struct next_fnfieldlist));
|
854 |
|
|
make_cleanup (free, new_fnlist);
|
855 |
|
|
memset (new_fnlist, 0, sizeof (struct next_fnfieldlist));
|
856 |
|
|
|
857 |
|
|
/* The following is code to work around cfront generated stabs.
|
858 |
|
|
The stabs contains full mangled name for each field.
|
859 |
|
|
We try to demangle the name and extract the field name out of it. */
|
860 |
|
|
{
|
861 |
|
|
char *dem, *dem_p, *dem_args;
|
862 |
|
|
int dem_len;
|
863 |
|
|
dem = cplus_demangle (fname, DMGL_ANSI | DMGL_PARAMS);
|
864 |
|
|
if (dem != NULL)
|
865 |
|
|
{
|
866 |
|
|
dem_p = strrchr (dem, ':');
|
867 |
|
|
if (dem_p != 0 && *(dem_p - 1) == ':')
|
868 |
|
|
dem_p++;
|
869 |
|
|
/* get rid of args */
|
870 |
|
|
dem_args = strchr (dem_p, '(');
|
871 |
|
|
if (dem_args == NULL)
|
872 |
|
|
dem_len = strlen (dem_p);
|
873 |
|
|
else
|
874 |
|
|
dem_len = dem_args - dem_p;
|
875 |
|
|
main_fn_name =
|
876 |
|
|
obsavestring (dem_p, dem_len, &objfile->type_obstack);
|
877 |
|
|
}
|
878 |
|
|
else
|
879 |
|
|
{
|
880 |
|
|
main_fn_name =
|
881 |
|
|
obsavestring (fname, strlen (fname), &objfile->type_obstack);
|
882 |
|
|
}
|
883 |
|
|
} /* end of code for cfront work around */
|
884 |
|
|
|
885 |
|
|
new_fnlist->fn_fieldlist.name = main_fn_name;
|
886 |
|
|
|
887 |
|
|
/*-------------------------------------------------*/
|
888 |
|
|
/* Set up the sublists
|
889 |
|
|
Sublists are stuff like args, static, visibility, etc.
|
890 |
|
|
so in ARM, we have to set that info some other way.
|
891 |
|
|
Multiple sublists happen if overloading
|
892 |
|
|
eg: foo::26=##1;:;2A.;
|
893 |
|
|
In g++, we'd loop here thru all the sublists... */
|
894 |
|
|
|
895 |
|
|
new_sublist =
|
896 |
|
|
(struct next_fnfield *) xmalloc (sizeof (struct next_fnfield));
|
897 |
|
|
make_cleanup (free, new_sublist);
|
898 |
|
|
memset (new_sublist, 0, sizeof (struct next_fnfield));
|
899 |
|
|
|
900 |
|
|
/* eat 1; from :;2A.; */
|
901 |
|
|
new_sublist->fn_field.type = SYMBOL_TYPE (ref_func); /* normally takes a read_type */
|
902 |
|
|
/* Make this type look like a method stub for gdb */
|
903 |
|
|
TYPE_FLAGS (new_sublist->fn_field.type) |= TYPE_FLAG_STUB;
|
904 |
|
|
TYPE_CODE (new_sublist->fn_field.type) = TYPE_CODE_METHOD;
|
905 |
|
|
|
906 |
|
|
/* If this is just a stub, then we don't have the real name here. */
|
907 |
|
|
if (TYPE_FLAGS (new_sublist->fn_field.type) & TYPE_FLAG_STUB)
|
908 |
|
|
{
|
909 |
|
|
if (!TYPE_DOMAIN_TYPE (new_sublist->fn_field.type))
|
910 |
|
|
TYPE_DOMAIN_TYPE (new_sublist->fn_field.type) = type;
|
911 |
|
|
new_sublist->fn_field.is_stub = 1;
|
912 |
|
|
}
|
913 |
|
|
|
914 |
|
|
/* physname used later in mangling; eg PFs_i,5 for foo__1aFPFs_i
|
915 |
|
|
physname gets strcat'd in order to recreate the onto mangled name */
|
916 |
|
|
pname = get_cfront_method_physname (fname);
|
917 |
|
|
new_sublist->fn_field.physname = savestring (pname, strlen (pname));
|
918 |
|
|
|
919 |
|
|
|
920 |
|
|
/* Set this member function's visibility fields.
|
921 |
|
|
Unable to distinguish access from stabs definition!
|
922 |
|
|
Assuming public for now. FIXME!
|
923 |
|
|
(for private, set new_sublist->fn_field.is_private = 1,
|
924 |
|
|
for public, set new_sublist->fn_field.is_protected = 1) */
|
925 |
|
|
|
926 |
|
|
/* Unable to distinguish const/volatile from stabs definition!
|
927 |
|
|
Assuming normal for now. FIXME! */
|
928 |
|
|
|
929 |
|
|
new_sublist->fn_field.is_const = 0;
|
930 |
|
|
new_sublist->fn_field.is_volatile = 0; /* volatile not implemented in cfront */
|
931 |
|
|
|
932 |
|
|
/* Set virtual/static function info
|
933 |
|
|
How to get vtable offsets ?
|
934 |
|
|
Assuming normal for now FIXME!!
|
935 |
|
|
For vtables, figure out from whence this virtual function came.
|
936 |
|
|
It may belong to virtual function table of
|
937 |
|
|
one of its baseclasses.
|
938 |
|
|
set:
|
939 |
|
|
new_sublist -> fn_field.voffset = vtable offset,
|
940 |
|
|
new_sublist -> fn_field.fcontext = look_ahead_type;
|
941 |
|
|
where look_ahead_type is type of baseclass */
|
942 |
|
|
if (is_static)
|
943 |
|
|
new_sublist->fn_field.voffset = VOFFSET_STATIC;
|
944 |
|
|
else /* normal member function. */
|
945 |
|
|
new_sublist->fn_field.voffset = 0;
|
946 |
|
|
new_sublist->fn_field.fcontext = 0;
|
947 |
|
|
|
948 |
|
|
|
949 |
|
|
/* Prepare new sublist */
|
950 |
|
|
new_sublist->next = sublist;
|
951 |
|
|
sublist = new_sublist;
|
952 |
|
|
length++;
|
953 |
|
|
|
954 |
|
|
/* In g++, we loop thu sublists - now we set from functions. */
|
955 |
|
|
new_fnlist->fn_fieldlist.fn_fields = (struct fn_field *)
|
956 |
|
|
obstack_alloc (&objfile->type_obstack,
|
957 |
|
|
sizeof (struct fn_field) * length);
|
958 |
|
|
memset (new_fnlist->fn_fieldlist.fn_fields, 0,
|
959 |
|
|
sizeof (struct fn_field) * length);
|
960 |
|
|
for (i = length; (i--, sublist); sublist = sublist->next)
|
961 |
|
|
{
|
962 |
|
|
new_fnlist->fn_fieldlist.fn_fields[i] = sublist->fn_field;
|
963 |
|
|
}
|
964 |
|
|
|
965 |
|
|
new_fnlist->fn_fieldlist.length = length;
|
966 |
|
|
new_fnlist->next = fip->fnlist;
|
967 |
|
|
fip->fnlist = new_fnlist;
|
968 |
|
|
nfn_fields++;
|
969 |
|
|
total_length += length;
|
970 |
|
|
STABS_CONTINUE (pp, objfile); /* handle \\ */
|
971 |
|
|
} /* end of loop */
|
972 |
|
|
|
973 |
|
|
if (nfn_fields)
|
974 |
|
|
{
|
975 |
|
|
/* type should already have space */
|
976 |
|
|
TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *)
|
977 |
|
|
TYPE_ALLOC (type, sizeof (struct fn_fieldlist) * nfn_fields);
|
978 |
|
|
memset (TYPE_FN_FIELDLISTS (type), 0,
|
979 |
|
|
sizeof (struct fn_fieldlist) * nfn_fields);
|
980 |
|
|
TYPE_NFN_FIELDS (type) = nfn_fields;
|
981 |
|
|
TYPE_NFN_FIELDS_TOTAL (type) = total_length;
|
982 |
|
|
}
|
983 |
|
|
|
984 |
|
|
/* end of scope for reading member func */
|
985 |
|
|
|
986 |
|
|
/* eg: ";;" */
|
987 |
|
|
|
988 |
|
|
/* Skip trailing ';' and bump count of number of fields seen */
|
989 |
|
|
if (**pp == ';')
|
990 |
|
|
(*pp)++;
|
991 |
|
|
else
|
992 |
|
|
return 0;
|
993 |
|
|
return 1;
|
994 |
|
|
}
|
995 |
|
|
|
996 |
|
|
/* This routine fixes up partial cfront types that were created
|
997 |
|
|
while parsing the stabs. The main need for this function is
|
998 |
|
|
to add information such as methods to classes.
|
999 |
|
|
Examples of "p": "sA;;__ct__1AFv foo__1AFv ;;;" */
|
1000 |
|
|
int
|
1001 |
|
|
resolve_cfront_continuation (objfile, sym, p)
|
1002 |
|
|
struct objfile *objfile;
|
1003 |
|
|
struct symbol *sym;
|
1004 |
|
|
char *p;
|
1005 |
|
|
{
|
1006 |
|
|
struct symbol *ref_sym = 0;
|
1007 |
|
|
char *sname;
|
1008 |
|
|
/* snarfed from read_struct_type */
|
1009 |
|
|
struct field_info fi;
|
1010 |
|
|
struct type *type;
|
1011 |
|
|
struct cleanup *back_to;
|
1012 |
|
|
|
1013 |
|
|
/* Need to make sure that fi isn't gunna conflict with struct
|
1014 |
|
|
in case struct already had some fnfs */
|
1015 |
|
|
fi.list = NULL;
|
1016 |
|
|
fi.fnlist = NULL;
|
1017 |
|
|
back_to = make_cleanup (null_cleanup, 0);
|
1018 |
|
|
|
1019 |
|
|
/* We only accept structs, classes and unions at the moment.
|
1020 |
|
|
Other continuation types include t (typedef), r (long dbl), ...
|
1021 |
|
|
We may want to add support for them as well;
|
1022 |
|
|
right now they are handled by duplicating the symbol information
|
1023 |
|
|
into the type information (see define_symbol) */
|
1024 |
|
|
if (*p != 's' /* structs */
|
1025 |
|
|
&& *p != 'c' /* class */
|
1026 |
|
|
&& *p != 'u') /* union */
|
1027 |
|
|
return 0; /* only handle C++ types */
|
1028 |
|
|
p++;
|
1029 |
|
|
|
1030 |
|
|
/* Get symbol typs name and validate
|
1031 |
|
|
eg: p = "A;;__ct__1AFv foo__1AFv ;;;" */
|
1032 |
|
|
sname = get_substring (&p, ';');
|
1033 |
|
|
if (!sname || strcmp (sname, SYMBOL_NAME (sym)))
|
1034 |
|
|
error ("Internal error: base symbol type name does not match\n");
|
1035 |
|
|
|
1036 |
|
|
/* Find symbol's internal gdb reference using demangled_name.
|
1037 |
|
|
This is the real sym that we want;
|
1038 |
|
|
sym was a temp hack to make debugger happy */
|
1039 |
|
|
ref_sym = lookup_symbol (SYMBOL_NAME (sym), 0, STRUCT_NAMESPACE, 0, 0);
|
1040 |
|
|
type = SYMBOL_TYPE (ref_sym);
|
1041 |
|
|
|
1042 |
|
|
|
1043 |
|
|
/* Now read the baseclasses, if any, read the regular C struct or C++
|
1044 |
|
|
class member fields, attach the fields to the type, read the C++
|
1045 |
|
|
member functions, attach them to the type, and then read any tilde
|
1046 |
|
|
field (baseclass specifier for the class holding the main vtable). */
|
1047 |
|
|
|
1048 |
|
|
if (!read_cfront_baseclasses (&fi, &p, type, objfile)
|
1049 |
|
|
/* g++ does this next, but cfront already did this:
|
1050 |
|
|
|| !read_struct_fields (&fi, &p, type, objfile) */
|
1051 |
|
|
|| !copy_cfront_struct_fields (&fi, type, objfile)
|
1052 |
|
|
|| !read_cfront_member_functions (&fi, &p, type, objfile)
|
1053 |
|
|
|| !read_cfront_static_fields (&fi, &p, type, objfile)
|
1054 |
|
|
|| !attach_fields_to_type (&fi, type, objfile)
|
1055 |
|
|
|| !attach_fn_fields_to_type (&fi, type)
|
1056 |
|
|
/* g++ does this next, but cfront doesn't seem to have this:
|
1057 |
|
|
|| !read_tilde_fields (&fi, &p, type, objfile) */
|
1058 |
|
|
)
|
1059 |
|
|
{
|
1060 |
|
|
type = error_type (&p, objfile);
|
1061 |
|
|
}
|
1062 |
|
|
|
1063 |
|
|
do_cleanups (back_to);
|
1064 |
|
|
return 0;
|
1065 |
|
|
}
|
1066 |
|
|
/* End of code added to support parsing of ARM/Cfront stabs strings */
|
1067 |
|
|
|
1068 |
|
|
|
1069 |
|
|
/* This routine fixes up symbol references/aliases to point to the original
|
1070 |
|
|
symbol definition. Returns 0 on failure, non-zero on success. */
|
1071 |
|
|
|
1072 |
|
|
static int
|
1073 |
|
|
resolve_symbol_reference (objfile, sym, p)
|
1074 |
|
|
struct objfile *objfile;
|
1075 |
|
|
struct symbol *sym;
|
1076 |
|
|
char *p;
|
1077 |
|
|
{
|
1078 |
|
|
int refnum;
|
1079 |
|
|
struct symbol *ref_sym = 0;
|
1080 |
|
|
struct alias_list *alias;
|
1081 |
|
|
|
1082 |
|
|
/* If this is not a symbol reference return now. */
|
1083 |
|
|
if (*p != '#')
|
1084 |
|
|
return 0;
|
1085 |
|
|
|
1086 |
|
|
/* Use "#<num>" as the name; we'll fix the name later.
|
1087 |
|
|
We stored the original symbol name as "#<id>=<name>"
|
1088 |
|
|
so we can now search for "#<id>" to resolving the reference.
|
1089 |
|
|
We'll fix the names later by removing the "#<id>" or "#<id>=" */
|
1090 |
|
|
|
1091 |
|
|
/*---------------------------------------------------------*/
|
1092 |
|
|
/* Get the reference id number, and
|
1093 |
|
|
advance p past the names so we can parse the rest.
|
1094 |
|
|
eg: id=2 for p : "2=", "2=z:r(0,1)" "2:r(0,1);l(#5,#6),l(#7,#4)" */
|
1095 |
|
|
/*---------------------------------------------------------*/
|
1096 |
|
|
|
1097 |
|
|
/* This gets reference name from string. sym may not have a name. */
|
1098 |
|
|
|
1099 |
|
|
/* Get the reference number associated with the reference id in the
|
1100 |
|
|
gdb stab string. From that reference number, get the main/primary
|
1101 |
|
|
symbol for this alias. */
|
1102 |
|
|
refnum = process_reference (&p);
|
1103 |
|
|
ref_sym = ref_search (refnum);
|
1104 |
|
|
if (!ref_sym)
|
1105 |
|
|
{
|
1106 |
|
|
complain (&lrs_general_complaint, "symbol for reference not found");
|
1107 |
|
|
return 0;
|
1108 |
|
|
}
|
1109 |
|
|
|
1110 |
|
|
/* Parse the stab of the referencing symbol
|
1111 |
|
|
now that we have the referenced symbol.
|
1112 |
|
|
Add it as a new symbol and a link back to the referenced symbol.
|
1113 |
|
|
eg: p : "=", "=z:r(0,1)" ":r(0,1);l(#5,#6),l(#7,#4)" */
|
1114 |
|
|
|
1115 |
|
|
|
1116 |
|
|
/* If the stab symbol table and string contain:
|
1117 |
|
|
RSYM 0 5 00000000 868 #15=z:r(0,1)
|
1118 |
|
|
LBRAC 0 0 00000000 899 #5=
|
1119 |
|
|
SLINE 0 16 00000003 923 #6=
|
1120 |
|
|
Then the same symbols can be later referenced by:
|
1121 |
|
|
RSYM 0 5 00000000 927 #15:r(0,1);l(#5,#6)
|
1122 |
|
|
This is used in live range splitting to:
|
1123 |
|
|
1) specify that a symbol (#15) is actually just a new storage
|
1124 |
|
|
class for a symbol (#15=z) which was previously defined.
|
1125 |
|
|
2) specify that the beginning and ending ranges for a symbol
|
1126 |
|
|
(#15) are the values of the beginning (#5) and ending (#6)
|
1127 |
|
|
symbols. */
|
1128 |
|
|
|
1129 |
|
|
/* Read number as reference id.
|
1130 |
|
|
eg: p : "=", "=z:r(0,1)" ":r(0,1);l(#5,#6),l(#7,#4)" */
|
1131 |
|
|
/* FIXME! Might I want to use SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT;
|
1132 |
|
|
in case of "l(0,0)"? */
|
1133 |
|
|
|
1134 |
|
|
/*--------------------------------------------------*/
|
1135 |
|
|
/* Add this symbol to the reference list. */
|
1136 |
|
|
/*--------------------------------------------------*/
|
1137 |
|
|
|
1138 |
|
|
alias = (struct alias_list *) obstack_alloc (&objfile->type_obstack,
|
1139 |
|
|
sizeof (struct alias_list));
|
1140 |
|
|
if (!alias)
|
1141 |
|
|
{
|
1142 |
|
|
complain (&lrs_general_complaint, "Unable to allocate alias list memory");
|
1143 |
|
|
return 0;
|
1144 |
|
|
}
|
1145 |
|
|
|
1146 |
|
|
alias->next = 0;
|
1147 |
|
|
alias->sym = sym;
|
1148 |
|
|
|
1149 |
|
|
if (!SYMBOL_ALIASES (ref_sym))
|
1150 |
|
|
{
|
1151 |
|
|
SYMBOL_ALIASES (ref_sym) = alias;
|
1152 |
|
|
}
|
1153 |
|
|
else
|
1154 |
|
|
{
|
1155 |
|
|
struct alias_list *temp;
|
1156 |
|
|
|
1157 |
|
|
/* Get to the end of the list. */
|
1158 |
|
|
for (temp = SYMBOL_ALIASES (ref_sym);
|
1159 |
|
|
temp->next;
|
1160 |
|
|
temp = temp->next)
|
1161 |
|
|
;
|
1162 |
|
|
temp->next = alias;
|
1163 |
|
|
}
|
1164 |
|
|
|
1165 |
|
|
/* Want to fix up name so that other functions (eg. valops)
|
1166 |
|
|
will correctly print the name.
|
1167 |
|
|
Don't add_symbol_to_list so that lookup_symbol won't find it.
|
1168 |
|
|
nope... needed for fixups. */
|
1169 |
|
|
SYMBOL_NAME (sym) = SYMBOL_NAME (ref_sym);
|
1170 |
|
|
|
1171 |
|
|
/* Done! */
|
1172 |
|
|
return 1;
|
1173 |
|
|
}
|
1174 |
|
|
|
1175 |
|
|
/* Structure for storing pointers to reference definitions for fast lookup
|
1176 |
|
|
during "process_later". */
|
1177 |
|
|
|
1178 |
|
|
struct ref_map
|
1179 |
|
|
{
|
1180 |
|
|
char *stabs;
|
1181 |
|
|
CORE_ADDR value;
|
1182 |
|
|
struct symbol *sym;
|
1183 |
|
|
};
|
1184 |
|
|
|
1185 |
|
|
#define MAX_CHUNK_REFS 100
|
1186 |
|
|
#define REF_CHUNK_SIZE (MAX_CHUNK_REFS * sizeof (struct ref_map))
|
1187 |
|
|
#define REF_MAP_SIZE(ref_chunk) ((ref_chunk) * REF_CHUNK_SIZE)
|
1188 |
|
|
|
1189 |
|
|
static struct ref_map *ref_map;
|
1190 |
|
|
|
1191 |
|
|
/* Ptr to free cell in chunk's linked list. */
|
1192 |
|
|
static int ref_count = 0;
|
1193 |
|
|
|
1194 |
|
|
/* Number of chunks malloced. */
|
1195 |
|
|
static int ref_chunk = 0;
|
1196 |
|
|
|
1197 |
|
|
/* This file maintains a cache of stabs aliases found in the symbol
|
1198 |
|
|
table. If the symbol table changes, this cache must be cleared
|
1199 |
|
|
or we are left holding onto data in invalid obstacks. */
|
1200 |
|
|
void
|
1201 |
|
|
stabsread_clear_cache ()
|
1202 |
|
|
{
|
1203 |
|
|
ref_count = 0;
|
1204 |
|
|
ref_chunk = 0;
|
1205 |
|
|
}
|
1206 |
|
|
|
1207 |
|
|
/* Create array of pointers mapping refids to symbols and stab strings.
|
1208 |
|
|
Add pointers to reference definition symbols and/or their values as we
|
1209 |
|
|
find them, using their reference numbers as our index.
|
1210 |
|
|
These will be used later when we resolve references. */
|
1211 |
|
|
void
|
1212 |
|
|
ref_add (refnum, sym, stabs, value)
|
1213 |
|
|
int refnum;
|
1214 |
|
|
struct symbol *sym;
|
1215 |
|
|
char *stabs;
|
1216 |
|
|
CORE_ADDR value;
|
1217 |
|
|
{
|
1218 |
|
|
if (ref_count == 0)
|
1219 |
|
|
ref_chunk = 0;
|
1220 |
|
|
if (refnum >= ref_count)
|
1221 |
|
|
ref_count = refnum + 1;
|
1222 |
|
|
if (ref_count > ref_chunk * MAX_CHUNK_REFS)
|
1223 |
|
|
{
|
1224 |
|
|
int new_slots = ref_count - ref_chunk * MAX_CHUNK_REFS;
|
1225 |
|
|
int new_chunks = new_slots / MAX_CHUNK_REFS + 1;
|
1226 |
|
|
ref_map = (struct ref_map *)
|
1227 |
|
|
xrealloc (ref_map, REF_MAP_SIZE (ref_chunk + new_chunks));
|
1228 |
|
|
memset (ref_map + ref_chunk * MAX_CHUNK_REFS, 0, new_chunks * REF_CHUNK_SIZE);
|
1229 |
|
|
ref_chunk += new_chunks;
|
1230 |
|
|
}
|
1231 |
|
|
ref_map[refnum].stabs = stabs;
|
1232 |
|
|
ref_map[refnum].sym = sym;
|
1233 |
|
|
ref_map[refnum].value = value;
|
1234 |
|
|
}
|
1235 |
|
|
|
1236 |
|
|
/* Return defined sym for the reference REFNUM. */
|
1237 |
|
|
struct symbol *
|
1238 |
|
|
ref_search (refnum)
|
1239 |
|
|
int refnum;
|
1240 |
|
|
{
|
1241 |
|
|
if (refnum < 0 || refnum > ref_count)
|
1242 |
|
|
return 0;
|
1243 |
|
|
return ref_map[refnum].sym;
|
1244 |
|
|
}
|
1245 |
|
|
|
1246 |
|
|
/* Return value for the reference REFNUM. */
|
1247 |
|
|
|
1248 |
|
|
static CORE_ADDR
|
1249 |
|
|
ref_search_value (refnum)
|
1250 |
|
|
int refnum;
|
1251 |
|
|
{
|
1252 |
|
|
if (refnum < 0 || refnum > ref_count)
|
1253 |
|
|
return 0;
|
1254 |
|
|
return ref_map[refnum].value;
|
1255 |
|
|
}
|
1256 |
|
|
|
1257 |
|
|
/* Parse a reference id in STRING and return the resulting
|
1258 |
|
|
reference number. Move STRING beyond the reference id. */
|
1259 |
|
|
|
1260 |
|
|
static int
|
1261 |
|
|
process_reference (string)
|
1262 |
|
|
char **string;
|
1263 |
|
|
{
|
1264 |
|
|
char *p;
|
1265 |
|
|
int refnum = 0;
|
1266 |
|
|
|
1267 |
|
|
if (**string != '#')
|
1268 |
|
|
return 0;
|
1269 |
|
|
|
1270 |
|
|
/* Advance beyond the initial '#'. */
|
1271 |
|
|
p = *string + 1;
|
1272 |
|
|
|
1273 |
|
|
/* Read number as reference id. */
|
1274 |
|
|
while (*p && isdigit (*p))
|
1275 |
|
|
{
|
1276 |
|
|
refnum = refnum * 10 + *p - '0';
|
1277 |
|
|
p++;
|
1278 |
|
|
}
|
1279 |
|
|
*string = p;
|
1280 |
|
|
return refnum;
|
1281 |
|
|
}
|
1282 |
|
|
|
1283 |
|
|
/* If STRING defines a reference, store away a pointer to the reference
|
1284 |
|
|
definition for later use. Return the reference number. */
|
1285 |
|
|
|
1286 |
|
|
int
|
1287 |
|
|
symbol_reference_defined (string)
|
1288 |
|
|
char **string;
|
1289 |
|
|
{
|
1290 |
|
|
char *p = *string;
|
1291 |
|
|
int refnum = 0;
|
1292 |
|
|
|
1293 |
|
|
refnum = process_reference (&p);
|
1294 |
|
|
|
1295 |
|
|
/* Defining symbols end in '=' */
|
1296 |
|
|
if (*p == '=')
|
1297 |
|
|
{
|
1298 |
|
|
/* Symbol is being defined here. */
|
1299 |
|
|
*string = p + 1;
|
1300 |
|
|
return refnum;
|
1301 |
|
|
}
|
1302 |
|
|
else
|
1303 |
|
|
{
|
1304 |
|
|
/* Must be a reference. Either the symbol has already been defined,
|
1305 |
|
|
or this is a forward reference to it. */
|
1306 |
|
|
*string = p;
|
1307 |
|
|
return -1;
|
1308 |
|
|
}
|
1309 |
|
|
}
|
1310 |
|
|
|
1311 |
|
|
/* ARGSUSED */
|
1312 |
|
|
struct symbol *
|
1313 |
|
|
define_symbol (valu, string, desc, type, objfile)
|
1314 |
|
|
CORE_ADDR valu;
|
1315 |
|
|
char *string;
|
1316 |
|
|
int desc;
|
1317 |
|
|
int type;
|
1318 |
|
|
struct objfile *objfile;
|
1319 |
|
|
{
|
1320 |
|
|
register struct symbol *sym;
|
1321 |
|
|
char *p = (char *) strchr (string, ':');
|
1322 |
|
|
int deftype;
|
1323 |
|
|
int synonym = 0;
|
1324 |
|
|
register int i;
|
1325 |
|
|
|
1326 |
|
|
/* We would like to eliminate nameless symbols, but keep their types.
|
1327 |
|
|
E.g. stab entry ":t10=*2" should produce a type 10, which is a pointer
|
1328 |
|
|
to type 2, but, should not create a symbol to address that type. Since
|
1329 |
|
|
the symbol will be nameless, there is no way any user can refer to it. */
|
1330 |
|
|
|
1331 |
|
|
int nameless;
|
1332 |
|
|
|
1333 |
|
|
/* Ignore syms with empty names. */
|
1334 |
|
|
if (string[0] == 0)
|
1335 |
|
|
return 0;
|
1336 |
|
|
|
1337 |
|
|
/* Ignore old-style symbols from cc -go */
|
1338 |
|
|
if (p == 0)
|
1339 |
|
|
return 0;
|
1340 |
|
|
|
1341 |
|
|
while (p[1] == ':')
|
1342 |
|
|
{
|
1343 |
|
|
p += 2;
|
1344 |
|
|
p = strchr (p, ':');
|
1345 |
|
|
}
|
1346 |
|
|
|
1347 |
|
|
/* If a nameless stab entry, all we need is the type, not the symbol.
|
1348 |
|
|
e.g. ":t10=*2" or a nameless enum like " :T16=ered:0,green:1,blue:2,;" */
|
1349 |
|
|
nameless = (p == string || ((string[0] == ' ') && (string[1] == ':')));
|
1350 |
|
|
|
1351 |
|
|
current_symbol = sym = (struct symbol *)
|
1352 |
|
|
obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
|
1353 |
|
|
memset (sym, 0, sizeof (struct symbol));
|
1354 |
|
|
|
1355 |
|
|
switch (type & N_TYPE)
|
1356 |
|
|
{
|
1357 |
|
|
case N_TEXT:
|
1358 |
|
|
SYMBOL_SECTION (sym) = SECT_OFF_TEXT;
|
1359 |
|
|
break;
|
1360 |
|
|
case N_DATA:
|
1361 |
|
|
SYMBOL_SECTION (sym) = SECT_OFF_DATA;
|
1362 |
|
|
break;
|
1363 |
|
|
case N_BSS:
|
1364 |
|
|
SYMBOL_SECTION (sym) = SECT_OFF_BSS;
|
1365 |
|
|
break;
|
1366 |
|
|
}
|
1367 |
|
|
|
1368 |
|
|
if (processing_gcc_compilation)
|
1369 |
|
|
{
|
1370 |
|
|
/* GCC 2.x puts the line number in desc. SunOS apparently puts in the
|
1371 |
|
|
number of bytes occupied by a type or object, which we ignore. */
|
1372 |
|
|
SYMBOL_LINE (sym) = desc;
|
1373 |
|
|
}
|
1374 |
|
|
else
|
1375 |
|
|
{
|
1376 |
|
|
SYMBOL_LINE (sym) = 0; /* unknown */
|
1377 |
|
|
}
|
1378 |
|
|
|
1379 |
|
|
if (is_cplus_marker (string[0]))
|
1380 |
|
|
{
|
1381 |
|
|
/* Special GNU C++ names. */
|
1382 |
|
|
switch (string[1])
|
1383 |
|
|
{
|
1384 |
|
|
case 't':
|
1385 |
|
|
SYMBOL_NAME (sym) = obsavestring ("this", strlen ("this"),
|
1386 |
|
|
&objfile->symbol_obstack);
|
1387 |
|
|
break;
|
1388 |
|
|
|
1389 |
|
|
case 'v': /* $vtbl_ptr_type */
|
1390 |
|
|
/* Was: SYMBOL_NAME (sym) = "vptr"; */
|
1391 |
|
|
goto normal;
|
1392 |
|
|
|
1393 |
|
|
case 'e':
|
1394 |
|
|
SYMBOL_NAME (sym) = obsavestring ("eh_throw", strlen ("eh_throw"),
|
1395 |
|
|
&objfile->symbol_obstack);
|
1396 |
|
|
break;
|
1397 |
|
|
|
1398 |
|
|
case '_':
|
1399 |
|
|
/* This was an anonymous type that was never fixed up. */
|
1400 |
|
|
goto normal;
|
1401 |
|
|
|
1402 |
|
|
#ifdef STATIC_TRANSFORM_NAME
|
1403 |
|
|
case 'X':
|
1404 |
|
|
/* SunPRO (3.0 at least) static variable encoding. */
|
1405 |
|
|
goto normal;
|
1406 |
|
|
#endif
|
1407 |
|
|
|
1408 |
|
|
default:
|
1409 |
|
|
complain (&unrecognized_cplus_name_complaint, string);
|
1410 |
|
|
goto normal; /* Do *something* with it */
|
1411 |
|
|
}
|
1412 |
|
|
}
|
1413 |
|
|
else if (string[0] == '#')
|
1414 |
|
|
{
|
1415 |
|
|
/* Special GNU C extension for referencing symbols. */
|
1416 |
|
|
char *s;
|
1417 |
|
|
int refnum, nlen;
|
1418 |
|
|
|
1419 |
|
|
/* If STRING defines a new reference id, then add it to the
|
1420 |
|
|
reference map. Else it must be referring to a previously
|
1421 |
|
|
defined symbol, so add it to the alias list of the previously
|
1422 |
|
|
defined symbol. */
|
1423 |
|
|
s = string;
|
1424 |
|
|
refnum = symbol_reference_defined (&s);
|
1425 |
|
|
if (refnum >= 0)
|
1426 |
|
|
ref_add (refnum, sym, string, SYMBOL_VALUE (sym));
|
1427 |
|
|
else if (!resolve_symbol_reference (objfile, sym, string))
|
1428 |
|
|
return NULL;
|
1429 |
|
|
|
1430 |
|
|
/* S..P contains the name of the symbol. We need to store
|
1431 |
|
|
the correct name into SYMBOL_NAME. */
|
1432 |
|
|
nlen = p - s;
|
1433 |
|
|
if (refnum >= 0)
|
1434 |
|
|
{
|
1435 |
|
|
if (nlen > 0)
|
1436 |
|
|
{
|
1437 |
|
|
SYMBOL_NAME (sym) = (char *)
|
1438 |
|
|
obstack_alloc (&objfile->symbol_obstack, nlen);
|
1439 |
|
|
strncpy (SYMBOL_NAME (sym), s, nlen);
|
1440 |
|
|
SYMBOL_NAME (sym)[nlen] = '\0';
|
1441 |
|
|
SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack);
|
1442 |
|
|
}
|
1443 |
|
|
else
|
1444 |
|
|
/* FIXME! Want SYMBOL_NAME (sym) = 0;
|
1445 |
|
|
Get error if leave name 0. So give it something. */
|
1446 |
|
|
{
|
1447 |
|
|
nlen = p - string;
|
1448 |
|
|
SYMBOL_NAME (sym) = (char *)
|
1449 |
|
|
obstack_alloc (&objfile->symbol_obstack, nlen);
|
1450 |
|
|
strncpy (SYMBOL_NAME (sym), string, nlen);
|
1451 |
|
|
SYMBOL_NAME (sym)[nlen] = '\0';
|
1452 |
|
|
SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack);
|
1453 |
|
|
}
|
1454 |
|
|
}
|
1455 |
|
|
/* Advance STRING beyond the reference id. */
|
1456 |
|
|
string = s;
|
1457 |
|
|
}
|
1458 |
|
|
else
|
1459 |
|
|
{
|
1460 |
|
|
normal:
|
1461 |
|
|
SYMBOL_LANGUAGE (sym) = current_subfile->language;
|
1462 |
|
|
SYMBOL_NAME (sym) = (char *)
|
1463 |
|
|
obstack_alloc (&objfile->symbol_obstack, ((p - string) + 1));
|
1464 |
|
|
/* Open-coded memcpy--saves function call time. */
|
1465 |
|
|
/* FIXME: Does it really? Try replacing with simple strcpy and
|
1466 |
|
|
try it on an executable with a large symbol table. */
|
1467 |
|
|
/* FIXME: considering that gcc can open code memcpy anyway, I
|
1468 |
|
|
doubt it. xoxorich. */
|
1469 |
|
|
{
|
1470 |
|
|
register char *p1 = string;
|
1471 |
|
|
register char *p2 = SYMBOL_NAME (sym);
|
1472 |
|
|
while (p1 != p)
|
1473 |
|
|
{
|
1474 |
|
|
*p2++ = *p1++;
|
1475 |
|
|
}
|
1476 |
|
|
*p2++ = '\0';
|
1477 |
|
|
}
|
1478 |
|
|
|
1479 |
|
|
/* If this symbol is from a C++ compilation, then attempt to cache the
|
1480 |
|
|
demangled form for future reference. This is a typical time versus
|
1481 |
|
|
space tradeoff, that was decided in favor of time because it sped up
|
1482 |
|
|
C++ symbol lookups by a factor of about 20. */
|
1483 |
|
|
|
1484 |
|
|
SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack);
|
1485 |
|
|
}
|
1486 |
|
|
p++;
|
1487 |
|
|
|
1488 |
|
|
/* Determine the type of name being defined. */
|
1489 |
|
|
#if 0
|
1490 |
|
|
/* Getting GDB to correctly skip the symbol on an undefined symbol
|
1491 |
|
|
descriptor and not ever dump core is a very dodgy proposition if
|
1492 |
|
|
we do things this way. I say the acorn RISC machine can just
|
1493 |
|
|
fix their compiler. */
|
1494 |
|
|
/* The Acorn RISC machine's compiler can put out locals that don't
|
1495 |
|
|
start with "234=" or "(3,4)=", so assume anything other than the
|
1496 |
|
|
deftypes we know how to handle is a local. */
|
1497 |
|
|
if (!strchr ("cfFGpPrStTvVXCR", *p))
|
1498 |
|
|
#else
|
1499 |
|
|
if (isdigit (*p) || *p == '(' || *p == '-')
|
1500 |
|
|
#endif
|
1501 |
|
|
deftype = 'l';
|
1502 |
|
|
else
|
1503 |
|
|
deftype = *p++;
|
1504 |
|
|
|
1505 |
|
|
switch (deftype)
|
1506 |
|
|
{
|
1507 |
|
|
case 'c':
|
1508 |
|
|
/* c is a special case, not followed by a type-number.
|
1509 |
|
|
SYMBOL:c=iVALUE for an integer constant symbol.
|
1510 |
|
|
SYMBOL:c=rVALUE for a floating constant symbol.
|
1511 |
|
|
SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol.
|
1512 |
|
|
e.g. "b:c=e6,0" for "const b = blob1"
|
1513 |
|
|
(where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
|
1514 |
|
|
if (*p != '=')
|
1515 |
|
|
{
|
1516 |
|
|
SYMBOL_CLASS (sym) = LOC_CONST;
|
1517 |
|
|
SYMBOL_TYPE (sym) = error_type (&p, objfile);
|
1518 |
|
|
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
|
1519 |
|
|
add_symbol_to_list (sym, &file_symbols);
|
1520 |
|
|
return sym;
|
1521 |
|
|
}
|
1522 |
|
|
++p;
|
1523 |
|
|
switch (*p++)
|
1524 |
|
|
{
|
1525 |
|
|
case 'r':
|
1526 |
|
|
{
|
1527 |
|
|
double d = atof (p);
|
1528 |
|
|
char *dbl_valu;
|
1529 |
|
|
|
1530 |
|
|
/* FIXME-if-picky-about-floating-accuracy: Should be using
|
1531 |
|
|
target arithmetic to get the value. real.c in GCC
|
1532 |
|
|
probably has the necessary code. */
|
1533 |
|
|
|
1534 |
|
|
/* FIXME: lookup_fundamental_type is a hack. We should be
|
1535 |
|
|
creating a type especially for the type of float constants.
|
1536 |
|
|
Problem is, what type should it be?
|
1537 |
|
|
|
1538 |
|
|
Also, what should the name of this type be? Should we
|
1539 |
|
|
be using 'S' constants (see stabs.texinfo) instead? */
|
1540 |
|
|
|
1541 |
|
|
SYMBOL_TYPE (sym) = lookup_fundamental_type (objfile,
|
1542 |
|
|
FT_DBL_PREC_FLOAT);
|
1543 |
|
|
dbl_valu = (char *)
|
1544 |
|
|
obstack_alloc (&objfile->symbol_obstack,
|
1545 |
|
|
TYPE_LENGTH (SYMBOL_TYPE (sym)));
|
1546 |
|
|
store_floating (dbl_valu, TYPE_LENGTH (SYMBOL_TYPE (sym)), d);
|
1547 |
|
|
SYMBOL_VALUE_BYTES (sym) = dbl_valu;
|
1548 |
|
|
SYMBOL_CLASS (sym) = LOC_CONST_BYTES;
|
1549 |
|
|
}
|
1550 |
|
|
break;
|
1551 |
|
|
case 'i':
|
1552 |
|
|
{
|
1553 |
|
|
/* Defining integer constants this way is kind of silly,
|
1554 |
|
|
since 'e' constants allows the compiler to give not
|
1555 |
|
|
only the value, but the type as well. C has at least
|
1556 |
|
|
int, long, unsigned int, and long long as constant
|
1557 |
|
|
types; other languages probably should have at least
|
1558 |
|
|
unsigned as well as signed constants. */
|
1559 |
|
|
|
1560 |
|
|
/* We just need one int constant type for all objfiles.
|
1561 |
|
|
It doesn't depend on languages or anything (arguably its
|
1562 |
|
|
name should be a language-specific name for a type of
|
1563 |
|
|
that size, but I'm inclined to say that if the compiler
|
1564 |
|
|
wants a nice name for the type, it can use 'e'). */
|
1565 |
|
|
static struct type *int_const_type;
|
1566 |
|
|
|
1567 |
|
|
/* Yes, this is as long as a *host* int. That is because we
|
1568 |
|
|
use atoi. */
|
1569 |
|
|
if (int_const_type == NULL)
|
1570 |
|
|
int_const_type =
|
1571 |
|
|
init_type (TYPE_CODE_INT,
|
1572 |
|
|
sizeof (int) * HOST_CHAR_BIT / TARGET_CHAR_BIT, 0,
|
1573 |
|
|
"integer constant",
|
1574 |
|
|
(struct objfile *) NULL);
|
1575 |
|
|
SYMBOL_TYPE (sym) = int_const_type;
|
1576 |
|
|
SYMBOL_VALUE (sym) = atoi (p);
|
1577 |
|
|
SYMBOL_CLASS (sym) = LOC_CONST;
|
1578 |
|
|
}
|
1579 |
|
|
break;
|
1580 |
|
|
case 'e':
|
1581 |
|
|
/* SYMBOL:c=eTYPE,INTVALUE for a constant symbol whose value
|
1582 |
|
|
can be represented as integral.
|
1583 |
|
|
e.g. "b:c=e6,0" for "const b = blob1"
|
1584 |
|
|
(where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
|
1585 |
|
|
{
|
1586 |
|
|
SYMBOL_CLASS (sym) = LOC_CONST;
|
1587 |
|
|
SYMBOL_TYPE (sym) = read_type (&p, objfile);
|
1588 |
|
|
|
1589 |
|
|
if (*p != ',')
|
1590 |
|
|
{
|
1591 |
|
|
SYMBOL_TYPE (sym) = error_type (&p, objfile);
|
1592 |
|
|
break;
|
1593 |
|
|
}
|
1594 |
|
|
++p;
|
1595 |
|
|
|
1596 |
|
|
/* If the value is too big to fit in an int (perhaps because
|
1597 |
|
|
it is unsigned), or something like that, we silently get
|
1598 |
|
|
a bogus value. The type and everything else about it is
|
1599 |
|
|
correct. Ideally, we should be using whatever we have
|
1600 |
|
|
available for parsing unsigned and long long values,
|
1601 |
|
|
however. */
|
1602 |
|
|
SYMBOL_VALUE (sym) = atoi (p);
|
1603 |
|
|
}
|
1604 |
|
|
break;
|
1605 |
|
|
default:
|
1606 |
|
|
{
|
1607 |
|
|
SYMBOL_CLASS (sym) = LOC_CONST;
|
1608 |
|
|
SYMBOL_TYPE (sym) = error_type (&p, objfile);
|
1609 |
|
|
}
|
1610 |
|
|
}
|
1611 |
|
|
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
|
1612 |
|
|
add_symbol_to_list (sym, &file_symbols);
|
1613 |
|
|
return sym;
|
1614 |
|
|
|
1615 |
|
|
case 'C':
|
1616 |
|
|
/* The name of a caught exception. */
|
1617 |
|
|
SYMBOL_TYPE (sym) = read_type (&p, objfile);
|
1618 |
|
|
SYMBOL_CLASS (sym) = LOC_LABEL;
|
1619 |
|
|
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
|
1620 |
|
|
SYMBOL_VALUE_ADDRESS (sym) = valu;
|
1621 |
|
|
add_symbol_to_list (sym, &local_symbols);
|
1622 |
|
|
break;
|
1623 |
|
|
|
1624 |
|
|
case 'f':
|
1625 |
|
|
/* A static function definition. */
|
1626 |
|
|
SYMBOL_TYPE (sym) = read_type (&p, objfile);
|
1627 |
|
|
SYMBOL_CLASS (sym) = LOC_BLOCK;
|
1628 |
|
|
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
|
1629 |
|
|
add_symbol_to_list (sym, &file_symbols);
|
1630 |
|
|
/* fall into process_function_types. */
|
1631 |
|
|
|
1632 |
|
|
process_function_types:
|
1633 |
|
|
/* Function result types are described as the result type in stabs.
|
1634 |
|
|
We need to convert this to the function-returning-type-X type
|
1635 |
|
|
in GDB. E.g. "int" is converted to "function returning int". */
|
1636 |
|
|
if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_FUNC)
|
1637 |
|
|
SYMBOL_TYPE (sym) = lookup_function_type (SYMBOL_TYPE (sym));
|
1638 |
|
|
|
1639 |
|
|
/* All functions in C++ have prototypes. */
|
1640 |
|
|
if (SYMBOL_LANGUAGE (sym) == language_cplus)
|
1641 |
|
|
TYPE_FLAGS (SYMBOL_TYPE (sym)) |= TYPE_FLAG_PROTOTYPED;
|
1642 |
|
|
|
1643 |
|
|
/* fall into process_prototype_types */
|
1644 |
|
|
|
1645 |
|
|
process_prototype_types:
|
1646 |
|
|
/* Sun acc puts declared types of arguments here. */
|
1647 |
|
|
if (*p == ';')
|
1648 |
|
|
{
|
1649 |
|
|
struct type *ftype = SYMBOL_TYPE (sym);
|
1650 |
|
|
int nsemi = 0;
|
1651 |
|
|
int nparams = 0;
|
1652 |
|
|
char *p1 = p;
|
1653 |
|
|
|
1654 |
|
|
/* Obtain a worst case guess for the number of arguments
|
1655 |
|
|
by counting the semicolons. */
|
1656 |
|
|
while (*p1)
|
1657 |
|
|
{
|
1658 |
|
|
if (*p1++ == ';')
|
1659 |
|
|
nsemi++;
|
1660 |
|
|
}
|
1661 |
|
|
|
1662 |
|
|
/* Allocate parameter information fields and fill them in. */
|
1663 |
|
|
TYPE_FIELDS (ftype) = (struct field *)
|
1664 |
|
|
TYPE_ALLOC (ftype, nsemi * sizeof (struct field));
|
1665 |
|
|
while (*p++ == ';')
|
1666 |
|
|
{
|
1667 |
|
|
struct type *ptype;
|
1668 |
|
|
|
1669 |
|
|
/* A type number of zero indicates the start of varargs.
|
1670 |
|
|
FIXME: GDB currently ignores vararg functions. */
|
1671 |
|
|
if (p[0] == '0' && p[1] == '\0')
|
1672 |
|
|
break;
|
1673 |
|
|
ptype = read_type (&p, objfile);
|
1674 |
|
|
|
1675 |
|
|
/* The Sun compilers mark integer arguments, which should
|
1676 |
|
|
be promoted to the width of the calling conventions, with
|
1677 |
|
|
a type which references itself. This type is turned into
|
1678 |
|
|
a TYPE_CODE_VOID type by read_type, and we have to turn
|
1679 |
|
|
it back into builtin_type_int here.
|
1680 |
|
|
FIXME: Do we need a new builtin_type_promoted_int_arg ? */
|
1681 |
|
|
if (TYPE_CODE (ptype) == TYPE_CODE_VOID)
|
1682 |
|
|
ptype = builtin_type_int;
|
1683 |
|
|
TYPE_FIELD_TYPE (ftype, nparams++) = ptype;
|
1684 |
|
|
}
|
1685 |
|
|
TYPE_NFIELDS (ftype) = nparams;
|
1686 |
|
|
TYPE_FLAGS (ftype) |= TYPE_FLAG_PROTOTYPED;
|
1687 |
|
|
}
|
1688 |
|
|
break;
|
1689 |
|
|
|
1690 |
|
|
case 'F':
|
1691 |
|
|
/* A global function definition. */
|
1692 |
|
|
SYMBOL_TYPE (sym) = read_type (&p, objfile);
|
1693 |
|
|
SYMBOL_CLASS (sym) = LOC_BLOCK;
|
1694 |
|
|
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
|
1695 |
|
|
add_symbol_to_list (sym, &global_symbols);
|
1696 |
|
|
goto process_function_types;
|
1697 |
|
|
|
1698 |
|
|
case 'G':
|
1699 |
|
|
/* For a class G (global) symbol, it appears that the
|
1700 |
|
|
value is not correct. It is necessary to search for the
|
1701 |
|
|
corresponding linker definition to find the value.
|
1702 |
|
|
These definitions appear at the end of the namelist. */
|
1703 |
|
|
SYMBOL_TYPE (sym) = read_type (&p, objfile);
|
1704 |
|
|
SYMBOL_CLASS (sym) = LOC_STATIC;
|
1705 |
|
|
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
|
1706 |
|
|
/* Don't add symbol references to global_sym_chain.
|
1707 |
|
|
Symbol references don't have valid names and wont't match up with
|
1708 |
|
|
minimal symbols when the global_sym_chain is relocated.
|
1709 |
|
|
We'll fixup symbol references when we fixup the defining symbol. */
|
1710 |
|
|
if (SYMBOL_NAME (sym) && SYMBOL_NAME (sym)[0] != '#')
|
1711 |
|
|
{
|
1712 |
|
|
i = hashname (SYMBOL_NAME (sym));
|
1713 |
|
|
SYMBOL_VALUE_CHAIN (sym) = global_sym_chain[i];
|
1714 |
|
|
global_sym_chain[i] = sym;
|
1715 |
|
|
}
|
1716 |
|
|
add_symbol_to_list (sym, &global_symbols);
|
1717 |
|
|
break;
|
1718 |
|
|
|
1719 |
|
|
/* This case is faked by a conditional above,
|
1720 |
|
|
when there is no code letter in the dbx data.
|
1721 |
|
|
Dbx data never actually contains 'l'. */
|
1722 |
|
|
case 's':
|
1723 |
|
|
case 'l':
|
1724 |
|
|
SYMBOL_TYPE (sym) = read_type (&p, objfile);
|
1725 |
|
|
SYMBOL_CLASS (sym) = LOC_LOCAL;
|
1726 |
|
|
SYMBOL_VALUE (sym) = valu;
|
1727 |
|
|
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
|
1728 |
|
|
add_symbol_to_list (sym, &local_symbols);
|
1729 |
|
|
break;
|
1730 |
|
|
|
1731 |
|
|
case 'p':
|
1732 |
|
|
if (*p == 'F')
|
1733 |
|
|
/* pF is a two-letter code that means a function parameter in Fortran.
|
1734 |
|
|
The type-number specifies the type of the return value.
|
1735 |
|
|
Translate it into a pointer-to-function type. */
|
1736 |
|
|
{
|
1737 |
|
|
p++;
|
1738 |
|
|
SYMBOL_TYPE (sym)
|
1739 |
|
|
= lookup_pointer_type
|
1740 |
|
|
(lookup_function_type (read_type (&p, objfile)));
|
1741 |
|
|
}
|
1742 |
|
|
else
|
1743 |
|
|
SYMBOL_TYPE (sym) = read_type (&p, objfile);
|
1744 |
|
|
|
1745 |
|
|
/* Normally this is a parameter, a LOC_ARG. On the i960, it
|
1746 |
|
|
can also be a LOC_LOCAL_ARG depending on symbol type. */
|
1747 |
|
|
#ifndef DBX_PARM_SYMBOL_CLASS
|
1748 |
|
|
#define DBX_PARM_SYMBOL_CLASS(type) LOC_ARG
|
1749 |
|
|
#endif
|
1750 |
|
|
|
1751 |
|
|
SYMBOL_CLASS (sym) = DBX_PARM_SYMBOL_CLASS (type);
|
1752 |
|
|
SYMBOL_VALUE (sym) = valu;
|
1753 |
|
|
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
|
1754 |
|
|
add_symbol_to_list (sym, &local_symbols);
|
1755 |
|
|
|
1756 |
|
|
if (TARGET_BYTE_ORDER != BIG_ENDIAN)
|
1757 |
|
|
{
|
1758 |
|
|
/* On little-endian machines, this crud is never necessary,
|
1759 |
|
|
and, if the extra bytes contain garbage, is harmful. */
|
1760 |
|
|
break;
|
1761 |
|
|
}
|
1762 |
|
|
|
1763 |
|
|
/* If it's gcc-compiled, if it says `short', believe it. */
|
1764 |
|
|
if (processing_gcc_compilation || BELIEVE_PCC_PROMOTION)
|
1765 |
|
|
break;
|
1766 |
|
|
|
1767 |
|
|
if (!BELIEVE_PCC_PROMOTION)
|
1768 |
|
|
{
|
1769 |
|
|
/* This is the signed type which arguments get promoted to. */
|
1770 |
|
|
static struct type *pcc_promotion_type;
|
1771 |
|
|
/* This is the unsigned type which arguments get promoted to. */
|
1772 |
|
|
static struct type *pcc_unsigned_promotion_type;
|
1773 |
|
|
|
1774 |
|
|
/* Call it "int" because this is mainly C lossage. */
|
1775 |
|
|
if (pcc_promotion_type == NULL)
|
1776 |
|
|
pcc_promotion_type =
|
1777 |
|
|
init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
|
1778 |
|
|
0, "int", NULL);
|
1779 |
|
|
|
1780 |
|
|
if (pcc_unsigned_promotion_type == NULL)
|
1781 |
|
|
pcc_unsigned_promotion_type =
|
1782 |
|
|
init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
|
1783 |
|
|
TYPE_FLAG_UNSIGNED, "unsigned int", NULL);
|
1784 |
|
|
|
1785 |
|
|
if (BELIEVE_PCC_PROMOTION_TYPE)
|
1786 |
|
|
{
|
1787 |
|
|
/* This is defined on machines (e.g. sparc) where we
|
1788 |
|
|
should believe the type of a PCC 'short' argument,
|
1789 |
|
|
but shouldn't believe the address (the address is the
|
1790 |
|
|
address of the corresponding int).
|
1791 |
|
|
|
1792 |
|
|
My guess is that this correction, as opposed to
|
1793 |
|
|
changing the parameter to an 'int' (as done below,
|
1794 |
|
|
for PCC on most machines), is the right thing to do
|
1795 |
|
|
on all machines, but I don't want to risk breaking
|
1796 |
|
|
something that already works. On most PCC machines,
|
1797 |
|
|
the sparc problem doesn't come up because the calling
|
1798 |
|
|
function has to zero the top bytes (not knowing
|
1799 |
|
|
whether the called function wants an int or a short),
|
1800 |
|
|
so there is little practical difference between an
|
1801 |
|
|
int and a short (except perhaps what happens when the
|
1802 |
|
|
GDB user types "print short_arg = 0x10000;").
|
1803 |
|
|
|
1804 |
|
|
Hacked for SunOS 4.1 by gnu@cygnus.com. In 4.1, the
|
1805 |
|
|
compiler actually produces the correct address (we
|
1806 |
|
|
don't need to fix it up). I made this code adapt so
|
1807 |
|
|
that it will offset the symbol if it was pointing at
|
1808 |
|
|
an int-aligned location and not otherwise. This way
|
1809 |
|
|
you can use the same gdb for 4.0.x and 4.1 systems.
|
1810 |
|
|
|
1811 |
|
|
If the parameter is shorter than an int, and is
|
1812 |
|
|
integral (e.g. char, short, or unsigned equivalent),
|
1813 |
|
|
and is claimed to be passed on an integer boundary,
|
1814 |
|
|
don't believe it! Offset the parameter's address to
|
1815 |
|
|
the tail-end of that integer. */
|
1816 |
|
|
|
1817 |
|
|
if (TYPE_LENGTH (SYMBOL_TYPE (sym)) < TYPE_LENGTH (pcc_promotion_type)
|
1818 |
|
|
&& TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_INT
|
1819 |
|
|
&& 0 == SYMBOL_VALUE (sym) % TYPE_LENGTH (pcc_promotion_type))
|
1820 |
|
|
{
|
1821 |
|
|
SYMBOL_VALUE (sym) += TYPE_LENGTH (pcc_promotion_type)
|
1822 |
|
|
- TYPE_LENGTH (SYMBOL_TYPE (sym));
|
1823 |
|
|
}
|
1824 |
|
|
break;
|
1825 |
|
|
}
|
1826 |
|
|
else
|
1827 |
|
|
{
|
1828 |
|
|
/* If PCC says a parameter is a short or a char,
|
1829 |
|
|
it is really an int. */
|
1830 |
|
|
if (TYPE_LENGTH (SYMBOL_TYPE (sym)) < TYPE_LENGTH (pcc_promotion_type)
|
1831 |
|
|
&& TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_INT)
|
1832 |
|
|
{
|
1833 |
|
|
SYMBOL_TYPE (sym) =
|
1834 |
|
|
TYPE_UNSIGNED (SYMBOL_TYPE (sym))
|
1835 |
|
|
? pcc_unsigned_promotion_type
|
1836 |
|
|
: pcc_promotion_type;
|
1837 |
|
|
}
|
1838 |
|
|
break;
|
1839 |
|
|
}
|
1840 |
|
|
}
|
1841 |
|
|
|
1842 |
|
|
case 'P':
|
1843 |
|
|
/* acc seems to use P to declare the prototypes of functions that
|
1844 |
|
|
are referenced by this file. gdb is not prepared to deal
|
1845 |
|
|
with this extra information. FIXME, it ought to. */
|
1846 |
|
|
if (type == N_FUN)
|
1847 |
|
|
{
|
1848 |
|
|
SYMBOL_TYPE (sym) = read_type (&p, objfile);
|
1849 |
|
|
goto process_prototype_types;
|
1850 |
|
|
}
|
1851 |
|
|
/*FALLTHROUGH */
|
1852 |
|
|
|
1853 |
|
|
case 'R':
|
1854 |
|
|
/* Parameter which is in a register. */
|
1855 |
|
|
SYMBOL_TYPE (sym) = read_type (&p, objfile);
|
1856 |
|
|
SYMBOL_CLASS (sym) = LOC_REGPARM;
|
1857 |
|
|
SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
|
1858 |
|
|
if (SYMBOL_VALUE (sym) >= NUM_REGS)
|
1859 |
|
|
{
|
1860 |
|
|
complain (®_value_complaint, SYMBOL_VALUE (sym), NUM_REGS,
|
1861 |
|
|
SYMBOL_SOURCE_NAME (sym));
|
1862 |
|
|
SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */
|
1863 |
|
|
}
|
1864 |
|
|
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
|
1865 |
|
|
add_symbol_to_list (sym, &local_symbols);
|
1866 |
|
|
break;
|
1867 |
|
|
|
1868 |
|
|
case 'r':
|
1869 |
|
|
/* Register variable (either global or local). */
|
1870 |
|
|
SYMBOL_TYPE (sym) = read_type (&p, objfile);
|
1871 |
|
|
SYMBOL_CLASS (sym) = LOC_REGISTER;
|
1872 |
|
|
SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
|
1873 |
|
|
if (SYMBOL_VALUE (sym) >= NUM_REGS)
|
1874 |
|
|
{
|
1875 |
|
|
complain (®_value_complaint, SYMBOL_VALUE (sym), NUM_REGS,
|
1876 |
|
|
SYMBOL_SOURCE_NAME (sym));
|
1877 |
|
|
SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */
|
1878 |
|
|
}
|
1879 |
|
|
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
|
1880 |
|
|
if (within_function)
|
1881 |
|
|
{
|
1882 |
|
|
/* Sun cc uses a pair of symbols, one 'p' and one 'r' with the same
|
1883 |
|
|
name to represent an argument passed in a register.
|
1884 |
|
|
GCC uses 'P' for the same case. So if we find such a symbol pair
|
1885 |
|
|
we combine it into one 'P' symbol. For Sun cc we need to do this
|
1886 |
|
|
regardless of REG_STRUCT_HAS_ADDR, because the compiler puts out
|
1887 |
|
|
the 'p' symbol even if it never saves the argument onto the stack.
|
1888 |
|
|
|
1889 |
|
|
On most machines, we want to preserve both symbols, so that
|
1890 |
|
|
we can still get information about what is going on with the
|
1891 |
|
|
stack (VAX for computing args_printed, using stack slots instead
|
1892 |
|
|
of saved registers in backtraces, etc.).
|
1893 |
|
|
|
1894 |
|
|
Note that this code illegally combines
|
1895 |
|
|
main(argc) struct foo argc; { register struct foo argc; }
|
1896 |
|
|
but this case is considered pathological and causes a warning
|
1897 |
|
|
from a decent compiler. */
|
1898 |
|
|
|
1899 |
|
|
if (local_symbols
|
1900 |
|
|
&& local_symbols->nsyms > 0
|
1901 |
|
|
#ifndef USE_REGISTER_NOT_ARG
|
1902 |
|
|
&& REG_STRUCT_HAS_ADDR (processing_gcc_compilation,
|
1903 |
|
|
SYMBOL_TYPE (sym))
|
1904 |
|
|
&& (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
|
1905 |
|
|
|| TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION
|
1906 |
|
|
|| TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_SET
|
1907 |
|
|
|| TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_BITSTRING)
|
1908 |
|
|
#endif
|
1909 |
|
|
)
|
1910 |
|
|
{
|
1911 |
|
|
struct symbol *prev_sym;
|
1912 |
|
|
prev_sym = local_symbols->symbol[local_symbols->nsyms - 1];
|
1913 |
|
|
if ((SYMBOL_CLASS (prev_sym) == LOC_REF_ARG
|
1914 |
|
|
|| SYMBOL_CLASS (prev_sym) == LOC_ARG)
|
1915 |
|
|
&& STREQ (SYMBOL_NAME (prev_sym), SYMBOL_NAME (sym)))
|
1916 |
|
|
{
|
1917 |
|
|
SYMBOL_CLASS (prev_sym) = LOC_REGPARM;
|
1918 |
|
|
/* Use the type from the LOC_REGISTER; that is the type
|
1919 |
|
|
that is actually in that register. */
|
1920 |
|
|
SYMBOL_TYPE (prev_sym) = SYMBOL_TYPE (sym);
|
1921 |
|
|
SYMBOL_VALUE (prev_sym) = SYMBOL_VALUE (sym);
|
1922 |
|
|
sym = prev_sym;
|
1923 |
|
|
break;
|
1924 |
|
|
}
|
1925 |
|
|
}
|
1926 |
|
|
add_symbol_to_list (sym, &local_symbols);
|
1927 |
|
|
}
|
1928 |
|
|
else
|
1929 |
|
|
add_symbol_to_list (sym, &file_symbols);
|
1930 |
|
|
break;
|
1931 |
|
|
|
1932 |
|
|
case 'S':
|
1933 |
|
|
/* Static symbol at top level of file */
|
1934 |
|
|
SYMBOL_TYPE (sym) = read_type (&p, objfile);
|
1935 |
|
|
SYMBOL_CLASS (sym) = LOC_STATIC;
|
1936 |
|
|
SYMBOL_VALUE_ADDRESS (sym) = valu;
|
1937 |
|
|
#ifdef STATIC_TRANSFORM_NAME
|
1938 |
|
|
if (IS_STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym)))
|
1939 |
|
|
{
|
1940 |
|
|
struct minimal_symbol *msym;
|
1941 |
|
|
msym = lookup_minimal_symbol (SYMBOL_NAME (sym), NULL, objfile);
|
1942 |
|
|
if (msym != NULL)
|
1943 |
|
|
{
|
1944 |
|
|
SYMBOL_NAME (sym) = STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym));
|
1945 |
|
|
SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msym);
|
1946 |
|
|
}
|
1947 |
|
|
}
|
1948 |
|
|
#endif
|
1949 |
|
|
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
|
1950 |
|
|
add_symbol_to_list (sym, &file_symbols);
|
1951 |
|
|
break;
|
1952 |
|
|
|
1953 |
|
|
case 't':
|
1954 |
|
|
SYMBOL_TYPE (sym) = read_type (&p, objfile);
|
1955 |
|
|
|
1956 |
|
|
/* For a nameless type, we don't want a create a symbol, thus we
|
1957 |
|
|
did not use `sym'. Return without further processing. */
|
1958 |
|
|
if (nameless)
|
1959 |
|
|
return NULL;
|
1960 |
|
|
|
1961 |
|
|
SYMBOL_CLASS (sym) = LOC_TYPEDEF;
|
1962 |
|
|
SYMBOL_VALUE (sym) = valu;
|
1963 |
|
|
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
|
1964 |
|
|
/* C++ vagaries: we may have a type which is derived from
|
1965 |
|
|
a base type which did not have its name defined when the
|
1966 |
|
|
derived class was output. We fill in the derived class's
|
1967 |
|
|
base part member's name here in that case. */
|
1968 |
|
|
if (TYPE_NAME (SYMBOL_TYPE (sym)) != NULL)
|
1969 |
|
|
if ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
|
1970 |
|
|
|| TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION)
|
1971 |
|
|
&& TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)))
|
1972 |
|
|
{
|
1973 |
|
|
int j;
|
1974 |
|
|
for (j = TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)) - 1; j >= 0; j--)
|
1975 |
|
|
if (TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) == 0)
|
1976 |
|
|
TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) =
|
1977 |
|
|
type_name_no_tag (TYPE_BASECLASS (SYMBOL_TYPE (sym), j));
|
1978 |
|
|
}
|
1979 |
|
|
|
1980 |
|
|
if (TYPE_NAME (SYMBOL_TYPE (sym)) == NULL)
|
1981 |
|
|
{
|
1982 |
|
|
/* gcc-2.6 or later (when using -fvtable-thunks)
|
1983 |
|
|
emits a unique named type for a vtable entry.
|
1984 |
|
|
Some gdb code depends on that specific name. */
|
1985 |
|
|
extern const char vtbl_ptr_name[];
|
1986 |
|
|
|
1987 |
|
|
if ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_PTR
|
1988 |
|
|
&& strcmp (SYMBOL_NAME (sym), vtbl_ptr_name))
|
1989 |
|
|
|| TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_FUNC)
|
1990 |
|
|
{
|
1991 |
|
|
/* If we are giving a name to a type such as "pointer to
|
1992 |
|
|
foo" or "function returning foo", we better not set
|
1993 |
|
|
the TYPE_NAME. If the program contains "typedef char
|
1994 |
|
|
*caddr_t;", we don't want all variables of type char
|
1995 |
|
|
* to print as caddr_t. This is not just a
|
1996 |
|
|
consequence of GDB's type management; PCC and GCC (at
|
1997 |
|
|
least through version 2.4) both output variables of
|
1998 |
|
|
either type char * or caddr_t with the type number
|
1999 |
|
|
defined in the 't' symbol for caddr_t. If a future
|
2000 |
|
|
compiler cleans this up it GDB is not ready for it
|
2001 |
|
|
yet, but if it becomes ready we somehow need to
|
2002 |
|
|
disable this check (without breaking the PCC/GCC2.4
|
2003 |
|
|
case).
|
2004 |
|
|
|
2005 |
|
|
Sigh.
|
2006 |
|
|
|
2007 |
|
|
Fortunately, this check seems not to be necessary
|
2008 |
|
|
for anything except pointers or functions. */
|
2009 |
|
|
}
|
2010 |
|
|
else
|
2011 |
|
|
TYPE_NAME (SYMBOL_TYPE (sym)) = SYMBOL_NAME (sym);
|
2012 |
|
|
}
|
2013 |
|
|
|
2014 |
|
|
add_symbol_to_list (sym, &file_symbols);
|
2015 |
|
|
break;
|
2016 |
|
|
|
2017 |
|
|
case 'T':
|
2018 |
|
|
/* Struct, union, or enum tag. For GNU C++, this can be be followed
|
2019 |
|
|
by 't' which means we are typedef'ing it as well. */
|
2020 |
|
|
synonym = *p == 't';
|
2021 |
|
|
|
2022 |
|
|
if (synonym)
|
2023 |
|
|
p++;
|
2024 |
|
|
/* The semantics of C++ state that "struct foo { ... }" also defines
|
2025 |
|
|
a typedef for "foo". Unfortunately, cfront never makes the typedef
|
2026 |
|
|
when translating C++ into C. We make the typedef here so that
|
2027 |
|
|
"ptype foo" works as expected for cfront translated code. */
|
2028 |
|
|
else if (current_subfile->language == language_cplus)
|
2029 |
|
|
synonym = 1;
|
2030 |
|
|
|
2031 |
|
|
SYMBOL_TYPE (sym) = read_type (&p, objfile);
|
2032 |
|
|
|
2033 |
|
|
/* For a nameless type, we don't want a create a symbol, thus we
|
2034 |
|
|
did not use `sym'. Return without further processing. */
|
2035 |
|
|
if (nameless)
|
2036 |
|
|
return NULL;
|
2037 |
|
|
|
2038 |
|
|
SYMBOL_CLASS (sym) = LOC_TYPEDEF;
|
2039 |
|
|
SYMBOL_VALUE (sym) = valu;
|
2040 |
|
|
SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE;
|
2041 |
|
|
if (TYPE_TAG_NAME (SYMBOL_TYPE (sym)) == 0)
|
2042 |
|
|
TYPE_TAG_NAME (SYMBOL_TYPE (sym))
|
2043 |
|
|
= obconcat (&objfile->type_obstack, "", "", SYMBOL_NAME (sym));
|
2044 |
|
|
add_symbol_to_list (sym, &file_symbols);
|
2045 |
|
|
|
2046 |
|
|
if (synonym)
|
2047 |
|
|
{
|
2048 |
|
|
/* Clone the sym and then modify it. */
|
2049 |
|
|
register struct symbol *typedef_sym = (struct symbol *)
|
2050 |
|
|
obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
|
2051 |
|
|
*typedef_sym = *sym;
|
2052 |
|
|
SYMBOL_CLASS (typedef_sym) = LOC_TYPEDEF;
|
2053 |
|
|
SYMBOL_VALUE (typedef_sym) = valu;
|
2054 |
|
|
SYMBOL_NAMESPACE (typedef_sym) = VAR_NAMESPACE;
|
2055 |
|
|
if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)
|
2056 |
|
|
TYPE_NAME (SYMBOL_TYPE (sym))
|
2057 |
|
|
= obconcat (&objfile->type_obstack, "", "", SYMBOL_NAME (sym));
|
2058 |
|
|
add_symbol_to_list (typedef_sym, &file_symbols);
|
2059 |
|
|
}
|
2060 |
|
|
break;
|
2061 |
|
|
|
2062 |
|
|
case 'V':
|
2063 |
|
|
/* Static symbol of local scope */
|
2064 |
|
|
SYMBOL_TYPE (sym) = read_type (&p, objfile);
|
2065 |
|
|
SYMBOL_CLASS (sym) = LOC_STATIC;
|
2066 |
|
|
SYMBOL_VALUE_ADDRESS (sym) = valu;
|
2067 |
|
|
#ifdef STATIC_TRANSFORM_NAME
|
2068 |
|
|
if (IS_STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym)))
|
2069 |
|
|
{
|
2070 |
|
|
struct minimal_symbol *msym;
|
2071 |
|
|
msym = lookup_minimal_symbol (SYMBOL_NAME (sym), NULL, objfile);
|
2072 |
|
|
if (msym != NULL)
|
2073 |
|
|
{
|
2074 |
|
|
SYMBOL_NAME (sym) = STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym));
|
2075 |
|
|
SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msym);
|
2076 |
|
|
}
|
2077 |
|
|
}
|
2078 |
|
|
#endif
|
2079 |
|
|
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
|
2080 |
|
|
if (os9k_stabs)
|
2081 |
|
|
add_symbol_to_list (sym, &global_symbols);
|
2082 |
|
|
else
|
2083 |
|
|
add_symbol_to_list (sym, &local_symbols);
|
2084 |
|
|
break;
|
2085 |
|
|
|
2086 |
|
|
case 'v':
|
2087 |
|
|
/* Reference parameter */
|
2088 |
|
|
SYMBOL_TYPE (sym) = read_type (&p, objfile);
|
2089 |
|
|
SYMBOL_CLASS (sym) = LOC_REF_ARG;
|
2090 |
|
|
SYMBOL_VALUE (sym) = valu;
|
2091 |
|
|
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
|
2092 |
|
|
add_symbol_to_list (sym, &local_symbols);
|
2093 |
|
|
break;
|
2094 |
|
|
|
2095 |
|
|
case 'a':
|
2096 |
|
|
/* Reference parameter which is in a register. */
|
2097 |
|
|
SYMBOL_TYPE (sym) = read_type (&p, objfile);
|
2098 |
|
|
SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
|
2099 |
|
|
SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
|
2100 |
|
|
if (SYMBOL_VALUE (sym) >= NUM_REGS)
|
2101 |
|
|
{
|
2102 |
|
|
complain (®_value_complaint, SYMBOL_VALUE (sym), NUM_REGS,
|
2103 |
|
|
SYMBOL_SOURCE_NAME (sym));
|
2104 |
|
|
SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */
|
2105 |
|
|
}
|
2106 |
|
|
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
|
2107 |
|
|
add_symbol_to_list (sym, &local_symbols);
|
2108 |
|
|
break;
|
2109 |
|
|
|
2110 |
|
|
case 'X':
|
2111 |
|
|
/* This is used by Sun FORTRAN for "function result value".
|
2112 |
|
|
Sun claims ("dbx and dbxtool interfaces", 2nd ed)
|
2113 |
|
|
that Pascal uses it too, but when I tried it Pascal used
|
2114 |
|
|
"x:3" (local symbol) instead. */
|
2115 |
|
|
SYMBOL_TYPE (sym) = read_type (&p, objfile);
|
2116 |
|
|
SYMBOL_CLASS (sym) = LOC_LOCAL;
|
2117 |
|
|
SYMBOL_VALUE (sym) = valu;
|
2118 |
|
|
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
|
2119 |
|
|
add_symbol_to_list (sym, &local_symbols);
|
2120 |
|
|
break;
|
2121 |
|
|
|
2122 |
|
|
/* New code added to support cfront stabs strings.
|
2123 |
|
|
Note: case 'P' already handled above */
|
2124 |
|
|
case 'Z':
|
2125 |
|
|
/* Cfront type continuation coming up!
|
2126 |
|
|
Find the original definition and add to it.
|
2127 |
|
|
We'll have to do this for the typedef too,
|
2128 |
|
|
since we cloned the symbol to define a type in read_type.
|
2129 |
|
|
Stabs info examples:
|
2130 |
|
|
__1C :Ztl
|
2131 |
|
|
foo__1CFv :ZtF (first def foo__1CFv:F(0,3);(0,24))
|
2132 |
|
|
C:ZsC;;__ct__1CFv func1__1CFv func2__1CFv ... ;;;
|
2133 |
|
|
where C is the name of the class.
|
2134 |
|
|
Unfortunately, we can't lookup the original symbol yet 'cuz
|
2135 |
|
|
we haven't finished reading all the symbols.
|
2136 |
|
|
Instead, we save it for processing later */
|
2137 |
|
|
process_later (sym, p, resolve_cfront_continuation);
|
2138 |
|
|
SYMBOL_TYPE (sym) = error_type (&p, objfile); /* FIXME! change later */
|
2139 |
|
|
SYMBOL_CLASS (sym) = LOC_CONST;
|
2140 |
|
|
SYMBOL_VALUE (sym) = 0;
|
2141 |
|
|
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
|
2142 |
|
|
/* Don't add to list - we'll delete it later when
|
2143 |
|
|
we add the continuation to the real sym */
|
2144 |
|
|
return sym;
|
2145 |
|
|
/* End of new code added to support cfront stabs strings */
|
2146 |
|
|
|
2147 |
|
|
default:
|
2148 |
|
|
SYMBOL_TYPE (sym) = error_type (&p, objfile);
|
2149 |
|
|
SYMBOL_CLASS (sym) = LOC_CONST;
|
2150 |
|
|
SYMBOL_VALUE (sym) = 0;
|
2151 |
|
|
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
|
2152 |
|
|
add_symbol_to_list (sym, &file_symbols);
|
2153 |
|
|
break;
|
2154 |
|
|
}
|
2155 |
|
|
|
2156 |
|
|
/* When passing structures to a function, some systems sometimes pass
|
2157 |
|
|
the address in a register, not the structure itself. */
|
2158 |
|
|
|
2159 |
|
|
if (REG_STRUCT_HAS_ADDR (processing_gcc_compilation, SYMBOL_TYPE (sym))
|
2160 |
|
|
&& (SYMBOL_CLASS (sym) == LOC_REGPARM || SYMBOL_CLASS (sym) == LOC_ARG))
|
2161 |
|
|
{
|
2162 |
|
|
struct type *symbol_type = check_typedef (SYMBOL_TYPE (sym));
|
2163 |
|
|
|
2164 |
|
|
if ((TYPE_CODE (symbol_type) == TYPE_CODE_STRUCT)
|
2165 |
|
|
|| (TYPE_CODE (symbol_type) == TYPE_CODE_UNION)
|
2166 |
|
|
|| (TYPE_CODE (symbol_type) == TYPE_CODE_BITSTRING)
|
2167 |
|
|
|| (TYPE_CODE (symbol_type) == TYPE_CODE_SET))
|
2168 |
|
|
{
|
2169 |
|
|
/* If REG_STRUCT_HAS_ADDR yields non-zero we have to convert
|
2170 |
|
|
LOC_REGPARM to LOC_REGPARM_ADDR for structures and unions. */
|
2171 |
|
|
if (SYMBOL_CLASS (sym) == LOC_REGPARM)
|
2172 |
|
|
SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
|
2173 |
|
|
/* Likewise for converting LOC_ARG to LOC_REF_ARG (for the 7th
|
2174 |
|
|
and subsequent arguments on the sparc, for example). */
|
2175 |
|
|
else if (SYMBOL_CLASS (sym) == LOC_ARG)
|
2176 |
|
|
SYMBOL_CLASS (sym) = LOC_REF_ARG;
|
2177 |
|
|
}
|
2178 |
|
|
}
|
2179 |
|
|
|
2180 |
|
|
/* Is there more to parse? For example LRS/alias information? */
|
2181 |
|
|
while (*p && *p == ';')
|
2182 |
|
|
{
|
2183 |
|
|
p++;
|
2184 |
|
|
if (*p && p[0] == 'l' && p[1] == '(')
|
2185 |
|
|
{
|
2186 |
|
|
/* GNU extensions for live range splitting may be appended to
|
2187 |
|
|
the end of the stab string. eg. "l(#1,#2);l(#3,#5)" */
|
2188 |
|
|
|
2189 |
|
|
/* Resolve the live range and add it to SYM's live range list. */
|
2190 |
|
|
if (!resolve_live_range (objfile, sym, p))
|
2191 |
|
|
return NULL;
|
2192 |
|
|
|
2193 |
|
|
/* Find end of live range info. */
|
2194 |
|
|
p = strchr (p, ')');
|
2195 |
|
|
if (!*p || *p != ')')
|
2196 |
|
|
{
|
2197 |
|
|
complain (&lrs_general_complaint, "live range format not recognized");
|
2198 |
|
|
return NULL;
|
2199 |
|
|
}
|
2200 |
|
|
p++;
|
2201 |
|
|
}
|
2202 |
|
|
}
|
2203 |
|
|
return sym;
|
2204 |
|
|
}
|
2205 |
|
|
|
2206 |
|
|
/* Add the live range found in P to the symbol SYM in objfile OBJFILE. Returns
|
2207 |
|
|
non-zero on success, zero otherwise. */
|
2208 |
|
|
|
2209 |
|
|
static int
|
2210 |
|
|
resolve_live_range (objfile, sym, p)
|
2211 |
|
|
struct objfile *objfile;
|
2212 |
|
|
struct symbol *sym;
|
2213 |
|
|
char *p;
|
2214 |
|
|
{
|
2215 |
|
|
int refnum;
|
2216 |
|
|
CORE_ADDR start, end;
|
2217 |
|
|
|
2218 |
|
|
/* Sanity check the beginning of the stabs string. */
|
2219 |
|
|
if (!*p || *p != 'l')
|
2220 |
|
|
{
|
2221 |
|
|
complain (&lrs_general_complaint, "live range string 1");
|
2222 |
|
|
return 0;
|
2223 |
|
|
}
|
2224 |
|
|
p++;
|
2225 |
|
|
|
2226 |
|
|
if (!*p || *p != '(')
|
2227 |
|
|
{
|
2228 |
|
|
complain (&lrs_general_complaint, "live range string 2");
|
2229 |
|
|
return 0;
|
2230 |
|
|
}
|
2231 |
|
|
p++;
|
2232 |
|
|
|
2233 |
|
|
/* Get starting value of range and advance P past the reference id.
|
2234 |
|
|
|
2235 |
|
|
?!? In theory, the process_reference should never fail, but we should
|
2236 |
|
|
catch that case just in case the compiler scrogged the stabs. */
|
2237 |
|
|
refnum = process_reference (&p);
|
2238 |
|
|
start = ref_search_value (refnum);
|
2239 |
|
|
if (!start)
|
2240 |
|
|
{
|
2241 |
|
|
complain (&lrs_general_complaint, "Live range symbol not found 1");
|
2242 |
|
|
return 0;
|
2243 |
|
|
}
|
2244 |
|
|
|
2245 |
|
|
if (!*p || *p != ',')
|
2246 |
|
|
{
|
2247 |
|
|
complain (&lrs_general_complaint, "live range string 3");
|
2248 |
|
|
return 0;
|
2249 |
|
|
}
|
2250 |
|
|
p++;
|
2251 |
|
|
|
2252 |
|
|
/* Get ending value of range and advance P past the reference id.
|
2253 |
|
|
|
2254 |
|
|
?!? In theory, the process_reference should never fail, but we should
|
2255 |
|
|
catch that case just in case the compiler scrogged the stabs. */
|
2256 |
|
|
refnum = process_reference (&p);
|
2257 |
|
|
end = ref_search_value (refnum);
|
2258 |
|
|
if (!end)
|
2259 |
|
|
{
|
2260 |
|
|
complain (&lrs_general_complaint, "Live range symbol not found 2");
|
2261 |
|
|
return 0;
|
2262 |
|
|
}
|
2263 |
|
|
|
2264 |
|
|
if (!*p || *p != ')')
|
2265 |
|
|
{
|
2266 |
|
|
complain (&lrs_general_complaint, "live range string 4");
|
2267 |
|
|
return 0;
|
2268 |
|
|
}
|
2269 |
|
|
|
2270 |
|
|
/* Now that we know the bounds of the range, add it to the
|
2271 |
|
|
symbol. */
|
2272 |
|
|
add_live_range (objfile, sym, start, end);
|
2273 |
|
|
|
2274 |
|
|
return 1;
|
2275 |
|
|
}
|
2276 |
|
|
|
2277 |
|
|
/* Add a new live range defined by START and END to the symbol SYM
|
2278 |
|
|
in objfile OBJFILE. */
|
2279 |
|
|
|
2280 |
|
|
static void
|
2281 |
|
|
add_live_range (objfile, sym, start, end)
|
2282 |
|
|
struct objfile *objfile;
|
2283 |
|
|
struct symbol *sym;
|
2284 |
|
|
CORE_ADDR start, end;
|
2285 |
|
|
{
|
2286 |
|
|
struct range_list *r, *rs;
|
2287 |
|
|
|
2288 |
|
|
if (start >= end)
|
2289 |
|
|
{
|
2290 |
|
|
complain (&lrs_general_complaint, "end of live range follows start");
|
2291 |
|
|
return;
|
2292 |
|
|
}
|
2293 |
|
|
|
2294 |
|
|
/* Alloc new live range structure. */
|
2295 |
|
|
r = (struct range_list *)
|
2296 |
|
|
obstack_alloc (&objfile->type_obstack,
|
2297 |
|
|
sizeof (struct range_list));
|
2298 |
|
|
r->start = start;
|
2299 |
|
|
r->end = end;
|
2300 |
|
|
r->next = 0;
|
2301 |
|
|
|
2302 |
|
|
/* Append this range to the symbol's range list. */
|
2303 |
|
|
if (!SYMBOL_RANGES (sym))
|
2304 |
|
|
SYMBOL_RANGES (sym) = r;
|
2305 |
|
|
else
|
2306 |
|
|
{
|
2307 |
|
|
/* Get the last range for the symbol. */
|
2308 |
|
|
for (rs = SYMBOL_RANGES (sym); rs->next; rs = rs->next)
|
2309 |
|
|
;
|
2310 |
|
|
rs->next = r;
|
2311 |
|
|
}
|
2312 |
|
|
}
|
2313 |
|
|
|
2314 |
|
|
|
2315 |
|
|
/* Skip rest of this symbol and return an error type.
|
2316 |
|
|
|
2317 |
|
|
General notes on error recovery: error_type always skips to the
|
2318 |
|
|
end of the symbol (modulo cretinous dbx symbol name continuation).
|
2319 |
|
|
Thus code like this:
|
2320 |
|
|
|
2321 |
|
|
if (*(*pp)++ != ';')
|
2322 |
|
|
return error_type (pp, objfile);
|
2323 |
|
|
|
2324 |
|
|
is wrong because if *pp starts out pointing at '\0' (typically as the
|
2325 |
|
|
result of an earlier error), it will be incremented to point to the
|
2326 |
|
|
start of the next symbol, which might produce strange results, at least
|
2327 |
|
|
if you run off the end of the string table. Instead use
|
2328 |
|
|
|
2329 |
|
|
if (**pp != ';')
|
2330 |
|
|
return error_type (pp, objfile);
|
2331 |
|
|
++*pp;
|
2332 |
|
|
|
2333 |
|
|
or
|
2334 |
|
|
|
2335 |
|
|
if (**pp != ';')
|
2336 |
|
|
foo = error_type (pp, objfile);
|
2337 |
|
|
else
|
2338 |
|
|
++*pp;
|
2339 |
|
|
|
2340 |
|
|
And in case it isn't obvious, the point of all this hair is so the compiler
|
2341 |
|
|
can define new types and new syntaxes, and old versions of the
|
2342 |
|
|
debugger will be able to read the new symbol tables. */
|
2343 |
|
|
|
2344 |
|
|
static struct type *
|
2345 |
|
|
error_type (pp, objfile)
|
2346 |
|
|
char **pp;
|
2347 |
|
|
struct objfile *objfile;
|
2348 |
|
|
{
|
2349 |
|
|
complain (&error_type_complaint);
|
2350 |
|
|
while (1)
|
2351 |
|
|
{
|
2352 |
|
|
/* Skip to end of symbol. */
|
2353 |
|
|
while (**pp != '\0')
|
2354 |
|
|
{
|
2355 |
|
|
(*pp)++;
|
2356 |
|
|
}
|
2357 |
|
|
|
2358 |
|
|
/* Check for and handle cretinous dbx symbol name continuation! */
|
2359 |
|
|
if ((*pp)[-1] == '\\' || (*pp)[-1] == '?')
|
2360 |
|
|
{
|
2361 |
|
|
*pp = next_symbol_text (objfile);
|
2362 |
|
|
}
|
2363 |
|
|
else
|
2364 |
|
|
{
|
2365 |
|
|
break;
|
2366 |
|
|
}
|
2367 |
|
|
}
|
2368 |
|
|
return (builtin_type_error);
|
2369 |
|
|
}
|
2370 |
|
|
|
2371 |
|
|
|
2372 |
|
|
/* Read type information or a type definition; return the type. Even
|
2373 |
|
|
though this routine accepts either type information or a type
|
2374 |
|
|
definition, the distinction is relevant--some parts of stabsread.c
|
2375 |
|
|
assume that type information starts with a digit, '-', or '(' in
|
2376 |
|
|
deciding whether to call read_type. */
|
2377 |
|
|
|
2378 |
|
|
struct type *
|
2379 |
|
|
read_type (pp, objfile)
|
2380 |
|
|
register char **pp;
|
2381 |
|
|
struct objfile *objfile;
|
2382 |
|
|
{
|
2383 |
|
|
register struct type *type = 0;
|
2384 |
|
|
struct type *type1;
|
2385 |
|
|
int typenums[2];
|
2386 |
|
|
char type_descriptor;
|
2387 |
|
|
|
2388 |
|
|
/* Size in bits of type if specified by a type attribute, or -1 if
|
2389 |
|
|
there is no size attribute. */
|
2390 |
|
|
int type_size = -1;
|
2391 |
|
|
|
2392 |
|
|
/* Used to distinguish string and bitstring from char-array and set. */
|
2393 |
|
|
int is_string = 0;
|
2394 |
|
|
|
2395 |
|
|
/* Read type number if present. The type number may be omitted.
|
2396 |
|
|
for instance in a two-dimensional array declared with type
|
2397 |
|
|
"ar1;1;10;ar1;1;10;4". */
|
2398 |
|
|
if ((**pp >= '0' && **pp <= '9')
|
2399 |
|
|
|| **pp == '('
|
2400 |
|
|
|| **pp == '-')
|
2401 |
|
|
{
|
2402 |
|
|
if (read_type_number (pp, typenums) != 0)
|
2403 |
|
|
return error_type (pp, objfile);
|
2404 |
|
|
|
2405 |
|
|
/* Type is not being defined here. Either it already exists,
|
2406 |
|
|
or this is a forward reference to it. dbx_alloc_type handles
|
2407 |
|
|
both cases. */
|
2408 |
|
|
if (**pp != '=')
|
2409 |
|
|
return dbx_alloc_type (typenums, objfile);
|
2410 |
|
|
|
2411 |
|
|
/* Type is being defined here. */
|
2412 |
|
|
/* Skip the '='.
|
2413 |
|
|
Also skip the type descriptor - we get it below with (*pp)[-1]. */
|
2414 |
|
|
(*pp) += 2;
|
2415 |
|
|
}
|
2416 |
|
|
else
|
2417 |
|
|
{
|
2418 |
|
|
/* 'typenums=' not present, type is anonymous. Read and return
|
2419 |
|
|
the definition, but don't put it in the type vector. */
|
2420 |
|
|
typenums[0] = typenums[1] = -1;
|
2421 |
|
|
(*pp)++;
|
2422 |
|
|
}
|
2423 |
|
|
|
2424 |
|
|
again:
|
2425 |
|
|
type_descriptor = (*pp)[-1];
|
2426 |
|
|
switch (type_descriptor)
|
2427 |
|
|
{
|
2428 |
|
|
case 'x':
|
2429 |
|
|
{
|
2430 |
|
|
enum type_code code;
|
2431 |
|
|
|
2432 |
|
|
/* Used to index through file_symbols. */
|
2433 |
|
|
struct pending *ppt;
|
2434 |
|
|
int i;
|
2435 |
|
|
|
2436 |
|
|
/* Name including "struct", etc. */
|
2437 |
|
|
char *type_name;
|
2438 |
|
|
|
2439 |
|
|
{
|
2440 |
|
|
char *from, *to, *p, *q1, *q2;
|
2441 |
|
|
|
2442 |
|
|
/* Set the type code according to the following letter. */
|
2443 |
|
|
switch ((*pp)[0])
|
2444 |
|
|
{
|
2445 |
|
|
case 's':
|
2446 |
|
|
code = TYPE_CODE_STRUCT;
|
2447 |
|
|
break;
|
2448 |
|
|
case 'u':
|
2449 |
|
|
code = TYPE_CODE_UNION;
|
2450 |
|
|
break;
|
2451 |
|
|
case 'e':
|
2452 |
|
|
code = TYPE_CODE_ENUM;
|
2453 |
|
|
break;
|
2454 |
|
|
default:
|
2455 |
|
|
{
|
2456 |
|
|
/* Complain and keep going, so compilers can invent new
|
2457 |
|
|
cross-reference types. */
|
2458 |
|
|
static struct complaint msg =
|
2459 |
|
|
{"Unrecognized cross-reference type `%c'", 0, 0};
|
2460 |
|
|
complain (&msg, (*pp)[0]);
|
2461 |
|
|
code = TYPE_CODE_STRUCT;
|
2462 |
|
|
break;
|
2463 |
|
|
}
|
2464 |
|
|
}
|
2465 |
|
|
|
2466 |
|
|
q1 = strchr (*pp, '<');
|
2467 |
|
|
p = strchr (*pp, ':');
|
2468 |
|
|
if (p == NULL)
|
2469 |
|
|
return error_type (pp, objfile);
|
2470 |
|
|
if (q1 && p > q1 && p[1] == ':')
|
2471 |
|
|
{
|
2472 |
|
|
int nesting_level = 0;
|
2473 |
|
|
for (q2 = q1; *q2; q2++)
|
2474 |
|
|
{
|
2475 |
|
|
if (*q2 == '<')
|
2476 |
|
|
nesting_level++;
|
2477 |
|
|
else if (*q2 == '>')
|
2478 |
|
|
nesting_level--;
|
2479 |
|
|
else if (*q2 == ':' && nesting_level == 0)
|
2480 |
|
|
break;
|
2481 |
|
|
}
|
2482 |
|
|
p = q2;
|
2483 |
|
|
if (*p != ':')
|
2484 |
|
|
return error_type (pp, objfile);
|
2485 |
|
|
}
|
2486 |
|
|
to = type_name =
|
2487 |
|
|
(char *) obstack_alloc (&objfile->type_obstack, p - *pp + 1);
|
2488 |
|
|
|
2489 |
|
|
/* Copy the name. */
|
2490 |
|
|
from = *pp + 1;
|
2491 |
|
|
while (from < p)
|
2492 |
|
|
*to++ = *from++;
|
2493 |
|
|
*to = '\0';
|
2494 |
|
|
|
2495 |
|
|
/* Set the pointer ahead of the name which we just read, and
|
2496 |
|
|
the colon. */
|
2497 |
|
|
*pp = from + 1;
|
2498 |
|
|
}
|
2499 |
|
|
|
2500 |
|
|
/* Now check to see whether the type has already been
|
2501 |
|
|
declared. This was written for arrays of cross-referenced
|
2502 |
|
|
types before we had TYPE_CODE_TARGET_STUBBED, so I'm pretty
|
2503 |
|
|
sure it is not necessary anymore. But it might be a good
|
2504 |
|
|
idea, to save a little memory. */
|
2505 |
|
|
|
2506 |
|
|
for (ppt = file_symbols; ppt; ppt = ppt->next)
|
2507 |
|
|
for (i = 0; i < ppt->nsyms; i++)
|
2508 |
|
|
{
|
2509 |
|
|
struct symbol *sym = ppt->symbol[i];
|
2510 |
|
|
|
2511 |
|
|
if (SYMBOL_CLASS (sym) == LOC_TYPEDEF
|
2512 |
|
|
&& SYMBOL_NAMESPACE (sym) == STRUCT_NAMESPACE
|
2513 |
|
|
&& (TYPE_CODE (SYMBOL_TYPE (sym)) == code)
|
2514 |
|
|
&& STREQ (SYMBOL_NAME (sym), type_name))
|
2515 |
|
|
{
|
2516 |
|
|
obstack_free (&objfile->type_obstack, type_name);
|
2517 |
|
|
type = SYMBOL_TYPE (sym);
|
2518 |
|
|
return type;
|
2519 |
|
|
}
|
2520 |
|
|
}
|
2521 |
|
|
|
2522 |
|
|
/* Didn't find the type to which this refers, so we must
|
2523 |
|
|
be dealing with a forward reference. Allocate a type
|
2524 |
|
|
structure for it, and keep track of it so we can
|
2525 |
|
|
fill in the rest of the fields when we get the full
|
2526 |
|
|
type. */
|
2527 |
|
|
type = dbx_alloc_type (typenums, objfile);
|
2528 |
|
|
TYPE_CODE (type) = code;
|
2529 |
|
|
TYPE_TAG_NAME (type) = type_name;
|
2530 |
|
|
INIT_CPLUS_SPECIFIC (type);
|
2531 |
|
|
TYPE_FLAGS (type) |= TYPE_FLAG_STUB;
|
2532 |
|
|
|
2533 |
|
|
add_undefined_type (type);
|
2534 |
|
|
return type;
|
2535 |
|
|
}
|
2536 |
|
|
|
2537 |
|
|
case '-': /* RS/6000 built-in type */
|
2538 |
|
|
case '0':
|
2539 |
|
|
case '1':
|
2540 |
|
|
case '2':
|
2541 |
|
|
case '3':
|
2542 |
|
|
case '4':
|
2543 |
|
|
case '5':
|
2544 |
|
|
case '6':
|
2545 |
|
|
case '7':
|
2546 |
|
|
case '8':
|
2547 |
|
|
case '9':
|
2548 |
|
|
case '(':
|
2549 |
|
|
(*pp)--;
|
2550 |
|
|
|
2551 |
|
|
/* We deal with something like t(1,2)=(3,4)=... which
|
2552 |
|
|
the Lucid compiler and recent gcc versions (post 2.7.3) use. */
|
2553 |
|
|
|
2554 |
|
|
/* Allocate and enter the typedef type first.
|
2555 |
|
|
This handles recursive types. */
|
2556 |
|
|
type = dbx_alloc_type (typenums, objfile);
|
2557 |
|
|
TYPE_CODE (type) = TYPE_CODE_TYPEDEF;
|
2558 |
|
|
{
|
2559 |
|
|
struct type *xtype = read_type (pp, objfile);
|
2560 |
|
|
if (type == xtype)
|
2561 |
|
|
{
|
2562 |
|
|
/* It's being defined as itself. That means it is "void". */
|
2563 |
|
|
TYPE_CODE (type) = TYPE_CODE_VOID;
|
2564 |
|
|
TYPE_LENGTH (type) = 1;
|
2565 |
|
|
}
|
2566 |
|
|
else if (type_size >= 0 || is_string)
|
2567 |
|
|
{
|
2568 |
|
|
*type = *xtype;
|
2569 |
|
|
TYPE_NAME (type) = NULL;
|
2570 |
|
|
TYPE_TAG_NAME (type) = NULL;
|
2571 |
|
|
}
|
2572 |
|
|
else
|
2573 |
|
|
{
|
2574 |
|
|
TYPE_FLAGS (type) |= TYPE_FLAG_TARGET_STUB;
|
2575 |
|
|
TYPE_TARGET_TYPE (type) = xtype;
|
2576 |
|
|
}
|
2577 |
|
|
}
|
2578 |
|
|
break;
|
2579 |
|
|
|
2580 |
|
|
/* In the following types, we must be sure to overwrite any existing
|
2581 |
|
|
type that the typenums refer to, rather than allocating a new one
|
2582 |
|
|
and making the typenums point to the new one. This is because there
|
2583 |
|
|
may already be pointers to the existing type (if it had been
|
2584 |
|
|
forward-referenced), and we must change it to a pointer, function,
|
2585 |
|
|
reference, or whatever, *in-place*. */
|
2586 |
|
|
|
2587 |
|
|
case '*':
|
2588 |
|
|
type1 = read_type (pp, objfile);
|
2589 |
|
|
type = make_pointer_type (type1, dbx_lookup_type (typenums));
|
2590 |
|
|
break;
|
2591 |
|
|
|
2592 |
|
|
case '&': /* Reference to another type */
|
2593 |
|
|
type1 = read_type (pp, objfile);
|
2594 |
|
|
type = make_reference_type (type1, dbx_lookup_type (typenums));
|
2595 |
|
|
break;
|
2596 |
|
|
|
2597 |
|
|
case 'f': /* Function returning another type */
|
2598 |
|
|
if (os9k_stabs && **pp == '(')
|
2599 |
|
|
{
|
2600 |
|
|
/* Function prototype; parse it.
|
2601 |
|
|
We must conditionalize this on os9k_stabs because otherwise
|
2602 |
|
|
it could be confused with a Sun-style (1,3) typenumber
|
2603 |
|
|
(I think). */
|
2604 |
|
|
struct type *t;
|
2605 |
|
|
++*pp;
|
2606 |
|
|
while (**pp != ')')
|
2607 |
|
|
{
|
2608 |
|
|
t = read_type (pp, objfile);
|
2609 |
|
|
if (**pp == ',')
|
2610 |
|
|
++ * pp;
|
2611 |
|
|
}
|
2612 |
|
|
}
|
2613 |
|
|
type1 = read_type (pp, objfile);
|
2614 |
|
|
type = make_function_type (type1, dbx_lookup_type (typenums));
|
2615 |
|
|
break;
|
2616 |
|
|
|
2617 |
|
|
case 'k': /* Const qualifier on some type (Sun) */
|
2618 |
|
|
case 'c': /* Const qualifier on some type (OS9000) */
|
2619 |
|
|
/* Because 'c' means other things to AIX and 'k' is perfectly good,
|
2620 |
|
|
only accept 'c' in the os9k_stabs case. */
|
2621 |
|
|
if (type_descriptor == 'c' && !os9k_stabs)
|
2622 |
|
|
return error_type (pp, objfile);
|
2623 |
|
|
type = read_type (pp, objfile);
|
2624 |
|
|
/* FIXME! For now, we ignore const and volatile qualifiers. */
|
2625 |
|
|
break;
|
2626 |
|
|
|
2627 |
|
|
case 'B': /* Volatile qual on some type (Sun) */
|
2628 |
|
|
case 'i': /* Volatile qual on some type (OS9000) */
|
2629 |
|
|
/* Because 'i' means other things to AIX and 'B' is perfectly good,
|
2630 |
|
|
only accept 'i' in the os9k_stabs case. */
|
2631 |
|
|
if (type_descriptor == 'i' && !os9k_stabs)
|
2632 |
|
|
return error_type (pp, objfile);
|
2633 |
|
|
type = read_type (pp, objfile);
|
2634 |
|
|
/* FIXME! For now, we ignore const and volatile qualifiers. */
|
2635 |
|
|
break;
|
2636 |
|
|
|
2637 |
|
|
case '@':
|
2638 |
|
|
if (isdigit (**pp) || **pp == '(' || **pp == '-')
|
2639 |
|
|
{ /* Member (class & variable) type */
|
2640 |
|
|
/* FIXME -- we should be doing smash_to_XXX types here. */
|
2641 |
|
|
|
2642 |
|
|
struct type *domain = read_type (pp, objfile);
|
2643 |
|
|
struct type *memtype;
|
2644 |
|
|
|
2645 |
|
|
if (**pp != ',')
|
2646 |
|
|
/* Invalid member type data format. */
|
2647 |
|
|
return error_type (pp, objfile);
|
2648 |
|
|
++*pp;
|
2649 |
|
|
|
2650 |
|
|
memtype = read_type (pp, objfile);
|
2651 |
|
|
type = dbx_alloc_type (typenums, objfile);
|
2652 |
|
|
smash_to_member_type (type, domain, memtype);
|
2653 |
|
|
}
|
2654 |
|
|
else
|
2655 |
|
|
/* type attribute */
|
2656 |
|
|
{
|
2657 |
|
|
char *attr = *pp;
|
2658 |
|
|
/* Skip to the semicolon. */
|
2659 |
|
|
while (**pp != ';' && **pp != '\0')
|
2660 |
|
|
++(*pp);
|
2661 |
|
|
if (**pp == '\0')
|
2662 |
|
|
return error_type (pp, objfile);
|
2663 |
|
|
else
|
2664 |
|
|
++ * pp; /* Skip the semicolon. */
|
2665 |
|
|
|
2666 |
|
|
switch (*attr)
|
2667 |
|
|
{
|
2668 |
|
|
case 's':
|
2669 |
|
|
type_size = atoi (attr + 1);
|
2670 |
|
|
if (type_size <= 0)
|
2671 |
|
|
type_size = -1;
|
2672 |
|
|
break;
|
2673 |
|
|
|
2674 |
|
|
case 'S':
|
2675 |
|
|
is_string = 1;
|
2676 |
|
|
break;
|
2677 |
|
|
|
2678 |
|
|
default:
|
2679 |
|
|
/* Ignore unrecognized type attributes, so future compilers
|
2680 |
|
|
can invent new ones. */
|
2681 |
|
|
break;
|
2682 |
|
|
}
|
2683 |
|
|
++*pp;
|
2684 |
|
|
goto again;
|
2685 |
|
|
}
|
2686 |
|
|
break;
|
2687 |
|
|
|
2688 |
|
|
case '#': /* Method (class & fn) type */
|
2689 |
|
|
if ((*pp)[0] == '#')
|
2690 |
|
|
{
|
2691 |
|
|
/* We'll get the parameter types from the name. */
|
2692 |
|
|
struct type *return_type;
|
2693 |
|
|
|
2694 |
|
|
(*pp)++;
|
2695 |
|
|
return_type = read_type (pp, objfile);
|
2696 |
|
|
if (*(*pp)++ != ';')
|
2697 |
|
|
complain (&invalid_member_complaint, symnum);
|
2698 |
|
|
type = allocate_stub_method (return_type);
|
2699 |
|
|
if (typenums[0] != -1)
|
2700 |
|
|
*dbx_lookup_type (typenums) = type;
|
2701 |
|
|
}
|
2702 |
|
|
else
|
2703 |
|
|
{
|
2704 |
|
|
struct type *domain = read_type (pp, objfile);
|
2705 |
|
|
struct type *return_type;
|
2706 |
|
|
struct type **args;
|
2707 |
|
|
|
2708 |
|
|
if (**pp != ',')
|
2709 |
|
|
/* Invalid member type data format. */
|
2710 |
|
|
return error_type (pp, objfile);
|
2711 |
|
|
else
|
2712 |
|
|
++(*pp);
|
2713 |
|
|
|
2714 |
|
|
return_type = read_type (pp, objfile);
|
2715 |
|
|
args = read_args (pp, ';', objfile);
|
2716 |
|
|
type = dbx_alloc_type (typenums, objfile);
|
2717 |
|
|
smash_to_method_type (type, domain, return_type, args);
|
2718 |
|
|
}
|
2719 |
|
|
break;
|
2720 |
|
|
|
2721 |
|
|
case 'r': /* Range type */
|
2722 |
|
|
type = read_range_type (pp, typenums, objfile);
|
2723 |
|
|
if (typenums[0] != -1)
|
2724 |
|
|
*dbx_lookup_type (typenums) = type;
|
2725 |
|
|
break;
|
2726 |
|
|
|
2727 |
|
|
case 'b':
|
2728 |
|
|
if (os9k_stabs)
|
2729 |
|
|
/* Const and volatile qualified type. */
|
2730 |
|
|
type = read_type (pp, objfile);
|
2731 |
|
|
else
|
2732 |
|
|
{
|
2733 |
|
|
/* Sun ACC builtin int type */
|
2734 |
|
|
type = read_sun_builtin_type (pp, typenums, objfile);
|
2735 |
|
|
if (typenums[0] != -1)
|
2736 |
|
|
*dbx_lookup_type (typenums) = type;
|
2737 |
|
|
}
|
2738 |
|
|
break;
|
2739 |
|
|
|
2740 |
|
|
case 'R': /* Sun ACC builtin float type */
|
2741 |
|
|
type = read_sun_floating_type (pp, typenums, objfile);
|
2742 |
|
|
if (typenums[0] != -1)
|
2743 |
|
|
*dbx_lookup_type (typenums) = type;
|
2744 |
|
|
break;
|
2745 |
|
|
|
2746 |
|
|
case 'e': /* Enumeration type */
|
2747 |
|
|
type = dbx_alloc_type (typenums, objfile);
|
2748 |
|
|
type = read_enum_type (pp, type, objfile);
|
2749 |
|
|
if (typenums[0] != -1)
|
2750 |
|
|
*dbx_lookup_type (typenums) = type;
|
2751 |
|
|
break;
|
2752 |
|
|
|
2753 |
|
|
case 's': /* Struct type */
|
2754 |
|
|
case 'u': /* Union type */
|
2755 |
|
|
type = dbx_alloc_type (typenums, objfile);
|
2756 |
|
|
switch (type_descriptor)
|
2757 |
|
|
{
|
2758 |
|
|
case 's':
|
2759 |
|
|
TYPE_CODE (type) = TYPE_CODE_STRUCT;
|
2760 |
|
|
break;
|
2761 |
|
|
case 'u':
|
2762 |
|
|
TYPE_CODE (type) = TYPE_CODE_UNION;
|
2763 |
|
|
break;
|
2764 |
|
|
}
|
2765 |
|
|
type = read_struct_type (pp, type, objfile);
|
2766 |
|
|
break;
|
2767 |
|
|
|
2768 |
|
|
case 'a': /* Array type */
|
2769 |
|
|
if (**pp != 'r')
|
2770 |
|
|
return error_type (pp, objfile);
|
2771 |
|
|
++*pp;
|
2772 |
|
|
|
2773 |
|
|
type = dbx_alloc_type (typenums, objfile);
|
2774 |
|
|
type = read_array_type (pp, type, objfile);
|
2775 |
|
|
if (is_string)
|
2776 |
|
|
TYPE_CODE (type) = TYPE_CODE_STRING;
|
2777 |
|
|
break;
|
2778 |
|
|
|
2779 |
|
|
case 'S':
|
2780 |
|
|
type1 = read_type (pp, objfile);
|
2781 |
|
|
type = create_set_type ((struct type *) NULL, type1);
|
2782 |
|
|
if (is_string)
|
2783 |
|
|
TYPE_CODE (type) = TYPE_CODE_BITSTRING;
|
2784 |
|
|
if (typenums[0] != -1)
|
2785 |
|
|
*dbx_lookup_type (typenums) = type;
|
2786 |
|
|
break;
|
2787 |
|
|
|
2788 |
|
|
default:
|
2789 |
|
|
--*pp; /* Go back to the symbol in error */
|
2790 |
|
|
/* Particularly important if it was \0! */
|
2791 |
|
|
return error_type (pp, objfile);
|
2792 |
|
|
}
|
2793 |
|
|
|
2794 |
|
|
if (type == 0)
|
2795 |
|
|
{
|
2796 |
|
|
warning ("GDB internal error, type is NULL in stabsread.c\n");
|
2797 |
|
|
return error_type (pp, objfile);
|
2798 |
|
|
}
|
2799 |
|
|
|
2800 |
|
|
/* Size specified in a type attribute overrides any other size. */
|
2801 |
|
|
if (type_size != -1)
|
2802 |
|
|
TYPE_LENGTH (type) = (type_size + TARGET_CHAR_BIT - 1) / TARGET_CHAR_BIT;
|
2803 |
|
|
|
2804 |
|
|
return type;
|
2805 |
|
|
}
|
2806 |
|
|
|
2807 |
|
|
/* RS/6000 xlc/dbx combination uses a set of builtin types, starting from -1.
|
2808 |
|
|
Return the proper type node for a given builtin type number. */
|
2809 |
|
|
|
2810 |
|
|
static struct type *
|
2811 |
|
|
rs6000_builtin_type (typenum)
|
2812 |
|
|
int typenum;
|
2813 |
|
|
{
|
2814 |
|
|
/* We recognize types numbered from -NUMBER_RECOGNIZED to -1. */
|
2815 |
|
|
#define NUMBER_RECOGNIZED 34
|
2816 |
|
|
/* This includes an empty slot for type number -0. */
|
2817 |
|
|
static struct type *negative_types[NUMBER_RECOGNIZED + 1];
|
2818 |
|
|
struct type *rettype = NULL;
|
2819 |
|
|
|
2820 |
|
|
if (typenum >= 0 || typenum < -NUMBER_RECOGNIZED)
|
2821 |
|
|
{
|
2822 |
|
|
complain (&rs6000_builtin_complaint, typenum);
|
2823 |
|
|
return builtin_type_error;
|
2824 |
|
|
}
|
2825 |
|
|
if (negative_types[-typenum] != NULL)
|
2826 |
|
|
return negative_types[-typenum];
|
2827 |
|
|
|
2828 |
|
|
#if TARGET_CHAR_BIT != 8
|
2829 |
|
|
#error This code wrong for TARGET_CHAR_BIT not 8
|
2830 |
|
|
/* These definitions all assume that TARGET_CHAR_BIT is 8. I think
|
2831 |
|
|
that if that ever becomes not true, the correct fix will be to
|
2832 |
|
|
make the size in the struct type to be in bits, not in units of
|
2833 |
|
|
TARGET_CHAR_BIT. */
|
2834 |
|
|
#endif
|
2835 |
|
|
|
2836 |
|
|
switch (-typenum)
|
2837 |
|
|
{
|
2838 |
|
|
case 1:
|
2839 |
|
|
/* The size of this and all the other types are fixed, defined
|
2840 |
|
|
by the debugging format. If there is a type called "int" which
|
2841 |
|
|
is other than 32 bits, then it should use a new negative type
|
2842 |
|
|
number (or avoid negative type numbers for that case).
|
2843 |
|
|
See stabs.texinfo. */
|
2844 |
|
|
rettype = init_type (TYPE_CODE_INT, 4, 0, "int", NULL);
|
2845 |
|
|
break;
|
2846 |
|
|
case 2:
|
2847 |
|
|
rettype = init_type (TYPE_CODE_INT, 1, 0, "char", NULL);
|
2848 |
|
|
break;
|
2849 |
|
|
case 3:
|
2850 |
|
|
rettype = init_type (TYPE_CODE_INT, 2, 0, "short", NULL);
|
2851 |
|
|
break;
|
2852 |
|
|
case 4:
|
2853 |
|
|
rettype = init_type (TYPE_CODE_INT, 4, 0, "long", NULL);
|
2854 |
|
|
break;
|
2855 |
|
|
case 5:
|
2856 |
|
|
rettype = init_type (TYPE_CODE_INT, 1, TYPE_FLAG_UNSIGNED,
|
2857 |
|
|
"unsigned char", NULL);
|
2858 |
|
|
break;
|
2859 |
|
|
case 6:
|
2860 |
|
|
rettype = init_type (TYPE_CODE_INT, 1, 0, "signed char", NULL);
|
2861 |
|
|
break;
|
2862 |
|
|
case 7:
|
2863 |
|
|
rettype = init_type (TYPE_CODE_INT, 2, TYPE_FLAG_UNSIGNED,
|
2864 |
|
|
"unsigned short", NULL);
|
2865 |
|
|
break;
|
2866 |
|
|
case 8:
|
2867 |
|
|
rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED,
|
2868 |
|
|
"unsigned int", NULL);
|
2869 |
|
|
break;
|
2870 |
|
|
case 9:
|
2871 |
|
|
rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED,
|
2872 |
|
|
"unsigned", NULL);
|
2873 |
|
|
case 10:
|
2874 |
|
|
rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED,
|
2875 |
|
|
"unsigned long", NULL);
|
2876 |
|
|
break;
|
2877 |
|
|
case 11:
|
2878 |
|
|
rettype = init_type (TYPE_CODE_VOID, 1, 0, "void", NULL);
|
2879 |
|
|
break;
|
2880 |
|
|
case 12:
|
2881 |
|
|
/* IEEE single precision (32 bit). */
|
2882 |
|
|
rettype = init_type (TYPE_CODE_FLT, 4, 0, "float", NULL);
|
2883 |
|
|
break;
|
2884 |
|
|
case 13:
|
2885 |
|
|
/* IEEE double precision (64 bit). */
|
2886 |
|
|
rettype = init_type (TYPE_CODE_FLT, 8, 0, "double", NULL);
|
2887 |
|
|
break;
|
2888 |
|
|
case 14:
|
2889 |
|
|
/* This is an IEEE double on the RS/6000, and different machines with
|
2890 |
|
|
different sizes for "long double" should use different negative
|
2891 |
|
|
type numbers. See stabs.texinfo. */
|
2892 |
|
|
rettype = init_type (TYPE_CODE_FLT, 8, 0, "long double", NULL);
|
2893 |
|
|
break;
|
2894 |
|
|
case 15:
|
2895 |
|
|
rettype = init_type (TYPE_CODE_INT, 4, 0, "integer", NULL);
|
2896 |
|
|
break;
|
2897 |
|
|
case 16:
|
2898 |
|
|
rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED,
|
2899 |
|
|
"boolean", NULL);
|
2900 |
|
|
break;
|
2901 |
|
|
case 17:
|
2902 |
|
|
rettype = init_type (TYPE_CODE_FLT, 4, 0, "short real", NULL);
|
2903 |
|
|
break;
|
2904 |
|
|
case 18:
|
2905 |
|
|
rettype = init_type (TYPE_CODE_FLT, 8, 0, "real", NULL);
|
2906 |
|
|
break;
|
2907 |
|
|
case 19:
|
2908 |
|
|
rettype = init_type (TYPE_CODE_ERROR, 0, 0, "stringptr", NULL);
|
2909 |
|
|
break;
|
2910 |
|
|
case 20:
|
2911 |
|
|
rettype = init_type (TYPE_CODE_CHAR, 1, TYPE_FLAG_UNSIGNED,
|
2912 |
|
|
"character", NULL);
|
2913 |
|
|
break;
|
2914 |
|
|
case 21:
|
2915 |
|
|
rettype = init_type (TYPE_CODE_BOOL, 1, TYPE_FLAG_UNSIGNED,
|
2916 |
|
|
"logical*1", NULL);
|
2917 |
|
|
break;
|
2918 |
|
|
case 22:
|
2919 |
|
|
rettype = init_type (TYPE_CODE_BOOL, 2, TYPE_FLAG_UNSIGNED,
|
2920 |
|
|
"logical*2", NULL);
|
2921 |
|
|
break;
|
2922 |
|
|
case 23:
|
2923 |
|
|
rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED,
|
2924 |
|
|
"logical*4", NULL);
|
2925 |
|
|
break;
|
2926 |
|
|
case 24:
|
2927 |
|
|
rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED,
|
2928 |
|
|
"logical", NULL);
|
2929 |
|
|
break;
|
2930 |
|
|
case 25:
|
2931 |
|
|
/* Complex type consisting of two IEEE single precision values. */
|
2932 |
|
|
rettype = init_type (TYPE_CODE_COMPLEX, 8, 0, "complex", NULL);
|
2933 |
|
|
break;
|
2934 |
|
|
case 26:
|
2935 |
|
|
/* Complex type consisting of two IEEE double precision values. */
|
2936 |
|
|
rettype = init_type (TYPE_CODE_COMPLEX, 16, 0, "double complex", NULL);
|
2937 |
|
|
break;
|
2938 |
|
|
case 27:
|
2939 |
|
|
rettype = init_type (TYPE_CODE_INT, 1, 0, "integer*1", NULL);
|
2940 |
|
|
break;
|
2941 |
|
|
case 28:
|
2942 |
|
|
rettype = init_type (TYPE_CODE_INT, 2, 0, "integer*2", NULL);
|
2943 |
|
|
break;
|
2944 |
|
|
case 29:
|
2945 |
|
|
rettype = init_type (TYPE_CODE_INT, 4, 0, "integer*4", NULL);
|
2946 |
|
|
break;
|
2947 |
|
|
case 30:
|
2948 |
|
|
rettype = init_type (TYPE_CODE_CHAR, 2, 0, "wchar", NULL);
|
2949 |
|
|
break;
|
2950 |
|
|
case 31:
|
2951 |
|
|
rettype = init_type (TYPE_CODE_INT, 8, 0, "long long", NULL);
|
2952 |
|
|
break;
|
2953 |
|
|
case 32:
|
2954 |
|
|
rettype = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED,
|
2955 |
|
|
"unsigned long long", NULL);
|
2956 |
|
|
break;
|
2957 |
|
|
case 33:
|
2958 |
|
|
rettype = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED,
|
2959 |
|
|
"logical*8", NULL);
|
2960 |
|
|
break;
|
2961 |
|
|
case 34:
|
2962 |
|
|
rettype = init_type (TYPE_CODE_INT, 8, 0, "integer*8", NULL);
|
2963 |
|
|
break;
|
2964 |
|
|
}
|
2965 |
|
|
negative_types[-typenum] = rettype;
|
2966 |
|
|
return rettype;
|
2967 |
|
|
}
|
2968 |
|
|
|
2969 |
|
|
/* This page contains subroutines of read_type. */
|
2970 |
|
|
|
2971 |
|
|
/* Read member function stabs info for C++ classes. The form of each member
|
2972 |
|
|
function data is:
|
2973 |
|
|
|
2974 |
|
|
NAME :: TYPENUM[=type definition] ARGS : PHYSNAME ;
|
2975 |
|
|
|
2976 |
|
|
An example with two member functions is:
|
2977 |
|
|
|
2978 |
|
|
afunc1::20=##15;:i;2A.;afunc2::20:i;2A.;
|
2979 |
|
|
|
2980 |
|
|
For the case of overloaded operators, the format is op$::*.funcs, where
|
2981 |
|
|
$ is the CPLUS_MARKER (usually '$'), `*' holds the place for an operator
|
2982 |
|
|
name (such as `+=') and `.' marks the end of the operator name.
|
2983 |
|
|
|
2984 |
|
|
Returns 1 for success, 0 for failure. */
|
2985 |
|
|
|
2986 |
|
|
static int
|
2987 |
|
|
read_member_functions (fip, pp, type, objfile)
|
2988 |
|
|
struct field_info *fip;
|
2989 |
|
|
char **pp;
|
2990 |
|
|
struct type *type;
|
2991 |
|
|
struct objfile *objfile;
|
2992 |
|
|
{
|
2993 |
|
|
int nfn_fields = 0;
|
2994 |
|
|
int length = 0;
|
2995 |
|
|
/* Total number of member functions defined in this class. If the class
|
2996 |
|
|
defines two `f' functions, and one `g' function, then this will have
|
2997 |
|
|
the value 3. */
|
2998 |
|
|
int total_length = 0;
|
2999 |
|
|
int i;
|
3000 |
|
|
struct next_fnfield
|
3001 |
|
|
{
|
3002 |
|
|
struct next_fnfield *next;
|
3003 |
|
|
struct fn_field fn_field;
|
3004 |
|
|
}
|
3005 |
|
|
*sublist;
|
3006 |
|
|
struct type *look_ahead_type;
|
3007 |
|
|
struct next_fnfieldlist *new_fnlist;
|
3008 |
|
|
struct next_fnfield *new_sublist;
|
3009 |
|
|
char *main_fn_name;
|
3010 |
|
|
register char *p;
|
3011 |
|
|
|
3012 |
|
|
/* Process each list until we find something that is not a member function
|
3013 |
|
|
or find the end of the functions. */
|
3014 |
|
|
|
3015 |
|
|
while (**pp != ';')
|
3016 |
|
|
{
|
3017 |
|
|
/* We should be positioned at the start of the function name.
|
3018 |
|
|
Scan forward to find the first ':' and if it is not the
|
3019 |
|
|
first of a "::" delimiter, then this is not a member function. */
|
3020 |
|
|
p = *pp;
|
3021 |
|
|
while (*p != ':')
|
3022 |
|
|
{
|
3023 |
|
|
p++;
|
3024 |
|
|
}
|
3025 |
|
|
if (p[1] != ':')
|
3026 |
|
|
{
|
3027 |
|
|
break;
|
3028 |
|
|
}
|
3029 |
|
|
|
3030 |
|
|
sublist = NULL;
|
3031 |
|
|
look_ahead_type = NULL;
|
3032 |
|
|
length = 0;
|
3033 |
|
|
|
3034 |
|
|
new_fnlist = (struct next_fnfieldlist *)
|
3035 |
|
|
xmalloc (sizeof (struct next_fnfieldlist));
|
3036 |
|
|
make_cleanup (free, new_fnlist);
|
3037 |
|
|
memset (new_fnlist, 0, sizeof (struct next_fnfieldlist));
|
3038 |
|
|
|
3039 |
|
|
if ((*pp)[0] == 'o' && (*pp)[1] == 'p' && is_cplus_marker ((*pp)[2]))
|
3040 |
|
|
{
|
3041 |
|
|
/* This is a completely wierd case. In order to stuff in the
|
3042 |
|
|
names that might contain colons (the usual name delimiter),
|
3043 |
|
|
Mike Tiemann defined a different name format which is
|
3044 |
|
|
signalled if the identifier is "op$". In that case, the
|
3045 |
|
|
format is "op$::XXXX." where XXXX is the name. This is
|
3046 |
|
|
used for names like "+" or "=". YUUUUUUUK! FIXME! */
|
3047 |
|
|
/* This lets the user type "break operator+".
|
3048 |
|
|
We could just put in "+" as the name, but that wouldn't
|
3049 |
|
|
work for "*". */
|
3050 |
|
|
static char opname[32] =
|
3051 |
|
|
{'o', 'p', CPLUS_MARKER};
|
3052 |
|
|
char *o = opname + 3;
|
3053 |
|
|
|
3054 |
|
|
/* Skip past '::'. */
|
3055 |
|
|
*pp = p + 2;
|
3056 |
|
|
|
3057 |
|
|
STABS_CONTINUE (pp, objfile);
|
3058 |
|
|
p = *pp;
|
3059 |
|
|
while (*p != '.')
|
3060 |
|
|
{
|
3061 |
|
|
*o++ = *p++;
|
3062 |
|
|
}
|
3063 |
|
|
main_fn_name = savestring (opname, o - opname);
|
3064 |
|
|
/* Skip past '.' */
|
3065 |
|
|
*pp = p + 1;
|
3066 |
|
|
}
|
3067 |
|
|
else
|
3068 |
|
|
{
|
3069 |
|
|
main_fn_name = savestring (*pp, p - *pp);
|
3070 |
|
|
/* Skip past '::'. */
|
3071 |
|
|
*pp = p + 2;
|
3072 |
|
|
}
|
3073 |
|
|
new_fnlist->fn_fieldlist.name = main_fn_name;
|
3074 |
|
|
|
3075 |
|
|
do
|
3076 |
|
|
{
|
3077 |
|
|
new_sublist =
|
3078 |
|
|
(struct next_fnfield *) xmalloc (sizeof (struct next_fnfield));
|
3079 |
|
|
make_cleanup (free, new_sublist);
|
3080 |
|
|
memset (new_sublist, 0, sizeof (struct next_fnfield));
|
3081 |
|
|
|
3082 |
|
|
/* Check for and handle cretinous dbx symbol name continuation! */
|
3083 |
|
|
if (look_ahead_type == NULL)
|
3084 |
|
|
{
|
3085 |
|
|
/* Normal case. */
|
3086 |
|
|
STABS_CONTINUE (pp, objfile);
|
3087 |
|
|
|
3088 |
|
|
new_sublist->fn_field.type = read_type (pp, objfile);
|
3089 |
|
|
if (**pp != ':')
|
3090 |
|
|
{
|
3091 |
|
|
/* Invalid symtab info for member function. */
|
3092 |
|
|
return 0;
|
3093 |
|
|
}
|
3094 |
|
|
}
|
3095 |
|
|
else
|
3096 |
|
|
{
|
3097 |
|
|
/* g++ version 1 kludge */
|
3098 |
|
|
new_sublist->fn_field.type = look_ahead_type;
|
3099 |
|
|
look_ahead_type = NULL;
|
3100 |
|
|
}
|
3101 |
|
|
|
3102 |
|
|
(*pp)++;
|
3103 |
|
|
p = *pp;
|
3104 |
|
|
while (*p != ';')
|
3105 |
|
|
{
|
3106 |
|
|
p++;
|
3107 |
|
|
}
|
3108 |
|
|
|
3109 |
|
|
/* If this is just a stub, then we don't have the real name here. */
|
3110 |
|
|
|
3111 |
|
|
if (TYPE_FLAGS (new_sublist->fn_field.type) & TYPE_FLAG_STUB)
|
3112 |
|
|
{
|
3113 |
|
|
if (!TYPE_DOMAIN_TYPE (new_sublist->fn_field.type))
|
3114 |
|
|
TYPE_DOMAIN_TYPE (new_sublist->fn_field.type) = type;
|
3115 |
|
|
new_sublist->fn_field.is_stub = 1;
|
3116 |
|
|
}
|
3117 |
|
|
new_sublist->fn_field.physname = savestring (*pp, p - *pp);
|
3118 |
|
|
*pp = p + 1;
|
3119 |
|
|
|
3120 |
|
|
/* Set this member function's visibility fields. */
|
3121 |
|
|
switch (*(*pp)++)
|
3122 |
|
|
{
|
3123 |
|
|
case VISIBILITY_PRIVATE:
|
3124 |
|
|
new_sublist->fn_field.is_private = 1;
|
3125 |
|
|
break;
|
3126 |
|
|
case VISIBILITY_PROTECTED:
|
3127 |
|
|
new_sublist->fn_field.is_protected = 1;
|
3128 |
|
|
break;
|
3129 |
|
|
}
|
3130 |
|
|
|
3131 |
|
|
STABS_CONTINUE (pp, objfile);
|
3132 |
|
|
switch (**pp)
|
3133 |
|
|
{
|
3134 |
|
|
case 'A': /* Normal functions. */
|
3135 |
|
|
new_sublist->fn_field.is_const = 0;
|
3136 |
|
|
new_sublist->fn_field.is_volatile = 0;
|
3137 |
|
|
(*pp)++;
|
3138 |
|
|
break;
|
3139 |
|
|
case 'B': /* `const' member functions. */
|
3140 |
|
|
new_sublist->fn_field.is_const = 1;
|
3141 |
|
|
new_sublist->fn_field.is_volatile = 0;
|
3142 |
|
|
(*pp)++;
|
3143 |
|
|
break;
|
3144 |
|
|
case 'C': /* `volatile' member function. */
|
3145 |
|
|
new_sublist->fn_field.is_const = 0;
|
3146 |
|
|
new_sublist->fn_field.is_volatile = 1;
|
3147 |
|
|
(*pp)++;
|
3148 |
|
|
break;
|
3149 |
|
|
case 'D': /* `const volatile' member function. */
|
3150 |
|
|
new_sublist->fn_field.is_const = 1;
|
3151 |
|
|
new_sublist->fn_field.is_volatile = 1;
|
3152 |
|
|
(*pp)++;
|
3153 |
|
|
break;
|
3154 |
|
|
case '*': /* File compiled with g++ version 1 -- no info */
|
3155 |
|
|
case '?':
|
3156 |
|
|
case '.':
|
3157 |
|
|
break;
|
3158 |
|
|
default:
|
3159 |
|
|
complain (&const_vol_complaint, **pp);
|
3160 |
|
|
break;
|
3161 |
|
|
}
|
3162 |
|
|
|
3163 |
|
|
switch (*(*pp)++)
|
3164 |
|
|
{
|
3165 |
|
|
case '*':
|
3166 |
|
|
{
|
3167 |
|
|
int nbits;
|
3168 |
|
|
/* virtual member function, followed by index.
|
3169 |
|
|
The sign bit is set to distinguish pointers-to-methods
|
3170 |
|
|
from virtual function indicies. Since the array is
|
3171 |
|
|
in words, the quantity must be shifted left by 1
|
3172 |
|
|
on 16 bit machine, and by 2 on 32 bit machine, forcing
|
3173 |
|
|
the sign bit out, and usable as a valid index into
|
3174 |
|
|
the array. Remove the sign bit here. */
|
3175 |
|
|
new_sublist->fn_field.voffset =
|
3176 |
|
|
(0x7fffffff & read_huge_number (pp, ';', &nbits)) + 2;
|
3177 |
|
|
if (nbits != 0)
|
3178 |
|
|
return 0;
|
3179 |
|
|
|
3180 |
|
|
STABS_CONTINUE (pp, objfile);
|
3181 |
|
|
if (**pp == ';' || **pp == '\0')
|
3182 |
|
|
{
|
3183 |
|
|
/* Must be g++ version 1. */
|
3184 |
|
|
new_sublist->fn_field.fcontext = 0;
|
3185 |
|
|
}
|
3186 |
|
|
else
|
3187 |
|
|
{
|
3188 |
|
|
/* Figure out from whence this virtual function came.
|
3189 |
|
|
It may belong to virtual function table of
|
3190 |
|
|
one of its baseclasses. */
|
3191 |
|
|
look_ahead_type = read_type (pp, objfile);
|
3192 |
|
|
if (**pp == ':')
|
3193 |
|
|
{
|
3194 |
|
|
/* g++ version 1 overloaded methods. */
|
3195 |
|
|
}
|
3196 |
|
|
else
|
3197 |
|
|
{
|
3198 |
|
|
new_sublist->fn_field.fcontext = look_ahead_type;
|
3199 |
|
|
if (**pp != ';')
|
3200 |
|
|
{
|
3201 |
|
|
return 0;
|
3202 |
|
|
}
|
3203 |
|
|
else
|
3204 |
|
|
{
|
3205 |
|
|
++*pp;
|
3206 |
|
|
}
|
3207 |
|
|
look_ahead_type = NULL;
|
3208 |
|
|
}
|
3209 |
|
|
}
|
3210 |
|
|
break;
|
3211 |
|
|
}
|
3212 |
|
|
case '?':
|
3213 |
|
|
/* static member function. */
|
3214 |
|
|
new_sublist->fn_field.voffset = VOFFSET_STATIC;
|
3215 |
|
|
if (strncmp (new_sublist->fn_field.physname,
|
3216 |
|
|
main_fn_name, strlen (main_fn_name)))
|
3217 |
|
|
{
|
3218 |
|
|
new_sublist->fn_field.is_stub = 1;
|
3219 |
|
|
}
|
3220 |
|
|
break;
|
3221 |
|
|
|
3222 |
|
|
default:
|
3223 |
|
|
/* error */
|
3224 |
|
|
complain (&member_fn_complaint, (*pp)[-1]);
|
3225 |
|
|
/* Fall through into normal member function. */
|
3226 |
|
|
|
3227 |
|
|
case '.':
|
3228 |
|
|
/* normal member function. */
|
3229 |
|
|
new_sublist->fn_field.voffset = 0;
|
3230 |
|
|
new_sublist->fn_field.fcontext = 0;
|
3231 |
|
|
break;
|
3232 |
|
|
}
|
3233 |
|
|
|
3234 |
|
|
new_sublist->next = sublist;
|
3235 |
|
|
sublist = new_sublist;
|
3236 |
|
|
length++;
|
3237 |
|
|
STABS_CONTINUE (pp, objfile);
|
3238 |
|
|
}
|
3239 |
|
|
while (**pp != ';' && **pp != '\0');
|
3240 |
|
|
|
3241 |
|
|
(*pp)++;
|
3242 |
|
|
|
3243 |
|
|
new_fnlist->fn_fieldlist.fn_fields = (struct fn_field *)
|
3244 |
|
|
obstack_alloc (&objfile->type_obstack,
|
3245 |
|
|
sizeof (struct fn_field) * length);
|
3246 |
|
|
memset (new_fnlist->fn_fieldlist.fn_fields, 0,
|
3247 |
|
|
sizeof (struct fn_field) * length);
|
3248 |
|
|
for (i = length; (i--, sublist); sublist = sublist->next)
|
3249 |
|
|
{
|
3250 |
|
|
new_fnlist->fn_fieldlist.fn_fields[i] = sublist->fn_field;
|
3251 |
|
|
}
|
3252 |
|
|
|
3253 |
|
|
new_fnlist->fn_fieldlist.length = length;
|
3254 |
|
|
new_fnlist->next = fip->fnlist;
|
3255 |
|
|
fip->fnlist = new_fnlist;
|
3256 |
|
|
nfn_fields++;
|
3257 |
|
|
total_length += length;
|
3258 |
|
|
STABS_CONTINUE (pp, objfile);
|
3259 |
|
|
}
|
3260 |
|
|
|
3261 |
|
|
if (nfn_fields)
|
3262 |
|
|
{
|
3263 |
|
|
ALLOCATE_CPLUS_STRUCT_TYPE (type);
|
3264 |
|
|
TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *)
|
3265 |
|
|
TYPE_ALLOC (type, sizeof (struct fn_fieldlist) * nfn_fields);
|
3266 |
|
|
memset (TYPE_FN_FIELDLISTS (type), 0,
|
3267 |
|
|
sizeof (struct fn_fieldlist) * nfn_fields);
|
3268 |
|
|
TYPE_NFN_FIELDS (type) = nfn_fields;
|
3269 |
|
|
TYPE_NFN_FIELDS_TOTAL (type) = total_length;
|
3270 |
|
|
}
|
3271 |
|
|
|
3272 |
|
|
return 1;
|
3273 |
|
|
}
|
3274 |
|
|
|
3275 |
|
|
/* Special GNU C++ name.
|
3276 |
|
|
|
3277 |
|
|
Returns 1 for success, 0 for failure. "failure" means that we can't
|
3278 |
|
|
keep parsing and it's time for error_type(). */
|
3279 |
|
|
|
3280 |
|
|
static int
|
3281 |
|
|
read_cpp_abbrev (fip, pp, type, objfile)
|
3282 |
|
|
struct field_info *fip;
|
3283 |
|
|
char **pp;
|
3284 |
|
|
struct type *type;
|
3285 |
|
|
struct objfile *objfile;
|
3286 |
|
|
{
|
3287 |
|
|
register char *p;
|
3288 |
|
|
char *name;
|
3289 |
|
|
char cpp_abbrev;
|
3290 |
|
|
struct type *context;
|
3291 |
|
|
|
3292 |
|
|
p = *pp;
|
3293 |
|
|
if (*++p == 'v')
|
3294 |
|
|
{
|
3295 |
|
|
name = NULL;
|
3296 |
|
|
cpp_abbrev = *++p;
|
3297 |
|
|
|
3298 |
|
|
*pp = p + 1;
|
3299 |
|
|
|
3300 |
|
|
/* At this point, *pp points to something like "22:23=*22...",
|
3301 |
|
|
where the type number before the ':' is the "context" and
|
3302 |
|
|
everything after is a regular type definition. Lookup the
|
3303 |
|
|
type, find it's name, and construct the field name. */
|
3304 |
|
|
|
3305 |
|
|
context = read_type (pp, objfile);
|
3306 |
|
|
|
3307 |
|
|
switch (cpp_abbrev)
|
3308 |
|
|
{
|
3309 |
|
|
case 'f': /* $vf -- a virtual function table pointer */
|
3310 |
|
|
fip->list->field.name =
|
3311 |
|
|
obconcat (&objfile->type_obstack, vptr_name, "", "");
|
3312 |
|
|
break;
|
3313 |
|
|
|
3314 |
|
|
case 'b': /* $vb -- a virtual bsomethingorother */
|
3315 |
|
|
name = type_name_no_tag (context);
|
3316 |
|
|
if (name == NULL)
|
3317 |
|
|
{
|
3318 |
|
|
complain (&invalid_cpp_type_complaint, symnum);
|
3319 |
|
|
name = "FOO";
|
3320 |
|
|
}
|
3321 |
|
|
fip->list->field.name =
|
3322 |
|
|
obconcat (&objfile->type_obstack, vb_name, name, "");
|
3323 |
|
|
break;
|
3324 |
|
|
|
3325 |
|
|
default:
|
3326 |
|
|
complain (&invalid_cpp_abbrev_complaint, *pp);
|
3327 |
|
|
fip->list->field.name =
|
3328 |
|
|
obconcat (&objfile->type_obstack,
|
3329 |
|
|
"INVALID_CPLUSPLUS_ABBREV", "", "");
|
3330 |
|
|
break;
|
3331 |
|
|
}
|
3332 |
|
|
|
3333 |
|
|
/* At this point, *pp points to the ':'. Skip it and read the
|
3334 |
|
|
field type. */
|
3335 |
|
|
|
3336 |
|
|
p = ++(*pp);
|
3337 |
|
|
if (p[-1] != ':')
|
3338 |
|
|
{
|
3339 |
|
|
complain (&invalid_cpp_abbrev_complaint, *pp);
|
3340 |
|
|
return 0;
|
3341 |
|
|
}
|
3342 |
|
|
fip->list->field.type = read_type (pp, objfile);
|
3343 |
|
|
if (**pp == ',')
|
3344 |
|
|
(*pp)++; /* Skip the comma. */
|
3345 |
|
|
else
|
3346 |
|
|
return 0;
|
3347 |
|
|
|
3348 |
|
|
{
|
3349 |
|
|
int nbits;
|
3350 |
|
|
FIELD_BITPOS (fip->list->field) = read_huge_number (pp, ';', &nbits);
|
3351 |
|
|
if (nbits != 0)
|
3352 |
|
|
return 0;
|
3353 |
|
|
}
|
3354 |
|
|
/* This field is unpacked. */
|
3355 |
|
|
FIELD_BITSIZE (fip->list->field) = 0;
|
3356 |
|
|
fip->list->visibility = VISIBILITY_PRIVATE;
|
3357 |
|
|
}
|
3358 |
|
|
else
|
3359 |
|
|
{
|
3360 |
|
|
complain (&invalid_cpp_abbrev_complaint, *pp);
|
3361 |
|
|
/* We have no idea what syntax an unrecognized abbrev would have, so
|
3362 |
|
|
better return 0. If we returned 1, we would need to at least advance
|
3363 |
|
|
*pp to avoid an infinite loop. */
|
3364 |
|
|
return 0;
|
3365 |
|
|
}
|
3366 |
|
|
return 1;
|
3367 |
|
|
}
|
3368 |
|
|
|
3369 |
|
|
static void
|
3370 |
|
|
read_one_struct_field (fip, pp, p, type, objfile)
|
3371 |
|
|
struct field_info *fip;
|
3372 |
|
|
char **pp;
|
3373 |
|
|
char *p;
|
3374 |
|
|
struct type *type;
|
3375 |
|
|
struct objfile *objfile;
|
3376 |
|
|
{
|
3377 |
|
|
/* The following is code to work around cfront generated stabs.
|
3378 |
|
|
The stabs contains full mangled name for each field.
|
3379 |
|
|
We try to demangle the name and extract the field name out of it.
|
3380 |
|
|
*/
|
3381 |
|
|
if (ARM_DEMANGLING && current_subfile->language == language_cplus)
|
3382 |
|
|
{
|
3383 |
|
|
char save_p;
|
3384 |
|
|
char *dem, *dem_p;
|
3385 |
|
|
save_p = *p;
|
3386 |
|
|
*p = '\0';
|
3387 |
|
|
dem = cplus_demangle (*pp, DMGL_ANSI | DMGL_PARAMS);
|
3388 |
|
|
if (dem != NULL)
|
3389 |
|
|
{
|
3390 |
|
|
dem_p = strrchr (dem, ':');
|
3391 |
|
|
if (dem_p != 0 && *(dem_p - 1) == ':')
|
3392 |
|
|
dem_p++;
|
3393 |
|
|
FIELD_NAME (fip->list->field) =
|
3394 |
|
|
obsavestring (dem_p, strlen (dem_p), &objfile->type_obstack);
|
3395 |
|
|
}
|
3396 |
|
|
else
|
3397 |
|
|
{
|
3398 |
|
|
FIELD_NAME (fip->list->field) =
|
3399 |
|
|
obsavestring (*pp, p - *pp, &objfile->type_obstack);
|
3400 |
|
|
}
|
3401 |
|
|
*p = save_p;
|
3402 |
|
|
}
|
3403 |
|
|
/* end of code for cfront work around */
|
3404 |
|
|
|
3405 |
|
|
else
|
3406 |
|
|
fip->list->field.name =
|
3407 |
|
|
obsavestring (*pp, p - *pp, &objfile->type_obstack);
|
3408 |
|
|
*pp = p + 1;
|
3409 |
|
|
|
3410 |
|
|
/* This means we have a visibility for a field coming. */
|
3411 |
|
|
if (**pp == '/')
|
3412 |
|
|
{
|
3413 |
|
|
(*pp)++;
|
3414 |
|
|
fip->list->visibility = *(*pp)++;
|
3415 |
|
|
}
|
3416 |
|
|
else
|
3417 |
|
|
{
|
3418 |
|
|
/* normal dbx-style format, no explicit visibility */
|
3419 |
|
|
fip->list->visibility = VISIBILITY_PUBLIC;
|
3420 |
|
|
}
|
3421 |
|
|
|
3422 |
|
|
fip->list->field.type = read_type (pp, objfile);
|
3423 |
|
|
if (**pp == ':')
|
3424 |
|
|
{
|
3425 |
|
|
p = ++(*pp);
|
3426 |
|
|
#if 0
|
3427 |
|
|
/* Possible future hook for nested types. */
|
3428 |
|
|
if (**pp == '!')
|
3429 |
|
|
{
|
3430 |
|
|
fip->list->field.bitpos = (long) -2; /* nested type */
|
3431 |
|
|
p = ++(*pp);
|
3432 |
|
|
}
|
3433 |
|
|
else
|
3434 |
|
|
...;
|
3435 |
|
|
#endif
|
3436 |
|
|
while (*p != ';')
|
3437 |
|
|
{
|
3438 |
|
|
p++;
|
3439 |
|
|
}
|
3440 |
|
|
/* Static class member. */
|
3441 |
|
|
SET_FIELD_PHYSNAME (fip->list->field, savestring (*pp, p - *pp));
|
3442 |
|
|
*pp = p + 1;
|
3443 |
|
|
return;
|
3444 |
|
|
}
|
3445 |
|
|
else if (**pp != ',')
|
3446 |
|
|
{
|
3447 |
|
|
/* Bad structure-type format. */
|
3448 |
|
|
complain (&stabs_general_complaint, "bad structure-type format");
|
3449 |
|
|
return;
|
3450 |
|
|
}
|
3451 |
|
|
|
3452 |
|
|
(*pp)++; /* Skip the comma. */
|
3453 |
|
|
|
3454 |
|
|
{
|
3455 |
|
|
int nbits;
|
3456 |
|
|
FIELD_BITPOS (fip->list->field) = read_huge_number (pp, ',', &nbits);
|
3457 |
|
|
if (nbits != 0)
|
3458 |
|
|
{
|
3459 |
|
|
complain (&stabs_general_complaint, "bad structure-type format");
|
3460 |
|
|
return;
|
3461 |
|
|
}
|
3462 |
|
|
FIELD_BITSIZE (fip->list->field) = read_huge_number (pp, ';', &nbits);
|
3463 |
|
|
if (nbits != 0)
|
3464 |
|
|
{
|
3465 |
|
|
complain (&stabs_general_complaint, "bad structure-type format");
|
3466 |
|
|
return;
|
3467 |
|
|
}
|
3468 |
|
|
}
|
3469 |
|
|
|
3470 |
|
|
if (FIELD_BITPOS (fip->list->field) == 0
|
3471 |
|
|
&& FIELD_BITSIZE (fip->list->field) == 0)
|
3472 |
|
|
{
|
3473 |
|
|
/* This can happen in two cases: (1) at least for gcc 2.4.5 or so,
|
3474 |
|
|
it is a field which has been optimized out. The correct stab for
|
3475 |
|
|
this case is to use VISIBILITY_IGNORE, but that is a recent
|
3476 |
|
|
invention. (2) It is a 0-size array. For example
|
3477 |
|
|
union { int num; char str[0]; } foo. Printing "<no value>" for
|
3478 |
|
|
str in "p foo" is OK, since foo.str (and thus foo.str[3])
|
3479 |
|
|
will continue to work, and a 0-size array as a whole doesn't
|
3480 |
|
|
have any contents to print.
|
3481 |
|
|
|
3482 |
|
|
I suspect this probably could also happen with gcc -gstabs (not
|
3483 |
|
|
-gstabs+) for static fields, and perhaps other C++ extensions.
|
3484 |
|
|
Hopefully few people use -gstabs with gdb, since it is intended
|
3485 |
|
|
for dbx compatibility. */
|
3486 |
|
|
|
3487 |
|
|
/* Ignore this field. */
|
3488 |
|
|
fip->list->visibility = VISIBILITY_IGNORE;
|
3489 |
|
|
}
|
3490 |
|
|
else
|
3491 |
|
|
{
|
3492 |
|
|
/* Detect an unpacked field and mark it as such.
|
3493 |
|
|
dbx gives a bit size for all fields.
|
3494 |
|
|
Note that forward refs cannot be packed,
|
3495 |
|
|
and treat enums as if they had the width of ints. */
|
3496 |
|
|
|
3497 |
|
|
struct type *field_type = check_typedef (FIELD_TYPE (fip->list->field));
|
3498 |
|
|
|
3499 |
|
|
if (TYPE_CODE (field_type) != TYPE_CODE_INT
|
3500 |
|
|
&& TYPE_CODE (field_type) != TYPE_CODE_RANGE
|
3501 |
|
|
&& TYPE_CODE (field_type) != TYPE_CODE_BOOL
|
3502 |
|
|
&& TYPE_CODE (field_type) != TYPE_CODE_ENUM)
|
3503 |
|
|
{
|
3504 |
|
|
FIELD_BITSIZE (fip->list->field) = 0;
|
3505 |
|
|
}
|
3506 |
|
|
if ((FIELD_BITSIZE (fip->list->field)
|
3507 |
|
|
== TARGET_CHAR_BIT * TYPE_LENGTH (field_type)
|
3508 |
|
|
|| (TYPE_CODE (field_type) == TYPE_CODE_ENUM
|
3509 |
|
|
&& FIELD_BITSIZE (fip->list->field) == TARGET_INT_BIT)
|
3510 |
|
|
)
|
3511 |
|
|
&&
|
3512 |
|
|
FIELD_BITPOS (fip->list->field) % 8 == 0)
|
3513 |
|
|
{
|
3514 |
|
|
FIELD_BITSIZE (fip->list->field) = 0;
|
3515 |
|
|
}
|
3516 |
|
|
}
|
3517 |
|
|
}
|
3518 |
|
|
|
3519 |
|
|
|
3520 |
|
|
/* Read struct or class data fields. They have the form:
|
3521 |
|
|
|
3522 |
|
|
NAME : [VISIBILITY] TYPENUM , BITPOS , BITSIZE ;
|
3523 |
|
|
|
3524 |
|
|
At the end, we see a semicolon instead of a field.
|
3525 |
|
|
|
3526 |
|
|
In C++, this may wind up being NAME:?TYPENUM:PHYSNAME; for
|
3527 |
|
|
a static field.
|
3528 |
|
|
|
3529 |
|
|
The optional VISIBILITY is one of:
|
3530 |
|
|
|
3531 |
|
|
'/0' (VISIBILITY_PRIVATE)
|
3532 |
|
|
'/1' (VISIBILITY_PROTECTED)
|
3533 |
|
|
'/2' (VISIBILITY_PUBLIC)
|
3534 |
|
|
'/9' (VISIBILITY_IGNORE)
|
3535 |
|
|
|
3536 |
|
|
or nothing, for C style fields with public visibility.
|
3537 |
|
|
|
3538 |
|
|
Returns 1 for success, 0 for failure. */
|
3539 |
|
|
|
3540 |
|
|
static int
|
3541 |
|
|
read_struct_fields (fip, pp, type, objfile)
|
3542 |
|
|
struct field_info *fip;
|
3543 |
|
|
char **pp;
|
3544 |
|
|
struct type *type;
|
3545 |
|
|
struct objfile *objfile;
|
3546 |
|
|
{
|
3547 |
|
|
register char *p;
|
3548 |
|
|
struct nextfield *new;
|
3549 |
|
|
|
3550 |
|
|
/* We better set p right now, in case there are no fields at all... */
|
3551 |
|
|
|
3552 |
|
|
p = *pp;
|
3553 |
|
|
|
3554 |
|
|
/* Read each data member type until we find the terminating ';' at the end of
|
3555 |
|
|
the data member list, or break for some other reason such as finding the
|
3556 |
|
|
start of the member function list. */
|
3557 |
|
|
|
3558 |
|
|
while (**pp != ';')
|
3559 |
|
|
{
|
3560 |
|
|
if (os9k_stabs && **pp == ',')
|
3561 |
|
|
break;
|
3562 |
|
|
STABS_CONTINUE (pp, objfile);
|
3563 |
|
|
/* Get space to record the next field's data. */
|
3564 |
|
|
new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
|
3565 |
|
|
make_cleanup (free, new);
|
3566 |
|
|
memset (new, 0, sizeof (struct nextfield));
|
3567 |
|
|
new->next = fip->list;
|
3568 |
|
|
fip->list = new;
|
3569 |
|
|
|
3570 |
|
|
/* Get the field name. */
|
3571 |
|
|
p = *pp;
|
3572 |
|
|
|
3573 |
|
|
/* If is starts with CPLUS_MARKER it is a special abbreviation,
|
3574 |
|
|
unless the CPLUS_MARKER is followed by an underscore, in
|
3575 |
|
|
which case it is just the name of an anonymous type, which we
|
3576 |
|
|
should handle like any other type name. */
|
3577 |
|
|
|
3578 |
|
|
if (is_cplus_marker (p[0]) && p[1] != '_')
|
3579 |
|
|
{
|
3580 |
|
|
if (!read_cpp_abbrev (fip, pp, type, objfile))
|
3581 |
|
|
return 0;
|
3582 |
|
|
continue;
|
3583 |
|
|
}
|
3584 |
|
|
|
3585 |
|
|
/* Look for the ':' that separates the field name from the field
|
3586 |
|
|
values. Data members are delimited by a single ':', while member
|
3587 |
|
|
functions are delimited by a pair of ':'s. When we hit the member
|
3588 |
|
|
functions (if any), terminate scan loop and return. */
|
3589 |
|
|
|
3590 |
|
|
while (*p != ':' && *p != '\0')
|
3591 |
|
|
{
|
3592 |
|
|
p++;
|
3593 |
|
|
}
|
3594 |
|
|
if (*p == '\0')
|
3595 |
|
|
return 0;
|
3596 |
|
|
|
3597 |
|
|
/* Check to see if we have hit the member functions yet. */
|
3598 |
|
|
if (p[1] == ':')
|
3599 |
|
|
{
|
3600 |
|
|
break;
|
3601 |
|
|
}
|
3602 |
|
|
read_one_struct_field (fip, pp, p, type, objfile);
|
3603 |
|
|
}
|
3604 |
|
|
if (p[0] == ':' && p[1] == ':')
|
3605 |
|
|
{
|
3606 |
|
|
/* chill the list of fields: the last entry (at the head) is a
|
3607 |
|
|
partially constructed entry which we now scrub. */
|
3608 |
|
|
fip->list = fip->list->next;
|
3609 |
|
|
}
|
3610 |
|
|
return 1;
|
3611 |
|
|
}
|
3612 |
|
|
/* *INDENT-OFF* */
|
3613 |
|
|
/* The stabs for C++ derived classes contain baseclass information which
|
3614 |
|
|
is marked by a '!' character after the total size. This function is
|
3615 |
|
|
called when we encounter the baseclass marker, and slurps up all the
|
3616 |
|
|
baseclass information.
|
3617 |
|
|
|
3618 |
|
|
Immediately following the '!' marker is the number of base classes that
|
3619 |
|
|
the class is derived from, followed by information for each base class.
|
3620 |
|
|
For each base class, there are two visibility specifiers, a bit offset
|
3621 |
|
|
to the base class information within the derived class, a reference to
|
3622 |
|
|
the type for the base class, and a terminating semicolon.
|
3623 |
|
|
|
3624 |
|
|
A typical example, with two base classes, would be "!2,020,19;0264,21;".
|
3625 |
|
|
^^ ^ ^ ^ ^ ^ ^
|
3626 |
|
|
Baseclass information marker __________________|| | | | | | |
|
3627 |
|
|
Number of baseclasses __________________________| | | | | | |
|
3628 |
|
|
Visibility specifiers (2) ________________________| | | | | |
|
3629 |
|
|
Offset in bits from start of class _________________| | | | |
|
3630 |
|
|
Type number for base class ___________________________| | | |
|
3631 |
|
|
Visibility specifiers (2) _______________________________| | |
|
3632 |
|
|
Offset in bits from start of class ________________________| |
|
3633 |
|
|
Type number of base class ____________________________________|
|
3634 |
|
|
|
3635 |
|
|
Return 1 for success, 0 for (error-type-inducing) failure. */
|
3636 |
|
|
/* *INDENT-ON* */
|
3637 |
|
|
|
3638 |
|
|
|
3639 |
|
|
|
3640 |
|
|
static int
|
3641 |
|
|
read_baseclasses (fip, pp, type, objfile)
|
3642 |
|
|
struct field_info *fip;
|
3643 |
|
|
char **pp;
|
3644 |
|
|
struct type *type;
|
3645 |
|
|
struct objfile *objfile;
|
3646 |
|
|
{
|
3647 |
|
|
int i;
|
3648 |
|
|
struct nextfield *new;
|
3649 |
|
|
|
3650 |
|
|
if (**pp != '!')
|
3651 |
|
|
{
|
3652 |
|
|
return 1;
|
3653 |
|
|
}
|
3654 |
|
|
else
|
3655 |
|
|
{
|
3656 |
|
|
/* Skip the '!' baseclass information marker. */
|
3657 |
|
|
(*pp)++;
|
3658 |
|
|
}
|
3659 |
|
|
|
3660 |
|
|
ALLOCATE_CPLUS_STRUCT_TYPE (type);
|
3661 |
|
|
{
|
3662 |
|
|
int nbits;
|
3663 |
|
|
TYPE_N_BASECLASSES (type) = read_huge_number (pp, ',', &nbits);
|
3664 |
|
|
if (nbits != 0)
|
3665 |
|
|
return 0;
|
3666 |
|
|
}
|
3667 |
|
|
|
3668 |
|
|
#if 0
|
3669 |
|
|
/* Some stupid compilers have trouble with the following, so break
|
3670 |
|
|
it up into simpler expressions. */
|
3671 |
|
|
TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *)
|
3672 |
|
|
TYPE_ALLOC (type, B_BYTES (TYPE_N_BASECLASSES (type)));
|
3673 |
|
|
#else
|
3674 |
|
|
{
|
3675 |
|
|
int num_bytes = B_BYTES (TYPE_N_BASECLASSES (type));
|
3676 |
|
|
char *pointer;
|
3677 |
|
|
|
3678 |
|
|
pointer = (char *) TYPE_ALLOC (type, num_bytes);
|
3679 |
|
|
TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *) pointer;
|
3680 |
|
|
}
|
3681 |
|
|
#endif /* 0 */
|
3682 |
|
|
|
3683 |
|
|
B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), TYPE_N_BASECLASSES (type));
|
3684 |
|
|
|
3685 |
|
|
for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
|
3686 |
|
|
{
|
3687 |
|
|
new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
|
3688 |
|
|
make_cleanup (free, new);
|
3689 |
|
|
memset (new, 0, sizeof (struct nextfield));
|
3690 |
|
|
new->next = fip->list;
|
3691 |
|
|
fip->list = new;
|
3692 |
|
|
FIELD_BITSIZE (new->field) = 0; /* this should be an unpacked field! */
|
3693 |
|
|
|
3694 |
|
|
STABS_CONTINUE (pp, objfile);
|
3695 |
|
|
switch (**pp)
|
3696 |
|
|
{
|
3697 |
|
|
case '0':
|
3698 |
|
|
/* Nothing to do. */
|
3699 |
|
|
break;
|
3700 |
|
|
case '1':
|
3701 |
|
|
SET_TYPE_FIELD_VIRTUAL (type, i);
|
3702 |
|
|
break;
|
3703 |
|
|
default:
|
3704 |
|
|
/* Unknown character. Complain and treat it as non-virtual. */
|
3705 |
|
|
{
|
3706 |
|
|
static struct complaint msg =
|
3707 |
|
|
{
|
3708 |
|
|
"Unknown virtual character `%c' for baseclass", 0, 0};
|
3709 |
|
|
complain (&msg, **pp);
|
3710 |
|
|
}
|
3711 |
|
|
}
|
3712 |
|
|
++(*pp);
|
3713 |
|
|
|
3714 |
|
|
new->visibility = *(*pp)++;
|
3715 |
|
|
switch (new->visibility)
|
3716 |
|
|
{
|
3717 |
|
|
case VISIBILITY_PRIVATE:
|
3718 |
|
|
case VISIBILITY_PROTECTED:
|
3719 |
|
|
case VISIBILITY_PUBLIC:
|
3720 |
|
|
break;
|
3721 |
|
|
default:
|
3722 |
|
|
/* Bad visibility format. Complain and treat it as
|
3723 |
|
|
public. */
|
3724 |
|
|
{
|
3725 |
|
|
static struct complaint msg =
|
3726 |
|
|
{
|
3727 |
|
|
"Unknown visibility `%c' for baseclass", 0, 0
|
3728 |
|
|
};
|
3729 |
|
|
complain (&msg, new->visibility);
|
3730 |
|
|
new->visibility = VISIBILITY_PUBLIC;
|
3731 |
|
|
}
|
3732 |
|
|
}
|
3733 |
|
|
|
3734 |
|
|
{
|
3735 |
|
|
int nbits;
|
3736 |
|
|
|
3737 |
|
|
/* The remaining value is the bit offset of the portion of the object
|
3738 |
|
|
corresponding to this baseclass. Always zero in the absence of
|
3739 |
|
|
multiple inheritance. */
|
3740 |
|
|
|
3741 |
|
|
FIELD_BITPOS (new->field) = read_huge_number (pp, ',', &nbits);
|
3742 |
|
|
if (nbits != 0)
|
3743 |
|
|
return 0;
|
3744 |
|
|
}
|
3745 |
|
|
|
3746 |
|
|
/* The last piece of baseclass information is the type of the
|
3747 |
|
|
base class. Read it, and remember it's type name as this
|
3748 |
|
|
field's name. */
|
3749 |
|
|
|
3750 |
|
|
new->field.type = read_type (pp, objfile);
|
3751 |
|
|
new->field.name = type_name_no_tag (new->field.type);
|
3752 |
|
|
|
3753 |
|
|
/* skip trailing ';' and bump count of number of fields seen */
|
3754 |
|
|
if (**pp == ';')
|
3755 |
|
|
(*pp)++;
|
3756 |
|
|
else
|
3757 |
|
|
return 0;
|
3758 |
|
|
}
|
3759 |
|
|
return 1;
|
3760 |
|
|
}
|
3761 |
|
|
|
3762 |
|
|
/* The tail end of stabs for C++ classes that contain a virtual function
|
3763 |
|
|
pointer contains a tilde, a %, and a type number.
|
3764 |
|
|
The type number refers to the base class (possibly this class itself) which
|
3765 |
|
|
contains the vtable pointer for the current class.
|
3766 |
|
|
|
3767 |
|
|
This function is called when we have parsed all the method declarations,
|
3768 |
|
|
so we can look for the vptr base class info. */
|
3769 |
|
|
|
3770 |
|
|
static int
|
3771 |
|
|
read_tilde_fields (fip, pp, type, objfile)
|
3772 |
|
|
struct field_info *fip;
|
3773 |
|
|
char **pp;
|
3774 |
|
|
struct type *type;
|
3775 |
|
|
struct objfile *objfile;
|
3776 |
|
|
{
|
3777 |
|
|
register char *p;
|
3778 |
|
|
|
3779 |
|
|
STABS_CONTINUE (pp, objfile);
|
3780 |
|
|
|
3781 |
|
|
/* If we are positioned at a ';', then skip it. */
|
3782 |
|
|
if (**pp == ';')
|
3783 |
|
|
{
|
3784 |
|
|
(*pp)++;
|
3785 |
|
|
}
|
3786 |
|
|
|
3787 |
|
|
if (**pp == '~')
|
3788 |
|
|
{
|
3789 |
|
|
(*pp)++;
|
3790 |
|
|
|
3791 |
|
|
if (**pp == '=' || **pp == '+' || **pp == '-')
|
3792 |
|
|
{
|
3793 |
|
|
/* Obsolete flags that used to indicate the presence
|
3794 |
|
|
of constructors and/or destructors. */
|
3795 |
|
|
(*pp)++;
|
3796 |
|
|
}
|
3797 |
|
|
|
3798 |
|
|
/* Read either a '%' or the final ';'. */
|
3799 |
|
|
if (*(*pp)++ == '%')
|
3800 |
|
|
{
|
3801 |
|
|
/* The next number is the type number of the base class
|
3802 |
|
|
(possibly our own class) which supplies the vtable for
|
3803 |
|
|
this class. Parse it out, and search that class to find
|
3804 |
|
|
its vtable pointer, and install those into TYPE_VPTR_BASETYPE
|
3805 |
|
|
and TYPE_VPTR_FIELDNO. */
|
3806 |
|
|
|
3807 |
|
|
struct type *t;
|
3808 |
|
|
int i;
|
3809 |
|
|
|
3810 |
|
|
t = read_type (pp, objfile);
|
3811 |
|
|
p = (*pp)++;
|
3812 |
|
|
while (*p != '\0' && *p != ';')
|
3813 |
|
|
{
|
3814 |
|
|
p++;
|
3815 |
|
|
}
|
3816 |
|
|
if (*p == '\0')
|
3817 |
|
|
{
|
3818 |
|
|
/* Premature end of symbol. */
|
3819 |
|
|
return 0;
|
3820 |
|
|
}
|
3821 |
|
|
|
3822 |
|
|
TYPE_VPTR_BASETYPE (type) = t;
|
3823 |
|
|
if (type == t) /* Our own class provides vtbl ptr */
|
3824 |
|
|
{
|
3825 |
|
|
for (i = TYPE_NFIELDS (t) - 1;
|
3826 |
|
|
i >= TYPE_N_BASECLASSES (t);
|
3827 |
|
|
--i)
|
3828 |
|
|
{
|
3829 |
|
|
if (!strncmp (TYPE_FIELD_NAME (t, i), vptr_name,
|
3830 |
|
|
sizeof (vptr_name) - 1))
|
3831 |
|
|
{
|
3832 |
|
|
TYPE_VPTR_FIELDNO (type) = i;
|
3833 |
|
|
goto gotit;
|
3834 |
|
|
}
|
3835 |
|
|
}
|
3836 |
|
|
/* Virtual function table field not found. */
|
3837 |
|
|
complain (&vtbl_notfound_complaint, TYPE_NAME (type));
|
3838 |
|
|
return 0;
|
3839 |
|
|
}
|
3840 |
|
|
else
|
3841 |
|
|
{
|
3842 |
|
|
TYPE_VPTR_FIELDNO (type) = TYPE_VPTR_FIELDNO (t);
|
3843 |
|
|
}
|
3844 |
|
|
|
3845 |
|
|
gotit:
|
3846 |
|
|
*pp = p + 1;
|
3847 |
|
|
}
|
3848 |
|
|
}
|
3849 |
|
|
return 1;
|
3850 |
|
|
}
|
3851 |
|
|
|
3852 |
|
|
static int
|
3853 |
|
|
attach_fn_fields_to_type (fip, type)
|
3854 |
|
|
struct field_info *fip;
|
3855 |
|
|
register struct type *type;
|
3856 |
|
|
{
|
3857 |
|
|
register int n;
|
3858 |
|
|
|
3859 |
|
|
for (n = TYPE_NFN_FIELDS (type);
|
3860 |
|
|
fip->fnlist != NULL;
|
3861 |
|
|
fip->fnlist = fip->fnlist->next)
|
3862 |
|
|
{
|
3863 |
|
|
--n; /* Circumvent Sun3 compiler bug */
|
3864 |
|
|
TYPE_FN_FIELDLISTS (type)[n] = fip->fnlist->fn_fieldlist;
|
3865 |
|
|
}
|
3866 |
|
|
return 1;
|
3867 |
|
|
}
|
3868 |
|
|
|
3869 |
|
|
/* read cfront class static data.
|
3870 |
|
|
pp points to string starting with the list of static data
|
3871 |
|
|
eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;;
|
3872 |
|
|
^^^^^^^^
|
3873 |
|
|
|
3874 |
|
|
A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;;
|
3875 |
|
|
^
|
3876 |
|
|
*/
|
3877 |
|
|
|
3878 |
|
|
static int
|
3879 |
|
|
read_cfront_static_fields (fip, pp, type, objfile)
|
3880 |
|
|
struct field_info *fip;
|
3881 |
|
|
char **pp;
|
3882 |
|
|
struct type *type;
|
3883 |
|
|
struct objfile *objfile;
|
3884 |
|
|
{
|
3885 |
|
|
struct nextfield *new;
|
3886 |
|
|
struct type *stype;
|
3887 |
|
|
char *sname;
|
3888 |
|
|
struct symbol *ref_static = 0;
|
3889 |
|
|
|
3890 |
|
|
if (**pp == ';') /* no static data; return */
|
3891 |
|
|
{
|
3892 |
|
|
++(*pp);
|
3893 |
|
|
return 1;
|
3894 |
|
|
}
|
3895 |
|
|
|
3896 |
|
|
/* Process each field in the list until we find the terminating ";" */
|
3897 |
|
|
|
3898 |
|
|
/* eg: p = "as__1A ;;;" */
|
3899 |
|
|
STABS_CONTINUE (pp, objfile); /* handle \\ */
|
3900 |
|
|
while (**pp != ';' && (sname = get_substring (pp, ' '), sname))
|
3901 |
|
|
{
|
3902 |
|
|
ref_static = lookup_symbol (sname, 0, VAR_NAMESPACE, 0, 0); /*demangled_name */
|
3903 |
|
|
if (!ref_static)
|
3904 |
|
|
{
|
3905 |
|
|
static struct complaint msg =
|
3906 |
|
|
{"\
|
3907 |
|
|
Unable to find symbol for static data field %s\n",
|
3908 |
|
|
0, 0};
|
3909 |
|
|
complain (&msg, sname);
|
3910 |
|
|
continue;
|
3911 |
|
|
}
|
3912 |
|
|
stype = SYMBOL_TYPE (ref_static);
|
3913 |
|
|
|
3914 |
|
|
/* allocate a new fip */
|
3915 |
|
|
new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
|
3916 |
|
|
make_cleanup (free, new);
|
3917 |
|
|
memset (new, 0, sizeof (struct nextfield));
|
3918 |
|
|
new->next = fip->list;
|
3919 |
|
|
fip->list = new;
|
3920 |
|
|
|
3921 |
|
|
/* set visibility */
|
3922 |
|
|
/* FIXME! no way to tell visibility from stabs??? */
|
3923 |
|
|
new->visibility = VISIBILITY_PUBLIC;
|
3924 |
|
|
|
3925 |
|
|
/* set field info into fip */
|
3926 |
|
|
fip->list->field.type = stype;
|
3927 |
|
|
|
3928 |
|
|
/* set bitpos & bitsize */
|
3929 |
|
|
SET_FIELD_PHYSNAME (fip->list->field, savestring (sname, strlen (sname)));
|
3930 |
|
|
|
3931 |
|
|
/* set name field */
|
3932 |
|
|
/* The following is code to work around cfront generated stabs.
|
3933 |
|
|
The stabs contains full mangled name for each field.
|
3934 |
|
|
We try to demangle the name and extract the field name out of it.
|
3935 |
|
|
*/
|
3936 |
|
|
if (ARM_DEMANGLING)
|
3937 |
|
|
{
|
3938 |
|
|
char *dem, *dem_p;
|
3939 |
|
|
dem = cplus_demangle (sname, DMGL_ANSI | DMGL_PARAMS);
|
3940 |
|
|
if (dem != NULL)
|
3941 |
|
|
{
|
3942 |
|
|
dem_p = strrchr (dem, ':');
|
3943 |
|
|
if (dem_p != 0 && *(dem_p - 1) == ':')
|
3944 |
|
|
dem_p++;
|
3945 |
|
|
fip->list->field.name =
|
3946 |
|
|
obsavestring (dem_p, strlen (dem_p), &objfile->type_obstack);
|
3947 |
|
|
}
|
3948 |
|
|
else
|
3949 |
|
|
{
|
3950 |
|
|
fip->list->field.name =
|
3951 |
|
|
obsavestring (sname, strlen (sname), &objfile->type_obstack);
|
3952 |
|
|
}
|
3953 |
|
|
} /* end of code for cfront work around */
|
3954 |
|
|
} /* loop again for next static field */
|
3955 |
|
|
return 1;
|
3956 |
|
|
}
|
3957 |
|
|
|
3958 |
|
|
/* Copy structure fields to fip so attach_fields_to_type will work.
|
3959 |
|
|
type has already been created with the initial instance data fields.
|
3960 |
|
|
Now we want to be able to add the other members to the class,
|
3961 |
|
|
so we want to add them back to the fip and reattach them again
|
3962 |
|
|
once we have collected all the class members. */
|
3963 |
|
|
|
3964 |
|
|
static int
|
3965 |
|
|
copy_cfront_struct_fields (fip, type, objfile)
|
3966 |
|
|
struct field_info *fip;
|
3967 |
|
|
struct type *type;
|
3968 |
|
|
struct objfile *objfile;
|
3969 |
|
|
{
|
3970 |
|
|
int nfields = TYPE_NFIELDS (type);
|
3971 |
|
|
int i;
|
3972 |
|
|
struct nextfield *new;
|
3973 |
|
|
|
3974 |
|
|
/* Copy the fields into the list of fips and reset the types
|
3975 |
|
|
to remove the old fields */
|
3976 |
|
|
|
3977 |
|
|
for (i = 0; i < nfields; i++)
|
3978 |
|
|
{
|
3979 |
|
|
/* allocate a new fip */
|
3980 |
|
|
new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
|
3981 |
|
|
make_cleanup (free, new);
|
3982 |
|
|
memset (new, 0, sizeof (struct nextfield));
|
3983 |
|
|
new->next = fip->list;
|
3984 |
|
|
fip->list = new;
|
3985 |
|
|
|
3986 |
|
|
/* copy field info into fip */
|
3987 |
|
|
new->field = TYPE_FIELD (type, i);
|
3988 |
|
|
/* set visibility */
|
3989 |
|
|
if (TYPE_FIELD_PROTECTED (type, i))
|
3990 |
|
|
new->visibility = VISIBILITY_PROTECTED;
|
3991 |
|
|
else if (TYPE_FIELD_PRIVATE (type, i))
|
3992 |
|
|
new->visibility = VISIBILITY_PRIVATE;
|
3993 |
|
|
else
|
3994 |
|
|
new->visibility = VISIBILITY_PUBLIC;
|
3995 |
|
|
}
|
3996 |
|
|
/* Now delete the fields from the type since we will be
|
3997 |
|
|
allocing new space once we get the rest of the fields
|
3998 |
|
|
in attach_fields_to_type.
|
3999 |
|
|
The pointer TYPE_FIELDS(type) is left dangling but should
|
4000 |
|
|
be freed later by objstack_free */
|
4001 |
|
|
TYPE_FIELDS (type) = 0;
|
4002 |
|
|
TYPE_NFIELDS (type) = 0;
|
4003 |
|
|
|
4004 |
|
|
return 1;
|
4005 |
|
|
}
|
4006 |
|
|
|
4007 |
|
|
/* Create the vector of fields, and record how big it is.
|
4008 |
|
|
We need this info to record proper virtual function table information
|
4009 |
|
|
for this class's virtual functions. */
|
4010 |
|
|
|
4011 |
|
|
static int
|
4012 |
|
|
attach_fields_to_type (fip, type, objfile)
|
4013 |
|
|
struct field_info *fip;
|
4014 |
|
|
register struct type *type;
|
4015 |
|
|
struct objfile *objfile;
|
4016 |
|
|
{
|
4017 |
|
|
register int nfields = 0;
|
4018 |
|
|
register int non_public_fields = 0;
|
4019 |
|
|
register struct nextfield *scan;
|
4020 |
|
|
|
4021 |
|
|
/* Count up the number of fields that we have, as well as taking note of
|
4022 |
|
|
whether or not there are any non-public fields, which requires us to
|
4023 |
|
|
allocate and build the private_field_bits and protected_field_bits
|
4024 |
|
|
bitfields. */
|
4025 |
|
|
|
4026 |
|
|
for (scan = fip->list; scan != NULL; scan = scan->next)
|
4027 |
|
|
{
|
4028 |
|
|
nfields++;
|
4029 |
|
|
if (scan->visibility != VISIBILITY_PUBLIC)
|
4030 |
|
|
{
|
4031 |
|
|
non_public_fields++;
|
4032 |
|
|
}
|
4033 |
|
|
}
|
4034 |
|
|
|
4035 |
|
|
/* Now we know how many fields there are, and whether or not there are any
|
4036 |
|
|
non-public fields. Record the field count, allocate space for the
|
4037 |
|
|
array of fields, and create blank visibility bitfields if necessary. */
|
4038 |
|
|
|
4039 |
|
|
TYPE_NFIELDS (type) = nfields;
|
4040 |
|
|
TYPE_FIELDS (type) = (struct field *)
|
4041 |
|
|
TYPE_ALLOC (type, sizeof (struct field) * nfields);
|
4042 |
|
|
memset (TYPE_FIELDS (type), 0, sizeof (struct field) * nfields);
|
4043 |
|
|
|
4044 |
|
|
if (non_public_fields)
|
4045 |
|
|
{
|
4046 |
|
|
ALLOCATE_CPLUS_STRUCT_TYPE (type);
|
4047 |
|
|
|
4048 |
|
|
TYPE_FIELD_PRIVATE_BITS (type) =
|
4049 |
|
|
(B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
|
4050 |
|
|
B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type), nfields);
|
4051 |
|
|
|
4052 |
|
|
TYPE_FIELD_PROTECTED_BITS (type) =
|
4053 |
|
|
(B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
|
4054 |
|
|
B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type), nfields);
|
4055 |
|
|
|
4056 |
|
|
TYPE_FIELD_IGNORE_BITS (type) =
|
4057 |
|
|
(B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
|
4058 |
|
|
B_CLRALL (TYPE_FIELD_IGNORE_BITS (type), nfields);
|
4059 |
|
|
}
|
4060 |
|
|
|
4061 |
|
|
/* Copy the saved-up fields into the field vector. Start from the head
|
4062 |
|
|
of the list, adding to the tail of the field array, so that they end
|
4063 |
|
|
up in the same order in the array in which they were added to the list. */
|
4064 |
|
|
|
4065 |
|
|
while (nfields-- > 0)
|
4066 |
|
|
{
|
4067 |
|
|
TYPE_FIELD (type, nfields) = fip->list->field;
|
4068 |
|
|
switch (fip->list->visibility)
|
4069 |
|
|
{
|
4070 |
|
|
case VISIBILITY_PRIVATE:
|
4071 |
|
|
SET_TYPE_FIELD_PRIVATE (type, nfields);
|
4072 |
|
|
break;
|
4073 |
|
|
|
4074 |
|
|
case VISIBILITY_PROTECTED:
|
4075 |
|
|
SET_TYPE_FIELD_PROTECTED (type, nfields);
|
4076 |
|
|
break;
|
4077 |
|
|
|
4078 |
|
|
case VISIBILITY_IGNORE:
|
4079 |
|
|
SET_TYPE_FIELD_IGNORE (type, nfields);
|
4080 |
|
|
break;
|
4081 |
|
|
|
4082 |
|
|
case VISIBILITY_PUBLIC:
|
4083 |
|
|
break;
|
4084 |
|
|
|
4085 |
|
|
default:
|
4086 |
|
|
/* Unknown visibility. Complain and treat it as public. */
|
4087 |
|
|
{
|
4088 |
|
|
static struct complaint msg =
|
4089 |
|
|
{
|
4090 |
|
|
"Unknown visibility `%c' for field", 0, 0};
|
4091 |
|
|
complain (&msg, fip->list->visibility);
|
4092 |
|
|
}
|
4093 |
|
|
break;
|
4094 |
|
|
}
|
4095 |
|
|
fip->list = fip->list->next;
|
4096 |
|
|
}
|
4097 |
|
|
return 1;
|
4098 |
|
|
}
|
4099 |
|
|
|
4100 |
|
|
/* Read the description of a structure (or union type) and return an object
|
4101 |
|
|
describing the type.
|
4102 |
|
|
|
4103 |
|
|
PP points to a character pointer that points to the next unconsumed token
|
4104 |
|
|
in the the stabs string. For example, given stabs "A:T4=s4a:1,0,32;;",
|
4105 |
|
|
*PP will point to "4a:1,0,32;;".
|
4106 |
|
|
|
4107 |
|
|
TYPE points to an incomplete type that needs to be filled in.
|
4108 |
|
|
|
4109 |
|
|
OBJFILE points to the current objfile from which the stabs information is
|
4110 |
|
|
being read. (Note that it is redundant in that TYPE also contains a pointer
|
4111 |
|
|
to this same objfile, so it might be a good idea to eliminate it. FIXME).
|
4112 |
|
|
*/
|
4113 |
|
|
|
4114 |
|
|
static struct type *
|
4115 |
|
|
read_struct_type (pp, type, objfile)
|
4116 |
|
|
char **pp;
|
4117 |
|
|
struct type *type;
|
4118 |
|
|
struct objfile *objfile;
|
4119 |
|
|
{
|
4120 |
|
|
struct cleanup *back_to;
|
4121 |
|
|
struct field_info fi;
|
4122 |
|
|
|
4123 |
|
|
fi.list = NULL;
|
4124 |
|
|
fi.fnlist = NULL;
|
4125 |
|
|
|
4126 |
|
|
back_to = make_cleanup (null_cleanup, 0);
|
4127 |
|
|
|
4128 |
|
|
INIT_CPLUS_SPECIFIC (type);
|
4129 |
|
|
TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
|
4130 |
|
|
|
4131 |
|
|
/* First comes the total size in bytes. */
|
4132 |
|
|
|
4133 |
|
|
{
|
4134 |
|
|
int nbits;
|
4135 |
|
|
TYPE_LENGTH (type) = read_huge_number (pp, 0, &nbits);
|
4136 |
|
|
if (nbits != 0)
|
4137 |
|
|
return error_type (pp, objfile);
|
4138 |
|
|
}
|
4139 |
|
|
|
4140 |
|
|
/* Now read the baseclasses, if any, read the regular C struct or C++
|
4141 |
|
|
class member fields, attach the fields to the type, read the C++
|
4142 |
|
|
member functions, attach them to the type, and then read any tilde
|
4143 |
|
|
field (baseclass specifier for the class holding the main vtable). */
|
4144 |
|
|
|
4145 |
|
|
if (!read_baseclasses (&fi, pp, type, objfile)
|
4146 |
|
|
|| !read_struct_fields (&fi, pp, type, objfile)
|
4147 |
|
|
|| !attach_fields_to_type (&fi, type, objfile)
|
4148 |
|
|
|| !read_member_functions (&fi, pp, type, objfile)
|
4149 |
|
|
|| !attach_fn_fields_to_type (&fi, type)
|
4150 |
|
|
|| !read_tilde_fields (&fi, pp, type, objfile))
|
4151 |
|
|
{
|
4152 |
|
|
type = error_type (pp, objfile);
|
4153 |
|
|
}
|
4154 |
|
|
|
4155 |
|
|
do_cleanups (back_to);
|
4156 |
|
|
return (type);
|
4157 |
|
|
}
|
4158 |
|
|
|
4159 |
|
|
/* Read a definition of an array type,
|
4160 |
|
|
and create and return a suitable type object.
|
4161 |
|
|
Also creates a range type which represents the bounds of that
|
4162 |
|
|
array. */
|
4163 |
|
|
|
4164 |
|
|
static struct type *
|
4165 |
|
|
read_array_type (pp, type, objfile)
|
4166 |
|
|
register char **pp;
|
4167 |
|
|
register struct type *type;
|
4168 |
|
|
struct objfile *objfile;
|
4169 |
|
|
{
|
4170 |
|
|
struct type *index_type, *element_type, *range_type;
|
4171 |
|
|
int lower, upper;
|
4172 |
|
|
int adjustable = 0;
|
4173 |
|
|
int nbits;
|
4174 |
|
|
|
4175 |
|
|
/* Format of an array type:
|
4176 |
|
|
"ar<index type>;lower;upper;<array_contents_type>".
|
4177 |
|
|
OS9000: "arlower,upper;<array_contents_type>".
|
4178 |
|
|
|
4179 |
|
|
Fortran adjustable arrays use Adigits or Tdigits for lower or upper;
|
4180 |
|
|
for these, produce a type like float[][]. */
|
4181 |
|
|
|
4182 |
|
|
if (os9k_stabs)
|
4183 |
|
|
index_type = builtin_type_int;
|
4184 |
|
|
else
|
4185 |
|
|
{
|
4186 |
|
|
index_type = read_type (pp, objfile);
|
4187 |
|
|
if (**pp != ';')
|
4188 |
|
|
/* Improper format of array type decl. */
|
4189 |
|
|
return error_type (pp, objfile);
|
4190 |
|
|
++*pp;
|
4191 |
|
|
}
|
4192 |
|
|
|
4193 |
|
|
if (!(**pp >= '0' && **pp <= '9') && **pp != '-')
|
4194 |
|
|
{
|
4195 |
|
|
(*pp)++;
|
4196 |
|
|
adjustable = 1;
|
4197 |
|
|
}
|
4198 |
|
|
lower = read_huge_number (pp, os9k_stabs ? ',' : ';', &nbits);
|
4199 |
|
|
if (nbits != 0)
|
4200 |
|
|
return error_type (pp, objfile);
|
4201 |
|
|
|
4202 |
|
|
if (!(**pp >= '0' && **pp <= '9') && **pp != '-')
|
4203 |
|
|
{
|
4204 |
|
|
(*pp)++;
|
4205 |
|
|
adjustable = 1;
|
4206 |
|
|
}
|
4207 |
|
|
upper = read_huge_number (pp, ';', &nbits);
|
4208 |
|
|
if (nbits != 0)
|
4209 |
|
|
return error_type (pp, objfile);
|
4210 |
|
|
|
4211 |
|
|
element_type = read_type (pp, objfile);
|
4212 |
|
|
|
4213 |
|
|
if (adjustable)
|
4214 |
|
|
{
|
4215 |
|
|
lower = 0;
|
4216 |
|
|
upper = -1;
|
4217 |
|
|
}
|
4218 |
|
|
|
4219 |
|
|
range_type =
|
4220 |
|
|
create_range_type ((struct type *) NULL, index_type, lower, upper);
|
4221 |
|
|
type = create_array_type (type, element_type, range_type);
|
4222 |
|
|
|
4223 |
|
|
return type;
|
4224 |
|
|
}
|
4225 |
|
|
|
4226 |
|
|
|
4227 |
|
|
/* Read a definition of an enumeration type,
|
4228 |
|
|
and create and return a suitable type object.
|
4229 |
|
|
Also defines the symbols that represent the values of the type. */
|
4230 |
|
|
|
4231 |
|
|
static struct type *
|
4232 |
|
|
read_enum_type (pp, type, objfile)
|
4233 |
|
|
register char **pp;
|
4234 |
|
|
register struct type *type;
|
4235 |
|
|
struct objfile *objfile;
|
4236 |
|
|
{
|
4237 |
|
|
register char *p;
|
4238 |
|
|
char *name;
|
4239 |
|
|
register long n;
|
4240 |
|
|
register struct symbol *sym;
|
4241 |
|
|
int nsyms = 0;
|
4242 |
|
|
struct pending **symlist;
|
4243 |
|
|
struct pending *osyms, *syms;
|
4244 |
|
|
int o_nsyms;
|
4245 |
|
|
int nbits;
|
4246 |
|
|
int unsigned_enum = 1;
|
4247 |
|
|
|
4248 |
|
|
#if 0
|
4249 |
|
|
/* FIXME! The stabs produced by Sun CC merrily define things that ought
|
4250 |
|
|
to be file-scope, between N_FN entries, using N_LSYM. What's a mother
|
4251 |
|
|
to do? For now, force all enum values to file scope. */
|
4252 |
|
|
if (within_function)
|
4253 |
|
|
symlist = &local_symbols;
|
4254 |
|
|
else
|
4255 |
|
|
#endif
|
4256 |
|
|
symlist = &file_symbols;
|
4257 |
|
|
osyms = *symlist;
|
4258 |
|
|
o_nsyms = osyms ? osyms->nsyms : 0;
|
4259 |
|
|
|
4260 |
|
|
if (os9k_stabs)
|
4261 |
|
|
{
|
4262 |
|
|
/* Size. Perhaps this does not have to be conditionalized on
|
4263 |
|
|
os9k_stabs (assuming the name of an enum constant can't start
|
4264 |
|
|
with a digit). */
|
4265 |
|
|
read_huge_number (pp, 0, &nbits);
|
4266 |
|
|
if (nbits != 0)
|
4267 |
|
|
return error_type (pp, objfile);
|
4268 |
|
|
}
|
4269 |
|
|
|
4270 |
|
|
/* The aix4 compiler emits an extra field before the enum members;
|
4271 |
|
|
my guess is it's a type of some sort. Just ignore it. */
|
4272 |
|
|
if (**pp == '-')
|
4273 |
|
|
{
|
4274 |
|
|
/* Skip over the type. */
|
4275 |
|
|
while (**pp != ':')
|
4276 |
|
|
(*pp)++;
|
4277 |
|
|
|
4278 |
|
|
/* Skip over the colon. */
|
4279 |
|
|
(*pp)++;
|
4280 |
|
|
}
|
4281 |
|
|
|
4282 |
|
|
/* Read the value-names and their values.
|
4283 |
|
|
The input syntax is NAME:VALUE,NAME:VALUE, and so on.
|
4284 |
|
|
A semicolon or comma instead of a NAME means the end. */
|
4285 |
|
|
while (**pp && **pp != ';' && **pp != ',')
|
4286 |
|
|
{
|
4287 |
|
|
STABS_CONTINUE (pp, objfile);
|
4288 |
|
|
p = *pp;
|
4289 |
|
|
while (*p != ':')
|
4290 |
|
|
p++;
|
4291 |
|
|
name = obsavestring (*pp, p - *pp, &objfile->symbol_obstack);
|
4292 |
|
|
*pp = p + 1;
|
4293 |
|
|
n = read_huge_number (pp, ',', &nbits);
|
4294 |
|
|
if (nbits != 0)
|
4295 |
|
|
return error_type (pp, objfile);
|
4296 |
|
|
|
4297 |
|
|
sym = (struct symbol *)
|
4298 |
|
|
obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
|
4299 |
|
|
memset (sym, 0, sizeof (struct symbol));
|
4300 |
|
|
SYMBOL_NAME (sym) = name;
|
4301 |
|
|
SYMBOL_LANGUAGE (sym) = current_subfile->language;
|
4302 |
|
|
SYMBOL_CLASS (sym) = LOC_CONST;
|
4303 |
|
|
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
|
4304 |
|
|
SYMBOL_VALUE (sym) = n;
|
4305 |
|
|
if (n < 0)
|
4306 |
|
|
unsigned_enum = 0;
|
4307 |
|
|
add_symbol_to_list (sym, symlist);
|
4308 |
|
|
nsyms++;
|
4309 |
|
|
}
|
4310 |
|
|
|
4311 |
|
|
if (**pp == ';')
|
4312 |
|
|
(*pp)++; /* Skip the semicolon. */
|
4313 |
|
|
|
4314 |
|
|
/* Now fill in the fields of the type-structure. */
|
4315 |
|
|
|
4316 |
|
|
TYPE_LENGTH (type) = TARGET_INT_BIT / HOST_CHAR_BIT;
|
4317 |
|
|
TYPE_CODE (type) = TYPE_CODE_ENUM;
|
4318 |
|
|
TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
|
4319 |
|
|
if (unsigned_enum)
|
4320 |
|
|
TYPE_FLAGS (type) |= TYPE_FLAG_UNSIGNED;
|
4321 |
|
|
TYPE_NFIELDS (type) = nsyms;
|
4322 |
|
|
TYPE_FIELDS (type) = (struct field *)
|
4323 |
|
|
TYPE_ALLOC (type, sizeof (struct field) * nsyms);
|
4324 |
|
|
memset (TYPE_FIELDS (type), 0, sizeof (struct field) * nsyms);
|
4325 |
|
|
|
4326 |
|
|
/* Find the symbols for the values and put them into the type.
|
4327 |
|
|
The symbols can be found in the symlist that we put them on
|
4328 |
|
|
to cause them to be defined. osyms contains the old value
|
4329 |
|
|
of that symlist; everything up to there was defined by us. */
|
4330 |
|
|
/* Note that we preserve the order of the enum constants, so
|
4331 |
|
|
that in something like "enum {FOO, LAST_THING=FOO}" we print
|
4332 |
|
|
FOO, not LAST_THING. */
|
4333 |
|
|
|
4334 |
|
|
for (syms = *symlist, n = nsyms - 1; syms; syms = syms->next)
|
4335 |
|
|
{
|
4336 |
|
|
int last = syms == osyms ? o_nsyms : 0;
|
4337 |
|
|
int j = syms->nsyms;
|
4338 |
|
|
for (; --j >= last; --n)
|
4339 |
|
|
{
|
4340 |
|
|
struct symbol *xsym = syms->symbol[j];
|
4341 |
|
|
SYMBOL_TYPE (xsym) = type;
|
4342 |
|
|
TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym);
|
4343 |
|
|
TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (xsym);
|
4344 |
|
|
TYPE_FIELD_BITSIZE (type, n) = 0;
|
4345 |
|
|
}
|
4346 |
|
|
if (syms == osyms)
|
4347 |
|
|
break;
|
4348 |
|
|
}
|
4349 |
|
|
|
4350 |
|
|
return type;
|
4351 |
|
|
}
|
4352 |
|
|
|
4353 |
|
|
/* Sun's ACC uses a somewhat saner method for specifying the builtin
|
4354 |
|
|
typedefs in every file (for int, long, etc):
|
4355 |
|
|
|
4356 |
|
|
type = b <signed> <width> <format type>; <offset>; <nbits>
|
4357 |
|
|
signed = u or s.
|
4358 |
|
|
optional format type = c or b for char or boolean.
|
4359 |
|
|
offset = offset from high order bit to start bit of type.
|
4360 |
|
|
width is # bytes in object of this type, nbits is # bits in type.
|
4361 |
|
|
|
4362 |
|
|
The width/offset stuff appears to be for small objects stored in
|
4363 |
|
|
larger ones (e.g. `shorts' in `int' registers). We ignore it for now,
|
4364 |
|
|
FIXME. */
|
4365 |
|
|
|
4366 |
|
|
static struct type *
|
4367 |
|
|
read_sun_builtin_type (pp, typenums, objfile)
|
4368 |
|
|
char **pp;
|
4369 |
|
|
int typenums[2];
|
4370 |
|
|
struct objfile *objfile;
|
4371 |
|
|
{
|
4372 |
|
|
int type_bits;
|
4373 |
|
|
int nbits;
|
4374 |
|
|
int signed_type;
|
4375 |
|
|
enum type_code code = TYPE_CODE_INT;
|
4376 |
|
|
|
4377 |
|
|
switch (**pp)
|
4378 |
|
|
{
|
4379 |
|
|
case 's':
|
4380 |
|
|
signed_type = 1;
|
4381 |
|
|
break;
|
4382 |
|
|
case 'u':
|
4383 |
|
|
signed_type = 0;
|
4384 |
|
|
break;
|
4385 |
|
|
default:
|
4386 |
|
|
return error_type (pp, objfile);
|
4387 |
|
|
}
|
4388 |
|
|
(*pp)++;
|
4389 |
|
|
|
4390 |
|
|
/* For some odd reason, all forms of char put a c here. This is strange
|
4391 |
|
|
because no other type has this honor. We can safely ignore this because
|
4392 |
|
|
we actually determine 'char'acterness by the number of bits specified in
|
4393 |
|
|
the descriptor.
|
4394 |
|
|
Boolean forms, e.g Fortran logical*X, put a b here. */
|
4395 |
|
|
|
4396 |
|
|
if (**pp == 'c')
|
4397 |
|
|
(*pp)++;
|
4398 |
|
|
else if (**pp == 'b')
|
4399 |
|
|
{
|
4400 |
|
|
code = TYPE_CODE_BOOL;
|
4401 |
|
|
(*pp)++;
|
4402 |
|
|
}
|
4403 |
|
|
|
4404 |
|
|
/* The first number appears to be the number of bytes occupied
|
4405 |
|
|
by this type, except that unsigned short is 4 instead of 2.
|
4406 |
|
|
Since this information is redundant with the third number,
|
4407 |
|
|
we will ignore it. */
|
4408 |
|
|
read_huge_number (pp, ';', &nbits);
|
4409 |
|
|
if (nbits != 0)
|
4410 |
|
|
return error_type (pp, objfile);
|
4411 |
|
|
|
4412 |
|
|
/* The second number is always 0, so ignore it too. */
|
4413 |
|
|
read_huge_number (pp, ';', &nbits);
|
4414 |
|
|
if (nbits != 0)
|
4415 |
|
|
return error_type (pp, objfile);
|
4416 |
|
|
|
4417 |
|
|
/* The third number is the number of bits for this type. */
|
4418 |
|
|
type_bits = read_huge_number (pp, 0, &nbits);
|
4419 |
|
|
if (nbits != 0)
|
4420 |
|
|
return error_type (pp, objfile);
|
4421 |
|
|
/* The type *should* end with a semicolon. If it are embedded
|
4422 |
|
|
in a larger type the semicolon may be the only way to know where
|
4423 |
|
|
the type ends. If this type is at the end of the stabstring we
|
4424 |
|
|
can deal with the omitted semicolon (but we don't have to like
|
4425 |
|
|
it). Don't bother to complain(), Sun's compiler omits the semicolon
|
4426 |
|
|
for "void". */
|
4427 |
|
|
if (**pp == ';')
|
4428 |
|
|
++(*pp);
|
4429 |
|
|
|
4430 |
|
|
if (type_bits == 0)
|
4431 |
|
|
return init_type (TYPE_CODE_VOID, 1,
|
4432 |
|
|
signed_type ? 0 : TYPE_FLAG_UNSIGNED, (char *) NULL,
|
4433 |
|
|
objfile);
|
4434 |
|
|
else
|
4435 |
|
|
return init_type (code,
|
4436 |
|
|
type_bits / TARGET_CHAR_BIT,
|
4437 |
|
|
signed_type ? 0 : TYPE_FLAG_UNSIGNED, (char *) NULL,
|
4438 |
|
|
objfile);
|
4439 |
|
|
}
|
4440 |
|
|
|
4441 |
|
|
static struct type *
|
4442 |
|
|
read_sun_floating_type (pp, typenums, objfile)
|
4443 |
|
|
char **pp;
|
4444 |
|
|
int typenums[2];
|
4445 |
|
|
struct objfile *objfile;
|
4446 |
|
|
{
|
4447 |
|
|
int nbits;
|
4448 |
|
|
int details;
|
4449 |
|
|
int nbytes;
|
4450 |
|
|
|
4451 |
|
|
/* The first number has more details about the type, for example
|
4452 |
|
|
FN_COMPLEX. */
|
4453 |
|
|
details = read_huge_number (pp, ';', &nbits);
|
4454 |
|
|
if (nbits != 0)
|
4455 |
|
|
return error_type (pp, objfile);
|
4456 |
|
|
|
4457 |
|
|
/* The second number is the number of bytes occupied by this type */
|
4458 |
|
|
nbytes = read_huge_number (pp, ';', &nbits);
|
4459 |
|
|
if (nbits != 0)
|
4460 |
|
|
return error_type (pp, objfile);
|
4461 |
|
|
|
4462 |
|
|
if (details == NF_COMPLEX || details == NF_COMPLEX16
|
4463 |
|
|
|| details == NF_COMPLEX32)
|
4464 |
|
|
/* This is a type we can't handle, but we do know the size.
|
4465 |
|
|
We also will be able to give it a name. */
|
4466 |
|
|
return init_type (TYPE_CODE_COMPLEX, nbytes, 0, NULL, objfile);
|
4467 |
|
|
|
4468 |
|
|
return init_type (TYPE_CODE_FLT, nbytes, 0, NULL, objfile);
|
4469 |
|
|
}
|
4470 |
|
|
|
4471 |
|
|
/* Read a number from the string pointed to by *PP.
|
4472 |
|
|
The value of *PP is advanced over the number.
|
4473 |
|
|
If END is nonzero, the character that ends the
|
4474 |
|
|
number must match END, or an error happens;
|
4475 |
|
|
and that character is skipped if it does match.
|
4476 |
|
|
If END is zero, *PP is left pointing to that character.
|
4477 |
|
|
|
4478 |
|
|
If the number fits in a long, set *BITS to 0 and return the value.
|
4479 |
|
|
If not, set *BITS to be the number of bits in the number and return 0.
|
4480 |
|
|
|
4481 |
|
|
If encounter garbage, set *BITS to -1 and return 0. */
|
4482 |
|
|
|
4483 |
|
|
static long
|
4484 |
|
|
read_huge_number (pp, end, bits)
|
4485 |
|
|
char **pp;
|
4486 |
|
|
int end;
|
4487 |
|
|
int *bits;
|
4488 |
|
|
{
|
4489 |
|
|
char *p = *pp;
|
4490 |
|
|
int sign = 1;
|
4491 |
|
|
long n = 0;
|
4492 |
|
|
int radix = 10;
|
4493 |
|
|
char overflow = 0;
|
4494 |
|
|
int nbits = 0;
|
4495 |
|
|
int c;
|
4496 |
|
|
long upper_limit;
|
4497 |
|
|
|
4498 |
|
|
if (*p == '-')
|
4499 |
|
|
{
|
4500 |
|
|
sign = -1;
|
4501 |
|
|
p++;
|
4502 |
|
|
}
|
4503 |
|
|
|
4504 |
|
|
/* Leading zero means octal. GCC uses this to output values larger
|
4505 |
|
|
than an int (because that would be hard in decimal). */
|
4506 |
|
|
if (*p == '0')
|
4507 |
|
|
{
|
4508 |
|
|
radix = 8;
|
4509 |
|
|
p++;
|
4510 |
|
|
}
|
4511 |
|
|
|
4512 |
|
|
if (os9k_stabs)
|
4513 |
|
|
upper_limit = ULONG_MAX / radix;
|
4514 |
|
|
else
|
4515 |
|
|
upper_limit = LONG_MAX / radix;
|
4516 |
|
|
|
4517 |
|
|
while ((c = *p++) >= '0' && c < ('0' + radix))
|
4518 |
|
|
{
|
4519 |
|
|
if (n <= upper_limit)
|
4520 |
|
|
{
|
4521 |
|
|
n *= radix;
|
4522 |
|
|
n += c - '0'; /* FIXME this overflows anyway */
|
4523 |
|
|
}
|
4524 |
|
|
else
|
4525 |
|
|
overflow = 1;
|
4526 |
|
|
|
4527 |
|
|
/* This depends on large values being output in octal, which is
|
4528 |
|
|
what GCC does. */
|
4529 |
|
|
if (radix == 8)
|
4530 |
|
|
{
|
4531 |
|
|
if (nbits == 0)
|
4532 |
|
|
{
|
4533 |
|
|
if (c == '0')
|
4534 |
|
|
/* Ignore leading zeroes. */
|
4535 |
|
|
;
|
4536 |
|
|
else if (c == '1')
|
4537 |
|
|
nbits = 1;
|
4538 |
|
|
else if (c == '2' || c == '3')
|
4539 |
|
|
nbits = 2;
|
4540 |
|
|
else
|
4541 |
|
|
nbits = 3;
|
4542 |
|
|
}
|
4543 |
|
|
else
|
4544 |
|
|
nbits += 3;
|
4545 |
|
|
}
|
4546 |
|
|
}
|
4547 |
|
|
if (end)
|
4548 |
|
|
{
|
4549 |
|
|
if (c && c != end)
|
4550 |
|
|
{
|
4551 |
|
|
if (bits != NULL)
|
4552 |
|
|
*bits = -1;
|
4553 |
|
|
return 0;
|
4554 |
|
|
}
|
4555 |
|
|
}
|
4556 |
|
|
else
|
4557 |
|
|
--p;
|
4558 |
|
|
|
4559 |
|
|
*pp = p;
|
4560 |
|
|
if (overflow)
|
4561 |
|
|
{
|
4562 |
|
|
if (nbits == 0)
|
4563 |
|
|
{
|
4564 |
|
|
/* Large decimal constants are an error (because it is hard to
|
4565 |
|
|
count how many bits are in them). */
|
4566 |
|
|
if (bits != NULL)
|
4567 |
|
|
*bits = -1;
|
4568 |
|
|
return 0;
|
4569 |
|
|
}
|
4570 |
|
|
|
4571 |
|
|
/* -0x7f is the same as 0x80. So deal with it by adding one to
|
4572 |
|
|
the number of bits. */
|
4573 |
|
|
if (sign == -1)
|
4574 |
|
|
++nbits;
|
4575 |
|
|
if (bits)
|
4576 |
|
|
*bits = nbits;
|
4577 |
|
|
}
|
4578 |
|
|
else
|
4579 |
|
|
{
|
4580 |
|
|
if (bits)
|
4581 |
|
|
*bits = 0;
|
4582 |
|
|
return n * sign;
|
4583 |
|
|
}
|
4584 |
|
|
/* It's *BITS which has the interesting information. */
|
4585 |
|
|
return 0;
|
4586 |
|
|
}
|
4587 |
|
|
|
4588 |
|
|
static struct type *
|
4589 |
|
|
read_range_type (pp, typenums, objfile)
|
4590 |
|
|
char **pp;
|
4591 |
|
|
int typenums[2];
|
4592 |
|
|
struct objfile *objfile;
|
4593 |
|
|
{
|
4594 |
|
|
char *orig_pp = *pp;
|
4595 |
|
|
int rangenums[2];
|
4596 |
|
|
long n2, n3;
|
4597 |
|
|
int n2bits, n3bits;
|
4598 |
|
|
int self_subrange;
|
4599 |
|
|
struct type *result_type;
|
4600 |
|
|
struct type *index_type = NULL;
|
4601 |
|
|
|
4602 |
|
|
/* First comes a type we are a subrange of.
|
4603 |
|
|
In C it is usually 0, 1 or the type being defined. */
|
4604 |
|
|
if (read_type_number (pp, rangenums) != 0)
|
4605 |
|
|
return error_type (pp, objfile);
|
4606 |
|
|
self_subrange = (rangenums[0] == typenums[0] &&
|
4607 |
|
|
rangenums[1] == typenums[1]);
|
4608 |
|
|
|
4609 |
|
|
if (**pp == '=')
|
4610 |
|
|
{
|
4611 |
|
|
*pp = orig_pp;
|
4612 |
|
|
index_type = read_type (pp, objfile);
|
4613 |
|
|
}
|
4614 |
|
|
|
4615 |
|
|
/* A semicolon should now follow; skip it. */
|
4616 |
|
|
if (**pp == ';')
|
4617 |
|
|
(*pp)++;
|
4618 |
|
|
|
4619 |
|
|
/* The remaining two operands are usually lower and upper bounds
|
4620 |
|
|
of the range. But in some special cases they mean something else. */
|
4621 |
|
|
n2 = read_huge_number (pp, ';', &n2bits);
|
4622 |
|
|
n3 = read_huge_number (pp, ';', &n3bits);
|
4623 |
|
|
|
4624 |
|
|
if (n2bits == -1 || n3bits == -1)
|
4625 |
|
|
return error_type (pp, objfile);
|
4626 |
|
|
|
4627 |
|
|
if (index_type)
|
4628 |
|
|
goto handle_true_range;
|
4629 |
|
|
|
4630 |
|
|
/* If limits are huge, must be large integral type. */
|
4631 |
|
|
if (n2bits != 0 || n3bits != 0)
|
4632 |
|
|
{
|
4633 |
|
|
char got_signed = 0;
|
4634 |
|
|
char got_unsigned = 0;
|
4635 |
|
|
/* Number of bits in the type. */
|
4636 |
|
|
int nbits = 0;
|
4637 |
|
|
|
4638 |
|
|
/* Range from 0 to <large number> is an unsigned large integral type. */
|
4639 |
|
|
if ((n2bits == 0 && n2 == 0) && n3bits != 0)
|
4640 |
|
|
{
|
4641 |
|
|
got_unsigned = 1;
|
4642 |
|
|
nbits = n3bits;
|
4643 |
|
|
}
|
4644 |
|
|
/* Range from <large number> to <large number>-1 is a large signed
|
4645 |
|
|
integral type. Take care of the case where <large number> doesn't
|
4646 |
|
|
fit in a long but <large number>-1 does. */
|
4647 |
|
|
else if ((n2bits != 0 && n3bits != 0 && n2bits == n3bits + 1)
|
4648 |
|
|
|| (n2bits != 0 && n3bits == 0
|
4649 |
|
|
&& (n2bits == sizeof (long) * HOST_CHAR_BIT)
|
4650 |
|
|
&& n3 == LONG_MAX))
|
4651 |
|
|
{
|
4652 |
|
|
got_signed = 1;
|
4653 |
|
|
nbits = n2bits;
|
4654 |
|
|
}
|
4655 |
|
|
|
4656 |
|
|
if (got_signed || got_unsigned)
|
4657 |
|
|
{
|
4658 |
|
|
return init_type (TYPE_CODE_INT, nbits / TARGET_CHAR_BIT,
|
4659 |
|
|
got_unsigned ? TYPE_FLAG_UNSIGNED : 0, NULL,
|
4660 |
|
|
objfile);
|
4661 |
|
|
}
|
4662 |
|
|
else
|
4663 |
|
|
return error_type (pp, objfile);
|
4664 |
|
|
}
|
4665 |
|
|
|
4666 |
|
|
/* A type defined as a subrange of itself, with bounds both 0, is void. */
|
4667 |
|
|
if (self_subrange && n2 == 0 && n3 == 0)
|
4668 |
|
|
return init_type (TYPE_CODE_VOID, 1, 0, NULL, objfile);
|
4669 |
|
|
|
4670 |
|
|
/* If n3 is zero and n2 is positive, we want a floating type, and n2
|
4671 |
|
|
is the width in bytes.
|
4672 |
|
|
|
4673 |
|
|
Fortran programs appear to use this for complex types also. To
|
4674 |
|
|
distinguish between floats and complex, g77 (and others?) seem
|
4675 |
|
|
to use self-subranges for the complexes, and subranges of int for
|
4676 |
|
|
the floats.
|
4677 |
|
|
|
4678 |
|
|
Also note that for complexes, g77 sets n2 to the size of one of
|
4679 |
|
|
the member floats, not the whole complex beast. My guess is that
|
4680 |
|
|
this was to work well with pre-COMPLEX versions of gdb. */
|
4681 |
|
|
|
4682 |
|
|
if (n3 == 0 && n2 > 0)
|
4683 |
|
|
{
|
4684 |
|
|
if (self_subrange)
|
4685 |
|
|
{
|
4686 |
|
|
return init_type (TYPE_CODE_COMPLEX, 2 * n2, 0, NULL, objfile);
|
4687 |
|
|
}
|
4688 |
|
|
else
|
4689 |
|
|
{
|
4690 |
|
|
return init_type (TYPE_CODE_FLT, n2, 0, NULL, objfile);
|
4691 |
|
|
}
|
4692 |
|
|
}
|
4693 |
|
|
|
4694 |
|
|
/* If the upper bound is -1, it must really be an unsigned int. */
|
4695 |
|
|
|
4696 |
|
|
else if (n2 == 0 && n3 == -1)
|
4697 |
|
|
{
|
4698 |
|
|
/* It is unsigned int or unsigned long. */
|
4699 |
|
|
/* GCC 2.3.3 uses this for long long too, but that is just a GDB 3.5
|
4700 |
|
|
compatibility hack. */
|
4701 |
|
|
return init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
|
4702 |
|
|
TYPE_FLAG_UNSIGNED, NULL, objfile);
|
4703 |
|
|
}
|
4704 |
|
|
|
4705 |
|
|
/* Special case: char is defined (Who knows why) as a subrange of
|
4706 |
|
|
itself with range 0-127. */
|
4707 |
|
|
else if (self_subrange && n2 == 0 && n3 == 127)
|
4708 |
|
|
return init_type (TYPE_CODE_INT, 1, 0, NULL, objfile);
|
4709 |
|
|
|
4710 |
|
|
else if (current_symbol && SYMBOL_LANGUAGE (current_symbol) == language_chill
|
4711 |
|
|
&& !self_subrange)
|
4712 |
|
|
goto handle_true_range;
|
4713 |
|
|
|
4714 |
|
|
/* We used to do this only for subrange of self or subrange of int. */
|
4715 |
|
|
else if (n2 == 0)
|
4716 |
|
|
{
|
4717 |
|
|
/* -1 is used for the upper bound of (4 byte) "unsigned int" and
|
4718 |
|
|
"unsigned long", and we already checked for that,
|
4719 |
|
|
so don't need to test for it here. */
|
4720 |
|
|
|
4721 |
|
|
if (n3 < 0)
|
4722 |
|
|
/* n3 actually gives the size. */
|
4723 |
|
|
return init_type (TYPE_CODE_INT, -n3, TYPE_FLAG_UNSIGNED,
|
4724 |
|
|
NULL, objfile);
|
4725 |
|
|
|
4726 |
|
|
/* Is n3 == 2**(8n)-1 for some integer n? Then it's an
|
4727 |
|
|
unsigned n-byte integer. But do require n to be a power of
|
4728 |
|
|
two; we don't want 3- and 5-byte integers flying around. */
|
4729 |
|
|
{
|
4730 |
|
|
int bytes;
|
4731 |
|
|
unsigned long bits;
|
4732 |
|
|
|
4733 |
|
|
bits = n3;
|
4734 |
|
|
for (bytes = 0; (bits & 0xff) == 0xff; bytes++)
|
4735 |
|
|
bits >>= 8;
|
4736 |
|
|
if (bits == 0
|
4737 |
|
|
&& ((bytes - 1) & bytes) == 0) /* "bytes is a power of two" */
|
4738 |
|
|
return init_type (TYPE_CODE_INT, bytes, TYPE_FLAG_UNSIGNED, NULL,
|
4739 |
|
|
objfile);
|
4740 |
|
|
}
|
4741 |
|
|
}
|
4742 |
|
|
/* I think this is for Convex "long long". Since I don't know whether
|
4743 |
|
|
Convex sets self_subrange, I also accept that particular size regardless
|
4744 |
|
|
of self_subrange. */
|
4745 |
|
|
else if (n3 == 0 && n2 < 0
|
4746 |
|
|
&& (self_subrange
|
4747 |
|
|
|| n2 == -TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT))
|
4748 |
|
|
return init_type (TYPE_CODE_INT, -n2, 0, NULL, objfile);
|
4749 |
|
|
else if (n2 == -n3 - 1)
|
4750 |
|
|
{
|
4751 |
|
|
if (n3 == 0x7f)
|
4752 |
|
|
return init_type (TYPE_CODE_INT, 1, 0, NULL, objfile);
|
4753 |
|
|
if (n3 == 0x7fff)
|
4754 |
|
|
return init_type (TYPE_CODE_INT, 2, 0, NULL, objfile);
|
4755 |
|
|
if (n3 == 0x7fffffff)
|
4756 |
|
|
return init_type (TYPE_CODE_INT, 4, 0, NULL, objfile);
|
4757 |
|
|
}
|
4758 |
|
|
|
4759 |
|
|
/* We have a real range type on our hands. Allocate space and
|
4760 |
|
|
return a real pointer. */
|
4761 |
|
|
handle_true_range:
|
4762 |
|
|
|
4763 |
|
|
if (self_subrange)
|
4764 |
|
|
index_type = builtin_type_int;
|
4765 |
|
|
else
|
4766 |
|
|
index_type = *dbx_lookup_type (rangenums);
|
4767 |
|
|
if (index_type == NULL)
|
4768 |
|
|
{
|
4769 |
|
|
/* Does this actually ever happen? Is that why we are worrying
|
4770 |
|
|
about dealing with it rather than just calling error_type? */
|
4771 |
|
|
|
4772 |
|
|
static struct type *range_type_index;
|
4773 |
|
|
|
4774 |
|
|
complain (&range_type_base_complaint, rangenums[1]);
|
4775 |
|
|
if (range_type_index == NULL)
|
4776 |
|
|
range_type_index =
|
4777 |
|
|
init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
|
4778 |
|
|
0, "range type index type", NULL);
|
4779 |
|
|
index_type = range_type_index;
|
4780 |
|
|
}
|
4781 |
|
|
|
4782 |
|
|
result_type = create_range_type ((struct type *) NULL, index_type, n2, n3);
|
4783 |
|
|
return (result_type);
|
4784 |
|
|
}
|
4785 |
|
|
|
4786 |
|
|
/* Read in an argument list. This is a list of types, separated by commas
|
4787 |
|
|
and terminated with END. Return the list of types read in, or (struct type
|
4788 |
|
|
**)-1 if there is an error. */
|
4789 |
|
|
|
4790 |
|
|
static struct type **
|
4791 |
|
|
read_args (pp, end, objfile)
|
4792 |
|
|
char **pp;
|
4793 |
|
|
int end;
|
4794 |
|
|
struct objfile *objfile;
|
4795 |
|
|
{
|
4796 |
|
|
/* FIXME! Remove this arbitrary limit! */
|
4797 |
|
|
struct type *types[1024], **rval; /* allow for fns of 1023 parameters */
|
4798 |
|
|
int n = 0;
|
4799 |
|
|
|
4800 |
|
|
while (**pp != end)
|
4801 |
|
|
{
|
4802 |
|
|
if (**pp != ',')
|
4803 |
|
|
/* Invalid argument list: no ','. */
|
4804 |
|
|
return (struct type **) -1;
|
4805 |
|
|
(*pp)++;
|
4806 |
|
|
STABS_CONTINUE (pp, objfile);
|
4807 |
|
|
types[n++] = read_type (pp, objfile);
|
4808 |
|
|
}
|
4809 |
|
|
(*pp)++; /* get past `end' (the ':' character) */
|
4810 |
|
|
|
4811 |
|
|
if (n == 1)
|
4812 |
|
|
{
|
4813 |
|
|
rval = (struct type **) xmalloc (2 * sizeof (struct type *));
|
4814 |
|
|
}
|
4815 |
|
|
else if (TYPE_CODE (types[n - 1]) != TYPE_CODE_VOID)
|
4816 |
|
|
{
|
4817 |
|
|
rval = (struct type **) xmalloc ((n + 1) * sizeof (struct type *));
|
4818 |
|
|
memset (rval + n, 0, sizeof (struct type *));
|
4819 |
|
|
}
|
4820 |
|
|
else
|
4821 |
|
|
{
|
4822 |
|
|
rval = (struct type **) xmalloc (n * sizeof (struct type *));
|
4823 |
|
|
}
|
4824 |
|
|
memcpy (rval, types, n * sizeof (struct type *));
|
4825 |
|
|
return rval;
|
4826 |
|
|
}
|
4827 |
|
|
|
4828 |
|
|
/* Common block handling. */
|
4829 |
|
|
|
4830 |
|
|
/* List of symbols declared since the last BCOMM. This list is a tail
|
4831 |
|
|
of local_symbols. When ECOMM is seen, the symbols on the list
|
4832 |
|
|
are noted so their proper addresses can be filled in later,
|
4833 |
|
|
using the common block base address gotten from the assembler
|
4834 |
|
|
stabs. */
|
4835 |
|
|
|
4836 |
|
|
static struct pending *common_block;
|
4837 |
|
|
static int common_block_i;
|
4838 |
|
|
|
4839 |
|
|
/* Name of the current common block. We get it from the BCOMM instead of the
|
4840 |
|
|
ECOMM to match IBM documentation (even though IBM puts the name both places
|
4841 |
|
|
like everyone else). */
|
4842 |
|
|
static char *common_block_name;
|
4843 |
|
|
|
4844 |
|
|
/* Process a N_BCOMM symbol. The storage for NAME is not guaranteed
|
4845 |
|
|
to remain after this function returns. */
|
4846 |
|
|
|
4847 |
|
|
void
|
4848 |
|
|
common_block_start (name, objfile)
|
4849 |
|
|
char *name;
|
4850 |
|
|
struct objfile *objfile;
|
4851 |
|
|
{
|
4852 |
|
|
if (common_block_name != NULL)
|
4853 |
|
|
{
|
4854 |
|
|
static struct complaint msg =
|
4855 |
|
|
{
|
4856 |
|
|
"Invalid symbol data: common block within common block",
|
4857 |
|
|
0, 0};
|
4858 |
|
|
complain (&msg);
|
4859 |
|
|
}
|
4860 |
|
|
common_block = local_symbols;
|
4861 |
|
|
common_block_i = local_symbols ? local_symbols->nsyms : 0;
|
4862 |
|
|
common_block_name = obsavestring (name, strlen (name),
|
4863 |
|
|
&objfile->symbol_obstack);
|
4864 |
|
|
}
|
4865 |
|
|
|
4866 |
|
|
/* Process a N_ECOMM symbol. */
|
4867 |
|
|
|
4868 |
|
|
void
|
4869 |
|
|
common_block_end (objfile)
|
4870 |
|
|
struct objfile *objfile;
|
4871 |
|
|
{
|
4872 |
|
|
/* Symbols declared since the BCOMM are to have the common block
|
4873 |
|
|
start address added in when we know it. common_block and
|
4874 |
|
|
common_block_i point to the first symbol after the BCOMM in
|
4875 |
|
|
the local_symbols list; copy the list and hang it off the
|
4876 |
|
|
symbol for the common block name for later fixup. */
|
4877 |
|
|
int i;
|
4878 |
|
|
struct symbol *sym;
|
4879 |
|
|
struct pending *new = 0;
|
4880 |
|
|
struct pending *next;
|
4881 |
|
|
int j;
|
4882 |
|
|
|
4883 |
|
|
if (common_block_name == NULL)
|
4884 |
|
|
{
|
4885 |
|
|
static struct complaint msg =
|
4886 |
|
|
{"ECOMM symbol unmatched by BCOMM", 0, 0};
|
4887 |
|
|
complain (&msg);
|
4888 |
|
|
return;
|
4889 |
|
|
}
|
4890 |
|
|
|
4891 |
|
|
sym = (struct symbol *)
|
4892 |
|
|
obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
|
4893 |
|
|
memset (sym, 0, sizeof (struct symbol));
|
4894 |
|
|
/* Note: common_block_name already saved on symbol_obstack */
|
4895 |
|
|
SYMBOL_NAME (sym) = common_block_name;
|
4896 |
|
|
SYMBOL_CLASS (sym) = LOC_BLOCK;
|
4897 |
|
|
|
4898 |
|
|
/* Now we copy all the symbols which have been defined since the BCOMM. */
|
4899 |
|
|
|
4900 |
|
|
/* Copy all the struct pendings before common_block. */
|
4901 |
|
|
for (next = local_symbols;
|
4902 |
|
|
next != NULL && next != common_block;
|
4903 |
|
|
next = next->next)
|
4904 |
|
|
{
|
4905 |
|
|
for (j = 0; j < next->nsyms; j++)
|
4906 |
|
|
add_symbol_to_list (next->symbol[j], &new);
|
4907 |
|
|
}
|
4908 |
|
|
|
4909 |
|
|
/* Copy however much of COMMON_BLOCK we need. If COMMON_BLOCK is
|
4910 |
|
|
NULL, it means copy all the local symbols (which we already did
|
4911 |
|
|
above). */
|
4912 |
|
|
|
4913 |
|
|
if (common_block != NULL)
|
4914 |
|
|
for (j = common_block_i; j < common_block->nsyms; j++)
|
4915 |
|
|
add_symbol_to_list (common_block->symbol[j], &new);
|
4916 |
|
|
|
4917 |
|
|
SYMBOL_TYPE (sym) = (struct type *) new;
|
4918 |
|
|
|
4919 |
|
|
/* Should we be putting local_symbols back to what it was?
|
4920 |
|
|
Does it matter? */
|
4921 |
|
|
|
4922 |
|
|
i = hashname (SYMBOL_NAME (sym));
|
4923 |
|
|
SYMBOL_VALUE_CHAIN (sym) = global_sym_chain[i];
|
4924 |
|
|
global_sym_chain[i] = sym;
|
4925 |
|
|
common_block_name = NULL;
|
4926 |
|
|
}
|
4927 |
|
|
|
4928 |
|
|
/* Add a common block's start address to the offset of each symbol
|
4929 |
|
|
declared to be in it (by being between a BCOMM/ECOMM pair that uses
|
4930 |
|
|
the common block name). */
|
4931 |
|
|
|
4932 |
|
|
static void
|
4933 |
|
|
fix_common_block (sym, valu)
|
4934 |
|
|
struct symbol *sym;
|
4935 |
|
|
int valu;
|
4936 |
|
|
{
|
4937 |
|
|
struct pending *next = (struct pending *) SYMBOL_TYPE (sym);
|
4938 |
|
|
for (; next; next = next->next)
|
4939 |
|
|
{
|
4940 |
|
|
register int j;
|
4941 |
|
|
for (j = next->nsyms - 1; j >= 0; j--)
|
4942 |
|
|
SYMBOL_VALUE_ADDRESS (next->symbol[j]) += valu;
|
4943 |
|
|
}
|
4944 |
|
|
}
|
4945 |
|
|
|
4946 |
|
|
|
4947 |
|
|
|
4948 |
|
|
/* What about types defined as forward references inside of a small lexical
|
4949 |
|
|
scope? */
|
4950 |
|
|
/* Add a type to the list of undefined types to be checked through
|
4951 |
|
|
once this file has been read in. */
|
4952 |
|
|
|
4953 |
|
|
void
|
4954 |
|
|
add_undefined_type (type)
|
4955 |
|
|
struct type *type;
|
4956 |
|
|
{
|
4957 |
|
|
if (undef_types_length == undef_types_allocated)
|
4958 |
|
|
{
|
4959 |
|
|
undef_types_allocated *= 2;
|
4960 |
|
|
undef_types = (struct type **)
|
4961 |
|
|
xrealloc ((char *) undef_types,
|
4962 |
|
|
undef_types_allocated * sizeof (struct type *));
|
4963 |
|
|
}
|
4964 |
|
|
undef_types[undef_types_length++] = type;
|
4965 |
|
|
}
|
4966 |
|
|
|
4967 |
|
|
/* Go through each undefined type, see if it's still undefined, and fix it
|
4968 |
|
|
up if possible. We have two kinds of undefined types:
|
4969 |
|
|
|
4970 |
|
|
TYPE_CODE_ARRAY: Array whose target type wasn't defined yet.
|
4971 |
|
|
Fix: update array length using the element bounds
|
4972 |
|
|
and the target type's length.
|
4973 |
|
|
TYPE_CODE_STRUCT, TYPE_CODE_UNION: Structure whose fields were not
|
4974 |
|
|
yet defined at the time a pointer to it was made.
|
4975 |
|
|
Fix: Do a full lookup on the struct/union tag. */
|
4976 |
|
|
void
|
4977 |
|
|
cleanup_undefined_types ()
|
4978 |
|
|
{
|
4979 |
|
|
struct type **type;
|
4980 |
|
|
|
4981 |
|
|
for (type = undef_types; type < undef_types + undef_types_length; type++)
|
4982 |
|
|
{
|
4983 |
|
|
switch (TYPE_CODE (*type))
|
4984 |
|
|
{
|
4985 |
|
|
|
4986 |
|
|
case TYPE_CODE_STRUCT:
|
4987 |
|
|
case TYPE_CODE_UNION:
|
4988 |
|
|
case TYPE_CODE_ENUM:
|
4989 |
|
|
{
|
4990 |
|
|
/* Check if it has been defined since. Need to do this here
|
4991 |
|
|
as well as in check_typedef to deal with the (legitimate in
|
4992 |
|
|
C though not C++) case of several types with the same name
|
4993 |
|
|
in different source files. */
|
4994 |
|
|
if (TYPE_FLAGS (*type) & TYPE_FLAG_STUB)
|
4995 |
|
|
{
|
4996 |
|
|
struct pending *ppt;
|
4997 |
|
|
int i;
|
4998 |
|
|
/* Name of the type, without "struct" or "union" */
|
4999 |
|
|
char *typename = TYPE_TAG_NAME (*type);
|
5000 |
|
|
|
5001 |
|
|
if (typename == NULL)
|
5002 |
|
|
{
|
5003 |
|
|
static struct complaint msg =
|
5004 |
|
|
{"need a type name", 0, 0};
|
5005 |
|
|
complain (&msg);
|
5006 |
|
|
break;
|
5007 |
|
|
}
|
5008 |
|
|
for (ppt = file_symbols; ppt; ppt = ppt->next)
|
5009 |
|
|
{
|
5010 |
|
|
for (i = 0; i < ppt->nsyms; i++)
|
5011 |
|
|
{
|
5012 |
|
|
struct symbol *sym = ppt->symbol[i];
|
5013 |
|
|
|
5014 |
|
|
if (SYMBOL_CLASS (sym) == LOC_TYPEDEF
|
5015 |
|
|
&& SYMBOL_NAMESPACE (sym) == STRUCT_NAMESPACE
|
5016 |
|
|
&& (TYPE_CODE (SYMBOL_TYPE (sym)) ==
|
5017 |
|
|
TYPE_CODE (*type))
|
5018 |
|
|
&& STREQ (SYMBOL_NAME (sym), typename))
|
5019 |
|
|
{
|
5020 |
|
|
memcpy (*type, SYMBOL_TYPE (sym),
|
5021 |
|
|
sizeof (struct type));
|
5022 |
|
|
}
|
5023 |
|
|
}
|
5024 |
|
|
}
|
5025 |
|
|
}
|
5026 |
|
|
}
|
5027 |
|
|
break;
|
5028 |
|
|
|
5029 |
|
|
default:
|
5030 |
|
|
{
|
5031 |
|
|
static struct complaint msg =
|
5032 |
|
|
{"\
|
5033 |
|
|
GDB internal error. cleanup_undefined_types with bad type %d.", 0, 0};
|
5034 |
|
|
complain (&msg, TYPE_CODE (*type));
|
5035 |
|
|
}
|
5036 |
|
|
break;
|
5037 |
|
|
}
|
5038 |
|
|
}
|
5039 |
|
|
|
5040 |
|
|
undef_types_length = 0;
|
5041 |
|
|
}
|
5042 |
|
|
|
5043 |
|
|
/* Scan through all of the global symbols defined in the object file,
|
5044 |
|
|
assigning values to the debugging symbols that need to be assigned
|
5045 |
|
|
to. Get these symbols from the minimal symbol table. */
|
5046 |
|
|
|
5047 |
|
|
void
|
5048 |
|
|
scan_file_globals (objfile)
|
5049 |
|
|
struct objfile *objfile;
|
5050 |
|
|
{
|
5051 |
|
|
int hash;
|
5052 |
|
|
struct minimal_symbol *msymbol;
|
5053 |
|
|
struct symbol *sym, *prev, *rsym;
|
5054 |
|
|
struct objfile *resolve_objfile;
|
5055 |
|
|
|
5056 |
|
|
/* SVR4 based linkers copy referenced global symbols from shared
|
5057 |
|
|
libraries to the main executable.
|
5058 |
|
|
If we are scanning the symbols for a shared library, try to resolve
|
5059 |
|
|
them from the minimal symbols of the main executable first. */
|
5060 |
|
|
|
5061 |
|
|
if (symfile_objfile && objfile != symfile_objfile)
|
5062 |
|
|
resolve_objfile = symfile_objfile;
|
5063 |
|
|
else
|
5064 |
|
|
resolve_objfile = objfile;
|
5065 |
|
|
|
5066 |
|
|
while (1)
|
5067 |
|
|
{
|
5068 |
|
|
/* Avoid expensive loop through all minimal symbols if there are
|
5069 |
|
|
no unresolved symbols. */
|
5070 |
|
|
for (hash = 0; hash < HASHSIZE; hash++)
|
5071 |
|
|
{
|
5072 |
|
|
if (global_sym_chain[hash])
|
5073 |
|
|
break;
|
5074 |
|
|
}
|
5075 |
|
|
if (hash >= HASHSIZE)
|
5076 |
|
|
return;
|
5077 |
|
|
|
5078 |
|
|
for (msymbol = resolve_objfile->msymbols;
|
5079 |
|
|
msymbol && SYMBOL_NAME (msymbol) != NULL;
|
5080 |
|
|
msymbol++)
|
5081 |
|
|
{
|
5082 |
|
|
QUIT;
|
5083 |
|
|
|
5084 |
|
|
/* Skip static symbols. */
|
5085 |
|
|
switch (MSYMBOL_TYPE (msymbol))
|
5086 |
|
|
{
|
5087 |
|
|
case mst_file_text:
|
5088 |
|
|
case mst_file_data:
|
5089 |
|
|
case mst_file_bss:
|
5090 |
|
|
continue;
|
5091 |
|
|
default:
|
5092 |
|
|
break;
|
5093 |
|
|
}
|
5094 |
|
|
|
5095 |
|
|
prev = NULL;
|
5096 |
|
|
|
5097 |
|
|
/* Get the hash index and check all the symbols
|
5098 |
|
|
under that hash index. */
|
5099 |
|
|
|
5100 |
|
|
hash = hashname (SYMBOL_NAME (msymbol));
|
5101 |
|
|
|
5102 |
|
|
for (sym = global_sym_chain[hash]; sym;)
|
5103 |
|
|
{
|
5104 |
|
|
if (SYMBOL_NAME (msymbol)[0] == SYMBOL_NAME (sym)[0] &&
|
5105 |
|
|
STREQ (SYMBOL_NAME (msymbol) + 1, SYMBOL_NAME (sym) + 1))
|
5106 |
|
|
{
|
5107 |
|
|
|
5108 |
|
|
struct alias_list *aliases;
|
5109 |
|
|
|
5110 |
|
|
/* Splice this symbol out of the hash chain and
|
5111 |
|
|
assign the value we have to it. */
|
5112 |
|
|
if (prev)
|
5113 |
|
|
{
|
5114 |
|
|
SYMBOL_VALUE_CHAIN (prev) = SYMBOL_VALUE_CHAIN (sym);
|
5115 |
|
|
}
|
5116 |
|
|
else
|
5117 |
|
|
{
|
5118 |
|
|
global_sym_chain[hash] = SYMBOL_VALUE_CHAIN (sym);
|
5119 |
|
|
}
|
5120 |
|
|
|
5121 |
|
|
/* Check to see whether we need to fix up a common block. */
|
5122 |
|
|
/* Note: this code might be executed several times for
|
5123 |
|
|
the same symbol if there are multiple references. */
|
5124 |
|
|
|
5125 |
|
|
/* If symbol has aliases, do minimal symbol fixups for each.
|
5126 |
|
|
These live aliases/references weren't added to
|
5127 |
|
|
global_sym_chain hash but may also need to be fixed up. */
|
5128 |
|
|
/* FIXME: Maybe should have added aliases to the global chain, resolved symbol name, then treated aliases as normal
|
5129 |
|
|
symbols? Still, we wouldn't want to add_to_list. */
|
5130 |
|
|
/* Now do the same for each alias of this symbol */
|
5131 |
|
|
rsym = sym;
|
5132 |
|
|
aliases = SYMBOL_ALIASES (sym);
|
5133 |
|
|
while (rsym)
|
5134 |
|
|
{
|
5135 |
|
|
if (SYMBOL_CLASS (rsym) == LOC_BLOCK)
|
5136 |
|
|
{
|
5137 |
|
|
fix_common_block (rsym,
|
5138 |
|
|
SYMBOL_VALUE_ADDRESS (msymbol));
|
5139 |
|
|
}
|
5140 |
|
|
else
|
5141 |
|
|
{
|
5142 |
|
|
SYMBOL_VALUE_ADDRESS (rsym)
|
5143 |
|
|
= SYMBOL_VALUE_ADDRESS (msymbol);
|
5144 |
|
|
}
|
5145 |
|
|
SYMBOL_SECTION (rsym) = SYMBOL_SECTION (msymbol);
|
5146 |
|
|
if (aliases)
|
5147 |
|
|
{
|
5148 |
|
|
rsym = aliases->sym;
|
5149 |
|
|
aliases = aliases->next;
|
5150 |
|
|
}
|
5151 |
|
|
else
|
5152 |
|
|
rsym = NULL;
|
5153 |
|
|
}
|
5154 |
|
|
|
5155 |
|
|
|
5156 |
|
|
if (prev)
|
5157 |
|
|
{
|
5158 |
|
|
sym = SYMBOL_VALUE_CHAIN (prev);
|
5159 |
|
|
}
|
5160 |
|
|
else
|
5161 |
|
|
{
|
5162 |
|
|
sym = global_sym_chain[hash];
|
5163 |
|
|
}
|
5164 |
|
|
}
|
5165 |
|
|
else
|
5166 |
|
|
{
|
5167 |
|
|
prev = sym;
|
5168 |
|
|
sym = SYMBOL_VALUE_CHAIN (sym);
|
5169 |
|
|
}
|
5170 |
|
|
}
|
5171 |
|
|
}
|
5172 |
|
|
if (resolve_objfile == objfile)
|
5173 |
|
|
break;
|
5174 |
|
|
resolve_objfile = objfile;
|
5175 |
|
|
}
|
5176 |
|
|
|
5177 |
|
|
/* Change the storage class of any remaining unresolved globals to
|
5178 |
|
|
LOC_UNRESOLVED and remove them from the chain. */
|
5179 |
|
|
for (hash = 0; hash < HASHSIZE; hash++)
|
5180 |
|
|
{
|
5181 |
|
|
sym = global_sym_chain[hash];
|
5182 |
|
|
while (sym)
|
5183 |
|
|
{
|
5184 |
|
|
prev = sym;
|
5185 |
|
|
sym = SYMBOL_VALUE_CHAIN (sym);
|
5186 |
|
|
|
5187 |
|
|
/* Change the symbol address from the misleading chain value
|
5188 |
|
|
to address zero. */
|
5189 |
|
|
SYMBOL_VALUE_ADDRESS (prev) = 0;
|
5190 |
|
|
|
5191 |
|
|
/* Complain about unresolved common block symbols. */
|
5192 |
|
|
if (SYMBOL_CLASS (prev) == LOC_STATIC)
|
5193 |
|
|
SYMBOL_CLASS (prev) = LOC_UNRESOLVED;
|
5194 |
|
|
else
|
5195 |
|
|
complain (&unresolved_sym_chain_complaint,
|
5196 |
|
|
objfile->name, SYMBOL_NAME (prev));
|
5197 |
|
|
}
|
5198 |
|
|
}
|
5199 |
|
|
memset (global_sym_chain, 0, sizeof (global_sym_chain));
|
5200 |
|
|
}
|
5201 |
|
|
|
5202 |
|
|
/* Initialize anything that needs initializing when starting to read
|
5203 |
|
|
a fresh piece of a symbol file, e.g. reading in the stuff corresponding
|
5204 |
|
|
to a psymtab. */
|
5205 |
|
|
|
5206 |
|
|
void
|
5207 |
|
|
stabsread_init ()
|
5208 |
|
|
{
|
5209 |
|
|
}
|
5210 |
|
|
|
5211 |
|
|
/* Initialize anything that needs initializing when a completely new
|
5212 |
|
|
symbol file is specified (not just adding some symbols from another
|
5213 |
|
|
file, e.g. a shared library). */
|
5214 |
|
|
|
5215 |
|
|
void
|
5216 |
|
|
stabsread_new_init ()
|
5217 |
|
|
{
|
5218 |
|
|
/* Empty the hash table of global syms looking for values. */
|
5219 |
|
|
memset (global_sym_chain, 0, sizeof (global_sym_chain));
|
5220 |
|
|
}
|
5221 |
|
|
|
5222 |
|
|
/* Initialize anything that needs initializing at the same time as
|
5223 |
|
|
start_symtab() is called. */
|
5224 |
|
|
|
5225 |
|
|
void
|
5226 |
|
|
start_stabs ()
|
5227 |
|
|
{
|
5228 |
|
|
global_stabs = NULL; /* AIX COFF */
|
5229 |
|
|
/* Leave FILENUM of 0 free for builtin types and this file's types. */
|
5230 |
|
|
n_this_object_header_files = 1;
|
5231 |
|
|
type_vector_length = 0;
|
5232 |
|
|
type_vector = (struct type **) 0;
|
5233 |
|
|
|
5234 |
|
|
/* FIXME: If common_block_name is not already NULL, we should complain(). */
|
5235 |
|
|
common_block_name = NULL;
|
5236 |
|
|
|
5237 |
|
|
os9k_stabs = 0;
|
5238 |
|
|
}
|
5239 |
|
|
|
5240 |
|
|
/* Call after end_symtab() */
|
5241 |
|
|
|
5242 |
|
|
void
|
5243 |
|
|
end_stabs ()
|
5244 |
|
|
{
|
5245 |
|
|
if (type_vector)
|
5246 |
|
|
{
|
5247 |
|
|
free ((char *) type_vector);
|
5248 |
|
|
}
|
5249 |
|
|
type_vector = 0;
|
5250 |
|
|
type_vector_length = 0;
|
5251 |
|
|
previous_stab_code = 0;
|
5252 |
|
|
}
|
5253 |
|
|
|
5254 |
|
|
void
|
5255 |
|
|
finish_global_stabs (objfile)
|
5256 |
|
|
struct objfile *objfile;
|
5257 |
|
|
{
|
5258 |
|
|
if (global_stabs)
|
5259 |
|
|
{
|
5260 |
|
|
patch_block_stabs (global_symbols, global_stabs, objfile);
|
5261 |
|
|
free ((PTR) global_stabs);
|
5262 |
|
|
global_stabs = NULL;
|
5263 |
|
|
}
|
5264 |
|
|
}
|
5265 |
|
|
|
5266 |
|
|
/* Initializer for this module */
|
5267 |
|
|
|
5268 |
|
|
void
|
5269 |
|
|
_initialize_stabsread ()
|
5270 |
|
|
{
|
5271 |
|
|
undef_types_allocated = 20;
|
5272 |
|
|
undef_types_length = 0;
|
5273 |
|
|
undef_types = (struct type **)
|
5274 |
|
|
xmalloc (undef_types_allocated * sizeof (struct type *));
|
5275 |
|
|
}
|