1 /* Read hp debug symbols and convert to internal format, for GDB.
2 Copyright 1993, 1996, 1998, 1999, 2000 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 (sltpointer
, struct objfile
*);
88 static unsigned long hpread_get_line (sltpointer
, struct objfile
*);
90 static CORE_ADDR
hpread_get_location (sltpointer
, struct objfile
*);
92 static void hpread_psymtab_to_symtab_1 (struct partial_symtab
*);
94 void hpread_psymtab_to_symtab (struct partial_symtab
*);
96 static struct symtab
*hpread_expand_symtab
97 (struct objfile
*, int, int, CORE_ADDR
, int,
98 struct section_offsets
*, char *);
100 static int hpread_type_translate (dnttpointer
);
102 static struct type
**hpread_lookup_type (dnttpointer
, struct objfile
*);
104 static struct type
*hpread_alloc_type (dnttpointer
, struct objfile
*);
106 static struct type
*hpread_read_enum_type
107 (dnttpointer
, union dnttentry
*, struct objfile
*);
109 static struct type
*hpread_read_function_type
110 (dnttpointer
, union dnttentry
*, struct objfile
*, int);
112 static struct type
*hpread_read_doc_function_type
113 (dnttpointer
, union dnttentry
*, struct objfile
*, int);
115 static struct type
*hpread_read_struct_type
116 (dnttpointer
, union dnttentry
*, struct objfile
*);
118 static struct type
*hpread_get_nth_template_arg (struct objfile
*, int);
120 static struct type
*hpread_read_templ_arg_type
121 (dnttpointer
, union dnttentry
*, struct objfile
*, char *);
123 static struct type
*hpread_read_set_type
124 (dnttpointer
, union dnttentry
*, struct objfile
*);
126 static struct type
*hpread_read_array_type
127 (dnttpointer
, union dnttentry
*dn_bufp
, struct objfile
*objfile
);
129 static struct type
*hpread_read_subrange_type
130 (dnttpointer
, union dnttentry
*, struct objfile
*);
132 static struct type
*hpread_type_lookup (dnttpointer
, struct objfile
*);
134 static sltpointer hpread_record_lines
135 (struct subfile
*, sltpointer
, sltpointer
, struct objfile
*, CORE_ADDR
);
137 static void hpread_process_one_debug_symbol
138 (union dnttentry
*, char *, struct section_offsets
*,
139 struct objfile
*, CORE_ADDR
, int, char *, int, int *);
141 static int hpread_get_scope_depth (union dnttentry
*, struct objfile
*, int);
143 static void fix_static_member_physnames
144 (struct type
*, char *, struct objfile
*);
146 static void fixup_class_method_type
147 (struct type
*, struct type
*, struct objfile
*);
149 static void hpread_adjust_bitoffsets (struct type
*, int);
151 static dnttpointer hpread_get_next_skip_over_anon_unions
152 (int, dnttpointer
, union dnttentry
**, struct objfile
*);
154 /* Global to indicate presence of HP-compiled objects,
155 in particular, SOM executable file with SOM debug info
156 Defined in symtab.c, used in hppa-tdep.c. */
157 extern int hp_som_som_object_present
;
159 /* Static used to indicate a class type that requires a
160 fix-up of one of its method types */
161 static struct type
*fixup_class
= NULL
;
163 /* Static used to indicate the method type that is to be
164 used to fix-up the type for fixup_class */
165 static struct type
*fixup_method
= NULL
;
169 /* Get the nesting depth for the source line identified by INDEX. */
172 hpread_get_scope_start (sltpointer index
, struct objfile
*objfile
)
174 union sltentry
*sl_bufp
;
176 sl_bufp
= hpread_get_slt (index
, objfile
);
177 return sl_bufp
->sspec
.backptr
.dnttp
.index
;
180 /* Get the source line number the the line identified by INDEX. */
183 hpread_get_line (sltpointer index
, struct objfile
*objfile
)
185 union sltentry
*sl_bufp
;
187 sl_bufp
= hpread_get_slt (index
, objfile
);
188 return sl_bufp
->snorm
.line
;
191 /* Find the code address associated with a given sltpointer */
194 hpread_get_location (sltpointer index
, struct objfile
*objfile
)
196 union sltentry
*sl_bufp
;
199 /* code location of special sltentrys is determined from context */
200 sl_bufp
= hpread_get_slt (index
, objfile
);
202 if (sl_bufp
->snorm
.sltdesc
== SLT_END
)
204 /* find previous normal sltentry and get address */
205 for (i
= 0; ((sl_bufp
->snorm
.sltdesc
!= SLT_NORMAL
) &&
206 (sl_bufp
->snorm
.sltdesc
!= SLT_NORMAL_OFFSET
) &&
207 (sl_bufp
->snorm
.sltdesc
!= SLT_EXIT
)); i
++)
208 sl_bufp
= hpread_get_slt (index
- i
, objfile
);
209 if (sl_bufp
->snorm
.sltdesc
== SLT_NORMAL_OFFSET
)
210 return sl_bufp
->snormoff
.address
;
212 return sl_bufp
->snorm
.address
;
215 /* find next normal sltentry and get address */
216 for (i
= 0; ((sl_bufp
->snorm
.sltdesc
!= SLT_NORMAL
) &&
217 (sl_bufp
->snorm
.sltdesc
!= SLT_NORMAL_OFFSET
) &&
218 (sl_bufp
->snorm
.sltdesc
!= SLT_EXIT
)); i
++)
219 sl_bufp
= hpread_get_slt (index
+ i
, objfile
);
220 if (sl_bufp
->snorm
.sltdesc
== SLT_NORMAL_OFFSET
)
221 return sl_bufp
->snormoff
.address
;
223 return sl_bufp
->snorm
.address
;
227 /* Return 1 if an HP debug symbol of type KIND has a name associated with
228 * it, else return 0. (This function is not currently used, but I'll
229 * leave it here in case it proves useful later on. - RT).
233 hpread_has_name (enum dntt_entry_type kind
)
237 case DNTT_TYPE_SRCFILE
:
238 case DNTT_TYPE_MODULE
:
239 case DNTT_TYPE_FUNCTION
:
240 case DNTT_TYPE_DOC_FUNCTION
:
241 case DNTT_TYPE_ENTRY
:
242 case DNTT_TYPE_IMPORT
:
243 case DNTT_TYPE_LABEL
:
244 case DNTT_TYPE_FPARAM
:
247 case DNTT_TYPE_CONST
:
248 case DNTT_TYPE_TYPEDEF
:
249 case DNTT_TYPE_TAGDEF
:
250 case DNTT_TYPE_MEMENUM
:
251 case DNTT_TYPE_FIELD
:
253 case DNTT_TYPE_BLOCKDATA
:
254 case DNTT_TYPE_MEMFUNC
:
255 case DNTT_TYPE_DOC_MEMFUNC
:
258 case DNTT_TYPE_BEGIN
:
260 case DNTT_TYPE_POINTER
:
263 case DNTT_TYPE_ARRAY
:
264 case DNTT_TYPE_STRUCT
:
265 case DNTT_TYPE_UNION
:
266 case DNTT_TYPE_VARIANT
:
268 case DNTT_TYPE_FUNCTYPE
:
269 case DNTT_TYPE_SUBRANGE
:
271 case DNTT_TYPE_COMMON
:
272 case DNTT_TYPE_COBSTRUCT
:
274 case DNTT_TYPE_MACRO
:
275 case DNTT_TYPE_CLASS_SCOPE
:
276 case DNTT_TYPE_REFERENCE
:
277 case DNTT_TYPE_PTRMEM
:
278 case DNTT_TYPE_PTRMEMFUNC
:
279 case DNTT_TYPE_CLASS
:
280 case DNTT_TYPE_GENFIELD
:
281 case DNTT_TYPE_VFUNC
:
282 case DNTT_TYPE_MEMACCESS
:
283 case DNTT_TYPE_INHERITANCE
:
284 case DNTT_TYPE_FRIEND_CLASS
:
285 case DNTT_TYPE_FRIEND_FUNC
:
286 case DNTT_TYPE_MODIFIER
:
287 case DNTT_TYPE_OBJECT_ID
:
288 case DNTT_TYPE_TEMPLATE
:
289 case DNTT_TYPE_TEMPLATE_ARG
:
290 case DNTT_TYPE_FUNC_TEMPLATE
:
292 /* DNTT_TYPE_DYN_ARRAY_DESC ? */
293 /* DNTT_TYPE_DESC_SUBRANGE ? */
294 /* DNTT_TYPE_BEGIN_EXT ? */
295 /* DNTT_TYPE_INLN ? */
296 /* DNTT_TYPE_INLN_LIST ? */
297 /* DNTT_TYPE_ALIAS ? */
303 /* Do the dirty work of reading in the full symbol from a partial symbol
307 hpread_psymtab_to_symtab_1 (struct partial_symtab
*pst
)
309 struct cleanup
*old_chain
;
312 /* Get out quick if passed junk. */
316 /* Complain if we've already read in this symbol table. */
319 fprintf (stderr
, "Psymtab for %s already read in. Shouldn't happen.\n",
324 /* Read in all partial symtabs on which this one is dependent */
325 for (i
= 0; i
< pst
->number_of_dependencies
; i
++)
326 if (!pst
->dependencies
[i
]->readin
)
328 /* Inform about additional files that need to be read in. */
331 fputs_filtered (" ", gdb_stdout
);
333 fputs_filtered ("and ", gdb_stdout
);
335 printf_filtered ("%s...", pst
->dependencies
[i
]->filename
);
336 wrap_here (""); /* Flush output */
337 gdb_flush (gdb_stdout
);
339 hpread_psymtab_to_symtab_1 (pst
->dependencies
[i
]);
342 /* If it's real... */
345 /* Init stuff necessary for reading in symbols */
347 old_chain
= make_cleanup (really_free_pendings
, 0);
350 hpread_expand_symtab (pst
->objfile
, LDSYMOFF (pst
), LDSYMLEN (pst
),
351 pst
->textlow
, pst
->texthigh
- pst
->textlow
,
352 pst
->section_offsets
, pst
->filename
);
353 sort_symtab_syms (pst
->symtab
);
355 do_cleanups (old_chain
);
361 /* Read in all of the symbols for a given psymtab for real.
362 Be verbose about it if the user wants that. */
365 hpread_psymtab_to_symtab (struct partial_symtab
*pst
)
367 /* Get out quick if given junk. */
374 fprintf (stderr
, "Psymtab for %s already read in. Shouldn't happen.\n",
379 /* elz: setting the flag to indicate that the code of the target
380 was compiled using an HP compiler (aCC, cc)
381 the processing_acc_compilation variable is declared in the
382 file buildsym.h, the HP_COMPILED_TARGET is defined to be equal
383 to 3 in the file tm_hppa.h */
385 processing_gcc_compilation
= 0;
387 if (LDSYMLEN (pst
) || pst
->number_of_dependencies
)
389 /* Print the message now, before reading the string table,
390 to avoid disconcerting pauses. */
393 printf_filtered ("Reading in symbols for %s...", pst
->filename
);
394 gdb_flush (gdb_stdout
);
397 hpread_psymtab_to_symtab_1 (pst
);
399 /* Match with global symbols. This only needs to be done once,
400 after all of the symtabs and dependencies have been read in. */
401 scan_file_globals (pst
->objfile
);
403 /* Finish up the debug error message. */
405 printf_filtered ("done.\n");
409 /* Read in a defined section of a specific object file's symbols.
411 DESC is the file descriptor for the file, positioned at the
412 beginning of the symtab
413 SYM_OFFSET is the offset within the file of
414 the beginning of the symbols we want to read
415 SYM_SIZE is the size of the symbol info to read in.
416 TEXT_OFFSET is the beginning of the text segment we are reading symbols for
417 TEXT_SIZE is the size of the text segment read in.
418 SECTION_OFFSETS are the relocation offsets which get added to each symbol. */
420 static struct symtab
*
421 hpread_expand_symtab (struct objfile
*objfile
, int sym_offset
, int sym_size
,
422 CORE_ADDR text_offset
, int text_size
,
423 struct section_offsets
*section_offsets
, char *filename
)
426 union dnttentry
*dn_bufp
;
428 int at_module_boundary
= 0;
429 /* 1 => at end, -1 => at beginning */
431 int sym_index
= sym_offset
/ sizeof (struct dntt_type_block
);
433 current_objfile
= objfile
;
436 last_source_file
= 0;
438 /* Demangling style -- if EDG style already set, don't change it,
439 as HP style causes some problems with the KAI EDG compiler */
440 if (current_demangling_style
!= edg_demangling
)
442 /* Otherwise, ensure that we are using HP style demangling */
443 set_demangling_style (HP_DEMANGLING_STYLE_STRING
);
446 dn_bufp
= hpread_get_lntt (sym_index
, objfile
);
447 if (!((dn_bufp
->dblock
.kind
== (unsigned char) DNTT_TYPE_SRCFILE
) ||
448 (dn_bufp
->dblock
.kind
== (unsigned char) DNTT_TYPE_MODULE
)))
450 start_symtab ("globals", NULL
, 0);
451 record_debugformat ("HP");
454 /* The psymtab builder (hp-psymtab-read.c) is the one that
455 * determined the "sym_size" argument (i.e. how many DNTT symbols
456 * are in this symtab), which we use to compute "max_symnum"
457 * (point in DNTT to which we read).
459 * Perhaps this should be changed so that
460 * process_one_debug_symbol() "knows" when
461 * to stop reading (based on reading from the MODULE to the matching
462 * END), and take out this reliance on a #-syms being passed in...
463 * (I'm worried about the reliability of this number). But I'll
464 * leave it as-is, for now. - RT
466 * The change above has been made. I've left the "for" loop control
467 * in to prepare for backing this out again. -JB
469 max_symnum
= sym_size
/ sizeof (struct dntt_type_block
);
470 /* No reason to multiply on pst side and divide on sym side... FIXME */
472 /* Read in and process each debug symbol within the specified range.
478 QUIT
; /* Allow this to be interruptable */
479 dn_bufp
= hpread_get_lntt (sym_index
+ symnum
, objfile
);
481 if (dn_bufp
->dblock
.extension
)
484 /* Yow! We call SET_NAMESTRING on things without names! */
485 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
487 hpread_process_one_debug_symbol (dn_bufp
, namestring
, section_offsets
,
488 objfile
, text_offset
, text_size
,
489 filename
, symnum
+ sym_index
,
493 /* OLD COMMENTS: This routine is only called for psts. All psts
494 * correspond to MODULES. If we ever do lazy-reading of globals
495 * from the LNTT, then there will be a pst which ends when the
496 * LNTT ends, and not at an END MODULE entry. Then we'll have
497 * to re-visit this break.
499 if( at_end_of_module )
504 /* We no longer break out of the loop when we reach the end of a
505 module. The reason is that with CTTI, the compiler can generate
506 function symbols (for template function instantiations) which are not
507 in any module; typically they show up beyond a module's end, and
508 before the next module's start. We include them in the current
509 module. However, we still don't trust the MAX_SYMNUM value from
510 the psymtab, so we break out if we enter a new module. */
512 if (at_module_boundary
== -1)
516 current_objfile
= NULL
;
517 hp_som_som_object_present
= 1; /* Indicate we've processed an HP SOM SOM file */
519 return end_symtab (text_offset
+ text_size
, objfile
, SECT_OFF_TEXT (objfile
));
525 /* Convert basic types from HP debug format into GDB internal format. */
528 hpread_type_translate (dnttpointer typep
)
530 if (!typep
.dntti
.immediate
)
532 error ("error in hpread_type_translate\n.");
536 switch (typep
.dntti
.type
)
538 case HP_TYPE_BOOLEAN
:
539 case HP_TYPE_BOOLEAN_S300_COMPAT
:
540 case HP_TYPE_BOOLEAN_VAX_COMPAT
:
542 case HP_TYPE_CHAR
: /* C signed char, C++ plain char */
544 case HP_TYPE_WIDE_CHAR
:
547 if (typep
.dntti
.bitlength
<= 8)
548 return FT_SIGNED_CHAR
; /* C++ signed char */
549 if (typep
.dntti
.bitlength
<= 16)
551 if (typep
.dntti
.bitlength
<= 32)
555 if (typep
.dntti
.bitlength
<= 8)
556 return FT_SIGNED_CHAR
; /* C++ signed char. */
558 case HP_TYPE_UNSIGNED_LONG
:
559 if (typep
.dntti
.bitlength
<= 8)
560 return FT_UNSIGNED_CHAR
; /* C/C++ unsigned char */
561 if (typep
.dntti
.bitlength
<= 16)
562 return FT_UNSIGNED_SHORT
;
563 if (typep
.dntti
.bitlength
<= 32)
564 return FT_UNSIGNED_LONG
;
565 return FT_UNSIGNED_LONG_LONG
;
566 case HP_TYPE_UNSIGNED_INT
:
567 if (typep
.dntti
.bitlength
<= 8)
568 return FT_UNSIGNED_CHAR
;
569 if (typep
.dntti
.bitlength
<= 16)
570 return FT_UNSIGNED_SHORT
;
571 if (typep
.dntti
.bitlength
<= 32)
572 return FT_UNSIGNED_INTEGER
;
573 return FT_UNSIGNED_LONG_LONG
;
575 case HP_TYPE_REAL_3000
:
577 if (typep
.dntti
.bitlength
== 64)
578 return FT_DBL_PREC_FLOAT
;
579 if (typep
.dntti
.bitlength
== 128)
580 return FT_EXT_PREC_FLOAT
;
582 case HP_TYPE_COMPLEX
:
583 case HP_TYPE_COMPLEXS3000
:
584 if (typep
.dntti
.bitlength
== 128)
585 return FT_DBL_PREC_COMPLEX
;
586 if (typep
.dntti
.bitlength
== 192)
587 return FT_EXT_PREC_COMPLEX
;
591 case HP_TYPE_STRING200
:
592 case HP_TYPE_LONGSTRING200
:
593 case HP_TYPE_FTN_STRING_SPEC
:
594 case HP_TYPE_MOD_STRING_SPEC
:
595 case HP_TYPE_MOD_STRING_3000
:
596 case HP_TYPE_FTN_STRING_S300_COMPAT
:
597 case HP_TYPE_FTN_STRING_VAX_COMPAT
:
599 case HP_TYPE_TEMPLATE_ARG
:
600 return FT_TEMPLATE_ARG
;
603 case HP_TYPE_PACKED_DECIMAL
:
604 case HP_TYPE_ANYPOINTER
:
605 case HP_TYPE_GLOBAL_ANYPOINTER
:
606 case HP_TYPE_LOCAL_ANYPOINTER
:
608 warning ("hpread_type_translate: unhandled type code.\n");
613 /* Given a position in the DNTT, return a pointer to the
614 * already-built "struct type" (if any), for the type defined
618 static struct type
**
619 hpread_lookup_type (dnttpointer hp_type
, struct objfile
*objfile
)
622 int index
= hp_type
.dnttp
.index
;
623 int size_changed
= 0;
625 /* The immediate flag indicates this doesn't actually point to
628 if (hp_type
.dntti
.immediate
)
631 /* For each objfile, we maintain a "type vector".
632 * This an array of "struct type *"'s with one pointer per DNTT index.
633 * Given a DNTT index, we look in this array to see if we have
634 * already processed this DNTT and if it is a type definition.
635 * If so, then we can locate a pointer to the already-built
636 * "struct type", and not build it again.
638 * The need for this arises because our DNTT-walking code wanders
639 * around. In particular, it will encounter the same type multiple
640 * times (once for each object of that type). We don't want to
641 * built multiple "struct type"'s for the same thing.
643 * Having said this, I should point out that this type-vector is
644 * an expensive way to keep track of this. If most DNTT entries are
645 * 3 words, the type-vector will be 1/3 the size of the DNTT itself.
646 * Alternative solutions:
647 * - Keep a compressed or hashed table. Less memory, but more expensive
648 * to search and update.
649 * - (Suggested by JB): Overwrite the DNTT entry itself
650 * with the info. Create a new type code "ALREADY_BUILT", and modify
651 * the DNTT to have that type code and point to the already-built entry.
655 if (index
< LNTT_SYMCOUNT (objfile
))
657 if (index
>= TYPE_VECTOR_LENGTH (objfile
))
659 old_len
= TYPE_VECTOR_LENGTH (objfile
);
661 /* See if we need to allocate a type-vector. */
664 TYPE_VECTOR_LENGTH (objfile
) = LNTT_SYMCOUNT (objfile
) + GNTT_SYMCOUNT (objfile
);
665 TYPE_VECTOR (objfile
) = (struct type
**)
666 xmmalloc (objfile
->md
, TYPE_VECTOR_LENGTH (objfile
) * sizeof (struct type
*));
667 memset (&TYPE_VECTOR (objfile
)[old_len
], 0,
668 (TYPE_VECTOR_LENGTH (objfile
) - old_len
) *
669 sizeof (struct type
*));
672 /* See if we need to resize type-vector. With my change to
673 * initially allocate a correct-size type-vector, this code
674 * should no longer trigger.
676 while (index
>= TYPE_VECTOR_LENGTH (objfile
))
678 TYPE_VECTOR_LENGTH (objfile
) *= 2;
683 TYPE_VECTOR (objfile
) = (struct type
**)
684 xmrealloc (objfile
->md
,
685 (char *) TYPE_VECTOR (objfile
),
686 (TYPE_VECTOR_LENGTH (objfile
) * sizeof (struct type
*)));
688 memset (&TYPE_VECTOR (objfile
)[old_len
], 0,
689 (TYPE_VECTOR_LENGTH (objfile
) - old_len
) *
690 sizeof (struct type
*));
694 return &TYPE_VECTOR (objfile
)[index
];
700 /* Possibly allocate a GDB internal type so we can internalize HP_TYPE.
701 Note we'll just return the address of a GDB internal type if we already
702 have it lying around. */
705 hpread_alloc_type (dnttpointer hp_type
, struct objfile
*objfile
)
707 struct type
**type_addr
;
709 type_addr
= hpread_lookup_type (hp_type
, objfile
);
712 *type_addr
= alloc_type (objfile
);
714 /* A hack - if we really are a C++ class symbol, then this default
715 * will get overriden later on.
717 TYPE_CPLUS_SPECIFIC (*type_addr
)
718 = (struct cplus_struct_type
*) &cplus_struct_default
;
724 /* Read a native enumerated type and return it in GDB internal form. */
727 hpread_read_enum_type (dnttpointer hp_type
, union dnttentry
*dn_bufp
,
728 struct objfile
*objfile
)
731 struct pending
**symlist
, *osyms
, *syms
;
732 struct pending
*local_list
= NULL
;
733 int o_nsyms
, nsyms
= 0;
735 union dnttentry
*memp
;
740 /* Allocate a GDB type. If we've already read in this enum type,
741 * it'll return the already built GDB type, so stop here.
742 * (Note: I added this check, to conform with what's done for
743 * struct, union, class.
744 * I assume this is OK. - RT)
746 type
= hpread_alloc_type (hp_type
, objfile
);
747 if (TYPE_CODE (type
) == TYPE_CODE_ENUM
)
750 /* HP C supports "sized enums", where a specifier such as "short" or
751 "char" can be used to get enums of different sizes. So don't assume
752 an enum is always 4 bytes long. pai/1997-08-21 */
753 TYPE_LENGTH (type
) = dn_bufp
->denum
.bitlength
/ 8;
755 symlist
= &file_symbols
;
757 o_nsyms
= osyms
? osyms
->nsyms
: 0;
759 /* Get a name for each member and add it to our list of members.
760 * The list of "mem" SOM records we are walking should all be
761 * SOM type DNTT_TYPE_MEMENUM (not checked).
763 mem
= dn_bufp
->denum
.firstmem
;
764 while (mem
.word
&& mem
.word
!= DNTTNIL
)
766 memp
= hpread_get_lntt (mem
.dnttp
.index
, objfile
);
768 name
= VT (objfile
) + memp
->dmember
.name
;
769 sym
= (struct symbol
*) obstack_alloc (&objfile
->symbol_obstack
,
770 sizeof (struct symbol
));
771 memset (sym
, 0, sizeof (struct symbol
));
772 SYMBOL_NAME (sym
) = obsavestring (name
, strlen (name
),
773 &objfile
->symbol_obstack
);
774 SYMBOL_CLASS (sym
) = LOC_CONST
;
775 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
776 SYMBOL_VALUE (sym
) = memp
->dmember
.value
;
777 add_symbol_to_list (sym
, symlist
);
779 mem
= memp
->dmember
.nextmem
;
782 /* Now that we know more about the enum, fill in more info. */
783 TYPE_CODE (type
) = TYPE_CODE_ENUM
;
784 TYPE_FLAGS (type
) &= ~TYPE_FLAG_STUB
;
785 TYPE_NFIELDS (type
) = nsyms
;
786 TYPE_FIELDS (type
) = (struct field
*)
787 obstack_alloc (&objfile
->type_obstack
, sizeof (struct field
) * nsyms
);
789 /* Find the symbols for the members and put them into the type.
790 The symbols can be found in the symlist that we put them on
791 to cause them to be defined. osyms contains the old value
792 of that symlist; everything up to there was defined by us.
794 Note that we preserve the order of the enum constants, so
795 that in something like "enum {FOO, LAST_THING=FOO}" we print
796 FOO, not LAST_THING. */
797 for (syms
= *symlist
, n
= 0; syms
; syms
= syms
->next
)
802 for (; j
< syms
->nsyms
; j
++, n
++)
804 struct symbol
*xsym
= syms
->symbol
[j
];
805 SYMBOL_TYPE (xsym
) = type
;
806 TYPE_FIELD_NAME (type
, n
) = SYMBOL_NAME (xsym
);
807 TYPE_FIELD_BITPOS (type
, n
) = SYMBOL_VALUE (xsym
);
808 TYPE_FIELD_BITSIZE (type
, n
) = 0;
817 /* Read and internalize a native function debug symbol. */
820 hpread_read_function_type (dnttpointer hp_type
, union dnttentry
*dn_bufp
,
821 struct objfile
*objfile
, int newblock
)
823 struct type
*type
, *type1
;
824 struct pending
*syms
;
825 struct pending
*local_list
= NULL
;
828 union dnttentry
*paramp
;
834 /* See if we've already read in this type. */
835 type
= hpread_alloc_type (hp_type
, objfile
);
836 if (TYPE_CODE (type
) == TYPE_CODE_FUNC
)
838 record_args
= 0; /* already read in, don't modify type */
842 /* Nope, so read it in and store it away. */
843 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_FUNCTION
||
844 dn_bufp
->dblock
.kind
== DNTT_TYPE_MEMFUNC
)
845 type1
= lookup_function_type (hpread_type_lookup (dn_bufp
->dfunc
.retval
,
847 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_FUNCTYPE
)
848 type1
= lookup_function_type (hpread_type_lookup (dn_bufp
->dfunctype
.retval
,
850 else /* expect DNTT_TYPE_FUNC_TEMPLATE */
851 type1
= lookup_function_type (hpread_type_lookup (dn_bufp
->dfunc_template
.retval
,
853 memcpy ((char *) type
, (char *) type1
, sizeof (struct type
));
855 /* Mark it -- in the middle of processing */
856 TYPE_FLAGS (type
) |= TYPE_FLAG_INCOMPLETE
;
859 /* Now examine each parameter noting its type, location, and a
860 wealth of other information. */
861 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_FUNCTION
||
862 dn_bufp
->dblock
.kind
== DNTT_TYPE_MEMFUNC
)
863 param
= dn_bufp
->dfunc
.firstparam
;
864 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_FUNCTYPE
)
865 param
= dn_bufp
->dfunctype
.firstparam
;
866 else /* expect DNTT_TYPE_FUNC_TEMPLATE */
867 param
= dn_bufp
->dfunc_template
.firstparam
;
868 while (param
.word
&& param
.word
!= DNTTNIL
)
870 paramp
= hpread_get_lntt (param
.dnttp
.index
, objfile
);
872 param
= paramp
->dfparam
.nextparam
;
875 name
= VT (objfile
) + paramp
->dfparam
.name
;
876 sym
= (struct symbol
*) obstack_alloc (&objfile
->symbol_obstack
,
877 sizeof (struct symbol
));
878 (void) memset (sym
, 0, sizeof (struct symbol
));
879 SYMBOL_NAME (sym
) = obsavestring (name
, strlen (name
),
880 &objfile
->symbol_obstack
);
882 /* Figure out where it lives. */
883 if (paramp
->dfparam
.regparam
)
884 SYMBOL_CLASS (sym
) = LOC_REGPARM
;
885 else if (paramp
->dfparam
.indirect
)
886 SYMBOL_CLASS (sym
) = LOC_REF_ARG
;
888 SYMBOL_CLASS (sym
) = LOC_ARG
;
889 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
890 if (paramp
->dfparam
.copyparam
)
892 SYMBOL_VALUE (sym
) = paramp
->dfparam
.location
;
893 #ifdef HPREAD_ADJUST_STACK_ADDRESS
895 += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile
));
897 /* This is likely a pass-by-invisible reference parameter,
898 Hack on the symbol class to make GDB happy. */
899 /* ??rehrauer: This appears to be broken w/r/t to passing
900 C values of type float and struct. Perhaps this ought
901 to be highighted as a special case, but for now, just
902 allowing these to be LOC_ARGs seems to work fine.
905 SYMBOL_CLASS (sym
) = LOC_REGPARM_ADDR
;
909 SYMBOL_VALUE (sym
) = paramp
->dfparam
.location
;
912 SYMBOL_TYPE (sym
) = hpread_type_lookup (paramp
->dfparam
.type
, objfile
);
913 /* Add it to the symbol list. */
914 /* Note 1 (RT) At the moment, add_symbol_to_list() is also being
915 * called on FPARAM symbols from the process_one_debug_symbol()
916 * level... so parameters are getting added twice! (this shows
917 * up in the symbol dump you get from "maint print symbols ...").
918 * Note 2 (RT) I took out the processing of FPARAM from the
919 * process_one_debug_symbol() level, so at the moment parameters are only
920 * being processed here. This seems to have no ill effect.
922 /* Note 3 (pai/1997-08-11) I removed the add_symbol_to_list() which put
923 each fparam on the local_symbols list from here. Now we use the
924 local_list to which fparams are added below, and set the param_symbols
925 global to point to that at the end of this routine. */
926 /* elz: I added this new list of symbols which is local to the function.
927 this list is the one which is actually used to build the type for the
928 function rather than the gloabal list pointed to by symlist.
929 Using a global list to keep track of the parameters is wrong, because
930 this function is called recursively if one parameter happend to be
931 a function itself with more parameters in it. Adding parameters to the
932 same global symbol list would not work!
933 Actually it did work in case of cc compiled programs where you do
934 not check the parameter lists of the arguments. */
935 add_symbol_to_list (sym
, &local_list
);
939 /* If type was read in earlier, don't bother with modifying
944 /* Note how many parameters we found. */
945 TYPE_NFIELDS (type
) = nsyms
;
946 TYPE_FIELDS (type
) = (struct field
*)
947 obstack_alloc (&objfile
->type_obstack
,
948 sizeof (struct field
) * nsyms
);
950 /* Find the symbols for the parameters and
951 use them to fill parameter-type information into the function-type.
952 The parameter symbols can be found in the local_list that we just put them on. */
953 /* Note that we preserve the order of the parameters, so
954 that in something like "enum {FOO, LAST_THING=FOO}" we print
955 FOO, not LAST_THING. */
957 /* get the parameters types from the local list not the global list
958 so that the type can be correctly constructed for functions which
959 have function as parameters */
960 for (syms
= local_list
, n
= 0; syms
; syms
= syms
->next
)
963 for (j
= 0; j
< syms
->nsyms
; j
++, n
++)
965 struct symbol
*xsym
= syms
->symbol
[j
];
966 TYPE_FIELD_NAME (type
, n
) = SYMBOL_NAME (xsym
);
967 TYPE_FIELD_TYPE (type
, n
) = SYMBOL_TYPE (xsym
);
968 TYPE_FIELD_BITPOS (type
, n
) = n
;
969 TYPE_FIELD_BITSIZE (type
, n
) = 0;
972 /* Mark it as having been processed */
973 TYPE_FLAGS (type
) &= ~(TYPE_FLAG_INCOMPLETE
);
975 /* Check whether we need to fix-up a class type with this function's type */
976 if (fixup_class
&& (fixup_method
== type
))
978 fixup_class_method_type (fixup_class
, fixup_method
, objfile
);
983 /* Set the param list of this level of the context stack
984 to our local list. Do this only if this function was
985 called for creating a new block, and not if it was called
986 simply to get the function type. This prevents recursive
987 invocations from trashing param_symbols. */
990 param_symbols
= local_list
;
996 /* Read and internalize a native DOC function debug symbol. */
997 /* This is almost identical to hpread_read_function_type(), except
998 * for references to dn_bufp->ddocfunc instead of db_bufp->dfunc.
999 * Since debug information for DOC functions is more likely to be
1000 * volatile, please leave it this way.
1002 static struct type
*
1003 hpread_read_doc_function_type (dnttpointer hp_type
, union dnttentry
*dn_bufp
,
1004 struct objfile
*objfile
, int newblock
)
1006 struct type
*type
, *type1
;
1007 struct pending
*syms
;
1008 struct pending
*local_list
= NULL
;
1011 union dnttentry
*paramp
;
1015 int record_args
= 1;
1017 /* See if we've already read in this type. */
1018 type
= hpread_alloc_type (hp_type
, objfile
);
1019 if (TYPE_CODE (type
) == TYPE_CODE_FUNC
)
1021 record_args
= 0; /* already read in, don't modify type */
1025 /* Nope, so read it in and store it away. */
1026 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_DOC_FUNCTION
||
1027 dn_bufp
->dblock
.kind
== DNTT_TYPE_DOC_MEMFUNC
)
1028 type1
= lookup_function_type (hpread_type_lookup (dn_bufp
->ddocfunc
.retval
,
1030 memcpy ((char *) type
, (char *) type1
, sizeof (struct type
));
1032 /* Mark it -- in the middle of processing */
1033 TYPE_FLAGS (type
) |= TYPE_FLAG_INCOMPLETE
;
1036 /* Now examine each parameter noting its type, location, and a
1037 wealth of other information. */
1038 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_DOC_FUNCTION
||
1039 dn_bufp
->dblock
.kind
== DNTT_TYPE_DOC_MEMFUNC
)
1040 param
= dn_bufp
->ddocfunc
.firstparam
;
1041 while (param
.word
&& param
.word
!= DNTTNIL
)
1043 paramp
= hpread_get_lntt (param
.dnttp
.index
, objfile
);
1045 param
= paramp
->dfparam
.nextparam
;
1048 name
= VT (objfile
) + paramp
->dfparam
.name
;
1049 sym
= (struct symbol
*) obstack_alloc (&objfile
->symbol_obstack
,
1050 sizeof (struct symbol
));
1051 (void) memset (sym
, 0, sizeof (struct symbol
));
1052 SYMBOL_NAME (sym
) = name
;
1054 /* Figure out where it lives. */
1055 if (paramp
->dfparam
.regparam
)
1056 SYMBOL_CLASS (sym
) = LOC_REGPARM
;
1057 else if (paramp
->dfparam
.indirect
)
1058 SYMBOL_CLASS (sym
) = LOC_REF_ARG
;
1060 SYMBOL_CLASS (sym
) = LOC_ARG
;
1061 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1062 if (paramp
->dfparam
.copyparam
)
1064 SYMBOL_VALUE (sym
) = paramp
->dfparam
.location
;
1065 #ifdef HPREAD_ADJUST_STACK_ADDRESS
1067 += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile
));
1069 /* This is likely a pass-by-invisible reference parameter,
1070 Hack on the symbol class to make GDB happy. */
1071 /* ??rehrauer: This appears to be broken w/r/t to passing
1072 C values of type float and struct. Perhaps this ought
1073 to be highighted as a special case, but for now, just
1074 allowing these to be LOC_ARGs seems to work fine.
1077 SYMBOL_CLASS (sym
) = LOC_REGPARM_ADDR
;
1081 SYMBOL_VALUE (sym
) = paramp
->dfparam
.location
;
1084 SYMBOL_TYPE (sym
) = hpread_type_lookup (paramp
->dfparam
.type
, objfile
);
1085 /* Add it to the symbol list. */
1086 /* Note 1 (RT) At the moment, add_symbol_to_list() is also being
1087 * called on FPARAM symbols from the process_one_debug_symbol()
1088 * level... so parameters are getting added twice! (this shows
1089 * up in the symbol dump you get from "maint print symbols ...").
1090 * Note 2 (RT) I took out the processing of FPARAM from the
1091 * process_one_debug_symbol() level, so at the moment parameters are only
1092 * being processed here. This seems to have no ill effect.
1094 /* Note 3 (pai/1997-08-11) I removed the add_symbol_to_list() which put
1095 each fparam on the local_symbols list from here. Now we use the
1096 local_list to which fparams are added below, and set the param_symbols
1097 global to point to that at the end of this routine. */
1099 /* elz: I added this new list of symbols which is local to the function.
1100 this list is the one which is actually used to build the type for the
1101 function rather than the gloabal list pointed to by symlist.
1102 Using a global list to keep track of the parameters is wrong, because
1103 this function is called recursively if one parameter happend to be
1104 a function itself with more parameters in it. Adding parameters to the
1105 same global symbol list would not work!
1106 Actually it did work in case of cc compiled programs where you do not check the
1107 parameter lists of the arguments. */
1108 add_symbol_to_list (sym
, &local_list
);
1111 /* If type was read in earlier, don't bother with modifying
1116 /* Note how many parameters we found. */
1117 TYPE_NFIELDS (type
) = nsyms
;
1118 TYPE_FIELDS (type
) = (struct field
*)
1119 obstack_alloc (&objfile
->type_obstack
,
1120 sizeof (struct field
) * nsyms
);
1122 /* Find the symbols for the parameters and
1123 use them to fill parameter-type information into the function-type.
1124 The parameter symbols can be found in the local_list that we just put them on. */
1125 /* Note that we preserve the order of the parameters, so
1126 that in something like "enum {FOO, LAST_THING=FOO}" we print
1127 FOO, not LAST_THING. */
1129 /* get the parameters types from the local list not the global list
1130 so that the type can be correctly constructed for functions which
1131 have function as parameters
1133 for (syms
= local_list
, n
= 0; syms
; syms
= syms
->next
)
1136 for (j
= 0; j
< syms
->nsyms
; j
++, n
++)
1138 struct symbol
*xsym
= syms
->symbol
[j
];
1139 TYPE_FIELD_NAME (type
, n
) = SYMBOL_NAME (xsym
);
1140 TYPE_FIELD_TYPE (type
, n
) = SYMBOL_TYPE (xsym
);
1141 TYPE_FIELD_BITPOS (type
, n
) = n
;
1142 TYPE_FIELD_BITSIZE (type
, n
) = 0;
1146 /* Mark it as having been processed */
1147 TYPE_FLAGS (type
) &= ~(TYPE_FLAG_INCOMPLETE
);
1149 /* Check whether we need to fix-up a class type with this function's type */
1150 if (fixup_class
&& (fixup_method
== type
))
1152 fixup_class_method_type (fixup_class
, fixup_method
, objfile
);
1154 fixup_method
= NULL
;
1157 /* Set the param list of this level of the context stack
1158 to our local list. Do this only if this function was
1159 called for creating a new block, and not if it was called
1160 simply to get the function type. This prevents recursive
1161 invocations from trashing param_symbols. */
1164 param_symbols
= local_list
;
1171 /* A file-level variable which keeps track of the current-template
1172 * being processed. Set in hpread_read_struct_type() while processing
1173 * a template type. Referred to in hpread_get_nth_templ_arg().
1174 * Yes, this is a kludge, but it arises from the kludge that already
1175 * exists in symtab.h, namely the fact that they encode
1176 * "template argument n" with fundamental type FT_TEMPLATE_ARG and
1177 * bitlength n. This means that deep in processing fundamental types
1178 * I need to ask the question "what template am I in the middle of?".
1179 * The alternative to stuffing a global would be to pass an argument
1180 * down the chain of calls just for this purpose.
1182 * There may be problems handling nested templates... tough.
1184 static struct type
*current_template
= NULL
;
1186 /* Read in and internalize a structure definition.
1187 * This same routine is called for struct, union, and class types.
1188 * Also called for templates, since they build a very similar
1189 * type entry as for class types.
1192 static struct type
*
1193 hpread_read_struct_type (dnttpointer hp_type
, union dnttentry
*dn_bufp
,
1194 struct objfile
*objfile
)
1196 /* The data members get linked together into a list of struct nextfield's */
1199 struct nextfield
*next
;
1201 unsigned char attributes
; /* store visibility and virtuality info */
1202 #define ATTR_VIRTUAL 1
1203 #define ATTR_PRIVATE 2
1204 #define ATTR_PROTECT 3
1208 /* The methods get linked together into a list of struct next_fn_field's */
1209 struct next_fn_field
1211 struct next_fn_field
*next
;
1212 struct fn_fieldlist field
;
1213 struct fn_field fn_field
;
1217 /* The template args get linked together into a list of struct next_template's */
1218 struct next_template
1220 struct next_template
*next
;
1221 struct template_arg arg
;
1224 /* The template instantiations get linked together into a list of these... */
1225 struct next_instantiation
1227 struct next_instantiation
*next
;
1232 struct type
*baseclass
;
1233 struct type
*memtype
;
1234 struct nextfield
*list
= 0, *tmp_list
= 0;
1235 struct next_fn_field
*fn_list
= 0;
1236 struct next_fn_field
*fn_p
;
1237 struct next_template
*t_new
, *t_list
= 0;
1238 struct nextfield
*new;
1239 struct next_fn_field
*fn_new
;
1240 struct next_instantiation
*i_new
, *i_list
= 0;
1241 int n
, nfields
= 0, n_fn_fields
= 0, n_fn_fields_total
= 0;
1242 int n_base_classes
= 0, n_templ_args
= 0;
1243 int ninstantiations
= 0;
1244 dnttpointer field
, fn_field
, parent
;
1245 union dnttentry
*fieldp
, *fn_fieldp
, *parentp
;
1247 int static_member
= 0;
1248 int const_member
= 0;
1249 int volatile_member
= 0;
1250 unsigned long vtbl_offset
;
1251 int need_bitvectors
= 0;
1252 char *method_name
= NULL
;
1253 char *method_alias
= NULL
;
1256 /* Is it something we've already dealt with? */
1257 type
= hpread_alloc_type (hp_type
, objfile
);
1258 if ((TYPE_CODE (type
) == TYPE_CODE_STRUCT
) ||
1259 (TYPE_CODE (type
) == TYPE_CODE_UNION
) ||
1260 (TYPE_CODE (type
) == TYPE_CODE_CLASS
) ||
1261 (TYPE_CODE (type
) == TYPE_CODE_TEMPLATE
))
1264 /* Get the basic type correct. */
1265 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_STRUCT
)
1267 TYPE_CODE (type
) = TYPE_CODE_STRUCT
;
1268 TYPE_LENGTH (type
) = dn_bufp
->dstruct
.bitlength
/ 8;
1270 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_UNION
)
1272 TYPE_CODE (type
) = TYPE_CODE_UNION
;
1273 TYPE_LENGTH (type
) = dn_bufp
->dunion
.bitlength
/ 8;
1275 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_CLASS
)
1277 TYPE_CODE (type
) = TYPE_CODE_CLASS
;
1278 TYPE_LENGTH (type
) = dn_bufp
->dclass
.bitlength
/ 8;
1280 /* Overrides the TYPE_CPLUS_SPECIFIC(type) with allocated memory
1281 * rather than &cplus_struct_default.
1283 allocate_cplus_struct_type (type
);
1285 /* Fill in declared-type.
1286 * (The C++ compiler will emit TYPE_CODE_CLASS
1287 * for all 3 of "class", "struct"
1288 * "union", and we have to look at the "class_decl" field if we
1289 * want to know how it was really declared)
1291 /* (0==class, 1==union, 2==struct) */
1292 TYPE_DECLARED_TYPE (type
) = dn_bufp
->dclass
.class_decl
;
1294 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_TEMPLATE
)
1296 /* Get the basic type correct. */
1297 TYPE_CODE (type
) = TYPE_CODE_TEMPLATE
;
1298 allocate_cplus_struct_type (type
);
1299 TYPE_DECLARED_TYPE (type
) = DECLARED_TYPE_TEMPLATE
;
1305 TYPE_FLAGS (type
) &= ~TYPE_FLAG_STUB
;
1307 /* For classes, read the parent list.
1308 * Question (RT): Do we need to do this for templates also?
1310 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_CLASS
)
1313 /* First read the parent-list (classes from which we derive fields) */
1314 parent
= dn_bufp
->dclass
.parentlist
;
1315 while (parent
.word
&& parent
.word
!= DNTTNIL
)
1317 parentp
= hpread_get_lntt (parent
.dnttp
.index
, objfile
);
1319 /* "parentp" should point to a DNTT_TYPE_INHERITANCE record */
1321 /* Get space to record the next field/data-member. */
1322 new = (struct nextfield
*) alloca (sizeof (struct nextfield
));
1326 FIELD_BITSIZE (list
->field
) = 0;
1328 /* The "classname" field is actually a DNTT pointer to the base class */
1329 baseclass
= hpread_type_lookup (parentp
->dinheritance
.classname
,
1331 FIELD_TYPE (list
->field
) = baseclass
;
1333 list
->field
.name
= type_name_no_tag (FIELD_TYPE (list
->field
));
1335 list
->attributes
= 0;
1337 /* Check for virtuality of base, and set the
1338 * offset of the base subobject within the object.
1339 * (Offset set to -1 for virtual bases (for now).)
1341 if (parentp
->dinheritance
.Virtual
)
1343 B_SET (&(list
->attributes
), ATTR_VIRTUAL
);
1344 parentp
->dinheritance
.offset
= -1;
1347 FIELD_BITPOS (list
->field
) = parentp
->dinheritance
.offset
;
1349 /* Check visibility */
1350 switch (parentp
->dinheritance
.visibility
)
1353 B_SET (&(list
->attributes
), ATTR_PROTECT
);
1356 B_SET (&(list
->attributes
), ATTR_PRIVATE
);
1363 parent
= parentp
->dinheritance
.next
;
1367 /* For templates, read the template argument list.
1368 * This must be done before processing the member list, because
1369 * the member list may refer back to this. E.g.:
1370 * template <class T1, class T2> class q2 {
1375 * We need to read the argument list "T1", "T2" first.
1377 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_TEMPLATE
)
1379 /* Kludge alert: This stuffs a global "current_template" which
1380 * is referred to by hpread_get_nth_templ_arg(). The global
1381 * is cleared at the end of this routine.
1383 current_template
= type
;
1385 /* Read in the argument list */
1386 field
= dn_bufp
->dtemplate
.arglist
;
1387 while (field
.word
&& field
.word
!= DNTTNIL
)
1389 /* Get this template argument */
1390 fieldp
= hpread_get_lntt (field
.dnttp
.index
, objfile
);
1391 if (fieldp
->dblock
.kind
!= DNTT_TYPE_TEMPLATE_ARG
)
1393 warning ("Invalid debug info: Template argument entry is of wrong kind");
1396 /* Bump the count */
1398 /* Allocate and fill in a struct next_template */
1399 t_new
= (struct next_template
*) alloca (sizeof (struct next_template
));
1400 t_new
->next
= t_list
;
1402 t_list
->arg
.name
= VT (objfile
) + fieldp
->dtempl_arg
.name
;
1403 t_list
->arg
.type
= hpread_read_templ_arg_type (field
, fieldp
,
1404 objfile
, t_list
->arg
.name
);
1405 /* Walk to the next template argument */
1406 field
= fieldp
->dtempl_arg
.nextarg
;
1410 TYPE_NTEMPLATE_ARGS (type
) = n_templ_args
;
1412 if (n_templ_args
> 0)
1413 TYPE_TEMPLATE_ARGS (type
) = (struct template_arg
*)
1414 obstack_alloc (&objfile
->type_obstack
, sizeof (struct template_arg
) * n_templ_args
);
1415 for (n
= n_templ_args
; t_list
; t_list
= t_list
->next
)
1418 TYPE_TEMPLATE_ARG (type
, n
) = t_list
->arg
;
1421 /* Next read in and internalize all the fields/members. */
1422 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_STRUCT
)
1423 field
= dn_bufp
->dstruct
.firstfield
;
1424 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_UNION
)
1425 field
= dn_bufp
->dunion
.firstfield
;
1426 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_CLASS
)
1427 field
= dn_bufp
->dclass
.memberlist
;
1428 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_TEMPLATE
)
1429 field
= dn_bufp
->dtemplate
.memberlist
;
1431 field
.word
= DNTTNIL
;
1433 while (field
.word
&& field
.word
!= DNTTNIL
)
1435 fieldp
= hpread_get_lntt (field
.dnttp
.index
, objfile
);
1437 /* At this point "fieldp" may point to either a DNTT_TYPE_FIELD
1438 * or a DNTT_TYPE_GENFIELD record.
1443 volatile_member
= 0;
1445 if (fieldp
->dblock
.kind
== DNTT_TYPE_GENFIELD
)
1448 /* The type will be GENFIELD if the field is a method or
1449 * a static member (or some other cases -- see below)
1452 /* Follow a link to get to the record for the field. */
1453 fn_field
= fieldp
->dgenfield
.field
;
1454 fn_fieldp
= hpread_get_lntt (fn_field
.dnttp
.index
, objfile
);
1456 /* Virtual funcs are indicated by a VFUNC which points to the
1459 if (fn_fieldp
->dblock
.kind
== DNTT_TYPE_VFUNC
)
1461 vtbl_offset
= fn_fieldp
->dvfunc
.vtbl_offset
;
1462 fn_field
= fn_fieldp
->dvfunc
.funcptr
;
1463 fn_fieldp
= hpread_get_lntt (fn_field
.dnttp
.index
, objfile
);
1466 /* A function's entry may be preceded by a modifier which
1467 * labels it static/constant/volatile.
1469 if (fn_fieldp
->dblock
.kind
== DNTT_TYPE_MODIFIER
)
1471 static_member
= fn_fieldp
->dmodifier
.m_static
;
1472 const_member
= fn_fieldp
->dmodifier
.m_const
;
1473 volatile_member
= fn_fieldp
->dmodifier
.m_volatile
;
1474 fn_field
= fn_fieldp
->dmodifier
.type
;
1475 fn_fieldp
= hpread_get_lntt (fn_field
.dnttp
.index
, objfile
);
1478 /* Check whether we have a method */
1479 if ((fn_fieldp
->dblock
.kind
== DNTT_TYPE_MEMFUNC
) ||
1480 (fn_fieldp
->dblock
.kind
== DNTT_TYPE_FUNCTION
) ||
1481 (fn_fieldp
->dblock
.kind
== DNTT_TYPE_DOC_MEMFUNC
) ||
1482 (fn_fieldp
->dblock
.kind
== DNTT_TYPE_DOC_FUNCTION
))
1488 /* Look up function type of method */
1489 memtype
= hpread_type_lookup (fn_field
, objfile
);
1491 /* Methods can be seen before classes in the SOM records.
1492 If we are processing this class because it's a parameter of a
1493 method, at this point the method's type is actually incomplete;
1494 we'll have to fix it up later; mark the class for this. */
1496 if (TYPE_INCOMPLETE (memtype
))
1498 TYPE_FLAGS (type
) |= TYPE_FLAG_INCOMPLETE
;
1500 warning ("Two classes to fix up for method?? Type information may be incorrect for some classes.");
1502 warning ("Two methods to be fixed up at once?? Type information may be incorrect for some classes.");
1503 fixup_class
= type
; /* remember this class has to be fixed up */
1504 fixup_method
= memtype
; /* remember the method type to be used in fixup */
1507 /* HP aCC generates operator names without the "operator" keyword, and
1508 generates null strings as names for operators that are
1509 user-defined type conversions to basic types (e.g. operator int ()).
1510 So try to reconstruct name as best as possible. */
1512 method_name
= (char *) (VT (objfile
) + fn_fieldp
->dfunc
.name
);
1513 method_alias
= (char *) (VT (objfile
) + fn_fieldp
->dfunc
.alias
);
1515 if (!method_name
|| /* no name */
1516 !*method_name
|| /* or null name */
1517 cplus_mangle_opname (method_name
, DMGL_ANSI
)) /* or name is an operator like "<" */
1519 char *tmp_name
= cplus_demangle (method_alias
, DMGL_ANSI
);
1520 char *op_string
= strstr (tmp_name
, "operator");
1521 method_name
= xmalloc (strlen (op_string
) + 1); /* don't overwrite VT! */
1522 strcpy (method_name
, op_string
);
1525 /* First check if a method of the same name has already been seen. */
1529 if (STREQ (fn_p
->field
.name
, method_name
))
1534 /* If no such method was found, allocate a new entry in the list */
1537 /* Get space to record this member function */
1538 /* Note: alloca used; this will disappear on routine exit */
1539 fn_new
= (struct next_fn_field
*) alloca (sizeof (struct next_fn_field
));
1540 fn_new
->next
= fn_list
;
1543 /* Fill in the fields of the struct nextfield */
1545 /* Record the (unmangled) method name */
1546 fn_list
->field
.name
= method_name
;
1547 /* Initial space for overloaded methods */
1548 /* Note: xmalloc is used; this will persist after this routine exits */
1549 fn_list
->field
.fn_fields
= (struct fn_field
*) xmalloc (5 * (sizeof (struct fn_field
)));
1550 fn_list
->field
.length
= 1; /* Init # of overloaded instances */
1551 fn_list
->num_fn_fields
= 5; /* # of entries for which space allocated */
1553 ix
= 0; /* array index for fn_field */
1554 /* Bump the total count of the distinctly named methods */
1558 /* Another overloaded instance of an already seen method name */
1560 if (++(fn_p
->field
.length
) > fn_p
->num_fn_fields
)
1562 /* Increase space allocated for overloaded instances */
1563 fn_p
->field
.fn_fields
1564 = (struct fn_field
*) xrealloc (fn_p
->field
.fn_fields
,
1565 (fn_p
->num_fn_fields
+ 5) * sizeof (struct fn_field
));
1566 fn_p
->num_fn_fields
+= 5;
1568 ix
= fn_p
->field
.length
- 1; /* array index for fn_field */
1571 /* "physname" is intended to be the name of this overloaded instance. */
1572 if ((fn_fieldp
->dfunc
.language
== HP_LANGUAGE_CPLUSPLUS
) &&
1574 *method_alias
) /* not a null string */
1575 fn_p
->field
.fn_fields
[ix
].physname
= method_alias
;
1577 fn_p
->field
.fn_fields
[ix
].physname
= method_name
;
1578 /* What's expected here is the function type */
1579 /* But mark it as NULL if the method was incompletely processed
1580 We'll fix this up later when the method is fully processed */
1581 if (TYPE_INCOMPLETE (memtype
))
1583 fn_p
->field
.fn_fields
[ix
].type
= NULL
;
1584 fn_p
->field
.fn_fields
[ix
].args
= NULL
;
1588 fn_p
->field
.fn_fields
[ix
].type
= memtype
;
1590 /* The argument list */
1591 fn_p
->field
.fn_fields
[ix
].type
->type_specific
.arg_types
=
1592 (struct type
**) obstack_alloc (&objfile
->type_obstack
,
1593 sizeof (struct type
*) * (memtype
->nfields
+ 1));
1594 for (i
= 0; i
< memtype
->nfields
; i
++)
1595 fn_p
->field
.fn_fields
[ix
].type
->type_specific
.arg_types
[i
] = memtype
->fields
[i
].type
;
1596 /* void termination */
1597 fn_p
->field
.fn_fields
[ix
].type
->type_specific
.arg_types
[memtype
->nfields
] = builtin_type_void
;
1599 /* pai: It's not clear why this args field has to be set. Perhaps
1600 * it should be eliminated entirely. */
1601 fn_p
->field
.fn_fields
[ix
].args
=
1602 (struct type
**) obstack_alloc (&objfile
->type_obstack
,
1603 sizeof (struct type
*) * (memtype
->nfields
+ 1));
1604 for (i
= 0; i
< memtype
->nfields
; i
++)
1605 fn_p
->field
.fn_fields
[ix
].args
[i
] = memtype
->fields
[i
].type
;
1606 /* null-terminated, unlike arg_types above e */
1607 fn_p
->field
.fn_fields
[ix
].args
[memtype
->nfields
] = NULL
;
1609 /* For virtual functions, fill in the voffset field with the
1610 * virtual table offset. (This is just copied over from the
1611 * SOM record; not sure if it is what GDB expects here...).
1612 * But if the function is a static method, set it to 1.
1614 * Note that we have to add 1 because 1 indicates a static
1615 * method, and 0 indicates a non-static, non-virtual method */
1618 fn_p
->field
.fn_fields
[ix
].voffset
= VOFFSET_STATIC
;
1620 fn_p
->field
.fn_fields
[ix
].voffset
= vtbl_offset
? vtbl_offset
+ 1 : 0;
1622 /* Also fill in the fcontext field with the current
1623 * class. (The latter isn't quite right: should be the baseclass
1624 * that defines the virtual function... Note we do have
1625 * a variable "baseclass" that we could stuff into the fcontext
1626 * field, but "baseclass" isn't necessarily right either,
1627 * since the virtual function could have been defined more
1628 * than one level up).
1631 if (vtbl_offset
!= 0)
1632 fn_p
->field
.fn_fields
[ix
].fcontext
= type
;
1634 fn_p
->field
.fn_fields
[ix
].fcontext
= NULL
;
1636 /* Other random fields pertaining to this method */
1637 fn_p
->field
.fn_fields
[ix
].is_const
= const_member
;
1638 fn_p
->field
.fn_fields
[ix
].is_volatile
= volatile_member
; /* ?? */
1639 switch (fieldp
->dgenfield
.visibility
)
1642 fn_p
->field
.fn_fields
[ix
].is_protected
= 1;
1643 fn_p
->field
.fn_fields
[ix
].is_private
= 0;
1646 fn_p
->field
.fn_fields
[ix
].is_protected
= 0;
1647 fn_p
->field
.fn_fields
[ix
].is_private
= 1;
1649 default: /* public */
1650 fn_p
->field
.fn_fields
[ix
].is_protected
= 0;
1651 fn_p
->field
.fn_fields
[ix
].is_private
= 0;
1653 fn_p
->field
.fn_fields
[ix
].is_stub
= 0;
1655 /* HP aCC emits both MEMFUNC and FUNCTION entries for a method;
1656 if the class points to the FUNCTION, there is usually separate
1657 code for the method; but if we have a MEMFUNC, the method has
1658 been inlined (and there is usually no FUNCTION entry)
1659 FIXME Not sure if this test is accurate. pai/1997-08-22 */
1660 if ((fn_fieldp
->dblock
.kind
== DNTT_TYPE_MEMFUNC
) ||
1661 (fn_fieldp
->dblock
.kind
== DNTT_TYPE_DOC_MEMFUNC
))
1662 fn_p
->field
.fn_fields
[ix
].is_inlined
= 1;
1664 fn_p
->field
.fn_fields
[ix
].is_inlined
= 0;
1666 fn_p
->field
.fn_fields
[ix
].dummy
= 0;
1668 /* Bump the total count of the member functions */
1669 n_fn_fields_total
++;
1672 else if (fn_fieldp
->dblock
.kind
== DNTT_TYPE_SVAR
)
1674 /* This case is for static data members of classes */
1676 /* pai:: FIXME -- check that "staticmem" bit is set */
1678 /* Get space to record this static member */
1679 new = (struct nextfield
*) alloca (sizeof (struct nextfield
));
1683 list
->field
.name
= VT (objfile
) + fn_fieldp
->dsvar
.name
;
1684 FIELD_BITSIZE (list
->field
) = -1; /* indicates static member */
1685 SET_FIELD_PHYSNAME (list
->field
, 0); /* initialize to empty */
1686 memtype
= hpread_type_lookup (fn_fieldp
->dsvar
.type
, objfile
);
1688 FIELD_TYPE (list
->field
) = memtype
;
1689 list
->attributes
= 0;
1690 switch (fieldp
->dgenfield
.visibility
)
1693 B_SET (&(list
->attributes
), ATTR_PROTECT
);
1696 B_SET (&(list
->attributes
), ATTR_PRIVATE
);
1702 else if (fn_fieldp
->dblock
.kind
== DNTT_TYPE_FIELD
)
1704 /* FIELDs follow GENFIELDs for fields of anonymous unions.
1705 Code below is replicated from the case for FIELDs further
1706 below, except that fieldp is replaced by fn_fieldp */
1707 if (!fn_fieldp
->dfield
.a_union
)
1708 warning ("Debug info inconsistent: FIELD of anonymous union doesn't have a_union bit set");
1709 /* Get space to record the next field/data-member. */
1710 new = (struct nextfield
*) alloca (sizeof (struct nextfield
));
1714 list
->field
.name
= VT (objfile
) + fn_fieldp
->dfield
.name
;
1715 FIELD_BITPOS (list
->field
) = fn_fieldp
->dfield
.bitoffset
;
1716 if (fn_fieldp
->dfield
.bitlength
% 8)
1717 list
->field
.bitsize
= fn_fieldp
->dfield
.bitlength
;
1719 list
->field
.bitsize
= 0;
1721 memtype
= hpread_type_lookup (fn_fieldp
->dfield
.type
, objfile
);
1722 list
->field
.type
= memtype
;
1723 list
->attributes
= 0;
1724 switch (fn_fieldp
->dfield
.visibility
)
1727 B_SET (&(list
->attributes
), ATTR_PROTECT
);
1730 B_SET (&(list
->attributes
), ATTR_PRIVATE
);
1735 else if (fn_fieldp
->dblock
.kind
== DNTT_TYPE_SVAR
)
1737 /* Field of anonymous union; union is not inside a class */
1738 if (!fn_fieldp
->dsvar
.a_union
)
1739 warning ("Debug info inconsistent: SVAR field in anonymous union doesn't have a_union bit set");
1740 /* Get space to record the next field/data-member. */
1741 new = (struct nextfield
*) alloca (sizeof (struct nextfield
));
1745 list
->field
.name
= VT (objfile
) + fn_fieldp
->dsvar
.name
;
1746 FIELD_BITPOS (list
->field
) = 0; /* FIXME is this always true? */
1747 FIELD_BITSIZE (list
->field
) = 0; /* use length from type */
1748 memtype
= hpread_type_lookup (fn_fieldp
->dsvar
.type
, objfile
);
1749 list
->field
.type
= memtype
;
1750 list
->attributes
= 0;
1751 /* No info to set visibility -- always public */
1754 else if (fn_fieldp
->dblock
.kind
== DNTT_TYPE_DVAR
)
1756 /* Field of anonymous union; union is not inside a class */
1757 if (!fn_fieldp
->ddvar
.a_union
)
1758 warning ("Debug info inconsistent: DVAR field in anonymous union doesn't have a_union bit set");
1759 /* Get space to record the next field/data-member. */
1760 new = (struct nextfield
*) alloca (sizeof (struct nextfield
));
1764 list
->field
.name
= VT (objfile
) + fn_fieldp
->ddvar
.name
;
1765 FIELD_BITPOS (list
->field
) = 0; /* FIXME is this always true? */
1766 FIELD_BITSIZE (list
->field
) = 0; /* use length from type */
1767 memtype
= hpread_type_lookup (fn_fieldp
->ddvar
.type
, objfile
);
1768 list
->field
.type
= memtype
;
1769 list
->attributes
= 0;
1770 /* No info to set visibility -- always public */
1774 { /* Not a method, nor a static data member, nor an anon union field */
1776 /* This case is for miscellaneous type entries (local enums,
1777 local function templates, etc.) that can be present
1780 /* Enums -- will be handled by other code that takes care
1781 of DNTT_TYPE_ENUM; here we see only DNTT_TYPE_MEMENUM so
1782 it's not clear we could have handled them here at all. */
1783 /* FUNC_TEMPLATE: is handled by other code (?). */
1784 /* MEMACCESS: modified access for inherited member. Not
1785 sure what to do with this, ignoriing it at present. */
1787 /* What other entries can appear following a GENFIELD which
1788 we do not handle above? (MODIFIER, VFUNC handled above.) */
1790 if ((fn_fieldp
->dblock
.kind
!= DNTT_TYPE_MEMACCESS
) &&
1791 (fn_fieldp
->dblock
.kind
!= DNTT_TYPE_MEMENUM
) &&
1792 (fn_fieldp
->dblock
.kind
!= DNTT_TYPE_FUNC_TEMPLATE
))
1793 warning ("Internal error: Unexpected debug record kind %d found following DNTT_GENFIELD",
1794 fn_fieldp
->dblock
.kind
);
1796 /* walk to the next FIELD or GENFIELD */
1797 field
= fieldp
->dgenfield
.nextfield
;
1800 else if (fieldp
->dblock
.kind
== DNTT_TYPE_FIELD
)
1803 /* Ordinary structure/union/class field */
1804 struct type
*anon_union_type
;
1806 /* Get space to record the next field/data-member. */
1807 new = (struct nextfield
*) alloca (sizeof (struct nextfield
));
1811 list
->field
.name
= VT (objfile
) + fieldp
->dfield
.name
;
1814 /* A FIELD by itself (without a GENFIELD) can also be a static member */
1815 if (fieldp
->dfield
.staticmem
)
1817 FIELD_BITPOS (list
->field
) = -1;
1818 FIELD_BITSIZE (list
->field
) = 0;
1821 /* Non-static data member */
1823 FIELD_BITPOS (list
->field
) = fieldp
->dfield
.bitoffset
;
1824 if (fieldp
->dfield
.bitlength
% 8)
1825 FIELD_BITSIZE (list
->field
) = fieldp
->dfield
.bitlength
;
1827 FIELD_BITSIZE (list
->field
) = 0;
1830 memtype
= hpread_type_lookup (fieldp
->dfield
.type
, objfile
);
1831 FIELD_TYPE (list
->field
) = memtype
;
1832 list
->attributes
= 0;
1833 switch (fieldp
->dfield
.visibility
)
1836 B_SET (&(list
->attributes
), ATTR_PROTECT
);
1839 B_SET (&(list
->attributes
), ATTR_PRIVATE
);
1845 /* Note 1: First, we have to check if the current field is an anonymous
1846 union. If it is, then *its* fields are threaded along in the
1847 nextfield chain. :-( This was supposed to help debuggers, but is
1848 really just a nuisance since we deal with anonymous unions anyway by
1849 checking that the name is null. So anyway, we skip over the fields
1850 of the anonymous union. pai/1997-08-22 */
1851 /* Note 2: In addition, the bitoffsets for the fields of the anon union
1852 are relative to the enclosing struct, *NOT* relative to the anon
1853 union! This is an even bigger nuisance -- we have to go in and munge
1854 the anon union's type information appropriately. pai/1997-08-22 */
1856 /* Both tasks noted above are done by a separate function. This takes us
1857 to the next FIELD or GENFIELD, skipping anon unions, and recursively
1858 processing intermediate types. */
1859 field
= hpread_get_next_skip_over_anon_unions (1, field
, &fieldp
, objfile
);
1864 /* neither field nor genfield ?? is this possible?? */
1865 /* pai:: FIXME walk to the next -- how? */
1866 warning ("Internal error: unexpected DNTT kind %d encountered as field of struct",
1867 fieldp
->dblock
.kind
);
1868 warning ("Skipping remaining fields of struct");
1869 break; /* get out of loop of fields */
1873 /* If it's a template, read in the instantiation list */
1874 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_TEMPLATE
)
1876 ninstantiations
= 0;
1877 field
= dn_bufp
->dtemplate
.expansions
;
1878 while (field
.word
&& field
.word
!= DNTTNIL
)
1880 fieldp
= hpread_get_lntt (field
.dnttp
.index
, objfile
);
1882 /* The expansions or nextexp should point to a tagdef */
1883 if (fieldp
->dblock
.kind
!= DNTT_TYPE_TAGDEF
)
1886 i_new
= (struct next_instantiation
*) alloca (sizeof (struct next_instantiation
));
1887 i_new
->next
= i_list
;
1889 i_list
->t
= hpread_type_lookup (field
, objfile
);
1892 /* And the "type" field of that should point to a class */
1893 field
= fieldp
->dtag
.type
;
1894 fieldp
= hpread_get_lntt (field
.dnttp
.index
, objfile
);
1895 if (fieldp
->dblock
.kind
!= DNTT_TYPE_CLASS
)
1898 /* Get the next expansion */
1899 field
= fieldp
->dclass
.nextexp
;
1902 TYPE_NINSTANTIATIONS (type
) = ninstantiations
;
1903 if (ninstantiations
> 0)
1904 TYPE_INSTANTIATIONS (type
) = (struct type
**)
1905 obstack_alloc (&objfile
->type_obstack
, sizeof (struct type
*) * ninstantiations
);
1906 for (n
= ninstantiations
; i_list
; i_list
= i_list
->next
)
1909 TYPE_INSTANTIATION (type
, n
) = i_list
->t
;
1913 /* Copy the field-list to GDB's symbol table */
1914 TYPE_NFIELDS (type
) = nfields
;
1915 TYPE_N_BASECLASSES (type
) = n_base_classes
;
1916 TYPE_FIELDS (type
) = (struct field
*)
1917 obstack_alloc (&objfile
->type_obstack
, sizeof (struct field
) * nfields
);
1918 /* Copy the saved-up fields into the field vector. */
1919 for (n
= nfields
, tmp_list
= list
; tmp_list
; tmp_list
= tmp_list
->next
)
1922 TYPE_FIELD (type
, n
) = tmp_list
->field
;
1925 /* Copy the "function-field-list" (i.e., the list of member
1926 * functions in the class) to GDB's symbol table
1928 TYPE_NFN_FIELDS (type
) = n_fn_fields
;
1929 TYPE_NFN_FIELDS_TOTAL (type
) = n_fn_fields_total
;
1930 TYPE_FN_FIELDLISTS (type
) = (struct fn_fieldlist
*)
1931 obstack_alloc (&objfile
->type_obstack
, sizeof (struct fn_fieldlist
) * n_fn_fields
);
1932 for (n
= n_fn_fields
; fn_list
; fn_list
= fn_list
->next
)
1935 TYPE_FN_FIELDLIST (type
, n
) = fn_list
->field
;
1938 /* pai:: FIXME -- perhaps each bitvector should be created individually */
1939 for (n
= nfields
, tmp_list
= list
; tmp_list
; tmp_list
= tmp_list
->next
)
1942 if (tmp_list
->attributes
)
1944 need_bitvectors
= 1;
1949 if (need_bitvectors
)
1951 /* pai:: this step probably redundant */
1952 ALLOCATE_CPLUS_STRUCT_TYPE (type
);
1954 TYPE_FIELD_VIRTUAL_BITS (type
) =
1955 (B_TYPE
*) TYPE_ALLOC (type
, B_BYTES (nfields
));
1956 B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type
), nfields
);
1958 TYPE_FIELD_PRIVATE_BITS (type
) =
1959 (B_TYPE
*) TYPE_ALLOC (type
, B_BYTES (nfields
));
1960 B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type
), nfields
);
1962 TYPE_FIELD_PROTECTED_BITS (type
) =
1963 (B_TYPE
*) TYPE_ALLOC (type
, B_BYTES (nfields
));
1964 B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type
), nfields
);
1966 /* this field vector isn't actually used with HP aCC */
1967 TYPE_FIELD_IGNORE_BITS (type
) =
1968 (B_TYPE
*) TYPE_ALLOC (type
, B_BYTES (nfields
));
1969 B_CLRALL (TYPE_FIELD_IGNORE_BITS (type
), nfields
);
1971 while (nfields
-- > 0)
1973 if (B_TST (&(list
->attributes
), ATTR_VIRTUAL
))
1974 SET_TYPE_FIELD_VIRTUAL (type
, nfields
);
1975 if (B_TST (&(list
->attributes
), ATTR_PRIVATE
))
1976 SET_TYPE_FIELD_PRIVATE (type
, nfields
);
1977 if (B_TST (&(list
->attributes
), ATTR_PROTECT
))
1978 SET_TYPE_FIELD_PROTECTED (type
, nfields
);
1985 TYPE_FIELD_VIRTUAL_BITS (type
) = NULL
;
1986 TYPE_FIELD_PROTECTED_BITS (type
) = NULL
;
1987 TYPE_FIELD_PRIVATE_BITS (type
) = NULL
;
1990 if (has_vtable (type
))
1992 /* Allocate space for class runtime information */
1993 TYPE_RUNTIME_PTR (type
) = (struct runtime_info
*) xmalloc (sizeof (struct runtime_info
));
1994 /* Set flag for vtable */
1995 TYPE_VTABLE (type
) = 1;
1996 /* The first non-virtual base class with a vtable. */
1997 TYPE_PRIMARY_BASE (type
) = primary_base_class (type
);
1998 /* The virtual base list. */
1999 TYPE_VIRTUAL_BASE_LIST (type
) = virtual_base_list (type
);
2002 TYPE_RUNTIME_PTR (type
) = NULL
;
2004 /* If this is a local type (C++ - declared inside a function), record file name & line # */
2005 if (hpread_get_scope_depth (dn_bufp
, objfile
, 1 /* no need for real depth */ ))
2007 TYPE_LOCALTYPE_PTR (type
) = (struct local_type_info
*) xmalloc (sizeof (struct local_type_info
));
2008 TYPE_LOCALTYPE_FILE (type
) = (char *) xmalloc (strlen (current_subfile
->name
) + 1);
2009 strcpy (TYPE_LOCALTYPE_FILE (type
), current_subfile
->name
);
2010 if (current_subfile
->line_vector
&& (current_subfile
->line_vector
->nitems
> 0))
2011 TYPE_LOCALTYPE_LINE (type
) = current_subfile
->line_vector
->item
[current_subfile
->line_vector
->nitems
- 1].line
;
2013 TYPE_LOCALTYPE_LINE (type
) = 0;
2016 TYPE_LOCALTYPE_PTR (type
) = NULL
;
2018 /* Clear the global saying what template we are in the middle of processing */
2019 current_template
= NULL
;
2024 /* Adjust the physnames for each static member of a struct
2025 or class type to be something like "A::x"; then various
2026 other pieces of code that do a lookup_symbol on the phyname
2028 TYPE is a pointer to the struct/class type
2029 NAME is a char * (string) which is the class/struct name
2033 fix_static_member_physnames (struct type
*type
, char *class_name
,
2034 struct objfile
*objfile
)
2038 /* We fix the member names only for classes or structs */
2039 if (TYPE_CODE (type
) != TYPE_CODE_STRUCT
)
2042 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
2043 if (TYPE_FIELD_STATIC (type
, i
))
2045 if (TYPE_FIELD_STATIC_PHYSNAME (type
, i
))
2046 return; /* physnames are already set */
2048 SET_FIELD_PHYSNAME (type
->fields
[i
],
2049 obstack_alloc (&objfile
->type_obstack
,
2050 strlen (class_name
) + strlen (TYPE_FIELD_NAME (type
, i
)) + 3));
2051 strcpy (TYPE_FIELD_STATIC_PHYSNAME (type
, i
), class_name
);
2052 strcat (TYPE_FIELD_STATIC_PHYSNAME (type
, i
), "::");
2053 strcat (TYPE_FIELD_STATIC_PHYSNAME (type
, i
), TYPE_FIELD_NAME (type
, i
));
2057 /* Fix-up the type structure for a CLASS so that the type entry
2058 * for a method (previously marked with a null type in hpread_read_struct_type()
2059 * is set correctly to METHOD.
2060 * OBJFILE is as for other such functions.
2064 fixup_class_method_type (struct type
*class, struct type
*method
,
2065 struct objfile
*objfile
)
2069 if (!class || !method
|| !objfile
)
2072 /* Only for types that have methods */
2073 if ((TYPE_CODE (class) != TYPE_CODE_CLASS
) &&
2074 (TYPE_CODE (class) != TYPE_CODE_UNION
))
2077 /* Loop over all methods and find the one marked with a NULL type */
2078 for (i
= 0; i
< TYPE_NFN_FIELDS (class); i
++)
2079 for (j
= 0; j
< TYPE_FN_FIELDLIST_LENGTH (class, i
); j
++)
2080 if (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i
), j
) == NULL
)
2082 /* Set the method type */
2083 TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i
), j
) = method
;
2084 /* The argument list */
2085 (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i
), j
))->type_specific
.arg_types
2086 = (struct type
**) obstack_alloc (&objfile
->type_obstack
,
2087 sizeof (struct type
*) * (method
->nfields
+ 1));
2088 for (k
= 0; k
< method
->nfields
; k
++)
2089 (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i
), j
))->type_specific
.arg_types
[k
] = method
->fields
[k
].type
;
2090 /* void termination */
2091 (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i
), j
))->type_specific
.arg_types
[method
->nfields
] = builtin_type_void
;
2093 /* pai: It's not clear why this args field has to be set. Perhaps
2094 * it should be eliminated entirely. */
2095 (TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i
), j
)).args
2096 = (struct type
**) obstack_alloc (&objfile
->type_obstack
,
2097 sizeof (struct type
*) * (method
->nfields
+ 1));
2098 for (k
= 0; k
< method
->nfields
; k
++)
2099 (TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i
), j
)).args
[k
] = method
->fields
[k
].type
;
2100 /* null-terminated, unlike arg_types above */
2101 (TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i
), j
)).args
[method
->nfields
] = NULL
;
2103 /* Break out of both loops -- only one method to fix up in a class */
2108 TYPE_FLAGS (class) &= ~TYPE_FLAG_INCOMPLETE
;
2112 /* If we're in the middle of processing a template, get a pointer
2113 * to the Nth template argument.
2114 * An example may make this clearer:
2115 * template <class T1, class T2> class q2 {
2120 * The type for "a" will be "first template arg" and
2121 * the type for "b" will be "second template arg".
2122 * We need to look these up in order to fill in "a" and "b"'s type.
2123 * This is called from hpread_type_lookup().
2125 static struct type
*
2126 hpread_get_nth_template_arg (struct objfile
*objfile
, int n
)
2128 if (current_template
!= NULL
)
2129 return TYPE_TEMPLATE_ARG (current_template
, n
).type
;
2131 return lookup_fundamental_type (objfile
, FT_TEMPLATE_ARG
);
2134 /* Read in and internalize a TEMPL_ARG (template arg) symbol. */
2136 static struct type
*
2137 hpread_read_templ_arg_type (dnttpointer hp_type
, union dnttentry
*dn_bufp
,
2138 struct objfile
*objfile
, char *name
)
2142 /* See if it's something we've already deal with. */
2143 type
= hpread_alloc_type (hp_type
, objfile
);
2144 if (TYPE_CODE (type
) == TYPE_CODE_TEMPLATE_ARG
)
2147 /* Nope. Fill in the appropriate fields. */
2148 TYPE_CODE (type
) = TYPE_CODE_TEMPLATE_ARG
;
2149 TYPE_LENGTH (type
) = 0;
2150 TYPE_NFIELDS (type
) = 0;
2151 TYPE_NAME (type
) = name
;
2155 /* Read in and internalize a set debug symbol. */
2157 static struct type
*
2158 hpread_read_set_type (dnttpointer hp_type
, union dnttentry
*dn_bufp
,
2159 struct objfile
*objfile
)
2163 /* See if it's something we've already deal with. */
2164 type
= hpread_alloc_type (hp_type
, objfile
);
2165 if (TYPE_CODE (type
) == TYPE_CODE_SET
)
2168 /* Nope. Fill in the appropriate fields. */
2169 TYPE_CODE (type
) = TYPE_CODE_SET
;
2170 TYPE_LENGTH (type
) = dn_bufp
->dset
.bitlength
/ 8;
2171 TYPE_NFIELDS (type
) = 0;
2172 TYPE_TARGET_TYPE (type
) = hpread_type_lookup (dn_bufp
->dset
.subtype
,
2177 /* Read in and internalize an array debug symbol. */
2179 static struct type
*
2180 hpread_read_array_type (dnttpointer hp_type
, union dnttentry
*dn_bufp
,
2181 struct objfile
*objfile
)
2185 /* Allocate an array type symbol.
2186 * Why no check for already-read here, like in the other
2187 * hpread_read_xxx_type routines? Because it kept us
2188 * from properly determining the size of the array!
2190 type
= hpread_alloc_type (hp_type
, objfile
);
2192 TYPE_CODE (type
) = TYPE_CODE_ARRAY
;
2194 /* Although the hp-symtab.h does not *require* this to be the case,
2195 * GDB is assuming that "arrayisbytes" and "elemisbytes" be consistent.
2196 * I.e., express both array-length and element-length in bits,
2197 * or express both array-length and element-length in bytes.
2199 if (!((dn_bufp
->darray
.arrayisbytes
&& dn_bufp
->darray
.elemisbytes
) ||
2200 (!dn_bufp
->darray
.arrayisbytes
&& !dn_bufp
->darray
.elemisbytes
)))
2202 warning ("error in hpread_array_type.\n");
2205 else if (dn_bufp
->darray
.arraylength
== 0x7fffffff)
2207 /* The HP debug format represents char foo[]; as an array with
2208 * length 0x7fffffff. Internally GDB wants to represent this
2209 * as an array of length zero.
2211 TYPE_LENGTH (type
) = 0;
2213 else if (dn_bufp
->darray
.arrayisbytes
)
2214 TYPE_LENGTH (type
) = dn_bufp
->darray
.arraylength
;
2215 else /* arraylength is in bits */
2216 TYPE_LENGTH (type
) = dn_bufp
->darray
.arraylength
/ 8;
2218 TYPE_TARGET_TYPE (type
) = hpread_type_lookup (dn_bufp
->darray
.elemtype
,
2221 /* The one "field" is used to store the subscript type */
2222 /* Since C and C++ multi-dimensional arrays are simply represented
2223 * as: array of array of ..., we only need one subscript-type
2224 * per array. This subscript type is typically a subrange of integer.
2225 * If this gets extended to support languages like Pascal, then
2226 * we need to fix this to represent multi-dimensional arrays properly.
2228 TYPE_NFIELDS (type
) = 1;
2229 TYPE_FIELDS (type
) = (struct field
*)
2230 obstack_alloc (&objfile
->type_obstack
, sizeof (struct field
));
2231 TYPE_FIELD_TYPE (type
, 0) = hpread_type_lookup (dn_bufp
->darray
.indextype
,
2236 /* Read in and internalize a subrange debug symbol. */
2237 static struct type
*
2238 hpread_read_subrange_type (dnttpointer hp_type
, union dnttentry
*dn_bufp
,
2239 struct objfile
*objfile
)
2243 /* Is it something we've already dealt with. */
2244 type
= hpread_alloc_type (hp_type
, objfile
);
2245 if (TYPE_CODE (type
) == TYPE_CODE_RANGE
)
2248 /* Nope, internalize it. */
2249 TYPE_CODE (type
) = TYPE_CODE_RANGE
;
2250 TYPE_LENGTH (type
) = dn_bufp
->dsubr
.bitlength
/ 8;
2251 TYPE_NFIELDS (type
) = 2;
2253 = (struct field
*) obstack_alloc (&objfile
->type_obstack
,
2254 2 * sizeof (struct field
));
2256 if (dn_bufp
->dsubr
.dyn_low
)
2257 TYPE_FIELD_BITPOS (type
, 0) = 0;
2259 TYPE_FIELD_BITPOS (type
, 0) = dn_bufp
->dsubr
.lowbound
;
2261 if (dn_bufp
->dsubr
.dyn_high
)
2262 TYPE_FIELD_BITPOS (type
, 1) = -1;
2264 TYPE_FIELD_BITPOS (type
, 1) = dn_bufp
->dsubr
.highbound
;
2265 TYPE_TARGET_TYPE (type
) = hpread_type_lookup (dn_bufp
->dsubr
.subtype
,
2270 /* struct type * hpread_type_lookup(hp_type, objfile)
2272 * hp_type: A pointer into the DNTT specifying what type we
2273 * are about to "look up"., or else [for fundamental types
2274 * like int, float, ...] an "immediate" structure describing
2277 * Return value: A pointer to a "struct type" (representation of a
2278 * type in GDB's internal symbol table - see gdbtypes.h)
2279 * Routine description:
2280 * There are a variety of places when scanning the DNTT when we
2281 * need to interpret a "type" field. The simplest and most basic
2282 * example is when we're processing the symbol table record
2283 * for a data symbol (a SVAR or DVAR record). That has
2284 * a "type" field specifying the type of the data symbol. That
2285 * "type" field is either an "immediate" type specification (for the
2286 * fundamental types) or a DNTT pointer (for more complicated types).
2287 * For the more complicated types, we may or may not have already
2288 * processed the pointed-to type. (Multiple data symbols can of course
2289 * share the same type).
2290 * The job of hpread_type_lookup() is to process this "type" field.
2291 * Most of the real work is done in subroutines. Here we interpret
2292 * the immediate flag. If not immediate, chase the DNTT pointer to
2293 * find our way to the SOM record describing the type, switch on
2294 * the SOM kind, and then call an appropriate subroutine depending
2295 * on what kind of type we are constructing. (e.g., an array type,
2296 * a struct/class type, etc).
2298 static struct type
*
2299 hpread_type_lookup (dnttpointer hp_type
, struct objfile
*objfile
)
2301 union dnttentry
*dn_bufp
;
2302 struct type
*tmp_type
;
2304 /* First see if it's a simple builtin type. */
2305 if (hp_type
.dntti
.immediate
)
2307 /* If this is a template argument, the argument number is
2308 * encoded in the bitlength. All other cases, just return
2309 * GDB's representation of this fundamental type.
2311 if (hp_type
.dntti
.type
== HP_TYPE_TEMPLATE_ARG
)
2312 return hpread_get_nth_template_arg (objfile
, hp_type
.dntti
.bitlength
);
2314 return lookup_fundamental_type (objfile
,
2315 hpread_type_translate (hp_type
));
2318 /* Not a builtin type. We'll have to read it in. */
2319 if (hp_type
.dnttp
.index
< LNTT_SYMCOUNT (objfile
))
2320 dn_bufp
= hpread_get_lntt (hp_type
.dnttp
.index
, objfile
);
2322 /* This is a fancy way of returning NULL */
2323 return lookup_fundamental_type (objfile
, FT_VOID
);
2325 switch (dn_bufp
->dblock
.kind
)
2327 case DNTT_TYPE_SRCFILE
:
2328 case DNTT_TYPE_MODULE
:
2329 case DNTT_TYPE_ENTRY
:
2330 case DNTT_TYPE_BEGIN
:
2332 case DNTT_TYPE_IMPORT
:
2333 case DNTT_TYPE_LABEL
:
2334 case DNTT_TYPE_FPARAM
:
2335 case DNTT_TYPE_SVAR
:
2336 case DNTT_TYPE_DVAR
:
2337 case DNTT_TYPE_CONST
:
2338 case DNTT_TYPE_MEMENUM
:
2339 case DNTT_TYPE_VARIANT
:
2340 case DNTT_TYPE_FILE
:
2341 case DNTT_TYPE_WITH
:
2342 case DNTT_TYPE_COMMON
:
2343 case DNTT_TYPE_COBSTRUCT
:
2344 case DNTT_TYPE_XREF
:
2346 case DNTT_TYPE_MACRO
:
2347 case DNTT_TYPE_BLOCKDATA
:
2348 case DNTT_TYPE_CLASS_SCOPE
:
2349 case DNTT_TYPE_MEMACCESS
:
2350 case DNTT_TYPE_INHERITANCE
:
2351 case DNTT_TYPE_OBJECT_ID
:
2352 case DNTT_TYPE_FRIEND_CLASS
:
2353 case DNTT_TYPE_FRIEND_FUNC
:
2354 /* These are not types - something went wrong. */
2355 /* This is a fancy way of returning NULL */
2356 return lookup_fundamental_type (objfile
, FT_VOID
);
2358 case DNTT_TYPE_FUNCTION
:
2359 /* We wind up here when dealing with class member functions
2360 * (called from hpread_read_struct_type(), i.e. when processing
2361 * the class definition itself).
2363 return hpread_read_function_type (hp_type
, dn_bufp
, objfile
, 0);
2365 case DNTT_TYPE_DOC_FUNCTION
:
2366 return hpread_read_doc_function_type (hp_type
, dn_bufp
, objfile
, 0);
2368 case DNTT_TYPE_TYPEDEF
:
2370 /* A typedef - chase it down by making a recursive call */
2371 struct type
*structtype
= hpread_type_lookup (dn_bufp
->dtype
.type
,
2374 /* The following came from the base hpread.c that we inherited.
2375 * It is WRONG so I have commented it out. - RT
2379 suffix = VT (objfile) + dn_bufp->dtype.name;
2380 TYPE_NAME (structtype) = suffix;
2382 * ... further explanation ....
2384 * What we have here is a typedef pointing to a typedef.
2389 * What we desire to build is (these are pictures
2390 * of "struct type"'s):
2392 * +---------+ +----------+ +------------+
2393 * | typedef | | typedef | | fund. type |
2394 * | type| -> | type| -> | |
2395 * | "fum" | | "foo" | | "int" |
2396 * +---------+ +----------+ +------------+
2398 * What this commented-out code is doing is smashing the
2399 * name of pointed-to-type to be the same as the pointed-from
2400 * type. So we wind up with something like:
2402 * +---------+ +----------+ +------------+
2403 * | typedef | | typedef | | fund. type |
2404 * | type| -> | type| -> | |
2405 * | "fum" | | "fum" | | "fum" |
2406 * +---------+ +----------+ +------------+
2413 case DNTT_TYPE_TAGDEF
:
2415 /* Just a little different from above. We have to tack on
2416 * an identifier of some kind (struct, union, enum, class, etc).
2418 struct type
*structtype
= hpread_type_lookup (dn_bufp
->dtype
.type
,
2420 char *prefix
, *suffix
;
2421 suffix
= VT (objfile
) + dn_bufp
->dtype
.name
;
2423 /* Lookup the next type in the list. It should be a structure,
2424 * union, class, enum, or template type.
2425 * We will need to attach that to our name.
2427 if (dn_bufp
->dtype
.type
.dnttp
.index
< LNTT_SYMCOUNT (objfile
))
2428 dn_bufp
= hpread_get_lntt (dn_bufp
->dtype
.type
.dnttp
.index
, objfile
);
2431 complain (&hpread_type_lookup_complaint
);
2435 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_STRUCT
)
2439 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_UNION
)
2443 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_CLASS
)
2445 /* Further field for CLASS saying how it was really declared */
2446 /* 0==class, 1==union, 2==struct */
2447 if (dn_bufp
->dclass
.class_decl
== 0)
2449 else if (dn_bufp
->dclass
.class_decl
== 1)
2451 else if (dn_bufp
->dclass
.class_decl
== 2)
2456 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_ENUM
)
2460 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_TEMPLATE
)
2462 prefix
= "template ";
2469 /* Build the correct name. */
2471 = (char *) obstack_alloc (&objfile
->type_obstack
,
2472 strlen (prefix
) + strlen (suffix
) + 1);
2473 TYPE_NAME (structtype
) = strcpy (TYPE_NAME (structtype
), prefix
);
2474 TYPE_NAME (structtype
) = strcat (TYPE_NAME (structtype
), suffix
);
2475 TYPE_TAG_NAME (structtype
) = suffix
;
2477 /* For classes/structs, we have to set the static member "physnames"
2478 to point to strings like "Class::Member" */
2479 if (TYPE_CODE (structtype
) == TYPE_CODE_STRUCT
)
2480 fix_static_member_physnames (structtype
, suffix
, objfile
);
2485 case DNTT_TYPE_POINTER
:
2486 /* Pointer type - call a routine in gdbtypes.c that constructs
2487 * the appropriate GDB type.
2489 return make_pointer_type (
2490 hpread_type_lookup (dn_bufp
->dptr
.pointsto
,
2494 case DNTT_TYPE_REFERENCE
:
2495 /* C++ reference type - call a routine in gdbtypes.c that constructs
2496 * the appropriate GDB type.
2498 return make_reference_type (
2499 hpread_type_lookup (dn_bufp
->dreference
.pointsto
,
2503 case DNTT_TYPE_ENUM
:
2504 return hpread_read_enum_type (hp_type
, dn_bufp
, objfile
);
2506 return hpread_read_set_type (hp_type
, dn_bufp
, objfile
);
2507 case DNTT_TYPE_SUBRANGE
:
2508 return hpread_read_subrange_type (hp_type
, dn_bufp
, objfile
);
2509 case DNTT_TYPE_ARRAY
:
2510 return hpread_read_array_type (hp_type
, dn_bufp
, objfile
);
2511 case DNTT_TYPE_STRUCT
:
2512 case DNTT_TYPE_UNION
:
2513 return hpread_read_struct_type (hp_type
, dn_bufp
, objfile
);
2514 case DNTT_TYPE_FIELD
:
2515 return hpread_type_lookup (dn_bufp
->dfield
.type
, objfile
);
2517 case DNTT_TYPE_FUNCTYPE
:
2518 /* Here we want to read the function SOMs and return a
2519 * type for it. We get here, for instance, when processing
2520 * pointer-to-function type.
2522 return hpread_read_function_type (hp_type
, dn_bufp
, objfile
, 0);
2524 case DNTT_TYPE_PTRMEM
:
2525 /* Declares a C++ pointer-to-data-member type.
2526 * The "pointsto" field defines the class,
2527 * while the "memtype" field defines the pointed-to-type.
2530 struct type
*ptrmemtype
;
2531 struct type
*class_type
;
2532 struct type
*memtype
;
2533 memtype
= hpread_type_lookup (dn_bufp
->dptrmem
.memtype
,
2535 class_type
= hpread_type_lookup (dn_bufp
->dptrmem
.pointsto
,
2537 ptrmemtype
= alloc_type (objfile
);
2538 smash_to_member_type (ptrmemtype
, class_type
, memtype
);
2539 return make_pointer_type (ptrmemtype
, NULL
);
2543 case DNTT_TYPE_PTRMEMFUNC
:
2544 /* Defines a C++ pointer-to-function-member type.
2545 * The "pointsto" field defines the class,
2546 * while the "memtype" field defines the pointed-to-type.
2549 struct type
*ptrmemtype
;
2550 struct type
*class_type
;
2551 struct type
*functype
;
2552 struct type
*retvaltype
;
2555 struct type
**args_type
;
2556 class_type
= hpread_type_lookup (dn_bufp
->dptrmem
.pointsto
,
2558 functype
= hpread_type_lookup (dn_bufp
->dptrmem
.memtype
,
2560 retvaltype
= TYPE_TARGET_TYPE (functype
);
2561 nargs
= TYPE_NFIELDS (functype
);
2562 args_type
= (struct type
**) xmalloc ((nargs
+ 1) * sizeof (struct type
*));
2563 for (i
= 0; i
< nargs
; i
++)
2565 args_type
[i
] = TYPE_FIELD_TYPE (functype
, i
);
2567 args_type
[nargs
] = NULL
;
2568 ptrmemtype
= alloc_type (objfile
);
2569 smash_to_method_type (ptrmemtype
, class_type
, retvaltype
, args_type
);
2570 return make_pointer_type (ptrmemtype
, NULL
);
2574 case DNTT_TYPE_CLASS
:
2575 return hpread_read_struct_type (hp_type
, dn_bufp
, objfile
);
2577 case DNTT_TYPE_GENFIELD
:
2578 /* Chase pointer from GENFIELD to FIELD, and make recursive
2581 return hpread_type_lookup (dn_bufp
->dgenfield
.field
, objfile
);
2583 case DNTT_TYPE_VFUNC
:
2584 /* C++ virtual function.
2585 * We get here in the course of processing a class type which
2586 * contains virtual functions. Just go through another level
2587 * of indirection to get to the pointed-to function SOM.
2589 return hpread_type_lookup (dn_bufp
->dvfunc
.funcptr
, objfile
);
2591 case DNTT_TYPE_MODIFIER
:
2592 /* Check the modifiers and then just make a recursive call on
2593 * the "type" pointed to by the modifier DNTT.
2595 * pai:: FIXME -- do we ever want to handle "m_duplicate" and
2596 * "m_void" modifiers? Is static_flag really needed here?
2597 * (m_static used for methods of classes, elsewhere).
2599 tmp_type
= make_cv_type (dn_bufp
->dmodifier
.m_const
,
2600 dn_bufp
->dmodifier
.m_volatile
,
2601 hpread_type_lookup (dn_bufp
->dmodifier
.type
, objfile
),
2606 case DNTT_TYPE_MEMFUNC
:
2607 /* Member function. Treat like a function.
2608 * I think we get here in the course of processing a
2609 * pointer-to-member-function type...
2611 return hpread_read_function_type (hp_type
, dn_bufp
, objfile
, 0);
2613 case DNTT_TYPE_DOC_MEMFUNC
:
2614 return hpread_read_doc_function_type (hp_type
, dn_bufp
, objfile
, 0);
2616 case DNTT_TYPE_TEMPLATE
:
2617 /* Template - sort of the header for a template definition,
2618 * which like a class, points to a member list and also points
2619 * to a TEMPLATE_ARG list of type-arguments.
2621 return hpread_read_struct_type (hp_type
, dn_bufp
, objfile
);
2623 case DNTT_TYPE_TEMPLATE_ARG
:
2626 /* The TEMPLATE record points to an argument list of
2627 * TEMPLATE_ARG records, each of which describes one
2628 * of the type-arguments.
2630 name
= VT (objfile
) + dn_bufp
->dtempl_arg
.name
;
2631 return hpread_read_templ_arg_type (hp_type
, dn_bufp
, objfile
, name
);
2634 case DNTT_TYPE_FUNC_TEMPLATE
:
2635 /* We wind up here when processing a TEMPLATE type,
2636 * if the template has member function(s).
2637 * Treat it like a FUNCTION.
2639 return hpread_read_function_type (hp_type
, dn_bufp
, objfile
, 0);
2641 case DNTT_TYPE_LINK
:
2642 /* The LINK record is used to link up templates with instantiations.
2643 * There is no type associated with the LINK record per se.
2645 return lookup_fundamental_type (objfile
, FT_VOID
);
2647 /* Also not yet handled... */
2648 /* case DNTT_TYPE_DYN_ARRAY_DESC: */
2649 /* case DNTT_TYPE_DESC_SUBRANGE: */
2650 /* case DNTT_TYPE_BEGIN_EXT: */
2651 /* case DNTT_TYPE_INLN: */
2652 /* case DNTT_TYPE_INLN_LIST: */
2653 /* case DNTT_TYPE_ALIAS: */
2655 /* A fancy way of returning NULL */
2656 return lookup_fundamental_type (objfile
, FT_VOID
);
2661 hpread_record_lines (struct subfile
*subfile
, sltpointer s_idx
,
2662 sltpointer e_idx
, struct objfile
*objfile
,
2665 union sltentry
*sl_bufp
;
2667 while (s_idx
<= e_idx
)
2669 sl_bufp
= hpread_get_slt (s_idx
, objfile
);
2670 /* Only record "normal" entries in the SLT. */
2671 if (sl_bufp
->snorm
.sltdesc
== SLT_NORMAL
2672 || sl_bufp
->snorm
.sltdesc
== SLT_EXIT
)
2673 record_line (subfile
, sl_bufp
->snorm
.line
,
2674 sl_bufp
->snorm
.address
+ offset
);
2675 else if (sl_bufp
->snorm
.sltdesc
== SLT_NORMAL_OFFSET
)
2676 record_line (subfile
, sl_bufp
->snormoff
.line
,
2677 sl_bufp
->snormoff
.address
+ offset
);
2683 /* Given a function "f" which is a member of a class, find
2684 * the classname that it is a member of. Used to construct
2685 * the name (e.g., "c::f") which GDB will put in the
2686 * "demangled name" field of the function's symbol.
2687 * Called from hpread_process_one_debug_symbol()
2688 * If "f" is not a member function, return NULL.
2691 class_of (struct type
*functype
)
2693 struct type
*first_param_type
;
2694 char *first_param_name
;
2695 struct type
*pointed_to_type
;
2698 /* Check that the function has a first argument "this",
2699 * and that "this" is a pointer to a class. If not,
2700 * functype is not a member function, so return NULL.
2702 if (TYPE_NFIELDS (functype
) == 0)
2704 first_param_name
= TYPE_FIELD_NAME (functype
, 0);
2705 if (first_param_name
== NULL
)
2706 return NULL
; /* paranoia */
2707 if (strcmp (first_param_name
, "this"))
2709 first_param_type
= TYPE_FIELD_TYPE (functype
, 0);
2710 if (first_param_type
== NULL
)
2711 return NULL
; /* paranoia */
2712 if (TYPE_CODE (first_param_type
) != TYPE_CODE_PTR
)
2715 /* Get the thing that "this" points to, check that
2716 * it's a class, and get its class name.
2718 pointed_to_type
= TYPE_TARGET_TYPE (first_param_type
);
2719 if (pointed_to_type
== NULL
)
2720 return NULL
; /* paranoia */
2721 if (TYPE_CODE (pointed_to_type
) != TYPE_CODE_CLASS
)
2723 class_name
= TYPE_NAME (pointed_to_type
);
2724 if (class_name
== NULL
)
2725 return NULL
; /* paranoia */
2727 /* The class name may be of the form "class c", in which case
2728 * we want to strip off the leading "class ".
2730 if (strncmp (class_name
, "class ", 6) == 0)
2736 /* Internalize one native debug symbol.
2737 * Called in a loop from hpread_expand_symtab().
2746 * index: Index of this symbol
2747 * at_module_boundary_p Pointer to boolean flag to control caller's loop.
2751 hpread_process_one_debug_symbol (union dnttentry
*dn_bufp
, char *name
,
2752 struct section_offsets
*section_offsets
,
2753 struct objfile
*objfile
, CORE_ADDR text_offset
,
2754 int text_size
, char *filename
, int index
,
2755 int *at_module_boundary_p
)
2760 int offset
= ANOFFSET (section_offsets
, SECT_OFF_TEXT (objfile
));
2761 int data_offset
= ANOFFSET (section_offsets
, SECT_OFF_DATA (objfile
));
2762 union dnttentry
*dn_temp
;
2763 dnttpointer hp_type
;
2765 struct context_stack
*new;
2766 char *class_scope_name
;
2768 /* Allocate one GDB debug symbol and fill in some default values. */
2769 sym
= (struct symbol
*) obstack_alloc (&objfile
->symbol_obstack
,
2770 sizeof (struct symbol
));
2771 memset (sym
, 0, sizeof (struct symbol
));
2772 SYMBOL_NAME (sym
) = obsavestring (name
, strlen (name
), &objfile
->symbol_obstack
);
2773 SYMBOL_LANGUAGE (sym
) = language_auto
;
2774 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
2775 SYMBOL_LINE (sym
) = 0;
2776 SYMBOL_VALUE (sym
) = 0;
2777 SYMBOL_CLASS (sym
) = LOC_TYPEDEF
;
2779 /* Just a trick in case the SOM debug symbol is a type definition.
2780 * There are routines that are set up to build a GDB type symbol, given
2781 * a SOM dnttpointer. So we set up a dummy SOM dnttpointer "hp_type".
2782 * This allows us to call those same routines.
2784 hp_type
.dnttp
.extension
= 1;
2785 hp_type
.dnttp
.immediate
= 0;
2786 hp_type
.dnttp
.global
= 0;
2787 hp_type
.dnttp
.index
= index
;
2789 /* This "type" is the type of SOM record.
2790 * Switch on SOM type.
2792 type
= dn_bufp
->dblock
.kind
;
2795 case DNTT_TYPE_SRCFILE
:
2796 /* This type of symbol indicates from which source file or
2797 * include file any following data comes. It may indicate:
2799 * o The start of an entirely new source file (and thus
2802 * o The start of a different source file due to #include
2804 * o The end of an include file and the return to the original
2805 * file. Thus if "foo.c" includes "bar.h", we see first
2806 * a SRCFILE for foo.c, then one for bar.h, and then one for
2809 * If it indicates the start of a new module then we must
2810 * finish the symbol table of the previous module
2811 * (if any) and start accumulating a new symbol table.
2815 if (!last_source_file
)
2818 * A note on "last_source_file": this is a char* pointing
2819 * to the actual file name. "start_symtab" sets it,
2820 * "end_symtab" clears it.
2822 * So if "last_source_file" is NULL, then either this is
2823 * the first record we are looking at, or a previous call
2824 * to "end_symtab()" was made to close out the previous
2825 * module. Since we're now quitting the scan loop when we
2826 * see a MODULE END record, we should never get here, except
2827 * in the case that we're not using the quick look-up tables
2828 * and have to use the old system as a fall-back.
2830 start_symtab (name
, NULL
, valu
);
2831 record_debugformat ("HP");
2832 SL_INDEX (objfile
) = dn_bufp
->dsfile
.address
;
2837 /* Either a new include file, or a SRCFILE record
2838 * saying we are back in the main source (or out of
2839 * a nested include file) again.
2841 SL_INDEX (objfile
) = hpread_record_lines (current_subfile
,
2843 dn_bufp
->dsfile
.address
,
2847 /* A note on "start_subfile". This routine will check
2848 * the name we pass it and look for an existing subfile
2849 * of that name. There's thus only one sub-file for the
2850 * actual source (e.g. for "foo.c" in foo.c), despite the
2851 * fact that we'll see lots of SRCFILE entries for foo.c
2854 start_subfile (name
, NULL
);
2857 case DNTT_TYPE_MODULE
:
2859 * We no longer ignore DNTT_TYPE_MODULE symbols. The module
2860 * represents the meaningful semantic structure of a compilation
2861 * unit. We expect to start the psymtab-to-symtab expansion
2862 * looking at a MODULE entry, and to end it at the corresponding
2865 *--Begin outdated comments
2867 * This record signifies the start of a new source module
2868 * In C/C++ there is no explicit "module" construct in the language,
2869 * but each compilation unit is implicitly a module and they
2870 * do emit the DNTT_TYPE_MODULE records.
2871 * The end of the module is marked by a matching DNTT_TYPE_END record.
2873 * The reason GDB gets away with ignoring the DNTT_TYPE_MODULE record
2874 * is it notices the DNTT_TYPE_END record for the previous
2875 * module (see comments under DNTT_TYPE_END case), and then treats
2876 * the next DNTT_TYPE_SRCFILE record as if it were the module-start record.
2877 * (i.e., it makes a start_symtab() call).
2878 * This scheme seems a little convoluted, but I'll leave it
2879 * alone on the principle "if it ain't broke don't fix
2882 *-- End outdated comments
2886 if (!last_source_file
)
2888 /* Start of a new module. We know this because "last_source_file"
2889 * is NULL, which can only happen the first time or if we just
2890 * made a call to end_symtab() to close out the previous module.
2892 start_symtab (name
, NULL
, valu
);
2893 SL_INDEX (objfile
) = dn_bufp
->dmodule
.address
;
2897 /* This really shouldn't happen if we're using the quick
2898 * look-up tables, as it would mean we'd scanned past an
2899 * END MODULE entry. But if we're not using the tables,
2900 * we started the module on the SRCFILE entry, so it's ok.
2901 * For now, accept this.
2903 /* warning( "Error expanding psymtab, missed module end, found entry for %s",
2906 *at_module_boundary_p
= -1;
2909 start_subfile (name
, NULL
);
2912 case DNTT_TYPE_FUNCTION
:
2913 case DNTT_TYPE_ENTRY
:
2914 /* A function or secondary entry point. */
2915 valu
= dn_bufp
->dfunc
.lowaddr
+ offset
;
2917 /* Record lines up to this point. */
2918 SL_INDEX (objfile
) = hpread_record_lines (current_subfile
,
2920 dn_bufp
->dfunc
.address
,
2923 WITHIN_FUNCTION (objfile
) = 1;
2924 CURRENT_FUNCTION_VALUE (objfile
) = valu
;
2926 /* Stack must be empty now. */
2927 if (context_stack_depth
!= 0)
2928 complain (&lbrac_unmatched_complaint
, (char *) symnum
);
2929 new = push_context (0, valu
);
2931 /* Built a type for the function. This includes processing
2932 * the symbol records for the function parameters.
2934 SYMBOL_CLASS (sym
) = LOC_BLOCK
;
2935 SYMBOL_TYPE (sym
) = hpread_read_function_type (hp_type
, dn_bufp
, objfile
, 1);
2937 /* The "SYMBOL_NAME" field is expected to be the mangled name
2938 * (if any), which we get from the "alias" field of the SOM record
2941 if ((dn_bufp
->dfunc
.language
== HP_LANGUAGE_CPLUSPLUS
) &&
2942 dn_bufp
->dfunc
.alias
&& /* has an alias */
2943 *(char *) (VT (objfile
) + dn_bufp
->dfunc
.alias
)) /* not a null string */
2944 SYMBOL_NAME (sym
) = VT (objfile
) + dn_bufp
->dfunc
.alias
;
2946 SYMBOL_NAME (sym
) = VT (objfile
) + dn_bufp
->dfunc
.name
;
2948 /* Special hack to get around HP compilers' insistence on
2949 * reporting "main" as "_MAIN_" for C/C++ */
2950 if ((strcmp (SYMBOL_NAME (sym
), "_MAIN_") == 0) &&
2951 (strcmp (VT (objfile
) + dn_bufp
->dfunc
.name
, "main") == 0))
2952 SYMBOL_NAME (sym
) = VT (objfile
) + dn_bufp
->dfunc
.name
;
2954 /* The SYMBOL_CPLUS_DEMANGLED_NAME field is expected to
2955 * be the demangled name.
2957 if (dn_bufp
->dfunc
.language
== HP_LANGUAGE_CPLUSPLUS
)
2959 /* SYMBOL_INIT_DEMANGLED_NAME is a macro which winds up
2960 * calling the demangler in libiberty (cplus_demangle()) to
2961 * do the job. This generally does the job, even though
2962 * it's intended for the GNU compiler and not the aCC compiler
2963 * Note that SYMBOL_INIT_DEMANGLED_NAME calls the
2964 * demangler with arguments DMGL_PARAMS | DMGL_ANSI.
2965 * Generally, we don't want params when we display
2966 * a demangled name, but when I took out the DMGL_PARAMS,
2967 * some things broke, so I'm leaving it in here, and
2968 * working around the issue in stack.c. - RT
2970 SYMBOL_INIT_DEMANGLED_NAME (sym
, &objfile
->symbol_obstack
);
2971 if ((SYMBOL_NAME (sym
) == VT (objfile
) + dn_bufp
->dfunc
.alias
) &&
2972 (!SYMBOL_CPLUS_DEMANGLED_NAME (sym
)))
2975 /* Well, the symbol name is mangled, but the
2976 * demangler in libiberty failed so the demangled
2977 * field is still NULL. Try to
2978 * do the job ourselves based on the "name" field
2979 * in the SOM record. A complication here is that
2980 * the name field contains only the function name
2981 * (like "f"), whereas we want the class qualification
2982 * (as in "c::f"). Try to reconstruct that.
2987 basename
= VT (objfile
) + dn_bufp
->dfunc
.name
;
2988 classname
= class_of (SYMBOL_TYPE (sym
));
2991 dem_name
= xmalloc (strlen (basename
) + strlen (classname
) + 3);
2992 strcpy (dem_name
, classname
);
2993 strcat (dem_name
, "::");
2994 strcat (dem_name
, basename
);
2995 SYMBOL_CPLUS_DEMANGLED_NAME (sym
) = dem_name
;
2996 SYMBOL_LANGUAGE (sym
) = language_cplus
;
3001 /* Add the function symbol to the list of symbols in this blockvector */
3002 if (dn_bufp
->dfunc
.global
)
3003 add_symbol_to_list (sym
, &global_symbols
);
3005 add_symbol_to_list (sym
, &file_symbols
);
3008 /* Search forward to the next BEGIN and also read
3009 * in the line info up to that point.
3010 * Not sure why this is needed.
3011 * In HP FORTRAN this code is harmful since there
3012 * may not be a BEGIN after the FUNCTION.
3013 * So I made it C/C++ specific. - RT
3015 if (dn_bufp
->dfunc
.language
== HP_LANGUAGE_C
||
3016 dn_bufp
->dfunc
.language
== HP_LANGUAGE_CPLUSPLUS
)
3018 while (dn_bufp
->dblock
.kind
!= DNTT_TYPE_BEGIN
)
3020 dn_bufp
= hpread_get_lntt (++index
, objfile
);
3021 if (dn_bufp
->dblock
.extension
)
3024 SL_INDEX (objfile
) = hpread_record_lines (current_subfile
,
3026 dn_bufp
->dbegin
.address
,
3028 SYMBOL_LINE (sym
) = hpread_get_line (dn_bufp
->dbegin
.address
, objfile
);
3030 record_line (current_subfile
, SYMBOL_LINE (sym
), valu
);
3033 case DNTT_TYPE_DOC_FUNCTION
:
3034 valu
= dn_bufp
->ddocfunc
.lowaddr
+ offset
;
3036 /* Record lines up to this point. */
3037 SL_INDEX (objfile
) = hpread_record_lines (current_subfile
,
3039 dn_bufp
->ddocfunc
.address
,
3042 WITHIN_FUNCTION (objfile
) = 1;
3043 CURRENT_FUNCTION_VALUE (objfile
) = valu
;
3044 /* Stack must be empty now. */
3045 if (context_stack_depth
!= 0)
3046 complain (&lbrac_unmatched_complaint
, (char *) symnum
);
3047 new = push_context (0, valu
);
3049 /* Built a type for the function. This includes processing
3050 * the symbol records for the function parameters.
3052 SYMBOL_CLASS (sym
) = LOC_BLOCK
;
3053 SYMBOL_TYPE (sym
) = hpread_read_doc_function_type (hp_type
, dn_bufp
, objfile
, 1);
3055 /* The "SYMBOL_NAME" field is expected to be the mangled name
3056 * (if any), which we get from the "alias" field of the SOM record
3059 if ((dn_bufp
->ddocfunc
.language
== HP_LANGUAGE_CPLUSPLUS
) &&
3060 dn_bufp
->ddocfunc
.alias
&& /* has an alias */
3061 *(char *) (VT (objfile
) + dn_bufp
->ddocfunc
.alias
)) /* not a null string */
3062 SYMBOL_NAME (sym
) = VT (objfile
) + dn_bufp
->ddocfunc
.alias
;
3064 SYMBOL_NAME (sym
) = VT (objfile
) + dn_bufp
->ddocfunc
.name
;
3066 /* Special hack to get around HP compilers' insistence on
3067 * reporting "main" as "_MAIN_" for C/C++ */
3068 if ((strcmp (SYMBOL_NAME (sym
), "_MAIN_") == 0) &&
3069 (strcmp (VT (objfile
) + dn_bufp
->ddocfunc
.name
, "main") == 0))
3070 SYMBOL_NAME (sym
) = VT (objfile
) + dn_bufp
->ddocfunc
.name
;
3072 if (dn_bufp
->ddocfunc
.language
== HP_LANGUAGE_CPLUSPLUS
)
3075 /* SYMBOL_INIT_DEMANGLED_NAME is a macro which winds up
3076 * calling the demangler in libiberty (cplus_demangle()) to
3077 * do the job. This generally does the job, even though
3078 * it's intended for the GNU compiler and not the aCC compiler
3079 * Note that SYMBOL_INIT_DEMANGLED_NAME calls the
3080 * demangler with arguments DMGL_PARAMS | DMGL_ANSI.
3081 * Generally, we don't want params when we display
3082 * a demangled name, but when I took out the DMGL_PARAMS,
3083 * some things broke, so I'm leaving it in here, and
3084 * working around the issue in stack.c. - RT
3086 SYMBOL_INIT_DEMANGLED_NAME (sym
, &objfile
->symbol_obstack
);
3088 if ((SYMBOL_NAME (sym
) == VT (objfile
) + dn_bufp
->ddocfunc
.alias
) &&
3089 (!SYMBOL_CPLUS_DEMANGLED_NAME (sym
)))
3092 /* Well, the symbol name is mangled, but the
3093 * demangler in libiberty failed so the demangled
3094 * field is still NULL. Try to
3095 * do the job ourselves based on the "name" field
3096 * in the SOM record. A complication here is that
3097 * the name field contains only the function name
3098 * (like "f"), whereas we want the class qualification
3099 * (as in "c::f"). Try to reconstruct that.
3104 basename
= VT (objfile
) + dn_bufp
->ddocfunc
.name
;
3105 classname
= class_of (SYMBOL_TYPE (sym
));
3108 dem_name
= xmalloc (strlen (basename
) + strlen (classname
) + 3);
3109 strcpy (dem_name
, classname
);
3110 strcat (dem_name
, "::");
3111 strcat (dem_name
, basename
);
3112 SYMBOL_CPLUS_DEMANGLED_NAME (sym
) = dem_name
;
3113 SYMBOL_LANGUAGE (sym
) = language_cplus
;
3118 /* Add the function symbol to the list of symbols in this blockvector */
3119 if (dn_bufp
->ddocfunc
.global
)
3120 add_symbol_to_list (sym
, &global_symbols
);
3122 add_symbol_to_list (sym
, &file_symbols
);
3125 /* Search forward to the next BEGIN and also read
3126 * in the line info up to that point.
3127 * Not sure why this is needed.
3128 * In HP FORTRAN this code is harmful since there
3129 * may not be a BEGIN after the FUNCTION.
3130 * So I made it C/C++ specific. - RT
3132 if (dn_bufp
->ddocfunc
.language
== HP_LANGUAGE_C
||
3133 dn_bufp
->ddocfunc
.language
== HP_LANGUAGE_CPLUSPLUS
)
3135 while (dn_bufp
->dblock
.kind
!= DNTT_TYPE_BEGIN
)
3137 dn_bufp
= hpread_get_lntt (++index
, objfile
);
3138 if (dn_bufp
->dblock
.extension
)
3141 SL_INDEX (objfile
) = hpread_record_lines (current_subfile
,
3143 dn_bufp
->dbegin
.address
,
3145 SYMBOL_LINE (sym
) = hpread_get_line (dn_bufp
->dbegin
.address
, objfile
);
3147 record_line (current_subfile
, SYMBOL_LINE (sym
), valu
);
3150 case DNTT_TYPE_BEGIN
:
3151 /* Begin a new scope. */
3152 if (context_stack_depth
== 1 /* this means we're at function level */ &&
3153 context_stack
[0].name
!= NULL
/* this means it's a function */ &&
3154 context_stack
[0].depth
== 0 /* this means it's the first BEGIN
3155 we've seen after the FUNCTION */
3158 /* This is the first BEGIN after a FUNCTION.
3159 * We ignore this one, since HP compilers always insert
3160 * at least one BEGIN, i.e. it's:
3166 * (possibly nested BEGIN ... END's if there are inner { } blocks)
3170 * By ignoring this first BEGIN, the local symbols get treated
3171 * as belonging to the function scope, and "print func::local_sym"
3172 * works (which is what we want).
3175 /* All we do here is increase the depth count associated with
3176 * the FUNCTION entry in the context stack. This ensures that
3177 * the next BEGIN we see (if any), representing a real nested { }
3178 * block, will get processed.
3181 context_stack
[0].depth
++;
3187 /* Record lines up to this SLT pointer. */
3188 SL_INDEX (objfile
) = hpread_record_lines (current_subfile
,
3190 dn_bufp
->dbegin
.address
,
3192 /* Calculate start address of new scope */
3193 valu
= hpread_get_location (dn_bufp
->dbegin
.address
, objfile
);
3194 valu
+= offset
; /* Relocate for dynamic loading */
3195 /* We use the scope start DNTT index as nesting depth identifier! */
3196 desc
= hpread_get_scope_start (dn_bufp
->dbegin
.address
, objfile
);
3197 new = push_context (desc
, valu
);
3204 /* Valid end kinds are:
3213 SL_INDEX (objfile
) = hpread_record_lines (current_subfile
,
3215 dn_bufp
->dend
.address
,
3217 switch (dn_bufp
->dend
.endkind
)
3219 case DNTT_TYPE_MODULE
:
3220 /* Ending a module ends the symbol table for that module.
3221 * Calling end_symtab() has the side effect of clearing the
3222 * last_source_file pointer, which in turn signals
3223 * process_one_debug_symbol() to treat the next DNTT_TYPE_SRCFILE
3224 * record as a module-begin.
3226 valu
= text_offset
+ text_size
+ offset
;
3228 /* Tell our caller that we're done with expanding the
3229 * debug information for a module.
3231 *at_module_boundary_p
= 1;
3233 /* Don't do this, as our caller will do it!
3235 * (void) end_symtab (valu, objfile, 0);
3239 case DNTT_TYPE_FUNCTION
:
3240 /* Ending a function, well, ends the function's scope. */
3241 dn_temp
= hpread_get_lntt (dn_bufp
->dend
.beginscope
.dnttp
.index
,
3243 valu
= dn_temp
->dfunc
.hiaddr
+ offset
;
3244 /* Insert func params into local list */
3245 merge_symbol_lists (¶m_symbols
, &local_symbols
);
3246 new = pop_context ();
3247 /* Make a block for the local symbols within. */
3248 finish_block (new->name
, &local_symbols
, new->old_blocks
,
3249 new->start_addr
, valu
, objfile
);
3250 WITHIN_FUNCTION (objfile
) = 0; /* This may have to change for Pascal */
3251 local_symbols
= new->locals
;
3252 param_symbols
= new->params
;
3255 case DNTT_TYPE_BEGIN
:
3256 if (context_stack_depth
== 1 &&
3257 context_stack
[0].name
!= NULL
&&
3258 context_stack
[0].depth
== 1)
3260 /* This is the END corresponding to the
3261 * BEGIN which we ignored - see DNTT_TYPE_BEGIN case above.
3263 context_stack
[0].depth
--;
3267 /* Ending a local scope. */
3268 valu
= hpread_get_location (dn_bufp
->dend
.address
, objfile
);
3269 /* Why in the hell is this needed? */
3270 valu
+= offset
+ 9; /* Relocate for dynamic loading */
3271 new = pop_context ();
3272 desc
= dn_bufp
->dend
.beginscope
.dnttp
.index
;
3273 if (desc
!= new->depth
)
3274 complain (&lbrac_mismatch_complaint
, (char *) symnum
);
3276 /* Make a block for the local symbols within. */
3277 finish_block (new->name
, &local_symbols
, new->old_blocks
,
3278 new->start_addr
, valu
, objfile
);
3279 local_symbols
= new->locals
;
3280 param_symbols
= new->params
;
3284 case DNTT_TYPE_WITH
:
3285 /* Since we ignore the DNTT_TYPE_WITH that starts the scope,
3286 * we can ignore the DNTT_TYPE_END that ends it.
3290 case DNTT_TYPE_COMMON
:
3291 /* End a FORTRAN common block. We don't currently handle these */
3292 complain (&hpread_unhandled_end_common_complaint
);
3295 case DNTT_TYPE_CLASS_SCOPE
:
3297 /* pai: FIXME Not handling nested classes for now -- must
3298 * maintain a stack */
3299 class_scope_name
= NULL
;
3302 /* End a class scope */
3303 valu
= hpread_get_location (dn_bufp
->dend
.address
, objfile
);
3304 /* Why in the hell is this needed? */
3305 valu
+= offset
+ 9; /* Relocate for dynamic loading */
3306 new = pop_context ();
3307 desc
= dn_bufp
->dend
.beginscope
.dnttp
.index
;
3308 if (desc
!= new->depth
)
3309 complain (&lbrac_mismatch_complaint
, (char *) symnum
);
3310 /* Make a block for the local symbols within. */
3311 finish_block (new->name
, &local_symbols
, new->old_blocks
,
3312 new->start_addr
, valu
, objfile
);
3313 local_symbols
= new->locals
;
3314 param_symbols
= new->params
;
3319 complain (&hpread_unexpected_end_complaint
);
3324 /* DNTT_TYPE_IMPORT is not handled */
3326 case DNTT_TYPE_LABEL
:
3327 SYMBOL_NAMESPACE (sym
) = LABEL_NAMESPACE
;
3330 case DNTT_TYPE_FPARAM
:
3331 /* Function parameters. */
3332 /* Note 1: This code was present in the 4.16 sources, and then
3333 removed, because fparams are handled in
3334 hpread_read_function_type(). However, while fparam symbols
3335 are indeed handled twice, this code here cannot be removed
3336 because then they don't get added to the local symbol list of
3337 the function's code block, which leads to a failure to look
3338 up locals, "this"-relative member names, etc. So I've put
3339 this code back in. pai/1997-07-21 */
3340 /* Note 2: To fix a defect, we stopped adding FPARAMS to local_symbols
3341 in hpread_read_function_type(), so FPARAMS had to be handled
3342 here. I changed the location to be the appropriate argument
3343 kinds rather than LOC_LOCAL. pai/1997-08-08 */
3344 /* Note 3: Well, the fix in Note 2 above broke argument printing
3345 in traceback frames, and further it makes assumptions about the
3346 order of the FPARAM entries from HP compilers (cc and aCC in particular
3347 generate them in reverse orders -- fixing one breaks for the other).
3348 So I've added code in hpread_read_function_type() to add fparams
3349 to a param_symbols list for the current context level. These are
3350 then merged into local_symbols when a function end is reached.
3353 break; /* do nothing; handled in hpread_read_function_type() */
3355 #if 0 /* Old code */
3356 if (dn_bufp
->dfparam
.regparam
)
3357 SYMBOL_CLASS (sym
) = LOC_REGISTER
;
3358 else if (dn_bufp
->dfparam
.indirect
)
3359 SYMBOL_CLASS (sym
) = LOC_REF_ARG
;
3361 SYMBOL_CLASS (sym
) = LOC_ARG
;
3362 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
3363 if (dn_bufp
->dfparam
.copyparam
)
3365 SYMBOL_VALUE (sym
) = dn_bufp
->dfparam
.location
;
3366 #ifdef HPREAD_ADJUST_STACK_ADDRESS
3368 += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile
));
3372 SYMBOL_VALUE (sym
) = dn_bufp
->dfparam
.location
;
3373 SYMBOL_TYPE (sym
) = hpread_type_lookup (dn_bufp
->dfparam
.type
, objfile
);
3374 add_symbol_to_list (sym
, &fparam_symbols
);
3378 case DNTT_TYPE_SVAR
:
3379 /* Static variables. */
3380 SYMBOL_CLASS (sym
) = LOC_STATIC
;
3382 /* Note: There is a case that arises with globals in shared
3383 * libraries where we need to set the address to LOC_INDIRECT.
3384 * This case is if you have a global "g" in one library, and
3385 * it is referenced "extern <type> g;" in another library.
3386 * If we're processing the symbols for the referencing library,
3387 * we'll see a global "g", but in this case the address given
3388 * in the symbol table contains a pointer to the real "g".
3389 * We use the storage class LOC_INDIRECT to indicate this. RT
3391 if (is_in_import_list (SYMBOL_NAME (sym
), objfile
))
3392 SYMBOL_CLASS (sym
) = LOC_INDIRECT
;
3394 SYMBOL_VALUE_ADDRESS (sym
) = dn_bufp
->dsvar
.location
+ data_offset
;
3395 SYMBOL_TYPE (sym
) = hpread_type_lookup (dn_bufp
->dsvar
.type
, objfile
);
3397 if (dn_bufp
->dsvar
.global
)
3398 add_symbol_to_list (sym
, &global_symbols
);
3400 else if (WITHIN_FUNCTION (objfile
))
3401 add_symbol_to_list (sym
, &local_symbols
);
3404 add_symbol_to_list (sym
, &file_symbols
);
3406 if (dn_bufp
->dsvar
.thread_specific
)
3408 /* Thread-local variable.
3410 SYMBOL_CLASS (sym
) = LOC_THREAD_LOCAL_STATIC
;
3411 SYMBOL_BASEREG (sym
) = CR27_REGNUM
;
3413 if (objfile
->flags
& OBJF_SHARED
)
3416 * This variable is not only thread local but
3417 * in a shared library.
3419 * Alas, the shared lib structures are private
3420 * to "somsolib.c". But C lets us point to one.
3424 if (objfile
->obj_private
== NULL
)
3425 error ("Internal error in reading shared library information.");
3427 so
= ((obj_private_data_t
*) (objfile
->obj_private
))->so_info
;
3429 error ("Internal error in reading shared library information.");
3431 /* Thread-locals in shared libraries do NOT have the
3432 * standard offset ("data_offset"), so we re-calculate
3433 * where to look for this variable, using a call-back
3434 * to interpret the private shared-library data.
3436 SYMBOL_VALUE_ADDRESS (sym
) = dn_bufp
->dsvar
.location
+
3437 so_lib_thread_start_addr (so
);
3442 case DNTT_TYPE_DVAR
:
3443 /* Dynamic variables. */
3444 if (dn_bufp
->ddvar
.regvar
)
3445 SYMBOL_CLASS (sym
) = LOC_REGISTER
;
3447 SYMBOL_CLASS (sym
) = LOC_LOCAL
;
3449 SYMBOL_VALUE (sym
) = dn_bufp
->ddvar
.location
;
3450 #ifdef HPREAD_ADJUST_STACK_ADDRESS
3452 += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile
));
3454 SYMBOL_TYPE (sym
) = hpread_type_lookup (dn_bufp
->ddvar
.type
, objfile
);
3455 if (dn_bufp
->ddvar
.global
)
3456 add_symbol_to_list (sym
, &global_symbols
);
3457 else if (WITHIN_FUNCTION (objfile
))
3458 add_symbol_to_list (sym
, &local_symbols
);
3460 add_symbol_to_list (sym
, &file_symbols
);
3463 case DNTT_TYPE_CONST
:
3464 /* A constant (pascal?). */
3465 SYMBOL_CLASS (sym
) = LOC_CONST
;
3466 SYMBOL_VALUE (sym
) = dn_bufp
->dconst
.location
;
3467 SYMBOL_TYPE (sym
) = hpread_type_lookup (dn_bufp
->dconst
.type
, objfile
);
3468 if (dn_bufp
->dconst
.global
)
3469 add_symbol_to_list (sym
, &global_symbols
);
3470 else if (WITHIN_FUNCTION (objfile
))
3471 add_symbol_to_list (sym
, &local_symbols
);
3473 add_symbol_to_list (sym
, &file_symbols
);
3476 case DNTT_TYPE_TYPEDEF
:
3477 /* A typedef. We do want to process these, since a name is
3478 * added to the namespace for the typedef'ed name.
3480 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
3481 SYMBOL_TYPE (sym
) = hpread_type_lookup (dn_bufp
->dtype
.type
, objfile
);
3482 if (dn_bufp
->dtype
.global
)
3483 add_symbol_to_list (sym
, &global_symbols
);
3484 else if (WITHIN_FUNCTION (objfile
))
3485 add_symbol_to_list (sym
, &local_symbols
);
3487 add_symbol_to_list (sym
, &file_symbols
);
3490 case DNTT_TYPE_TAGDEF
:
3492 int global
= dn_bufp
->dtag
.global
;
3493 /* Structure, union, enum, template, or class tag definition */
3494 /* We do want to process these, since a name is
3495 * added to the namespace for the tag name (and if C++ class,
3496 * for the typename also).
3498 SYMBOL_NAMESPACE (sym
) = STRUCT_NAMESPACE
;
3500 /* The tag contains in its "type" field a pointer to the
3501 * DNTT_TYPE_STRUCT, DNTT_TYPE_UNION, DNTT_TYPE_ENUM,
3502 * DNTT_TYPE_CLASS or DNTT_TYPE_TEMPLATE
3503 * record that actually defines the type.
3505 SYMBOL_TYPE (sym
) = hpread_type_lookup (dn_bufp
->dtype
.type
, objfile
);
3506 TYPE_NAME (sym
->type
) = SYMBOL_NAME (sym
);
3507 TYPE_TAG_NAME (sym
->type
) = SYMBOL_NAME (sym
);
3508 if (dn_bufp
->dtag
.global
)
3509 add_symbol_to_list (sym
, &global_symbols
);
3510 else if (WITHIN_FUNCTION (objfile
))
3511 add_symbol_to_list (sym
, &local_symbols
);
3513 add_symbol_to_list (sym
, &file_symbols
);
3515 /* If this is a C++ class, then we additionally
3516 * need to define a typedef for the
3517 * class type. E.g., so that the name "c" becomes visible as
3518 * a type name when the user says "class c { ... }".
3519 * In order to figure this out, we need to chase down the "type"
3520 * field to get to the DNTT_TYPE_CLASS record.
3522 * We also add the typename for ENUM. Though this isn't
3523 * strictly correct, it is necessary because of the debug info
3524 * generated by the aCC compiler, in which we cannot
3525 * distinguish between:
3528 * typedef enum { ... } e;
3529 * I.e., the compiler emits the same debug info for the above
3530 * two cases, in both cases "e" appearing as a tagdef.
3531 * Therefore go ahead and generate the typename so that
3532 * "ptype e" will work in the above cases.
3534 * We also add the typename for TEMPLATE, so as to allow "ptype t"
3535 * when "t" is a template name.
3537 if (dn_bufp
->dtype
.type
.dnttp
.index
< LNTT_SYMCOUNT (objfile
))
3538 dn_bufp
= hpread_get_lntt (dn_bufp
->dtag
.type
.dnttp
.index
, objfile
);
3541 complain (&hpread_tagdef_complaint
);
3544 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_CLASS
||
3545 dn_bufp
->dblock
.kind
== DNTT_TYPE_ENUM
||
3546 dn_bufp
->dblock
.kind
== DNTT_TYPE_TEMPLATE
)
3548 struct symbol
*newsym
;
3550 newsym
= (struct symbol
*) obstack_alloc (&objfile
->symbol_obstack
,
3551 sizeof (struct symbol
));
3552 memset (newsym
, 0, sizeof (struct symbol
));
3553 SYMBOL_NAME (newsym
) = name
;
3554 SYMBOL_LANGUAGE (newsym
) = language_auto
;
3555 SYMBOL_NAMESPACE (newsym
) = VAR_NAMESPACE
;
3556 SYMBOL_LINE (newsym
) = 0;
3557 SYMBOL_VALUE (newsym
) = 0;
3558 SYMBOL_CLASS (newsym
) = LOC_TYPEDEF
;
3559 SYMBOL_TYPE (newsym
) = sym
->type
;
3561 add_symbol_to_list (newsym
, &global_symbols
);
3562 else if (WITHIN_FUNCTION (objfile
))
3563 add_symbol_to_list (newsym
, &local_symbols
);
3565 add_symbol_to_list (newsym
, &file_symbols
);
3570 case DNTT_TYPE_POINTER
:
3571 /* Declares a pointer type. Should not be necessary to do anything
3572 * with the type at this level; these are processed
3573 * at the hpread_type_lookup() level.
3577 case DNTT_TYPE_ENUM
:
3578 /* Declares an enum type. Should not be necessary to do anything
3579 * with the type at this level; these are processed
3580 * at the hpread_type_lookup() level.
3584 case DNTT_TYPE_MEMENUM
:
3585 /* Member of enum */
3586 /* Ignored at this level, but hpread_read_enum_type() will take
3587 * care of walking the list of enumeration members.
3592 /* Declares a set type. Should not be necessary to do anything
3593 * with the type at this level; these are processed
3594 * at the hpread_type_lookup() level.
3598 case DNTT_TYPE_SUBRANGE
:
3599 /* Declares a subrange type. Should not be necessary to do anything
3600 * with the type at this level; these are processed
3601 * at the hpread_type_lookup() level.
3605 case DNTT_TYPE_ARRAY
:
3606 /* Declares an array type. Should not be necessary to do anything
3607 * with the type at this level; these are processed
3608 * at the hpread_type_lookup() level.
3612 case DNTT_TYPE_STRUCT
:
3613 case DNTT_TYPE_UNION
:
3614 /* Declares an struct/union type.
3615 * Should not be necessary to do anything
3616 * with the type at this level; these are processed
3617 * at the hpread_type_lookup() level.
3621 case DNTT_TYPE_FIELD
:
3622 /* Structure/union/class field */
3623 /* Ignored at this level, but hpread_read_struct_type() will take
3624 * care of walking the list of structure/union/class members.
3628 /* DNTT_TYPE_VARIANT is not handled by GDB */
3630 /* DNTT_TYPE_FILE is not handled by GDB */
3632 case DNTT_TYPE_FUNCTYPE
:
3634 /* Ignored at this level, handled within hpread_type_lookup() */
3637 case DNTT_TYPE_WITH
:
3638 /* This is emitted within methods to indicate "with <class>"
3639 * scoping rules (i.e., indicate that the class data members
3640 * are directly visible).
3641 * However, since GDB already infers this by looking at the
3642 * "this" argument, interpreting the DNTT_TYPE_WITH
3643 * symbol record is unnecessary.
3647 case DNTT_TYPE_COMMON
:
3648 /* FORTRAN common. Not yet handled. */
3649 complain (&hpread_unhandled_common_complaint
);
3652 /* DNTT_TYPE_COBSTRUCT is not handled by GDB. */
3653 /* DNTT_TYPE_XREF is not handled by GDB. */
3654 /* DNTT_TYPE_SA is not handled by GDB. */
3655 /* DNTT_TYPE_MACRO is not handled by GDB */
3657 case DNTT_TYPE_BLOCKDATA
:
3658 /* Not sure what this is - part of FORTRAN support maybe?
3659 * Anyway, not yet handled.
3661 complain (&hpread_unhandled_blockdata_complaint
);
3664 case DNTT_TYPE_CLASS_SCOPE
:
3668 /* The compiler brackets member functions with a CLASS_SCOPE/END
3669 * pair of records, presumably to put them in a different scope
3670 * from the module scope where they are normally defined.
3671 * E.g., in the situation:
3673 * void c::f() { ...}
3674 * The member function "c::f" will be bracketed by a CLASS_SCOPE/END.
3675 * This causes "break f" at the module level to pick the
3676 * the file-level function f(), not the member function
3677 * (which needs to be referenced via "break c::f").
3679 * Here we record the class name to generate the demangled names of
3680 * member functions later.
3682 * FIXME Not being used now for anything -- cplus_demangle seems
3683 * enough for getting the class-qualified names of functions. We
3684 * may need this for handling nested classes and types. */
3686 /* pai: FIXME Not handling nested classes for now -- need to
3687 * maintain a stack */
3689 dn_temp
= hpread_get_lntt (dn_bufp
->dclass_scope
.type
.dnttp
.index
, objfile
);
3690 if (dn_temp
->dblock
.kind
== DNTT_TYPE_TAGDEF
)
3691 class_scope_name
= VT (objfile
) + dn_temp
->dtag
.name
;
3693 class_scope_name
= NULL
;
3697 /* Begin a new scope. */
3698 SL_INDEX (objfile
) = hpread_record_lines (current_subfile
,
3700 dn_bufp
->dclass_scope
.address
,
3702 valu
= hpread_get_location (dn_bufp
->dclass_scope
.address
, objfile
);
3703 valu
+= offset
; /* Relocate for dynamic loading */
3704 desc
= hpread_get_scope_start (dn_bufp
->dclass_scope
.address
, objfile
);
3705 /* We use the scope start DNTT index as the nesting depth identifier! */
3706 new = push_context (desc
, valu
);
3710 case DNTT_TYPE_REFERENCE
:
3711 /* Declares a C++ reference type. Should not be necessary to do anything
3712 * with the type at this level; these are processed
3713 * at the hpread_type_lookup() level.
3717 case DNTT_TYPE_PTRMEM
:
3718 /* Declares a C++ pointer-to-data-member type. This does not
3719 * need to be handled at this level; being a type description it
3720 * is instead handled at the hpread_type_lookup() level.
3724 case DNTT_TYPE_PTRMEMFUNC
:
3725 /* Declares a C++ pointer-to-function-member type. This does not
3726 * need to be handled at this level; being a type description it
3727 * is instead handled at the hpread_type_lookup() level.
3731 case DNTT_TYPE_CLASS
:
3732 /* Declares a class type.
3733 * Should not be necessary to do anything
3734 * with the type at this level; these are processed
3735 * at the hpread_type_lookup() level.
3739 case DNTT_TYPE_GENFIELD
:
3740 /* I believe this is used for class member functions */
3741 /* Ignored at this level, but hpread_read_struct_type() will take
3742 * care of walking the list of class members.
3746 case DNTT_TYPE_VFUNC
:
3747 /* Virtual function */
3748 /* This does not have to be handled at this level; handled in
3749 * the course of processing class symbols.
3753 case DNTT_TYPE_MEMACCESS
:
3754 /* DDE ignores this symbol table record.
3755 * It has something to do with "modified access" to class members.
3756 * I'll assume we can safely ignore it too.
3760 case DNTT_TYPE_INHERITANCE
:
3761 /* These don't have to be handled here, since they are handled
3762 * within hpread_read_struct_type() in the process of constructing
3767 case DNTT_TYPE_FRIEND_CLASS
:
3768 case DNTT_TYPE_FRIEND_FUNC
:
3769 /* These can safely be ignored, as GDB doesn't need this
3770 * info. DDE only uses it in "describe". We may later want
3771 * to extend GDB's "ptype" to give this info, but for now
3772 * it seems safe enough to ignore it.
3776 case DNTT_TYPE_MODIFIER
:
3777 /* Intended to supply "modified access" to a type */
3778 /* From the way DDE handles this, it looks like it always
3779 * modifies a type. Therefore it is safe to ignore it at this
3780 * level, and handle it in hpread_type_lookup().
3784 case DNTT_TYPE_OBJECT_ID
:
3785 /* Just ignore this - that's all DDE does */
3788 case DNTT_TYPE_MEMFUNC
:
3789 /* Member function */
3790 /* This does not have to be handled at this level; handled in
3791 * the course of processing class symbols.
3795 case DNTT_TYPE_DOC_MEMFUNC
:
3796 /* Member function */
3797 /* This does not have to be handled at this level; handled in
3798 * the course of processing class symbols.
3802 case DNTT_TYPE_TEMPLATE
:
3803 /* Template - sort of the header for a template definition,
3804 * which like a class, points to a member list and also points
3805 * to a TEMPLATE_ARG list of type-arguments.
3806 * We do not need to process TEMPLATE records at this level though.
3810 case DNTT_TYPE_TEMPLATE_ARG
:
3811 /* The TEMPLATE record points to an argument list of
3812 * TEMPLATE_ARG records, each of which describes one
3813 * of the type-arguments.
3814 * We do not need to process TEMPLATE_ARG records at this level though.
3818 case DNTT_TYPE_FUNC_TEMPLATE
:
3819 /* This will get emitted for member functions of templates.
3820 * But we don't need to process this record at this level though,
3821 * we will process it in the course of processing a TEMPLATE
3826 case DNTT_TYPE_LINK
:
3827 /* The LINK record is used to link up templates with instantiations. */
3828 /* It is not clear why this is needed, and furthermore aCC does
3829 * not appear to generate this, so I think we can safely ignore it. - RT
3833 /* DNTT_TYPE_DYN_ARRAY_DESC is not handled by GDB */
3834 /* DNTT_TYPE_DESC_SUBRANGE is not handled by GDB */
3835 /* DNTT_TYPE_BEGIN_EXT is not handled by GDB */
3836 /* DNTT_TYPE_INLN is not handled by GDB */
3837 /* DNTT_TYPE_INLN_LIST is not handled by GDB */
3838 /* DNTT_TYPE_ALIAS is not handled by GDB */
3845 /* Get nesting depth for a DNTT entry.
3846 * DN_BUFP points to a DNTT entry.
3847 * OBJFILE is the object file.
3848 * REPORT_NESTED is a flag; if 0, real nesting depth is
3849 * reported, if it is 1, the function simply returns a
3850 * non-zero value if the nesting depth is anything > 0.
3852 * Return value is an integer. 0 => not a local type / name
3853 * positive return => type or name is local to some
3854 * block or function.
3858 /* elz: ATTENTION: FIXME: NOTE: WARNING!!!!
3859 this function now returns 0 right away. It was taking too much time
3860 at start up. Now, though, the local types are not handled correctly.
3865 hpread_get_scope_depth (union dnttentry
*dn_bufp
, struct objfile
*objfile
,
3869 register union dnttentry
*dn_tmp
;
3870 register short depth
= 0;
3871 /****************************/
3873 /****************************/
3875 index
= (((char *) dn_bufp
) - LNTT (objfile
)) / (sizeof (struct dntt_type_block
));
3877 while (--index
>= 0)
3879 dn_tmp
= hpread_get_lntt (index
, objfile
);
3880 switch (dn_tmp
->dblock
.kind
)
3882 case DNTT_TYPE_MODULE
:
3885 /* index is signed int; dnttp.index is 29-bit unsigned int! */
3886 index
= (int) dn_tmp
->dend
.beginscope
.dnttp
.index
;
3888 case DNTT_TYPE_BEGIN
:
3889 case DNTT_TYPE_FUNCTION
:
3890 case DNTT_TYPE_DOC_FUNCTION
:
3891 case DNTT_TYPE_WITH
:
3892 case DNTT_TYPE_COMMON
:
3893 case DNTT_TYPE_CLASS_SCOPE
:
3905 /* Adjust the bitoffsets for all fields of an anonymous union of
3906 type TYPE by negative BITS. This handles HP aCC's hideous habit
3907 of giving members of anonymous unions bit offsets relative to the
3908 enclosing structure instead of relative to the union itself. */
3911 hpread_adjust_bitoffsets (struct type
*type
, int bits
)
3915 /* This is done only for unions; caller had better check that
3916 it is an anonymous one. */
3917 if (TYPE_CODE (type
) != TYPE_CODE_UNION
)
3920 /* Adjust each field; since this is a union, there are no base
3921 classes. Also no static membes. Also, no need for recursion as
3922 the members of this union if themeselves structs or unions, have
3923 the correct bitoffsets; if an anonymous union is a member of this
3924 anonymous union, the code in hpread_read_struct_type() will
3927 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
3928 TYPE_FIELD_BITPOS (type
, i
) -= bits
;
3931 /* Because of quirks in HP compilers' treatment of anonymous unions inside
3932 classes, we have to chase through a chain of threaded FIELD entries.
3933 If we encounter an anonymous union in the chain, we must recursively skip over
3936 This function does a "next" in the chain of FIELD entries, but transparently
3937 skips over anonymous unions' fields (recursively).
3939 Inputs are the number of times to do "next" at the top level, the dnttpointer
3940 (FIELD) and entry pointer (FIELDP) for the dntt record corresponding to it,
3941 and the ubiquitous objfile parameter. (Note: FIELDP is a **.) Return value
3942 is a dnttpointer for the new field after all the skipped ones */
3945 hpread_get_next_skip_over_anon_unions (int skip_fields
, dnttpointer field
,
3946 union dnttentry
**fieldp
,
3947 struct objfile
*objfile
)
3949 struct type
*anon_type
;
3954 for (i
= 0; i
< skip_fields
; i
++)
3956 /* Get type of item we're looking at now; recursively processes the types
3957 of these intermediate items we skip over, so they aren't lost. */
3958 anon_type
= hpread_type_lookup ((*fieldp
)->dfield
.type
, objfile
);
3959 anon_type
= CHECK_TYPEDEF (anon_type
);
3960 bitoffset
= (*fieldp
)->dfield
.bitoffset
;
3961 name
= VT (objfile
) + (*fieldp
)->dfield
.name
;
3962 /* First skip over one item to avoid stack death on recursion */
3963 field
= (*fieldp
)->dfield
.nextfield
;
3964 *fieldp
= hpread_get_lntt (field
.dnttp
.index
, objfile
);
3965 /* Do we have another anonymous union? If so, adjust the bitoffsets
3966 of its members and skip over its members. */
3967 if ((TYPE_CODE (anon_type
) == TYPE_CODE_UNION
) &&
3968 (!name
|| STREQ (name
, "")))
3970 hpread_adjust_bitoffsets (anon_type
, bitoffset
);
3971 field
= hpread_get_next_skip_over_anon_unions (TYPE_NFIELDS (anon_type
), field
, fieldp
, objfile
);