Commit | Line | Data |
---|---|---|
65b07ddc DT |
1 | /* Read hp debug symbols and convert to internal format, for GDB. |
2 | Copyright 1993, 1996 Free Software Foundation, Inc. | |
3 | ||
4 | This file is part of GDB. | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2 of the License, or | |
9 | (at your option) any later version. | |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with this program; if not, write to the Free Software | |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
19 | ||
20 | Written by the Center for Software Science at the University of Utah | |
21 | and by Cygnus Support. */ | |
22 | ||
23 | /* Common include for hp-symtab-read.c and hp-psymtab-read.c. | |
24 | * Note this has nested includes for a bunch of stuff. | |
25 | */ | |
26 | #include "defs.h" | |
27 | #include "symtab.h" | |
28 | #include "gdbtypes.h" | |
29 | #include "hpread.h" | |
30 | #include "demangle.h" | |
31 | #include "complaints.h" | |
32 | ||
33 | \f | |
34 | ||
35 | ||
36 | static struct complaint hpread_unhandled_end_common_complaint = | |
37 | { | |
38 | "unhandled symbol in hp-symtab-read.c: DNTT_TYPE_COMMON/DNTT_TYPE_END.\n", 0, 0 | |
39 | }; | |
40 | ||
41 | static struct complaint hpread_unhandled_type_complaint = | |
42 | { | |
43 | "hpread_type_translate: unhandled type code.", 0, 0 | |
44 | }; | |
45 | ||
46 | static struct complaint hpread_struct_complaint = | |
47 | { | |
48 | "hpread_read_struct_type: expected SVAR type...", 0, 0 | |
49 | }; | |
50 | ||
51 | static struct complaint hpread_array_complaint = | |
52 | { | |
53 | "error in hpread_array_type.", 0, 0 | |
54 | }; | |
55 | ||
56 | static struct complaint hpread_type_lookup_complaint = | |
57 | { | |
58 | "error in hpread_type_lookup().", 0, 0 | |
59 | }; | |
60 | ||
61 | ||
62 | static struct complaint hpread_unexpected_end_complaint = | |
63 | { | |
64 | "internal error in hp-symtab-read.c: Unexpected DNTT_TYPE_END kind.", 0, 0 | |
65 | }; | |
66 | ||
67 | static struct complaint hpread_tagdef_complaint = | |
68 | { | |
69 | "error processing class tagdef", 0, 0 | |
70 | }; | |
71 | ||
72 | static struct complaint hpread_unhandled_common_complaint = | |
73 | { | |
74 | "unhandled symbol in hp-symtab-read.c: DNTT_TYPE_COMMON.", 0, 0 | |
75 | }; | |
76 | ||
77 | static struct complaint hpread_unhandled_blockdata_complaint = | |
78 | { | |
79 | "unhandled symbol in hp-symtab-read.c: DNTT_TYPE_BLOCKDATA.", 0, 0 | |
80 | }; | |
81 | ||
82 | ||
83 | /* Forward procedure declarations */ | |
84 | ||
85 | static unsigned long hpread_get_scope_start | |
86 | PARAMS ((sltpointer, struct objfile *)); | |
87 | ||
88 | static unsigned long hpread_get_line | |
89 | PARAMS ((sltpointer, struct objfile *)); | |
90 | ||
91 | static CORE_ADDR hpread_get_location | |
92 | PARAMS ((sltpointer, struct objfile *)); | |
93 | ||
94 | static void hpread_psymtab_to_symtab_1 | |
95 | PARAMS ((struct partial_symtab *)); | |
96 | ||
97 | void hpread_psymtab_to_symtab | |
98 | PARAMS ((struct partial_symtab *)); | |
99 | ||
100 | static struct symtab *hpread_expand_symtab | |
101 | PARAMS ((struct objfile *, int, int, CORE_ADDR, int, | |
102 | struct section_offsets *, char *)); | |
103 | ||
104 | static int hpread_type_translate | |
105 | PARAMS ((dnttpointer)); | |
106 | ||
107 | static struct type **hpread_lookup_type | |
108 | PARAMS ((dnttpointer, struct objfile *)); | |
109 | ||
110 | static struct type *hpread_alloc_type | |
111 | PARAMS ((dnttpointer, struct objfile *)); | |
112 | ||
113 | static struct type *hpread_read_enum_type | |
114 | PARAMS ((dnttpointer, union dnttentry *, struct objfile *)); | |
115 | ||
116 | static struct type *hpread_read_function_type | |
117 | PARAMS ((dnttpointer, union dnttentry *, struct objfile *, int)); | |
118 | ||
119 | static struct type *hpread_read_doc_function_type | |
120 | PARAMS ((dnttpointer, union dnttentry *, struct objfile *, int)); | |
121 | ||
122 | static struct type *hpread_read_struct_type | |
123 | PARAMS ((dnttpointer, union dnttentry *, struct objfile *)); | |
124 | ||
125 | static struct type *hpread_get_nth_template_arg | |
126 | PARAMS ((struct objfile *, int)); | |
127 | ||
128 | static struct type * hpread_read_templ_arg_type | |
129 | PARAMS ((dnttpointer, union dnttentry *, struct objfile *, char *)); | |
130 | ||
131 | static struct type *hpread_read_set_type | |
132 | PARAMS ((dnttpointer, union dnttentry *, struct objfile *)); | |
133 | ||
134 | static struct type * hpread_read_array_type | |
135 | PARAMS ((dnttpointer, union dnttentry *dn_bufp, struct objfile *objfile)); | |
136 | ||
137 | static struct type *hpread_read_subrange_type | |
138 | PARAMS ((dnttpointer, union dnttentry *, struct objfile *)); | |
139 | ||
140 | static struct type * hpread_type_lookup | |
141 | PARAMS ((dnttpointer, struct objfile *)); | |
142 | ||
143 | static sltpointer hpread_record_lines | |
144 | PARAMS ((struct subfile *, sltpointer, sltpointer, | |
145 | struct objfile *, CORE_ADDR)); | |
146 | ||
147 | static void hpread_process_one_debug_symbol | |
148 | PARAMS ((union dnttentry *, char *, struct section_offsets *, | |
149 | struct objfile *, CORE_ADDR, int, char *, int, int * )); | |
150 | ||
151 | static int hpread_get_scope_depth | |
152 | PARAMS ((union dnttentry *, struct objfile *, int)); | |
153 | ||
154 | static void fix_static_member_physnames | |
155 | PARAMS ((struct type *, char *, struct objfile *)); | |
156 | ||
157 | static void fixup_class_method_type | |
158 | PARAMS ((struct type *, struct type *, struct objfile *)); | |
159 | ||
160 | static void hpread_adjust_bitoffsets PARAMS ((struct type *, int)); | |
161 | ||
162 | static dnttpointer hpread_get_next_skip_over_anon_unions | |
163 | PARAMS ((int, dnttpointer, union dnttentry **, struct objfile *)); | |
164 | ||
165 | /* Global to indicate presence of HP-compiled objects, | |
166 | in particular, SOM executable file with SOM debug info | |
167 | Defined in symtab.c, used in hppa-tdep.c. */ | |
168 | extern int hp_som_som_object_present; | |
169 | ||
170 | /* Static used to indicate a class type that requires a | |
171 | fix-up of one of its method types */ | |
172 | static struct type * fixup_class = NULL; | |
173 | ||
174 | /* Static used to indicate the method type that is to be | |
175 | used to fix-up the type for fixup_class */ | |
176 | static struct type * fixup_method = NULL; | |
177 | ||
178 | \f | |
179 | ||
180 | /* Get the nesting depth for the source line identified by INDEX. */ | |
181 | ||
182 | static unsigned long | |
183 | hpread_get_scope_start (index, objfile) | |
184 | sltpointer index; | |
185 | struct objfile *objfile; | |
186 | { | |
187 | union sltentry *sl_bufp; | |
188 | ||
189 | sl_bufp = hpread_get_slt (index, objfile); | |
190 | return sl_bufp->sspec.backptr.dnttp.index; | |
191 | } | |
192 | ||
193 | /* Get the source line number the the line identified by INDEX. */ | |
194 | ||
195 | static unsigned long | |
196 | hpread_get_line (index, objfile) | |
197 | sltpointer index; | |
198 | struct objfile *objfile; | |
199 | { | |
200 | union sltentry *sl_bufp; | |
201 | ||
202 | sl_bufp = hpread_get_slt (index, objfile); | |
203 | return sl_bufp->snorm.line; | |
204 | } | |
205 | ||
206 | /* Find the code address associated with a given sltpointer */ | |
207 | ||
208 | static CORE_ADDR | |
209 | hpread_get_location (index, objfile) | |
210 | sltpointer index; | |
211 | struct objfile *objfile; | |
212 | { | |
213 | union sltentry *sl_bufp; | |
214 | int i; | |
215 | ||
216 | /* code location of special sltentrys is determined from context */ | |
217 | sl_bufp = hpread_get_slt (index, objfile); | |
218 | ||
219 | if (sl_bufp->snorm.sltdesc == SLT_END) | |
220 | { | |
221 | /* find previous normal sltentry and get address */ | |
222 | for (i = 0; ((sl_bufp->snorm.sltdesc != SLT_NORMAL) && | |
223 | (sl_bufp->snorm.sltdesc != SLT_NORMAL_OFFSET) && | |
224 | (sl_bufp->snorm.sltdesc != SLT_EXIT)); i++) | |
225 | sl_bufp = hpread_get_slt (index - i, objfile); | |
226 | if (sl_bufp->snorm.sltdesc == SLT_NORMAL_OFFSET) | |
227 | return sl_bufp->snormoff.address; | |
228 | else | |
229 | return sl_bufp->snorm.address; | |
230 | } | |
231 | ||
232 | /* find next normal sltentry and get address */ | |
233 | for (i = 0; ((sl_bufp->snorm.sltdesc != SLT_NORMAL) && | |
234 | (sl_bufp->snorm.sltdesc != SLT_NORMAL_OFFSET) && | |
235 | (sl_bufp->snorm.sltdesc != SLT_EXIT)); i++) | |
236 | sl_bufp = hpread_get_slt (index + i, objfile); | |
237 | if (sl_bufp->snorm.sltdesc == SLT_NORMAL_OFFSET) | |
238 | return sl_bufp->snormoff.address; | |
239 | else | |
240 | return sl_bufp->snorm.address; | |
241 | } | |
242 | \f | |
243 | ||
244 | /* Return 1 if an HP debug symbol of type KIND has a name associated with | |
245 | * it, else return 0. (This function is not currently used, but I'll | |
246 | * leave it here in case it proves useful later on. - RT). | |
247 | */ | |
248 | ||
249 | int | |
250 | hpread_has_name (kind) | |
251 | enum dntt_entry_type kind; | |
252 | { | |
253 | switch (kind) | |
254 | { | |
255 | case DNTT_TYPE_SRCFILE: | |
256 | case DNTT_TYPE_MODULE: | |
257 | case DNTT_TYPE_FUNCTION: | |
258 | case DNTT_TYPE_DOC_FUNCTION: | |
259 | case DNTT_TYPE_ENTRY: | |
260 | case DNTT_TYPE_IMPORT: | |
261 | case DNTT_TYPE_LABEL: | |
262 | case DNTT_TYPE_FPARAM: | |
263 | case DNTT_TYPE_SVAR: | |
264 | case DNTT_TYPE_DVAR: | |
265 | case DNTT_TYPE_CONST: | |
266 | case DNTT_TYPE_TYPEDEF: | |
267 | case DNTT_TYPE_TAGDEF: | |
268 | case DNTT_TYPE_MEMENUM: | |
269 | case DNTT_TYPE_FIELD: | |
270 | case DNTT_TYPE_SA: | |
271 | case DNTT_TYPE_BLOCKDATA: | |
272 | case DNTT_TYPE_MEMFUNC: | |
273 | case DNTT_TYPE_DOC_MEMFUNC: | |
274 | return 1; | |
275 | ||
276 | case DNTT_TYPE_BEGIN: | |
277 | case DNTT_TYPE_END: | |
278 | case DNTT_TYPE_POINTER: | |
279 | case DNTT_TYPE_ENUM: | |
280 | case DNTT_TYPE_SET: | |
281 | case DNTT_TYPE_ARRAY: | |
282 | case DNTT_TYPE_STRUCT: | |
283 | case DNTT_TYPE_UNION: | |
284 | case DNTT_TYPE_VARIANT: | |
285 | case DNTT_TYPE_FILE: | |
286 | case DNTT_TYPE_FUNCTYPE: | |
287 | case DNTT_TYPE_SUBRANGE: | |
288 | case DNTT_TYPE_WITH: | |
289 | case DNTT_TYPE_COMMON: | |
290 | case DNTT_TYPE_COBSTRUCT: | |
291 | case DNTT_TYPE_XREF: | |
292 | case DNTT_TYPE_MACRO: | |
293 | case DNTT_TYPE_CLASS_SCOPE: | |
294 | case DNTT_TYPE_REFERENCE: | |
295 | case DNTT_TYPE_PTRMEM: | |
296 | case DNTT_TYPE_PTRMEMFUNC: | |
297 | case DNTT_TYPE_CLASS: | |
298 | case DNTT_TYPE_GENFIELD: | |
299 | case DNTT_TYPE_VFUNC: | |
300 | case DNTT_TYPE_MEMACCESS: | |
301 | case DNTT_TYPE_INHERITANCE: | |
302 | case DNTT_TYPE_FRIEND_CLASS: | |
303 | case DNTT_TYPE_FRIEND_FUNC: | |
304 | case DNTT_TYPE_MODIFIER: | |
305 | case DNTT_TYPE_OBJECT_ID: | |
306 | case DNTT_TYPE_TEMPLATE: | |
307 | case DNTT_TYPE_TEMPLATE_ARG: | |
308 | case DNTT_TYPE_FUNC_TEMPLATE: | |
309 | case DNTT_TYPE_LINK: | |
310 | /* DNTT_TYPE_DYN_ARRAY_DESC ? */ | |
311 | /* DNTT_TYPE_DESC_SUBRANGE ? */ | |
312 | /* DNTT_TYPE_BEGIN_EXT ? */ | |
313 | /* DNTT_TYPE_INLN ? */ | |
314 | /* DNTT_TYPE_INLN_LIST ? */ | |
315 | /* DNTT_TYPE_ALIAS ? */ | |
316 | default: | |
317 | return 0; | |
318 | } | |
319 | } | |
320 | ||
321 | /* Do the dirty work of reading in the full symbol from a partial symbol | |
322 | table. */ | |
323 | ||
324 | static void | |
325 | hpread_psymtab_to_symtab_1 (pst) | |
326 | struct partial_symtab *pst; | |
327 | { | |
328 | struct cleanup *old_chain; | |
329 | int i; | |
330 | ||
331 | /* Get out quick if passed junk. */ | |
332 | if (!pst) | |
333 | return; | |
334 | ||
335 | /* Complain if we've already read in this symbol table. */ | |
336 | if (pst->readin) | |
337 | { | |
338 | fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n", | |
339 | pst->filename); | |
340 | return; | |
341 | } | |
342 | ||
343 | /* Read in all partial symtabs on which this one is dependent */ | |
344 | for (i = 0; i < pst->number_of_dependencies; i++) | |
345 | if (!pst->dependencies[i]->readin) | |
346 | { | |
347 | /* Inform about additional files that need to be read in. */ | |
348 | if (info_verbose) | |
349 | { | |
350 | fputs_filtered (" ", gdb_stdout); | |
351 | wrap_here (""); | |
352 | fputs_filtered ("and ", gdb_stdout); | |
353 | wrap_here (""); | |
354 | printf_filtered ("%s...", pst->dependencies[i]->filename); | |
355 | wrap_here (""); /* Flush output */ | |
356 | gdb_flush (gdb_stdout); | |
357 | } | |
358 | hpread_psymtab_to_symtab_1 (pst->dependencies[i]); | |
359 | } | |
360 | ||
361 | /* If it's real... */ | |
362 | if (LDSYMLEN (pst)) | |
363 | { | |
364 | /* Init stuff necessary for reading in symbols */ | |
365 | buildsym_init (); | |
366 | old_chain = make_cleanup (really_free_pendings, 0); | |
367 | ||
368 | pst->symtab = | |
369 | hpread_expand_symtab (pst->objfile, LDSYMOFF (pst), LDSYMLEN (pst), | |
370 | pst->textlow, pst->texthigh - pst->textlow, | |
371 | pst->section_offsets, pst->filename); | |
372 | sort_symtab_syms (pst->symtab); | |
373 | ||
374 | do_cleanups (old_chain); | |
375 | } | |
376 | ||
377 | pst->readin = 1; | |
378 | } | |
379 | ||
380 | /* Read in all of the symbols for a given psymtab for real. | |
381 | Be verbose about it if the user wants that. */ | |
382 | ||
383 | void | |
384 | hpread_psymtab_to_symtab (pst) | |
385 | struct partial_symtab *pst; | |
386 | { | |
387 | /* Get out quick if given junk. */ | |
388 | if (!pst) | |
389 | return; | |
390 | ||
391 | /* Sanity check. */ | |
392 | if (pst->readin) | |
393 | { | |
394 | fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n", | |
395 | pst->filename); | |
396 | return; | |
397 | } | |
398 | ||
399 | /* elz: setting the flag to indicate that the code of the target | |
400 | was compiled using an HP compiler (aCC, cc) | |
401 | the processing_acc_compilation variable is declared in the | |
402 | file buildsym.h, the HP_COMPILED_TARGET is defined to be equal | |
403 | to 3 in the file tm_hppa.h*/ | |
404 | ||
405 | processing_gcc_compilation = 0; | |
406 | ||
407 | if (LDSYMLEN (pst) || pst->number_of_dependencies) | |
408 | { | |
409 | /* Print the message now, before reading the string table, | |
410 | to avoid disconcerting pauses. */ | |
411 | if (info_verbose) | |
412 | { | |
413 | printf_filtered ("Reading in symbols for %s...", pst->filename); | |
414 | gdb_flush (gdb_stdout); | |
415 | } | |
416 | ||
417 | hpread_psymtab_to_symtab_1 (pst); | |
418 | ||
419 | /* Match with global symbols. This only needs to be done once, | |
420 | after all of the symtabs and dependencies have been read in. */ | |
421 | scan_file_globals (pst->objfile); | |
422 | ||
423 | /* Finish up the debug error message. */ | |
424 | if (info_verbose) | |
425 | printf_filtered ("done.\n"); | |
426 | } | |
427 | } | |
428 | ||
429 | /* Read in a defined section of a specific object file's symbols. | |
430 | ||
431 | DESC is the file descriptor for the file, positioned at the | |
432 | beginning of the symtab | |
433 | SYM_OFFSET is the offset within the file of | |
434 | the beginning of the symbols we want to read | |
435 | SYM_SIZE is the size of the symbol info to read in. | |
436 | TEXT_OFFSET is the beginning of the text segment we are reading symbols for | |
437 | TEXT_SIZE is the size of the text segment read in. | |
438 | SECTION_OFFSETS are the relocation offsets which get added to each symbol. */ | |
439 | ||
440 | static struct symtab * | |
441 | hpread_expand_symtab (objfile, sym_offset, sym_size, text_offset, text_size, | |
442 | section_offsets, filename) | |
443 | struct objfile *objfile; | |
444 | int sym_offset; | |
445 | int sym_size; | |
446 | CORE_ADDR text_offset; | |
447 | int text_size; | |
448 | struct section_offsets *section_offsets; | |
449 | char *filename; | |
450 | { | |
451 | char *namestring; | |
452 | union dnttentry *dn_bufp; | |
453 | unsigned max_symnum; | |
454 | int at_module_boundary = 0; | |
455 | /* 1 => at end, -1 => at beginning */ | |
456 | ||
457 | int sym_index = sym_offset / sizeof (struct dntt_type_block); | |
458 | ||
459 | current_objfile = objfile; | |
460 | subfile_stack = 0; | |
461 | ||
462 | last_source_file = 0; | |
463 | ||
464 | /* Demangling style -- if EDG style already set, don't change it, | |
465 | as HP style causes some problems with the KAI EDG compiler */ | |
466 | if (current_demangling_style != edg_demangling) { | |
467 | /* Otherwise, ensure that we are using HP style demangling */ | |
468 | set_demangling_style (HP_DEMANGLING_STYLE_STRING); | |
469 | } | |
470 | ||
471 | dn_bufp = hpread_get_lntt (sym_index, objfile); | |
472 | if (!((dn_bufp->dblock.kind == (unsigned char) DNTT_TYPE_SRCFILE) || | |
473 | (dn_bufp->dblock.kind == (unsigned char) DNTT_TYPE_MODULE))) | |
474 | { | |
475 | start_symtab ("globals", NULL, 0); | |
476 | record_debugformat ("HP"); | |
477 | } | |
478 | ||
479 | /* The psymtab builder (hp-psymtab-read.c) is the one that | |
480 | * determined the "sym_size" argument (i.e. how many DNTT symbols | |
481 | * are in this symtab), which we use to compute "max_symnum" | |
482 | * (point in DNTT to which we read). | |
483 | * | |
484 | * Perhaps this should be changed so that | |
485 | * process_one_debug_symbol() "knows" when | |
486 | * to stop reading (based on reading from the MODULE to the matching | |
487 | * END), and take out this reliance on a #-syms being passed in... | |
488 | * (I'm worried about the reliability of this number). But I'll | |
489 | * leave it as-is, for now. - RT | |
490 | * | |
491 | * The change above has been made. I've left the "for" loop control | |
492 | * in to prepare for backing this out again. -JB | |
493 | */ | |
494 | max_symnum = sym_size / sizeof (struct dntt_type_block); | |
495 | /* No reason to multiply on pst side and divide on sym side... FIXME */ | |
496 | ||
497 | /* Read in and process each debug symbol within the specified range. | |
498 | */ | |
499 | for (symnum = 0; | |
500 | symnum < max_symnum; | |
501 | symnum++) | |
502 | { | |
503 | QUIT; /* Allow this to be interruptable */ | |
504 | dn_bufp = hpread_get_lntt (sym_index + symnum, objfile); | |
505 | ||
506 | if (dn_bufp->dblock.extension) | |
507 | continue; | |
508 | ||
509 | /* Yow! We call SET_NAMESTRING on things without names! */ | |
510 | SET_NAMESTRING (dn_bufp, &namestring, objfile); | |
511 | ||
512 | hpread_process_one_debug_symbol (dn_bufp, namestring, section_offsets, | |
513 | objfile, text_offset, text_size, | |
514 | filename, symnum + sym_index, | |
515 | &at_module_boundary | |
516 | ); | |
517 | ||
518 | /* OLD COMMENTS: This routine is only called for psts. All psts | |
519 | * correspond to MODULES. If we ever do lazy-reading of globals | |
520 | * from the LNTT, then there will be a pst which ends when the | |
521 | * LNTT ends, and not at an END MODULE entry. Then we'll have | |
522 | * to re-visit this break. | |
523 | ||
524 | if( at_end_of_module ) | |
525 | break; | |
526 | ||
527 | */ | |
528 | ||
529 | /* We no longer break out of the loop when we reach the end of a | |
530 | module. The reason is that with CTTI, the compiler can generate | |
531 | function symbols (for template function instantiations) which are not | |
532 | in any module; typically they show up beyond a module's end, and | |
533 | before the next module's start. We include them in the current | |
534 | module. However, we still don't trust the MAX_SYMNUM value from | |
535 | the psymtab, so we break out if we enter a new module. */ | |
536 | ||
537 | if (at_module_boundary == -1) | |
538 | break; | |
539 | } | |
540 | ||
541 | current_objfile = NULL; | |
542 | hp_som_som_object_present = 1; /* Indicate we've processed an HP SOM SOM file */ | |
543 | ||
544 | return end_symtab (text_offset + text_size, objfile, 0); | |
545 | } | |
546 | \f | |
547 | ||
548 | ||
549 | ||
550 | /* Convert basic types from HP debug format into GDB internal format. */ | |
551 | ||
552 | static int | |
553 | hpread_type_translate (typep) | |
554 | dnttpointer typep; | |
555 | { | |
556 | if (!typep.dntti.immediate) { | |
557 | error ("error in hpread_type_translate\n."); | |
558 | return; | |
559 | } | |
560 | ||
561 | switch (typep.dntti.type) | |
562 | { | |
563 | case HP_TYPE_BOOLEAN: | |
564 | case HP_TYPE_BOOLEAN_S300_COMPAT: | |
565 | case HP_TYPE_BOOLEAN_VAX_COMPAT: | |
566 | return FT_BOOLEAN; | |
567 | case HP_TYPE_CHAR: /* C signed char, C++ plain char */ | |
568 | ||
569 | case HP_TYPE_WIDE_CHAR: | |
570 | return FT_CHAR; | |
571 | case HP_TYPE_INT: | |
572 | if (typep.dntti.bitlength <= 8) | |
573 | return FT_SIGNED_CHAR; /* C++ signed char */ | |
574 | if (typep.dntti.bitlength <= 16) | |
575 | return FT_SHORT; | |
576 | if (typep.dntti.bitlength <= 32) | |
577 | return FT_INTEGER; | |
578 | return FT_LONG_LONG; | |
579 | case HP_TYPE_LONG: | |
580 | if (typep.dntti.bitlength <= 8) | |
581 | return FT_SIGNED_CHAR; /* C++ signed char. */ | |
582 | return FT_LONG; | |
583 | case HP_TYPE_UNSIGNED_LONG: | |
584 | if (typep.dntti.bitlength <= 8) | |
585 | return FT_UNSIGNED_CHAR; /* C/C++ unsigned char */ | |
586 | if (typep.dntti.bitlength <= 16) | |
587 | return FT_UNSIGNED_SHORT; | |
588 | if (typep.dntti.bitlength <= 32) | |
589 | return FT_UNSIGNED_LONG; | |
590 | return FT_UNSIGNED_LONG_LONG; | |
591 | case HP_TYPE_UNSIGNED_INT: | |
592 | if (typep.dntti.bitlength <= 8) | |
593 | return FT_UNSIGNED_CHAR; | |
594 | if (typep.dntti.bitlength <= 16) | |
595 | return FT_UNSIGNED_SHORT; | |
596 | if (typep.dntti.bitlength <= 32) | |
597 | return FT_UNSIGNED_INTEGER; | |
598 | return FT_UNSIGNED_LONG_LONG; | |
599 | case HP_TYPE_REAL: | |
600 | case HP_TYPE_REAL_3000: | |
601 | case HP_TYPE_DOUBLE: | |
602 | if (typep.dntti.bitlength == 64) | |
603 | return FT_DBL_PREC_FLOAT; | |
604 | if (typep.dntti.bitlength == 128) | |
605 | return FT_EXT_PREC_FLOAT; | |
606 | return FT_FLOAT; | |
607 | case HP_TYPE_COMPLEX: | |
608 | case HP_TYPE_COMPLEXS3000: | |
609 | if (typep.dntti.bitlength == 128) | |
610 | return FT_DBL_PREC_COMPLEX; | |
611 | if (typep.dntti.bitlength == 192) | |
612 | return FT_EXT_PREC_COMPLEX; | |
613 | return FT_COMPLEX; | |
614 | case HP_TYPE_VOID: | |
615 | return FT_VOID; | |
616 | case HP_TYPE_STRING200: | |
617 | case HP_TYPE_LONGSTRING200: | |
618 | case HP_TYPE_FTN_STRING_SPEC: | |
619 | case HP_TYPE_MOD_STRING_SPEC: | |
620 | case HP_TYPE_MOD_STRING_3000: | |
621 | case HP_TYPE_FTN_STRING_S300_COMPAT: | |
622 | case HP_TYPE_FTN_STRING_VAX_COMPAT: | |
623 | return FT_STRING; | |
624 | case HP_TYPE_TEMPLATE_ARG: | |
625 | return FT_TEMPLATE_ARG; | |
626 | case HP_TYPE_TEXT: | |
627 | case HP_TYPE_FLABEL: | |
628 | case HP_TYPE_PACKED_DECIMAL: | |
629 | case HP_TYPE_ANYPOINTER: | |
630 | case HP_TYPE_GLOBAL_ANYPOINTER: | |
631 | case HP_TYPE_LOCAL_ANYPOINTER: | |
632 | default: | |
633 | warning ("hpread_type_translate: unhandled type code.\n"); | |
634 | return FT_VOID; | |
635 | } | |
636 | } | |
637 | ||
638 | /* Given a position in the DNTT, return a pointer to the | |
639 | * already-built "struct type" (if any), for the type defined | |
640 | * at that position. | |
641 | */ | |
642 | ||
643 | static struct type ** | |
644 | hpread_lookup_type (hp_type, objfile) | |
645 | dnttpointer hp_type; | |
646 | struct objfile *objfile; | |
647 | { | |
648 | unsigned old_len; | |
649 | int index = hp_type.dnttp.index; | |
650 | int size_changed = 0; | |
651 | ||
652 | /* The immediate flag indicates this doesn't actually point to | |
653 | * a type DNTT. | |
654 | */ | |
655 | if (hp_type.dntti.immediate) | |
656 | return NULL; | |
657 | ||
658 | /* For each objfile, we maintain a "type vector". | |
659 | * This an array of "struct type *"'s with one pointer per DNTT index. | |
660 | * Given a DNTT index, we look in this array to see if we have | |
661 | * already processed this DNTT and if it is a type definition. | |
662 | * If so, then we can locate a pointer to the already-built | |
663 | * "struct type", and not build it again. | |
664 | * | |
665 | * The need for this arises because our DNTT-walking code wanders | |
666 | * around. In particular, it will encounter the same type multiple | |
667 | * times (once for each object of that type). We don't want to | |
668 | * built multiple "struct type"'s for the same thing. | |
669 | * | |
670 | * Having said this, I should point out that this type-vector is | |
671 | * an expensive way to keep track of this. If most DNTT entries are | |
672 | * 3 words, the type-vector will be 1/3 the size of the DNTT itself. | |
673 | * Alternative solutions: | |
674 | * - Keep a compressed or hashed table. Less memory, but more expensive | |
675 | * to search and update. | |
676 | * - (Suggested by JB): Overwrite the DNTT entry itself | |
677 | * with the info. Create a new type code "ALREADY_BUILT", and modify | |
678 | * the DNTT to have that type code and point to the already-built entry. | |
679 | * -RT | |
680 | */ | |
681 | ||
682 | if (index < LNTT_SYMCOUNT (objfile)) | |
683 | { | |
684 | if (index >= TYPE_VECTOR_LENGTH (objfile)) | |
685 | { | |
686 | old_len = TYPE_VECTOR_LENGTH (objfile); | |
687 | ||
688 | /* See if we need to allocate a type-vector. */ | |
689 | if (old_len == 0) | |
690 | { | |
691 | TYPE_VECTOR_LENGTH(objfile) = LNTT_SYMCOUNT (objfile) + GNTT_SYMCOUNT (objfile); | |
692 | TYPE_VECTOR (objfile) = (struct type **) | |
693 | xmmalloc (objfile->md, TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *)); | |
694 | memset (&TYPE_VECTOR (objfile)[old_len], 0, | |
695 | (TYPE_VECTOR_LENGTH (objfile) - old_len) * | |
696 | sizeof (struct type *)); | |
697 | } | |
698 | ||
699 | /* See if we need to resize type-vector. With my change to | |
700 | * initially allocate a correct-size type-vector, this code | |
701 | * should no longer trigger. | |
702 | */ | |
703 | while (index >= TYPE_VECTOR_LENGTH (objfile)) { | |
704 | TYPE_VECTOR_LENGTH (objfile) *= 2; | |
705 | size_changed = 1; | |
706 | } | |
707 | if (size_changed) { | |
708 | TYPE_VECTOR (objfile) = (struct type **) | |
709 | xmrealloc (objfile -> md, | |
710 | (char *) TYPE_VECTOR (objfile), | |
711 | (TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *))); | |
712 | ||
713 | memset (&TYPE_VECTOR (objfile)[old_len], 0, | |
714 | (TYPE_VECTOR_LENGTH (objfile) - old_len) * | |
715 | sizeof (struct type *)); | |
716 | } | |
717 | ||
718 | } | |
719 | return &TYPE_VECTOR (objfile)[index]; | |
720 | } | |
721 | else | |
722 | return NULL; | |
723 | } | |
724 | ||
725 | /* Possibly allocate a GDB internal type so we can internalize HP_TYPE. | |
726 | Note we'll just return the address of a GDB internal type if we already | |
727 | have it lying around. */ | |
728 | ||
729 | static struct type * | |
730 | hpread_alloc_type (hp_type, objfile) | |
731 | dnttpointer hp_type; | |
732 | struct objfile *objfile; | |
733 | { | |
734 | struct type **type_addr; | |
735 | ||
736 | type_addr = hpread_lookup_type (hp_type, objfile); | |
737 | if (*type_addr == 0) { | |
738 | *type_addr = alloc_type (objfile); | |
739 | ||
740 | /* A hack - if we really are a C++ class symbol, then this default | |
741 | * will get overriden later on. | |
742 | */ | |
743 | TYPE_CPLUS_SPECIFIC (*type_addr) | |
744 | = (struct cplus_struct_type *) &cplus_struct_default; | |
745 | } | |
746 | ||
747 | return *type_addr; | |
748 | } | |
749 | ||
750 | /* Read a native enumerated type and return it in GDB internal form. */ | |
751 | ||
752 | static struct type * | |
753 | hpread_read_enum_type (hp_type, dn_bufp, objfile) | |
754 | dnttpointer hp_type; | |
755 | union dnttentry *dn_bufp; | |
756 | struct objfile *objfile; | |
757 | { | |
758 | struct type *type; | |
759 | struct pending **symlist, *osyms, *syms; | |
760 | struct pending *local_list = NULL; | |
761 | int o_nsyms, nsyms = 0; | |
762 | dnttpointer mem; | |
763 | union dnttentry *memp; | |
764 | char *name; | |
765 | long n; | |
766 | struct symbol *sym; | |
767 | ||
768 | /* Allocate a GDB type. If we've already read in this enum type, | |
769 | * it'll return the already built GDB type, so stop here. | |
770 | * (Note: I added this check, to conform with what's done for | |
771 | * struct, union, class. | |
772 | * I assume this is OK. - RT) | |
773 | */ | |
774 | type = hpread_alloc_type (hp_type, objfile); | |
775 | if (TYPE_CODE (type) == TYPE_CODE_ENUM) | |
776 | return type; | |
777 | ||
778 | /* HP C supports "sized enums", where a specifier such as "short" or | |
779 | "char" can be used to get enums of different sizes. So don't assume | |
780 | an enum is always 4 bytes long. pai/1997-08-21 */ | |
781 | TYPE_LENGTH (type) = dn_bufp->denum.bitlength / 8; | |
782 | ||
783 | symlist = &file_symbols; | |
784 | osyms = *symlist; | |
785 | o_nsyms = osyms ? osyms->nsyms : 0; | |
786 | ||
787 | /* Get a name for each member and add it to our list of members. | |
788 | * The list of "mem" SOM records we are walking should all be | |
789 | * SOM type DNTT_TYPE_MEMENUM (not checked). | |
790 | */ | |
791 | mem = dn_bufp->denum.firstmem; | |
792 | while (mem.word && mem.word != DNTTNIL) | |
793 | { | |
794 | memp = hpread_get_lntt (mem.dnttp.index, objfile); | |
795 | ||
796 | name = VT (objfile) + memp->dmember.name; | |
797 | sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack, | |
798 | sizeof (struct symbol)); | |
799 | memset (sym, 0, sizeof (struct symbol)); | |
800 | SYMBOL_NAME (sym) = obsavestring (name, strlen (name), | |
801 | &objfile->symbol_obstack); | |
802 | SYMBOL_CLASS (sym) = LOC_CONST; | |
803 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
804 | SYMBOL_VALUE (sym) = memp->dmember.value; | |
805 | add_symbol_to_list (sym, symlist); | |
806 | nsyms++; | |
807 | mem = memp->dmember.nextmem; | |
808 | } | |
809 | ||
810 | /* Now that we know more about the enum, fill in more info. */ | |
811 | TYPE_CODE (type) = TYPE_CODE_ENUM; | |
812 | TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB; | |
813 | TYPE_NFIELDS (type) = nsyms; | |
814 | TYPE_FIELDS (type) = (struct field *) | |
815 | obstack_alloc (&objfile->type_obstack, sizeof (struct field) * nsyms); | |
816 | ||
817 | /* Find the symbols for the members and put them into the type. | |
818 | The symbols can be found in the symlist that we put them on | |
819 | to cause them to be defined. osyms contains the old value | |
820 | of that symlist; everything up to there was defined by us. | |
821 | ||
822 | Note that we preserve the order of the enum constants, so | |
823 | that in something like "enum {FOO, LAST_THING=FOO}" we print | |
824 | FOO, not LAST_THING. */ | |
825 | for (syms = *symlist, n = 0; syms; syms = syms->next) | |
826 | { | |
827 | int j = 0; | |
828 | if (syms == osyms) | |
829 | j = o_nsyms; | |
830 | for (; j < syms->nsyms; j++, n++) | |
831 | { | |
832 | struct symbol *xsym = syms->symbol[j]; | |
833 | SYMBOL_TYPE (xsym) = type; | |
834 | TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym); | |
835 | TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (xsym); | |
836 | TYPE_FIELD_BITSIZE (type, n) = 0; | |
837 | } | |
838 | if (syms == osyms) | |
839 | break; | |
840 | } | |
841 | ||
842 | return type; | |
843 | } | |
844 | ||
845 | /* Read and internalize a native function debug symbol. */ | |
846 | ||
847 | static struct type * | |
848 | hpread_read_function_type (hp_type, dn_bufp, objfile, newblock) | |
849 | dnttpointer hp_type; | |
850 | union dnttentry *dn_bufp; | |
851 | struct objfile *objfile; | |
852 | int newblock; | |
853 | { | |
854 | struct type *type, *type1; | |
855 | struct pending *syms; | |
856 | struct pending *local_list = NULL; | |
857 | int nsyms = 0; | |
858 | dnttpointer param; | |
859 | union dnttentry *paramp; | |
860 | char *name; | |
861 | long n; | |
862 | struct symbol *sym; | |
863 | int record_args = 1; | |
864 | ||
865 | /* See if we've already read in this type. */ | |
866 | type = hpread_alloc_type (hp_type, objfile); | |
867 | if (TYPE_CODE (type) == TYPE_CODE_FUNC) | |
868 | { | |
869 | record_args = 0; /* already read in, don't modify type */ | |
870 | } | |
871 | else | |
872 | { | |
873 | /* Nope, so read it in and store it away. */ | |
874 | if (dn_bufp->dblock.kind == DNTT_TYPE_FUNCTION || | |
875 | dn_bufp->dblock.kind == DNTT_TYPE_MEMFUNC) | |
876 | type1 = lookup_function_type (hpread_type_lookup (dn_bufp->dfunc.retval, | |
877 | objfile)); | |
878 | else if (dn_bufp->dblock.kind == DNTT_TYPE_FUNCTYPE) | |
879 | type1 = lookup_function_type (hpread_type_lookup (dn_bufp->dfunctype.retval, | |
880 | objfile)); | |
881 | else /* expect DNTT_TYPE_FUNC_TEMPLATE */ | |
882 | type1 = lookup_function_type (hpread_type_lookup (dn_bufp->dfunc_template.retval, | |
883 | objfile)); | |
884 | memcpy ((char *) type, (char *) type1, sizeof (struct type)); | |
885 | ||
886 | /* Mark it -- in the middle of processing */ | |
887 | TYPE_FLAGS (type) |= TYPE_FLAG_INCOMPLETE; | |
888 | } | |
889 | ||
890 | /* Now examine each parameter noting its type, location, and a | |
891 | wealth of other information. */ | |
892 | if (dn_bufp->dblock.kind == DNTT_TYPE_FUNCTION || | |
893 | dn_bufp->dblock.kind == DNTT_TYPE_MEMFUNC) | |
894 | param = dn_bufp->dfunc.firstparam; | |
895 | else if (dn_bufp->dblock.kind == DNTT_TYPE_FUNCTYPE) | |
896 | param = dn_bufp->dfunctype.firstparam; | |
897 | else /* expect DNTT_TYPE_FUNC_TEMPLATE */ | |
898 | param = dn_bufp->dfunc_template.firstparam; | |
899 | while (param.word && param.word != DNTTNIL) | |
900 | { | |
901 | paramp = hpread_get_lntt (param.dnttp.index, objfile); | |
902 | nsyms++; | |
903 | param = paramp->dfparam.nextparam; | |
904 | ||
905 | /* Get the name. */ | |
906 | name = VT (objfile) + paramp->dfparam.name; | |
907 | sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack, | |
908 | sizeof (struct symbol)); | |
909 | (void) memset (sym, 0, sizeof (struct symbol)); | |
910 | SYMBOL_NAME (sym) = obsavestring (name, strlen (name), | |
911 | &objfile->symbol_obstack); | |
912 | ||
913 | /* Figure out where it lives. */ | |
914 | if (paramp->dfparam.regparam) | |
915 | SYMBOL_CLASS (sym) = LOC_REGPARM; | |
916 | else if (paramp->dfparam.indirect) | |
917 | SYMBOL_CLASS (sym) = LOC_REF_ARG; | |
918 | else | |
919 | SYMBOL_CLASS (sym) = LOC_ARG; | |
920 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
921 | if (paramp->dfparam.copyparam) | |
922 | { | |
923 | SYMBOL_VALUE (sym) = paramp->dfparam.location ; | |
924 | #ifdef HPREAD_ADJUST_STACK_ADDRESS | |
925 | SYMBOL_VALUE (sym) | |
926 | += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile)); | |
927 | #endif | |
928 | /* This is likely a pass-by-invisible reference parameter, | |
929 | Hack on the symbol class to make GDB happy. */ | |
930 | /* ??rehrauer: This appears to be broken w/r/t to passing | |
931 | C values of type float and struct. Perhaps this ought | |
932 | to be highighted as a special case, but for now, just | |
933 | allowing these to be LOC_ARGs seems to work fine. | |
934 | */ | |
935 | #if 0 | |
936 | SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR; | |
937 | #endif | |
938 | } | |
939 | else | |
940 | SYMBOL_VALUE (sym) = paramp->dfparam.location; | |
941 | ||
942 | /* Get its type. */ | |
943 | SYMBOL_TYPE (sym) = hpread_type_lookup (paramp->dfparam.type, objfile); | |
944 | /* Add it to the symbol list. */ | |
945 | /* Note 1 (RT) At the moment, add_symbol_to_list() is also being | |
946 | * called on FPARAM symbols from the process_one_debug_symbol() | |
947 | * level... so parameters are getting added twice! (this shows | |
948 | * up in the symbol dump you get from "maint print symbols ..."). | |
949 | * Note 2 (RT) I took out the processing of FPARAM from the | |
950 | * process_one_debug_symbol() level, so at the moment parameters are only | |
951 | * being processed here. This seems to have no ill effect. | |
952 | */ | |
953 | /* Note 3 (pai/1997-08-11) I removed the add_symbol_to_list() which put | |
954 | each fparam on the local_symbols list from here. Now we use the | |
955 | local_list to which fparams are added below, and set the param_symbols | |
956 | global to point to that at the end of this routine. */ | |
957 | /* elz: I added this new list of symbols which is local to the function. | |
958 | this list is the one which is actually used to build the type for the | |
959 | function rather than the gloabal list pointed to by symlist. | |
960 | Using a global list to keep track of the parameters is wrong, because | |
961 | this function is called recursively if one parameter happend to be | |
962 | a function itself with more parameters in it. Adding parameters to the | |
963 | same global symbol list would not work! | |
964 | Actually it did work in case of cc compiled programs where you do | |
965 | not check the parameter lists of the arguments. */ | |
966 | add_symbol_to_list (sym, &local_list); | |
967 | ||
968 | } | |
969 | ||
970 | /* If type was read in earlier, don't bother with modifying | |
971 | the type struct */ | |
972 | if (!record_args) | |
973 | goto finish; | |
974 | ||
975 | /* Note how many parameters we found. */ | |
976 | TYPE_NFIELDS (type) = nsyms; | |
977 | TYPE_FIELDS (type) = (struct field *) | |
978 | obstack_alloc (&objfile->type_obstack, | |
979 | sizeof (struct field) * nsyms); | |
980 | ||
981 | /* Find the symbols for the parameters and | |
982 | use them to fill parameter-type information into the function-type. | |
983 | The parameter symbols can be found in the local_list that we just put them on. */ | |
984 | /* Note that we preserve the order of the parameters, so | |
985 | that in something like "enum {FOO, LAST_THING=FOO}" we print | |
986 | FOO, not LAST_THING. */ | |
987 | ||
988 | /* get the parameters types from the local list not the global list | |
989 | so that the type can be correctly constructed for functions which | |
990 | have function as parameters */ | |
991 | for (syms = local_list, n = 0; syms; syms = syms->next) | |
992 | { | |
993 | int j = 0; | |
994 | for (j=0; j < syms->nsyms; j++, n++) | |
995 | { | |
996 | struct symbol *xsym = syms->symbol[j]; | |
997 | TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym); | |
998 | TYPE_FIELD_TYPE (type, n) = SYMBOL_TYPE (xsym); | |
999 | TYPE_FIELD_BITPOS (type, n) = n; | |
1000 | TYPE_FIELD_BITSIZE (type, n) = 0; | |
1001 | } | |
1002 | } | |
1003 | /* Mark it as having been processed */ | |
1004 | TYPE_FLAGS (type) &= ~(TYPE_FLAG_INCOMPLETE); | |
1005 | ||
1006 | /* Check whether we need to fix-up a class type with this function's type */ | |
1007 | if (fixup_class && (fixup_method == type)) | |
1008 | { | |
1009 | fixup_class_method_type (fixup_class, fixup_method, objfile); | |
1010 | fixup_class = NULL; | |
1011 | fixup_method = NULL; | |
1012 | } | |
1013 | ||
1014 | /* Set the param list of this level of the context stack | |
1015 | to our local list. Do this only if this function was | |
1016 | called for creating a new block, and not if it was called | |
1017 | simply to get the function type. This prevents recursive | |
1018 | invocations from trashing param_symbols. */ | |
1019 | finish: | |
1020 | if (newblock) | |
1021 | param_symbols = local_list; | |
1022 | ||
1023 | return type; | |
1024 | } | |
1025 | ||
1026 | ||
1027 | /* Read and internalize a native DOC function debug symbol. */ | |
1028 | /* This is almost identical to hpread_read_function_type(), except | |
1029 | * for references to dn_bufp->ddocfunc instead of db_bufp->dfunc. | |
1030 | * Since debug information for DOC functions is more likely to be | |
1031 | * volatile, please leave it this way. | |
1032 | */ | |
1033 | static struct type * | |
1034 | hpread_read_doc_function_type (hp_type, dn_bufp, objfile, newblock) | |
1035 | dnttpointer hp_type; | |
1036 | union dnttentry *dn_bufp; | |
1037 | struct objfile *objfile; | |
1038 | int newblock; | |
1039 | { | |
1040 | struct type *type, *type1; | |
1041 | struct pending *syms; | |
1042 | struct pending *local_list = NULL; | |
1043 | int nsyms = 0; | |
1044 | dnttpointer param; | |
1045 | union dnttentry *paramp; | |
1046 | char *name; | |
1047 | long n; | |
1048 | struct symbol *sym; | |
1049 | int record_args = 1; | |
1050 | ||
1051 | /* See if we've already read in this type. */ | |
1052 | type = hpread_alloc_type (hp_type, objfile); | |
1053 | if (TYPE_CODE (type) == TYPE_CODE_FUNC) | |
1054 | { | |
1055 | record_args = 0; /* already read in, don't modify type */ | |
1056 | } | |
1057 | else | |
1058 | { | |
1059 | /* Nope, so read it in and store it away. */ | |
1060 | if (dn_bufp->dblock.kind == DNTT_TYPE_DOC_FUNCTION || | |
1061 | dn_bufp->dblock.kind == DNTT_TYPE_DOC_MEMFUNC) | |
1062 | type1 = lookup_function_type (hpread_type_lookup (dn_bufp->ddocfunc.retval, | |
1063 | objfile)); | |
1064 | memcpy ((char *) type, (char *) type1, sizeof (struct type)); | |
1065 | ||
1066 | /* Mark it -- in the middle of processing */ | |
1067 | TYPE_FLAGS (type) |= TYPE_FLAG_INCOMPLETE; | |
1068 | } | |
1069 | ||
1070 | /* Now examine each parameter noting its type, location, and a | |
1071 | wealth of other information. */ | |
1072 | if (dn_bufp->dblock.kind == DNTT_TYPE_DOC_FUNCTION || | |
1073 | dn_bufp->dblock.kind == DNTT_TYPE_DOC_MEMFUNC) | |
1074 | param = dn_bufp->ddocfunc.firstparam; | |
1075 | while (param.word && param.word != DNTTNIL) | |
1076 | { | |
1077 | paramp = hpread_get_lntt (param.dnttp.index, objfile); | |
1078 | nsyms++; | |
1079 | param = paramp->dfparam.nextparam; | |
1080 | ||
1081 | /* Get the name. */ | |
1082 | name = VT (objfile) + paramp->dfparam.name; | |
1083 | sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack, | |
1084 | sizeof (struct symbol)); | |
1085 | (void) memset (sym, 0, sizeof (struct symbol)); | |
1086 | SYMBOL_NAME (sym) = name; | |
1087 | ||
1088 | /* Figure out where it lives. */ | |
1089 | if (paramp->dfparam.regparam) | |
1090 | SYMBOL_CLASS (sym) = LOC_REGPARM; | |
1091 | else if (paramp->dfparam.indirect) | |
1092 | SYMBOL_CLASS (sym) = LOC_REF_ARG; | |
1093 | else | |
1094 | SYMBOL_CLASS (sym) = LOC_ARG; | |
1095 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
1096 | if (paramp->dfparam.copyparam) | |
1097 | { | |
1098 | SYMBOL_VALUE (sym) = paramp->dfparam.location ; | |
1099 | #ifdef HPREAD_ADJUST_STACK_ADDRESS | |
1100 | SYMBOL_VALUE (sym) | |
1101 | += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile)); | |
1102 | #endif | |
1103 | /* This is likely a pass-by-invisible reference parameter, | |
1104 | Hack on the symbol class to make GDB happy. */ | |
1105 | /* ??rehrauer: This appears to be broken w/r/t to passing | |
1106 | C values of type float and struct. Perhaps this ought | |
1107 | to be highighted as a special case, but for now, just | |
1108 | allowing these to be LOC_ARGs seems to work fine. | |
1109 | */ | |
1110 | #if 0 | |
1111 | SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR; | |
1112 | #endif | |
1113 | } | |
1114 | else | |
1115 | SYMBOL_VALUE (sym) = paramp->dfparam.location; | |
1116 | ||
1117 | /* Get its type. */ | |
1118 | SYMBOL_TYPE (sym) = hpread_type_lookup (paramp->dfparam.type, objfile); | |
1119 | /* Add it to the symbol list. */ | |
1120 | /* Note 1 (RT) At the moment, add_symbol_to_list() is also being | |
1121 | * called on FPARAM symbols from the process_one_debug_symbol() | |
1122 | * level... so parameters are getting added twice! (this shows | |
1123 | * up in the symbol dump you get from "maint print symbols ..."). | |
1124 | * Note 2 (RT) I took out the processing of FPARAM from the | |
1125 | * process_one_debug_symbol() level, so at the moment parameters are only | |
1126 | * being processed here. This seems to have no ill effect. | |
1127 | */ | |
1128 | /* Note 3 (pai/1997-08-11) I removed the add_symbol_to_list() which put | |
1129 | each fparam on the local_symbols list from here. Now we use the | |
1130 | local_list to which fparams are added below, and set the param_symbols | |
1131 | global to point to that at the end of this routine. */ | |
1132 | ||
1133 | /* elz: I added this new list of symbols which is local to the function. | |
1134 | this list is the one which is actually used to build the type for the | |
1135 | function rather than the gloabal list pointed to by symlist. | |
1136 | Using a global list to keep track of the parameters is wrong, because | |
1137 | this function is called recursively if one parameter happend to be | |
1138 | a function itself with more parameters in it. Adding parameters to the | |
1139 | same global symbol list would not work! | |
1140 | Actually it did work in case of cc compiled programs where you do not check the | |
1141 | parameter lists of the arguments. */ | |
1142 | add_symbol_to_list (sym, &local_list); | |
1143 | } | |
1144 | ||
1145 | /* If type was read in earlier, don't bother with modifying | |
1146 | the type struct */ | |
1147 | if (!record_args) | |
1148 | goto finish; | |
1149 | ||
1150 | /* Note how many parameters we found. */ | |
1151 | TYPE_NFIELDS (type) = nsyms; | |
1152 | TYPE_FIELDS (type) = (struct field *) | |
1153 | obstack_alloc (&objfile->type_obstack, | |
1154 | sizeof (struct field) * nsyms); | |
1155 | ||
1156 | /* Find the symbols for the parameters and | |
1157 | use them to fill parameter-type information into the function-type. | |
1158 | The parameter symbols can be found in the local_list that we just put them on. */ | |
1159 | /* Note that we preserve the order of the parameters, so | |
1160 | that in something like "enum {FOO, LAST_THING=FOO}" we print | |
1161 | FOO, not LAST_THING. */ | |
1162 | ||
1163 | /* get the parameters types from the local list not the global list | |
1164 | so that the type can be correctly constructed for functions which | |
1165 | have function as parameters | |
1166 | */ | |
1167 | for (syms = local_list, n = 0; syms; syms = syms->next) | |
1168 | { | |
1169 | int j = 0; | |
1170 | for (j = 0; j < syms->nsyms; j++, n++) | |
1171 | { | |
1172 | struct symbol *xsym = syms->symbol[j]; | |
1173 | TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym); | |
1174 | TYPE_FIELD_TYPE (type, n) = SYMBOL_TYPE (xsym); | |
1175 | TYPE_FIELD_BITPOS (type, n) = n; | |
1176 | TYPE_FIELD_BITSIZE (type, n) = 0; | |
1177 | } | |
1178 | } | |
1179 | ||
1180 | /* Mark it as having been processed */ | |
1181 | TYPE_FLAGS (type) &= ~(TYPE_FLAG_INCOMPLETE); | |
1182 | ||
1183 | /* Check whether we need to fix-up a class type with this function's type */ | |
1184 | if (fixup_class && (fixup_method == type)) | |
1185 | { | |
1186 | fixup_class_method_type (fixup_class, fixup_method, objfile); | |
1187 | fixup_class = NULL; | |
1188 | fixup_method = NULL; | |
1189 | } | |
1190 | ||
1191 | /* Set the param list of this level of the context stack | |
1192 | to our local list. Do this only if this function was | |
1193 | called for creating a new block, and not if it was called | |
1194 | simply to get the function type. This prevents recursive | |
1195 | invocations from trashing param_symbols. */ | |
1196 | finish: | |
1197 | if (newblock) | |
1198 | param_symbols = local_list; | |
1199 | ||
1200 | return type; | |
1201 | } | |
1202 | ||
1203 | ||
1204 | ||
1205 | /* A file-level variable which keeps track of the current-template | |
1206 | * being processed. Set in hpread_read_struct_type() while processing | |
1207 | * a template type. Referred to in hpread_get_nth_templ_arg(). | |
1208 | * Yes, this is a kludge, but it arises from the kludge that already | |
1209 | * exists in symtab.h, namely the fact that they encode | |
1210 | * "template argument n" with fundamental type FT_TEMPLATE_ARG and | |
1211 | * bitlength n. This means that deep in processing fundamental types | |
1212 | * I need to ask the question "what template am I in the middle of?". | |
1213 | * The alternative to stuffing a global would be to pass an argument | |
1214 | * down the chain of calls just for this purpose. | |
1215 | * | |
1216 | * There may be problems handling nested templates... tough. | |
1217 | */ | |
1218 | static struct type * current_template = NULL; | |
1219 | ||
1220 | /* Read in and internalize a structure definition. | |
1221 | * This same routine is called for struct, union, and class types. | |
1222 | * Also called for templates, since they build a very similar | |
1223 | * type entry as for class types. | |
1224 | */ | |
1225 | ||
1226 | static struct type * | |
1227 | hpread_read_struct_type (hp_type, dn_bufp, objfile) | |
1228 | dnttpointer hp_type; | |
1229 | union dnttentry *dn_bufp; | |
1230 | struct objfile *objfile; | |
1231 | { | |
1232 | /* The data members get linked together into a list of struct nextfield's */ | |
1233 | struct nextfield | |
1234 | { | |
1235 | struct nextfield *next; | |
1236 | struct field field; | |
1237 | unsigned char attributes; /* store visibility and virtuality info */ | |
1238 | # define ATTR_VIRTUAL 1 | |
1239 | # define ATTR_PRIVATE 2 | |
1240 | # define ATTR_PROTECT 3 | |
1241 | }; | |
1242 | ||
1243 | ||
1244 | /* The methods get linked together into a list of struct next_fn_field's */ | |
1245 | struct next_fn_field | |
1246 | { | |
1247 | struct next_fn_field *next; | |
1248 | struct fn_fieldlist field; | |
1249 | struct fn_field fn_field; | |
1250 | int num_fn_fields; | |
1251 | }; | |
1252 | ||
1253 | /* The template args get linked together into a list of struct next_template's */ | |
1254 | struct next_template | |
1255 | { | |
1256 | struct next_template *next; | |
1257 | struct template_arg arg; | |
1258 | }; | |
1259 | ||
1260 | /* The template instantiations get linked together into a list of these... */ | |
1261 | struct next_instantiation | |
1262 | { | |
1263 | struct next_instantiation * next; | |
1264 | struct type * t; | |
1265 | }; | |
1266 | ||
1267 | struct type *type; | |
1268 | struct type *baseclass; | |
1269 | struct type *memtype; | |
1270 | struct nextfield *list = 0, *tmp_list = 0; | |
1271 | struct next_fn_field *fn_list = 0; | |
1272 | struct next_fn_field *fn_p; | |
1273 | struct next_template *t_new, *t_list = 0; | |
1274 | struct nextfield *new; | |
1275 | struct next_fn_field *fn_new; | |
1276 | struct next_instantiation *i_new, *i_list = 0; | |
1277 | int n, nfields = 0, n_fn_fields = 0, n_fn_fields_total = 0; | |
1278 | int n_base_classes = 0, n_templ_args = 0; | |
1279 | int ninstantiations = 0; | |
1280 | dnttpointer field, fn_field, parent; | |
1281 | union dnttentry *fieldp, *fn_fieldp, *parentp; | |
1282 | int i; | |
1283 | int static_member = 0; | |
1284 | int const_member = 0; | |
1285 | int volatile_member = 0; | |
1286 | unsigned long vtbl_offset; | |
1287 | int need_bitvectors = 0; | |
1288 | char * method_name = NULL; | |
1289 | char * method_alias = NULL; | |
1290 | ||
1291 | ||
1292 | /* Is it something we've already dealt with? */ | |
1293 | type = hpread_alloc_type (hp_type, objfile); | |
1294 | if ((TYPE_CODE (type) == TYPE_CODE_STRUCT) || | |
1295 | (TYPE_CODE (type) == TYPE_CODE_UNION) || | |
1296 | (TYPE_CODE (type) == TYPE_CODE_CLASS) || | |
1297 | (TYPE_CODE (type) == TYPE_CODE_TEMPLATE)) | |
1298 | return type; | |
1299 | ||
1300 | /* Get the basic type correct. */ | |
1301 | if (dn_bufp->dblock.kind == DNTT_TYPE_STRUCT) | |
1302 | { | |
1303 | TYPE_CODE (type) = TYPE_CODE_STRUCT; | |
1304 | TYPE_LENGTH (type) = dn_bufp->dstruct.bitlength / 8; | |
1305 | } | |
1306 | else if (dn_bufp->dblock.kind == DNTT_TYPE_UNION) | |
1307 | { | |
1308 | TYPE_CODE (type) = TYPE_CODE_UNION; | |
1309 | TYPE_LENGTH (type) = dn_bufp->dunion.bitlength / 8; | |
1310 | } | |
1311 | else if (dn_bufp->dblock.kind == DNTT_TYPE_CLASS) | |
1312 | { | |
1313 | TYPE_CODE (type) = TYPE_CODE_CLASS; | |
1314 | TYPE_LENGTH (type) = dn_bufp->dclass.bitlength / 8; | |
1315 | ||
1316 | /* Overrides the TYPE_CPLUS_SPECIFIC(type) with allocated memory | |
1317 | * rather than &cplus_struct_default. | |
1318 | */ | |
1319 | allocate_cplus_struct_type(type); | |
1320 | ||
1321 | /* Fill in declared-type. | |
1322 | * (The C++ compiler will emit TYPE_CODE_CLASS | |
1323 | * for all 3 of "class", "struct" | |
1324 | * "union", and we have to look at the "class_decl" field if we | |
1325 | * want to know how it was really declared) | |
1326 | */ | |
1327 | /* (0==class, 1==union, 2==struct) */ | |
1328 | TYPE_DECLARED_TYPE(type) = dn_bufp->dclass.class_decl; | |
1329 | } | |
1330 | else if (dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE) | |
1331 | { | |
1332 | /* Get the basic type correct. */ | |
1333 | TYPE_CODE (type) = TYPE_CODE_TEMPLATE; | |
1334 | allocate_cplus_struct_type(type); | |
1335 | TYPE_DECLARED_TYPE(type) = DECLARED_TYPE_TEMPLATE; | |
1336 | } | |
1337 | else | |
1338 | return type; | |
1339 | ||
1340 | ||
1341 | TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB; | |
1342 | ||
1343 | /* For classes, read the parent list. | |
1344 | * Question (RT): Do we need to do this for templates also? | |
1345 | */ | |
1346 | if (dn_bufp->dblock.kind == DNTT_TYPE_CLASS) { | |
1347 | ||
1348 | /* First read the parent-list (classes from which we derive fields) */ | |
1349 | parent = dn_bufp->dclass.parentlist; | |
1350 | while (parent.word && parent.word != DNTTNIL) { | |
1351 | parentp = hpread_get_lntt (parent.dnttp.index, objfile); | |
1352 | ||
1353 | /* "parentp" should point to a DNTT_TYPE_INHERITANCE record */ | |
1354 | ||
1355 | /* Get space to record the next field/data-member. */ | |
1356 | new = (struct nextfield *) alloca (sizeof (struct nextfield)); | |
1357 | new->next = list; | |
1358 | list = new; | |
1359 | ||
1360 | FIELD_BITSIZE (list->field) = 0; | |
1361 | ||
1362 | /* The "classname" field is actually a DNTT pointer to the base class */ | |
1363 | baseclass = hpread_type_lookup (parentp->dinheritance.classname, | |
1364 | objfile); | |
1365 | FIELD_TYPE (list->field) = baseclass; | |
1366 | ||
1367 | list->field.name = type_name_no_tag(FIELD_TYPE (list->field)); | |
1368 | ||
1369 | list->attributes = 0; | |
1370 | ||
1371 | /* Check for virtuality of base, and set the | |
1372 | * offset of the base subobject within the object. | |
1373 | * (Offset set to -1 for virtual bases (for now).) | |
1374 | */ | |
1375 | if (parentp->dinheritance.Virtual) | |
1376 | { | |
1377 | B_SET(&(list->attributes), ATTR_VIRTUAL); | |
1378 | parentp->dinheritance.offset = -1; | |
1379 | } | |
1380 | else | |
1381 | FIELD_BITPOS (list->field) = parentp->dinheritance.offset; | |
1382 | ||
1383 | /* Check visibility */ | |
1384 | switch (parentp->dinheritance.visibility) | |
1385 | { | |
1386 | case 1: | |
1387 | B_SET(&(list->attributes), ATTR_PROTECT); | |
1388 | break; | |
1389 | case 2: | |
1390 | B_SET(&(list->attributes), ATTR_PRIVATE); | |
1391 | break; | |
1392 | } | |
1393 | ||
1394 | n_base_classes++; | |
1395 | nfields++; | |
1396 | ||
1397 | parent = parentp->dinheritance.next; | |
1398 | } | |
1399 | } | |
1400 | ||
1401 | /* For templates, read the template argument list. | |
1402 | * This must be done before processing the member list, because | |
1403 | * the member list may refer back to this. E.g.: | |
1404 | * template <class T1, class T2> class q2 { | |
1405 | * public: | |
1406 | * T1 a; | |
1407 | * T2 b; | |
1408 | * }; | |
1409 | * We need to read the argument list "T1", "T2" first. | |
1410 | */ | |
1411 | if (dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE) { | |
1412 | /* Kludge alert: This stuffs a global "current_template" which | |
1413 | * is referred to by hpread_get_nth_templ_arg(). The global | |
1414 | * is cleared at the end of this routine. | |
1415 | */ | |
1416 | current_template = type; | |
1417 | ||
1418 | /* Read in the argument list */ | |
1419 | field = dn_bufp->dtemplate.arglist; | |
1420 | while (field.word && field.word != DNTTNIL) { | |
1421 | /* Get this template argument*/ | |
1422 | fieldp = hpread_get_lntt (field.dnttp.index, objfile); | |
1423 | if (fieldp->dblock.kind != DNTT_TYPE_TEMPLATE_ARG) | |
1424 | { | |
1425 | warning ("Invalid debug info: Template argument entry is of wrong kind"); | |
1426 | break; | |
1427 | } | |
1428 | /* Bump the count */ | |
1429 | n_templ_args++; | |
1430 | /* Allocate and fill in a struct next_template */ | |
1431 | t_new = (struct next_template *) alloca (sizeof (struct next_template)); | |
1432 | t_new->next = t_list; | |
1433 | t_list = t_new; | |
1434 | t_list->arg.name = VT (objfile) + fieldp->dtempl_arg.name; | |
1435 | t_list->arg.type = hpread_read_templ_arg_type(field, fieldp, | |
1436 | objfile, t_list->arg.name); | |
1437 | /* Walk to the next template argument */ | |
1438 | field = fieldp->dtempl_arg.nextarg; | |
1439 | } | |
1440 | } | |
1441 | ||
1442 | TYPE_NTEMPLATE_ARGS(type) = n_templ_args; | |
1443 | ||
1444 | if (n_templ_args > 0) | |
1445 | TYPE_TEMPLATE_ARGS(type) = (struct template_arg *) | |
1446 | obstack_alloc (&objfile->type_obstack, sizeof (struct template_arg) * n_templ_args); | |
1447 | for (n = n_templ_args; t_list; t_list = t_list->next) | |
1448 | { | |
1449 | n -= 1; | |
1450 | TYPE_TEMPLATE_ARG(type, n) = t_list->arg; | |
1451 | } | |
1452 | ||
1453 | /* Next read in and internalize all the fields/members. */ | |
1454 | if (dn_bufp->dblock.kind == DNTT_TYPE_STRUCT) | |
1455 | field = dn_bufp->dstruct.firstfield; | |
1456 | else if (dn_bufp->dblock.kind == DNTT_TYPE_UNION) | |
1457 | field = dn_bufp->dunion.firstfield; | |
1458 | else if (dn_bufp->dblock.kind == DNTT_TYPE_CLASS) | |
1459 | field = dn_bufp->dclass.memberlist; | |
1460 | else if (dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE) | |
1461 | field = dn_bufp->dtemplate.memberlist; | |
1462 | else | |
1463 | field.word = DNTTNIL; | |
1464 | ||
1465 | while (field.word && field.word != DNTTNIL) | |
1466 | { | |
1467 | fieldp = hpread_get_lntt (field.dnttp.index, objfile); | |
1468 | ||
1469 | /* At this point "fieldp" may point to either a DNTT_TYPE_FIELD | |
1470 | * or a DNTT_TYPE_GENFIELD record. | |
1471 | */ | |
1472 | vtbl_offset = 0; | |
1473 | static_member = 0; | |
1474 | const_member = 0; | |
1475 | volatile_member = 0; | |
1476 | ||
1477 | if (fieldp->dblock.kind == DNTT_TYPE_GENFIELD) { | |
1478 | ||
1479 | /* The type will be GENFIELD if the field is a method or | |
1480 | * a static member (or some other cases -- see below) | |
1481 | */ | |
1482 | ||
1483 | /* Follow a link to get to the record for the field. */ | |
1484 | fn_field = fieldp->dgenfield.field; | |
1485 | fn_fieldp = hpread_get_lntt(fn_field.dnttp.index, objfile); | |
1486 | ||
1487 | /* Virtual funcs are indicated by a VFUNC which points to the | |
1488 | * real entry | |
1489 | */ | |
1490 | if (fn_fieldp->dblock.kind == DNTT_TYPE_VFUNC) { | |
1491 | vtbl_offset = fn_fieldp->dvfunc.vtbl_offset; | |
1492 | fn_field = fn_fieldp->dvfunc.funcptr; | |
1493 | fn_fieldp = hpread_get_lntt(fn_field.dnttp.index, objfile); | |
1494 | } | |
1495 | ||
1496 | /* A function's entry may be preceded by a modifier which | |
1497 | * labels it static/constant/volatile. | |
1498 | */ | |
1499 | if (fn_fieldp->dblock.kind == DNTT_TYPE_MODIFIER) { | |
1500 | static_member = fn_fieldp->dmodifier.m_static; | |
1501 | const_member = fn_fieldp->dmodifier.m_const; | |
1502 | volatile_member = fn_fieldp->dmodifier.m_volatile; | |
1503 | fn_field = fn_fieldp->dmodifier.type; | |
1504 | fn_fieldp = hpread_get_lntt(fn_field.dnttp.index, objfile); | |
1505 | } | |
1506 | ||
1507 | /* Check whether we have a method */ | |
1508 | if ((fn_fieldp->dblock.kind == DNTT_TYPE_MEMFUNC) || | |
1509 | (fn_fieldp->dblock.kind == DNTT_TYPE_FUNCTION) || | |
1510 | (fn_fieldp->dblock.kind == DNTT_TYPE_DOC_MEMFUNC) || | |
1511 | (fn_fieldp->dblock.kind == DNTT_TYPE_DOC_FUNCTION)) { | |
1512 | /* Method found */ | |
1513 | ||
1514 | short ix = 0; | |
1515 | ||
1516 | /* Look up function type of method */ | |
1517 | memtype = hpread_type_lookup (fn_field, objfile); | |
1518 | ||
1519 | /* Methods can be seen before classes in the SOM records. | |
1520 | If we are processing this class because it's a parameter of a | |
1521 | method, at this point the method's type is actually incomplete; | |
1522 | we'll have to fix it up later; mark the class for this. */ | |
1523 | ||
1524 | if (TYPE_INCOMPLETE (memtype)) | |
1525 | { | |
1526 | TYPE_FLAGS (type) |= TYPE_FLAG_INCOMPLETE; | |
1527 | if (fixup_class) | |
1528 | warning ("Two classes to fix up for method?? Type information may be incorrect for some classes."); | |
1529 | if (fixup_method) | |
1530 | warning ("Two methods to be fixed up at once?? Type information may be incorrect for some classes."); | |
1531 | fixup_class = type; /* remember this class has to be fixed up */ | |
1532 | fixup_method = memtype; /* remember the method type to be used in fixup */ | |
1533 | } | |
1534 | ||
1535 | /* HP aCC generates operator names without the "operator" keyword, and | |
1536 | generates null strings as names for operators that are | |
1537 | user-defined type conversions to basic types (e.g. operator int ()). | |
1538 | So try to reconstruct name as best as possible. */ | |
1539 | ||
1540 | method_name = (char *) (VT (objfile) + fn_fieldp->dfunc.name); | |
1541 | method_alias = (char *) (VT (objfile) + fn_fieldp->dfunc.alias); | |
1542 | ||
1543 | if (!method_name || /* no name */ | |
1544 | !*method_name || /* or null name */ | |
1545 | cplus_mangle_opname (method_name, DMGL_ANSI)) /* or name is an operator like "<" */ | |
1546 | { | |
1547 | char * tmp_name = cplus_demangle (method_alias, DMGL_ANSI); | |
1548 | char * op_string = strstr (tmp_name, "operator"); | |
1549 | method_name = xmalloc (strlen (op_string) + 1); /* don't overwrite VT! */ | |
1550 | strcpy (method_name, op_string); | |
1551 | } | |
1552 | ||
1553 | /* First check if a method of the same name has already been seen. */ | |
1554 | fn_p = fn_list; | |
1555 | while (fn_p) | |
1556 | { | |
1557 | if (STREQ (fn_p->field.name, method_name)) | |
1558 | break; | |
1559 | fn_p = fn_p->next; | |
1560 | } | |
1561 | ||
1562 | /* If no such method was found, allocate a new entry in the list */ | |
1563 | if (!fn_p) | |
1564 | { | |
1565 | /* Get space to record this member function */ | |
1566 | /* Note: alloca used; this will disappear on routine exit */ | |
1567 | fn_new = (struct next_fn_field *) alloca (sizeof (struct next_fn_field)); | |
1568 | fn_new->next = fn_list; | |
1569 | fn_list = fn_new; | |
1570 | ||
1571 | /* Fill in the fields of the struct nextfield */ | |
1572 | ||
1573 | /* Record the (unmangled) method name */ | |
1574 | fn_list->field.name = method_name; | |
1575 | /* Initial space for overloaded methods */ | |
1576 | /* Note: xmalloc is used; this will persist after this routine exits */ | |
1577 | fn_list->field.fn_fields = (struct fn_field *) xmalloc (5 * (sizeof (struct fn_field))); | |
1578 | fn_list->field.length = 1; /* Init # of overloaded instances */ | |
1579 | fn_list->num_fn_fields = 5; /* # of entries for which space allocated */ | |
1580 | fn_p = fn_list; | |
1581 | ix = 0; /* array index for fn_field */ | |
1582 | /* Bump the total count of the distinctly named methods */ | |
1583 | n_fn_fields++; | |
1584 | } | |
1585 | else /* Another overloaded instance of an already seen method name */ | |
1586 | { | |
1587 | if (++(fn_p->field.length) > fn_p->num_fn_fields) | |
1588 | { | |
1589 | /* Increase space allocated for overloaded instances */ | |
1590 | fn_p->field.fn_fields | |
1591 | = (struct fn_field *) xrealloc (fn_p->field.fn_fields, | |
1592 | (fn_p->num_fn_fields + 5) * sizeof (struct fn_field)); | |
1593 | fn_p->num_fn_fields += 5; | |
1594 | } | |
1595 | ix = fn_p->field.length -1; /* array index for fn_field */ | |
1596 | } | |
1597 | ||
1598 | /* "physname" is intended to be the name of this overloaded instance. */ | |
1599 | if ((fn_fieldp->dfunc.language == HP_LANGUAGE_CPLUSPLUS) && | |
1600 | method_alias && | |
1601 | *method_alias) /* not a null string */ | |
1602 | fn_p->field.fn_fields[ix].physname = method_alias; | |
1603 | else | |
1604 | fn_p->field.fn_fields[ix].physname = method_name; | |
1605 | /* What's expected here is the function type */ | |
1606 | /* But mark it as NULL if the method was incompletely processed | |
1607 | We'll fix this up later when the method is fully processed */ | |
1608 | if (TYPE_INCOMPLETE (memtype)) | |
1609 | { | |
1610 | fn_p->field.fn_fields[ix].type = NULL; | |
1611 | fn_p->field.fn_fields[ix].args = NULL; | |
1612 | } | |
1613 | else | |
1614 | { | |
1615 | fn_p->field.fn_fields[ix].type = memtype; | |
1616 | ||
1617 | /* The argument list */ | |
1618 | fn_p->field.fn_fields[ix].type->type_specific.arg_types = | |
1619 | (struct type **) obstack_alloc(&objfile->type_obstack, | |
1620 | sizeof(struct type *) * (memtype->nfields + 1)); | |
1621 | for (i = 0; i < memtype->nfields; i++) | |
1622 | fn_p->field.fn_fields[ix].type->type_specific.arg_types[i] = memtype->fields[i].type; | |
1623 | /* void termination */ | |
1624 | fn_p->field.fn_fields[ix].type->type_specific.arg_types[memtype->nfields] = builtin_type_void; | |
1625 | ||
1626 | /* pai: It's not clear why this args field has to be set. Perhaps | |
1627 | * it should be eliminated entirely. */ | |
1628 | fn_p->field.fn_fields[ix].args = | |
1629 | (struct type **) obstack_alloc(&objfile->type_obstack, | |
1630 | sizeof(struct type *) * (memtype->nfields + 1)); | |
1631 | for (i = 0; i < memtype->nfields; i++) | |
1632 | fn_p->field.fn_fields[ix].args[i] = memtype->fields[i].type; | |
1633 | /* null-terminated, unlike arg_types above e*/ | |
1634 | fn_p->field.fn_fields[ix].args[memtype->nfields] = NULL; | |
1635 | } | |
1636 | /* For virtual functions, fill in the voffset field with the | |
1637 | * virtual table offset. (This is just copied over from the | |
1638 | * SOM record; not sure if it is what GDB expects here...). | |
1639 | * But if the function is a static method, set it to 1. | |
1640 | * | |
1641 | * Note that we have to add 1 because 1 indicates a static | |
1642 | * method, and 0 indicates a non-static, non-virtual method */ | |
1643 | ||
1644 | if (static_member) | |
1645 | fn_p->field.fn_fields[ix].voffset = VOFFSET_STATIC; | |
1646 | else | |
1647 | fn_p->field.fn_fields[ix].voffset = vtbl_offset ? vtbl_offset + 1 : 0; | |
1648 | ||
1649 | /* Also fill in the fcontext field with the current | |
1650 | * class. (The latter isn't quite right: should be the baseclass | |
1651 | * that defines the virtual function... Note we do have | |
1652 | * a variable "baseclass" that we could stuff into the fcontext | |
1653 | * field, but "baseclass" isn't necessarily right either, | |
1654 | * since the virtual function could have been defined more | |
1655 | * than one level up). | |
1656 | */ | |
1657 | ||
1658 | if (vtbl_offset != 0) | |
1659 | fn_p->field.fn_fields[ix].fcontext = type; | |
1660 | else | |
1661 | fn_p->field.fn_fields[ix].fcontext = NULL; | |
1662 | ||
1663 | /* Other random fields pertaining to this method */ | |
1664 | fn_p->field.fn_fields[ix].is_const = const_member; | |
1665 | fn_p->field.fn_fields[ix].is_volatile = volatile_member; /* ?? */ | |
1666 | switch (fieldp->dgenfield.visibility) { | |
1667 | case 1: | |
1668 | fn_p->field.fn_fields[ix].is_protected = 1; | |
1669 | fn_p->field.fn_fields[ix].is_private = 0; | |
1670 | break; | |
1671 | case 2: | |
1672 | fn_p->field.fn_fields[ix].is_protected = 0; | |
1673 | fn_p->field.fn_fields[ix].is_private = 1; | |
1674 | break; | |
1675 | default: /* public */ | |
1676 | fn_p->field.fn_fields[ix].is_protected = 0; | |
1677 | fn_p->field.fn_fields[ix].is_private = 0; | |
1678 | } | |
1679 | fn_p->field.fn_fields[ix].is_stub = 0; | |
1680 | ||
1681 | /* HP aCC emits both MEMFUNC and FUNCTION entries for a method; | |
1682 | if the class points to the FUNCTION, there is usually separate | |
1683 | code for the method; but if we have a MEMFUNC, the method has | |
1684 | been inlined (and there is usually no FUNCTION entry) | |
1685 | FIXME Not sure if this test is accurate. pai/1997-08-22 */ | |
1686 | if ((fn_fieldp->dblock.kind == DNTT_TYPE_MEMFUNC) || | |
1687 | (fn_fieldp->dblock.kind == DNTT_TYPE_DOC_MEMFUNC)) | |
1688 | fn_p->field.fn_fields[ix].is_inlined = 1; | |
1689 | else | |
1690 | fn_p->field.fn_fields[ix].is_inlined = 0; | |
1691 | ||
1692 | fn_p->field.fn_fields[ix].dummy = 0; | |
1693 | ||
1694 | /* Bump the total count of the member functions */ | |
1695 | n_fn_fields_total++; | |
1696 | ||
1697 | } else if (fn_fieldp->dblock.kind == DNTT_TYPE_SVAR) { | |
1698 | /* This case is for static data members of classes */ | |
1699 | ||
1700 | /* pai:: FIXME -- check that "staticmem" bit is set */ | |
1701 | ||
1702 | /* Get space to record this static member */ | |
1703 | new = (struct nextfield *) alloca (sizeof (struct nextfield)); | |
1704 | new->next = list; | |
1705 | list = new; | |
1706 | ||
1707 | list->field.name = VT (objfile) + fn_fieldp->dsvar.name; | |
1708 | FIELD_BITSIZE (list->field) = -1; /* indicates static member */ | |
1709 | SET_FIELD_PHYSNAME (list->field, 0); /* initialize to empty */ | |
1710 | memtype = hpread_type_lookup (fn_fieldp->dsvar.type, objfile); | |
1711 | ||
1712 | FIELD_TYPE (list->field) = memtype; | |
1713 | list->attributes = 0; | |
1714 | switch (fieldp->dgenfield.visibility) { | |
1715 | case 1: | |
1716 | B_SET(&(list->attributes), ATTR_PROTECT); | |
1717 | break; | |
1718 | case 2: | |
1719 | B_SET(&(list->attributes), ATTR_PRIVATE); | |
1720 | break; | |
1721 | } | |
1722 | nfields++; | |
1723 | } | |
1724 | ||
1725 | else if (fn_fieldp->dblock.kind == DNTT_TYPE_FIELD) | |
1726 | { | |
1727 | /* FIELDs follow GENFIELDs for fields of anonymous unions. | |
1728 | Code below is replicated from the case for FIELDs further | |
1729 | below, except that fieldp is replaced by fn_fieldp */ | |
1730 | if (!fn_fieldp->dfield.a_union) | |
1731 | warning ("Debug info inconsistent: FIELD of anonymous union doesn't have a_union bit set"); | |
1732 | /* Get space to record the next field/data-member. */ | |
1733 | new = (struct nextfield *) alloca (sizeof (struct nextfield)); | |
1734 | new->next = list; | |
1735 | list = new; | |
1736 | ||
1737 | list->field.name = VT (objfile) + fn_fieldp->dfield.name; | |
1738 | FIELD_BITPOS (list->field) = fn_fieldp->dfield.bitoffset; | |
1739 | if (fn_fieldp->dfield.bitlength % 8) | |
1740 | list->field.bitsize = fn_fieldp->dfield.bitlength; | |
1741 | else | |
1742 | list->field.bitsize = 0; | |
1743 | ||
1744 | memtype = hpread_type_lookup (fn_fieldp->dfield.type, objfile); | |
1745 | list->field.type = memtype; | |
1746 | list->attributes = 0; | |
1747 | switch (fn_fieldp->dfield.visibility) { | |
1748 | case 1: | |
1749 | B_SET(&(list->attributes), ATTR_PROTECT); | |
1750 | break; | |
1751 | case 2: | |
1752 | B_SET(&(list->attributes), ATTR_PRIVATE); | |
1753 | break; | |
1754 | } | |
1755 | nfields++; | |
1756 | } | |
1757 | else if (fn_fieldp->dblock.kind == DNTT_TYPE_SVAR) | |
1758 | { | |
1759 | /* Field of anonymous union; union is not inside a class */ | |
1760 | if (!fn_fieldp->dsvar.a_union) | |
1761 | warning ("Debug info inconsistent: SVAR field in anonymous union doesn't have a_union bit set"); | |
1762 | /* Get space to record the next field/data-member. */ | |
1763 | new = (struct nextfield *) alloca (sizeof (struct nextfield)); | |
1764 | new->next = list; | |
1765 | list = new; | |
1766 | ||
1767 | list->field.name = VT (objfile) + fn_fieldp->dsvar.name; | |
1768 | FIELD_BITPOS (list->field) = 0; /* FIXME is this always true? */ | |
1769 | FIELD_BITSIZE (list->field) = 0; /* use length from type */ | |
1770 | memtype = hpread_type_lookup (fn_fieldp->dsvar.type, objfile); | |
1771 | list->field.type = memtype; | |
1772 | list->attributes = 0; | |
1773 | /* No info to set visibility -- always public */ | |
1774 | nfields++; | |
1775 | } | |
1776 | else if (fn_fieldp->dblock.kind == DNTT_TYPE_DVAR) | |
1777 | { | |
1778 | /* Field of anonymous union; union is not inside a class */ | |
1779 | if (!fn_fieldp->ddvar.a_union) | |
1780 | warning ("Debug info inconsistent: DVAR field in anonymous union doesn't have a_union bit set"); | |
1781 | /* Get space to record the next field/data-member. */ | |
1782 | new = (struct nextfield *) alloca (sizeof (struct nextfield)); | |
1783 | new->next = list; | |
1784 | list = new; | |
1785 | ||
1786 | list->field.name = VT (objfile) + fn_fieldp->ddvar.name; | |
1787 | FIELD_BITPOS (list->field) = 0; /* FIXME is this always true? */ | |
1788 | FIELD_BITSIZE (list->field) = 0; /* use length from type */ | |
1789 | memtype = hpread_type_lookup (fn_fieldp->ddvar.type, objfile); | |
1790 | list->field.type = memtype; | |
1791 | list->attributes = 0; | |
1792 | /* No info to set visibility -- always public */ | |
1793 | nfields++; | |
1794 | } | |
1795 | else { /* Not a method, nor a static data member, nor an anon union field */ | |
1796 | ||
1797 | /* This case is for miscellaneous type entries (local enums, | |
1798 | local function templates, etc.) that can be present | |
1799 | inside a class. */ | |
1800 | ||
1801 | /* Enums -- will be handled by other code that takes care | |
1802 | of DNTT_TYPE_ENUM; here we see only DNTT_TYPE_MEMENUM so | |
1803 | it's not clear we could have handled them here at all. */ | |
1804 | /* FUNC_TEMPLATE: is handled by other code (??). */ | |
1805 | /* MEMACCESS: modified access for inherited member. Not | |
1806 | sure what to do with this, ignoriing it at present. */ | |
1807 | ||
1808 | /* What other entries can appear following a GENFIELD which | |
1809 | we do not handle above? (MODIFIER, VFUNC handled above.) */ | |
1810 | ||
1811 | if ((fn_fieldp->dblock.kind != DNTT_TYPE_MEMACCESS) && | |
1812 | (fn_fieldp->dblock.kind != DNTT_TYPE_MEMENUM) && | |
1813 | (fn_fieldp->dblock.kind != DNTT_TYPE_FUNC_TEMPLATE)) | |
1814 | warning ("Internal error: Unexpected debug record kind %d found following DNTT_GENFIELD", | |
1815 | fn_fieldp->dblock.kind); | |
1816 | } | |
1817 | /* walk to the next FIELD or GENFIELD */ | |
1818 | field = fieldp->dgenfield.nextfield; | |
1819 | ||
1820 | } | |
1821 | else if (fieldp->dblock.kind == DNTT_TYPE_FIELD) { | |
1822 | ||
1823 | /* Ordinary structure/union/class field */ | |
1824 | struct type * anon_union_type; | |
1825 | ||
1826 | /* Get space to record the next field/data-member. */ | |
1827 | new = (struct nextfield *) alloca (sizeof (struct nextfield)); | |
1828 | new->next = list; | |
1829 | list = new; | |
1830 | ||
1831 | list->field.name = VT (objfile) + fieldp->dfield.name; | |
1832 | ||
1833 | ||
1834 | /* A FIELD by itself (without a GENFIELD) can also be a static member */ | |
1835 | if (fieldp->dfield.staticmem) | |
1836 | { | |
1837 | FIELD_BITPOS (list->field) = -1; | |
1838 | FIELD_BITSIZE (list->field) = 0; | |
1839 | } | |
1840 | else /* Non-static data member */ | |
1841 | { | |
1842 | FIELD_BITPOS (list->field) = fieldp->dfield.bitoffset; | |
1843 | if (fieldp->dfield.bitlength % 8) | |
1844 | FIELD_BITSIZE (list->field) = fieldp->dfield.bitlength; | |
1845 | else | |
1846 | FIELD_BITSIZE (list->field) = 0; | |
1847 | } | |
1848 | ||
1849 | memtype = hpread_type_lookup (fieldp->dfield.type, objfile); | |
1850 | FIELD_TYPE (list->field) = memtype; | |
1851 | list->attributes = 0; | |
1852 | switch (fieldp->dfield.visibility) { | |
1853 | case 1: | |
1854 | B_SET(&(list->attributes), ATTR_PROTECT); | |
1855 | break; | |
1856 | case 2: | |
1857 | B_SET(&(list->attributes), ATTR_PRIVATE); | |
1858 | break; | |
1859 | } | |
1860 | nfields++; | |
1861 | ||
1862 | ||
1863 | /* Note 1: First, we have to check if the current field is an anonymous | |
1864 | union. If it is, then *its* fields are threaded along in the | |
1865 | nextfield chain. :-( This was supposed to help debuggers, but is | |
1866 | really just a nuisance since we deal with anonymous unions anyway by | |
1867 | checking that the name is null. So anyway, we skip over the fields | |
1868 | of the anonymous union. pai/1997-08-22 */ | |
1869 | /* Note 2: In addition, the bitoffsets for the fields of the anon union | |
1870 | are relative to the enclosing struct, *NOT* relative to the anon | |
1871 | union! This is an even bigger nuisance -- we have to go in and munge | |
1872 | the anon union's type information appropriately. pai/1997-08-22 */ | |
1873 | ||
1874 | /* Both tasks noted above are done by a separate function. This takes us | |
1875 | to the next FIELD or GENFIELD, skipping anon unions, and recursively | |
1876 | processing intermediate types. */ | |
1877 | field = hpread_get_next_skip_over_anon_unions (1, field, &fieldp, objfile); | |
1878 | ||
1879 | } else { | |
1880 | /* neither field nor genfield ?? is this possible?? */ | |
1881 | /* pai:: FIXME walk to the next -- how? */ | |
1882 | warning ("Internal error: unexpected DNTT kind %d encountered as field of struct"); | |
1883 | warning ("Skipping remaining fields of struct"); | |
1884 | break; /* get out of loop of fields */ | |
1885 | } | |
1886 | } | |
1887 | ||
1888 | /* If it's a template, read in the instantiation list */ | |
1889 | if (dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE) { | |
1890 | ninstantiations = 0; | |
1891 | field = dn_bufp->dtemplate.expansions; | |
1892 | while (field.word && field.word != DNTTNIL) { | |
1893 | fieldp = hpread_get_lntt (field.dnttp.index, objfile); | |
1894 | ||
1895 | /* The expansions or nextexp should point to a tagdef */ | |
1896 | if (fieldp->dblock.kind != DNTT_TYPE_TAGDEF) | |
1897 | break; | |
1898 | ||
1899 | i_new = (struct next_instantiation *) alloca (sizeof (struct next_instantiation)); | |
1900 | i_new->next = i_list; | |
1901 | i_list = i_new; | |
1902 | i_list->t = hpread_type_lookup (field, objfile); | |
1903 | ninstantiations++; | |
1904 | ||
1905 | /* And the "type" field of that should point to a class */ | |
1906 | field = fieldp->dtag.type; | |
1907 | fieldp = hpread_get_lntt (field.dnttp.index, objfile); | |
1908 | if (fieldp->dblock.kind != DNTT_TYPE_CLASS) | |
1909 | break; | |
1910 | ||
1911 | /* Get the next expansion */ | |
1912 | field = fieldp->dclass.nextexp; | |
1913 | } | |
1914 | } | |
1915 | TYPE_NINSTANTIATIONS(type) = ninstantiations; | |
1916 | if (ninstantiations > 0) | |
1917 | TYPE_INSTANTIATIONS(type) = (struct type **) | |
1918 | obstack_alloc (&objfile->type_obstack, sizeof (struct type *) * ninstantiations); | |
1919 | for (n = ninstantiations; i_list; i_list = i_list->next) | |
1920 | { | |
1921 | n -= 1; | |
1922 | TYPE_INSTANTIATION(type, n) = i_list->t; | |
1923 | } | |
1924 | ||
1925 | ||
1926 | /* Copy the field-list to GDB's symbol table */ | |
1927 | TYPE_NFIELDS (type) = nfields; | |
1928 | TYPE_N_BASECLASSES (type) = n_base_classes; | |
1929 | TYPE_FIELDS (type) = (struct field *) | |
1930 | obstack_alloc (&objfile->type_obstack, sizeof (struct field) * nfields); | |
1931 | /* Copy the saved-up fields into the field vector. */ | |
1932 | for (n = nfields, tmp_list = list; tmp_list; tmp_list = tmp_list->next) | |
1933 | { | |
1934 | n -= 1; | |
1935 | TYPE_FIELD (type, n) = tmp_list->field; | |
1936 | } | |
1937 | ||
1938 | /* Copy the "function-field-list" (i.e., the list of member | |
1939 | * functions in the class) to GDB's symbol table | |
1940 | */ | |
1941 | TYPE_NFN_FIELDS (type) = n_fn_fields; | |
1942 | TYPE_NFN_FIELDS_TOTAL (type) = n_fn_fields_total; | |
1943 | TYPE_FN_FIELDLISTS(type) = (struct fn_fieldlist *) | |
1944 | obstack_alloc (&objfile->type_obstack, sizeof (struct fn_fieldlist) * n_fn_fields); | |
1945 | for (n = n_fn_fields; fn_list; fn_list = fn_list->next) | |
1946 | { | |
1947 | n -= 1; | |
1948 | TYPE_FN_FIELDLIST(type, n) = fn_list->field; | |
1949 | } | |
1950 | ||
1951 | /* pai:: FIXME -- perhaps each bitvector should be created individually */ | |
1952 | for (n = nfields, tmp_list = list; tmp_list; tmp_list = tmp_list->next) | |
1953 | { | |
1954 | n -= 1; | |
1955 | if (tmp_list->attributes) | |
1956 | { | |
1957 | need_bitvectors = 1; | |
1958 | break; | |
1959 | } | |
1960 | } | |
1961 | ||
1962 | if (need_bitvectors) | |
1963 | { | |
1964 | /* pai:: this step probably redundant */ | |
1965 | ALLOCATE_CPLUS_STRUCT_TYPE (type); | |
1966 | ||
1967 | TYPE_FIELD_VIRTUAL_BITS (type) = | |
1968 | (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields)); | |
1969 | B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), nfields); | |
1970 | ||
1971 | TYPE_FIELD_PRIVATE_BITS (type) = | |
1972 | (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields)); | |
1973 | B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type), nfields); | |
1974 | ||
1975 | TYPE_FIELD_PROTECTED_BITS (type) = | |
1976 | (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields)); | |
1977 | B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type), nfields); | |
1978 | ||
1979 | /* this field vector isn't actually used with HP aCC */ | |
1980 | TYPE_FIELD_IGNORE_BITS (type) = | |
1981 | (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields)); | |
1982 | B_CLRALL (TYPE_FIELD_IGNORE_BITS (type), nfields); | |
1983 | ||
1984 | while (nfields-- > 0) | |
1985 | { | |
1986 | if (B_TST(&(list->attributes),ATTR_VIRTUAL)) | |
1987 | SET_TYPE_FIELD_VIRTUAL (type, nfields); | |
1988 | if (B_TST(&(list->attributes),ATTR_PRIVATE)) | |
1989 | SET_TYPE_FIELD_PRIVATE (type, nfields); | |
1990 | if (B_TST(&(list->attributes),ATTR_PROTECT)) | |
1991 | SET_TYPE_FIELD_PROTECTED (type, nfields); | |
1992 | ||
1993 | list = list->next; | |
1994 | } | |
1995 | } | |
1996 | else | |
1997 | { | |
1998 | TYPE_FIELD_VIRTUAL_BITS(type) = NULL; | |
1999 | TYPE_FIELD_PROTECTED_BITS(type) = NULL; | |
2000 | TYPE_FIELD_PRIVATE_BITS(type) = NULL; | |
2001 | } | |
2002 | ||
2003 | if (has_vtable(type)) | |
2004 | { | |
2005 | /* Allocate space for class runtime information */ | |
2006 | TYPE_RUNTIME_PTR(type) = (struct runtime_info *) xmalloc (sizeof(struct runtime_info)); | |
2007 | /* Set flag for vtable */ | |
2008 | TYPE_VTABLE(type) = 1; | |
2009 | /* The first non-virtual base class with a vtable. */ | |
2010 | TYPE_PRIMARY_BASE(type) = primary_base_class(type); | |
2011 | /* The virtual base list. */ | |
2012 | TYPE_VIRTUAL_BASE_LIST(type) = virtual_base_list(type); | |
2013 | } | |
2014 | else | |
2015 | TYPE_RUNTIME_PTR(type) = NULL; | |
2016 | ||
2017 | /* If this is a local type (C++ - declared inside a function), record file name & line # */ | |
2018 | if (hpread_get_scope_depth (dn_bufp, objfile, 1 /* no need for real depth */)) | |
2019 | { | |
2020 | TYPE_LOCALTYPE_PTR (type) = (struct local_type_info *) xmalloc (sizeof (struct local_type_info)); | |
2021 | TYPE_LOCALTYPE_FILE (type) = (char *) xmalloc (strlen (current_subfile->name) + 1); | |
2022 | strcpy (TYPE_LOCALTYPE_FILE (type), current_subfile->name); | |
2023 | if (current_subfile->line_vector && (current_subfile->line_vector->nitems > 0)) | |
2024 | TYPE_LOCALTYPE_LINE (type) = current_subfile->line_vector->item[current_subfile->line_vector->nitems - 1].line; | |
2025 | else | |
2026 | TYPE_LOCALTYPE_LINE (type) = 0; | |
2027 | } | |
2028 | else | |
2029 | TYPE_LOCALTYPE_PTR (type) = NULL; | |
2030 | ||
2031 | /* Clear the global saying what template we are in the middle of processing */ | |
2032 | current_template = NULL; | |
2033 | ||
2034 | return type; | |
2035 | } | |
2036 | ||
2037 | /* Adjust the physnames for each static member of a struct | |
2038 | or class type to be something like "A::x"; then various | |
2039 | other pieces of code that do a lookup_symbol on the phyname | |
2040 | work correctly. | |
2041 | TYPE is a pointer to the struct/class type | |
2042 | NAME is a char * (string) which is the class/struct name | |
2043 | Void return */ | |
2044 | ||
2045 | static void | |
2046 | fix_static_member_physnames (type, class_name, objfile) | |
2047 | struct type * type; | |
2048 | char * class_name; | |
2049 | struct objfile * objfile; | |
2050 | { | |
2051 | int i; | |
2052 | ||
2053 | /* We fix the member names only for classes or structs */ | |
2054 | if (TYPE_CODE (type) != TYPE_CODE_STRUCT) | |
2055 | return; | |
2056 | ||
2057 | for (i=0; i < TYPE_NFIELDS (type); i++) | |
2058 | if (TYPE_FIELD_STATIC (type, i)) | |
2059 | { | |
2060 | if (TYPE_FIELD_STATIC_PHYSNAME (type, i)) | |
2061 | return; /* physnames are already set */ | |
2062 | ||
2063 | SET_FIELD_PHYSNAME (type->fields[i], | |
2064 | obstack_alloc (&objfile->type_obstack, | |
2065 | strlen (class_name) + strlen (TYPE_FIELD_NAME (type, i)) + 3)); | |
2066 | strcpy (TYPE_FIELD_STATIC_PHYSNAME (type, i), class_name); | |
2067 | strcat (TYPE_FIELD_STATIC_PHYSNAME (type, i), "::"); | |
2068 | strcat (TYPE_FIELD_STATIC_PHYSNAME (type, i), TYPE_FIELD_NAME (type, i)); | |
2069 | } | |
2070 | } | |
2071 | ||
2072 | /* Fix-up the type structure for a CLASS so that the type entry | |
2073 | * for a method (previously marked with a null type in hpread_read_struct_type() | |
2074 | * is set correctly to METHOD. | |
2075 | * OBJFILE is as for other such functions. | |
2076 | * Void return. */ | |
2077 | ||
2078 | static void | |
2079 | fixup_class_method_type (class, method, objfile) | |
2080 | struct type * class; | |
2081 | struct type * method; | |
2082 | struct objfile * objfile; | |
2083 | { | |
2084 | int i, j, k; | |
2085 | ||
2086 | if (!class || !method || !objfile) | |
2087 | return; | |
2088 | ||
2089 | /* Only for types that have methods */ | |
2090 | if ((TYPE_CODE (class) != TYPE_CODE_CLASS) && | |
2091 | (TYPE_CODE (class) != TYPE_CODE_UNION)) | |
2092 | return; | |
2093 | ||
2094 | /* Loop over all methods and find the one marked with a NULL type */ | |
2095 | for (i = 0; i < TYPE_NFN_FIELDS (class); i++) | |
2096 | for (j = 0; j < TYPE_FN_FIELDLIST_LENGTH (class, i); j++) | |
2097 | if (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j) == NULL) | |
2098 | { | |
2099 | /* Set the method type */ | |
2100 | TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j) = method; | |
2101 | /* The argument list */ | |
2102 | (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j))->type_specific.arg_types | |
2103 | = (struct type **) obstack_alloc(&objfile->type_obstack, | |
2104 | sizeof(struct type *) * (method->nfields + 1)); | |
2105 | for (k = 0; k < method->nfields; k++) | |
2106 | (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j))->type_specific.arg_types[k] = method->fields[k].type; | |
2107 | /* void termination */ | |
2108 | (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j))->type_specific.arg_types[method->nfields] = builtin_type_void; | |
2109 | ||
2110 | /* pai: It's not clear why this args field has to be set. Perhaps | |
2111 | * it should be eliminated entirely. */ | |
2112 | (TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i), j)).args | |
2113 | = (struct type **) obstack_alloc(&objfile->type_obstack, | |
2114 | sizeof(struct type *) * (method->nfields + 1)); | |
2115 | for (k = 0; k < method->nfields; k++) | |
2116 | (TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i), j)).args[k] = method->fields[k].type; | |
2117 | /* null-terminated, unlike arg_types above */ | |
2118 | (TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i), j)).args[method->nfields] = NULL; | |
2119 | ||
2120 | /* Break out of both loops -- only one method to fix up in a class */ | |
2121 | goto finish; | |
2122 | } | |
2123 | ||
2124 | finish: | |
2125 | TYPE_FLAGS (class) &= ~TYPE_FLAG_INCOMPLETE; | |
2126 | } | |
2127 | ||
2128 | ||
2129 | /* If we're in the middle of processing a template, get a pointer | |
2130 | * to the Nth template argument. | |
2131 | * An example may make this clearer: | |
2132 | * template <class T1, class T2> class q2 { | |
2133 | * public: | |
2134 | * T1 a; | |
2135 | * T2 b; | |
2136 | * }; | |
2137 | * The type for "a" will be "first template arg" and | |
2138 | * the type for "b" will be "second template arg". | |
2139 | * We need to look these up in order to fill in "a" and "b"'s type. | |
2140 | * This is called from hpread_type_lookup(). | |
2141 | */ | |
2142 | static struct type * | |
2143 | hpread_get_nth_template_arg(objfile, n) | |
2144 | struct objfile *objfile; | |
2145 | int n; | |
2146 | { | |
2147 | if (current_template != NULL) | |
2148 | return TYPE_TEMPLATE_ARG(current_template, n).type; | |
2149 | else | |
2150 | return lookup_fundamental_type (objfile, FT_TEMPLATE_ARG); | |
2151 | } | |
2152 | ||
2153 | /* Read in and internalize a TEMPL_ARG (template arg) symbol. */ | |
2154 | ||
2155 | static struct type * | |
2156 | hpread_read_templ_arg_type (hp_type, dn_bufp, objfile, name) | |
2157 | dnttpointer hp_type; | |
2158 | union dnttentry *dn_bufp; | |
2159 | struct objfile *objfile; | |
2160 | char * name; | |
2161 | { | |
2162 | struct type *type; | |
2163 | ||
2164 | /* See if it's something we've already deal with. */ | |
2165 | type = hpread_alloc_type (hp_type, objfile); | |
2166 | if (TYPE_CODE (type) == TYPE_CODE_TEMPLATE_ARG) | |
2167 | return type; | |
2168 | ||
2169 | /* Nope. Fill in the appropriate fields. */ | |
2170 | TYPE_CODE (type) = TYPE_CODE_TEMPLATE_ARG; | |
2171 | TYPE_LENGTH (type) = 0; | |
2172 | TYPE_NFIELDS (type) = 0; | |
2173 | TYPE_NAME (type) = name; | |
2174 | return type; | |
2175 | } | |
2176 | ||
2177 | /* Read in and internalize a set debug symbol. */ | |
2178 | ||
2179 | static struct type * | |
2180 | hpread_read_set_type (hp_type, dn_bufp, objfile) | |
2181 | dnttpointer hp_type; | |
2182 | union dnttentry *dn_bufp; | |
2183 | struct objfile *objfile; | |
2184 | { | |
2185 | struct type *type; | |
2186 | ||
2187 | /* See if it's something we've already deal with. */ | |
2188 | type = hpread_alloc_type (hp_type, objfile); | |
2189 | if (TYPE_CODE (type) == TYPE_CODE_SET) | |
2190 | return type; | |
2191 | ||
2192 | /* Nope. Fill in the appropriate fields. */ | |
2193 | TYPE_CODE (type) = TYPE_CODE_SET; | |
2194 | TYPE_LENGTH (type) = dn_bufp->dset.bitlength / 8; | |
2195 | TYPE_NFIELDS (type) = 0; | |
2196 | TYPE_TARGET_TYPE (type) = hpread_type_lookup (dn_bufp->dset.subtype, | |
2197 | objfile); | |
2198 | return type; | |
2199 | } | |
2200 | ||
2201 | /* Read in and internalize an array debug symbol. */ | |
2202 | ||
2203 | static struct type * | |
2204 | hpread_read_array_type (hp_type, dn_bufp, objfile) | |
2205 | dnttpointer hp_type; | |
2206 | union dnttentry *dn_bufp; | |
2207 | struct objfile *objfile; | |
2208 | { | |
2209 | struct type *type; | |
2210 | ||
2211 | /* Allocate an array type symbol. | |
2212 | * Why no check for already-read here, like in the other | |
2213 | * hpread_read_xxx_type routines? Because it kept us | |
2214 | * from properly determining the size of the array! | |
2215 | */ | |
2216 | type = hpread_alloc_type (hp_type, objfile); | |
2217 | ||
2218 | TYPE_CODE (type) = TYPE_CODE_ARRAY; | |
2219 | ||
2220 | /* Although the hp-symtab.h does not *require* this to be the case, | |
2221 | * GDB is assuming that "arrayisbytes" and "elemisbytes" be consistent. | |
2222 | * I.e., express both array-length and element-length in bits, | |
2223 | * or express both array-length and element-length in bytes. | |
2224 | */ | |
2225 | if (!((dn_bufp->darray.arrayisbytes && dn_bufp->darray.elemisbytes) || | |
2226 | (!dn_bufp->darray.arrayisbytes && !dn_bufp->darray.elemisbytes))) { | |
2227 | warning ("error in hpread_array_type.\n"); | |
2228 | return; | |
2229 | } else if (dn_bufp->darray.arraylength == 0x7fffffff) { | |
2230 | /* The HP debug format represents char foo[]; as an array with | |
2231 | * length 0x7fffffff. Internally GDB wants to represent this | |
2232 | * as an array of length zero. | |
2233 | */ | |
2234 | TYPE_LENGTH (type) = 0; | |
2235 | } else if (dn_bufp->darray.arrayisbytes) | |
2236 | TYPE_LENGTH (type) = dn_bufp->darray.arraylength; | |
2237 | else /* arraylength is in bits */ | |
2238 | TYPE_LENGTH (type) = dn_bufp->darray.arraylength / 8; | |
2239 | ||
2240 | TYPE_TARGET_TYPE (type) = hpread_type_lookup (dn_bufp->darray.elemtype, | |
2241 | objfile); | |
2242 | ||
2243 | /* The one "field" is used to store the subscript type */ | |
2244 | /* Since C and C++ multi-dimensional arrays are simply represented | |
2245 | * as: array of array of ..., we only need one subscript-type | |
2246 | * per array. This subscript type is typically a subrange of integer. | |
2247 | * If this gets extended to support languages like Pascal, then | |
2248 | * we need to fix this to represent multi-dimensional arrays properly. | |
2249 | */ | |
2250 | TYPE_NFIELDS (type) = 1; | |
2251 | TYPE_FIELDS (type) = (struct field *) | |
2252 | obstack_alloc (&objfile->type_obstack, sizeof (struct field)); | |
2253 | TYPE_FIELD_TYPE (type, 0) = hpread_type_lookup (dn_bufp->darray.indextype, | |
2254 | objfile); | |
2255 | return type; | |
2256 | } | |
2257 | ||
2258 | /* Read in and internalize a subrange debug symbol. */ | |
2259 | static struct type * | |
2260 | hpread_read_subrange_type (hp_type, dn_bufp, objfile) | |
2261 | dnttpointer hp_type; | |
2262 | union dnttentry *dn_bufp; | |
2263 | struct objfile *objfile; | |
2264 | { | |
2265 | struct type *type; | |
2266 | ||
2267 | /* Is it something we've already dealt with. */ | |
2268 | type = hpread_alloc_type (hp_type, objfile); | |
2269 | if (TYPE_CODE (type) == TYPE_CODE_RANGE) | |
2270 | return type; | |
2271 | ||
2272 | /* Nope, internalize it. */ | |
2273 | TYPE_CODE (type) = TYPE_CODE_RANGE; | |
2274 | TYPE_LENGTH (type) = dn_bufp->dsubr.bitlength / 8; | |
2275 | TYPE_NFIELDS (type) = 2; | |
2276 | TYPE_FIELDS (type) | |
2277 | = (struct field *) obstack_alloc (&objfile->type_obstack, | |
2278 | 2 * sizeof (struct field)); | |
2279 | ||
2280 | if (dn_bufp->dsubr.dyn_low) | |
2281 | TYPE_FIELD_BITPOS (type, 0) = 0; | |
2282 | else | |
2283 | TYPE_FIELD_BITPOS (type, 0) = dn_bufp->dsubr.lowbound; | |
2284 | ||
2285 | if (dn_bufp->dsubr.dyn_high) | |
2286 | TYPE_FIELD_BITPOS (type, 1) = -1; | |
2287 | else | |
2288 | TYPE_FIELD_BITPOS (type, 1) = dn_bufp->dsubr.highbound; | |
2289 | TYPE_TARGET_TYPE (type) = hpread_type_lookup (dn_bufp->dsubr.subtype, | |
2290 | objfile); | |
2291 | return type; | |
2292 | } | |
2293 | ||
2294 | /* struct type * hpread_type_lookup(hp_type, objfile) | |
2295 | * Arguments: | |
2296 | * hp_type: A pointer into the DNTT specifying what type we | |
2297 | * are about to "look up"., or else [for fundamental types | |
2298 | * like int, float, ...] an "immediate" structure describing | |
2299 | * the type. | |
2300 | * objfile: ? | |
2301 | * Return value: A pointer to a "struct type" (representation of a | |
2302 | * type in GDB's internal symbol table - see gdbtypes.h) | |
2303 | * Routine description: | |
2304 | * There are a variety of places when scanning the DNTT when we | |
2305 | * need to interpret a "type" field. The simplest and most basic | |
2306 | * example is when we're processing the symbol table record | |
2307 | * for a data symbol (a SVAR or DVAR record). That has | |
2308 | * a "type" field specifying the type of the data symbol. That | |
2309 | * "type" field is either an "immediate" type specification (for the | |
2310 | * fundamental types) or a DNTT pointer (for more complicated types). | |
2311 | * For the more complicated types, we may or may not have already | |
2312 | * processed the pointed-to type. (Multiple data symbols can of course | |
2313 | * share the same type). | |
2314 | * The job of hpread_type_lookup() is to process this "type" field. | |
2315 | * Most of the real work is done in subroutines. Here we interpret | |
2316 | * the immediate flag. If not immediate, chase the DNTT pointer to | |
2317 | * find our way to the SOM record describing the type, switch on | |
2318 | * the SOM kind, and then call an appropriate subroutine depending | |
2319 | * on what kind of type we are constructing. (e.g., an array type, | |
2320 | * a struct/class type, etc). | |
2321 | */ | |
2322 | static struct type * | |
2323 | hpread_type_lookup (hp_type, objfile) | |
2324 | dnttpointer hp_type; | |
2325 | struct objfile *objfile; | |
2326 | { | |
2327 | union dnttentry *dn_bufp; | |
2328 | struct type * tmp_type; | |
2329 | ||
2330 | /* First see if it's a simple builtin type. */ | |
2331 | if (hp_type.dntti.immediate) | |
2332 | /* If this is a template argument, the argument number is | |
2333 | * encoded in the bitlength. All other cases, just return | |
2334 | * GDB's representation of this fundamental type. | |
2335 | */ | |
2336 | if (hp_type.dntti.type == HP_TYPE_TEMPLATE_ARG) | |
2337 | return hpread_get_nth_template_arg(objfile, hp_type.dntti.bitlength); | |
2338 | else | |
2339 | return lookup_fundamental_type (objfile, hpread_type_translate (hp_type)); | |
2340 | ||
2341 | /* Not a builtin type. We'll have to read it in. */ | |
2342 | if (hp_type.dnttp.index < LNTT_SYMCOUNT (objfile)) | |
2343 | dn_bufp = hpread_get_lntt (hp_type.dnttp.index, objfile); | |
2344 | else | |
2345 | /* This is a fancy way of returning NULL */ | |
2346 | return lookup_fundamental_type (objfile, FT_VOID); | |
2347 | ||
2348 | switch (dn_bufp->dblock.kind) | |
2349 | { | |
2350 | case DNTT_TYPE_SRCFILE: | |
2351 | case DNTT_TYPE_MODULE: | |
2352 | case DNTT_TYPE_ENTRY: | |
2353 | case DNTT_TYPE_BEGIN: | |
2354 | case DNTT_TYPE_END: | |
2355 | case DNTT_TYPE_IMPORT: | |
2356 | case DNTT_TYPE_LABEL: | |
2357 | case DNTT_TYPE_FPARAM: | |
2358 | case DNTT_TYPE_SVAR: | |
2359 | case DNTT_TYPE_DVAR: | |
2360 | case DNTT_TYPE_CONST: | |
2361 | case DNTT_TYPE_MEMENUM: | |
2362 | case DNTT_TYPE_VARIANT: | |
2363 | case DNTT_TYPE_FILE: | |
2364 | case DNTT_TYPE_WITH: | |
2365 | case DNTT_TYPE_COMMON: | |
2366 | case DNTT_TYPE_COBSTRUCT: | |
2367 | case DNTT_TYPE_XREF: | |
2368 | case DNTT_TYPE_SA: | |
2369 | case DNTT_TYPE_MACRO: | |
2370 | case DNTT_TYPE_BLOCKDATA: | |
2371 | case DNTT_TYPE_CLASS_SCOPE: | |
2372 | case DNTT_TYPE_MEMACCESS: | |
2373 | case DNTT_TYPE_INHERITANCE: | |
2374 | case DNTT_TYPE_OBJECT_ID: | |
2375 | case DNTT_TYPE_FRIEND_CLASS: | |
2376 | case DNTT_TYPE_FRIEND_FUNC: | |
2377 | /* These are not types - something went wrong. */ | |
2378 | /* This is a fancy way of returning NULL */ | |
2379 | return lookup_fundamental_type (objfile, FT_VOID); | |
2380 | ||
2381 | case DNTT_TYPE_FUNCTION: | |
2382 | /* We wind up here when dealing with class member functions | |
2383 | * (called from hpread_read_struct_type(), i.e. when processing | |
2384 | * the class definition itself). | |
2385 | */ | |
2386 | return hpread_read_function_type (hp_type, dn_bufp, objfile, 0); | |
2387 | ||
2388 | case DNTT_TYPE_DOC_FUNCTION: | |
2389 | return hpread_read_doc_function_type (hp_type, dn_bufp, objfile, 0); | |
2390 | ||
2391 | case DNTT_TYPE_TYPEDEF: | |
2392 | { | |
2393 | /* A typedef - chase it down by making a recursive call */ | |
2394 | struct type *structtype = hpread_type_lookup (dn_bufp->dtype.type, | |
2395 | objfile); | |
2396 | ||
2397 | /* The following came from the base hpread.c that we inherited. | |
2398 | * It is WRONG so I have commented it out. - RT | |
2399 | *... | |
2400 | ||
2401 | char *suffix; | |
2402 | suffix = VT (objfile) + dn_bufp->dtype.name; | |
2403 | TYPE_NAME (structtype) = suffix; | |
2404 | ||
2405 | * ... further explanation .... | |
2406 | * | |
2407 | * What we have here is a typedef pointing to a typedef. | |
2408 | * E.g., | |
2409 | * typedef int foo; | |
2410 | * typedef foo fum; | |
2411 | * | |
2412 | * What we desire to build is (these are pictures | |
2413 | * of "struct type"'s): | |
2414 | * | |
2415 | * +---------+ +----------+ +------------+ | |
2416 | * | typedef | | typedef | | fund. type | | |
2417 | * | type| -> | type| -> | | | |
2418 | * | "fum" | | "foo" | | "int" | | |
2419 | * +---------+ +----------+ +------------+ | |
2420 | * | |
2421 | * What this commented-out code is doing is smashing the | |
2422 | * name of pointed-to-type to be the same as the pointed-from | |
2423 | * type. So we wind up with something like: | |
2424 | * | |
2425 | * +---------+ +----------+ +------------+ | |
2426 | * | typedef | | typedef | | fund. type | | |
2427 | * | type| -> | type| -> | | | |
2428 | * | "fum" | | "fum" | | "fum" | | |
2429 | * +---------+ +----------+ +------------+ | |
2430 | * | |
2431 | */ | |
2432 | ||
2433 | return structtype; | |
2434 | } | |
2435 | ||
2436 | case DNTT_TYPE_TAGDEF: | |
2437 | { | |
2438 | /* Just a little different from above. We have to tack on | |
2439 | * an identifier of some kind (struct, union, enum, class, etc). | |
2440 | */ | |
2441 | struct type *structtype = hpread_type_lookup (dn_bufp->dtype.type, | |
2442 | objfile); | |
2443 | char *prefix, *suffix; | |
2444 | suffix = VT (objfile) + dn_bufp->dtype.name; | |
2445 | ||
2446 | /* Lookup the next type in the list. It should be a structure, | |
2447 | * union, class, enum, or template type. | |
2448 | * We will need to attach that to our name. | |
2449 | */ | |
2450 | if (dn_bufp->dtype.type.dnttp.index < LNTT_SYMCOUNT (objfile)) | |
2451 | dn_bufp = hpread_get_lntt (dn_bufp->dtype.type.dnttp.index, objfile); | |
2452 | else { | |
2453 | complain (&hpread_type_lookup_complaint); | |
2454 | return; | |
2455 | } | |
2456 | ||
2457 | if (dn_bufp->dblock.kind == DNTT_TYPE_STRUCT) { | |
2458 | prefix = "struct "; | |
2459 | } else if (dn_bufp->dblock.kind == DNTT_TYPE_UNION) { | |
2460 | prefix = "union "; | |
2461 | } else if (dn_bufp->dblock.kind == DNTT_TYPE_CLASS) { | |
2462 | /* Further field for CLASS saying how it was really declared */ | |
2463 | /* 0==class, 1==union, 2==struct */ | |
2464 | if (dn_bufp->dclass.class_decl == 0) | |
2465 | prefix = "class "; | |
2466 | else if (dn_bufp->dclass.class_decl == 1) | |
2467 | prefix = "union "; | |
2468 | else if (dn_bufp->dclass.class_decl == 2) | |
2469 | prefix = "struct "; | |
2470 | else | |
2471 | prefix = ""; | |
2472 | } else if (dn_bufp->dblock.kind == DNTT_TYPE_ENUM) { | |
2473 | prefix = "enum "; | |
2474 | } else if (dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE) { | |
2475 | prefix = "template "; | |
2476 | } else { | |
2477 | prefix = ""; | |
2478 | } | |
2479 | ||
2480 | /* Build the correct name. */ | |
2481 | structtype->name | |
2482 | = (char *) obstack_alloc (&objfile->type_obstack, | |
2483 | strlen (prefix) + strlen (suffix) + 1); | |
2484 | TYPE_NAME (structtype) = strcpy (TYPE_NAME (structtype), prefix); | |
2485 | TYPE_NAME (structtype) = strcat (TYPE_NAME (structtype), suffix); | |
2486 | TYPE_TAG_NAME (structtype) = suffix; | |
2487 | ||
2488 | /* For classes/structs, we have to set the static member "physnames" | |
2489 | to point to strings like "Class::Member" */ | |
2490 | if (TYPE_CODE (structtype) == TYPE_CODE_STRUCT) | |
2491 | fix_static_member_physnames (structtype, suffix, objfile); | |
2492 | ||
2493 | return structtype; | |
2494 | } | |
2495 | ||
2496 | case DNTT_TYPE_POINTER: | |
2497 | /* Pointer type - call a routine in gdbtypes.c that constructs | |
2498 | * the appropriate GDB type. | |
2499 | */ | |
2500 | return make_pointer_type ( | |
2501 | hpread_type_lookup (dn_bufp->dptr.pointsto, | |
2502 | objfile), | |
2503 | NULL); | |
2504 | ||
2505 | case DNTT_TYPE_REFERENCE: | |
2506 | /* C++ reference type - call a routine in gdbtypes.c that constructs | |
2507 | * the appropriate GDB type. | |
2508 | */ | |
2509 | return make_reference_type ( | |
2510 | hpread_type_lookup (dn_bufp->dreference.pointsto, | |
2511 | objfile), | |
2512 | NULL); | |
2513 | ||
2514 | case DNTT_TYPE_ENUM: | |
2515 | return hpread_read_enum_type (hp_type, dn_bufp, objfile); | |
2516 | case DNTT_TYPE_SET: | |
2517 | return hpread_read_set_type (hp_type, dn_bufp, objfile); | |
2518 | case DNTT_TYPE_SUBRANGE: | |
2519 | return hpread_read_subrange_type (hp_type, dn_bufp, objfile); | |
2520 | case DNTT_TYPE_ARRAY: | |
2521 | return hpread_read_array_type (hp_type, dn_bufp, objfile); | |
2522 | case DNTT_TYPE_STRUCT: | |
2523 | case DNTT_TYPE_UNION: | |
2524 | return hpread_read_struct_type (hp_type, dn_bufp, objfile); | |
2525 | case DNTT_TYPE_FIELD: | |
2526 | return hpread_type_lookup (dn_bufp->dfield.type, objfile); | |
2527 | ||
2528 | case DNTT_TYPE_FUNCTYPE: | |
2529 | /* Here we want to read the function SOMs and return a | |
2530 | * type for it. We get here, for instance, when processing | |
2531 | * pointer-to-function type. | |
2532 | */ | |
2533 | return hpread_read_function_type (hp_type, dn_bufp, objfile, 0); | |
2534 | ||
2535 | case DNTT_TYPE_PTRMEM: | |
2536 | /* Declares a C++ pointer-to-data-member type. | |
2537 | * The "pointsto" field defines the class, | |
2538 | * while the "memtype" field defines the pointed-to-type. | |
2539 | */ | |
2540 | { | |
2541 | struct type * ptrmemtype; | |
2542 | struct type * class_type; | |
2543 | struct type * memtype; | |
2544 | memtype = hpread_type_lookup (dn_bufp->dptrmem.memtype, | |
2545 | objfile), | |
2546 | class_type = hpread_type_lookup (dn_bufp->dptrmem.pointsto, | |
2547 | objfile), | |
2548 | ptrmemtype = alloc_type(objfile); | |
2549 | smash_to_member_type(ptrmemtype, class_type, memtype); | |
2550 | return make_pointer_type(ptrmemtype, NULL); | |
2551 | } | |
2552 | break; | |
2553 | ||
2554 | case DNTT_TYPE_PTRMEMFUNC: | |
2555 | /* Defines a C++ pointer-to-function-member type. | |
2556 | * The "pointsto" field defines the class, | |
2557 | * while the "memtype" field defines the pointed-to-type. | |
2558 | */ | |
2559 | { | |
2560 | struct type * ptrmemtype; | |
2561 | struct type * class_type; | |
2562 | struct type * functype; | |
2563 | struct type * retvaltype; | |
2564 | int nargs; | |
2565 | int i; | |
2566 | struct type ** args_type; | |
2567 | class_type = hpread_type_lookup (dn_bufp->dptrmem.pointsto, | |
2568 | objfile); | |
2569 | functype = hpread_type_lookup (dn_bufp->dptrmem.memtype, | |
2570 | objfile); | |
2571 | retvaltype = TYPE_TARGET_TYPE (functype); | |
2572 | nargs = TYPE_NFIELDS (functype); | |
2573 | args_type = (struct type **) xmalloc ((nargs+1) * sizeof (struct type *)); | |
2574 | for (i = 0; i < nargs; i++) { | |
2575 | args_type[i] = TYPE_FIELD_TYPE (functype, i); | |
2576 | } | |
2577 | args_type[nargs] = NULL; | |
2578 | ptrmemtype = alloc_type(objfile); | |
2579 | smash_to_method_type(ptrmemtype, class_type, retvaltype, args_type); | |
2580 | return make_pointer_type(ptrmemtype, NULL); | |
2581 | } | |
2582 | break; | |
2583 | ||
2584 | case DNTT_TYPE_CLASS: | |
2585 | return hpread_read_struct_type (hp_type, dn_bufp, objfile); | |
2586 | ||
2587 | case DNTT_TYPE_GENFIELD: | |
2588 | /* Chase pointer from GENFIELD to FIELD, and make recursive | |
2589 | * call on that. | |
2590 | */ | |
2591 | return hpread_type_lookup (dn_bufp->dgenfield.field, objfile); | |
2592 | ||
2593 | case DNTT_TYPE_VFUNC: | |
2594 | /* C++ virtual function. | |
2595 | * We get here in the course of processing a class type which | |
2596 | * contains virtual functions. Just go through another level | |
2597 | * of indirection to get to the pointed-to function SOM. | |
2598 | */ | |
2599 | return hpread_type_lookup (dn_bufp->dvfunc.funcptr, objfile); | |
2600 | ||
2601 | case DNTT_TYPE_MODIFIER: | |
2602 | /* Check the modifiers and then just make a recursive call on | |
2603 | * the "type" pointed to by the modifier DNTT. | |
2604 | * | |
2605 | * pai:: FIXME -- do we ever want to handle "m_duplicate" and | |
2606 | * "m_void" modifiers? Is static_flag really needed here? | |
2607 | * (m_static used for methods of classes, elsewhere). | |
2608 | */ | |
2609 | tmp_type = make_cv_type (dn_bufp->dmodifier.m_const, | |
2610 | dn_bufp->dmodifier.m_volatile, | |
2611 | hpread_type_lookup (dn_bufp->dmodifier.type, objfile), | |
2612 | 0); | |
2613 | return tmp_type; | |
2614 | ||
2615 | ||
2616 | case DNTT_TYPE_MEMFUNC: | |
2617 | /* Member function. Treat like a function. | |
2618 | * I think we get here in the course of processing a | |
2619 | * pointer-to-member-function type... | |
2620 | */ | |
2621 | return hpread_read_function_type (hp_type, dn_bufp, objfile, 0); | |
2622 | ||
2623 | case DNTT_TYPE_DOC_MEMFUNC: | |
2624 | return hpread_read_doc_function_type (hp_type, dn_bufp, objfile, 0); | |
2625 | ||
2626 | case DNTT_TYPE_TEMPLATE: | |
2627 | /* Template - sort of the header for a template definition, | |
2628 | * which like a class, points to a member list and also points | |
2629 | * to a TEMPLATE_ARG list of type-arguments. | |
2630 | */ | |
2631 | return hpread_read_struct_type (hp_type, dn_bufp, objfile); | |
2632 | ||
2633 | case DNTT_TYPE_TEMPLATE_ARG: | |
2634 | { | |
2635 | char * name; | |
2636 | /* The TEMPLATE record points to an argument list of | |
2637 | * TEMPLATE_ARG records, each of which describes one | |
2638 | * of the type-arguments. | |
2639 | */ | |
2640 | name = VT (objfile) + dn_bufp->dtempl_arg.name; | |
2641 | return hpread_read_templ_arg_type (hp_type, dn_bufp, objfile, name); | |
2642 | } | |
2643 | ||
2644 | case DNTT_TYPE_FUNC_TEMPLATE: | |
2645 | /* We wind up here when processing a TEMPLATE type, | |
2646 | * if the template has member function(s). | |
2647 | * Treat it like a FUNCTION. | |
2648 | */ | |
2649 | return hpread_read_function_type (hp_type, dn_bufp, objfile, 0); | |
2650 | ||
2651 | case DNTT_TYPE_LINK: | |
2652 | /* The LINK record is used to link up templates with instantiations. | |
2653 | * There is no type associated with the LINK record per se. | |
2654 | */ | |
2655 | return lookup_fundamental_type (objfile, FT_VOID); | |
2656 | ||
2657 | /* Also not yet handled... */ | |
2658 | /* case DNTT_TYPE_DYN_ARRAY_DESC: */ | |
2659 | /* case DNTT_TYPE_DESC_SUBRANGE: */ | |
2660 | /* case DNTT_TYPE_BEGIN_EXT: */ | |
2661 | /* case DNTT_TYPE_INLN: */ | |
2662 | /* case DNTT_TYPE_INLN_LIST: */ | |
2663 | /* case DNTT_TYPE_ALIAS: */ | |
2664 | default: | |
2665 | /* A fancy way of returning NULL */ | |
2666 | return lookup_fundamental_type (objfile, FT_VOID); | |
2667 | } | |
2668 | } | |
2669 | ||
2670 | static sltpointer | |
2671 | hpread_record_lines (subfile, s_idx, e_idx, objfile, offset) | |
2672 | struct subfile *subfile; | |
2673 | sltpointer s_idx, e_idx; | |
2674 | struct objfile *objfile; | |
2675 | CORE_ADDR offset; | |
2676 | { | |
2677 | union sltentry *sl_bufp; | |
2678 | ||
2679 | while (s_idx <= e_idx) | |
2680 | { | |
2681 | sl_bufp = hpread_get_slt (s_idx, objfile); | |
2682 | /* Only record "normal" entries in the SLT. */ | |
2683 | if (sl_bufp->snorm.sltdesc == SLT_NORMAL | |
2684 | || sl_bufp->snorm.sltdesc == SLT_EXIT) | |
2685 | record_line (subfile, sl_bufp->snorm.line, | |
2686 | sl_bufp->snorm.address + offset); | |
2687 | else if (sl_bufp->snorm.sltdesc == SLT_NORMAL_OFFSET) | |
2688 | record_line (subfile, sl_bufp->snormoff.line, | |
2689 | sl_bufp->snormoff.address + offset); | |
2690 | s_idx++; | |
2691 | } | |
2692 | return e_idx; | |
2693 | } | |
2694 | ||
2695 | /* Given a function "f" which is a member of a class, find | |
2696 | * the classname that it is a member of. Used to construct | |
2697 | * the name (e.g., "c::f") which GDB will put in the | |
2698 | * "demangled name" field of the function's symbol. | |
2699 | * Called from hpread_process_one_debug_symbol() | |
2700 | * If "f" is not a member function, return NULL. | |
2701 | */ | |
2702 | char * class_of (functype) | |
2703 | struct type * functype; | |
2704 | { | |
2705 | struct type * first_param_type; | |
2706 | char * first_param_name; | |
2707 | struct type * pointed_to_type; | |
2708 | char * class_name; | |
2709 | ||
2710 | /* Check that the function has a first argument "this", | |
2711 | * and that "this" is a pointer to a class. If not, | |
2712 | * functype is not a member function, so return NULL. | |
2713 | */ | |
2714 | if (TYPE_NFIELDS(functype) == 0) | |
2715 | return NULL; | |
2716 | first_param_name = TYPE_FIELD_NAME (functype, 0); | |
2717 | if (first_param_name == NULL) | |
2718 | return NULL; /* paranoia */ | |
2719 | if (strcmp(first_param_name, "this")) | |
2720 | return NULL; | |
2721 | first_param_type = TYPE_FIELD_TYPE (functype, 0); | |
2722 | if (first_param_type == NULL) | |
2723 | return NULL; /* paranoia */ | |
2724 | if (TYPE_CODE(first_param_type) != TYPE_CODE_PTR) | |
2725 | return NULL; | |
2726 | ||
2727 | /* Get the thing that "this" points to, check that | |
2728 | * it's a class, and get its class name. | |
2729 | */ | |
2730 | pointed_to_type = TYPE_TARGET_TYPE(first_param_type); | |
2731 | if (pointed_to_type == NULL) | |
2732 | return NULL; /* paranoia */ | |
2733 | if (TYPE_CODE(pointed_to_type) != TYPE_CODE_CLASS) | |
2734 | return NULL; | |
2735 | class_name = TYPE_NAME(pointed_to_type); | |
2736 | if (class_name == NULL) | |
2737 | return NULL; /* paranoia */ | |
2738 | ||
2739 | /* The class name may be of the form "class c", in which case | |
2740 | * we want to strip off the leading "class ". | |
2741 | */ | |
2742 | if (strncmp(class_name, "class ", 6) == 0) | |
2743 | class_name += 6; | |
2744 | ||
2745 | return class_name; | |
2746 | } | |
2747 | ||
2748 | /* Internalize one native debug symbol. | |
2749 | * Called in a loop from hpread_expand_symtab(). | |
2750 | * Arguments: | |
2751 | * dn_bufp: | |
2752 | * name: | |
2753 | * section_offsets: | |
2754 | * objfile: | |
2755 | * text_offset: | |
2756 | * text_size: | |
2757 | * filename: | |
2758 | * index: Index of this symbol | |
2759 | * at_module_boundary_p Pointer to boolean flag to control caller's loop. | |
2760 | */ | |
2761 | ||
2762 | static void | |
2763 | hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, | |
2764 | text_offset, text_size, filename, | |
2765 | index, at_module_boundary_p | |
2766 | ) | |
2767 | union dnttentry *dn_bufp; | |
2768 | char *name; | |
2769 | struct section_offsets *section_offsets; | |
2770 | struct objfile *objfile; | |
2771 | CORE_ADDR text_offset; | |
2772 | int text_size; | |
2773 | char *filename; | |
2774 | int index; | |
2775 | int *at_module_boundary_p; | |
2776 | { | |
2777 | unsigned long desc; | |
2778 | int type; | |
2779 | CORE_ADDR valu; | |
2780 | int offset = ANOFFSET (section_offsets, SECT_OFF_TEXT); | |
2781 | int data_offset = ANOFFSET (section_offsets, SECT_OFF_DATA); | |
2782 | union dnttentry *dn_temp; | |
2783 | dnttpointer hp_type; | |
2784 | struct symbol *sym; | |
2785 | struct context_stack *new; | |
2786 | char * class_scope_name; | |
2787 | extern int is_in_import_list (); /* in somread.c */ | |
2788 | ||
2789 | /* Allocate one GDB debug symbol and fill in some default values. */ | |
2790 | sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack, | |
2791 | sizeof (struct symbol)); | |
2792 | memset (sym, 0, sizeof (struct symbol)); | |
2793 | SYMBOL_NAME (sym) = obsavestring (name, strlen (name), &objfile->symbol_obstack); | |
2794 | SYMBOL_LANGUAGE (sym) = language_auto; | |
2795 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
2796 | SYMBOL_LINE (sym) = 0; | |
2797 | SYMBOL_VALUE (sym) = 0; | |
2798 | SYMBOL_CLASS (sym) = LOC_TYPEDEF; | |
2799 | ||
2800 | /* Just a trick in case the SOM debug symbol is a type definition. | |
2801 | * There are routines that are set up to build a GDB type symbol, given | |
2802 | * a SOM dnttpointer. So we set up a dummy SOM dnttpointer "hp_type". | |
2803 | * This allows us to call those same routines. | |
2804 | */ | |
2805 | hp_type.dnttp.extension = 1; | |
2806 | hp_type.dnttp.immediate = 0; | |
2807 | hp_type.dnttp.global = 0; | |
2808 | hp_type.dnttp.index = index; | |
2809 | ||
2810 | /* This "type" is the type of SOM record. | |
2811 | * Switch on SOM type. | |
2812 | */ | |
2813 | type = dn_bufp->dblock.kind; | |
2814 | switch (type) | |
2815 | { | |
2816 | case DNTT_TYPE_SRCFILE: | |
2817 | /* This type of symbol indicates from which source file or | |
2818 | * include file any following data comes. It may indicate: | |
2819 | * | |
2820 | * o The start of an entirely new source file (and thus | |
2821 | * a new module) | |
2822 | * | |
2823 | * o The start of a different source file due to #include | |
2824 | * | |
2825 | * o The end of an include file and the return to the original | |
2826 | * file. Thus if "foo.c" includes "bar.h", we see first | |
2827 | * a SRCFILE for foo.c, then one for bar.h, and then one for | |
2828 | * foo.c again. | |
2829 | * | |
2830 | * If it indicates the start of a new module then we must | |
2831 | * finish the symbol table of the previous module | |
2832 | * (if any) and start accumulating a new symbol table. | |
2833 | */ | |
2834 | ||
2835 | valu = text_offset; | |
2836 | if (!last_source_file ) { | |
2837 | /* | |
2838 | * A note on "last_source_file": this is a char* pointing | |
2839 | * to the actual file name. "start_symtab" sets it, | |
2840 | * "end_symtab" clears it. | |
2841 | * | |
2842 | * So if "last_source_file" is NULL, then either this is | |
2843 | * the first record we are looking at, or a previous call | |
2844 | * to "end_symtab()" was made to close out the previous | |
2845 | * module. Since we're now quitting the scan loop when we | |
2846 | * see a MODULE END record, we should never get here, except | |
2847 | * in the case that we're not using the quick look-up tables | |
2848 | * and have to use the old system as a fall-back. | |
2849 | */ | |
2850 | start_symtab (name, NULL, valu); | |
2851 | record_debugformat ("HP"); | |
2852 | SL_INDEX (objfile) = dn_bufp->dsfile.address; | |
2853 | } | |
2854 | ||
2855 | else { | |
2856 | /* Either a new include file, or a SRCFILE record | |
2857 | * saying we are back in the main source (or out of | |
2858 | * a nested include file) again. | |
2859 | */ | |
2860 | SL_INDEX (objfile) = hpread_record_lines (current_subfile, | |
2861 | SL_INDEX (objfile), | |
2862 | dn_bufp->dsfile.address, | |
2863 | objfile, offset); | |
2864 | } | |
2865 | ||
2866 | /* A note on "start_subfile". This routine will check | |
2867 | * the name we pass it and look for an existing subfile | |
2868 | * of that name. There's thus only one sub-file for the | |
2869 | * actual source (e.g. for "foo.c" in foo.c), despite the | |
2870 | * fact that we'll see lots of SRCFILE entries for foo.c | |
2871 | * inside foo.c. | |
2872 | */ | |
2873 | start_subfile (name, NULL); | |
2874 | break; | |
2875 | ||
2876 | case DNTT_TYPE_MODULE: | |
2877 | /* | |
2878 | * We no longer ignore DNTT_TYPE_MODULE symbols. The module | |
2879 | * represents the meaningful semantic structure of a compilation | |
2880 | * unit. We expect to start the psymtab-to-symtab expansion | |
2881 | * looking at a MODULE entry, and to end it at the corresponding | |
2882 | * END MODULE entry. | |
2883 | * | |
2884 | *--Begin outdated comments | |
2885 | * | |
2886 | * This record signifies the start of a new source module | |
2887 | * In C/C++ there is no explicit "module" construct in the language, | |
2888 | * but each compilation unit is implicitly a module and they | |
2889 | * do emit the DNTT_TYPE_MODULE records. | |
2890 | * The end of the module is marked by a matching DNTT_TYPE_END record. | |
2891 | * | |
2892 | * The reason GDB gets away with ignoring the DNTT_TYPE_MODULE record | |
2893 | * is it notices the DNTT_TYPE_END record for the previous | |
2894 | * module (see comments under DNTT_TYPE_END case), and then treats | |
2895 | * the next DNTT_TYPE_SRCFILE record as if it were the module-start record. | |
2896 | * (i.e., it makes a start_symtab() call). | |
2897 | * This scheme seems a little convoluted, but I'll leave it | |
2898 | * alone on the principle "if it ain't broke don't fix | |
2899 | * it". (RT). | |
2900 | * | |
2901 | *-- End outdated comments | |
2902 | */ | |
2903 | ||
2904 | valu = text_offset; | |
2905 | if (!last_source_file ) | |
2906 | { | |
2907 | /* Start of a new module. We know this because "last_source_file" | |
2908 | * is NULL, which can only happen the first time or if we just | |
2909 | * made a call to end_symtab() to close out the previous module. | |
2910 | */ | |
2911 | start_symtab (name, NULL, valu); | |
2912 | SL_INDEX (objfile) = dn_bufp->dmodule.address; | |
2913 | } | |
2914 | else | |
2915 | { | |
2916 | /* This really shouldn't happen if we're using the quick | |
2917 | * look-up tables, as it would mean we'd scanned past an | |
2918 | * END MODULE entry. But if we're not using the tables, | |
2919 | * we started the module on the SRCFILE entry, so it's ok. | |
2920 | * For now, accept this. | |
2921 | */ | |
2922 | /* warning( "Error expanding psymtab, missed module end, found entry for %s", | |
2923 | * name ); | |
2924 | */ | |
2925 | *at_module_boundary_p = -1; | |
2926 | } | |
2927 | ||
2928 | start_subfile (name, NULL); | |
2929 | break; | |
2930 | ||
2931 | case DNTT_TYPE_FUNCTION: | |
2932 | case DNTT_TYPE_ENTRY: | |
2933 | /* A function or secondary entry point. */ | |
2934 | valu = dn_bufp->dfunc.lowaddr + offset; | |
2935 | ||
2936 | /* Record lines up to this point. */ | |
2937 | SL_INDEX (objfile) = hpread_record_lines (current_subfile, | |
2938 | SL_INDEX (objfile), | |
2939 | dn_bufp->dfunc.address, | |
2940 | objfile, offset); | |
2941 | ||
2942 | WITHIN_FUNCTION (objfile) = 1; | |
2943 | CURRENT_FUNCTION_VALUE (objfile) = valu; | |
2944 | ||
2945 | /* Stack must be empty now. */ | |
2946 | if (context_stack_depth != 0) | |
2947 | complain (&lbrac_unmatched_complaint, (char *) symnum); | |
2948 | new = push_context (0, valu); | |
2949 | ||
2950 | /* Built a type for the function. This includes processing | |
2951 | * the symbol records for the function parameters. | |
2952 | */ | |
2953 | SYMBOL_CLASS (sym) = LOC_BLOCK; | |
2954 | SYMBOL_TYPE (sym) = hpread_read_function_type (hp_type, dn_bufp, objfile, 1); | |
2955 | ||
2956 | /* The "SYMBOL_NAME" field is expected to be the mangled name | |
2957 | * (if any), which we get from the "alias" field of the SOM record | |
2958 | * if that exists. | |
2959 | */ | |
2960 | if ((dn_bufp->dfunc.language == HP_LANGUAGE_CPLUSPLUS) && | |
2961 | dn_bufp->dfunc.alias && /* has an alias */ | |
2962 | *(char *)(VT (objfile) + dn_bufp->dfunc.alias)) /* not a null string */ | |
2963 | SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->dfunc.alias; | |
2964 | else | |
2965 | SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->dfunc.name; | |
2966 | ||
2967 | /* Special hack to get around HP compilers' insistence on | |
2968 | * reporting "main" as "_MAIN_" for C/C++ */ | |
2969 | if ((strcmp (SYMBOL_NAME (sym), "_MAIN_") == 0) && | |
2970 | (strcmp (VT (objfile) + dn_bufp->dfunc.name, "main") == 0)) | |
2971 | SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->dfunc.name; | |
2972 | ||
2973 | /* The SYMBOL_CPLUS_DEMANGLED_NAME field is expected to | |
2974 | * be the demangled name. | |
2975 | */ | |
2976 | if (dn_bufp->dfunc.language == HP_LANGUAGE_CPLUSPLUS) | |
2977 | { | |
2978 | /* SYMBOL_INIT_DEMANGLED_NAME is a macro which winds up | |
2979 | * calling the demangler in libiberty (cplus_demangle()) to | |
2980 | * do the job. This generally does the job, even though | |
2981 | * it's intended for the GNU compiler and not the aCC compiler | |
2982 | * Note that SYMBOL_INIT_DEMANGLED_NAME calls the | |
2983 | * demangler with arguments DMGL_PARAMS | DMGL_ANSI. | |
2984 | * Generally, we don't want params when we display | |
2985 | * a demangled name, but when I took out the DMGL_PARAMS, | |
2986 | * some things broke, so I'm leaving it in here, and | |
2987 | * working around the issue in stack.c. - RT | |
2988 | */ | |
2989 | SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack); | |
2990 | if ((SYMBOL_NAME (sym) == VT (objfile) + dn_bufp->dfunc.alias) && | |
2991 | (!SYMBOL_CPLUS_DEMANGLED_NAME(sym))) { | |
2992 | ||
2993 | /* Well, the symbol name is mangled, but the | |
2994 | * demangler in libiberty failed so the demangled | |
2995 | * field is still NULL. Try to | |
2996 | * do the job ourselves based on the "name" field | |
2997 | * in the SOM record. A complication here is that | |
2998 | * the name field contains only the function name | |
2999 | * (like "f"), whereas we want the class qualification | |
3000 | * (as in "c::f"). Try to reconstruct that. | |
3001 | */ | |
3002 | char * basename; | |
3003 | char * classname; | |
3004 | char * dem_name; | |
3005 | basename = VT (objfile) + dn_bufp->dfunc.name; | |
3006 | classname = class_of(SYMBOL_TYPE(sym)); | |
3007 | if (classname) { | |
3008 | dem_name = xmalloc(strlen(basename)+strlen(classname)+3); | |
3009 | strcpy(dem_name, classname); | |
3010 | strcat(dem_name, "::"); | |
3011 | strcat(dem_name, basename); | |
3012 | SYMBOL_CPLUS_DEMANGLED_NAME(sym) = dem_name; | |
3013 | SYMBOL_LANGUAGE (sym) = language_cplus; | |
3014 | } | |
3015 | } | |
3016 | } | |
3017 | ||
3018 | /* Add the function symbol to the list of symbols in this blockvector */ | |
3019 | if (dn_bufp->dfunc.global) | |
3020 | add_symbol_to_list (sym, &global_symbols); | |
3021 | else | |
3022 | add_symbol_to_list (sym, &file_symbols); | |
3023 | new->name = sym; | |
3024 | ||
3025 | /* Search forward to the next BEGIN and also read | |
3026 | * in the line info up to that point. | |
3027 | * Not sure why this is needed. | |
3028 | * In HP FORTRAN this code is harmful since there | |
3029 | * may not be a BEGIN after the FUNCTION. | |
3030 | * So I made it C/C++ specific. - RT | |
3031 | */ | |
3032 | if (dn_bufp->dfunc.language == HP_LANGUAGE_C || | |
3033 | dn_bufp->dfunc.language == HP_LANGUAGE_CPLUSPLUS) { | |
3034 | while (dn_bufp->dblock.kind != DNTT_TYPE_BEGIN) | |
3035 | { | |
3036 | dn_bufp = hpread_get_lntt (++index, objfile); | |
3037 | if (dn_bufp->dblock.extension) | |
3038 | continue; | |
3039 | } | |
3040 | SL_INDEX (objfile) = hpread_record_lines (current_subfile, | |
3041 | SL_INDEX (objfile), | |
3042 | dn_bufp->dbegin.address, | |
3043 | objfile, offset); | |
3044 | SYMBOL_LINE (sym) = hpread_get_line (dn_bufp->dbegin.address, objfile); | |
3045 | } | |
3046 | record_line (current_subfile, SYMBOL_LINE (sym), valu); | |
3047 | break; | |
3048 | ||
3049 | case DNTT_TYPE_DOC_FUNCTION: | |
3050 | valu = dn_bufp->ddocfunc.lowaddr + offset; | |
3051 | ||
3052 | /* Record lines up to this point. */ | |
3053 | SL_INDEX (objfile) = hpread_record_lines (current_subfile, | |
3054 | SL_INDEX (objfile), | |
3055 | dn_bufp->ddocfunc.address, | |
3056 | objfile, offset); | |
3057 | ||
3058 | WITHIN_FUNCTION (objfile) = 1; | |
3059 | CURRENT_FUNCTION_VALUE (objfile) = valu; | |
3060 | /* Stack must be empty now. */ | |
3061 | if (context_stack_depth != 0) | |
3062 | complain (&lbrac_unmatched_complaint, (char *) symnum); | |
3063 | new = push_context (0, valu); | |
3064 | ||
3065 | /* Built a type for the function. This includes processing | |
3066 | * the symbol records for the function parameters. | |
3067 | */ | |
3068 | SYMBOL_CLASS (sym) = LOC_BLOCK; | |
3069 | SYMBOL_TYPE (sym) = hpread_read_doc_function_type (hp_type, dn_bufp, objfile, 1); | |
3070 | ||
3071 | /* The "SYMBOL_NAME" field is expected to be the mangled name | |
3072 | * (if any), which we get from the "alias" field of the SOM record | |
3073 | * if that exists. | |
3074 | */ | |
3075 | if ((dn_bufp->ddocfunc.language == HP_LANGUAGE_CPLUSPLUS) && | |
3076 | dn_bufp->ddocfunc.alias && /* has an alias */ | |
3077 | *(char *)(VT (objfile) + dn_bufp->ddocfunc.alias)) /* not a null string */ | |
3078 | SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->ddocfunc.alias; | |
3079 | else | |
3080 | SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->ddocfunc.name; | |
3081 | ||
3082 | /* Special hack to get around HP compilers' insistence on | |
3083 | * reporting "main" as "_MAIN_" for C/C++ */ | |
3084 | if ((strcmp (SYMBOL_NAME (sym), "_MAIN_") == 0) && | |
3085 | (strcmp (VT (objfile) + dn_bufp->ddocfunc.name, "main") == 0)) | |
3086 | SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->ddocfunc.name; | |
3087 | ||
3088 | if (dn_bufp->ddocfunc.language == HP_LANGUAGE_CPLUSPLUS) { | |
3089 | ||
3090 | /* SYMBOL_INIT_DEMANGLED_NAME is a macro which winds up | |
3091 | * calling the demangler in libiberty (cplus_demangle()) to | |
3092 | * do the job. This generally does the job, even though | |
3093 | * it's intended for the GNU compiler and not the aCC compiler | |
3094 | * Note that SYMBOL_INIT_DEMANGLED_NAME calls the | |
3095 | * demangler with arguments DMGL_PARAMS | DMGL_ANSI. | |
3096 | * Generally, we don't want params when we display | |
3097 | * a demangled name, but when I took out the DMGL_PARAMS, | |
3098 | * some things broke, so I'm leaving it in here, and | |
3099 | * working around the issue in stack.c. - RT | |
3100 | */ | |
3101 | SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack); | |
3102 | ||
3103 | if ((SYMBOL_NAME (sym) == VT (objfile) + dn_bufp->ddocfunc.alias) && | |
3104 | (!SYMBOL_CPLUS_DEMANGLED_NAME(sym))) { | |
3105 | ||
3106 | /* Well, the symbol name is mangled, but the | |
3107 | * demangler in libiberty failed so the demangled | |
3108 | * field is still NULL. Try to | |
3109 | * do the job ourselves based on the "name" field | |
3110 | * in the SOM record. A complication here is that | |
3111 | * the name field contains only the function name | |
3112 | * (like "f"), whereas we want the class qualification | |
3113 | * (as in "c::f"). Try to reconstruct that. | |
3114 | */ | |
3115 | char * basename; | |
3116 | char * classname; | |
3117 | char * dem_name; | |
3118 | basename = VT (objfile) + dn_bufp->ddocfunc.name; | |
3119 | classname = class_of(SYMBOL_TYPE(sym)); | |
3120 | if (classname) { | |
3121 | dem_name = xmalloc(strlen(basename)+strlen(classname)+3); | |
3122 | strcpy(dem_name, classname); | |
3123 | strcat(dem_name, "::"); | |
3124 | strcat(dem_name, basename); | |
3125 | SYMBOL_CPLUS_DEMANGLED_NAME(sym) = dem_name; | |
3126 | SYMBOL_LANGUAGE (sym) = language_cplus; | |
3127 | } | |
3128 | } | |
3129 | } | |
3130 | ||
3131 | /* Add the function symbol to the list of symbols in this blockvector */ | |
3132 | if (dn_bufp->ddocfunc.global) | |
3133 | add_symbol_to_list (sym, &global_symbols); | |
3134 | else | |
3135 | add_symbol_to_list (sym, &file_symbols); | |
3136 | new->name = sym; | |
3137 | ||
3138 | /* Search forward to the next BEGIN and also read | |
3139 | * in the line info up to that point. | |
3140 | * Not sure why this is needed. | |
3141 | * In HP FORTRAN this code is harmful since there | |
3142 | * may not be a BEGIN after the FUNCTION. | |
3143 | * So I made it C/C++ specific. - RT | |
3144 | */ | |
3145 | if (dn_bufp->ddocfunc.language == HP_LANGUAGE_C || | |
3146 | dn_bufp->ddocfunc.language == HP_LANGUAGE_CPLUSPLUS) { | |
3147 | while (dn_bufp->dblock.kind != DNTT_TYPE_BEGIN) | |
3148 | { | |
3149 | dn_bufp = hpread_get_lntt (++index, objfile); | |
3150 | if (dn_bufp->dblock.extension) | |
3151 | continue; | |
3152 | } | |
3153 | SL_INDEX (objfile) = hpread_record_lines (current_subfile, | |
3154 | SL_INDEX (objfile), | |
3155 | dn_bufp->dbegin.address, | |
3156 | objfile, offset); | |
3157 | SYMBOL_LINE (sym) = hpread_get_line (dn_bufp->dbegin.address, objfile); | |
3158 | } | |
3159 | record_line (current_subfile, SYMBOL_LINE (sym), valu); | |
3160 | break; | |
3161 | ||
3162 | case DNTT_TYPE_BEGIN: | |
3163 | /* Begin a new scope. */ | |
3164 | if (context_stack_depth == 1 /* this means we're at function level */ && | |
3165 | context_stack[0].name != NULL /* this means it's a function */ && | |
3166 | context_stack[0].depth == 0 /* this means it's the first BEGIN | |
3167 | we've seen after the FUNCTION */ | |
3168 | ) | |
3169 | { | |
3170 | /* This is the first BEGIN after a FUNCTION. | |
3171 | * We ignore this one, since HP compilers always insert | |
3172 | * at least one BEGIN, i.e. it's: | |
3173 | * | |
3174 | * FUNCTION | |
3175 | * argument symbols | |
3176 | * BEGIN | |
3177 | * local symbols | |
3178 | * (possibly nested BEGIN ... END's if there are inner { } blocks) | |
3179 | * END | |
3180 | * END | |
3181 | * | |
3182 | * By ignoring this first BEGIN, the local symbols get treated | |
3183 | * as belonging to the function scope, and "print func::local_sym" | |
3184 | * works (which is what we want). | |
3185 | */ | |
3186 | ||
3187 | /* All we do here is increase the depth count associated with | |
3188 | * the FUNCTION entry in the context stack. This ensures that | |
3189 | * the next BEGIN we see (if any), representing a real nested { } | |
3190 | * block, will get processed. | |
3191 | */ | |
3192 | ||
3193 | context_stack[0].depth++; | |
3194 | ||
3195 | } else { | |
3196 | ||
3197 | /* Record lines up to this SLT pointer. */ | |
3198 | SL_INDEX (objfile) = hpread_record_lines (current_subfile, | |
3199 | SL_INDEX (objfile), | |
3200 | dn_bufp->dbegin.address, | |
3201 | objfile, offset); | |
3202 | /* Calculate start address of new scope */ | |
3203 | valu = hpread_get_location (dn_bufp->dbegin.address, objfile); | |
3204 | valu += offset; /* Relocate for dynamic loading */ | |
3205 | /* We use the scope start DNTT index as nesting depth identifier! */ | |
3206 | desc = hpread_get_scope_start (dn_bufp->dbegin.address, objfile); | |
3207 | new = push_context (desc, valu); | |
3208 | } | |
3209 | break; | |
3210 | ||
3211 | case DNTT_TYPE_END: | |
3212 | /* End a scope. */ | |
3213 | ||
3214 | /* Valid end kinds are: | |
3215 | * MODULE | |
3216 | * FUNCTION | |
3217 | * WITH | |
3218 | * COMMON | |
3219 | * BEGIN | |
3220 | * CLASS_SCOPE | |
3221 | */ | |
3222 | ||
3223 | SL_INDEX (objfile) = hpread_record_lines (current_subfile, | |
3224 | SL_INDEX (objfile), | |
3225 | dn_bufp->dend.address, | |
3226 | objfile, offset); | |
3227 | switch (dn_bufp->dend.endkind) | |
3228 | { | |
3229 | case DNTT_TYPE_MODULE: | |
3230 | /* Ending a module ends the symbol table for that module. | |
3231 | * Calling end_symtab() has the side effect of clearing the | |
3232 | * last_source_file pointer, which in turn signals | |
3233 | * process_one_debug_symbol() to treat the next DNTT_TYPE_SRCFILE | |
3234 | * record as a module-begin. | |
3235 | */ | |
3236 | valu = text_offset + text_size + offset; | |
3237 | ||
3238 | /* Tell our caller that we're done with expanding the | |
3239 | * debug information for a module. | |
3240 | */ | |
3241 | *at_module_boundary_p = 1; | |
3242 | ||
3243 | /* Don't do this, as our caller will do it! | |
3244 | * | |
3245 | * (void) end_symtab (valu, objfile, 0); | |
3246 | */ | |
3247 | break; | |
3248 | ||
3249 | case DNTT_TYPE_FUNCTION: | |
3250 | /* Ending a function, well, ends the function's scope. */ | |
3251 | dn_temp = hpread_get_lntt (dn_bufp->dend.beginscope.dnttp.index, | |
3252 | objfile); | |
3253 | valu = dn_temp->dfunc.hiaddr + offset; | |
3254 | /* Insert func params into local list */ | |
3255 | merge_symbol_lists (¶m_symbols, &local_symbols); | |
3256 | new = pop_context (); | |
3257 | /* Make a block for the local symbols within. */ | |
3258 | finish_block (new->name, &local_symbols, new->old_blocks, | |
3259 | new->start_addr, valu, objfile); | |
3260 | WITHIN_FUNCTION (objfile) = 0; /* This may have to change for Pascal */ | |
3261 | local_symbols = new->locals; | |
3262 | param_symbols = new->params; | |
3263 | break; | |
3264 | ||
3265 | case DNTT_TYPE_BEGIN: | |
3266 | if (context_stack_depth == 1 && | |
3267 | context_stack[0].name != NULL && | |
3268 | context_stack[0].depth == 1) | |
3269 | { | |
3270 | /* This is the END corresponding to the | |
3271 | * BEGIN which we ignored - see DNTT_TYPE_BEGIN case above. | |
3272 | */ | |
3273 | context_stack[0].depth--; | |
3274 | } else { | |
3275 | /* Ending a local scope. */ | |
3276 | valu = hpread_get_location (dn_bufp->dend.address, objfile); | |
3277 | /* Why in the hell is this needed? */ | |
3278 | valu += offset + 9; /* Relocate for dynamic loading */ | |
3279 | new = pop_context (); | |
3280 | desc = dn_bufp->dend.beginscope.dnttp.index; | |
3281 | if (desc != new->depth) | |
3282 | complain (&lbrac_mismatch_complaint, (char *) symnum); | |
3283 | ||
3284 | /* Make a block for the local symbols within. */ | |
3285 | finish_block (new->name, &local_symbols, new->old_blocks, | |
3286 | new->start_addr, valu, objfile); | |
3287 | local_symbols = new->locals; | |
3288 | param_symbols = new->params; | |
3289 | } | |
3290 | break; | |
3291 | ||
3292 | case DNTT_TYPE_WITH: | |
3293 | /* Since we ignore the DNTT_TYPE_WITH that starts the scope, | |
3294 | * we can ignore the DNTT_TYPE_END that ends it. | |
3295 | */ | |
3296 | break; | |
3297 | ||
3298 | case DNTT_TYPE_COMMON: | |
3299 | /* End a FORTRAN common block. We don't currently handle these */ | |
3300 | complain (&hpread_unhandled_end_common_complaint); | |
3301 | break; | |
3302 | ||
3303 | case DNTT_TYPE_CLASS_SCOPE: | |
3304 | ||
3305 | /* pai: FIXME Not handling nested classes for now -- must | |
3306 | * maintain a stack */ | |
3307 | class_scope_name = NULL; | |
3308 | ||
3309 | #if 0 | |
3310 | /* End a class scope */ | |
3311 | valu = hpread_get_location (dn_bufp->dend.address, objfile); | |
3312 | /* Why in the hell is this needed? */ | |
3313 | valu += offset + 9; /* Relocate for dynamic loading */ | |
3314 | new = pop_context (); | |
3315 | desc = dn_bufp->dend.beginscope.dnttp.index; | |
3316 | if (desc != new->depth) | |
3317 | complain (&lbrac_mismatch_complaint, (char *) symnum); | |
3318 | /* Make a block for the local symbols within. */ | |
3319 | finish_block (new->name, &local_symbols, new->old_blocks, | |
3320 | new->start_addr, valu, objfile); | |
3321 | local_symbols = new->locals; | |
3322 | param_symbols = new->params; | |
3323 | #endif | |
3324 | break; | |
3325 | ||
3326 | default: | |
3327 | complain (&hpread_unexpected_end_complaint); | |
3328 | break; | |
3329 | } | |
3330 | break; | |
3331 | ||
3332 | /* DNTT_TYPE_IMPORT is not handled */ | |
3333 | ||
3334 | case DNTT_TYPE_LABEL: | |
3335 | SYMBOL_NAMESPACE (sym) = LABEL_NAMESPACE; | |
3336 | break; | |
3337 | ||
3338 | case DNTT_TYPE_FPARAM: | |
3339 | /* Function parameters. */ | |
3340 | /* Note 1: This code was present in the 4.16 sources, and then | |
3341 | removed, because fparams are handled in | |
3342 | hpread_read_function_type(). However, while fparam symbols | |
3343 | are indeed handled twice, this code here cannot be removed | |
3344 | because then they don't get added to the local symbol list of | |
3345 | the function's code block, which leads to a failure to look | |
3346 | up locals, "this"-relative member names, etc. So I've put | |
3347 | this code back in. pai/1997-07-21 */ | |
3348 | /* Note 2: To fix a defect, we stopped adding FPARAMS to local_symbols | |
3349 | in hpread_read_function_type(), so FPARAMS had to be handled | |
3350 | here. I changed the location to be the appropriate argument | |
3351 | kinds rather than LOC_LOCAL. pai/1997-08-08 */ | |
3352 | /* Note 3: Well, the fix in Note 2 above broke argument printing | |
3353 | in traceback frames, and further it makes assumptions about the | |
3354 | order of the FPARAM entries from HP compilers (cc and aCC in particular | |
3355 | generate them in reverse orders -- fixing one breaks for the other). | |
3356 | So I've added code in hpread_read_function_type() to add fparams | |
3357 | to a param_symbols list for the current context level. These are | |
3358 | then merged into local_symbols when a function end is reached. | |
3359 | pai/1997-08-11 */ | |
3360 | ||
3361 | break; /* do nothing; handled in hpread_read_function_type() */ | |
3362 | ||
3363 | #if 0 /* Old code */ | |
3364 | if (dn_bufp->dfparam.regparam) | |
3365 | SYMBOL_CLASS (sym) = LOC_REGISTER; | |
3366 | else if (dn_bufp->dfparam.indirect) | |
3367 | SYMBOL_CLASS (sym) = LOC_REF_ARG; | |
3368 | else | |
3369 | SYMBOL_CLASS (sym) = LOC_ARG; | |
3370 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
3371 | if (dn_bufp->dfparam.copyparam) | |
3372 | { | |
3373 | SYMBOL_VALUE (sym) = dn_bufp->dfparam.location; | |
3374 | #ifdef HPREAD_ADJUST_STACK_ADDRESS | |
3375 | SYMBOL_VALUE (sym) | |
3376 | += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile)); | |
3377 | #endif | |
3378 | } | |
3379 | else | |
3380 | SYMBOL_VALUE (sym) = dn_bufp->dfparam.location; | |
3381 | SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dfparam.type, objfile); | |
3382 | add_symbol_to_list (sym, &fparam_symbols); | |
3383 | break; | |
3384 | #endif | |
3385 | ||
3386 | case DNTT_TYPE_SVAR: | |
3387 | /* Static variables. */ | |
3388 | SYMBOL_CLASS (sym) = LOC_STATIC; | |
3389 | ||
3390 | /* Note: There is a case that arises with globals in shared | |
3391 | * libraries where we need to set the address to LOC_INDIRECT. | |
3392 | * This case is if you have a global "g" in one library, and | |
3393 | * it is referenced "extern <type> g;" in another library. | |
3394 | * If we're processing the symbols for the referencing library, | |
3395 | * we'll see a global "g", but in this case the address given | |
3396 | * in the symbol table contains a pointer to the real "g". | |
3397 | * We use the storage class LOC_INDIRECT to indicate this. RT | |
3398 | */ | |
3399 | if (is_in_import_list (SYMBOL_NAME(sym), objfile)) | |
3400 | SYMBOL_CLASS (sym) = LOC_INDIRECT; | |
3401 | ||
3402 | SYMBOL_VALUE_ADDRESS (sym) = dn_bufp->dsvar.location + data_offset; | |
3403 | SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dsvar.type, objfile); | |
3404 | ||
3405 | if (dn_bufp->dsvar.global) | |
3406 | add_symbol_to_list (sym, &global_symbols); | |
3407 | ||
3408 | else if (WITHIN_FUNCTION (objfile)) | |
3409 | add_symbol_to_list (sym, &local_symbols); | |
3410 | ||
3411 | else | |
3412 | add_symbol_to_list (sym, &file_symbols); | |
3413 | ||
3414 | if (dn_bufp->dsvar.thread_specific) | |
3415 | { | |
3416 | /* Thread-local variable. | |
3417 | */ | |
3418 | SYMBOL_CLASS (sym) = LOC_THREAD_LOCAL_STATIC; | |
3419 | SYMBOL_BASEREG (sym) = CR27_REGNUM; | |
3420 | ||
3421 | if( objfile->flags & OBJF_SHARED ) { | |
3422 | /* | |
3423 | * This variable is not only thread local but | |
3424 | * in a shared library. | |
3425 | * | |
3426 | * Alas, the shared lib structures are private | |
3427 | * to "somsolib.c". But C lets us point to one. | |
3428 | */ | |
3429 | struct so_list *so; | |
3430 | ||
3431 | if( objfile->obj_private == NULL ) | |
3432 | error( "Internal error in reading shared library information." ); | |
3433 | ||
3434 | so = ((obj_private_data_t *)(objfile->obj_private))->so_info; | |
3435 | if( so == NULL ) | |
3436 | error( "Internal error in reading shared library information." ); | |
3437 | ||
3438 | /* Thread-locals in shared libraries do NOT have the | |
3439 | * standard offset ("data_offset"), so we re-calculate | |
3440 | * where to look for this variable, using a call-back | |
3441 | * to interpret the private shared-library data. | |
3442 | */ | |
3443 | SYMBOL_VALUE_ADDRESS(sym) = dn_bufp->dsvar.location + | |
3444 | so_lib_thread_start_addr( so ); | |
3445 | } | |
3446 | } | |
3447 | break; | |
3448 | ||
3449 | case DNTT_TYPE_DVAR: | |
3450 | /* Dynamic variables. */ | |
3451 | if (dn_bufp->ddvar.regvar) | |
3452 | SYMBOL_CLASS (sym) = LOC_REGISTER; | |
3453 | else | |
3454 | SYMBOL_CLASS (sym) = LOC_LOCAL; | |
3455 | ||
3456 | SYMBOL_VALUE (sym) = dn_bufp->ddvar.location; | |
3457 | #ifdef HPREAD_ADJUST_STACK_ADDRESS | |
3458 | SYMBOL_VALUE (sym) | |
3459 | += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile)); | |
3460 | #endif | |
3461 | SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->ddvar.type, objfile); | |
3462 | if (dn_bufp->ddvar.global) | |
3463 | add_symbol_to_list (sym, &global_symbols); | |
3464 | else if (WITHIN_FUNCTION (objfile)) | |
3465 | add_symbol_to_list (sym, &local_symbols); | |
3466 | else | |
3467 | add_symbol_to_list (sym, &file_symbols); | |
3468 | break; | |
3469 | ||
3470 | case DNTT_TYPE_CONST: | |
3471 | /* A constant (pascal?). */ | |
3472 | SYMBOL_CLASS (sym) = LOC_CONST; | |
3473 | SYMBOL_VALUE (sym) = dn_bufp->dconst.location; | |
3474 | SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dconst.type, objfile); | |
3475 | if (dn_bufp->dconst.global) | |
3476 | add_symbol_to_list (sym, &global_symbols); | |
3477 | else if (WITHIN_FUNCTION (objfile)) | |
3478 | add_symbol_to_list (sym, &local_symbols); | |
3479 | else | |
3480 | add_symbol_to_list (sym, &file_symbols); | |
3481 | break; | |
3482 | ||
3483 | case DNTT_TYPE_TYPEDEF: | |
3484 | /* A typedef. We do want to process these, since a name is | |
3485 | * added to the namespace for the typedef'ed name. | |
3486 | */ | |
3487 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
3488 | SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dtype.type, objfile); | |
3489 | if (dn_bufp->dtype.global) | |
3490 | add_symbol_to_list (sym, &global_symbols); | |
3491 | else if (WITHIN_FUNCTION (objfile)) | |
3492 | add_symbol_to_list (sym, &local_symbols); | |
3493 | else | |
3494 | add_symbol_to_list (sym, &file_symbols); | |
3495 | break; | |
3496 | ||
3497 | case DNTT_TYPE_TAGDEF: | |
3498 | { | |
3499 | int global = dn_bufp->dtag.global; | |
3500 | /* Structure, union, enum, template, or class tag definition */ | |
3501 | /* We do want to process these, since a name is | |
3502 | * added to the namespace for the tag name (and if C++ class, | |
3503 | * for the typename also). | |
3504 | */ | |
3505 | SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE; | |
3506 | ||
3507 | /* The tag contains in its "type" field a pointer to the | |
3508 | * DNTT_TYPE_STRUCT, DNTT_TYPE_UNION, DNTT_TYPE_ENUM, | |
3509 | * DNTT_TYPE_CLASS or DNTT_TYPE_TEMPLATE | |
3510 | * record that actually defines the type. | |
3511 | */ | |
3512 | SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dtype.type, objfile); | |
3513 | TYPE_NAME (sym->type) = SYMBOL_NAME (sym); | |
3514 | TYPE_TAG_NAME (sym->type) = SYMBOL_NAME (sym); | |
3515 | if (dn_bufp->dtag.global) | |
3516 | add_symbol_to_list (sym, &global_symbols); | |
3517 | else if (WITHIN_FUNCTION (objfile)) | |
3518 | add_symbol_to_list (sym, &local_symbols); | |
3519 | else | |
3520 | add_symbol_to_list (sym, &file_symbols); | |
3521 | ||
3522 | /* If this is a C++ class, then we additionally | |
3523 | * need to define a typedef for the | |
3524 | * class type. E.g., so that the name "c" becomes visible as | |
3525 | * a type name when the user says "class c { ... }". | |
3526 | * In order to figure this out, we need to chase down the "type" | |
3527 | * field to get to the DNTT_TYPE_CLASS record. | |
3528 | * | |
3529 | * We also add the typename for ENUM. Though this isn't | |
3530 | * strictly correct, it is necessary because of the debug info | |
3531 | * generated by the aCC compiler, in which we cannot | |
3532 | * distinguish between: | |
3533 | * enum e { ... }; | |
3534 | * and | |
3535 | * typedef enum { ... } e; | |
3536 | * I.e., the compiler emits the same debug info for the above | |
3537 | * two cases, in both cases "e" appearing as a tagdef. | |
3538 | * Therefore go ahead and generate the typename so that | |
3539 | * "ptype e" will work in the above cases. | |
3540 | * | |
3541 | * We also add the typename for TEMPLATE, so as to allow "ptype t" | |
3542 | * when "t" is a template name. | |
3543 | */ | |
3544 | if (dn_bufp->dtype.type.dnttp.index < LNTT_SYMCOUNT (objfile)) | |
3545 | dn_bufp = hpread_get_lntt (dn_bufp->dtag.type.dnttp.index, objfile); | |
3546 | else { | |
3547 | complain (&hpread_tagdef_complaint); | |
3548 | return; | |
3549 | } | |
3550 | if (dn_bufp->dblock.kind == DNTT_TYPE_CLASS || | |
3551 | dn_bufp->dblock.kind == DNTT_TYPE_ENUM || | |
3552 | dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE) { | |
3553 | struct symbol *newsym; | |
3554 | ||
3555 | newsym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack, | |
3556 | sizeof (struct symbol)); | |
3557 | memset (newsym, 0, sizeof (struct symbol)); | |
3558 | SYMBOL_NAME (newsym) = name; | |
3559 | SYMBOL_LANGUAGE (newsym) = language_auto; | |
3560 | SYMBOL_NAMESPACE (newsym) = VAR_NAMESPACE; | |
3561 | SYMBOL_LINE (newsym) = 0; | |
3562 | SYMBOL_VALUE (newsym) = 0; | |
3563 | SYMBOL_CLASS (newsym) = LOC_TYPEDEF; | |
3564 | SYMBOL_TYPE (newsym) = sym->type; | |
3565 | if (global) | |
3566 | add_symbol_to_list (newsym, &global_symbols); | |
3567 | else if (WITHIN_FUNCTION (objfile)) | |
3568 | add_symbol_to_list (newsym, &local_symbols); | |
3569 | else | |
3570 | add_symbol_to_list (newsym, &file_symbols); | |
3571 | } | |
3572 | } | |
3573 | break; | |
3574 | ||
3575 | case DNTT_TYPE_POINTER: | |
3576 | /* Declares a pointer type. Should not be necessary to do anything | |
3577 | * with the type at this level; these are processed | |
3578 | * at the hpread_type_lookup() level. | |
3579 | */ | |
3580 | break; | |
3581 | ||
3582 | case DNTT_TYPE_ENUM: | |
3583 | /* Declares an enum type. Should not be necessary to do anything | |
3584 | * with the type at this level; these are processed | |
3585 | * at the hpread_type_lookup() level. | |
3586 | */ | |
3587 | break; | |
3588 | ||
3589 | case DNTT_TYPE_MEMENUM: | |
3590 | /* Member of enum */ | |
3591 | /* Ignored at this level, but hpread_read_enum_type() will take | |
3592 | * care of walking the list of enumeration members. | |
3593 | */ | |
3594 | break; | |
3595 | ||
3596 | case DNTT_TYPE_SET: | |
3597 | /* Declares a set type. Should not be necessary to do anything | |
3598 | * with the type at this level; these are processed | |
3599 | * at the hpread_type_lookup() level. | |
3600 | */ | |
3601 | break; | |
3602 | ||
3603 | case DNTT_TYPE_SUBRANGE: | |
3604 | /* Declares a subrange type. Should not be necessary to do anything | |
3605 | * with the type at this level; these are processed | |
3606 | * at the hpread_type_lookup() level. | |
3607 | */ | |
3608 | break; | |
3609 | ||
3610 | case DNTT_TYPE_ARRAY: | |
3611 | /* Declares an array type. Should not be necessary to do anything | |
3612 | * with the type at this level; these are processed | |
3613 | * at the hpread_type_lookup() level. | |
3614 | */ | |
3615 | break; | |
3616 | ||
3617 | case DNTT_TYPE_STRUCT: | |
3618 | case DNTT_TYPE_UNION: | |
3619 | /* Declares an struct/union type. | |
3620 | * Should not be necessary to do anything | |
3621 | * with the type at this level; these are processed | |
3622 | * at the hpread_type_lookup() level. | |
3623 | */ | |
3624 | break; | |
3625 | ||
3626 | case DNTT_TYPE_FIELD: | |
3627 | /* Structure/union/class field */ | |
3628 | /* Ignored at this level, but hpread_read_struct_type() will take | |
3629 | * care of walking the list of structure/union/class members. | |
3630 | */ | |
3631 | break; | |
3632 | ||
3633 | /* DNTT_TYPE_VARIANT is not handled by GDB */ | |
3634 | ||
3635 | /* DNTT_TYPE_FILE is not handled by GDB */ | |
3636 | ||
3637 | case DNTT_TYPE_FUNCTYPE: | |
3638 | /* Function type */ | |
3639 | /* Ignored at this level, handled within hpread_type_lookup() */ | |
3640 | break; | |
3641 | ||
3642 | case DNTT_TYPE_WITH: | |
3643 | /* This is emitted within methods to indicate "with <class>" | |
3644 | * scoping rules (i.e., indicate that the class data members | |
3645 | * are directly visible). | |
3646 | * However, since GDB already infers this by looking at the | |
3647 | * "this" argument, interpreting the DNTT_TYPE_WITH | |
3648 | * symbol record is unnecessary. | |
3649 | */ | |
3650 | break; | |
3651 | ||
3652 | case DNTT_TYPE_COMMON: | |
3653 | /* FORTRAN common. Not yet handled. */ | |
3654 | complain (&hpread_unhandled_common_complaint); | |
3655 | break; | |
3656 | ||
3657 | /* DNTT_TYPE_COBSTRUCT is not handled by GDB. */ | |
3658 | /* DNTT_TYPE_XREF is not handled by GDB. */ | |
3659 | /* DNTT_TYPE_SA is not handled by GDB. */ | |
3660 | /* DNTT_TYPE_MACRO is not handled by GDB */ | |
3661 | ||
3662 | case DNTT_TYPE_BLOCKDATA: | |
3663 | /* Not sure what this is - part of FORTRAN support maybe? | |
3664 | * Anyway, not yet handled. | |
3665 | */ | |
3666 | complain (&hpread_unhandled_blockdata_complaint); | |
3667 | break; | |
3668 | ||
3669 | case DNTT_TYPE_CLASS_SCOPE: | |
3670 | ||
3671 | ||
3672 | ||
3673 | /* The compiler brackets member functions with a CLASS_SCOPE/END | |
3674 | * pair of records, presumably to put them in a different scope | |
3675 | * from the module scope where they are normally defined. | |
3676 | * E.g., in the situation: | |
3677 | * void f() { ... } | |
3678 | * void c::f() { ...} | |
3679 | * The member function "c::f" will be bracketed by a CLASS_SCOPE/END. | |
3680 | * This causes "break f" at the module level to pick the | |
3681 | * the file-level function f(), not the member function | |
3682 | * (which needs to be referenced via "break c::f"). | |
3683 | * | |
3684 | * Here we record the class name to generate the demangled names of | |
3685 | * member functions later. | |
3686 | * | |
3687 | * FIXME Not being used now for anything -- cplus_demangle seems | |
3688 | * enough for getting the class-qualified names of functions. We | |
3689 | * may need this for handling nested classes and types. */ | |
3690 | ||
3691 | /* pai: FIXME Not handling nested classes for now -- need to | |
3692 | * maintain a stack */ | |
3693 | ||
3694 | dn_temp = hpread_get_lntt (dn_bufp->dclass_scope.type.dnttp.index, objfile); | |
3695 | if (dn_temp->dblock.kind == DNTT_TYPE_TAGDEF) | |
3696 | class_scope_name = VT (objfile) + dn_temp->dtag.name; | |
3697 | else | |
3698 | class_scope_name = NULL; | |
3699 | ||
3700 | #if 0 | |
3701 | ||
3702 | /* Begin a new scope. */ | |
3703 | SL_INDEX (objfile) = hpread_record_lines (current_subfile, | |
3704 | SL_INDEX (objfile), | |
3705 | dn_bufp->dclass_scope.address, | |
3706 | objfile, offset); | |
3707 | valu = hpread_get_location (dn_bufp->dclass_scope.address, objfile); | |
3708 | valu += offset; /* Relocate for dynamic loading */ | |
3709 | desc = hpread_get_scope_start (dn_bufp->dclass_scope.address, objfile); | |
3710 | /* We use the scope start DNTT index as the nesting depth identifier! */ | |
3711 | new = push_context (desc, valu); | |
3712 | #endif | |
3713 | break; | |
3714 | ||
3715 | case DNTT_TYPE_REFERENCE: | |
3716 | /* Declares a C++ reference type. Should not be necessary to do anything | |
3717 | * with the type at this level; these are processed | |
3718 | * at the hpread_type_lookup() level. | |
3719 | */ | |
3720 | break; | |
3721 | ||
3722 | case DNTT_TYPE_PTRMEM: | |
3723 | /* Declares a C++ pointer-to-data-member type. This does not | |
3724 | * need to be handled at this level; being a type description it | |
3725 | * is instead handled at the hpread_type_lookup() level. | |
3726 | */ | |
3727 | break; | |
3728 | ||
3729 | case DNTT_TYPE_PTRMEMFUNC: | |
3730 | /* Declares a C++ pointer-to-function-member type. This does not | |
3731 | * need to be handled at this level; being a type description it | |
3732 | * is instead handled at the hpread_type_lookup() level. | |
3733 | */ | |
3734 | break; | |
3735 | ||
3736 | case DNTT_TYPE_CLASS: | |
3737 | /* Declares a class type. | |
3738 | * Should not be necessary to do anything | |
3739 | * with the type at this level; these are processed | |
3740 | * at the hpread_type_lookup() level. | |
3741 | */ | |
3742 | break; | |
3743 | ||
3744 | case DNTT_TYPE_GENFIELD: | |
3745 | /* I believe this is used for class member functions */ | |
3746 | /* Ignored at this level, but hpread_read_struct_type() will take | |
3747 | * care of walking the list of class members. | |
3748 | */ | |
3749 | break; | |
3750 | ||
3751 | case DNTT_TYPE_VFUNC: | |
3752 | /* Virtual function */ | |
3753 | /* This does not have to be handled at this level; handled in | |
3754 | * the course of processing class symbols. | |
3755 | */ | |
3756 | break; | |
3757 | ||
3758 | case DNTT_TYPE_MEMACCESS: | |
3759 | /* DDE ignores this symbol table record. | |
3760 | * It has something to do with "modified access" to class members. | |
3761 | * I'll assume we can safely ignore it too. | |
3762 | */ | |
3763 | break; | |
3764 | ||
3765 | case DNTT_TYPE_INHERITANCE: | |
3766 | /* These don't have to be handled here, since they are handled | |
3767 | * within hpread_read_struct_type() in the process of constructing | |
3768 | * a class type. | |
3769 | */ | |
3770 | break; | |
3771 | ||
3772 | case DNTT_TYPE_FRIEND_CLASS: | |
3773 | case DNTT_TYPE_FRIEND_FUNC: | |
3774 | /* These can safely be ignored, as GDB doesn't need this | |
3775 | * info. DDE only uses it in "describe". We may later want | |
3776 | * to extend GDB's "ptype" to give this info, but for now | |
3777 | * it seems safe enough to ignore it. | |
3778 | */ | |
3779 | break; | |
3780 | ||
3781 | case DNTT_TYPE_MODIFIER: | |
3782 | /* Intended to supply "modified access" to a type */ | |
3783 | /* From the way DDE handles this, it looks like it always | |
3784 | * modifies a type. Therefore it is safe to ignore it at this | |
3785 | * level, and handle it in hpread_type_lookup(). | |
3786 | */ | |
3787 | break; | |
3788 | ||
3789 | case DNTT_TYPE_OBJECT_ID: | |
3790 | /* Just ignore this - that's all DDE does */ | |
3791 | break; | |
3792 | ||
3793 | case DNTT_TYPE_MEMFUNC: | |
3794 | /* Member function */ | |
3795 | /* This does not have to be handled at this level; handled in | |
3796 | * the course of processing class symbols. | |
3797 | */ | |
3798 | break; | |
3799 | ||
3800 | case DNTT_TYPE_DOC_MEMFUNC: | |
3801 | /* Member function */ | |
3802 | /* This does not have to be handled at this level; handled in | |
3803 | * the course of processing class symbols. | |
3804 | */ | |
3805 | break; | |
3806 | ||
3807 | case DNTT_TYPE_TEMPLATE: | |
3808 | /* Template - sort of the header for a template definition, | |
3809 | * which like a class, points to a member list and also points | |
3810 | * to a TEMPLATE_ARG list of type-arguments. | |
3811 | * We do not need to process TEMPLATE records at this level though. | |
3812 | */ | |
3813 | break; | |
3814 | ||
3815 | case DNTT_TYPE_TEMPLATE_ARG: | |
3816 | /* The TEMPLATE record points to an argument list of | |
3817 | * TEMPLATE_ARG records, each of which describes one | |
3818 | * of the type-arguments. | |
3819 | * We do not need to process TEMPLATE_ARG records at this level though. | |
3820 | */ | |
3821 | break; | |
3822 | ||
3823 | case DNTT_TYPE_FUNC_TEMPLATE: | |
3824 | /* This will get emitted for member functions of templates. | |
3825 | * But we don't need to process this record at this level though, | |
3826 | * we will process it in the course of processing a TEMPLATE | |
3827 | * record. | |
3828 | */ | |
3829 | break; | |
3830 | ||
3831 | case DNTT_TYPE_LINK: | |
3832 | /* The LINK record is used to link up templates with instantiations. */ | |
3833 | /* It is not clear why this is needed, and furthermore aCC does | |
3834 | * not appear to generate this, so I think we can safely ignore it. - RT | |
3835 | */ | |
3836 | break; | |
3837 | ||
3838 | /* DNTT_TYPE_DYN_ARRAY_DESC is not handled by GDB */ | |
3839 | /* DNTT_TYPE_DESC_SUBRANGE is not handled by GDB */ | |
3840 | /* DNTT_TYPE_BEGIN_EXT is not handled by GDB */ | |
3841 | /* DNTT_TYPE_INLN is not handled by GDB */ | |
3842 | /* DNTT_TYPE_INLN_LIST is not handled by GDB */ | |
3843 | /* DNTT_TYPE_ALIAS is not handled by GDB */ | |
3844 | ||
3845 | default: | |
3846 | break; | |
3847 | } | |
3848 | } | |
3849 | ||
3850 | /* Get nesting depth for a DNTT entry. | |
3851 | * DN_BUFP points to a DNTT entry. | |
3852 | * OBJFILE is the object file. | |
3853 | * REPORT_NESTED is a flag; if 0, real nesting depth is | |
3854 | * reported, if it is 1, the function simply returns a | |
3855 | * non-zero value if the nesting depth is anything > 0. | |
3856 | * | |
3857 | * Return value is an integer. 0 => not a local type / name | |
3858 | * positive return => type or name is local to some | |
3859 | * block or function. | |
3860 | */ | |
3861 | ||
3862 | ||
3863 | /* elz: ATTENTION: FIXME: NOTE: WARNING!!!! | |
3864 | this function now returns 0 right away. It was taking too much time | |
3865 | at start up. Now, though, the local types are not handled correctly. | |
3866 | */ | |
3867 | ||
3868 | ||
3869 | static int | |
3870 | hpread_get_scope_depth (dn_bufp, objfile, report_nested) | |
3871 | union dnttentry * dn_bufp; | |
3872 | struct objfile * objfile; | |
3873 | int report_nested; | |
3874 | { | |
3875 | register int index; | |
3876 | register union dnttentry * dn_tmp; | |
3877 | register short depth = 0; | |
3878 | /****************************/ | |
3879 | return 0; | |
3880 | /****************************/ | |
3881 | ||
3882 | index = (((char *) dn_bufp) - LNTT (objfile)) / (sizeof (struct dntt_type_block)); | |
3883 | ||
3884 | while (--index >= 0) | |
3885 | { | |
3886 | dn_tmp = hpread_get_lntt (index, objfile); | |
3887 | switch (dn_tmp->dblock.kind) | |
3888 | { | |
3889 | case DNTT_TYPE_MODULE: | |
3890 | return depth; | |
3891 | case DNTT_TYPE_END: | |
3892 | /* index is signed int; dnttp.index is 29-bit unsigned int! */ | |
3893 | index = (int) dn_tmp->dend.beginscope.dnttp.index; | |
3894 | break; | |
3895 | case DNTT_TYPE_BEGIN: | |
3896 | case DNTT_TYPE_FUNCTION: | |
3897 | case DNTT_TYPE_DOC_FUNCTION: | |
3898 | case DNTT_TYPE_WITH: | |
3899 | case DNTT_TYPE_COMMON: | |
3900 | case DNTT_TYPE_CLASS_SCOPE: | |
3901 | depth++; | |
3902 | if (report_nested) | |
3903 | return 1; | |
3904 | break; | |
3905 | default: | |
3906 | break; | |
3907 | } | |
3908 | } | |
3909 | return depth; | |
3910 | } | |
3911 | ||
3912 | /* Adjust the bitoffsets for all fields of an anonymous union of | |
3913 | type TYPE by negative BITS. This handles HP aCC's hideous habit | |
3914 | of giving members of anonymous unions bit offsets relative to the | |
3915 | enclosing structure instead of relative to the union itself. */ | |
3916 | ||
3917 | static void | |
3918 | hpread_adjust_bitoffsets (type, bits) | |
3919 | struct type * type; | |
3920 | int bits; | |
3921 | { | |
3922 | register int i; | |
3923 | ||
3924 | /* This is done only for unions; caller had better check that | |
3925 | it is an anonymous one. */ | |
3926 | if (TYPE_CODE (type) != TYPE_CODE_UNION) | |
3927 | return; | |
3928 | ||
3929 | /* Adjust each field; since this is a union, there are no base | |
3930 | classes. Also no static membes. Also, no need for recursion as | |
3931 | the members of this union if themeselves structs or unions, have | |
3932 | the correct bitoffsets; if an anonymous union is a member of this | |
3933 | anonymous union, the code in hpread_read_struct_type() will | |
3934 | adjust for that. */ | |
3935 | ||
3936 | for (i = 0; i < TYPE_NFIELDS (type); i++) | |
3937 | TYPE_FIELD_BITPOS (type, i) -= bits; | |
3938 | } | |
3939 | ||
3940 | /* Because of quirks in HP compilers' treatment of anonymous unions inside | |
3941 | classes, we have to chase through a chain of threaded FIELD entries. | |
3942 | If we encounter an anonymous union in the chain, we must recursively skip over | |
3943 | that too. | |
3944 | ||
3945 | This function does a "next" in the chain of FIELD entries, but transparently | |
3946 | skips over anonymous unions' fields (recursively). | |
3947 | ||
3948 | Inputs are the number of times to do "next" at the top level, the dnttpointer | |
3949 | (FIELD) and entry pointer (FIELDP) for the dntt record corresponding to it, | |
3950 | and the ubiquitous objfile parameter. (Note: FIELDP is a **.) Return value | |
3951 | is a dnttpointer for the new field after all the skipped ones */ | |
3952 | ||
3953 | static dnttpointer | |
3954 | hpread_get_next_skip_over_anon_unions (skip_fields, field, fieldp, objfile) | |
3955 | int skip_fields; | |
3956 | dnttpointer field; | |
3957 | union dnttentry ** fieldp; | |
3958 | struct objfile * objfile; | |
3959 | { | |
3960 | struct type * anon_type; | |
3961 | register int i; | |
3962 | int bitoffset; | |
3963 | char * name; | |
3964 | ||
3965 | for (i=0; i < skip_fields; i++) | |
3966 | { | |
3967 | /* Get type of item we're looking at now; recursively processes the types | |
3968 | of these intermediate items we skip over, so they aren't lost. */ | |
3969 | anon_type = hpread_type_lookup ((*fieldp)->dfield.type, objfile); | |
3970 | anon_type = CHECK_TYPEDEF (anon_type); | |
3971 | bitoffset = (*fieldp)->dfield.bitoffset; | |
3972 | name = VT (objfile) + (*fieldp)->dfield.name; | |
3973 | /* First skip over one item to avoid stack death on recursion */ | |
3974 | field = (*fieldp)->dfield.nextfield; | |
3975 | *fieldp = hpread_get_lntt (field.dnttp.index, objfile); | |
3976 | /* Do we have another anonymous union? If so, adjust the bitoffsets | |
3977 | of its members and skip over its members. */ | |
3978 | if ((TYPE_CODE (anon_type) == TYPE_CODE_UNION) && | |
3979 | (!name || STREQ (name, ""))) | |
3980 | { | |
3981 | hpread_adjust_bitoffsets (anon_type, bitoffset); | |
3982 | field = hpread_get_next_skip_over_anon_unions (TYPE_NFIELDS (anon_type), field, fieldp, objfile); | |
3983 | } | |
3984 | } | |
3985 | return field; | |
3986 | } | |
3987 | ||
3988 |