1 /* Read hp debug symbols and convert to internal format, for GDB.
2 Copyright 1993, 1996 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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,
19 Boston, MA 02111-1307, USA.
21 Written by the Center for Software Science at the University of Utah
22 and by Cygnus Support. */
24 /* Common include for hp-symtab-read.c and hp-psymtab-read.c.
25 * Note this has nested includes for a bunch of stuff.
32 #include "complaints.h"
37 static struct complaint hpread_unhandled_end_common_complaint =
39 "unhandled symbol in hp-symtab-read.c: DNTT_TYPE_COMMON/DNTT_TYPE_END.\n", 0, 0
42 static struct complaint hpread_unhandled_type_complaint =
44 "hpread_type_translate: unhandled type code.", 0, 0
47 static struct complaint hpread_struct_complaint =
49 "hpread_read_struct_type: expected SVAR type...", 0, 0
52 static struct complaint hpread_array_complaint =
54 "error in hpread_array_type.", 0, 0
57 static struct complaint hpread_type_lookup_complaint =
59 "error in hpread_type_lookup().", 0, 0
63 static struct complaint hpread_unexpected_end_complaint =
65 "internal error in hp-symtab-read.c: Unexpected DNTT_TYPE_END kind.", 0, 0
68 static struct complaint hpread_tagdef_complaint =
70 "error processing class tagdef", 0, 0
73 static struct complaint hpread_unhandled_common_complaint =
75 "unhandled symbol in hp-symtab-read.c: DNTT_TYPE_COMMON.", 0, 0
78 static struct complaint hpread_unhandled_blockdata_complaint =
80 "unhandled symbol in hp-symtab-read.c: DNTT_TYPE_BLOCKDATA.", 0, 0
84 /* Forward procedure declarations */
86 static unsigned long hpread_get_scope_start
87 PARAMS ((sltpointer, struct objfile *));
89 static unsigned long hpread_get_line
90 PARAMS ((sltpointer, struct objfile *));
92 static CORE_ADDR hpread_get_location
93 PARAMS ((sltpointer, struct objfile *));
95 static void hpread_psymtab_to_symtab_1
96 PARAMS ((struct partial_symtab *));
98 void hpread_psymtab_to_symtab
99 PARAMS ((struct partial_symtab *));
101 static struct symtab *hpread_expand_symtab
102 PARAMS ((struct objfile *, int, int, CORE_ADDR, int,
103 struct section_offsets *, char *));
105 static int hpread_type_translate
106 PARAMS ((dnttpointer));
108 static struct type **hpread_lookup_type
109 PARAMS ((dnttpointer, struct objfile *));
111 static struct type *hpread_alloc_type
112 PARAMS ((dnttpointer, struct objfile *));
114 static struct type *hpread_read_enum_type
115 PARAMS ((dnttpointer, union dnttentry *, struct objfile *));
117 static struct type *hpread_read_function_type
118 PARAMS ((dnttpointer, union dnttentry *, struct objfile *, int));
120 static struct type *hpread_read_doc_function_type
121 PARAMS ((dnttpointer, union dnttentry *, struct objfile *, int));
123 static struct type *hpread_read_struct_type
124 PARAMS ((dnttpointer, union dnttentry *, struct objfile *));
126 static struct type *hpread_get_nth_template_arg
127 PARAMS ((struct objfile *, int));
129 static struct type *hpread_read_templ_arg_type
130 PARAMS ((dnttpointer, union dnttentry *, struct objfile *, char *));
132 static struct type *hpread_read_set_type
133 PARAMS ((dnttpointer, union dnttentry *, struct objfile *));
135 static struct type *hpread_read_array_type
136 PARAMS ((dnttpointer, union dnttentry * dn_bufp, struct objfile * objfile));
138 static struct type *hpread_read_subrange_type
139 PARAMS ((dnttpointer, union dnttentry *, struct objfile *));
141 static struct type *hpread_type_lookup
142 PARAMS ((dnttpointer, struct objfile *));
144 static sltpointer hpread_record_lines
145 PARAMS ((struct subfile *, sltpointer, sltpointer,
146 struct objfile *, CORE_ADDR));
148 static void hpread_process_one_debug_symbol
149 PARAMS ((union dnttentry *, char *, struct section_offsets *,
150 struct objfile *, CORE_ADDR, int, char *, int, int *));
152 static int hpread_get_scope_depth
153 PARAMS ((union dnttentry *, struct objfile *, int));
155 static void fix_static_member_physnames
156 PARAMS ((struct type *, char *, struct objfile *));
158 static void fixup_class_method_type
159 PARAMS ((struct type *, struct type *, struct objfile *));
161 static void hpread_adjust_bitoffsets PARAMS ((struct type *, int));
163 static dnttpointer hpread_get_next_skip_over_anon_unions
164 PARAMS ((int, dnttpointer, union dnttentry **, struct objfile *));
166 /* Global to indicate presence of HP-compiled objects,
167 in particular, SOM executable file with SOM debug info
168 Defined in symtab.c, used in hppa-tdep.c. */
169 extern int hp_som_som_object_present;
171 /* Static used to indicate a class type that requires a
172 fix-up of one of its method types */
173 static struct type *fixup_class = NULL;
175 /* Static used to indicate the method type that is to be
176 used to fix-up the type for fixup_class */
177 static struct type *fixup_method = NULL;
181 /* Get the nesting depth for the source line identified by INDEX. */
184 hpread_get_scope_start (index, objfile)
186 struct objfile *objfile;
188 union sltentry *sl_bufp;
190 sl_bufp = hpread_get_slt (index, objfile);
191 return sl_bufp->sspec.backptr.dnttp.index;
194 /* Get the source line number the the line identified by INDEX. */
197 hpread_get_line (index, objfile)
199 struct objfile *objfile;
201 union sltentry *sl_bufp;
203 sl_bufp = hpread_get_slt (index, objfile);
204 return sl_bufp->snorm.line;
207 /* Find the code address associated with a given sltpointer */
210 hpread_get_location (index, objfile)
212 struct objfile *objfile;
214 union sltentry *sl_bufp;
217 /* code location of special sltentrys is determined from context */
218 sl_bufp = hpread_get_slt (index, objfile);
220 if (sl_bufp->snorm.sltdesc == SLT_END)
222 /* find previous normal sltentry and get address */
223 for (i = 0; ((sl_bufp->snorm.sltdesc != SLT_NORMAL) &&
224 (sl_bufp->snorm.sltdesc != SLT_NORMAL_OFFSET) &&
225 (sl_bufp->snorm.sltdesc != SLT_EXIT)); i++)
226 sl_bufp = hpread_get_slt (index - i, objfile);
227 if (sl_bufp->snorm.sltdesc == SLT_NORMAL_OFFSET)
228 return sl_bufp->snormoff.address;
230 return sl_bufp->snorm.address;
233 /* find next normal sltentry and get address */
234 for (i = 0; ((sl_bufp->snorm.sltdesc != SLT_NORMAL) &&
235 (sl_bufp->snorm.sltdesc != SLT_NORMAL_OFFSET) &&
236 (sl_bufp->snorm.sltdesc != SLT_EXIT)); i++)
237 sl_bufp = hpread_get_slt (index + i, objfile);
238 if (sl_bufp->snorm.sltdesc == SLT_NORMAL_OFFSET)
239 return sl_bufp->snormoff.address;
241 return sl_bufp->snorm.address;
245 /* Return 1 if an HP debug symbol of type KIND has a name associated with
246 * it, else return 0. (This function is not currently used, but I'll
247 * leave it here in case it proves useful later on. - RT).
251 hpread_has_name (kind)
252 enum dntt_entry_type kind;
256 case DNTT_TYPE_SRCFILE:
257 case DNTT_TYPE_MODULE:
258 case DNTT_TYPE_FUNCTION:
259 case DNTT_TYPE_DOC_FUNCTION:
260 case DNTT_TYPE_ENTRY:
261 case DNTT_TYPE_IMPORT:
262 case DNTT_TYPE_LABEL:
263 case DNTT_TYPE_FPARAM:
266 case DNTT_TYPE_CONST:
267 case DNTT_TYPE_TYPEDEF:
268 case DNTT_TYPE_TAGDEF:
269 case DNTT_TYPE_MEMENUM:
270 case DNTT_TYPE_FIELD:
272 case DNTT_TYPE_BLOCKDATA:
273 case DNTT_TYPE_MEMFUNC:
274 case DNTT_TYPE_DOC_MEMFUNC:
277 case DNTT_TYPE_BEGIN:
279 case DNTT_TYPE_POINTER:
282 case DNTT_TYPE_ARRAY:
283 case DNTT_TYPE_STRUCT:
284 case DNTT_TYPE_UNION:
285 case DNTT_TYPE_VARIANT:
287 case DNTT_TYPE_FUNCTYPE:
288 case DNTT_TYPE_SUBRANGE:
290 case DNTT_TYPE_COMMON:
291 case DNTT_TYPE_COBSTRUCT:
293 case DNTT_TYPE_MACRO:
294 case DNTT_TYPE_CLASS_SCOPE:
295 case DNTT_TYPE_REFERENCE:
296 case DNTT_TYPE_PTRMEM:
297 case DNTT_TYPE_PTRMEMFUNC:
298 case DNTT_TYPE_CLASS:
299 case DNTT_TYPE_GENFIELD:
300 case DNTT_TYPE_VFUNC:
301 case DNTT_TYPE_MEMACCESS:
302 case DNTT_TYPE_INHERITANCE:
303 case DNTT_TYPE_FRIEND_CLASS:
304 case DNTT_TYPE_FRIEND_FUNC:
305 case DNTT_TYPE_MODIFIER:
306 case DNTT_TYPE_OBJECT_ID:
307 case DNTT_TYPE_TEMPLATE:
308 case DNTT_TYPE_TEMPLATE_ARG:
309 case DNTT_TYPE_FUNC_TEMPLATE:
311 /* DNTT_TYPE_DYN_ARRAY_DESC ? */
312 /* DNTT_TYPE_DESC_SUBRANGE ? */
313 /* DNTT_TYPE_BEGIN_EXT ? */
314 /* DNTT_TYPE_INLN ? */
315 /* DNTT_TYPE_INLN_LIST ? */
316 /* DNTT_TYPE_ALIAS ? */
322 /* Do the dirty work of reading in the full symbol from a partial symbol
326 hpread_psymtab_to_symtab_1 (pst)
327 struct partial_symtab *pst;
329 struct cleanup *old_chain;
332 /* Get out quick if passed junk. */
336 /* Complain if we've already read in this symbol table. */
339 fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
344 /* Read in all partial symtabs on which this one is dependent */
345 for (i = 0; i < pst->number_of_dependencies; i++)
346 if (!pst->dependencies[i]->readin)
348 /* Inform about additional files that need to be read in. */
351 fputs_filtered (" ", gdb_stdout);
353 fputs_filtered ("and ", gdb_stdout);
355 printf_filtered ("%s...", pst->dependencies[i]->filename);
356 wrap_here (""); /* Flush output */
357 gdb_flush (gdb_stdout);
359 hpread_psymtab_to_symtab_1 (pst->dependencies[i]);
362 /* If it's real... */
365 /* Init stuff necessary for reading in symbols */
367 old_chain = make_cleanup (really_free_pendings, 0);
370 hpread_expand_symtab (pst->objfile, LDSYMOFF (pst), LDSYMLEN (pst),
371 pst->textlow, pst->texthigh - pst->textlow,
372 pst->section_offsets, pst->filename);
373 sort_symtab_syms (pst->symtab);
375 do_cleanups (old_chain);
381 /* Read in all of the symbols for a given psymtab for real.
382 Be verbose about it if the user wants that. */
385 hpread_psymtab_to_symtab (pst)
386 struct partial_symtab *pst;
388 /* Get out quick if given junk. */
395 fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
400 /* elz: setting the flag to indicate that the code of the target
401 was compiled using an HP compiler (aCC, cc)
402 the processing_acc_compilation variable is declared in the
403 file buildsym.h, the HP_COMPILED_TARGET is defined to be equal
404 to 3 in the file tm_hppa.h */
406 processing_gcc_compilation = 0;
408 if (LDSYMLEN (pst) || pst->number_of_dependencies)
410 /* Print the message now, before reading the string table,
411 to avoid disconcerting pauses. */
414 printf_filtered ("Reading in symbols for %s...", pst->filename);
415 gdb_flush (gdb_stdout);
418 hpread_psymtab_to_symtab_1 (pst);
420 /* Match with global symbols. This only needs to be done once,
421 after all of the symtabs and dependencies have been read in. */
422 scan_file_globals (pst->objfile);
424 /* Finish up the debug error message. */
426 printf_filtered ("done.\n");
430 /* Read in a defined section of a specific object file's symbols.
432 DESC is the file descriptor for the file, positioned at the
433 beginning of the symtab
434 SYM_OFFSET is the offset within the file of
435 the beginning of the symbols we want to read
436 SYM_SIZE is the size of the symbol info to read in.
437 TEXT_OFFSET is the beginning of the text segment we are reading symbols for
438 TEXT_SIZE is the size of the text segment read in.
439 SECTION_OFFSETS are the relocation offsets which get added to each symbol. */
441 static struct symtab *
442 hpread_expand_symtab (objfile, sym_offset, sym_size, text_offset, text_size,
443 section_offsets, filename)
444 struct objfile *objfile;
447 CORE_ADDR text_offset;
449 struct section_offsets *section_offsets;
453 union dnttentry *dn_bufp;
455 int at_module_boundary = 0;
456 /* 1 => at end, -1 => at beginning */
458 int sym_index = sym_offset / sizeof (struct dntt_type_block);
460 current_objfile = objfile;
463 last_source_file = 0;
465 /* Demangling style -- if EDG style already set, don't change it,
466 as HP style causes some problems with the KAI EDG compiler */
467 if (current_demangling_style != edg_demangling)
469 /* Otherwise, ensure that we are using HP style demangling */
470 set_demangling_style (HP_DEMANGLING_STYLE_STRING);
473 dn_bufp = hpread_get_lntt (sym_index, objfile);
474 if (!((dn_bufp->dblock.kind == (unsigned char) DNTT_TYPE_SRCFILE) ||
475 (dn_bufp->dblock.kind == (unsigned char) DNTT_TYPE_MODULE)))
477 start_symtab ("globals", NULL, 0);
478 record_debugformat ("HP");
481 /* The psymtab builder (hp-psymtab-read.c) is the one that
482 * determined the "sym_size" argument (i.e. how many DNTT symbols
483 * are in this symtab), which we use to compute "max_symnum"
484 * (point in DNTT to which we read).
486 * Perhaps this should be changed so that
487 * process_one_debug_symbol() "knows" when
488 * to stop reading (based on reading from the MODULE to the matching
489 * END), and take out this reliance on a #-syms being passed in...
490 * (I'm worried about the reliability of this number). But I'll
491 * leave it as-is, for now. - RT
493 * The change above has been made. I've left the "for" loop control
494 * in to prepare for backing this out again. -JB
496 max_symnum = sym_size / sizeof (struct dntt_type_block);
497 /* No reason to multiply on pst side and divide on sym side... FIXME */
499 /* Read in and process each debug symbol within the specified range.
505 QUIT; /* Allow this to be interruptable */
506 dn_bufp = hpread_get_lntt (sym_index + symnum, objfile);
508 if (dn_bufp->dblock.extension)
511 /* Yow! We call SET_NAMESTRING on things without names! */
512 SET_NAMESTRING (dn_bufp, &namestring, objfile);
514 hpread_process_one_debug_symbol (dn_bufp, namestring, section_offsets,
515 objfile, text_offset, text_size,
516 filename, symnum + sym_index,
520 /* OLD COMMENTS: This routine is only called for psts. All psts
521 * correspond to MODULES. If we ever do lazy-reading of globals
522 * from the LNTT, then there will be a pst which ends when the
523 * LNTT ends, and not at an END MODULE entry. Then we'll have
524 * to re-visit this break.
526 if( at_end_of_module )
531 /* We no longer break out of the loop when we reach the end of a
532 module. The reason is that with CTTI, the compiler can generate
533 function symbols (for template function instantiations) which are not
534 in any module; typically they show up beyond a module's end, and
535 before the next module's start. We include them in the current
536 module. However, we still don't trust the MAX_SYMNUM value from
537 the psymtab, so we break out if we enter a new module. */
539 if (at_module_boundary == -1)
543 current_objfile = NULL;
544 hp_som_som_object_present = 1; /* Indicate we've processed an HP SOM SOM file */
546 return end_symtab (text_offset + text_size, objfile, 0);
552 /* Convert basic types from HP debug format into GDB internal format. */
555 hpread_type_translate (typep)
558 if (!typep.dntti.immediate)
560 error ("error in hpread_type_translate\n.");
564 switch (typep.dntti.type)
566 case HP_TYPE_BOOLEAN:
567 case HP_TYPE_BOOLEAN_S300_COMPAT:
568 case HP_TYPE_BOOLEAN_VAX_COMPAT:
570 case HP_TYPE_CHAR: /* C signed char, C++ plain char */
572 case HP_TYPE_WIDE_CHAR:
575 if (typep.dntti.bitlength <= 8)
576 return FT_SIGNED_CHAR; /* C++ signed char */
577 if (typep.dntti.bitlength <= 16)
579 if (typep.dntti.bitlength <= 32)
583 if (typep.dntti.bitlength <= 8)
584 return FT_SIGNED_CHAR; /* C++ signed char. */
586 case HP_TYPE_UNSIGNED_LONG:
587 if (typep.dntti.bitlength <= 8)
588 return FT_UNSIGNED_CHAR; /* C/C++ unsigned char */
589 if (typep.dntti.bitlength <= 16)
590 return FT_UNSIGNED_SHORT;
591 if (typep.dntti.bitlength <= 32)
592 return FT_UNSIGNED_LONG;
593 return FT_UNSIGNED_LONG_LONG;
594 case HP_TYPE_UNSIGNED_INT:
595 if (typep.dntti.bitlength <= 8)
596 return FT_UNSIGNED_CHAR;
597 if (typep.dntti.bitlength <= 16)
598 return FT_UNSIGNED_SHORT;
599 if (typep.dntti.bitlength <= 32)
600 return FT_UNSIGNED_INTEGER;
601 return FT_UNSIGNED_LONG_LONG;
603 case HP_TYPE_REAL_3000:
605 if (typep.dntti.bitlength == 64)
606 return FT_DBL_PREC_FLOAT;
607 if (typep.dntti.bitlength == 128)
608 return FT_EXT_PREC_FLOAT;
610 case HP_TYPE_COMPLEX:
611 case HP_TYPE_COMPLEXS3000:
612 if (typep.dntti.bitlength == 128)
613 return FT_DBL_PREC_COMPLEX;
614 if (typep.dntti.bitlength == 192)
615 return FT_EXT_PREC_COMPLEX;
619 case HP_TYPE_STRING200:
620 case HP_TYPE_LONGSTRING200:
621 case HP_TYPE_FTN_STRING_SPEC:
622 case HP_TYPE_MOD_STRING_SPEC:
623 case HP_TYPE_MOD_STRING_3000:
624 case HP_TYPE_FTN_STRING_S300_COMPAT:
625 case HP_TYPE_FTN_STRING_VAX_COMPAT:
627 case HP_TYPE_TEMPLATE_ARG:
628 return FT_TEMPLATE_ARG;
631 case HP_TYPE_PACKED_DECIMAL:
632 case HP_TYPE_ANYPOINTER:
633 case HP_TYPE_GLOBAL_ANYPOINTER:
634 case HP_TYPE_LOCAL_ANYPOINTER:
636 warning ("hpread_type_translate: unhandled type code.\n");
641 /* Given a position in the DNTT, return a pointer to the
642 * already-built "struct type" (if any), for the type defined
646 static struct type **
647 hpread_lookup_type (hp_type, objfile)
649 struct objfile *objfile;
652 int index = hp_type.dnttp.index;
653 int size_changed = 0;
655 /* The immediate flag indicates this doesn't actually point to
658 if (hp_type.dntti.immediate)
661 /* For each objfile, we maintain a "type vector".
662 * This an array of "struct type *"'s with one pointer per DNTT index.
663 * Given a DNTT index, we look in this array to see if we have
664 * already processed this DNTT and if it is a type definition.
665 * If so, then we can locate a pointer to the already-built
666 * "struct type", and not build it again.
668 * The need for this arises because our DNTT-walking code wanders
669 * around. In particular, it will encounter the same type multiple
670 * times (once for each object of that type). We don't want to
671 * built multiple "struct type"'s for the same thing.
673 * Having said this, I should point out that this type-vector is
674 * an expensive way to keep track of this. If most DNTT entries are
675 * 3 words, the type-vector will be 1/3 the size of the DNTT itself.
676 * Alternative solutions:
677 * - Keep a compressed or hashed table. Less memory, but more expensive
678 * to search and update.
679 * - (Suggested by JB): Overwrite the DNTT entry itself
680 * with the info. Create a new type code "ALREADY_BUILT", and modify
681 * the DNTT to have that type code and point to the already-built entry.
685 if (index < LNTT_SYMCOUNT (objfile))
687 if (index >= TYPE_VECTOR_LENGTH (objfile))
689 old_len = TYPE_VECTOR_LENGTH (objfile);
691 /* See if we need to allocate a type-vector. */
694 TYPE_VECTOR_LENGTH (objfile) = LNTT_SYMCOUNT (objfile) + GNTT_SYMCOUNT (objfile);
695 TYPE_VECTOR (objfile) = (struct type **)
696 xmmalloc (objfile->md, TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *));
697 memset (&TYPE_VECTOR (objfile)[old_len], 0,
698 (TYPE_VECTOR_LENGTH (objfile) - old_len) *
699 sizeof (struct type *));
702 /* See if we need to resize type-vector. With my change to
703 * initially allocate a correct-size type-vector, this code
704 * should no longer trigger.
706 while (index >= TYPE_VECTOR_LENGTH (objfile))
708 TYPE_VECTOR_LENGTH (objfile) *= 2;
713 TYPE_VECTOR (objfile) = (struct type **)
714 xmrealloc (objfile->md,
715 (char *) TYPE_VECTOR (objfile),
716 (TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *)));
718 memset (&TYPE_VECTOR (objfile)[old_len], 0,
719 (TYPE_VECTOR_LENGTH (objfile) - old_len) *
720 sizeof (struct type *));
724 return &TYPE_VECTOR (objfile)[index];
730 /* Possibly allocate a GDB internal type so we can internalize HP_TYPE.
731 Note we'll just return the address of a GDB internal type if we already
732 have it lying around. */
735 hpread_alloc_type (hp_type, objfile)
737 struct objfile *objfile;
739 struct type **type_addr;
741 type_addr = hpread_lookup_type (hp_type, objfile);
744 *type_addr = alloc_type (objfile);
746 /* A hack - if we really are a C++ class symbol, then this default
747 * will get overriden later on.
749 TYPE_CPLUS_SPECIFIC (*type_addr)
750 = (struct cplus_struct_type *) &cplus_struct_default;
756 /* Read a native enumerated type and return it in GDB internal form. */
759 hpread_read_enum_type (hp_type, dn_bufp, objfile)
761 union dnttentry *dn_bufp;
762 struct objfile *objfile;
765 struct pending **symlist, *osyms, *syms;
766 struct pending *local_list = NULL;
767 int o_nsyms, nsyms = 0;
769 union dnttentry *memp;
774 /* Allocate a GDB type. If we've already read in this enum type,
775 * it'll return the already built GDB type, so stop here.
776 * (Note: I added this check, to conform with what's done for
777 * struct, union, class.
778 * I assume this is OK. - RT)
780 type = hpread_alloc_type (hp_type, objfile);
781 if (TYPE_CODE (type) == TYPE_CODE_ENUM)
784 /* HP C supports "sized enums", where a specifier such as "short" or
785 "char" can be used to get enums of different sizes. So don't assume
786 an enum is always 4 bytes long. pai/1997-08-21 */
787 TYPE_LENGTH (type) = dn_bufp->denum.bitlength / 8;
789 symlist = &file_symbols;
791 o_nsyms = osyms ? osyms->nsyms : 0;
793 /* Get a name for each member and add it to our list of members.
794 * The list of "mem" SOM records we are walking should all be
795 * SOM type DNTT_TYPE_MEMENUM (not checked).
797 mem = dn_bufp->denum.firstmem;
798 while (mem.word && mem.word != DNTTNIL)
800 memp = hpread_get_lntt (mem.dnttp.index, objfile);
802 name = VT (objfile) + memp->dmember.name;
803 sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
804 sizeof (struct symbol));
805 memset (sym, 0, sizeof (struct symbol));
806 SYMBOL_NAME (sym) = obsavestring (name, strlen (name),
807 &objfile->symbol_obstack);
808 SYMBOL_CLASS (sym) = LOC_CONST;
809 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
810 SYMBOL_VALUE (sym) = memp->dmember.value;
811 add_symbol_to_list (sym, symlist);
813 mem = memp->dmember.nextmem;
816 /* Now that we know more about the enum, fill in more info. */
817 TYPE_CODE (type) = TYPE_CODE_ENUM;
818 TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
819 TYPE_NFIELDS (type) = nsyms;
820 TYPE_FIELDS (type) = (struct field *)
821 obstack_alloc (&objfile->type_obstack, sizeof (struct field) * nsyms);
823 /* Find the symbols for the members and put them into the type.
824 The symbols can be found in the symlist that we put them on
825 to cause them to be defined. osyms contains the old value
826 of that symlist; everything up to there was defined by us.
828 Note that we preserve the order of the enum constants, so
829 that in something like "enum {FOO, LAST_THING=FOO}" we print
830 FOO, not LAST_THING. */
831 for (syms = *symlist, n = 0; syms; syms = syms->next)
836 for (; j < syms->nsyms; j++, n++)
838 struct symbol *xsym = syms->symbol[j];
839 SYMBOL_TYPE (xsym) = type;
840 TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym);
841 TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (xsym);
842 TYPE_FIELD_BITSIZE (type, n) = 0;
851 /* Read and internalize a native function debug symbol. */
854 hpread_read_function_type (hp_type, dn_bufp, objfile, newblock)
856 union dnttentry *dn_bufp;
857 struct objfile *objfile;
860 struct type *type, *type1;
861 struct pending *syms;
862 struct pending *local_list = NULL;
865 union dnttentry *paramp;
871 /* See if we've already read in this type. */
872 type = hpread_alloc_type (hp_type, objfile);
873 if (TYPE_CODE (type) == TYPE_CODE_FUNC)
875 record_args = 0; /* already read in, don't modify type */
879 /* Nope, so read it in and store it away. */
880 if (dn_bufp->dblock.kind == DNTT_TYPE_FUNCTION ||
881 dn_bufp->dblock.kind == DNTT_TYPE_MEMFUNC)
882 type1 = lookup_function_type (hpread_type_lookup (dn_bufp->dfunc.retval,
884 else if (dn_bufp->dblock.kind == DNTT_TYPE_FUNCTYPE)
885 type1 = lookup_function_type (hpread_type_lookup (dn_bufp->dfunctype.retval,
887 else /* expect DNTT_TYPE_FUNC_TEMPLATE */
888 type1 = lookup_function_type (hpread_type_lookup (dn_bufp->dfunc_template.retval,
890 memcpy ((char *) type, (char *) type1, sizeof (struct type));
892 /* Mark it -- in the middle of processing */
893 TYPE_FLAGS (type) |= TYPE_FLAG_INCOMPLETE;
896 /* Now examine each parameter noting its type, location, and a
897 wealth of other information. */
898 if (dn_bufp->dblock.kind == DNTT_TYPE_FUNCTION ||
899 dn_bufp->dblock.kind == DNTT_TYPE_MEMFUNC)
900 param = dn_bufp->dfunc.firstparam;
901 else if (dn_bufp->dblock.kind == DNTT_TYPE_FUNCTYPE)
902 param = dn_bufp->dfunctype.firstparam;
903 else /* expect DNTT_TYPE_FUNC_TEMPLATE */
904 param = dn_bufp->dfunc_template.firstparam;
905 while (param.word && param.word != DNTTNIL)
907 paramp = hpread_get_lntt (param.dnttp.index, objfile);
909 param = paramp->dfparam.nextparam;
912 name = VT (objfile) + paramp->dfparam.name;
913 sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
914 sizeof (struct symbol));
915 (void) memset (sym, 0, sizeof (struct symbol));
916 SYMBOL_NAME (sym) = obsavestring (name, strlen (name),
917 &objfile->symbol_obstack);
919 /* Figure out where it lives. */
920 if (paramp->dfparam.regparam)
921 SYMBOL_CLASS (sym) = LOC_REGPARM;
922 else if (paramp->dfparam.indirect)
923 SYMBOL_CLASS (sym) = LOC_REF_ARG;
925 SYMBOL_CLASS (sym) = LOC_ARG;
926 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
927 if (paramp->dfparam.copyparam)
929 SYMBOL_VALUE (sym) = paramp->dfparam.location;
930 #ifdef HPREAD_ADJUST_STACK_ADDRESS
932 += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile));
934 /* This is likely a pass-by-invisible reference parameter,
935 Hack on the symbol class to make GDB happy. */
936 /* ??rehrauer: This appears to be broken w/r/t to passing
937 C values of type float and struct. Perhaps this ought
938 to be highighted as a special case, but for now, just
939 allowing these to be LOC_ARGs seems to work fine.
942 SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
946 SYMBOL_VALUE (sym) = paramp->dfparam.location;
949 SYMBOL_TYPE (sym) = hpread_type_lookup (paramp->dfparam.type, objfile);
950 /* Add it to the symbol list. */
951 /* Note 1 (RT) At the moment, add_symbol_to_list() is also being
952 * called on FPARAM symbols from the process_one_debug_symbol()
953 * level... so parameters are getting added twice! (this shows
954 * up in the symbol dump you get from "maint print symbols ...").
955 * Note 2 (RT) I took out the processing of FPARAM from the
956 * process_one_debug_symbol() level, so at the moment parameters are only
957 * being processed here. This seems to have no ill effect.
959 /* Note 3 (pai/1997-08-11) I removed the add_symbol_to_list() which put
960 each fparam on the local_symbols list from here. Now we use the
961 local_list to which fparams are added below, and set the param_symbols
962 global to point to that at the end of this routine. */
963 /* elz: I added this new list of symbols which is local to the function.
964 this list is the one which is actually used to build the type for the
965 function rather than the gloabal list pointed to by symlist.
966 Using a global list to keep track of the parameters is wrong, because
967 this function is called recursively if one parameter happend to be
968 a function itself with more parameters in it. Adding parameters to the
969 same global symbol list would not work!
970 Actually it did work in case of cc compiled programs where you do
971 not check the parameter lists of the arguments. */
972 add_symbol_to_list (sym, &local_list);
976 /* If type was read in earlier, don't bother with modifying
981 /* Note how many parameters we found. */
982 TYPE_NFIELDS (type) = nsyms;
983 TYPE_FIELDS (type) = (struct field *)
984 obstack_alloc (&objfile->type_obstack,
985 sizeof (struct field) * nsyms);
987 /* Find the symbols for the parameters and
988 use them to fill parameter-type information into the function-type.
989 The parameter symbols can be found in the local_list that we just put them on. */
990 /* Note that we preserve the order of the parameters, so
991 that in something like "enum {FOO, LAST_THING=FOO}" we print
992 FOO, not LAST_THING. */
994 /* get the parameters types from the local list not the global list
995 so that the type can be correctly constructed for functions which
996 have function as parameters */
997 for (syms = local_list, n = 0; syms; syms = syms->next)
1000 for (j = 0; j < syms->nsyms; j++, n++)
1002 struct symbol *xsym = syms->symbol[j];
1003 TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym);
1004 TYPE_FIELD_TYPE (type, n) = SYMBOL_TYPE (xsym);
1005 TYPE_FIELD_BITPOS (type, n) = n;
1006 TYPE_FIELD_BITSIZE (type, n) = 0;
1009 /* Mark it as having been processed */
1010 TYPE_FLAGS (type) &= ~(TYPE_FLAG_INCOMPLETE);
1012 /* Check whether we need to fix-up a class type with this function's type */
1013 if (fixup_class && (fixup_method == type))
1015 fixup_class_method_type (fixup_class, fixup_method, objfile);
1017 fixup_method = NULL;
1020 /* Set the param list of this level of the context stack
1021 to our local list. Do this only if this function was
1022 called for creating a new block, and not if it was called
1023 simply to get the function type. This prevents recursive
1024 invocations from trashing param_symbols. */
1027 param_symbols = local_list;
1033 /* Read and internalize a native DOC function debug symbol. */
1034 /* This is almost identical to hpread_read_function_type(), except
1035 * for references to dn_bufp->ddocfunc instead of db_bufp->dfunc.
1036 * Since debug information for DOC functions is more likely to be
1037 * volatile, please leave it this way.
1039 static struct type *
1040 hpread_read_doc_function_type (hp_type, dn_bufp, objfile, newblock)
1041 dnttpointer hp_type;
1042 union dnttentry *dn_bufp;
1043 struct objfile *objfile;
1046 struct type *type, *type1;
1047 struct pending *syms;
1048 struct pending *local_list = NULL;
1051 union dnttentry *paramp;
1055 int record_args = 1;
1057 /* See if we've already read in this type. */
1058 type = hpread_alloc_type (hp_type, objfile);
1059 if (TYPE_CODE (type) == TYPE_CODE_FUNC)
1061 record_args = 0; /* already read in, don't modify type */
1065 /* Nope, so read it in and store it away. */
1066 if (dn_bufp->dblock.kind == DNTT_TYPE_DOC_FUNCTION ||
1067 dn_bufp->dblock.kind == DNTT_TYPE_DOC_MEMFUNC)
1068 type1 = lookup_function_type (hpread_type_lookup (dn_bufp->ddocfunc.retval,
1070 memcpy ((char *) type, (char *) type1, sizeof (struct type));
1072 /* Mark it -- in the middle of processing */
1073 TYPE_FLAGS (type) |= TYPE_FLAG_INCOMPLETE;
1076 /* Now examine each parameter noting its type, location, and a
1077 wealth of other information. */
1078 if (dn_bufp->dblock.kind == DNTT_TYPE_DOC_FUNCTION ||
1079 dn_bufp->dblock.kind == DNTT_TYPE_DOC_MEMFUNC)
1080 param = dn_bufp->ddocfunc.firstparam;
1081 while (param.word && param.word != DNTTNIL)
1083 paramp = hpread_get_lntt (param.dnttp.index, objfile);
1085 param = paramp->dfparam.nextparam;
1088 name = VT (objfile) + paramp->dfparam.name;
1089 sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
1090 sizeof (struct symbol));
1091 (void) memset (sym, 0, sizeof (struct symbol));
1092 SYMBOL_NAME (sym) = name;
1094 /* Figure out where it lives. */
1095 if (paramp->dfparam.regparam)
1096 SYMBOL_CLASS (sym) = LOC_REGPARM;
1097 else if (paramp->dfparam.indirect)
1098 SYMBOL_CLASS (sym) = LOC_REF_ARG;
1100 SYMBOL_CLASS (sym) = LOC_ARG;
1101 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1102 if (paramp->dfparam.copyparam)
1104 SYMBOL_VALUE (sym) = paramp->dfparam.location;
1105 #ifdef HPREAD_ADJUST_STACK_ADDRESS
1107 += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile));
1109 /* This is likely a pass-by-invisible reference parameter,
1110 Hack on the symbol class to make GDB happy. */
1111 /* ??rehrauer: This appears to be broken w/r/t to passing
1112 C values of type float and struct. Perhaps this ought
1113 to be highighted as a special case, but for now, just
1114 allowing these to be LOC_ARGs seems to work fine.
1117 SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
1121 SYMBOL_VALUE (sym) = paramp->dfparam.location;
1124 SYMBOL_TYPE (sym) = hpread_type_lookup (paramp->dfparam.type, objfile);
1125 /* Add it to the symbol list. */
1126 /* Note 1 (RT) At the moment, add_symbol_to_list() is also being
1127 * called on FPARAM symbols from the process_one_debug_symbol()
1128 * level... so parameters are getting added twice! (this shows
1129 * up in the symbol dump you get from "maint print symbols ...").
1130 * Note 2 (RT) I took out the processing of FPARAM from the
1131 * process_one_debug_symbol() level, so at the moment parameters are only
1132 * being processed here. This seems to have no ill effect.
1134 /* Note 3 (pai/1997-08-11) I removed the add_symbol_to_list() which put
1135 each fparam on the local_symbols list from here. Now we use the
1136 local_list to which fparams are added below, and set the param_symbols
1137 global to point to that at the end of this routine. */
1139 /* elz: I added this new list of symbols which is local to the function.
1140 this list is the one which is actually used to build the type for the
1141 function rather than the gloabal list pointed to by symlist.
1142 Using a global list to keep track of the parameters is wrong, because
1143 this function is called recursively if one parameter happend to be
1144 a function itself with more parameters in it. Adding parameters to the
1145 same global symbol list would not work!
1146 Actually it did work in case of cc compiled programs where you do not check the
1147 parameter lists of the arguments. */
1148 add_symbol_to_list (sym, &local_list);
1151 /* If type was read in earlier, don't bother with modifying
1156 /* Note how many parameters we found. */
1157 TYPE_NFIELDS (type) = nsyms;
1158 TYPE_FIELDS (type) = (struct field *)
1159 obstack_alloc (&objfile->type_obstack,
1160 sizeof (struct field) * nsyms);
1162 /* Find the symbols for the parameters and
1163 use them to fill parameter-type information into the function-type.
1164 The parameter symbols can be found in the local_list that we just put them on. */
1165 /* Note that we preserve the order of the parameters, so
1166 that in something like "enum {FOO, LAST_THING=FOO}" we print
1167 FOO, not LAST_THING. */
1169 /* get the parameters types from the local list not the global list
1170 so that the type can be correctly constructed for functions which
1171 have function as parameters
1173 for (syms = local_list, n = 0; syms; syms = syms->next)
1176 for (j = 0; j < syms->nsyms; j++, n++)
1178 struct symbol *xsym = syms->symbol[j];
1179 TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym);
1180 TYPE_FIELD_TYPE (type, n) = SYMBOL_TYPE (xsym);
1181 TYPE_FIELD_BITPOS (type, n) = n;
1182 TYPE_FIELD_BITSIZE (type, n) = 0;
1186 /* Mark it as having been processed */
1187 TYPE_FLAGS (type) &= ~(TYPE_FLAG_INCOMPLETE);
1189 /* Check whether we need to fix-up a class type with this function's type */
1190 if (fixup_class && (fixup_method == type))
1192 fixup_class_method_type (fixup_class, fixup_method, objfile);
1194 fixup_method = NULL;
1197 /* Set the param list of this level of the context stack
1198 to our local list. Do this only if this function was
1199 called for creating a new block, and not if it was called
1200 simply to get the function type. This prevents recursive
1201 invocations from trashing param_symbols. */
1204 param_symbols = local_list;
1211 /* A file-level variable which keeps track of the current-template
1212 * being processed. Set in hpread_read_struct_type() while processing
1213 * a template type. Referred to in hpread_get_nth_templ_arg().
1214 * Yes, this is a kludge, but it arises from the kludge that already
1215 * exists in symtab.h, namely the fact that they encode
1216 * "template argument n" with fundamental type FT_TEMPLATE_ARG and
1217 * bitlength n. This means that deep in processing fundamental types
1218 * I need to ask the question "what template am I in the middle of?".
1219 * The alternative to stuffing a global would be to pass an argument
1220 * down the chain of calls just for this purpose.
1222 * There may be problems handling nested templates... tough.
1224 static struct type *current_template = NULL;
1226 /* Read in and internalize a structure definition.
1227 * This same routine is called for struct, union, and class types.
1228 * Also called for templates, since they build a very similar
1229 * type entry as for class types.
1232 static struct type *
1233 hpread_read_struct_type (hp_type, dn_bufp, objfile)
1234 dnttpointer hp_type;
1235 union dnttentry *dn_bufp;
1236 struct objfile *objfile;
1238 /* The data members get linked together into a list of struct nextfield's */
1241 struct nextfield *next;
1243 unsigned char attributes; /* store visibility and virtuality info */
1244 #define ATTR_VIRTUAL 1
1245 #define ATTR_PRIVATE 2
1246 #define ATTR_PROTECT 3
1250 /* The methods get linked together into a list of struct next_fn_field's */
1251 struct next_fn_field
1253 struct next_fn_field *next;
1254 struct fn_fieldlist field;
1255 struct fn_field fn_field;
1259 /* The template args get linked together into a list of struct next_template's */
1260 struct next_template
1262 struct next_template *next;
1263 struct template_arg arg;
1266 /* The template instantiations get linked together into a list of these... */
1267 struct next_instantiation
1269 struct next_instantiation *next;
1274 struct type *baseclass;
1275 struct type *memtype;
1276 struct nextfield *list = 0, *tmp_list = 0;
1277 struct next_fn_field *fn_list = 0;
1278 struct next_fn_field *fn_p;
1279 struct next_template *t_new, *t_list = 0;
1280 struct nextfield *new;
1281 struct next_fn_field *fn_new;
1282 struct next_instantiation *i_new, *i_list = 0;
1283 int n, nfields = 0, n_fn_fields = 0, n_fn_fields_total = 0;
1284 int n_base_classes = 0, n_templ_args = 0;
1285 int ninstantiations = 0;
1286 dnttpointer field, fn_field, parent;
1287 union dnttentry *fieldp, *fn_fieldp, *parentp;
1289 int static_member = 0;
1290 int const_member = 0;
1291 int volatile_member = 0;
1292 unsigned long vtbl_offset;
1293 int need_bitvectors = 0;
1294 char *method_name = NULL;
1295 char *method_alias = NULL;
1298 /* Is it something we've already dealt with? */
1299 type = hpread_alloc_type (hp_type, objfile);
1300 if ((TYPE_CODE (type) == TYPE_CODE_STRUCT) ||
1301 (TYPE_CODE (type) == TYPE_CODE_UNION) ||
1302 (TYPE_CODE (type) == TYPE_CODE_CLASS) ||
1303 (TYPE_CODE (type) == TYPE_CODE_TEMPLATE))
1306 /* Get the basic type correct. */
1307 if (dn_bufp->dblock.kind == DNTT_TYPE_STRUCT)
1309 TYPE_CODE (type) = TYPE_CODE_STRUCT;
1310 TYPE_LENGTH (type) = dn_bufp->dstruct.bitlength / 8;
1312 else if (dn_bufp->dblock.kind == DNTT_TYPE_UNION)
1314 TYPE_CODE (type) = TYPE_CODE_UNION;
1315 TYPE_LENGTH (type) = dn_bufp->dunion.bitlength / 8;
1317 else if (dn_bufp->dblock.kind == DNTT_TYPE_CLASS)
1319 TYPE_CODE (type) = TYPE_CODE_CLASS;
1320 TYPE_LENGTH (type) = dn_bufp->dclass.bitlength / 8;
1322 /* Overrides the TYPE_CPLUS_SPECIFIC(type) with allocated memory
1323 * rather than &cplus_struct_default.
1325 allocate_cplus_struct_type (type);
1327 /* Fill in declared-type.
1328 * (The C++ compiler will emit TYPE_CODE_CLASS
1329 * for all 3 of "class", "struct"
1330 * "union", and we have to look at the "class_decl" field if we
1331 * want to know how it was really declared)
1333 /* (0==class, 1==union, 2==struct) */
1334 TYPE_DECLARED_TYPE (type) = dn_bufp->dclass.class_decl;
1336 else if (dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE)
1338 /* Get the basic type correct. */
1339 TYPE_CODE (type) = TYPE_CODE_TEMPLATE;
1340 allocate_cplus_struct_type (type);
1341 TYPE_DECLARED_TYPE (type) = DECLARED_TYPE_TEMPLATE;
1347 TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
1349 /* For classes, read the parent list.
1350 * Question (RT): Do we need to do this for templates also?
1352 if (dn_bufp->dblock.kind == DNTT_TYPE_CLASS)
1355 /* First read the parent-list (classes from which we derive fields) */
1356 parent = dn_bufp->dclass.parentlist;
1357 while (parent.word && parent.word != DNTTNIL)
1359 parentp = hpread_get_lntt (parent.dnttp.index, objfile);
1361 /* "parentp" should point to a DNTT_TYPE_INHERITANCE record */
1363 /* Get space to record the next field/data-member. */
1364 new = (struct nextfield *) alloca (sizeof (struct nextfield));
1368 FIELD_BITSIZE (list->field) = 0;
1370 /* The "classname" field is actually a DNTT pointer to the base class */
1371 baseclass = hpread_type_lookup (parentp->dinheritance.classname,
1373 FIELD_TYPE (list->field) = baseclass;
1375 list->field.name = type_name_no_tag (FIELD_TYPE (list->field));
1377 list->attributes = 0;
1379 /* Check for virtuality of base, and set the
1380 * offset of the base subobject within the object.
1381 * (Offset set to -1 for virtual bases (for now).)
1383 if (parentp->dinheritance.Virtual)
1385 B_SET (&(list->attributes), ATTR_VIRTUAL);
1386 parentp->dinheritance.offset = -1;
1389 FIELD_BITPOS (list->field) = parentp->dinheritance.offset;
1391 /* Check visibility */
1392 switch (parentp->dinheritance.visibility)
1395 B_SET (&(list->attributes), ATTR_PROTECT);
1398 B_SET (&(list->attributes), ATTR_PRIVATE);
1405 parent = parentp->dinheritance.next;
1409 /* For templates, read the template argument list.
1410 * This must be done before processing the member list, because
1411 * the member list may refer back to this. E.g.:
1412 * template <class T1, class T2> class q2 {
1417 * We need to read the argument list "T1", "T2" first.
1419 if (dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE)
1421 /* Kludge alert: This stuffs a global "current_template" which
1422 * is referred to by hpread_get_nth_templ_arg(). The global
1423 * is cleared at the end of this routine.
1425 current_template = type;
1427 /* Read in the argument list */
1428 field = dn_bufp->dtemplate.arglist;
1429 while (field.word && field.word != DNTTNIL)
1431 /* Get this template argument */
1432 fieldp = hpread_get_lntt (field.dnttp.index, objfile);
1433 if (fieldp->dblock.kind != DNTT_TYPE_TEMPLATE_ARG)
1435 warning ("Invalid debug info: Template argument entry is of wrong kind");
1438 /* Bump the count */
1440 /* Allocate and fill in a struct next_template */
1441 t_new = (struct next_template *) alloca (sizeof (struct next_template));
1442 t_new->next = t_list;
1444 t_list->arg.name = VT (objfile) + fieldp->dtempl_arg.name;
1445 t_list->arg.type = hpread_read_templ_arg_type (field, fieldp,
1446 objfile, t_list->arg.name);
1447 /* Walk to the next template argument */
1448 field = fieldp->dtempl_arg.nextarg;
1452 TYPE_NTEMPLATE_ARGS (type) = n_templ_args;
1454 if (n_templ_args > 0)
1455 TYPE_TEMPLATE_ARGS (type) = (struct template_arg *)
1456 obstack_alloc (&objfile->type_obstack, sizeof (struct template_arg) * n_templ_args);
1457 for (n = n_templ_args; t_list; t_list = t_list->next)
1460 TYPE_TEMPLATE_ARG (type, n) = t_list->arg;
1463 /* Next read in and internalize all the fields/members. */
1464 if (dn_bufp->dblock.kind == DNTT_TYPE_STRUCT)
1465 field = dn_bufp->dstruct.firstfield;
1466 else if (dn_bufp->dblock.kind == DNTT_TYPE_UNION)
1467 field = dn_bufp->dunion.firstfield;
1468 else if (dn_bufp->dblock.kind == DNTT_TYPE_CLASS)
1469 field = dn_bufp->dclass.memberlist;
1470 else if (dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE)
1471 field = dn_bufp->dtemplate.memberlist;
1473 field.word = DNTTNIL;
1475 while (field.word && field.word != DNTTNIL)
1477 fieldp = hpread_get_lntt (field.dnttp.index, objfile);
1479 /* At this point "fieldp" may point to either a DNTT_TYPE_FIELD
1480 * or a DNTT_TYPE_GENFIELD record.
1485 volatile_member = 0;
1487 if (fieldp->dblock.kind == DNTT_TYPE_GENFIELD)
1490 /* The type will be GENFIELD if the field is a method or
1491 * a static member (or some other cases -- see below)
1494 /* Follow a link to get to the record for the field. */
1495 fn_field = fieldp->dgenfield.field;
1496 fn_fieldp = hpread_get_lntt (fn_field.dnttp.index, objfile);
1498 /* Virtual funcs are indicated by a VFUNC which points to the
1501 if (fn_fieldp->dblock.kind == DNTT_TYPE_VFUNC)
1503 vtbl_offset = fn_fieldp->dvfunc.vtbl_offset;
1504 fn_field = fn_fieldp->dvfunc.funcptr;
1505 fn_fieldp = hpread_get_lntt (fn_field.dnttp.index, objfile);
1508 /* A function's entry may be preceded by a modifier which
1509 * labels it static/constant/volatile.
1511 if (fn_fieldp->dblock.kind == DNTT_TYPE_MODIFIER)
1513 static_member = fn_fieldp->dmodifier.m_static;
1514 const_member = fn_fieldp->dmodifier.m_const;
1515 volatile_member = fn_fieldp->dmodifier.m_volatile;
1516 fn_field = fn_fieldp->dmodifier.type;
1517 fn_fieldp = hpread_get_lntt (fn_field.dnttp.index, objfile);
1520 /* Check whether we have a method */
1521 if ((fn_fieldp->dblock.kind == DNTT_TYPE_MEMFUNC) ||
1522 (fn_fieldp->dblock.kind == DNTT_TYPE_FUNCTION) ||
1523 (fn_fieldp->dblock.kind == DNTT_TYPE_DOC_MEMFUNC) ||
1524 (fn_fieldp->dblock.kind == DNTT_TYPE_DOC_FUNCTION))
1530 /* Look up function type of method */
1531 memtype = hpread_type_lookup (fn_field, objfile);
1533 /* Methods can be seen before classes in the SOM records.
1534 If we are processing this class because it's a parameter of a
1535 method, at this point the method's type is actually incomplete;
1536 we'll have to fix it up later; mark the class for this. */
1538 if (TYPE_INCOMPLETE (memtype))
1540 TYPE_FLAGS (type) |= TYPE_FLAG_INCOMPLETE;
1542 warning ("Two classes to fix up for method?? Type information may be incorrect for some classes.");
1544 warning ("Two methods to be fixed up at once?? Type information may be incorrect for some classes.");
1545 fixup_class = type; /* remember this class has to be fixed up */
1546 fixup_method = memtype; /* remember the method type to be used in fixup */
1549 /* HP aCC generates operator names without the "operator" keyword, and
1550 generates null strings as names for operators that are
1551 user-defined type conversions to basic types (e.g. operator int ()).
1552 So try to reconstruct name as best as possible. */
1554 method_name = (char *) (VT (objfile) + fn_fieldp->dfunc.name);
1555 method_alias = (char *) (VT (objfile) + fn_fieldp->dfunc.alias);
1557 if (!method_name || /* no name */
1558 !*method_name || /* or null name */
1559 cplus_mangle_opname (method_name, DMGL_ANSI)) /* or name is an operator like "<" */
1561 char *tmp_name = cplus_demangle (method_alias, DMGL_ANSI);
1562 char *op_string = strstr (tmp_name, "operator");
1563 method_name = xmalloc (strlen (op_string) + 1); /* don't overwrite VT! */
1564 strcpy (method_name, op_string);
1567 /* First check if a method of the same name has already been seen. */
1571 if (STREQ (fn_p->field.name, method_name))
1576 /* If no such method was found, allocate a new entry in the list */
1579 /* Get space to record this member function */
1580 /* Note: alloca used; this will disappear on routine exit */
1581 fn_new = (struct next_fn_field *) alloca (sizeof (struct next_fn_field));
1582 fn_new->next = fn_list;
1585 /* Fill in the fields of the struct nextfield */
1587 /* Record the (unmangled) method name */
1588 fn_list->field.name = method_name;
1589 /* Initial space for overloaded methods */
1590 /* Note: xmalloc is used; this will persist after this routine exits */
1591 fn_list->field.fn_fields = (struct fn_field *) xmalloc (5 * (sizeof (struct fn_field)));
1592 fn_list->field.length = 1; /* Init # of overloaded instances */
1593 fn_list->num_fn_fields = 5; /* # of entries for which space allocated */
1595 ix = 0; /* array index for fn_field */
1596 /* Bump the total count of the distinctly named methods */
1600 /* Another overloaded instance of an already seen method name */
1602 if (++(fn_p->field.length) > fn_p->num_fn_fields)
1604 /* Increase space allocated for overloaded instances */
1605 fn_p->field.fn_fields
1606 = (struct fn_field *) xrealloc (fn_p->field.fn_fields,
1607 (fn_p->num_fn_fields + 5) * sizeof (struct fn_field));
1608 fn_p->num_fn_fields += 5;
1610 ix = fn_p->field.length - 1; /* array index for fn_field */
1613 /* "physname" is intended to be the name of this overloaded instance. */
1614 if ((fn_fieldp->dfunc.language == HP_LANGUAGE_CPLUSPLUS) &&
1616 *method_alias) /* not a null string */
1617 fn_p->field.fn_fields[ix].physname = method_alias;
1619 fn_p->field.fn_fields[ix].physname = method_name;
1620 /* What's expected here is the function type */
1621 /* But mark it as NULL if the method was incompletely processed
1622 We'll fix this up later when the method is fully processed */
1623 if (TYPE_INCOMPLETE (memtype))
1625 fn_p->field.fn_fields[ix].type = NULL;
1626 fn_p->field.fn_fields[ix].args = NULL;
1630 fn_p->field.fn_fields[ix].type = memtype;
1632 /* The argument list */
1633 fn_p->field.fn_fields[ix].type->type_specific.arg_types =
1634 (struct type **) obstack_alloc (&objfile->type_obstack,
1635 sizeof (struct type *) * (memtype->nfields + 1));
1636 for (i = 0; i < memtype->nfields; i++)
1637 fn_p->field.fn_fields[ix].type->type_specific.arg_types[i] = memtype->fields[i].type;
1638 /* void termination */
1639 fn_p->field.fn_fields[ix].type->type_specific.arg_types[memtype->nfields] = builtin_type_void;
1641 /* pai: It's not clear why this args field has to be set. Perhaps
1642 * it should be eliminated entirely. */
1643 fn_p->field.fn_fields[ix].args =
1644 (struct type **) obstack_alloc (&objfile->type_obstack,
1645 sizeof (struct type *) * (memtype->nfields + 1));
1646 for (i = 0; i < memtype->nfields; i++)
1647 fn_p->field.fn_fields[ix].args[i] = memtype->fields[i].type;
1648 /* null-terminated, unlike arg_types above e */
1649 fn_p->field.fn_fields[ix].args[memtype->nfields] = NULL;
1651 /* For virtual functions, fill in the voffset field with the
1652 * virtual table offset. (This is just copied over from the
1653 * SOM record; not sure if it is what GDB expects here...).
1654 * But if the function is a static method, set it to 1.
1656 * Note that we have to add 1 because 1 indicates a static
1657 * method, and 0 indicates a non-static, non-virtual method */
1660 fn_p->field.fn_fields[ix].voffset = VOFFSET_STATIC;
1662 fn_p->field.fn_fields[ix].voffset = vtbl_offset ? vtbl_offset + 1 : 0;
1664 /* Also fill in the fcontext field with the current
1665 * class. (The latter isn't quite right: should be the baseclass
1666 * that defines the virtual function... Note we do have
1667 * a variable "baseclass" that we could stuff into the fcontext
1668 * field, but "baseclass" isn't necessarily right either,
1669 * since the virtual function could have been defined more
1670 * than one level up).
1673 if (vtbl_offset != 0)
1674 fn_p->field.fn_fields[ix].fcontext = type;
1676 fn_p->field.fn_fields[ix].fcontext = NULL;
1678 /* Other random fields pertaining to this method */
1679 fn_p->field.fn_fields[ix].is_const = const_member;
1680 fn_p->field.fn_fields[ix].is_volatile = volatile_member; /* ?? */
1681 switch (fieldp->dgenfield.visibility)
1684 fn_p->field.fn_fields[ix].is_protected = 1;
1685 fn_p->field.fn_fields[ix].is_private = 0;
1688 fn_p->field.fn_fields[ix].is_protected = 0;
1689 fn_p->field.fn_fields[ix].is_private = 1;
1691 default: /* public */
1692 fn_p->field.fn_fields[ix].is_protected = 0;
1693 fn_p->field.fn_fields[ix].is_private = 0;
1695 fn_p->field.fn_fields[ix].is_stub = 0;
1697 /* HP aCC emits both MEMFUNC and FUNCTION entries for a method;
1698 if the class points to the FUNCTION, there is usually separate
1699 code for the method; but if we have a MEMFUNC, the method has
1700 been inlined (and there is usually no FUNCTION entry)
1701 FIXME Not sure if this test is accurate. pai/1997-08-22 */
1702 if ((fn_fieldp->dblock.kind == DNTT_TYPE_MEMFUNC) ||
1703 (fn_fieldp->dblock.kind == DNTT_TYPE_DOC_MEMFUNC))
1704 fn_p->field.fn_fields[ix].is_inlined = 1;
1706 fn_p->field.fn_fields[ix].is_inlined = 0;
1708 fn_p->field.fn_fields[ix].dummy = 0;
1710 /* Bump the total count of the member functions */
1711 n_fn_fields_total++;
1714 else if (fn_fieldp->dblock.kind == DNTT_TYPE_SVAR)
1716 /* This case is for static data members of classes */
1718 /* pai:: FIXME -- check that "staticmem" bit is set */
1720 /* Get space to record this static member */
1721 new = (struct nextfield *) alloca (sizeof (struct nextfield));
1725 list->field.name = VT (objfile) + fn_fieldp->dsvar.name;
1726 FIELD_BITSIZE (list->field) = -1; /* indicates static member */
1727 SET_FIELD_PHYSNAME (list->field, 0); /* initialize to empty */
1728 memtype = hpread_type_lookup (fn_fieldp->dsvar.type, objfile);
1730 FIELD_TYPE (list->field) = memtype;
1731 list->attributes = 0;
1732 switch (fieldp->dgenfield.visibility)
1735 B_SET (&(list->attributes), ATTR_PROTECT);
1738 B_SET (&(list->attributes), ATTR_PRIVATE);
1744 else if (fn_fieldp->dblock.kind == DNTT_TYPE_FIELD)
1746 /* FIELDs follow GENFIELDs for fields of anonymous unions.
1747 Code below is replicated from the case for FIELDs further
1748 below, except that fieldp is replaced by fn_fieldp */
1749 if (!fn_fieldp->dfield.a_union)
1750 warning ("Debug info inconsistent: FIELD of anonymous union doesn't have a_union bit set");
1751 /* Get space to record the next field/data-member. */
1752 new = (struct nextfield *) alloca (sizeof (struct nextfield));
1756 list->field.name = VT (objfile) + fn_fieldp->dfield.name;
1757 FIELD_BITPOS (list->field) = fn_fieldp->dfield.bitoffset;
1758 if (fn_fieldp->dfield.bitlength % 8)
1759 list->field.bitsize = fn_fieldp->dfield.bitlength;
1761 list->field.bitsize = 0;
1763 memtype = hpread_type_lookup (fn_fieldp->dfield.type, objfile);
1764 list->field.type = memtype;
1765 list->attributes = 0;
1766 switch (fn_fieldp->dfield.visibility)
1769 B_SET (&(list->attributes), ATTR_PROTECT);
1772 B_SET (&(list->attributes), ATTR_PRIVATE);
1777 else if (fn_fieldp->dblock.kind == DNTT_TYPE_SVAR)
1779 /* Field of anonymous union; union is not inside a class */
1780 if (!fn_fieldp->dsvar.a_union)
1781 warning ("Debug info inconsistent: SVAR field in anonymous union doesn't have a_union bit set");
1782 /* Get space to record the next field/data-member. */
1783 new = (struct nextfield *) alloca (sizeof (struct nextfield));
1787 list->field.name = VT (objfile) + fn_fieldp->dsvar.name;
1788 FIELD_BITPOS (list->field) = 0; /* FIXME is this always true? */
1789 FIELD_BITSIZE (list->field) = 0; /* use length from type */
1790 memtype = hpread_type_lookup (fn_fieldp->dsvar.type, objfile);
1791 list->field.type = memtype;
1792 list->attributes = 0;
1793 /* No info to set visibility -- always public */
1796 else if (fn_fieldp->dblock.kind == DNTT_TYPE_DVAR)
1798 /* Field of anonymous union; union is not inside a class */
1799 if (!fn_fieldp->ddvar.a_union)
1800 warning ("Debug info inconsistent: DVAR field in anonymous union doesn't have a_union bit set");
1801 /* Get space to record the next field/data-member. */
1802 new = (struct nextfield *) alloca (sizeof (struct nextfield));
1806 list->field.name = VT (objfile) + fn_fieldp->ddvar.name;
1807 FIELD_BITPOS (list->field) = 0; /* FIXME is this always true? */
1808 FIELD_BITSIZE (list->field) = 0; /* use length from type */
1809 memtype = hpread_type_lookup (fn_fieldp->ddvar.type, objfile);
1810 list->field.type = memtype;
1811 list->attributes = 0;
1812 /* No info to set visibility -- always public */
1816 { /* Not a method, nor a static data member, nor an anon union field */
1818 /* This case is for miscellaneous type entries (local enums,
1819 local function templates, etc.) that can be present
1822 /* Enums -- will be handled by other code that takes care
1823 of DNTT_TYPE_ENUM; here we see only DNTT_TYPE_MEMENUM so
1824 it's not clear we could have handled them here at all. */
1825 /* FUNC_TEMPLATE: is handled by other code (??). */
1826 /* MEMACCESS: modified access for inherited member. Not
1827 sure what to do with this, ignoriing it at present. */
1829 /* What other entries can appear following a GENFIELD which
1830 we do not handle above? (MODIFIER, VFUNC handled above.) */
1832 if ((fn_fieldp->dblock.kind != DNTT_TYPE_MEMACCESS) &&
1833 (fn_fieldp->dblock.kind != DNTT_TYPE_MEMENUM) &&
1834 (fn_fieldp->dblock.kind != DNTT_TYPE_FUNC_TEMPLATE))
1835 warning ("Internal error: Unexpected debug record kind %d found following DNTT_GENFIELD",
1836 fn_fieldp->dblock.kind);
1838 /* walk to the next FIELD or GENFIELD */
1839 field = fieldp->dgenfield.nextfield;
1842 else if (fieldp->dblock.kind == DNTT_TYPE_FIELD)
1845 /* Ordinary structure/union/class field */
1846 struct type *anon_union_type;
1848 /* Get space to record the next field/data-member. */
1849 new = (struct nextfield *) alloca (sizeof (struct nextfield));
1853 list->field.name = VT (objfile) + fieldp->dfield.name;
1856 /* A FIELD by itself (without a GENFIELD) can also be a static member */
1857 if (fieldp->dfield.staticmem)
1859 FIELD_BITPOS (list->field) = -1;
1860 FIELD_BITSIZE (list->field) = 0;
1863 /* Non-static data member */
1865 FIELD_BITPOS (list->field) = fieldp->dfield.bitoffset;
1866 if (fieldp->dfield.bitlength % 8)
1867 FIELD_BITSIZE (list->field) = fieldp->dfield.bitlength;
1869 FIELD_BITSIZE (list->field) = 0;
1872 memtype = hpread_type_lookup (fieldp->dfield.type, objfile);
1873 FIELD_TYPE (list->field) = memtype;
1874 list->attributes = 0;
1875 switch (fieldp->dfield.visibility)
1878 B_SET (&(list->attributes), ATTR_PROTECT);
1881 B_SET (&(list->attributes), ATTR_PRIVATE);
1887 /* Note 1: First, we have to check if the current field is an anonymous
1888 union. If it is, then *its* fields are threaded along in the
1889 nextfield chain. :-( This was supposed to help debuggers, but is
1890 really just a nuisance since we deal with anonymous unions anyway by
1891 checking that the name is null. So anyway, we skip over the fields
1892 of the anonymous union. pai/1997-08-22 */
1893 /* Note 2: In addition, the bitoffsets for the fields of the anon union
1894 are relative to the enclosing struct, *NOT* relative to the anon
1895 union! This is an even bigger nuisance -- we have to go in and munge
1896 the anon union's type information appropriately. pai/1997-08-22 */
1898 /* Both tasks noted above are done by a separate function. This takes us
1899 to the next FIELD or GENFIELD, skipping anon unions, and recursively
1900 processing intermediate types. */
1901 field = hpread_get_next_skip_over_anon_unions (1, field, &fieldp, objfile);
1906 /* neither field nor genfield ?? is this possible?? */
1907 /* pai:: FIXME walk to the next -- how? */
1908 warning ("Internal error: unexpected DNTT kind %d encountered as field of struct");
1909 warning ("Skipping remaining fields of struct");
1910 break; /* get out of loop of fields */
1914 /* If it's a template, read in the instantiation list */
1915 if (dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE)
1917 ninstantiations = 0;
1918 field = dn_bufp->dtemplate.expansions;
1919 while (field.word && field.word != DNTTNIL)
1921 fieldp = hpread_get_lntt (field.dnttp.index, objfile);
1923 /* The expansions or nextexp should point to a tagdef */
1924 if (fieldp->dblock.kind != DNTT_TYPE_TAGDEF)
1927 i_new = (struct next_instantiation *) alloca (sizeof (struct next_instantiation));
1928 i_new->next = i_list;
1930 i_list->t = hpread_type_lookup (field, objfile);
1933 /* And the "type" field of that should point to a class */
1934 field = fieldp->dtag.type;
1935 fieldp = hpread_get_lntt (field.dnttp.index, objfile);
1936 if (fieldp->dblock.kind != DNTT_TYPE_CLASS)
1939 /* Get the next expansion */
1940 field = fieldp->dclass.nextexp;
1943 TYPE_NINSTANTIATIONS (type) = ninstantiations;
1944 if (ninstantiations > 0)
1945 TYPE_INSTANTIATIONS (type) = (struct type **)
1946 obstack_alloc (&objfile->type_obstack, sizeof (struct type *) * ninstantiations);
1947 for (n = ninstantiations; i_list; i_list = i_list->next)
1950 TYPE_INSTANTIATION (type, n) = i_list->t;
1954 /* Copy the field-list to GDB's symbol table */
1955 TYPE_NFIELDS (type) = nfields;
1956 TYPE_N_BASECLASSES (type) = n_base_classes;
1957 TYPE_FIELDS (type) = (struct field *)
1958 obstack_alloc (&objfile->type_obstack, sizeof (struct field) * nfields);
1959 /* Copy the saved-up fields into the field vector. */
1960 for (n = nfields, tmp_list = list; tmp_list; tmp_list = tmp_list->next)
1963 TYPE_FIELD (type, n) = tmp_list->field;
1966 /* Copy the "function-field-list" (i.e., the list of member
1967 * functions in the class) to GDB's symbol table
1969 TYPE_NFN_FIELDS (type) = n_fn_fields;
1970 TYPE_NFN_FIELDS_TOTAL (type) = n_fn_fields_total;
1971 TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *)
1972 obstack_alloc (&objfile->type_obstack, sizeof (struct fn_fieldlist) * n_fn_fields);
1973 for (n = n_fn_fields; fn_list; fn_list = fn_list->next)
1976 TYPE_FN_FIELDLIST (type, n) = fn_list->field;
1979 /* pai:: FIXME -- perhaps each bitvector should be created individually */
1980 for (n = nfields, tmp_list = list; tmp_list; tmp_list = tmp_list->next)
1983 if (tmp_list->attributes)
1985 need_bitvectors = 1;
1990 if (need_bitvectors)
1992 /* pai:: this step probably redundant */
1993 ALLOCATE_CPLUS_STRUCT_TYPE (type);
1995 TYPE_FIELD_VIRTUAL_BITS (type) =
1996 (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
1997 B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), nfields);
1999 TYPE_FIELD_PRIVATE_BITS (type) =
2000 (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
2001 B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type), nfields);
2003 TYPE_FIELD_PROTECTED_BITS (type) =
2004 (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
2005 B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type), nfields);
2007 /* this field vector isn't actually used with HP aCC */
2008 TYPE_FIELD_IGNORE_BITS (type) =
2009 (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
2010 B_CLRALL (TYPE_FIELD_IGNORE_BITS (type), nfields);
2012 while (nfields-- > 0)
2014 if (B_TST (&(list->attributes), ATTR_VIRTUAL))
2015 SET_TYPE_FIELD_VIRTUAL (type, nfields);
2016 if (B_TST (&(list->attributes), ATTR_PRIVATE))
2017 SET_TYPE_FIELD_PRIVATE (type, nfields);
2018 if (B_TST (&(list->attributes), ATTR_PROTECT))
2019 SET_TYPE_FIELD_PROTECTED (type, nfields);
2026 TYPE_FIELD_VIRTUAL_BITS (type) = NULL;
2027 TYPE_FIELD_PROTECTED_BITS (type) = NULL;
2028 TYPE_FIELD_PRIVATE_BITS (type) = NULL;
2031 if (has_vtable (type))
2033 /* Allocate space for class runtime information */
2034 TYPE_RUNTIME_PTR (type) = (struct runtime_info *) xmalloc (sizeof (struct runtime_info));
2035 /* Set flag for vtable */
2036 TYPE_VTABLE (type) = 1;
2037 /* The first non-virtual base class with a vtable. */
2038 TYPE_PRIMARY_BASE (type) = primary_base_class (type);
2039 /* The virtual base list. */
2040 TYPE_VIRTUAL_BASE_LIST (type) = virtual_base_list (type);
2043 TYPE_RUNTIME_PTR (type) = NULL;
2045 /* If this is a local type (C++ - declared inside a function), record file name & line # */
2046 if (hpread_get_scope_depth (dn_bufp, objfile, 1 /* no need for real depth */ ))
2048 TYPE_LOCALTYPE_PTR (type) = (struct local_type_info *) xmalloc (sizeof (struct local_type_info));
2049 TYPE_LOCALTYPE_FILE (type) = (char *) xmalloc (strlen (current_subfile->name) + 1);
2050 strcpy (TYPE_LOCALTYPE_FILE (type), current_subfile->name);
2051 if (current_subfile->line_vector && (current_subfile->line_vector->nitems > 0))
2052 TYPE_LOCALTYPE_LINE (type) = current_subfile->line_vector->item[current_subfile->line_vector->nitems - 1].line;
2054 TYPE_LOCALTYPE_LINE (type) = 0;
2057 TYPE_LOCALTYPE_PTR (type) = NULL;
2059 /* Clear the global saying what template we are in the middle of processing */
2060 current_template = NULL;
2065 /* Adjust the physnames for each static member of a struct
2066 or class type to be something like "A::x"; then various
2067 other pieces of code that do a lookup_symbol on the phyname
2069 TYPE is a pointer to the struct/class type
2070 NAME is a char * (string) which is the class/struct name
2074 fix_static_member_physnames (type, class_name, objfile)
2077 struct objfile *objfile;
2081 /* We fix the member names only for classes or structs */
2082 if (TYPE_CODE (type) != TYPE_CODE_STRUCT)
2085 for (i = 0; i < TYPE_NFIELDS (type); i++)
2086 if (TYPE_FIELD_STATIC (type, i))
2088 if (TYPE_FIELD_STATIC_PHYSNAME (type, i))
2089 return; /* physnames are already set */
2091 SET_FIELD_PHYSNAME (type->fields[i],
2092 obstack_alloc (&objfile->type_obstack,
2093 strlen (class_name) + strlen (TYPE_FIELD_NAME (type, i)) + 3));
2094 strcpy (TYPE_FIELD_STATIC_PHYSNAME (type, i), class_name);
2095 strcat (TYPE_FIELD_STATIC_PHYSNAME (type, i), "::");
2096 strcat (TYPE_FIELD_STATIC_PHYSNAME (type, i), TYPE_FIELD_NAME (type, i));
2100 /* Fix-up the type structure for a CLASS so that the type entry
2101 * for a method (previously marked with a null type in hpread_read_struct_type()
2102 * is set correctly to METHOD.
2103 * OBJFILE is as for other such functions.
2107 fixup_class_method_type (class, method, objfile)
2109 struct type *method;
2110 struct objfile *objfile;
2114 if (!class || !method || !objfile)
2117 /* Only for types that have methods */
2118 if ((TYPE_CODE (class) != TYPE_CODE_CLASS) &&
2119 (TYPE_CODE (class) != TYPE_CODE_UNION))
2122 /* Loop over all methods and find the one marked with a NULL type */
2123 for (i = 0; i < TYPE_NFN_FIELDS (class); i++)
2124 for (j = 0; j < TYPE_FN_FIELDLIST_LENGTH (class, i); j++)
2125 if (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j) == NULL)
2127 /* Set the method type */
2128 TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j) = method;
2129 /* The argument list */
2130 (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j))->type_specific.arg_types
2131 = (struct type **) obstack_alloc (&objfile->type_obstack,
2132 sizeof (struct type *) * (method->nfields + 1));
2133 for (k = 0; k < method->nfields; k++)
2134 (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j))->type_specific.arg_types[k] = method->fields[k].type;
2135 /* void termination */
2136 (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j))->type_specific.arg_types[method->nfields] = builtin_type_void;
2138 /* pai: It's not clear why this args field has to be set. Perhaps
2139 * it should be eliminated entirely. */
2140 (TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i), j)).args
2141 = (struct type **) obstack_alloc (&objfile->type_obstack,
2142 sizeof (struct type *) * (method->nfields + 1));
2143 for (k = 0; k < method->nfields; k++)
2144 (TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i), j)).args[k] = method->fields[k].type;
2145 /* null-terminated, unlike arg_types above */
2146 (TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i), j)).args[method->nfields] = NULL;
2148 /* Break out of both loops -- only one method to fix up in a class */
2153 TYPE_FLAGS (class) &= ~TYPE_FLAG_INCOMPLETE;
2157 /* If we're in the middle of processing a template, get a pointer
2158 * to the Nth template argument.
2159 * An example may make this clearer:
2160 * template <class T1, class T2> class q2 {
2165 * The type for "a" will be "first template arg" and
2166 * the type for "b" will be "second template arg".
2167 * We need to look these up in order to fill in "a" and "b"'s type.
2168 * This is called from hpread_type_lookup().
2170 static struct type *
2171 hpread_get_nth_template_arg (objfile, n)
2172 struct objfile *objfile;
2175 if (current_template != NULL)
2176 return TYPE_TEMPLATE_ARG (current_template, n).type;
2178 return lookup_fundamental_type (objfile, FT_TEMPLATE_ARG);
2181 /* Read in and internalize a TEMPL_ARG (template arg) symbol. */
2183 static struct type *
2184 hpread_read_templ_arg_type (hp_type, dn_bufp, objfile, name)
2185 dnttpointer hp_type;
2186 union dnttentry *dn_bufp;
2187 struct objfile *objfile;
2192 /* See if it's something we've already deal with. */
2193 type = hpread_alloc_type (hp_type, objfile);
2194 if (TYPE_CODE (type) == TYPE_CODE_TEMPLATE_ARG)
2197 /* Nope. Fill in the appropriate fields. */
2198 TYPE_CODE (type) = TYPE_CODE_TEMPLATE_ARG;
2199 TYPE_LENGTH (type) = 0;
2200 TYPE_NFIELDS (type) = 0;
2201 TYPE_NAME (type) = name;
2205 /* Read in and internalize a set debug symbol. */
2207 static struct type *
2208 hpread_read_set_type (hp_type, dn_bufp, objfile)
2209 dnttpointer hp_type;
2210 union dnttentry *dn_bufp;
2211 struct objfile *objfile;
2215 /* See if it's something we've already deal with. */
2216 type = hpread_alloc_type (hp_type, objfile);
2217 if (TYPE_CODE (type) == TYPE_CODE_SET)
2220 /* Nope. Fill in the appropriate fields. */
2221 TYPE_CODE (type) = TYPE_CODE_SET;
2222 TYPE_LENGTH (type) = dn_bufp->dset.bitlength / 8;
2223 TYPE_NFIELDS (type) = 0;
2224 TYPE_TARGET_TYPE (type) = hpread_type_lookup (dn_bufp->dset.subtype,
2229 /* Read in and internalize an array debug symbol. */
2231 static struct type *
2232 hpread_read_array_type (hp_type, dn_bufp, objfile)
2233 dnttpointer hp_type;
2234 union dnttentry *dn_bufp;
2235 struct objfile *objfile;
2239 /* Allocate an array type symbol.
2240 * Why no check for already-read here, like in the other
2241 * hpread_read_xxx_type routines? Because it kept us
2242 * from properly determining the size of the array!
2244 type = hpread_alloc_type (hp_type, objfile);
2246 TYPE_CODE (type) = TYPE_CODE_ARRAY;
2248 /* Although the hp-symtab.h does not *require* this to be the case,
2249 * GDB is assuming that "arrayisbytes" and "elemisbytes" be consistent.
2250 * I.e., express both array-length and element-length in bits,
2251 * or express both array-length and element-length in bytes.
2253 if (!((dn_bufp->darray.arrayisbytes && dn_bufp->darray.elemisbytes) ||
2254 (!dn_bufp->darray.arrayisbytes && !dn_bufp->darray.elemisbytes)))
2256 warning ("error in hpread_array_type.\n");
2259 else if (dn_bufp->darray.arraylength == 0x7fffffff)
2261 /* The HP debug format represents char foo[]; as an array with
2262 * length 0x7fffffff. Internally GDB wants to represent this
2263 * as an array of length zero.
2265 TYPE_LENGTH (type) = 0;
2267 else if (dn_bufp->darray.arrayisbytes)
2268 TYPE_LENGTH (type) = dn_bufp->darray.arraylength;
2269 else /* arraylength is in bits */
2270 TYPE_LENGTH (type) = dn_bufp->darray.arraylength / 8;
2272 TYPE_TARGET_TYPE (type) = hpread_type_lookup (dn_bufp->darray.elemtype,
2275 /* The one "field" is used to store the subscript type */
2276 /* Since C and C++ multi-dimensional arrays are simply represented
2277 * as: array of array of ..., we only need one subscript-type
2278 * per array. This subscript type is typically a subrange of integer.
2279 * If this gets extended to support languages like Pascal, then
2280 * we need to fix this to represent multi-dimensional arrays properly.
2282 TYPE_NFIELDS (type) = 1;
2283 TYPE_FIELDS (type) = (struct field *)
2284 obstack_alloc (&objfile->type_obstack, sizeof (struct field));
2285 TYPE_FIELD_TYPE (type, 0) = hpread_type_lookup (dn_bufp->darray.indextype,
2290 /* Read in and internalize a subrange debug symbol. */
2291 static struct type *
2292 hpread_read_subrange_type (hp_type, dn_bufp, objfile)
2293 dnttpointer hp_type;
2294 union dnttentry *dn_bufp;
2295 struct objfile *objfile;
2299 /* Is it something we've already dealt with. */
2300 type = hpread_alloc_type (hp_type, objfile);
2301 if (TYPE_CODE (type) == TYPE_CODE_RANGE)
2304 /* Nope, internalize it. */
2305 TYPE_CODE (type) = TYPE_CODE_RANGE;
2306 TYPE_LENGTH (type) = dn_bufp->dsubr.bitlength / 8;
2307 TYPE_NFIELDS (type) = 2;
2309 = (struct field *) obstack_alloc (&objfile->type_obstack,
2310 2 * sizeof (struct field));
2312 if (dn_bufp->dsubr.dyn_low)
2313 TYPE_FIELD_BITPOS (type, 0) = 0;
2315 TYPE_FIELD_BITPOS (type, 0) = dn_bufp->dsubr.lowbound;
2317 if (dn_bufp->dsubr.dyn_high)
2318 TYPE_FIELD_BITPOS (type, 1) = -1;
2320 TYPE_FIELD_BITPOS (type, 1) = dn_bufp->dsubr.highbound;
2321 TYPE_TARGET_TYPE (type) = hpread_type_lookup (dn_bufp->dsubr.subtype,
2326 /* struct type * hpread_type_lookup(hp_type, objfile)
2328 * hp_type: A pointer into the DNTT specifying what type we
2329 * are about to "look up"., or else [for fundamental types
2330 * like int, float, ...] an "immediate" structure describing
2333 * Return value: A pointer to a "struct type" (representation of a
2334 * type in GDB's internal symbol table - see gdbtypes.h)
2335 * Routine description:
2336 * There are a variety of places when scanning the DNTT when we
2337 * need to interpret a "type" field. The simplest and most basic
2338 * example is when we're processing the symbol table record
2339 * for a data symbol (a SVAR or DVAR record). That has
2340 * a "type" field specifying the type of the data symbol. That
2341 * "type" field is either an "immediate" type specification (for the
2342 * fundamental types) or a DNTT pointer (for more complicated types).
2343 * For the more complicated types, we may or may not have already
2344 * processed the pointed-to type. (Multiple data symbols can of course
2345 * share the same type).
2346 * The job of hpread_type_lookup() is to process this "type" field.
2347 * Most of the real work is done in subroutines. Here we interpret
2348 * the immediate flag. If not immediate, chase the DNTT pointer to
2349 * find our way to the SOM record describing the type, switch on
2350 * the SOM kind, and then call an appropriate subroutine depending
2351 * on what kind of type we are constructing. (e.g., an array type,
2352 * a struct/class type, etc).
2354 static struct type *
2355 hpread_type_lookup (hp_type, objfile)
2356 dnttpointer hp_type;
2357 struct objfile *objfile;
2359 union dnttentry *dn_bufp;
2360 struct type *tmp_type;
2362 /* First see if it's a simple builtin type. */
2363 if (hp_type.dntti.immediate)
2364 /* If this is a template argument, the argument number is
2365 * encoded in the bitlength. All other cases, just return
2366 * GDB's representation of this fundamental type.
2368 if (hp_type.dntti.type == HP_TYPE_TEMPLATE_ARG)
2369 return hpread_get_nth_template_arg (objfile, hp_type.dntti.bitlength);
2371 return lookup_fundamental_type (objfile, hpread_type_translate (hp_type));
2373 /* Not a builtin type. We'll have to read it in. */
2374 if (hp_type.dnttp.index < LNTT_SYMCOUNT (objfile))
2375 dn_bufp = hpread_get_lntt (hp_type.dnttp.index, objfile);
2377 /* This is a fancy way of returning NULL */
2378 return lookup_fundamental_type (objfile, FT_VOID);
2380 switch (dn_bufp->dblock.kind)
2382 case DNTT_TYPE_SRCFILE:
2383 case DNTT_TYPE_MODULE:
2384 case DNTT_TYPE_ENTRY:
2385 case DNTT_TYPE_BEGIN:
2387 case DNTT_TYPE_IMPORT:
2388 case DNTT_TYPE_LABEL:
2389 case DNTT_TYPE_FPARAM:
2390 case DNTT_TYPE_SVAR:
2391 case DNTT_TYPE_DVAR:
2392 case DNTT_TYPE_CONST:
2393 case DNTT_TYPE_MEMENUM:
2394 case DNTT_TYPE_VARIANT:
2395 case DNTT_TYPE_FILE:
2396 case DNTT_TYPE_WITH:
2397 case DNTT_TYPE_COMMON:
2398 case DNTT_TYPE_COBSTRUCT:
2399 case DNTT_TYPE_XREF:
2401 case DNTT_TYPE_MACRO:
2402 case DNTT_TYPE_BLOCKDATA:
2403 case DNTT_TYPE_CLASS_SCOPE:
2404 case DNTT_TYPE_MEMACCESS:
2405 case DNTT_TYPE_INHERITANCE:
2406 case DNTT_TYPE_OBJECT_ID:
2407 case DNTT_TYPE_FRIEND_CLASS:
2408 case DNTT_TYPE_FRIEND_FUNC:
2409 /* These are not types - something went wrong. */
2410 /* This is a fancy way of returning NULL */
2411 return lookup_fundamental_type (objfile, FT_VOID);
2413 case DNTT_TYPE_FUNCTION:
2414 /* We wind up here when dealing with class member functions
2415 * (called from hpread_read_struct_type(), i.e. when processing
2416 * the class definition itself).
2418 return hpread_read_function_type (hp_type, dn_bufp, objfile, 0);
2420 case DNTT_TYPE_DOC_FUNCTION:
2421 return hpread_read_doc_function_type (hp_type, dn_bufp, objfile, 0);
2423 case DNTT_TYPE_TYPEDEF:
2425 /* A typedef - chase it down by making a recursive call */
2426 struct type *structtype = hpread_type_lookup (dn_bufp->dtype.type,
2429 /* The following came from the base hpread.c that we inherited.
2430 * It is WRONG so I have commented it out. - RT
2434 suffix = VT (objfile) + dn_bufp->dtype.name;
2435 TYPE_NAME (structtype) = suffix;
2437 * ... further explanation ....
2439 * What we have here is a typedef pointing to a typedef.
2444 * What we desire to build is (these are pictures
2445 * of "struct type"'s):
2447 * +---------+ +----------+ +------------+
2448 * | typedef | | typedef | | fund. type |
2449 * | type| -> | type| -> | |
2450 * | "fum" | | "foo" | | "int" |
2451 * +---------+ +----------+ +------------+
2453 * What this commented-out code is doing is smashing the
2454 * name of pointed-to-type to be the same as the pointed-from
2455 * type. So we wind up with something like:
2457 * +---------+ +----------+ +------------+
2458 * | typedef | | typedef | | fund. type |
2459 * | type| -> | type| -> | |
2460 * | "fum" | | "fum" | | "fum" |
2461 * +---------+ +----------+ +------------+
2468 case DNTT_TYPE_TAGDEF:
2470 /* Just a little different from above. We have to tack on
2471 * an identifier of some kind (struct, union, enum, class, etc).
2473 struct type *structtype = hpread_type_lookup (dn_bufp->dtype.type,
2475 char *prefix, *suffix;
2476 suffix = VT (objfile) + dn_bufp->dtype.name;
2478 /* Lookup the next type in the list. It should be a structure,
2479 * union, class, enum, or template type.
2480 * We will need to attach that to our name.
2482 if (dn_bufp->dtype.type.dnttp.index < LNTT_SYMCOUNT (objfile))
2483 dn_bufp = hpread_get_lntt (dn_bufp->dtype.type.dnttp.index, objfile);
2486 complain (&hpread_type_lookup_complaint);
2490 if (dn_bufp->dblock.kind == DNTT_TYPE_STRUCT)
2494 else if (dn_bufp->dblock.kind == DNTT_TYPE_UNION)
2498 else if (dn_bufp->dblock.kind == DNTT_TYPE_CLASS)
2500 /* Further field for CLASS saying how it was really declared */
2501 /* 0==class, 1==union, 2==struct */
2502 if (dn_bufp->dclass.class_decl == 0)
2504 else if (dn_bufp->dclass.class_decl == 1)
2506 else if (dn_bufp->dclass.class_decl == 2)
2511 else if (dn_bufp->dblock.kind == DNTT_TYPE_ENUM)
2515 else if (dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE)
2517 prefix = "template ";
2524 /* Build the correct name. */
2526 = (char *) obstack_alloc (&objfile->type_obstack,
2527 strlen (prefix) + strlen (suffix) + 1);
2528 TYPE_NAME (structtype) = strcpy (TYPE_NAME (structtype), prefix);
2529 TYPE_NAME (structtype) = strcat (TYPE_NAME (structtype), suffix);
2530 TYPE_TAG_NAME (structtype) = suffix;
2532 /* For classes/structs, we have to set the static member "physnames"
2533 to point to strings like "Class::Member" */
2534 if (TYPE_CODE (structtype) == TYPE_CODE_STRUCT)
2535 fix_static_member_physnames (structtype, suffix, objfile);
2540 case DNTT_TYPE_POINTER:
2541 /* Pointer type - call a routine in gdbtypes.c that constructs
2542 * the appropriate GDB type.
2544 return make_pointer_type (
2545 hpread_type_lookup (dn_bufp->dptr.pointsto,
2549 case DNTT_TYPE_REFERENCE:
2550 /* C++ reference type - call a routine in gdbtypes.c that constructs
2551 * the appropriate GDB type.
2553 return make_reference_type (
2554 hpread_type_lookup (dn_bufp->dreference.pointsto,
2558 case DNTT_TYPE_ENUM:
2559 return hpread_read_enum_type (hp_type, dn_bufp, objfile);
2561 return hpread_read_set_type (hp_type, dn_bufp, objfile);
2562 case DNTT_TYPE_SUBRANGE:
2563 return hpread_read_subrange_type (hp_type, dn_bufp, objfile);
2564 case DNTT_TYPE_ARRAY:
2565 return hpread_read_array_type (hp_type, dn_bufp, objfile);
2566 case DNTT_TYPE_STRUCT:
2567 case DNTT_TYPE_UNION:
2568 return hpread_read_struct_type (hp_type, dn_bufp, objfile);
2569 case DNTT_TYPE_FIELD:
2570 return hpread_type_lookup (dn_bufp->dfield.type, objfile);
2572 case DNTT_TYPE_FUNCTYPE:
2573 /* Here we want to read the function SOMs and return a
2574 * type for it. We get here, for instance, when processing
2575 * pointer-to-function type.
2577 return hpread_read_function_type (hp_type, dn_bufp, objfile, 0);
2579 case DNTT_TYPE_PTRMEM:
2580 /* Declares a C++ pointer-to-data-member type.
2581 * The "pointsto" field defines the class,
2582 * while the "memtype" field defines the pointed-to-type.
2585 struct type *ptrmemtype;
2586 struct type *class_type;
2587 struct type *memtype;
2588 memtype = hpread_type_lookup (dn_bufp->dptrmem.memtype,
2590 class_type = hpread_type_lookup (dn_bufp->dptrmem.pointsto,
2592 ptrmemtype = alloc_type (objfile);
2593 smash_to_member_type (ptrmemtype, class_type, memtype);
2594 return make_pointer_type (ptrmemtype, NULL);
2598 case DNTT_TYPE_PTRMEMFUNC:
2599 /* Defines a C++ pointer-to-function-member type.
2600 * The "pointsto" field defines the class,
2601 * while the "memtype" field defines the pointed-to-type.
2604 struct type *ptrmemtype;
2605 struct type *class_type;
2606 struct type *functype;
2607 struct type *retvaltype;
2610 struct type **args_type;
2611 class_type = hpread_type_lookup (dn_bufp->dptrmem.pointsto,
2613 functype = hpread_type_lookup (dn_bufp->dptrmem.memtype,
2615 retvaltype = TYPE_TARGET_TYPE (functype);
2616 nargs = TYPE_NFIELDS (functype);
2617 args_type = (struct type **) xmalloc ((nargs + 1) * sizeof (struct type *));
2618 for (i = 0; i < nargs; i++)
2620 args_type[i] = TYPE_FIELD_TYPE (functype, i);
2622 args_type[nargs] = NULL;
2623 ptrmemtype = alloc_type (objfile);
2624 smash_to_method_type (ptrmemtype, class_type, retvaltype, args_type);
2625 return make_pointer_type (ptrmemtype, NULL);
2629 case DNTT_TYPE_CLASS:
2630 return hpread_read_struct_type (hp_type, dn_bufp, objfile);
2632 case DNTT_TYPE_GENFIELD:
2633 /* Chase pointer from GENFIELD to FIELD, and make recursive
2636 return hpread_type_lookup (dn_bufp->dgenfield.field, objfile);
2638 case DNTT_TYPE_VFUNC:
2639 /* C++ virtual function.
2640 * We get here in the course of processing a class type which
2641 * contains virtual functions. Just go through another level
2642 * of indirection to get to the pointed-to function SOM.
2644 return hpread_type_lookup (dn_bufp->dvfunc.funcptr, objfile);
2646 case DNTT_TYPE_MODIFIER:
2647 /* Check the modifiers and then just make a recursive call on
2648 * the "type" pointed to by the modifier DNTT.
2650 * pai:: FIXME -- do we ever want to handle "m_duplicate" and
2651 * "m_void" modifiers? Is static_flag really needed here?
2652 * (m_static used for methods of classes, elsewhere).
2654 tmp_type = make_cv_type (dn_bufp->dmodifier.m_const,
2655 dn_bufp->dmodifier.m_volatile,
2656 hpread_type_lookup (dn_bufp->dmodifier.type, objfile),
2661 case DNTT_TYPE_MEMFUNC:
2662 /* Member function. Treat like a function.
2663 * I think we get here in the course of processing a
2664 * pointer-to-member-function type...
2666 return hpread_read_function_type (hp_type, dn_bufp, objfile, 0);
2668 case DNTT_TYPE_DOC_MEMFUNC:
2669 return hpread_read_doc_function_type (hp_type, dn_bufp, objfile, 0);
2671 case DNTT_TYPE_TEMPLATE:
2672 /* Template - sort of the header for a template definition,
2673 * which like a class, points to a member list and also points
2674 * to a TEMPLATE_ARG list of type-arguments.
2676 return hpread_read_struct_type (hp_type, dn_bufp, objfile);
2678 case DNTT_TYPE_TEMPLATE_ARG:
2681 /* The TEMPLATE record points to an argument list of
2682 * TEMPLATE_ARG records, each of which describes one
2683 * of the type-arguments.
2685 name = VT (objfile) + dn_bufp->dtempl_arg.name;
2686 return hpread_read_templ_arg_type (hp_type, dn_bufp, objfile, name);
2689 case DNTT_TYPE_FUNC_TEMPLATE:
2690 /* We wind up here when processing a TEMPLATE type,
2691 * if the template has member function(s).
2692 * Treat it like a FUNCTION.
2694 return hpread_read_function_type (hp_type, dn_bufp, objfile, 0);
2696 case DNTT_TYPE_LINK:
2697 /* The LINK record is used to link up templates with instantiations.
2698 * There is no type associated with the LINK record per se.
2700 return lookup_fundamental_type (objfile, FT_VOID);
2702 /* Also not yet handled... */
2703 /* case DNTT_TYPE_DYN_ARRAY_DESC: */
2704 /* case DNTT_TYPE_DESC_SUBRANGE: */
2705 /* case DNTT_TYPE_BEGIN_EXT: */
2706 /* case DNTT_TYPE_INLN: */
2707 /* case DNTT_TYPE_INLN_LIST: */
2708 /* case DNTT_TYPE_ALIAS: */
2710 /* A fancy way of returning NULL */
2711 return lookup_fundamental_type (objfile, FT_VOID);
2716 hpread_record_lines (subfile, s_idx, e_idx, objfile, offset)
2717 struct subfile *subfile;
2718 sltpointer s_idx, e_idx;
2719 struct objfile *objfile;
2722 union sltentry *sl_bufp;
2724 while (s_idx <= e_idx)
2726 sl_bufp = hpread_get_slt (s_idx, objfile);
2727 /* Only record "normal" entries in the SLT. */
2728 if (sl_bufp->snorm.sltdesc == SLT_NORMAL
2729 || sl_bufp->snorm.sltdesc == SLT_EXIT)
2730 record_line (subfile, sl_bufp->snorm.line,
2731 sl_bufp->snorm.address + offset);
2732 else if (sl_bufp->snorm.sltdesc == SLT_NORMAL_OFFSET)
2733 record_line (subfile, sl_bufp->snormoff.line,
2734 sl_bufp->snormoff.address + offset);
2740 /* Given a function "f" which is a member of a class, find
2741 * the classname that it is a member of. Used to construct
2742 * the name (e.g., "c::f") which GDB will put in the
2743 * "demangled name" field of the function's symbol.
2744 * Called from hpread_process_one_debug_symbol()
2745 * If "f" is not a member function, return NULL.
2749 struct type *functype;
2751 struct type *first_param_type;
2752 char *first_param_name;
2753 struct type *pointed_to_type;
2756 /* Check that the function has a first argument "this",
2757 * and that "this" is a pointer to a class. If not,
2758 * functype is not a member function, so return NULL.
2760 if (TYPE_NFIELDS (functype) == 0)
2762 first_param_name = TYPE_FIELD_NAME (functype, 0);
2763 if (first_param_name == NULL)
2764 return NULL; /* paranoia */
2765 if (strcmp (first_param_name, "this"))
2767 first_param_type = TYPE_FIELD_TYPE (functype, 0);
2768 if (first_param_type == NULL)
2769 return NULL; /* paranoia */
2770 if (TYPE_CODE (first_param_type) != TYPE_CODE_PTR)
2773 /* Get the thing that "this" points to, check that
2774 * it's a class, and get its class name.
2776 pointed_to_type = TYPE_TARGET_TYPE (first_param_type);
2777 if (pointed_to_type == NULL)
2778 return NULL; /* paranoia */
2779 if (TYPE_CODE (pointed_to_type) != TYPE_CODE_CLASS)
2781 class_name = TYPE_NAME (pointed_to_type);
2782 if (class_name == NULL)
2783 return NULL; /* paranoia */
2785 /* The class name may be of the form "class c", in which case
2786 * we want to strip off the leading "class ".
2788 if (strncmp (class_name, "class ", 6) == 0)
2794 /* Internalize one native debug symbol.
2795 * Called in a loop from hpread_expand_symtab().
2804 * index: Index of this symbol
2805 * at_module_boundary_p Pointer to boolean flag to control caller's loop.
2809 hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile,
2810 text_offset, text_size, filename,
2811 index, at_module_boundary_p
2813 union dnttentry *dn_bufp;
2815 struct section_offsets *section_offsets;
2816 struct objfile *objfile;
2817 CORE_ADDR text_offset;
2821 int *at_module_boundary_p;
2826 int offset = ANOFFSET (section_offsets, SECT_OFF_TEXT);
2827 int data_offset = ANOFFSET (section_offsets, SECT_OFF_DATA);
2828 union dnttentry *dn_temp;
2829 dnttpointer hp_type;
2831 struct context_stack *new;
2832 char *class_scope_name;
2834 /* Allocate one GDB debug symbol and fill in some default values. */
2835 sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
2836 sizeof (struct symbol));
2837 memset (sym, 0, sizeof (struct symbol));
2838 SYMBOL_NAME (sym) = obsavestring (name, strlen (name), &objfile->symbol_obstack);
2839 SYMBOL_LANGUAGE (sym) = language_auto;
2840 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2841 SYMBOL_LINE (sym) = 0;
2842 SYMBOL_VALUE (sym) = 0;
2843 SYMBOL_CLASS (sym) = LOC_TYPEDEF;
2845 /* Just a trick in case the SOM debug symbol is a type definition.
2846 * There are routines that are set up to build a GDB type symbol, given
2847 * a SOM dnttpointer. So we set up a dummy SOM dnttpointer "hp_type".
2848 * This allows us to call those same routines.
2850 hp_type.dnttp.extension = 1;
2851 hp_type.dnttp.immediate = 0;
2852 hp_type.dnttp.global = 0;
2853 hp_type.dnttp.index = index;
2855 /* This "type" is the type of SOM record.
2856 * Switch on SOM type.
2858 type = dn_bufp->dblock.kind;
2861 case DNTT_TYPE_SRCFILE:
2862 /* This type of symbol indicates from which source file or
2863 * include file any following data comes. It may indicate:
2865 * o The start of an entirely new source file (and thus
2868 * o The start of a different source file due to #include
2870 * o The end of an include file and the return to the original
2871 * file. Thus if "foo.c" includes "bar.h", we see first
2872 * a SRCFILE for foo.c, then one for bar.h, and then one for
2875 * If it indicates the start of a new module then we must
2876 * finish the symbol table of the previous module
2877 * (if any) and start accumulating a new symbol table.
2881 if (!last_source_file)
2884 * A note on "last_source_file": this is a char* pointing
2885 * to the actual file name. "start_symtab" sets it,
2886 * "end_symtab" clears it.
2888 * So if "last_source_file" is NULL, then either this is
2889 * the first record we are looking at, or a previous call
2890 * to "end_symtab()" was made to close out the previous
2891 * module. Since we're now quitting the scan loop when we
2892 * see a MODULE END record, we should never get here, except
2893 * in the case that we're not using the quick look-up tables
2894 * and have to use the old system as a fall-back.
2896 start_symtab (name, NULL, valu);
2897 record_debugformat ("HP");
2898 SL_INDEX (objfile) = dn_bufp->dsfile.address;
2903 /* Either a new include file, or a SRCFILE record
2904 * saying we are back in the main source (or out of
2905 * a nested include file) again.
2907 SL_INDEX (objfile) = hpread_record_lines (current_subfile,
2909 dn_bufp->dsfile.address,
2913 /* A note on "start_subfile". This routine will check
2914 * the name we pass it and look for an existing subfile
2915 * of that name. There's thus only one sub-file for the
2916 * actual source (e.g. for "foo.c" in foo.c), despite the
2917 * fact that we'll see lots of SRCFILE entries for foo.c
2920 start_subfile (name, NULL);
2923 case DNTT_TYPE_MODULE:
2925 * We no longer ignore DNTT_TYPE_MODULE symbols. The module
2926 * represents the meaningful semantic structure of a compilation
2927 * unit. We expect to start the psymtab-to-symtab expansion
2928 * looking at a MODULE entry, and to end it at the corresponding
2931 *--Begin outdated comments
2933 * This record signifies the start of a new source module
2934 * In C/C++ there is no explicit "module" construct in the language,
2935 * but each compilation unit is implicitly a module and they
2936 * do emit the DNTT_TYPE_MODULE records.
2937 * The end of the module is marked by a matching DNTT_TYPE_END record.
2939 * The reason GDB gets away with ignoring the DNTT_TYPE_MODULE record
2940 * is it notices the DNTT_TYPE_END record for the previous
2941 * module (see comments under DNTT_TYPE_END case), and then treats
2942 * the next DNTT_TYPE_SRCFILE record as if it were the module-start record.
2943 * (i.e., it makes a start_symtab() call).
2944 * This scheme seems a little convoluted, but I'll leave it
2945 * alone on the principle "if it ain't broke don't fix
2948 *-- End outdated comments
2952 if (!last_source_file)
2954 /* Start of a new module. We know this because "last_source_file"
2955 * is NULL, which can only happen the first time or if we just
2956 * made a call to end_symtab() to close out the previous module.
2958 start_symtab (name, NULL, valu);
2959 SL_INDEX (objfile) = dn_bufp->dmodule.address;
2963 /* This really shouldn't happen if we're using the quick
2964 * look-up tables, as it would mean we'd scanned past an
2965 * END MODULE entry. But if we're not using the tables,
2966 * we started the module on the SRCFILE entry, so it's ok.
2967 * For now, accept this.
2969 /* warning( "Error expanding psymtab, missed module end, found entry for %s",
2972 *at_module_boundary_p = -1;
2975 start_subfile (name, NULL);
2978 case DNTT_TYPE_FUNCTION:
2979 case DNTT_TYPE_ENTRY:
2980 /* A function or secondary entry point. */
2981 valu = dn_bufp->dfunc.lowaddr + offset;
2983 /* Record lines up to this point. */
2984 SL_INDEX (objfile) = hpread_record_lines (current_subfile,
2986 dn_bufp->dfunc.address,
2989 WITHIN_FUNCTION (objfile) = 1;
2990 CURRENT_FUNCTION_VALUE (objfile) = valu;
2992 /* Stack must be empty now. */
2993 if (context_stack_depth != 0)
2994 complain (&lbrac_unmatched_complaint, (char *) symnum);
2995 new = push_context (0, valu);
2997 /* Built a type for the function. This includes processing
2998 * the symbol records for the function parameters.
3000 SYMBOL_CLASS (sym) = LOC_BLOCK;
3001 SYMBOL_TYPE (sym) = hpread_read_function_type (hp_type, dn_bufp, objfile, 1);
3003 /* The "SYMBOL_NAME" field is expected to be the mangled name
3004 * (if any), which we get from the "alias" field of the SOM record
3007 if ((dn_bufp->dfunc.language == HP_LANGUAGE_CPLUSPLUS) &&
3008 dn_bufp->dfunc.alias && /* has an alias */
3009 *(char *) (VT (objfile) + dn_bufp->dfunc.alias)) /* not a null string */
3010 SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->dfunc.alias;
3012 SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->dfunc.name;
3014 /* Special hack to get around HP compilers' insistence on
3015 * reporting "main" as "_MAIN_" for C/C++ */
3016 if ((strcmp (SYMBOL_NAME (sym), "_MAIN_") == 0) &&
3017 (strcmp (VT (objfile) + dn_bufp->dfunc.name, "main") == 0))
3018 SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->dfunc.name;
3020 /* The SYMBOL_CPLUS_DEMANGLED_NAME field is expected to
3021 * be the demangled name.
3023 if (dn_bufp->dfunc.language == HP_LANGUAGE_CPLUSPLUS)
3025 /* SYMBOL_INIT_DEMANGLED_NAME is a macro which winds up
3026 * calling the demangler in libiberty (cplus_demangle()) to
3027 * do the job. This generally does the job, even though
3028 * it's intended for the GNU compiler and not the aCC compiler
3029 * Note that SYMBOL_INIT_DEMANGLED_NAME calls the
3030 * demangler with arguments DMGL_PARAMS | DMGL_ANSI.
3031 * Generally, we don't want params when we display
3032 * a demangled name, but when I took out the DMGL_PARAMS,
3033 * some things broke, so I'm leaving it in here, and
3034 * working around the issue in stack.c. - RT
3036 SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack);
3037 if ((SYMBOL_NAME (sym) == VT (objfile) + dn_bufp->dfunc.alias) &&
3038 (!SYMBOL_CPLUS_DEMANGLED_NAME (sym)))
3041 /* Well, the symbol name is mangled, but the
3042 * demangler in libiberty failed so the demangled
3043 * field is still NULL. Try to
3044 * do the job ourselves based on the "name" field
3045 * in the SOM record. A complication here is that
3046 * the name field contains only the function name
3047 * (like "f"), whereas we want the class qualification
3048 * (as in "c::f"). Try to reconstruct that.
3053 basename = VT (objfile) + dn_bufp->dfunc.name;
3054 classname = class_of (SYMBOL_TYPE (sym));
3057 dem_name = xmalloc (strlen (basename) + strlen (classname) + 3);
3058 strcpy (dem_name, classname);
3059 strcat (dem_name, "::");
3060 strcat (dem_name, basename);
3061 SYMBOL_CPLUS_DEMANGLED_NAME (sym) = dem_name;
3062 SYMBOL_LANGUAGE (sym) = language_cplus;
3067 /* Add the function symbol to the list of symbols in this blockvector */
3068 if (dn_bufp->dfunc.global)
3069 add_symbol_to_list (sym, &global_symbols);
3071 add_symbol_to_list (sym, &file_symbols);
3074 /* Search forward to the next BEGIN and also read
3075 * in the line info up to that point.
3076 * Not sure why this is needed.
3077 * In HP FORTRAN this code is harmful since there
3078 * may not be a BEGIN after the FUNCTION.
3079 * So I made it C/C++ specific. - RT
3081 if (dn_bufp->dfunc.language == HP_LANGUAGE_C ||
3082 dn_bufp->dfunc.language == HP_LANGUAGE_CPLUSPLUS)
3084 while (dn_bufp->dblock.kind != DNTT_TYPE_BEGIN)
3086 dn_bufp = hpread_get_lntt (++index, objfile);
3087 if (dn_bufp->dblock.extension)
3090 SL_INDEX (objfile) = hpread_record_lines (current_subfile,
3092 dn_bufp->dbegin.address,
3094 SYMBOL_LINE (sym) = hpread_get_line (dn_bufp->dbegin.address, objfile);
3096 record_line (current_subfile, SYMBOL_LINE (sym), valu);
3099 case DNTT_TYPE_DOC_FUNCTION:
3100 valu = dn_bufp->ddocfunc.lowaddr + offset;
3102 /* Record lines up to this point. */
3103 SL_INDEX (objfile) = hpread_record_lines (current_subfile,
3105 dn_bufp->ddocfunc.address,
3108 WITHIN_FUNCTION (objfile) = 1;
3109 CURRENT_FUNCTION_VALUE (objfile) = valu;
3110 /* Stack must be empty now. */
3111 if (context_stack_depth != 0)
3112 complain (&lbrac_unmatched_complaint, (char *) symnum);
3113 new = push_context (0, valu);
3115 /* Built a type for the function. This includes processing
3116 * the symbol records for the function parameters.
3118 SYMBOL_CLASS (sym) = LOC_BLOCK;
3119 SYMBOL_TYPE (sym) = hpread_read_doc_function_type (hp_type, dn_bufp, objfile, 1);
3121 /* The "SYMBOL_NAME" field is expected to be the mangled name
3122 * (if any), which we get from the "alias" field of the SOM record
3125 if ((dn_bufp->ddocfunc.language == HP_LANGUAGE_CPLUSPLUS) &&
3126 dn_bufp->ddocfunc.alias && /* has an alias */
3127 *(char *) (VT (objfile) + dn_bufp->ddocfunc.alias)) /* not a null string */
3128 SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->ddocfunc.alias;
3130 SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->ddocfunc.name;
3132 /* Special hack to get around HP compilers' insistence on
3133 * reporting "main" as "_MAIN_" for C/C++ */
3134 if ((strcmp (SYMBOL_NAME (sym), "_MAIN_") == 0) &&
3135 (strcmp (VT (objfile) + dn_bufp->ddocfunc.name, "main") == 0))
3136 SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->ddocfunc.name;
3138 if (dn_bufp->ddocfunc.language == HP_LANGUAGE_CPLUSPLUS)
3141 /* SYMBOL_INIT_DEMANGLED_NAME is a macro which winds up
3142 * calling the demangler in libiberty (cplus_demangle()) to
3143 * do the job. This generally does the job, even though
3144 * it's intended for the GNU compiler and not the aCC compiler
3145 * Note that SYMBOL_INIT_DEMANGLED_NAME calls the
3146 * demangler with arguments DMGL_PARAMS | DMGL_ANSI.
3147 * Generally, we don't want params when we display
3148 * a demangled name, but when I took out the DMGL_PARAMS,
3149 * some things broke, so I'm leaving it in here, and
3150 * working around the issue in stack.c. - RT
3152 SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack);
3154 if ((SYMBOL_NAME (sym) == VT (objfile) + dn_bufp->ddocfunc.alias) &&
3155 (!SYMBOL_CPLUS_DEMANGLED_NAME (sym)))
3158 /* Well, the symbol name is mangled, but the
3159 * demangler in libiberty failed so the demangled
3160 * field is still NULL. Try to
3161 * do the job ourselves based on the "name" field
3162 * in the SOM record. A complication here is that
3163 * the name field contains only the function name
3164 * (like "f"), whereas we want the class qualification
3165 * (as in "c::f"). Try to reconstruct that.
3170 basename = VT (objfile) + dn_bufp->ddocfunc.name;
3171 classname = class_of (SYMBOL_TYPE (sym));
3174 dem_name = xmalloc (strlen (basename) + strlen (classname) + 3);
3175 strcpy (dem_name, classname);
3176 strcat (dem_name, "::");
3177 strcat (dem_name, basename);
3178 SYMBOL_CPLUS_DEMANGLED_NAME (sym) = dem_name;
3179 SYMBOL_LANGUAGE (sym) = language_cplus;
3184 /* Add the function symbol to the list of symbols in this blockvector */
3185 if (dn_bufp->ddocfunc.global)
3186 add_symbol_to_list (sym, &global_symbols);
3188 add_symbol_to_list (sym, &file_symbols);
3191 /* Search forward to the next BEGIN and also read
3192 * in the line info up to that point.
3193 * Not sure why this is needed.
3194 * In HP FORTRAN this code is harmful since there
3195 * may not be a BEGIN after the FUNCTION.
3196 * So I made it C/C++ specific. - RT
3198 if (dn_bufp->ddocfunc.language == HP_LANGUAGE_C ||
3199 dn_bufp->ddocfunc.language == HP_LANGUAGE_CPLUSPLUS)
3201 while (dn_bufp->dblock.kind != DNTT_TYPE_BEGIN)
3203 dn_bufp = hpread_get_lntt (++index, objfile);
3204 if (dn_bufp->dblock.extension)
3207 SL_INDEX (objfile) = hpread_record_lines (current_subfile,
3209 dn_bufp->dbegin.address,
3211 SYMBOL_LINE (sym) = hpread_get_line (dn_bufp->dbegin.address, objfile);
3213 record_line (current_subfile, SYMBOL_LINE (sym), valu);
3216 case DNTT_TYPE_BEGIN:
3217 /* Begin a new scope. */
3218 if (context_stack_depth == 1 /* this means we're at function level */ &&
3219 context_stack[0].name != NULL /* this means it's a function */ &&
3220 context_stack[0].depth == 0 /* this means it's the first BEGIN
3221 we've seen after the FUNCTION */
3224 /* This is the first BEGIN after a FUNCTION.
3225 * We ignore this one, since HP compilers always insert
3226 * at least one BEGIN, i.e. it's:
3232 * (possibly nested BEGIN ... END's if there are inner { } blocks)
3236 * By ignoring this first BEGIN, the local symbols get treated
3237 * as belonging to the function scope, and "print func::local_sym"
3238 * works (which is what we want).
3241 /* All we do here is increase the depth count associated with
3242 * the FUNCTION entry in the context stack. This ensures that
3243 * the next BEGIN we see (if any), representing a real nested { }
3244 * block, will get processed.
3247 context_stack[0].depth++;
3253 /* Record lines up to this SLT pointer. */
3254 SL_INDEX (objfile) = hpread_record_lines (current_subfile,
3256 dn_bufp->dbegin.address,
3258 /* Calculate start address of new scope */
3259 valu = hpread_get_location (dn_bufp->dbegin.address, objfile);
3260 valu += offset; /* Relocate for dynamic loading */
3261 /* We use the scope start DNTT index as nesting depth identifier! */
3262 desc = hpread_get_scope_start (dn_bufp->dbegin.address, objfile);
3263 new = push_context (desc, valu);
3270 /* Valid end kinds are:
3279 SL_INDEX (objfile) = hpread_record_lines (current_subfile,
3281 dn_bufp->dend.address,
3283 switch (dn_bufp->dend.endkind)
3285 case DNTT_TYPE_MODULE:
3286 /* Ending a module ends the symbol table for that module.
3287 * Calling end_symtab() has the side effect of clearing the
3288 * last_source_file pointer, which in turn signals
3289 * process_one_debug_symbol() to treat the next DNTT_TYPE_SRCFILE
3290 * record as a module-begin.
3292 valu = text_offset + text_size + offset;
3294 /* Tell our caller that we're done with expanding the
3295 * debug information for a module.
3297 *at_module_boundary_p = 1;
3299 /* Don't do this, as our caller will do it!
3301 * (void) end_symtab (valu, objfile, 0);
3305 case DNTT_TYPE_FUNCTION:
3306 /* Ending a function, well, ends the function's scope. */
3307 dn_temp = hpread_get_lntt (dn_bufp->dend.beginscope.dnttp.index,
3309 valu = dn_temp->dfunc.hiaddr + offset;
3310 /* Insert func params into local list */
3311 merge_symbol_lists (¶m_symbols, &local_symbols);
3312 new = pop_context ();
3313 /* Make a block for the local symbols within. */
3314 finish_block (new->name, &local_symbols, new->old_blocks,
3315 new->start_addr, valu, objfile);
3316 WITHIN_FUNCTION (objfile) = 0; /* This may have to change for Pascal */
3317 local_symbols = new->locals;
3318 param_symbols = new->params;
3321 case DNTT_TYPE_BEGIN:
3322 if (context_stack_depth == 1 &&
3323 context_stack[0].name != NULL &&
3324 context_stack[0].depth == 1)
3326 /* This is the END corresponding to the
3327 * BEGIN which we ignored - see DNTT_TYPE_BEGIN case above.
3329 context_stack[0].depth--;
3333 /* Ending a local scope. */
3334 valu = hpread_get_location (dn_bufp->dend.address, objfile);
3335 /* Why in the hell is this needed? */
3336 valu += offset + 9; /* Relocate for dynamic loading */
3337 new = pop_context ();
3338 desc = dn_bufp->dend.beginscope.dnttp.index;
3339 if (desc != new->depth)
3340 complain (&lbrac_mismatch_complaint, (char *) symnum);
3342 /* Make a block for the local symbols within. */
3343 finish_block (new->name, &local_symbols, new->old_blocks,
3344 new->start_addr, valu, objfile);
3345 local_symbols = new->locals;
3346 param_symbols = new->params;
3350 case DNTT_TYPE_WITH:
3351 /* Since we ignore the DNTT_TYPE_WITH that starts the scope,
3352 * we can ignore the DNTT_TYPE_END that ends it.
3356 case DNTT_TYPE_COMMON:
3357 /* End a FORTRAN common block. We don't currently handle these */
3358 complain (&hpread_unhandled_end_common_complaint);
3361 case DNTT_TYPE_CLASS_SCOPE:
3363 /* pai: FIXME Not handling nested classes for now -- must
3364 * maintain a stack */
3365 class_scope_name = NULL;
3368 /* End a class scope */
3369 valu = hpread_get_location (dn_bufp->dend.address, objfile);
3370 /* Why in the hell is this needed? */
3371 valu += offset + 9; /* Relocate for dynamic loading */
3372 new = pop_context ();
3373 desc = dn_bufp->dend.beginscope.dnttp.index;
3374 if (desc != new->depth)
3375 complain (&lbrac_mismatch_complaint, (char *) symnum);
3376 /* Make a block for the local symbols within. */
3377 finish_block (new->name, &local_symbols, new->old_blocks,
3378 new->start_addr, valu, objfile);
3379 local_symbols = new->locals;
3380 param_symbols = new->params;
3385 complain (&hpread_unexpected_end_complaint);
3390 /* DNTT_TYPE_IMPORT is not handled */
3392 case DNTT_TYPE_LABEL:
3393 SYMBOL_NAMESPACE (sym) = LABEL_NAMESPACE;
3396 case DNTT_TYPE_FPARAM:
3397 /* Function parameters. */
3398 /* Note 1: This code was present in the 4.16 sources, and then
3399 removed, because fparams are handled in
3400 hpread_read_function_type(). However, while fparam symbols
3401 are indeed handled twice, this code here cannot be removed
3402 because then they don't get added to the local symbol list of
3403 the function's code block, which leads to a failure to look
3404 up locals, "this"-relative member names, etc. So I've put
3405 this code back in. pai/1997-07-21 */
3406 /* Note 2: To fix a defect, we stopped adding FPARAMS to local_symbols
3407 in hpread_read_function_type(), so FPARAMS had to be handled
3408 here. I changed the location to be the appropriate argument
3409 kinds rather than LOC_LOCAL. pai/1997-08-08 */
3410 /* Note 3: Well, the fix in Note 2 above broke argument printing
3411 in traceback frames, and further it makes assumptions about the
3412 order of the FPARAM entries from HP compilers (cc and aCC in particular
3413 generate them in reverse orders -- fixing one breaks for the other).
3414 So I've added code in hpread_read_function_type() to add fparams
3415 to a param_symbols list for the current context level. These are
3416 then merged into local_symbols when a function end is reached.
3419 break; /* do nothing; handled in hpread_read_function_type() */
3421 #if 0 /* Old code */
3422 if (dn_bufp->dfparam.regparam)
3423 SYMBOL_CLASS (sym) = LOC_REGISTER;
3424 else if (dn_bufp->dfparam.indirect)
3425 SYMBOL_CLASS (sym) = LOC_REF_ARG;
3427 SYMBOL_CLASS (sym) = LOC_ARG;
3428 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
3429 if (dn_bufp->dfparam.copyparam)
3431 SYMBOL_VALUE (sym) = dn_bufp->dfparam.location;
3432 #ifdef HPREAD_ADJUST_STACK_ADDRESS
3434 += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile));
3438 SYMBOL_VALUE (sym) = dn_bufp->dfparam.location;
3439 SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dfparam.type, objfile);
3440 add_symbol_to_list (sym, &fparam_symbols);
3444 case DNTT_TYPE_SVAR:
3445 /* Static variables. */
3446 SYMBOL_CLASS (sym) = LOC_STATIC;
3448 /* Note: There is a case that arises with globals in shared
3449 * libraries where we need to set the address to LOC_INDIRECT.
3450 * This case is if you have a global "g" in one library, and
3451 * it is referenced "extern <type> g;" in another library.
3452 * If we're processing the symbols for the referencing library,
3453 * we'll see a global "g", but in this case the address given
3454 * in the symbol table contains a pointer to the real "g".
3455 * We use the storage class LOC_INDIRECT to indicate this. RT
3457 if (is_in_import_list (SYMBOL_NAME (sym), objfile))
3458 SYMBOL_CLASS (sym) = LOC_INDIRECT;
3460 SYMBOL_VALUE_ADDRESS (sym) = dn_bufp->dsvar.location + data_offset;
3461 SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dsvar.type, objfile);
3463 if (dn_bufp->dsvar.global)
3464 add_symbol_to_list (sym, &global_symbols);
3466 else if (WITHIN_FUNCTION (objfile))
3467 add_symbol_to_list (sym, &local_symbols);
3470 add_symbol_to_list (sym, &file_symbols);
3472 if (dn_bufp->dsvar.thread_specific)
3474 /* Thread-local variable.
3476 SYMBOL_CLASS (sym) = LOC_THREAD_LOCAL_STATIC;
3477 SYMBOL_BASEREG (sym) = CR27_REGNUM;
3479 if (objfile->flags & OBJF_SHARED)
3482 * This variable is not only thread local but
3483 * in a shared library.
3485 * Alas, the shared lib structures are private
3486 * to "somsolib.c". But C lets us point to one.
3490 if (objfile->obj_private == NULL)
3491 error ("Internal error in reading shared library information.");
3493 so = ((obj_private_data_t *) (objfile->obj_private))->so_info;
3495 error ("Internal error in reading shared library information.");
3497 /* Thread-locals in shared libraries do NOT have the
3498 * standard offset ("data_offset"), so we re-calculate
3499 * where to look for this variable, using a call-back
3500 * to interpret the private shared-library data.
3502 SYMBOL_VALUE_ADDRESS (sym) = dn_bufp->dsvar.location +
3503 so_lib_thread_start_addr (so);
3508 case DNTT_TYPE_DVAR:
3509 /* Dynamic variables. */
3510 if (dn_bufp->ddvar.regvar)
3511 SYMBOL_CLASS (sym) = LOC_REGISTER;
3513 SYMBOL_CLASS (sym) = LOC_LOCAL;
3515 SYMBOL_VALUE (sym) = dn_bufp->ddvar.location;
3516 #ifdef HPREAD_ADJUST_STACK_ADDRESS
3518 += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile));
3520 SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->ddvar.type, objfile);
3521 if (dn_bufp->ddvar.global)
3522 add_symbol_to_list (sym, &global_symbols);
3523 else if (WITHIN_FUNCTION (objfile))
3524 add_symbol_to_list (sym, &local_symbols);
3526 add_symbol_to_list (sym, &file_symbols);
3529 case DNTT_TYPE_CONST:
3530 /* A constant (pascal?). */
3531 SYMBOL_CLASS (sym) = LOC_CONST;
3532 SYMBOL_VALUE (sym) = dn_bufp->dconst.location;
3533 SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dconst.type, objfile);
3534 if (dn_bufp->dconst.global)
3535 add_symbol_to_list (sym, &global_symbols);
3536 else if (WITHIN_FUNCTION (objfile))
3537 add_symbol_to_list (sym, &local_symbols);
3539 add_symbol_to_list (sym, &file_symbols);
3542 case DNTT_TYPE_TYPEDEF:
3543 /* A typedef. We do want to process these, since a name is
3544 * added to the namespace for the typedef'ed name.
3546 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
3547 SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dtype.type, objfile);
3548 if (dn_bufp->dtype.global)
3549 add_symbol_to_list (sym, &global_symbols);
3550 else if (WITHIN_FUNCTION (objfile))
3551 add_symbol_to_list (sym, &local_symbols);
3553 add_symbol_to_list (sym, &file_symbols);
3556 case DNTT_TYPE_TAGDEF:
3558 int global = dn_bufp->dtag.global;
3559 /* Structure, union, enum, template, or class tag definition */
3560 /* We do want to process these, since a name is
3561 * added to the namespace for the tag name (and if C++ class,
3562 * for the typename also).
3564 SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE;
3566 /* The tag contains in its "type" field a pointer to the
3567 * DNTT_TYPE_STRUCT, DNTT_TYPE_UNION, DNTT_TYPE_ENUM,
3568 * DNTT_TYPE_CLASS or DNTT_TYPE_TEMPLATE
3569 * record that actually defines the type.
3571 SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dtype.type, objfile);
3572 TYPE_NAME (sym->type) = SYMBOL_NAME (sym);
3573 TYPE_TAG_NAME (sym->type) = SYMBOL_NAME (sym);
3574 if (dn_bufp->dtag.global)
3575 add_symbol_to_list (sym, &global_symbols);
3576 else if (WITHIN_FUNCTION (objfile))
3577 add_symbol_to_list (sym, &local_symbols);
3579 add_symbol_to_list (sym, &file_symbols);
3581 /* If this is a C++ class, then we additionally
3582 * need to define a typedef for the
3583 * class type. E.g., so that the name "c" becomes visible as
3584 * a type name when the user says "class c { ... }".
3585 * In order to figure this out, we need to chase down the "type"
3586 * field to get to the DNTT_TYPE_CLASS record.
3588 * We also add the typename for ENUM. Though this isn't
3589 * strictly correct, it is necessary because of the debug info
3590 * generated by the aCC compiler, in which we cannot
3591 * distinguish between:
3594 * typedef enum { ... } e;
3595 * I.e., the compiler emits the same debug info for the above
3596 * two cases, in both cases "e" appearing as a tagdef.
3597 * Therefore go ahead and generate the typename so that
3598 * "ptype e" will work in the above cases.
3600 * We also add the typename for TEMPLATE, so as to allow "ptype t"
3601 * when "t" is a template name.
3603 if (dn_bufp->dtype.type.dnttp.index < LNTT_SYMCOUNT (objfile))
3604 dn_bufp = hpread_get_lntt (dn_bufp->dtag.type.dnttp.index, objfile);
3607 complain (&hpread_tagdef_complaint);
3610 if (dn_bufp->dblock.kind == DNTT_TYPE_CLASS ||
3611 dn_bufp->dblock.kind == DNTT_TYPE_ENUM ||
3612 dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE)
3614 struct symbol *newsym;
3616 newsym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
3617 sizeof (struct symbol));
3618 memset (newsym, 0, sizeof (struct symbol));
3619 SYMBOL_NAME (newsym) = name;
3620 SYMBOL_LANGUAGE (newsym) = language_auto;
3621 SYMBOL_NAMESPACE (newsym) = VAR_NAMESPACE;
3622 SYMBOL_LINE (newsym) = 0;
3623 SYMBOL_VALUE (newsym) = 0;
3624 SYMBOL_CLASS (newsym) = LOC_TYPEDEF;
3625 SYMBOL_TYPE (newsym) = sym->type;
3627 add_symbol_to_list (newsym, &global_symbols);
3628 else if (WITHIN_FUNCTION (objfile))
3629 add_symbol_to_list (newsym, &local_symbols);
3631 add_symbol_to_list (newsym, &file_symbols);
3636 case DNTT_TYPE_POINTER:
3637 /* Declares a pointer type. Should not be necessary to do anything
3638 * with the type at this level; these are processed
3639 * at the hpread_type_lookup() level.
3643 case DNTT_TYPE_ENUM:
3644 /* Declares an enum type. Should not be necessary to do anything
3645 * with the type at this level; these are processed
3646 * at the hpread_type_lookup() level.
3650 case DNTT_TYPE_MEMENUM:
3651 /* Member of enum */
3652 /* Ignored at this level, but hpread_read_enum_type() will take
3653 * care of walking the list of enumeration members.
3658 /* Declares a set type. Should not be necessary to do anything
3659 * with the type at this level; these are processed
3660 * at the hpread_type_lookup() level.
3664 case DNTT_TYPE_SUBRANGE:
3665 /* Declares a subrange type. Should not be necessary to do anything
3666 * with the type at this level; these are processed
3667 * at the hpread_type_lookup() level.
3671 case DNTT_TYPE_ARRAY:
3672 /* Declares an array type. Should not be necessary to do anything
3673 * with the type at this level; these are processed
3674 * at the hpread_type_lookup() level.
3678 case DNTT_TYPE_STRUCT:
3679 case DNTT_TYPE_UNION:
3680 /* Declares an struct/union type.
3681 * Should not be necessary to do anything
3682 * with the type at this level; these are processed
3683 * at the hpread_type_lookup() level.
3687 case DNTT_TYPE_FIELD:
3688 /* Structure/union/class field */
3689 /* Ignored at this level, but hpread_read_struct_type() will take
3690 * care of walking the list of structure/union/class members.
3694 /* DNTT_TYPE_VARIANT is not handled by GDB */
3696 /* DNTT_TYPE_FILE is not handled by GDB */
3698 case DNTT_TYPE_FUNCTYPE:
3700 /* Ignored at this level, handled within hpread_type_lookup() */
3703 case DNTT_TYPE_WITH:
3704 /* This is emitted within methods to indicate "with <class>"
3705 * scoping rules (i.e., indicate that the class data members
3706 * are directly visible).
3707 * However, since GDB already infers this by looking at the
3708 * "this" argument, interpreting the DNTT_TYPE_WITH
3709 * symbol record is unnecessary.
3713 case DNTT_TYPE_COMMON:
3714 /* FORTRAN common. Not yet handled. */
3715 complain (&hpread_unhandled_common_complaint);
3718 /* DNTT_TYPE_COBSTRUCT is not handled by GDB. */
3719 /* DNTT_TYPE_XREF is not handled by GDB. */
3720 /* DNTT_TYPE_SA is not handled by GDB. */
3721 /* DNTT_TYPE_MACRO is not handled by GDB */
3723 case DNTT_TYPE_BLOCKDATA:
3724 /* Not sure what this is - part of FORTRAN support maybe?
3725 * Anyway, not yet handled.
3727 complain (&hpread_unhandled_blockdata_complaint);
3730 case DNTT_TYPE_CLASS_SCOPE:
3734 /* The compiler brackets member functions with a CLASS_SCOPE/END
3735 * pair of records, presumably to put them in a different scope
3736 * from the module scope where they are normally defined.
3737 * E.g., in the situation:
3739 * void c::f() { ...}
3740 * The member function "c::f" will be bracketed by a CLASS_SCOPE/END.
3741 * This causes "break f" at the module level to pick the
3742 * the file-level function f(), not the member function
3743 * (which needs to be referenced via "break c::f").
3745 * Here we record the class name to generate the demangled names of
3746 * member functions later.
3748 * FIXME Not being used now for anything -- cplus_demangle seems
3749 * enough for getting the class-qualified names of functions. We
3750 * may need this for handling nested classes and types. */
3752 /* pai: FIXME Not handling nested classes for now -- need to
3753 * maintain a stack */
3755 dn_temp = hpread_get_lntt (dn_bufp->dclass_scope.type.dnttp.index, objfile);
3756 if (dn_temp->dblock.kind == DNTT_TYPE_TAGDEF)
3757 class_scope_name = VT (objfile) + dn_temp->dtag.name;
3759 class_scope_name = NULL;
3763 /* Begin a new scope. */
3764 SL_INDEX (objfile) = hpread_record_lines (current_subfile,
3766 dn_bufp->dclass_scope.address,
3768 valu = hpread_get_location (dn_bufp->dclass_scope.address, objfile);
3769 valu += offset; /* Relocate for dynamic loading */
3770 desc = hpread_get_scope_start (dn_bufp->dclass_scope.address, objfile);
3771 /* We use the scope start DNTT index as the nesting depth identifier! */
3772 new = push_context (desc, valu);
3776 case DNTT_TYPE_REFERENCE:
3777 /* Declares a C++ reference type. Should not be necessary to do anything
3778 * with the type at this level; these are processed
3779 * at the hpread_type_lookup() level.
3783 case DNTT_TYPE_PTRMEM:
3784 /* Declares a C++ pointer-to-data-member type. This does not
3785 * need to be handled at this level; being a type description it
3786 * is instead handled at the hpread_type_lookup() level.
3790 case DNTT_TYPE_PTRMEMFUNC:
3791 /* Declares a C++ pointer-to-function-member type. This does not
3792 * need to be handled at this level; being a type description it
3793 * is instead handled at the hpread_type_lookup() level.
3797 case DNTT_TYPE_CLASS:
3798 /* Declares a class type.
3799 * Should not be necessary to do anything
3800 * with the type at this level; these are processed
3801 * at the hpread_type_lookup() level.
3805 case DNTT_TYPE_GENFIELD:
3806 /* I believe this is used for class member functions */
3807 /* Ignored at this level, but hpread_read_struct_type() will take
3808 * care of walking the list of class members.
3812 case DNTT_TYPE_VFUNC:
3813 /* Virtual function */
3814 /* This does not have to be handled at this level; handled in
3815 * the course of processing class symbols.
3819 case DNTT_TYPE_MEMACCESS:
3820 /* DDE ignores this symbol table record.
3821 * It has something to do with "modified access" to class members.
3822 * I'll assume we can safely ignore it too.
3826 case DNTT_TYPE_INHERITANCE:
3827 /* These don't have to be handled here, since they are handled
3828 * within hpread_read_struct_type() in the process of constructing
3833 case DNTT_TYPE_FRIEND_CLASS:
3834 case DNTT_TYPE_FRIEND_FUNC:
3835 /* These can safely be ignored, as GDB doesn't need this
3836 * info. DDE only uses it in "describe". We may later want
3837 * to extend GDB's "ptype" to give this info, but for now
3838 * it seems safe enough to ignore it.
3842 case DNTT_TYPE_MODIFIER:
3843 /* Intended to supply "modified access" to a type */
3844 /* From the way DDE handles this, it looks like it always
3845 * modifies a type. Therefore it is safe to ignore it at this
3846 * level, and handle it in hpread_type_lookup().
3850 case DNTT_TYPE_OBJECT_ID:
3851 /* Just ignore this - that's all DDE does */
3854 case DNTT_TYPE_MEMFUNC:
3855 /* Member function */
3856 /* This does not have to be handled at this level; handled in
3857 * the course of processing class symbols.
3861 case DNTT_TYPE_DOC_MEMFUNC:
3862 /* Member function */
3863 /* This does not have to be handled at this level; handled in
3864 * the course of processing class symbols.
3868 case DNTT_TYPE_TEMPLATE:
3869 /* Template - sort of the header for a template definition,
3870 * which like a class, points to a member list and also points
3871 * to a TEMPLATE_ARG list of type-arguments.
3872 * We do not need to process TEMPLATE records at this level though.
3876 case DNTT_TYPE_TEMPLATE_ARG:
3877 /* The TEMPLATE record points to an argument list of
3878 * TEMPLATE_ARG records, each of which describes one
3879 * of the type-arguments.
3880 * We do not need to process TEMPLATE_ARG records at this level though.
3884 case DNTT_TYPE_FUNC_TEMPLATE:
3885 /* This will get emitted for member functions of templates.
3886 * But we don't need to process this record at this level though,
3887 * we will process it in the course of processing a TEMPLATE
3892 case DNTT_TYPE_LINK:
3893 /* The LINK record is used to link up templates with instantiations. */
3894 /* It is not clear why this is needed, and furthermore aCC does
3895 * not appear to generate this, so I think we can safely ignore it. - RT
3899 /* DNTT_TYPE_DYN_ARRAY_DESC is not handled by GDB */
3900 /* DNTT_TYPE_DESC_SUBRANGE is not handled by GDB */
3901 /* DNTT_TYPE_BEGIN_EXT is not handled by GDB */
3902 /* DNTT_TYPE_INLN is not handled by GDB */
3903 /* DNTT_TYPE_INLN_LIST is not handled by GDB */
3904 /* DNTT_TYPE_ALIAS is not handled by GDB */
3911 /* Get nesting depth for a DNTT entry.
3912 * DN_BUFP points to a DNTT entry.
3913 * OBJFILE is the object file.
3914 * REPORT_NESTED is a flag; if 0, real nesting depth is
3915 * reported, if it is 1, the function simply returns a
3916 * non-zero value if the nesting depth is anything > 0.
3918 * Return value is an integer. 0 => not a local type / name
3919 * positive return => type or name is local to some
3920 * block or function.
3924 /* elz: ATTENTION: FIXME: NOTE: WARNING!!!!
3925 this function now returns 0 right away. It was taking too much time
3926 at start up. Now, though, the local types are not handled correctly.
3931 hpread_get_scope_depth (dn_bufp, objfile, report_nested)
3932 union dnttentry *dn_bufp;
3933 struct objfile *objfile;
3937 register union dnttentry *dn_tmp;
3938 register short depth = 0;
3939 /****************************/
3941 /****************************/
3943 index = (((char *) dn_bufp) - LNTT (objfile)) / (sizeof (struct dntt_type_block));
3945 while (--index >= 0)
3947 dn_tmp = hpread_get_lntt (index, objfile);
3948 switch (dn_tmp->dblock.kind)
3950 case DNTT_TYPE_MODULE:
3953 /* index is signed int; dnttp.index is 29-bit unsigned int! */
3954 index = (int) dn_tmp->dend.beginscope.dnttp.index;
3956 case DNTT_TYPE_BEGIN:
3957 case DNTT_TYPE_FUNCTION:
3958 case DNTT_TYPE_DOC_FUNCTION:
3959 case DNTT_TYPE_WITH:
3960 case DNTT_TYPE_COMMON:
3961 case DNTT_TYPE_CLASS_SCOPE:
3973 /* Adjust the bitoffsets for all fields of an anonymous union of
3974 type TYPE by negative BITS. This handles HP aCC's hideous habit
3975 of giving members of anonymous unions bit offsets relative to the
3976 enclosing structure instead of relative to the union itself. */
3979 hpread_adjust_bitoffsets (type, bits)
3985 /* This is done only for unions; caller had better check that
3986 it is an anonymous one. */
3987 if (TYPE_CODE (type) != TYPE_CODE_UNION)
3990 /* Adjust each field; since this is a union, there are no base
3991 classes. Also no static membes. Also, no need for recursion as
3992 the members of this union if themeselves structs or unions, have
3993 the correct bitoffsets; if an anonymous union is a member of this
3994 anonymous union, the code in hpread_read_struct_type() will
3997 for (i = 0; i < TYPE_NFIELDS (type); i++)
3998 TYPE_FIELD_BITPOS (type, i) -= bits;
4001 /* Because of quirks in HP compilers' treatment of anonymous unions inside
4002 classes, we have to chase through a chain of threaded FIELD entries.
4003 If we encounter an anonymous union in the chain, we must recursively skip over
4006 This function does a "next" in the chain of FIELD entries, but transparently
4007 skips over anonymous unions' fields (recursively).
4009 Inputs are the number of times to do "next" at the top level, the dnttpointer
4010 (FIELD) and entry pointer (FIELDP) for the dntt record corresponding to it,
4011 and the ubiquitous objfile parameter. (Note: FIELDP is a **.) Return value
4012 is a dnttpointer for the new field after all the skipped ones */
4015 hpread_get_next_skip_over_anon_unions (skip_fields, field, fieldp, objfile)
4018 union dnttentry **fieldp;
4019 struct objfile *objfile;
4021 struct type *anon_type;
4026 for (i = 0; i < skip_fields; i++)
4028 /* Get type of item we're looking at now; recursively processes the types
4029 of these intermediate items we skip over, so they aren't lost. */
4030 anon_type = hpread_type_lookup ((*fieldp)->dfield.type, objfile);
4031 anon_type = CHECK_TYPEDEF (anon_type);
4032 bitoffset = (*fieldp)->dfield.bitoffset;
4033 name = VT (objfile) + (*fieldp)->dfield.name;
4034 /* First skip over one item to avoid stack death on recursion */
4035 field = (*fieldp)->dfield.nextfield;
4036 *fieldp = hpread_get_lntt (field.dnttp.index, objfile);
4037 /* Do we have another anonymous union? If so, adjust the bitoffsets
4038 of its members and skip over its members. */
4039 if ((TYPE_CODE (anon_type) == TYPE_CODE_UNION) &&
4040 (!name || STREQ (name, "")))
4042 hpread_adjust_bitoffsets (anon_type, bitoffset);
4043 field = hpread_get_next_skip_over_anon_unions (TYPE_NFIELDS (anon_type), field, fieldp, objfile);