1 /* Read hp debug symbols and convert to internal format, for GDB.
2 Copyright 1993, 1996 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
21 Written by the Center for Software Science at the University of Utah
22 and by Cygnus Support. */
24 /* Common include for hp-symtab-read.c and hp-psymtab-read.c.
25 * Note this has nested includes for a bunch of stuff.
32 #include "complaints.h"
37 static struct complaint hpread_unhandled_end_common_complaint
=
39 "unhandled symbol in hp-symtab-read.c: DNTT_TYPE_COMMON/DNTT_TYPE_END.\n", 0, 0
42 static struct complaint hpread_unhandled_type_complaint
=
44 "hpread_type_translate: unhandled type code.", 0, 0
47 static struct complaint hpread_struct_complaint
=
49 "hpread_read_struct_type: expected SVAR type...", 0, 0
52 static struct complaint hpread_array_complaint
=
54 "error in hpread_array_type.", 0, 0
57 static struct complaint hpread_type_lookup_complaint
=
59 "error in hpread_type_lookup().", 0, 0
63 static struct complaint hpread_unexpected_end_complaint
=
65 "internal error in hp-symtab-read.c: Unexpected DNTT_TYPE_END kind.", 0, 0
68 static struct complaint hpread_tagdef_complaint
=
70 "error processing class tagdef", 0, 0
73 static struct complaint hpread_unhandled_common_complaint
=
75 "unhandled symbol in hp-symtab-read.c: DNTT_TYPE_COMMON.", 0, 0
78 static struct complaint hpread_unhandled_blockdata_complaint
=
80 "unhandled symbol in hp-symtab-read.c: DNTT_TYPE_BLOCKDATA.", 0, 0
84 /* Forward procedure declarations */
86 static unsigned long hpread_get_scope_start (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 (index
, objfile
)
174 struct objfile
*objfile
;
176 union sltentry
*sl_bufp
;
178 sl_bufp
= hpread_get_slt (index
, objfile
);
179 return sl_bufp
->sspec
.backptr
.dnttp
.index
;
182 /* Get the source line number the the line identified by INDEX. */
185 hpread_get_line (index
, objfile
)
187 struct objfile
*objfile
;
189 union sltentry
*sl_bufp
;
191 sl_bufp
= hpread_get_slt (index
, objfile
);
192 return sl_bufp
->snorm
.line
;
195 /* Find the code address associated with a given sltpointer */
198 hpread_get_location (index
, objfile
)
200 struct objfile
*objfile
;
202 union sltentry
*sl_bufp
;
205 /* code location of special sltentrys is determined from context */
206 sl_bufp
= hpread_get_slt (index
, objfile
);
208 if (sl_bufp
->snorm
.sltdesc
== SLT_END
)
210 /* find previous normal sltentry and get address */
211 for (i
= 0; ((sl_bufp
->snorm
.sltdesc
!= SLT_NORMAL
) &&
212 (sl_bufp
->snorm
.sltdesc
!= SLT_NORMAL_OFFSET
) &&
213 (sl_bufp
->snorm
.sltdesc
!= SLT_EXIT
)); i
++)
214 sl_bufp
= hpread_get_slt (index
- i
, objfile
);
215 if (sl_bufp
->snorm
.sltdesc
== SLT_NORMAL_OFFSET
)
216 return sl_bufp
->snormoff
.address
;
218 return sl_bufp
->snorm
.address
;
221 /* find next normal sltentry and get address */
222 for (i
= 0; ((sl_bufp
->snorm
.sltdesc
!= SLT_NORMAL
) &&
223 (sl_bufp
->snorm
.sltdesc
!= SLT_NORMAL_OFFSET
) &&
224 (sl_bufp
->snorm
.sltdesc
!= SLT_EXIT
)); i
++)
225 sl_bufp
= hpread_get_slt (index
+ i
, objfile
);
226 if (sl_bufp
->snorm
.sltdesc
== SLT_NORMAL_OFFSET
)
227 return sl_bufp
->snormoff
.address
;
229 return sl_bufp
->snorm
.address
;
233 /* Return 1 if an HP debug symbol of type KIND has a name associated with
234 * it, else return 0. (This function is not currently used, but I'll
235 * leave it here in case it proves useful later on. - RT).
239 hpread_has_name (kind
)
240 enum dntt_entry_type kind
;
244 case DNTT_TYPE_SRCFILE
:
245 case DNTT_TYPE_MODULE
:
246 case DNTT_TYPE_FUNCTION
:
247 case DNTT_TYPE_DOC_FUNCTION
:
248 case DNTT_TYPE_ENTRY
:
249 case DNTT_TYPE_IMPORT
:
250 case DNTT_TYPE_LABEL
:
251 case DNTT_TYPE_FPARAM
:
254 case DNTT_TYPE_CONST
:
255 case DNTT_TYPE_TYPEDEF
:
256 case DNTT_TYPE_TAGDEF
:
257 case DNTT_TYPE_MEMENUM
:
258 case DNTT_TYPE_FIELD
:
260 case DNTT_TYPE_BLOCKDATA
:
261 case DNTT_TYPE_MEMFUNC
:
262 case DNTT_TYPE_DOC_MEMFUNC
:
265 case DNTT_TYPE_BEGIN
:
267 case DNTT_TYPE_POINTER
:
270 case DNTT_TYPE_ARRAY
:
271 case DNTT_TYPE_STRUCT
:
272 case DNTT_TYPE_UNION
:
273 case DNTT_TYPE_VARIANT
:
275 case DNTT_TYPE_FUNCTYPE
:
276 case DNTT_TYPE_SUBRANGE
:
278 case DNTT_TYPE_COMMON
:
279 case DNTT_TYPE_COBSTRUCT
:
281 case DNTT_TYPE_MACRO
:
282 case DNTT_TYPE_CLASS_SCOPE
:
283 case DNTT_TYPE_REFERENCE
:
284 case DNTT_TYPE_PTRMEM
:
285 case DNTT_TYPE_PTRMEMFUNC
:
286 case DNTT_TYPE_CLASS
:
287 case DNTT_TYPE_GENFIELD
:
288 case DNTT_TYPE_VFUNC
:
289 case DNTT_TYPE_MEMACCESS
:
290 case DNTT_TYPE_INHERITANCE
:
291 case DNTT_TYPE_FRIEND_CLASS
:
292 case DNTT_TYPE_FRIEND_FUNC
:
293 case DNTT_TYPE_MODIFIER
:
294 case DNTT_TYPE_OBJECT_ID
:
295 case DNTT_TYPE_TEMPLATE
:
296 case DNTT_TYPE_TEMPLATE_ARG
:
297 case DNTT_TYPE_FUNC_TEMPLATE
:
299 /* DNTT_TYPE_DYN_ARRAY_DESC ? */
300 /* DNTT_TYPE_DESC_SUBRANGE ? */
301 /* DNTT_TYPE_BEGIN_EXT ? */
302 /* DNTT_TYPE_INLN ? */
303 /* DNTT_TYPE_INLN_LIST ? */
304 /* DNTT_TYPE_ALIAS ? */
310 /* Do the dirty work of reading in the full symbol from a partial symbol
314 hpread_psymtab_to_symtab_1 (pst
)
315 struct partial_symtab
*pst
;
317 struct cleanup
*old_chain
;
320 /* Get out quick if passed junk. */
324 /* Complain if we've already read in this symbol table. */
327 fprintf (stderr
, "Psymtab for %s already read in. Shouldn't happen.\n",
332 /* Read in all partial symtabs on which this one is dependent */
333 for (i
= 0; i
< pst
->number_of_dependencies
; i
++)
334 if (!pst
->dependencies
[i
]->readin
)
336 /* Inform about additional files that need to be read in. */
339 fputs_filtered (" ", gdb_stdout
);
341 fputs_filtered ("and ", gdb_stdout
);
343 printf_filtered ("%s...", pst
->dependencies
[i
]->filename
);
344 wrap_here (""); /* Flush output */
345 gdb_flush (gdb_stdout
);
347 hpread_psymtab_to_symtab_1 (pst
->dependencies
[i
]);
350 /* If it's real... */
353 /* Init stuff necessary for reading in symbols */
355 old_chain
= make_cleanup (really_free_pendings
, 0);
358 hpread_expand_symtab (pst
->objfile
, LDSYMOFF (pst
), LDSYMLEN (pst
),
359 pst
->textlow
, pst
->texthigh
- pst
->textlow
,
360 pst
->section_offsets
, pst
->filename
);
361 sort_symtab_syms (pst
->symtab
);
363 do_cleanups (old_chain
);
369 /* Read in all of the symbols for a given psymtab for real.
370 Be verbose about it if the user wants that. */
373 hpread_psymtab_to_symtab (pst
)
374 struct partial_symtab
*pst
;
376 /* Get out quick if given junk. */
383 fprintf (stderr
, "Psymtab for %s already read in. Shouldn't happen.\n",
388 /* elz: setting the flag to indicate that the code of the target
389 was compiled using an HP compiler (aCC, cc)
390 the processing_acc_compilation variable is declared in the
391 file buildsym.h, the HP_COMPILED_TARGET is defined to be equal
392 to 3 in the file tm_hppa.h */
394 processing_gcc_compilation
= 0;
396 if (LDSYMLEN (pst
) || pst
->number_of_dependencies
)
398 /* Print the message now, before reading the string table,
399 to avoid disconcerting pauses. */
402 printf_filtered ("Reading in symbols for %s...", pst
->filename
);
403 gdb_flush (gdb_stdout
);
406 hpread_psymtab_to_symtab_1 (pst
);
408 /* Match with global symbols. This only needs to be done once,
409 after all of the symtabs and dependencies have been read in. */
410 scan_file_globals (pst
->objfile
);
412 /* Finish up the debug error message. */
414 printf_filtered ("done.\n");
418 /* Read in a defined section of a specific object file's symbols.
420 DESC is the file descriptor for the file, positioned at the
421 beginning of the symtab
422 SYM_OFFSET is the offset within the file of
423 the beginning of the symbols we want to read
424 SYM_SIZE is the size of the symbol info to read in.
425 TEXT_OFFSET is the beginning of the text segment we are reading symbols for
426 TEXT_SIZE is the size of the text segment read in.
427 SECTION_OFFSETS are the relocation offsets which get added to each symbol. */
429 static struct symtab
*
430 hpread_expand_symtab (objfile
, sym_offset
, sym_size
, text_offset
, text_size
,
431 section_offsets
, filename
)
432 struct objfile
*objfile
;
435 CORE_ADDR text_offset
;
437 struct section_offsets
*section_offsets
;
441 union dnttentry
*dn_bufp
;
443 int at_module_boundary
= 0;
444 /* 1 => at end, -1 => at beginning */
446 int sym_index
= sym_offset
/ sizeof (struct dntt_type_block
);
448 current_objfile
= objfile
;
451 last_source_file
= 0;
453 /* Demangling style -- if EDG style already set, don't change it,
454 as HP style causes some problems with the KAI EDG compiler */
455 if (current_demangling_style
!= edg_demangling
)
457 /* Otherwise, ensure that we are using HP style demangling */
458 set_demangling_style (HP_DEMANGLING_STYLE_STRING
);
461 dn_bufp
= hpread_get_lntt (sym_index
, objfile
);
462 if (!((dn_bufp
->dblock
.kind
== (unsigned char) DNTT_TYPE_SRCFILE
) ||
463 (dn_bufp
->dblock
.kind
== (unsigned char) DNTT_TYPE_MODULE
)))
465 start_symtab ("globals", NULL
, 0);
466 record_debugformat ("HP");
469 /* The psymtab builder (hp-psymtab-read.c) is the one that
470 * determined the "sym_size" argument (i.e. how many DNTT symbols
471 * are in this symtab), which we use to compute "max_symnum"
472 * (point in DNTT to which we read).
474 * Perhaps this should be changed so that
475 * process_one_debug_symbol() "knows" when
476 * to stop reading (based on reading from the MODULE to the matching
477 * END), and take out this reliance on a #-syms being passed in...
478 * (I'm worried about the reliability of this number). But I'll
479 * leave it as-is, for now. - RT
481 * The change above has been made. I've left the "for" loop control
482 * in to prepare for backing this out again. -JB
484 max_symnum
= sym_size
/ sizeof (struct dntt_type_block
);
485 /* No reason to multiply on pst side and divide on sym side... FIXME */
487 /* Read in and process each debug symbol within the specified range.
493 QUIT
; /* Allow this to be interruptable */
494 dn_bufp
= hpread_get_lntt (sym_index
+ symnum
, objfile
);
496 if (dn_bufp
->dblock
.extension
)
499 /* Yow! We call SET_NAMESTRING on things without names! */
500 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
502 hpread_process_one_debug_symbol (dn_bufp
, namestring
, section_offsets
,
503 objfile
, text_offset
, text_size
,
504 filename
, symnum
+ sym_index
,
508 /* OLD COMMENTS: This routine is only called for psts. All psts
509 * correspond to MODULES. If we ever do lazy-reading of globals
510 * from the LNTT, then there will be a pst which ends when the
511 * LNTT ends, and not at an END MODULE entry. Then we'll have
512 * to re-visit this break.
514 if( at_end_of_module )
519 /* We no longer break out of the loop when we reach the end of a
520 module. The reason is that with CTTI, the compiler can generate
521 function symbols (for template function instantiations) which are not
522 in any module; typically they show up beyond a module's end, and
523 before the next module's start. We include them in the current
524 module. However, we still don't trust the MAX_SYMNUM value from
525 the psymtab, so we break out if we enter a new module. */
527 if (at_module_boundary
== -1)
531 current_objfile
= NULL
;
532 hp_som_som_object_present
= 1; /* Indicate we've processed an HP SOM SOM file */
534 return end_symtab (text_offset
+ text_size
, objfile
, 0);
540 /* Convert basic types from HP debug format into GDB internal format. */
543 hpread_type_translate (typep
)
546 if (!typep
.dntti
.immediate
)
548 error ("error in hpread_type_translate\n.");
552 switch (typep
.dntti
.type
)
554 case HP_TYPE_BOOLEAN
:
555 case HP_TYPE_BOOLEAN_S300_COMPAT
:
556 case HP_TYPE_BOOLEAN_VAX_COMPAT
:
558 case HP_TYPE_CHAR
: /* C signed char, C++ plain char */
560 case HP_TYPE_WIDE_CHAR
:
563 if (typep
.dntti
.bitlength
<= 8)
564 return FT_SIGNED_CHAR
; /* C++ signed char */
565 if (typep
.dntti
.bitlength
<= 16)
567 if (typep
.dntti
.bitlength
<= 32)
571 if (typep
.dntti
.bitlength
<= 8)
572 return FT_SIGNED_CHAR
; /* C++ signed char. */
574 case HP_TYPE_UNSIGNED_LONG
:
575 if (typep
.dntti
.bitlength
<= 8)
576 return FT_UNSIGNED_CHAR
; /* C/C++ unsigned char */
577 if (typep
.dntti
.bitlength
<= 16)
578 return FT_UNSIGNED_SHORT
;
579 if (typep
.dntti
.bitlength
<= 32)
580 return FT_UNSIGNED_LONG
;
581 return FT_UNSIGNED_LONG_LONG
;
582 case HP_TYPE_UNSIGNED_INT
:
583 if (typep
.dntti
.bitlength
<= 8)
584 return FT_UNSIGNED_CHAR
;
585 if (typep
.dntti
.bitlength
<= 16)
586 return FT_UNSIGNED_SHORT
;
587 if (typep
.dntti
.bitlength
<= 32)
588 return FT_UNSIGNED_INTEGER
;
589 return FT_UNSIGNED_LONG_LONG
;
591 case HP_TYPE_REAL_3000
:
593 if (typep
.dntti
.bitlength
== 64)
594 return FT_DBL_PREC_FLOAT
;
595 if (typep
.dntti
.bitlength
== 128)
596 return FT_EXT_PREC_FLOAT
;
598 case HP_TYPE_COMPLEX
:
599 case HP_TYPE_COMPLEXS3000
:
600 if (typep
.dntti
.bitlength
== 128)
601 return FT_DBL_PREC_COMPLEX
;
602 if (typep
.dntti
.bitlength
== 192)
603 return FT_EXT_PREC_COMPLEX
;
607 case HP_TYPE_STRING200
:
608 case HP_TYPE_LONGSTRING200
:
609 case HP_TYPE_FTN_STRING_SPEC
:
610 case HP_TYPE_MOD_STRING_SPEC
:
611 case HP_TYPE_MOD_STRING_3000
:
612 case HP_TYPE_FTN_STRING_S300_COMPAT
:
613 case HP_TYPE_FTN_STRING_VAX_COMPAT
:
615 case HP_TYPE_TEMPLATE_ARG
:
616 return FT_TEMPLATE_ARG
;
619 case HP_TYPE_PACKED_DECIMAL
:
620 case HP_TYPE_ANYPOINTER
:
621 case HP_TYPE_GLOBAL_ANYPOINTER
:
622 case HP_TYPE_LOCAL_ANYPOINTER
:
624 warning ("hpread_type_translate: unhandled type code.\n");
629 /* Given a position in the DNTT, return a pointer to the
630 * already-built "struct type" (if any), for the type defined
634 static struct type
**
635 hpread_lookup_type (hp_type
, objfile
)
637 struct objfile
*objfile
;
640 int index
= hp_type
.dnttp
.index
;
641 int size_changed
= 0;
643 /* The immediate flag indicates this doesn't actually point to
646 if (hp_type
.dntti
.immediate
)
649 /* For each objfile, we maintain a "type vector".
650 * This an array of "struct type *"'s with one pointer per DNTT index.
651 * Given a DNTT index, we look in this array to see if we have
652 * already processed this DNTT and if it is a type definition.
653 * If so, then we can locate a pointer to the already-built
654 * "struct type", and not build it again.
656 * The need for this arises because our DNTT-walking code wanders
657 * around. In particular, it will encounter the same type multiple
658 * times (once for each object of that type). We don't want to
659 * built multiple "struct type"'s for the same thing.
661 * Having said this, I should point out that this type-vector is
662 * an expensive way to keep track of this. If most DNTT entries are
663 * 3 words, the type-vector will be 1/3 the size of the DNTT itself.
664 * Alternative solutions:
665 * - Keep a compressed or hashed table. Less memory, but more expensive
666 * to search and update.
667 * - (Suggested by JB): Overwrite the DNTT entry itself
668 * with the info. Create a new type code "ALREADY_BUILT", and modify
669 * the DNTT to have that type code and point to the already-built entry.
673 if (index
< LNTT_SYMCOUNT (objfile
))
675 if (index
>= TYPE_VECTOR_LENGTH (objfile
))
677 old_len
= TYPE_VECTOR_LENGTH (objfile
);
679 /* See if we need to allocate a type-vector. */
682 TYPE_VECTOR_LENGTH (objfile
) = LNTT_SYMCOUNT (objfile
) + GNTT_SYMCOUNT (objfile
);
683 TYPE_VECTOR (objfile
) = (struct type
**)
684 xmmalloc (objfile
->md
, TYPE_VECTOR_LENGTH (objfile
) * sizeof (struct type
*));
685 memset (&TYPE_VECTOR (objfile
)[old_len
], 0,
686 (TYPE_VECTOR_LENGTH (objfile
) - old_len
) *
687 sizeof (struct type
*));
690 /* See if we need to resize type-vector. With my change to
691 * initially allocate a correct-size type-vector, this code
692 * should no longer trigger.
694 while (index
>= TYPE_VECTOR_LENGTH (objfile
))
696 TYPE_VECTOR_LENGTH (objfile
) *= 2;
701 TYPE_VECTOR (objfile
) = (struct type
**)
702 xmrealloc (objfile
->md
,
703 (char *) TYPE_VECTOR (objfile
),
704 (TYPE_VECTOR_LENGTH (objfile
) * sizeof (struct type
*)));
706 memset (&TYPE_VECTOR (objfile
)[old_len
], 0,
707 (TYPE_VECTOR_LENGTH (objfile
) - old_len
) *
708 sizeof (struct type
*));
712 return &TYPE_VECTOR (objfile
)[index
];
718 /* Possibly allocate a GDB internal type so we can internalize HP_TYPE.
719 Note we'll just return the address of a GDB internal type if we already
720 have it lying around. */
723 hpread_alloc_type (hp_type
, objfile
)
725 struct objfile
*objfile
;
727 struct type
**type_addr
;
729 type_addr
= hpread_lookup_type (hp_type
, objfile
);
732 *type_addr
= alloc_type (objfile
);
734 /* A hack - if we really are a C++ class symbol, then this default
735 * will get overriden later on.
737 TYPE_CPLUS_SPECIFIC (*type_addr
)
738 = (struct cplus_struct_type
*) &cplus_struct_default
;
744 /* Read a native enumerated type and return it in GDB internal form. */
747 hpread_read_enum_type (hp_type
, dn_bufp
, objfile
)
749 union dnttentry
*dn_bufp
;
750 struct objfile
*objfile
;
753 struct pending
**symlist
, *osyms
, *syms
;
754 struct pending
*local_list
= NULL
;
755 int o_nsyms
, nsyms
= 0;
757 union dnttentry
*memp
;
762 /* Allocate a GDB type. If we've already read in this enum type,
763 * it'll return the already built GDB type, so stop here.
764 * (Note: I added this check, to conform with what's done for
765 * struct, union, class.
766 * I assume this is OK. - RT)
768 type
= hpread_alloc_type (hp_type
, objfile
);
769 if (TYPE_CODE (type
) == TYPE_CODE_ENUM
)
772 /* HP C supports "sized enums", where a specifier such as "short" or
773 "char" can be used to get enums of different sizes. So don't assume
774 an enum is always 4 bytes long. pai/1997-08-21 */
775 TYPE_LENGTH (type
) = dn_bufp
->denum
.bitlength
/ 8;
777 symlist
= &file_symbols
;
779 o_nsyms
= osyms
? osyms
->nsyms
: 0;
781 /* Get a name for each member and add it to our list of members.
782 * The list of "mem" SOM records we are walking should all be
783 * SOM type DNTT_TYPE_MEMENUM (not checked).
785 mem
= dn_bufp
->denum
.firstmem
;
786 while (mem
.word
&& mem
.word
!= DNTTNIL
)
788 memp
= hpread_get_lntt (mem
.dnttp
.index
, objfile
);
790 name
= VT (objfile
) + memp
->dmember
.name
;
791 sym
= (struct symbol
*) obstack_alloc (&objfile
->symbol_obstack
,
792 sizeof (struct symbol
));
793 memset (sym
, 0, sizeof (struct symbol
));
794 SYMBOL_NAME (sym
) = obsavestring (name
, strlen (name
),
795 &objfile
->symbol_obstack
);
796 SYMBOL_CLASS (sym
) = LOC_CONST
;
797 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
798 SYMBOL_VALUE (sym
) = memp
->dmember
.value
;
799 add_symbol_to_list (sym
, symlist
);
801 mem
= memp
->dmember
.nextmem
;
804 /* Now that we know more about the enum, fill in more info. */
805 TYPE_CODE (type
) = TYPE_CODE_ENUM
;
806 TYPE_FLAGS (type
) &= ~TYPE_FLAG_STUB
;
807 TYPE_NFIELDS (type
) = nsyms
;
808 TYPE_FIELDS (type
) = (struct field
*)
809 obstack_alloc (&objfile
->type_obstack
, sizeof (struct field
) * nsyms
);
811 /* Find the symbols for the members and put them into the type.
812 The symbols can be found in the symlist that we put them on
813 to cause them to be defined. osyms contains the old value
814 of that symlist; everything up to there was defined by us.
816 Note that we preserve the order of the enum constants, so
817 that in something like "enum {FOO, LAST_THING=FOO}" we print
818 FOO, not LAST_THING. */
819 for (syms
= *symlist
, n
= 0; syms
; syms
= syms
->next
)
824 for (; j
< syms
->nsyms
; j
++, n
++)
826 struct symbol
*xsym
= syms
->symbol
[j
];
827 SYMBOL_TYPE (xsym
) = type
;
828 TYPE_FIELD_NAME (type
, n
) = SYMBOL_NAME (xsym
);
829 TYPE_FIELD_BITPOS (type
, n
) = SYMBOL_VALUE (xsym
);
830 TYPE_FIELD_BITSIZE (type
, n
) = 0;
839 /* Read and internalize a native function debug symbol. */
842 hpread_read_function_type (hp_type
, dn_bufp
, objfile
, newblock
)
844 union dnttentry
*dn_bufp
;
845 struct objfile
*objfile
;
848 struct type
*type
, *type1
;
849 struct pending
*syms
;
850 struct pending
*local_list
= NULL
;
853 union dnttentry
*paramp
;
859 /* See if we've already read in this type. */
860 type
= hpread_alloc_type (hp_type
, objfile
);
861 if (TYPE_CODE (type
) == TYPE_CODE_FUNC
)
863 record_args
= 0; /* already read in, don't modify type */
867 /* Nope, so read it in and store it away. */
868 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_FUNCTION
||
869 dn_bufp
->dblock
.kind
== DNTT_TYPE_MEMFUNC
)
870 type1
= lookup_function_type (hpread_type_lookup (dn_bufp
->dfunc
.retval
,
872 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_FUNCTYPE
)
873 type1
= lookup_function_type (hpread_type_lookup (dn_bufp
->dfunctype
.retval
,
875 else /* expect DNTT_TYPE_FUNC_TEMPLATE */
876 type1
= lookup_function_type (hpread_type_lookup (dn_bufp
->dfunc_template
.retval
,
878 memcpy ((char *) type
, (char *) type1
, sizeof (struct type
));
880 /* Mark it -- in the middle of processing */
881 TYPE_FLAGS (type
) |= TYPE_FLAG_INCOMPLETE
;
884 /* Now examine each parameter noting its type, location, and a
885 wealth of other information. */
886 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_FUNCTION
||
887 dn_bufp
->dblock
.kind
== DNTT_TYPE_MEMFUNC
)
888 param
= dn_bufp
->dfunc
.firstparam
;
889 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_FUNCTYPE
)
890 param
= dn_bufp
->dfunctype
.firstparam
;
891 else /* expect DNTT_TYPE_FUNC_TEMPLATE */
892 param
= dn_bufp
->dfunc_template
.firstparam
;
893 while (param
.word
&& param
.word
!= DNTTNIL
)
895 paramp
= hpread_get_lntt (param
.dnttp
.index
, objfile
);
897 param
= paramp
->dfparam
.nextparam
;
900 name
= VT (objfile
) + paramp
->dfparam
.name
;
901 sym
= (struct symbol
*) obstack_alloc (&objfile
->symbol_obstack
,
902 sizeof (struct symbol
));
903 (void) memset (sym
, 0, sizeof (struct symbol
));
904 SYMBOL_NAME (sym
) = obsavestring (name
, strlen (name
),
905 &objfile
->symbol_obstack
);
907 /* Figure out where it lives. */
908 if (paramp
->dfparam
.regparam
)
909 SYMBOL_CLASS (sym
) = LOC_REGPARM
;
910 else if (paramp
->dfparam
.indirect
)
911 SYMBOL_CLASS (sym
) = LOC_REF_ARG
;
913 SYMBOL_CLASS (sym
) = LOC_ARG
;
914 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
915 if (paramp
->dfparam
.copyparam
)
917 SYMBOL_VALUE (sym
) = paramp
->dfparam
.location
;
918 #ifdef HPREAD_ADJUST_STACK_ADDRESS
920 += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile
));
922 /* This is likely a pass-by-invisible reference parameter,
923 Hack on the symbol class to make GDB happy. */
924 /* ??rehrauer: This appears to be broken w/r/t to passing
925 C values of type float and struct. Perhaps this ought
926 to be highighted as a special case, but for now, just
927 allowing these to be LOC_ARGs seems to work fine.
930 SYMBOL_CLASS (sym
) = LOC_REGPARM_ADDR
;
934 SYMBOL_VALUE (sym
) = paramp
->dfparam
.location
;
937 SYMBOL_TYPE (sym
) = hpread_type_lookup (paramp
->dfparam
.type
, objfile
);
938 /* Add it to the symbol list. */
939 /* Note 1 (RT) At the moment, add_symbol_to_list() is also being
940 * called on FPARAM symbols from the process_one_debug_symbol()
941 * level... so parameters are getting added twice! (this shows
942 * up in the symbol dump you get from "maint print symbols ...").
943 * Note 2 (RT) I took out the processing of FPARAM from the
944 * process_one_debug_symbol() level, so at the moment parameters are only
945 * being processed here. This seems to have no ill effect.
947 /* Note 3 (pai/1997-08-11) I removed the add_symbol_to_list() which put
948 each fparam on the local_symbols list from here. Now we use the
949 local_list to which fparams are added below, and set the param_symbols
950 global to point to that at the end of this routine. */
951 /* elz: I added this new list of symbols which is local to the function.
952 this list is the one which is actually used to build the type for the
953 function rather than the gloabal list pointed to by symlist.
954 Using a global list to keep track of the parameters is wrong, because
955 this function is called recursively if one parameter happend to be
956 a function itself with more parameters in it. Adding parameters to the
957 same global symbol list would not work!
958 Actually it did work in case of cc compiled programs where you do
959 not check the parameter lists of the arguments. */
960 add_symbol_to_list (sym
, &local_list
);
964 /* If type was read in earlier, don't bother with modifying
969 /* Note how many parameters we found. */
970 TYPE_NFIELDS (type
) = nsyms
;
971 TYPE_FIELDS (type
) = (struct field
*)
972 obstack_alloc (&objfile
->type_obstack
,
973 sizeof (struct field
) * nsyms
);
975 /* Find the symbols for the parameters and
976 use them to fill parameter-type information into the function-type.
977 The parameter symbols can be found in the local_list that we just put them on. */
978 /* Note that we preserve the order of the parameters, so
979 that in something like "enum {FOO, LAST_THING=FOO}" we print
980 FOO, not LAST_THING. */
982 /* get the parameters types from the local list not the global list
983 so that the type can be correctly constructed for functions which
984 have function as parameters */
985 for (syms
= local_list
, n
= 0; syms
; syms
= syms
->next
)
988 for (j
= 0; j
< syms
->nsyms
; j
++, n
++)
990 struct symbol
*xsym
= syms
->symbol
[j
];
991 TYPE_FIELD_NAME (type
, n
) = SYMBOL_NAME (xsym
);
992 TYPE_FIELD_TYPE (type
, n
) = SYMBOL_TYPE (xsym
);
993 TYPE_FIELD_BITPOS (type
, n
) = n
;
994 TYPE_FIELD_BITSIZE (type
, n
) = 0;
997 /* Mark it as having been processed */
998 TYPE_FLAGS (type
) &= ~(TYPE_FLAG_INCOMPLETE
);
1000 /* Check whether we need to fix-up a class type with this function's type */
1001 if (fixup_class
&& (fixup_method
== type
))
1003 fixup_class_method_type (fixup_class
, fixup_method
, objfile
);
1005 fixup_method
= NULL
;
1008 /* Set the param list of this level of the context stack
1009 to our local list. Do this only if this function was
1010 called for creating a new block, and not if it was called
1011 simply to get the function type. This prevents recursive
1012 invocations from trashing param_symbols. */
1015 param_symbols
= local_list
;
1021 /* Read and internalize a native DOC function debug symbol. */
1022 /* This is almost identical to hpread_read_function_type(), except
1023 * for references to dn_bufp->ddocfunc instead of db_bufp->dfunc.
1024 * Since debug information for DOC functions is more likely to be
1025 * volatile, please leave it this way.
1027 static struct type
*
1028 hpread_read_doc_function_type (hp_type
, dn_bufp
, objfile
, newblock
)
1029 dnttpointer hp_type
;
1030 union dnttentry
*dn_bufp
;
1031 struct objfile
*objfile
;
1034 struct type
*type
, *type1
;
1035 struct pending
*syms
;
1036 struct pending
*local_list
= NULL
;
1039 union dnttentry
*paramp
;
1043 int record_args
= 1;
1045 /* See if we've already read in this type. */
1046 type
= hpread_alloc_type (hp_type
, objfile
);
1047 if (TYPE_CODE (type
) == TYPE_CODE_FUNC
)
1049 record_args
= 0; /* already read in, don't modify type */
1053 /* Nope, so read it in and store it away. */
1054 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_DOC_FUNCTION
||
1055 dn_bufp
->dblock
.kind
== DNTT_TYPE_DOC_MEMFUNC
)
1056 type1
= lookup_function_type (hpread_type_lookup (dn_bufp
->ddocfunc
.retval
,
1058 memcpy ((char *) type
, (char *) type1
, sizeof (struct type
));
1060 /* Mark it -- in the middle of processing */
1061 TYPE_FLAGS (type
) |= TYPE_FLAG_INCOMPLETE
;
1064 /* Now examine each parameter noting its type, location, and a
1065 wealth of other information. */
1066 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_DOC_FUNCTION
||
1067 dn_bufp
->dblock
.kind
== DNTT_TYPE_DOC_MEMFUNC
)
1068 param
= dn_bufp
->ddocfunc
.firstparam
;
1069 while (param
.word
&& param
.word
!= DNTTNIL
)
1071 paramp
= hpread_get_lntt (param
.dnttp
.index
, objfile
);
1073 param
= paramp
->dfparam
.nextparam
;
1076 name
= VT (objfile
) + paramp
->dfparam
.name
;
1077 sym
= (struct symbol
*) obstack_alloc (&objfile
->symbol_obstack
,
1078 sizeof (struct symbol
));
1079 (void) memset (sym
, 0, sizeof (struct symbol
));
1080 SYMBOL_NAME (sym
) = name
;
1082 /* Figure out where it lives. */
1083 if (paramp
->dfparam
.regparam
)
1084 SYMBOL_CLASS (sym
) = LOC_REGPARM
;
1085 else if (paramp
->dfparam
.indirect
)
1086 SYMBOL_CLASS (sym
) = LOC_REF_ARG
;
1088 SYMBOL_CLASS (sym
) = LOC_ARG
;
1089 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1090 if (paramp
->dfparam
.copyparam
)
1092 SYMBOL_VALUE (sym
) = paramp
->dfparam
.location
;
1093 #ifdef HPREAD_ADJUST_STACK_ADDRESS
1095 += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile
));
1097 /* This is likely a pass-by-invisible reference parameter,
1098 Hack on the symbol class to make GDB happy. */
1099 /* ??rehrauer: This appears to be broken w/r/t to passing
1100 C values of type float and struct. Perhaps this ought
1101 to be highighted as a special case, but for now, just
1102 allowing these to be LOC_ARGs seems to work fine.
1105 SYMBOL_CLASS (sym
) = LOC_REGPARM_ADDR
;
1109 SYMBOL_VALUE (sym
) = paramp
->dfparam
.location
;
1112 SYMBOL_TYPE (sym
) = hpread_type_lookup (paramp
->dfparam
.type
, objfile
);
1113 /* Add it to the symbol list. */
1114 /* Note 1 (RT) At the moment, add_symbol_to_list() is also being
1115 * called on FPARAM symbols from the process_one_debug_symbol()
1116 * level... so parameters are getting added twice! (this shows
1117 * up in the symbol dump you get from "maint print symbols ...").
1118 * Note 2 (RT) I took out the processing of FPARAM from the
1119 * process_one_debug_symbol() level, so at the moment parameters are only
1120 * being processed here. This seems to have no ill effect.
1122 /* Note 3 (pai/1997-08-11) I removed the add_symbol_to_list() which put
1123 each fparam on the local_symbols list from here. Now we use the
1124 local_list to which fparams are added below, and set the param_symbols
1125 global to point to that at the end of this routine. */
1127 /* elz: I added this new list of symbols which is local to the function.
1128 this list is the one which is actually used to build the type for the
1129 function rather than the gloabal list pointed to by symlist.
1130 Using a global list to keep track of the parameters is wrong, because
1131 this function is called recursively if one parameter happend to be
1132 a function itself with more parameters in it. Adding parameters to the
1133 same global symbol list would not work!
1134 Actually it did work in case of cc compiled programs where you do not check the
1135 parameter lists of the arguments. */
1136 add_symbol_to_list (sym
, &local_list
);
1139 /* If type was read in earlier, don't bother with modifying
1144 /* Note how many parameters we found. */
1145 TYPE_NFIELDS (type
) = nsyms
;
1146 TYPE_FIELDS (type
) = (struct field
*)
1147 obstack_alloc (&objfile
->type_obstack
,
1148 sizeof (struct field
) * nsyms
);
1150 /* Find the symbols for the parameters and
1151 use them to fill parameter-type information into the function-type.
1152 The parameter symbols can be found in the local_list that we just put them on. */
1153 /* Note that we preserve the order of the parameters, so
1154 that in something like "enum {FOO, LAST_THING=FOO}" we print
1155 FOO, not LAST_THING. */
1157 /* get the parameters types from the local list not the global list
1158 so that the type can be correctly constructed for functions which
1159 have function as parameters
1161 for (syms
= local_list
, n
= 0; syms
; syms
= syms
->next
)
1164 for (j
= 0; j
< syms
->nsyms
; j
++, n
++)
1166 struct symbol
*xsym
= syms
->symbol
[j
];
1167 TYPE_FIELD_NAME (type
, n
) = SYMBOL_NAME (xsym
);
1168 TYPE_FIELD_TYPE (type
, n
) = SYMBOL_TYPE (xsym
);
1169 TYPE_FIELD_BITPOS (type
, n
) = n
;
1170 TYPE_FIELD_BITSIZE (type
, n
) = 0;
1174 /* Mark it as having been processed */
1175 TYPE_FLAGS (type
) &= ~(TYPE_FLAG_INCOMPLETE
);
1177 /* Check whether we need to fix-up a class type with this function's type */
1178 if (fixup_class
&& (fixup_method
== type
))
1180 fixup_class_method_type (fixup_class
, fixup_method
, objfile
);
1182 fixup_method
= NULL
;
1185 /* Set the param list of this level of the context stack
1186 to our local list. Do this only if this function was
1187 called for creating a new block, and not if it was called
1188 simply to get the function type. This prevents recursive
1189 invocations from trashing param_symbols. */
1192 param_symbols
= local_list
;
1199 /* A file-level variable which keeps track of the current-template
1200 * being processed. Set in hpread_read_struct_type() while processing
1201 * a template type. Referred to in hpread_get_nth_templ_arg().
1202 * Yes, this is a kludge, but it arises from the kludge that already
1203 * exists in symtab.h, namely the fact that they encode
1204 * "template argument n" with fundamental type FT_TEMPLATE_ARG and
1205 * bitlength n. This means that deep in processing fundamental types
1206 * I need to ask the question "what template am I in the middle of?".
1207 * The alternative to stuffing a global would be to pass an argument
1208 * down the chain of calls just for this purpose.
1210 * There may be problems handling nested templates... tough.
1212 static struct type
*current_template
= NULL
;
1214 /* Read in and internalize a structure definition.
1215 * This same routine is called for struct, union, and class types.
1216 * Also called for templates, since they build a very similar
1217 * type entry as for class types.
1220 static struct type
*
1221 hpread_read_struct_type (hp_type
, dn_bufp
, objfile
)
1222 dnttpointer hp_type
;
1223 union dnttentry
*dn_bufp
;
1224 struct objfile
*objfile
;
1226 /* The data members get linked together into a list of struct nextfield's */
1229 struct nextfield
*next
;
1231 unsigned char attributes
; /* store visibility and virtuality info */
1232 #define ATTR_VIRTUAL 1
1233 #define ATTR_PRIVATE 2
1234 #define ATTR_PROTECT 3
1238 /* The methods get linked together into a list of struct next_fn_field's */
1239 struct next_fn_field
1241 struct next_fn_field
*next
;
1242 struct fn_fieldlist field
;
1243 struct fn_field fn_field
;
1247 /* The template args get linked together into a list of struct next_template's */
1248 struct next_template
1250 struct next_template
*next
;
1251 struct template_arg arg
;
1254 /* The template instantiations get linked together into a list of these... */
1255 struct next_instantiation
1257 struct next_instantiation
*next
;
1262 struct type
*baseclass
;
1263 struct type
*memtype
;
1264 struct nextfield
*list
= 0, *tmp_list
= 0;
1265 struct next_fn_field
*fn_list
= 0;
1266 struct next_fn_field
*fn_p
;
1267 struct next_template
*t_new
, *t_list
= 0;
1268 struct nextfield
*new;
1269 struct next_fn_field
*fn_new
;
1270 struct next_instantiation
*i_new
, *i_list
= 0;
1271 int n
, nfields
= 0, n_fn_fields
= 0, n_fn_fields_total
= 0;
1272 int n_base_classes
= 0, n_templ_args
= 0;
1273 int ninstantiations
= 0;
1274 dnttpointer field
, fn_field
, parent
;
1275 union dnttentry
*fieldp
, *fn_fieldp
, *parentp
;
1277 int static_member
= 0;
1278 int const_member
= 0;
1279 int volatile_member
= 0;
1280 unsigned long vtbl_offset
;
1281 int need_bitvectors
= 0;
1282 char *method_name
= NULL
;
1283 char *method_alias
= NULL
;
1286 /* Is it something we've already dealt with? */
1287 type
= hpread_alloc_type (hp_type
, objfile
);
1288 if ((TYPE_CODE (type
) == TYPE_CODE_STRUCT
) ||
1289 (TYPE_CODE (type
) == TYPE_CODE_UNION
) ||
1290 (TYPE_CODE (type
) == TYPE_CODE_CLASS
) ||
1291 (TYPE_CODE (type
) == TYPE_CODE_TEMPLATE
))
1294 /* Get the basic type correct. */
1295 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_STRUCT
)
1297 TYPE_CODE (type
) = TYPE_CODE_STRUCT
;
1298 TYPE_LENGTH (type
) = dn_bufp
->dstruct
.bitlength
/ 8;
1300 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_UNION
)
1302 TYPE_CODE (type
) = TYPE_CODE_UNION
;
1303 TYPE_LENGTH (type
) = dn_bufp
->dunion
.bitlength
/ 8;
1305 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_CLASS
)
1307 TYPE_CODE (type
) = TYPE_CODE_CLASS
;
1308 TYPE_LENGTH (type
) = dn_bufp
->dclass
.bitlength
/ 8;
1310 /* Overrides the TYPE_CPLUS_SPECIFIC(type) with allocated memory
1311 * rather than &cplus_struct_default.
1313 allocate_cplus_struct_type (type
);
1315 /* Fill in declared-type.
1316 * (The C++ compiler will emit TYPE_CODE_CLASS
1317 * for all 3 of "class", "struct"
1318 * "union", and we have to look at the "class_decl" field if we
1319 * want to know how it was really declared)
1321 /* (0==class, 1==union, 2==struct) */
1322 TYPE_DECLARED_TYPE (type
) = dn_bufp
->dclass
.class_decl
;
1324 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_TEMPLATE
)
1326 /* Get the basic type correct. */
1327 TYPE_CODE (type
) = TYPE_CODE_TEMPLATE
;
1328 allocate_cplus_struct_type (type
);
1329 TYPE_DECLARED_TYPE (type
) = DECLARED_TYPE_TEMPLATE
;
1335 TYPE_FLAGS (type
) &= ~TYPE_FLAG_STUB
;
1337 /* For classes, read the parent list.
1338 * Question (RT): Do we need to do this for templates also?
1340 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_CLASS
)
1343 /* First read the parent-list (classes from which we derive fields) */
1344 parent
= dn_bufp
->dclass
.parentlist
;
1345 while (parent
.word
&& parent
.word
!= DNTTNIL
)
1347 parentp
= hpread_get_lntt (parent
.dnttp
.index
, objfile
);
1349 /* "parentp" should point to a DNTT_TYPE_INHERITANCE record */
1351 /* Get space to record the next field/data-member. */
1352 new = (struct nextfield
*) alloca (sizeof (struct nextfield
));
1356 FIELD_BITSIZE (list
->field
) = 0;
1358 /* The "classname" field is actually a DNTT pointer to the base class */
1359 baseclass
= hpread_type_lookup (parentp
->dinheritance
.classname
,
1361 FIELD_TYPE (list
->field
) = baseclass
;
1363 list
->field
.name
= type_name_no_tag (FIELD_TYPE (list
->field
));
1365 list
->attributes
= 0;
1367 /* Check for virtuality of base, and set the
1368 * offset of the base subobject within the object.
1369 * (Offset set to -1 for virtual bases (for now).)
1371 if (parentp
->dinheritance
.Virtual
)
1373 B_SET (&(list
->attributes
), ATTR_VIRTUAL
);
1374 parentp
->dinheritance
.offset
= -1;
1377 FIELD_BITPOS (list
->field
) = parentp
->dinheritance
.offset
;
1379 /* Check visibility */
1380 switch (parentp
->dinheritance
.visibility
)
1383 B_SET (&(list
->attributes
), ATTR_PROTECT
);
1386 B_SET (&(list
->attributes
), ATTR_PRIVATE
);
1393 parent
= parentp
->dinheritance
.next
;
1397 /* For templates, read the template argument list.
1398 * This must be done before processing the member list, because
1399 * the member list may refer back to this. E.g.:
1400 * template <class T1, class T2> class q2 {
1405 * We need to read the argument list "T1", "T2" first.
1407 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_TEMPLATE
)
1409 /* Kludge alert: This stuffs a global "current_template" which
1410 * is referred to by hpread_get_nth_templ_arg(). The global
1411 * is cleared at the end of this routine.
1413 current_template
= type
;
1415 /* Read in the argument list */
1416 field
= dn_bufp
->dtemplate
.arglist
;
1417 while (field
.word
&& field
.word
!= DNTTNIL
)
1419 /* Get this template argument */
1420 fieldp
= hpread_get_lntt (field
.dnttp
.index
, objfile
);
1421 if (fieldp
->dblock
.kind
!= DNTT_TYPE_TEMPLATE_ARG
)
1423 warning ("Invalid debug info: Template argument entry is of wrong kind");
1426 /* Bump the count */
1428 /* Allocate and fill in a struct next_template */
1429 t_new
= (struct next_template
*) alloca (sizeof (struct next_template
));
1430 t_new
->next
= t_list
;
1432 t_list
->arg
.name
= VT (objfile
) + fieldp
->dtempl_arg
.name
;
1433 t_list
->arg
.type
= hpread_read_templ_arg_type (field
, fieldp
,
1434 objfile
, t_list
->arg
.name
);
1435 /* Walk to the next template argument */
1436 field
= fieldp
->dtempl_arg
.nextarg
;
1440 TYPE_NTEMPLATE_ARGS (type
) = n_templ_args
;
1442 if (n_templ_args
> 0)
1443 TYPE_TEMPLATE_ARGS (type
) = (struct template_arg
*)
1444 obstack_alloc (&objfile
->type_obstack
, sizeof (struct template_arg
) * n_templ_args
);
1445 for (n
= n_templ_args
; t_list
; t_list
= t_list
->next
)
1448 TYPE_TEMPLATE_ARG (type
, n
) = t_list
->arg
;
1451 /* Next read in and internalize all the fields/members. */
1452 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_STRUCT
)
1453 field
= dn_bufp
->dstruct
.firstfield
;
1454 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_UNION
)
1455 field
= dn_bufp
->dunion
.firstfield
;
1456 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_CLASS
)
1457 field
= dn_bufp
->dclass
.memberlist
;
1458 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_TEMPLATE
)
1459 field
= dn_bufp
->dtemplate
.memberlist
;
1461 field
.word
= DNTTNIL
;
1463 while (field
.word
&& field
.word
!= DNTTNIL
)
1465 fieldp
= hpread_get_lntt (field
.dnttp
.index
, objfile
);
1467 /* At this point "fieldp" may point to either a DNTT_TYPE_FIELD
1468 * or a DNTT_TYPE_GENFIELD record.
1473 volatile_member
= 0;
1475 if (fieldp
->dblock
.kind
== DNTT_TYPE_GENFIELD
)
1478 /* The type will be GENFIELD if the field is a method or
1479 * a static member (or some other cases -- see below)
1482 /* Follow a link to get to the record for the field. */
1483 fn_field
= fieldp
->dgenfield
.field
;
1484 fn_fieldp
= hpread_get_lntt (fn_field
.dnttp
.index
, objfile
);
1486 /* Virtual funcs are indicated by a VFUNC which points to the
1489 if (fn_fieldp
->dblock
.kind
== DNTT_TYPE_VFUNC
)
1491 vtbl_offset
= fn_fieldp
->dvfunc
.vtbl_offset
;
1492 fn_field
= fn_fieldp
->dvfunc
.funcptr
;
1493 fn_fieldp
= hpread_get_lntt (fn_field
.dnttp
.index
, objfile
);
1496 /* A function's entry may be preceded by a modifier which
1497 * labels it static/constant/volatile.
1499 if (fn_fieldp
->dblock
.kind
== DNTT_TYPE_MODIFIER
)
1501 static_member
= fn_fieldp
->dmodifier
.m_static
;
1502 const_member
= fn_fieldp
->dmodifier
.m_const
;
1503 volatile_member
= fn_fieldp
->dmodifier
.m_volatile
;
1504 fn_field
= fn_fieldp
->dmodifier
.type
;
1505 fn_fieldp
= hpread_get_lntt (fn_field
.dnttp
.index
, objfile
);
1508 /* Check whether we have a method */
1509 if ((fn_fieldp
->dblock
.kind
== DNTT_TYPE_MEMFUNC
) ||
1510 (fn_fieldp
->dblock
.kind
== DNTT_TYPE_FUNCTION
) ||
1511 (fn_fieldp
->dblock
.kind
== DNTT_TYPE_DOC_MEMFUNC
) ||
1512 (fn_fieldp
->dblock
.kind
== DNTT_TYPE_DOC_FUNCTION
))
1518 /* Look up function type of method */
1519 memtype
= hpread_type_lookup (fn_field
, objfile
);
1521 /* Methods can be seen before classes in the SOM records.
1522 If we are processing this class because it's a parameter of a
1523 method, at this point the method's type is actually incomplete;
1524 we'll have to fix it up later; mark the class for this. */
1526 if (TYPE_INCOMPLETE (memtype
))
1528 TYPE_FLAGS (type
) |= TYPE_FLAG_INCOMPLETE
;
1530 warning ("Two classes to fix up for method?? Type information may be incorrect for some classes.");
1532 warning ("Two methods to be fixed up at once?? Type information may be incorrect for some classes.");
1533 fixup_class
= type
; /* remember this class has to be fixed up */
1534 fixup_method
= memtype
; /* remember the method type to be used in fixup */
1537 /* HP aCC generates operator names without the "operator" keyword, and
1538 generates null strings as names for operators that are
1539 user-defined type conversions to basic types (e.g. operator int ()).
1540 So try to reconstruct name as best as possible. */
1542 method_name
= (char *) (VT (objfile
) + fn_fieldp
->dfunc
.name
);
1543 method_alias
= (char *) (VT (objfile
) + fn_fieldp
->dfunc
.alias
);
1545 if (!method_name
|| /* no name */
1546 !*method_name
|| /* or null name */
1547 cplus_mangle_opname (method_name
, DMGL_ANSI
)) /* or name is an operator like "<" */
1549 char *tmp_name
= cplus_demangle (method_alias
, DMGL_ANSI
);
1550 char *op_string
= strstr (tmp_name
, "operator");
1551 method_name
= xmalloc (strlen (op_string
) + 1); /* don't overwrite VT! */
1552 strcpy (method_name
, op_string
);
1555 /* First check if a method of the same name has already been seen. */
1559 if (STREQ (fn_p
->field
.name
, method_name
))
1564 /* If no such method was found, allocate a new entry in the list */
1567 /* Get space to record this member function */
1568 /* Note: alloca used; this will disappear on routine exit */
1569 fn_new
= (struct next_fn_field
*) alloca (sizeof (struct next_fn_field
));
1570 fn_new
->next
= fn_list
;
1573 /* Fill in the fields of the struct nextfield */
1575 /* Record the (unmangled) method name */
1576 fn_list
->field
.name
= method_name
;
1577 /* Initial space for overloaded methods */
1578 /* Note: xmalloc is used; this will persist after this routine exits */
1579 fn_list
->field
.fn_fields
= (struct fn_field
*) xmalloc (5 * (sizeof (struct fn_field
)));
1580 fn_list
->field
.length
= 1; /* Init # of overloaded instances */
1581 fn_list
->num_fn_fields
= 5; /* # of entries for which space allocated */
1583 ix
= 0; /* array index for fn_field */
1584 /* Bump the total count of the distinctly named methods */
1588 /* Another overloaded instance of an already seen method name */
1590 if (++(fn_p
->field
.length
) > fn_p
->num_fn_fields
)
1592 /* Increase space allocated for overloaded instances */
1593 fn_p
->field
.fn_fields
1594 = (struct fn_field
*) xrealloc (fn_p
->field
.fn_fields
,
1595 (fn_p
->num_fn_fields
+ 5) * sizeof (struct fn_field
));
1596 fn_p
->num_fn_fields
+= 5;
1598 ix
= fn_p
->field
.length
- 1; /* array index for fn_field */
1601 /* "physname" is intended to be the name of this overloaded instance. */
1602 if ((fn_fieldp
->dfunc
.language
== HP_LANGUAGE_CPLUSPLUS
) &&
1604 *method_alias
) /* not a null string */
1605 fn_p
->field
.fn_fields
[ix
].physname
= method_alias
;
1607 fn_p
->field
.fn_fields
[ix
].physname
= method_name
;
1608 /* What's expected here is the function type */
1609 /* But mark it as NULL if the method was incompletely processed
1610 We'll fix this up later when the method is fully processed */
1611 if (TYPE_INCOMPLETE (memtype
))
1613 fn_p
->field
.fn_fields
[ix
].type
= NULL
;
1614 fn_p
->field
.fn_fields
[ix
].args
= NULL
;
1618 fn_p
->field
.fn_fields
[ix
].type
= memtype
;
1620 /* The argument list */
1621 fn_p
->field
.fn_fields
[ix
].type
->type_specific
.arg_types
=
1622 (struct type
**) obstack_alloc (&objfile
->type_obstack
,
1623 sizeof (struct type
*) * (memtype
->nfields
+ 1));
1624 for (i
= 0; i
< memtype
->nfields
; i
++)
1625 fn_p
->field
.fn_fields
[ix
].type
->type_specific
.arg_types
[i
] = memtype
->fields
[i
].type
;
1626 /* void termination */
1627 fn_p
->field
.fn_fields
[ix
].type
->type_specific
.arg_types
[memtype
->nfields
] = builtin_type_void
;
1629 /* pai: It's not clear why this args field has to be set. Perhaps
1630 * it should be eliminated entirely. */
1631 fn_p
->field
.fn_fields
[ix
].args
=
1632 (struct type
**) obstack_alloc (&objfile
->type_obstack
,
1633 sizeof (struct type
*) * (memtype
->nfields
+ 1));
1634 for (i
= 0; i
< memtype
->nfields
; i
++)
1635 fn_p
->field
.fn_fields
[ix
].args
[i
] = memtype
->fields
[i
].type
;
1636 /* null-terminated, unlike arg_types above e */
1637 fn_p
->field
.fn_fields
[ix
].args
[memtype
->nfields
] = NULL
;
1639 /* For virtual functions, fill in the voffset field with the
1640 * virtual table offset. (This is just copied over from the
1641 * SOM record; not sure if it is what GDB expects here...).
1642 * But if the function is a static method, set it to 1.
1644 * Note that we have to add 1 because 1 indicates a static
1645 * method, and 0 indicates a non-static, non-virtual method */
1648 fn_p
->field
.fn_fields
[ix
].voffset
= VOFFSET_STATIC
;
1650 fn_p
->field
.fn_fields
[ix
].voffset
= vtbl_offset
? vtbl_offset
+ 1 : 0;
1652 /* Also fill in the fcontext field with the current
1653 * class. (The latter isn't quite right: should be the baseclass
1654 * that defines the virtual function... Note we do have
1655 * a variable "baseclass" that we could stuff into the fcontext
1656 * field, but "baseclass" isn't necessarily right either,
1657 * since the virtual function could have been defined more
1658 * than one level up).
1661 if (vtbl_offset
!= 0)
1662 fn_p
->field
.fn_fields
[ix
].fcontext
= type
;
1664 fn_p
->field
.fn_fields
[ix
].fcontext
= NULL
;
1666 /* Other random fields pertaining to this method */
1667 fn_p
->field
.fn_fields
[ix
].is_const
= const_member
;
1668 fn_p
->field
.fn_fields
[ix
].is_volatile
= volatile_member
; /* ?? */
1669 switch (fieldp
->dgenfield
.visibility
)
1672 fn_p
->field
.fn_fields
[ix
].is_protected
= 1;
1673 fn_p
->field
.fn_fields
[ix
].is_private
= 0;
1676 fn_p
->field
.fn_fields
[ix
].is_protected
= 0;
1677 fn_p
->field
.fn_fields
[ix
].is_private
= 1;
1679 default: /* public */
1680 fn_p
->field
.fn_fields
[ix
].is_protected
= 0;
1681 fn_p
->field
.fn_fields
[ix
].is_private
= 0;
1683 fn_p
->field
.fn_fields
[ix
].is_stub
= 0;
1685 /* HP aCC emits both MEMFUNC and FUNCTION entries for a method;
1686 if the class points to the FUNCTION, there is usually separate
1687 code for the method; but if we have a MEMFUNC, the method has
1688 been inlined (and there is usually no FUNCTION entry)
1689 FIXME Not sure if this test is accurate. pai/1997-08-22 */
1690 if ((fn_fieldp
->dblock
.kind
== DNTT_TYPE_MEMFUNC
) ||
1691 (fn_fieldp
->dblock
.kind
== DNTT_TYPE_DOC_MEMFUNC
))
1692 fn_p
->field
.fn_fields
[ix
].is_inlined
= 1;
1694 fn_p
->field
.fn_fields
[ix
].is_inlined
= 0;
1696 fn_p
->field
.fn_fields
[ix
].dummy
= 0;
1698 /* Bump the total count of the member functions */
1699 n_fn_fields_total
++;
1702 else if (fn_fieldp
->dblock
.kind
== DNTT_TYPE_SVAR
)
1704 /* This case is for static data members of classes */
1706 /* pai:: FIXME -- check that "staticmem" bit is set */
1708 /* Get space to record this static member */
1709 new = (struct nextfield
*) alloca (sizeof (struct nextfield
));
1713 list
->field
.name
= VT (objfile
) + fn_fieldp
->dsvar
.name
;
1714 FIELD_BITSIZE (list
->field
) = -1; /* indicates static member */
1715 SET_FIELD_PHYSNAME (list
->field
, 0); /* initialize to empty */
1716 memtype
= hpread_type_lookup (fn_fieldp
->dsvar
.type
, objfile
);
1718 FIELD_TYPE (list
->field
) = memtype
;
1719 list
->attributes
= 0;
1720 switch (fieldp
->dgenfield
.visibility
)
1723 B_SET (&(list
->attributes
), ATTR_PROTECT
);
1726 B_SET (&(list
->attributes
), ATTR_PRIVATE
);
1732 else if (fn_fieldp
->dblock
.kind
== DNTT_TYPE_FIELD
)
1734 /* FIELDs follow GENFIELDs for fields of anonymous unions.
1735 Code below is replicated from the case for FIELDs further
1736 below, except that fieldp is replaced by fn_fieldp */
1737 if (!fn_fieldp
->dfield
.a_union
)
1738 warning ("Debug info inconsistent: FIELD of anonymous union doesn't have a_union bit set");
1739 /* Get space to record the next field/data-member. */
1740 new = (struct nextfield
*) alloca (sizeof (struct nextfield
));
1744 list
->field
.name
= VT (objfile
) + fn_fieldp
->dfield
.name
;
1745 FIELD_BITPOS (list
->field
) = fn_fieldp
->dfield
.bitoffset
;
1746 if (fn_fieldp
->dfield
.bitlength
% 8)
1747 list
->field
.bitsize
= fn_fieldp
->dfield
.bitlength
;
1749 list
->field
.bitsize
= 0;
1751 memtype
= hpread_type_lookup (fn_fieldp
->dfield
.type
, objfile
);
1752 list
->field
.type
= memtype
;
1753 list
->attributes
= 0;
1754 switch (fn_fieldp
->dfield
.visibility
)
1757 B_SET (&(list
->attributes
), ATTR_PROTECT
);
1760 B_SET (&(list
->attributes
), ATTR_PRIVATE
);
1765 else if (fn_fieldp
->dblock
.kind
== DNTT_TYPE_SVAR
)
1767 /* Field of anonymous union; union is not inside a class */
1768 if (!fn_fieldp
->dsvar
.a_union
)
1769 warning ("Debug info inconsistent: SVAR field in anonymous union doesn't have a_union bit set");
1770 /* Get space to record the next field/data-member. */
1771 new = (struct nextfield
*) alloca (sizeof (struct nextfield
));
1775 list
->field
.name
= VT (objfile
) + fn_fieldp
->dsvar
.name
;
1776 FIELD_BITPOS (list
->field
) = 0; /* FIXME is this always true? */
1777 FIELD_BITSIZE (list
->field
) = 0; /* use length from type */
1778 memtype
= hpread_type_lookup (fn_fieldp
->dsvar
.type
, objfile
);
1779 list
->field
.type
= memtype
;
1780 list
->attributes
= 0;
1781 /* No info to set visibility -- always public */
1784 else if (fn_fieldp
->dblock
.kind
== DNTT_TYPE_DVAR
)
1786 /* Field of anonymous union; union is not inside a class */
1787 if (!fn_fieldp
->ddvar
.a_union
)
1788 warning ("Debug info inconsistent: DVAR field in anonymous union doesn't have a_union bit set");
1789 /* Get space to record the next field/data-member. */
1790 new = (struct nextfield
*) alloca (sizeof (struct nextfield
));
1794 list
->field
.name
= VT (objfile
) + fn_fieldp
->ddvar
.name
;
1795 FIELD_BITPOS (list
->field
) = 0; /* FIXME is this always true? */
1796 FIELD_BITSIZE (list
->field
) = 0; /* use length from type */
1797 memtype
= hpread_type_lookup (fn_fieldp
->ddvar
.type
, objfile
);
1798 list
->field
.type
= memtype
;
1799 list
->attributes
= 0;
1800 /* No info to set visibility -- always public */
1804 { /* Not a method, nor a static data member, nor an anon union field */
1806 /* This case is for miscellaneous type entries (local enums,
1807 local function templates, etc.) that can be present
1810 /* Enums -- will be handled by other code that takes care
1811 of DNTT_TYPE_ENUM; here we see only DNTT_TYPE_MEMENUM so
1812 it's not clear we could have handled them here at all. */
1813 /* FUNC_TEMPLATE: is handled by other code (??). */
1814 /* MEMACCESS: modified access for inherited member. Not
1815 sure what to do with this, ignoriing it at present. */
1817 /* What other entries can appear following a GENFIELD which
1818 we do not handle above? (MODIFIER, VFUNC handled above.) */
1820 if ((fn_fieldp
->dblock
.kind
!= DNTT_TYPE_MEMACCESS
) &&
1821 (fn_fieldp
->dblock
.kind
!= DNTT_TYPE_MEMENUM
) &&
1822 (fn_fieldp
->dblock
.kind
!= DNTT_TYPE_FUNC_TEMPLATE
))
1823 warning ("Internal error: Unexpected debug record kind %d found following DNTT_GENFIELD",
1824 fn_fieldp
->dblock
.kind
);
1826 /* walk to the next FIELD or GENFIELD */
1827 field
= fieldp
->dgenfield
.nextfield
;
1830 else if (fieldp
->dblock
.kind
== DNTT_TYPE_FIELD
)
1833 /* Ordinary structure/union/class field */
1834 struct type
*anon_union_type
;
1836 /* Get space to record the next field/data-member. */
1837 new = (struct nextfield
*) alloca (sizeof (struct nextfield
));
1841 list
->field
.name
= VT (objfile
) + fieldp
->dfield
.name
;
1844 /* A FIELD by itself (without a GENFIELD) can also be a static member */
1845 if (fieldp
->dfield
.staticmem
)
1847 FIELD_BITPOS (list
->field
) = -1;
1848 FIELD_BITSIZE (list
->field
) = 0;
1851 /* Non-static data member */
1853 FIELD_BITPOS (list
->field
) = fieldp
->dfield
.bitoffset
;
1854 if (fieldp
->dfield
.bitlength
% 8)
1855 FIELD_BITSIZE (list
->field
) = fieldp
->dfield
.bitlength
;
1857 FIELD_BITSIZE (list
->field
) = 0;
1860 memtype
= hpread_type_lookup (fieldp
->dfield
.type
, objfile
);
1861 FIELD_TYPE (list
->field
) = memtype
;
1862 list
->attributes
= 0;
1863 switch (fieldp
->dfield
.visibility
)
1866 B_SET (&(list
->attributes
), ATTR_PROTECT
);
1869 B_SET (&(list
->attributes
), ATTR_PRIVATE
);
1875 /* Note 1: First, we have to check if the current field is an anonymous
1876 union. If it is, then *its* fields are threaded along in the
1877 nextfield chain. :-( This was supposed to help debuggers, but is
1878 really just a nuisance since we deal with anonymous unions anyway by
1879 checking that the name is null. So anyway, we skip over the fields
1880 of the anonymous union. pai/1997-08-22 */
1881 /* Note 2: In addition, the bitoffsets for the fields of the anon union
1882 are relative to the enclosing struct, *NOT* relative to the anon
1883 union! This is an even bigger nuisance -- we have to go in and munge
1884 the anon union's type information appropriately. pai/1997-08-22 */
1886 /* Both tasks noted above are done by a separate function. This takes us
1887 to the next FIELD or GENFIELD, skipping anon unions, and recursively
1888 processing intermediate types. */
1889 field
= hpread_get_next_skip_over_anon_unions (1, field
, &fieldp
, objfile
);
1894 /* neither field nor genfield ?? is this possible?? */
1895 /* pai:: FIXME walk to the next -- how? */
1896 warning ("Internal error: unexpected DNTT kind %d encountered as field of struct");
1897 warning ("Skipping remaining fields of struct");
1898 break; /* get out of loop of fields */
1902 /* If it's a template, read in the instantiation list */
1903 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_TEMPLATE
)
1905 ninstantiations
= 0;
1906 field
= dn_bufp
->dtemplate
.expansions
;
1907 while (field
.word
&& field
.word
!= DNTTNIL
)
1909 fieldp
= hpread_get_lntt (field
.dnttp
.index
, objfile
);
1911 /* The expansions or nextexp should point to a tagdef */
1912 if (fieldp
->dblock
.kind
!= DNTT_TYPE_TAGDEF
)
1915 i_new
= (struct next_instantiation
*) alloca (sizeof (struct next_instantiation
));
1916 i_new
->next
= i_list
;
1918 i_list
->t
= hpread_type_lookup (field
, objfile
);
1921 /* And the "type" field of that should point to a class */
1922 field
= fieldp
->dtag
.type
;
1923 fieldp
= hpread_get_lntt (field
.dnttp
.index
, objfile
);
1924 if (fieldp
->dblock
.kind
!= DNTT_TYPE_CLASS
)
1927 /* Get the next expansion */
1928 field
= fieldp
->dclass
.nextexp
;
1931 TYPE_NINSTANTIATIONS (type
) = ninstantiations
;
1932 if (ninstantiations
> 0)
1933 TYPE_INSTANTIATIONS (type
) = (struct type
**)
1934 obstack_alloc (&objfile
->type_obstack
, sizeof (struct type
*) * ninstantiations
);
1935 for (n
= ninstantiations
; i_list
; i_list
= i_list
->next
)
1938 TYPE_INSTANTIATION (type
, n
) = i_list
->t
;
1942 /* Copy the field-list to GDB's symbol table */
1943 TYPE_NFIELDS (type
) = nfields
;
1944 TYPE_N_BASECLASSES (type
) = n_base_classes
;
1945 TYPE_FIELDS (type
) = (struct field
*)
1946 obstack_alloc (&objfile
->type_obstack
, sizeof (struct field
) * nfields
);
1947 /* Copy the saved-up fields into the field vector. */
1948 for (n
= nfields
, tmp_list
= list
; tmp_list
; tmp_list
= tmp_list
->next
)
1951 TYPE_FIELD (type
, n
) = tmp_list
->field
;
1954 /* Copy the "function-field-list" (i.e., the list of member
1955 * functions in the class) to GDB's symbol table
1957 TYPE_NFN_FIELDS (type
) = n_fn_fields
;
1958 TYPE_NFN_FIELDS_TOTAL (type
) = n_fn_fields_total
;
1959 TYPE_FN_FIELDLISTS (type
) = (struct fn_fieldlist
*)
1960 obstack_alloc (&objfile
->type_obstack
, sizeof (struct fn_fieldlist
) * n_fn_fields
);
1961 for (n
= n_fn_fields
; fn_list
; fn_list
= fn_list
->next
)
1964 TYPE_FN_FIELDLIST (type
, n
) = fn_list
->field
;
1967 /* pai:: FIXME -- perhaps each bitvector should be created individually */
1968 for (n
= nfields
, tmp_list
= list
; tmp_list
; tmp_list
= tmp_list
->next
)
1971 if (tmp_list
->attributes
)
1973 need_bitvectors
= 1;
1978 if (need_bitvectors
)
1980 /* pai:: this step probably redundant */
1981 ALLOCATE_CPLUS_STRUCT_TYPE (type
);
1983 TYPE_FIELD_VIRTUAL_BITS (type
) =
1984 (B_TYPE
*) TYPE_ALLOC (type
, B_BYTES (nfields
));
1985 B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type
), nfields
);
1987 TYPE_FIELD_PRIVATE_BITS (type
) =
1988 (B_TYPE
*) TYPE_ALLOC (type
, B_BYTES (nfields
));
1989 B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type
), nfields
);
1991 TYPE_FIELD_PROTECTED_BITS (type
) =
1992 (B_TYPE
*) TYPE_ALLOC (type
, B_BYTES (nfields
));
1993 B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type
), nfields
);
1995 /* this field vector isn't actually used with HP aCC */
1996 TYPE_FIELD_IGNORE_BITS (type
) =
1997 (B_TYPE
*) TYPE_ALLOC (type
, B_BYTES (nfields
));
1998 B_CLRALL (TYPE_FIELD_IGNORE_BITS (type
), nfields
);
2000 while (nfields
-- > 0)
2002 if (B_TST (&(list
->attributes
), ATTR_VIRTUAL
))
2003 SET_TYPE_FIELD_VIRTUAL (type
, nfields
);
2004 if (B_TST (&(list
->attributes
), ATTR_PRIVATE
))
2005 SET_TYPE_FIELD_PRIVATE (type
, nfields
);
2006 if (B_TST (&(list
->attributes
), ATTR_PROTECT
))
2007 SET_TYPE_FIELD_PROTECTED (type
, nfields
);
2014 TYPE_FIELD_VIRTUAL_BITS (type
) = NULL
;
2015 TYPE_FIELD_PROTECTED_BITS (type
) = NULL
;
2016 TYPE_FIELD_PRIVATE_BITS (type
) = NULL
;
2019 if (has_vtable (type
))
2021 /* Allocate space for class runtime information */
2022 TYPE_RUNTIME_PTR (type
) = (struct runtime_info
*) xmalloc (sizeof (struct runtime_info
));
2023 /* Set flag for vtable */
2024 TYPE_VTABLE (type
) = 1;
2025 /* The first non-virtual base class with a vtable. */
2026 TYPE_PRIMARY_BASE (type
) = primary_base_class (type
);
2027 /* The virtual base list. */
2028 TYPE_VIRTUAL_BASE_LIST (type
) = virtual_base_list (type
);
2031 TYPE_RUNTIME_PTR (type
) = NULL
;
2033 /* If this is a local type (C++ - declared inside a function), record file name & line # */
2034 if (hpread_get_scope_depth (dn_bufp
, objfile
, 1 /* no need for real depth */ ))
2036 TYPE_LOCALTYPE_PTR (type
) = (struct local_type_info
*) xmalloc (sizeof (struct local_type_info
));
2037 TYPE_LOCALTYPE_FILE (type
) = (char *) xmalloc (strlen (current_subfile
->name
) + 1);
2038 strcpy (TYPE_LOCALTYPE_FILE (type
), current_subfile
->name
);
2039 if (current_subfile
->line_vector
&& (current_subfile
->line_vector
->nitems
> 0))
2040 TYPE_LOCALTYPE_LINE (type
) = current_subfile
->line_vector
->item
[current_subfile
->line_vector
->nitems
- 1].line
;
2042 TYPE_LOCALTYPE_LINE (type
) = 0;
2045 TYPE_LOCALTYPE_PTR (type
) = NULL
;
2047 /* Clear the global saying what template we are in the middle of processing */
2048 current_template
= NULL
;
2053 /* Adjust the physnames for each static member of a struct
2054 or class type to be something like "A::x"; then various
2055 other pieces of code that do a lookup_symbol on the phyname
2057 TYPE is a pointer to the struct/class type
2058 NAME is a char * (string) which is the class/struct name
2062 fix_static_member_physnames (type
, class_name
, objfile
)
2065 struct objfile
*objfile
;
2069 /* We fix the member names only for classes or structs */
2070 if (TYPE_CODE (type
) != TYPE_CODE_STRUCT
)
2073 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
2074 if (TYPE_FIELD_STATIC (type
, i
))
2076 if (TYPE_FIELD_STATIC_PHYSNAME (type
, i
))
2077 return; /* physnames are already set */
2079 SET_FIELD_PHYSNAME (type
->fields
[i
],
2080 obstack_alloc (&objfile
->type_obstack
,
2081 strlen (class_name
) + strlen (TYPE_FIELD_NAME (type
, i
)) + 3));
2082 strcpy (TYPE_FIELD_STATIC_PHYSNAME (type
, i
), class_name
);
2083 strcat (TYPE_FIELD_STATIC_PHYSNAME (type
, i
), "::");
2084 strcat (TYPE_FIELD_STATIC_PHYSNAME (type
, i
), TYPE_FIELD_NAME (type
, i
));
2088 /* Fix-up the type structure for a CLASS so that the type entry
2089 * for a method (previously marked with a null type in hpread_read_struct_type()
2090 * is set correctly to METHOD.
2091 * OBJFILE is as for other such functions.
2095 fixup_class_method_type (class, method
, objfile
)
2097 struct type
*method
;
2098 struct objfile
*objfile
;
2102 if (!class || !method
|| !objfile
)
2105 /* Only for types that have methods */
2106 if ((TYPE_CODE (class) != TYPE_CODE_CLASS
) &&
2107 (TYPE_CODE (class) != TYPE_CODE_UNION
))
2110 /* Loop over all methods and find the one marked with a NULL type */
2111 for (i
= 0; i
< TYPE_NFN_FIELDS (class); i
++)
2112 for (j
= 0; j
< TYPE_FN_FIELDLIST_LENGTH (class, i
); j
++)
2113 if (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i
), j
) == NULL
)
2115 /* Set the method type */
2116 TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i
), j
) = method
;
2117 /* The argument list */
2118 (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i
), j
))->type_specific
.arg_types
2119 = (struct type
**) obstack_alloc (&objfile
->type_obstack
,
2120 sizeof (struct type
*) * (method
->nfields
+ 1));
2121 for (k
= 0; k
< method
->nfields
; k
++)
2122 (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i
), j
))->type_specific
.arg_types
[k
] = method
->fields
[k
].type
;
2123 /* void termination */
2124 (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i
), j
))->type_specific
.arg_types
[method
->nfields
] = builtin_type_void
;
2126 /* pai: It's not clear why this args field has to be set. Perhaps
2127 * it should be eliminated entirely. */
2128 (TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i
), j
)).args
2129 = (struct type
**) obstack_alloc (&objfile
->type_obstack
,
2130 sizeof (struct type
*) * (method
->nfields
+ 1));
2131 for (k
= 0; k
< method
->nfields
; k
++)
2132 (TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i
), j
)).args
[k
] = method
->fields
[k
].type
;
2133 /* null-terminated, unlike arg_types above */
2134 (TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i
), j
)).args
[method
->nfields
] = NULL
;
2136 /* Break out of both loops -- only one method to fix up in a class */
2141 TYPE_FLAGS (class) &= ~TYPE_FLAG_INCOMPLETE
;
2145 /* If we're in the middle of processing a template, get a pointer
2146 * to the Nth template argument.
2147 * An example may make this clearer:
2148 * template <class T1, class T2> class q2 {
2153 * The type for "a" will be "first template arg" and
2154 * the type for "b" will be "second template arg".
2155 * We need to look these up in order to fill in "a" and "b"'s type.
2156 * This is called from hpread_type_lookup().
2158 static struct type
*
2159 hpread_get_nth_template_arg (objfile
, n
)
2160 struct objfile
*objfile
;
2163 if (current_template
!= NULL
)
2164 return TYPE_TEMPLATE_ARG (current_template
, n
).type
;
2166 return lookup_fundamental_type (objfile
, FT_TEMPLATE_ARG
);
2169 /* Read in and internalize a TEMPL_ARG (template arg) symbol. */
2171 static struct type
*
2172 hpread_read_templ_arg_type (hp_type
, dn_bufp
, objfile
, name
)
2173 dnttpointer hp_type
;
2174 union dnttentry
*dn_bufp
;
2175 struct objfile
*objfile
;
2180 /* See if it's something we've already deal with. */
2181 type
= hpread_alloc_type (hp_type
, objfile
);
2182 if (TYPE_CODE (type
) == TYPE_CODE_TEMPLATE_ARG
)
2185 /* Nope. Fill in the appropriate fields. */
2186 TYPE_CODE (type
) = TYPE_CODE_TEMPLATE_ARG
;
2187 TYPE_LENGTH (type
) = 0;
2188 TYPE_NFIELDS (type
) = 0;
2189 TYPE_NAME (type
) = name
;
2193 /* Read in and internalize a set debug symbol. */
2195 static struct type
*
2196 hpread_read_set_type (hp_type
, dn_bufp
, objfile
)
2197 dnttpointer hp_type
;
2198 union dnttentry
*dn_bufp
;
2199 struct objfile
*objfile
;
2203 /* See if it's something we've already deal with. */
2204 type
= hpread_alloc_type (hp_type
, objfile
);
2205 if (TYPE_CODE (type
) == TYPE_CODE_SET
)
2208 /* Nope. Fill in the appropriate fields. */
2209 TYPE_CODE (type
) = TYPE_CODE_SET
;
2210 TYPE_LENGTH (type
) = dn_bufp
->dset
.bitlength
/ 8;
2211 TYPE_NFIELDS (type
) = 0;
2212 TYPE_TARGET_TYPE (type
) = hpread_type_lookup (dn_bufp
->dset
.subtype
,
2217 /* Read in and internalize an array debug symbol. */
2219 static struct type
*
2220 hpread_read_array_type (hp_type
, dn_bufp
, objfile
)
2221 dnttpointer hp_type
;
2222 union dnttentry
*dn_bufp
;
2223 struct objfile
*objfile
;
2227 /* Allocate an array type symbol.
2228 * Why no check for already-read here, like in the other
2229 * hpread_read_xxx_type routines? Because it kept us
2230 * from properly determining the size of the array!
2232 type
= hpread_alloc_type (hp_type
, objfile
);
2234 TYPE_CODE (type
) = TYPE_CODE_ARRAY
;
2236 /* Although the hp-symtab.h does not *require* this to be the case,
2237 * GDB is assuming that "arrayisbytes" and "elemisbytes" be consistent.
2238 * I.e., express both array-length and element-length in bits,
2239 * or express both array-length and element-length in bytes.
2241 if (!((dn_bufp
->darray
.arrayisbytes
&& dn_bufp
->darray
.elemisbytes
) ||
2242 (!dn_bufp
->darray
.arrayisbytes
&& !dn_bufp
->darray
.elemisbytes
)))
2244 warning ("error in hpread_array_type.\n");
2247 else if (dn_bufp
->darray
.arraylength
== 0x7fffffff)
2249 /* The HP debug format represents char foo[]; as an array with
2250 * length 0x7fffffff. Internally GDB wants to represent this
2251 * as an array of length zero.
2253 TYPE_LENGTH (type
) = 0;
2255 else if (dn_bufp
->darray
.arrayisbytes
)
2256 TYPE_LENGTH (type
) = dn_bufp
->darray
.arraylength
;
2257 else /* arraylength is in bits */
2258 TYPE_LENGTH (type
) = dn_bufp
->darray
.arraylength
/ 8;
2260 TYPE_TARGET_TYPE (type
) = hpread_type_lookup (dn_bufp
->darray
.elemtype
,
2263 /* The one "field" is used to store the subscript type */
2264 /* Since C and C++ multi-dimensional arrays are simply represented
2265 * as: array of array of ..., we only need one subscript-type
2266 * per array. This subscript type is typically a subrange of integer.
2267 * If this gets extended to support languages like Pascal, then
2268 * we need to fix this to represent multi-dimensional arrays properly.
2270 TYPE_NFIELDS (type
) = 1;
2271 TYPE_FIELDS (type
) = (struct field
*)
2272 obstack_alloc (&objfile
->type_obstack
, sizeof (struct field
));
2273 TYPE_FIELD_TYPE (type
, 0) = hpread_type_lookup (dn_bufp
->darray
.indextype
,
2278 /* Read in and internalize a subrange debug symbol. */
2279 static struct type
*
2280 hpread_read_subrange_type (hp_type
, dn_bufp
, objfile
)
2281 dnttpointer hp_type
;
2282 union dnttentry
*dn_bufp
;
2283 struct objfile
*objfile
;
2287 /* Is it something we've already dealt with. */
2288 type
= hpread_alloc_type (hp_type
, objfile
);
2289 if (TYPE_CODE (type
) == TYPE_CODE_RANGE
)
2292 /* Nope, internalize it. */
2293 TYPE_CODE (type
) = TYPE_CODE_RANGE
;
2294 TYPE_LENGTH (type
) = dn_bufp
->dsubr
.bitlength
/ 8;
2295 TYPE_NFIELDS (type
) = 2;
2297 = (struct field
*) obstack_alloc (&objfile
->type_obstack
,
2298 2 * sizeof (struct field
));
2300 if (dn_bufp
->dsubr
.dyn_low
)
2301 TYPE_FIELD_BITPOS (type
, 0) = 0;
2303 TYPE_FIELD_BITPOS (type
, 0) = dn_bufp
->dsubr
.lowbound
;
2305 if (dn_bufp
->dsubr
.dyn_high
)
2306 TYPE_FIELD_BITPOS (type
, 1) = -1;
2308 TYPE_FIELD_BITPOS (type
, 1) = dn_bufp
->dsubr
.highbound
;
2309 TYPE_TARGET_TYPE (type
) = hpread_type_lookup (dn_bufp
->dsubr
.subtype
,
2314 /* struct type * hpread_type_lookup(hp_type, objfile)
2316 * hp_type: A pointer into the DNTT specifying what type we
2317 * are about to "look up"., or else [for fundamental types
2318 * like int, float, ...] an "immediate" structure describing
2321 * Return value: A pointer to a "struct type" (representation of a
2322 * type in GDB's internal symbol table - see gdbtypes.h)
2323 * Routine description:
2324 * There are a variety of places when scanning the DNTT when we
2325 * need to interpret a "type" field. The simplest and most basic
2326 * example is when we're processing the symbol table record
2327 * for a data symbol (a SVAR or DVAR record). That has
2328 * a "type" field specifying the type of the data symbol. That
2329 * "type" field is either an "immediate" type specification (for the
2330 * fundamental types) or a DNTT pointer (for more complicated types).
2331 * For the more complicated types, we may or may not have already
2332 * processed the pointed-to type. (Multiple data symbols can of course
2333 * share the same type).
2334 * The job of hpread_type_lookup() is to process this "type" field.
2335 * Most of the real work is done in subroutines. Here we interpret
2336 * the immediate flag. If not immediate, chase the DNTT pointer to
2337 * find our way to the SOM record describing the type, switch on
2338 * the SOM kind, and then call an appropriate subroutine depending
2339 * on what kind of type we are constructing. (e.g., an array type,
2340 * a struct/class type, etc).
2342 static struct type
*
2343 hpread_type_lookup (hp_type
, objfile
)
2344 dnttpointer hp_type
;
2345 struct objfile
*objfile
;
2347 union dnttentry
*dn_bufp
;
2348 struct type
*tmp_type
;
2350 /* First see if it's a simple builtin type. */
2351 if (hp_type
.dntti
.immediate
)
2352 /* If this is a template argument, the argument number is
2353 * encoded in the bitlength. All other cases, just return
2354 * GDB's representation of this fundamental type.
2356 if (hp_type
.dntti
.type
== HP_TYPE_TEMPLATE_ARG
)
2357 return hpread_get_nth_template_arg (objfile
, hp_type
.dntti
.bitlength
);
2359 return lookup_fundamental_type (objfile
, hpread_type_translate (hp_type
));
2361 /* Not a builtin type. We'll have to read it in. */
2362 if (hp_type
.dnttp
.index
< LNTT_SYMCOUNT (objfile
))
2363 dn_bufp
= hpread_get_lntt (hp_type
.dnttp
.index
, objfile
);
2365 /* This is a fancy way of returning NULL */
2366 return lookup_fundamental_type (objfile
, FT_VOID
);
2368 switch (dn_bufp
->dblock
.kind
)
2370 case DNTT_TYPE_SRCFILE
:
2371 case DNTT_TYPE_MODULE
:
2372 case DNTT_TYPE_ENTRY
:
2373 case DNTT_TYPE_BEGIN
:
2375 case DNTT_TYPE_IMPORT
:
2376 case DNTT_TYPE_LABEL
:
2377 case DNTT_TYPE_FPARAM
:
2378 case DNTT_TYPE_SVAR
:
2379 case DNTT_TYPE_DVAR
:
2380 case DNTT_TYPE_CONST
:
2381 case DNTT_TYPE_MEMENUM
:
2382 case DNTT_TYPE_VARIANT
:
2383 case DNTT_TYPE_FILE
:
2384 case DNTT_TYPE_WITH
:
2385 case DNTT_TYPE_COMMON
:
2386 case DNTT_TYPE_COBSTRUCT
:
2387 case DNTT_TYPE_XREF
:
2389 case DNTT_TYPE_MACRO
:
2390 case DNTT_TYPE_BLOCKDATA
:
2391 case DNTT_TYPE_CLASS_SCOPE
:
2392 case DNTT_TYPE_MEMACCESS
:
2393 case DNTT_TYPE_INHERITANCE
:
2394 case DNTT_TYPE_OBJECT_ID
:
2395 case DNTT_TYPE_FRIEND_CLASS
:
2396 case DNTT_TYPE_FRIEND_FUNC
:
2397 /* These are not types - something went wrong. */
2398 /* This is a fancy way of returning NULL */
2399 return lookup_fundamental_type (objfile
, FT_VOID
);
2401 case DNTT_TYPE_FUNCTION
:
2402 /* We wind up here when dealing with class member functions
2403 * (called from hpread_read_struct_type(), i.e. when processing
2404 * the class definition itself).
2406 return hpread_read_function_type (hp_type
, dn_bufp
, objfile
, 0);
2408 case DNTT_TYPE_DOC_FUNCTION
:
2409 return hpread_read_doc_function_type (hp_type
, dn_bufp
, objfile
, 0);
2411 case DNTT_TYPE_TYPEDEF
:
2413 /* A typedef - chase it down by making a recursive call */
2414 struct type
*structtype
= hpread_type_lookup (dn_bufp
->dtype
.type
,
2417 /* The following came from the base hpread.c that we inherited.
2418 * It is WRONG so I have commented it out. - RT
2422 suffix = VT (objfile) + dn_bufp->dtype.name;
2423 TYPE_NAME (structtype) = suffix;
2425 * ... further explanation ....
2427 * What we have here is a typedef pointing to a typedef.
2432 * What we desire to build is (these are pictures
2433 * of "struct type"'s):
2435 * +---------+ +----------+ +------------+
2436 * | typedef | | typedef | | fund. type |
2437 * | type| -> | type| -> | |
2438 * | "fum" | | "foo" | | "int" |
2439 * +---------+ +----------+ +------------+
2441 * What this commented-out code is doing is smashing the
2442 * name of pointed-to-type to be the same as the pointed-from
2443 * type. So we wind up with something like:
2445 * +---------+ +----------+ +------------+
2446 * | typedef | | typedef | | fund. type |
2447 * | type| -> | type| -> | |
2448 * | "fum" | | "fum" | | "fum" |
2449 * +---------+ +----------+ +------------+
2456 case DNTT_TYPE_TAGDEF
:
2458 /* Just a little different from above. We have to tack on
2459 * an identifier of some kind (struct, union, enum, class, etc).
2461 struct type
*structtype
= hpread_type_lookup (dn_bufp
->dtype
.type
,
2463 char *prefix
, *suffix
;
2464 suffix
= VT (objfile
) + dn_bufp
->dtype
.name
;
2466 /* Lookup the next type in the list. It should be a structure,
2467 * union, class, enum, or template type.
2468 * We will need to attach that to our name.
2470 if (dn_bufp
->dtype
.type
.dnttp
.index
< LNTT_SYMCOUNT (objfile
))
2471 dn_bufp
= hpread_get_lntt (dn_bufp
->dtype
.type
.dnttp
.index
, objfile
);
2474 complain (&hpread_type_lookup_complaint
);
2478 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_STRUCT
)
2482 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_UNION
)
2486 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_CLASS
)
2488 /* Further field for CLASS saying how it was really declared */
2489 /* 0==class, 1==union, 2==struct */
2490 if (dn_bufp
->dclass
.class_decl
== 0)
2492 else if (dn_bufp
->dclass
.class_decl
== 1)
2494 else if (dn_bufp
->dclass
.class_decl
== 2)
2499 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_ENUM
)
2503 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_TEMPLATE
)
2505 prefix
= "template ";
2512 /* Build the correct name. */
2514 = (char *) obstack_alloc (&objfile
->type_obstack
,
2515 strlen (prefix
) + strlen (suffix
) + 1);
2516 TYPE_NAME (structtype
) = strcpy (TYPE_NAME (structtype
), prefix
);
2517 TYPE_NAME (structtype
) = strcat (TYPE_NAME (structtype
), suffix
);
2518 TYPE_TAG_NAME (structtype
) = suffix
;
2520 /* For classes/structs, we have to set the static member "physnames"
2521 to point to strings like "Class::Member" */
2522 if (TYPE_CODE (structtype
) == TYPE_CODE_STRUCT
)
2523 fix_static_member_physnames (structtype
, suffix
, objfile
);
2528 case DNTT_TYPE_POINTER
:
2529 /* Pointer type - call a routine in gdbtypes.c that constructs
2530 * the appropriate GDB type.
2532 return make_pointer_type (
2533 hpread_type_lookup (dn_bufp
->dptr
.pointsto
,
2537 case DNTT_TYPE_REFERENCE
:
2538 /* C++ reference type - call a routine in gdbtypes.c that constructs
2539 * the appropriate GDB type.
2541 return make_reference_type (
2542 hpread_type_lookup (dn_bufp
->dreference
.pointsto
,
2546 case DNTT_TYPE_ENUM
:
2547 return hpread_read_enum_type (hp_type
, dn_bufp
, objfile
);
2549 return hpread_read_set_type (hp_type
, dn_bufp
, objfile
);
2550 case DNTT_TYPE_SUBRANGE
:
2551 return hpread_read_subrange_type (hp_type
, dn_bufp
, objfile
);
2552 case DNTT_TYPE_ARRAY
:
2553 return hpread_read_array_type (hp_type
, dn_bufp
, objfile
);
2554 case DNTT_TYPE_STRUCT
:
2555 case DNTT_TYPE_UNION
:
2556 return hpread_read_struct_type (hp_type
, dn_bufp
, objfile
);
2557 case DNTT_TYPE_FIELD
:
2558 return hpread_type_lookup (dn_bufp
->dfield
.type
, objfile
);
2560 case DNTT_TYPE_FUNCTYPE
:
2561 /* Here we want to read the function SOMs and return a
2562 * type for it. We get here, for instance, when processing
2563 * pointer-to-function type.
2565 return hpread_read_function_type (hp_type
, dn_bufp
, objfile
, 0);
2567 case DNTT_TYPE_PTRMEM
:
2568 /* Declares a C++ pointer-to-data-member type.
2569 * The "pointsto" field defines the class,
2570 * while the "memtype" field defines the pointed-to-type.
2573 struct type
*ptrmemtype
;
2574 struct type
*class_type
;
2575 struct type
*memtype
;
2576 memtype
= hpread_type_lookup (dn_bufp
->dptrmem
.memtype
,
2578 class_type
= hpread_type_lookup (dn_bufp
->dptrmem
.pointsto
,
2580 ptrmemtype
= alloc_type (objfile
);
2581 smash_to_member_type (ptrmemtype
, class_type
, memtype
);
2582 return make_pointer_type (ptrmemtype
, NULL
);
2586 case DNTT_TYPE_PTRMEMFUNC
:
2587 /* Defines a C++ pointer-to-function-member type.
2588 * The "pointsto" field defines the class,
2589 * while the "memtype" field defines the pointed-to-type.
2592 struct type
*ptrmemtype
;
2593 struct type
*class_type
;
2594 struct type
*functype
;
2595 struct type
*retvaltype
;
2598 struct type
**args_type
;
2599 class_type
= hpread_type_lookup (dn_bufp
->dptrmem
.pointsto
,
2601 functype
= hpread_type_lookup (dn_bufp
->dptrmem
.memtype
,
2603 retvaltype
= TYPE_TARGET_TYPE (functype
);
2604 nargs
= TYPE_NFIELDS (functype
);
2605 args_type
= (struct type
**) xmalloc ((nargs
+ 1) * sizeof (struct type
*));
2606 for (i
= 0; i
< nargs
; i
++)
2608 args_type
[i
] = TYPE_FIELD_TYPE (functype
, i
);
2610 args_type
[nargs
] = NULL
;
2611 ptrmemtype
= alloc_type (objfile
);
2612 smash_to_method_type (ptrmemtype
, class_type
, retvaltype
, args_type
);
2613 return make_pointer_type (ptrmemtype
, NULL
);
2617 case DNTT_TYPE_CLASS
:
2618 return hpread_read_struct_type (hp_type
, dn_bufp
, objfile
);
2620 case DNTT_TYPE_GENFIELD
:
2621 /* Chase pointer from GENFIELD to FIELD, and make recursive
2624 return hpread_type_lookup (dn_bufp
->dgenfield
.field
, objfile
);
2626 case DNTT_TYPE_VFUNC
:
2627 /* C++ virtual function.
2628 * We get here in the course of processing a class type which
2629 * contains virtual functions. Just go through another level
2630 * of indirection to get to the pointed-to function SOM.
2632 return hpread_type_lookup (dn_bufp
->dvfunc
.funcptr
, objfile
);
2634 case DNTT_TYPE_MODIFIER
:
2635 /* Check the modifiers and then just make a recursive call on
2636 * the "type" pointed to by the modifier DNTT.
2638 * pai:: FIXME -- do we ever want to handle "m_duplicate" and
2639 * "m_void" modifiers? Is static_flag really needed here?
2640 * (m_static used for methods of classes, elsewhere).
2642 tmp_type
= make_cv_type (dn_bufp
->dmodifier
.m_const
,
2643 dn_bufp
->dmodifier
.m_volatile
,
2644 hpread_type_lookup (dn_bufp
->dmodifier
.type
, objfile
),
2649 case DNTT_TYPE_MEMFUNC
:
2650 /* Member function. Treat like a function.
2651 * I think we get here in the course of processing a
2652 * pointer-to-member-function type...
2654 return hpread_read_function_type (hp_type
, dn_bufp
, objfile
, 0);
2656 case DNTT_TYPE_DOC_MEMFUNC
:
2657 return hpread_read_doc_function_type (hp_type
, dn_bufp
, objfile
, 0);
2659 case DNTT_TYPE_TEMPLATE
:
2660 /* Template - sort of the header for a template definition,
2661 * which like a class, points to a member list and also points
2662 * to a TEMPLATE_ARG list of type-arguments.
2664 return hpread_read_struct_type (hp_type
, dn_bufp
, objfile
);
2666 case DNTT_TYPE_TEMPLATE_ARG
:
2669 /* The TEMPLATE record points to an argument list of
2670 * TEMPLATE_ARG records, each of which describes one
2671 * of the type-arguments.
2673 name
= VT (objfile
) + dn_bufp
->dtempl_arg
.name
;
2674 return hpread_read_templ_arg_type (hp_type
, dn_bufp
, objfile
, name
);
2677 case DNTT_TYPE_FUNC_TEMPLATE
:
2678 /* We wind up here when processing a TEMPLATE type,
2679 * if the template has member function(s).
2680 * Treat it like a FUNCTION.
2682 return hpread_read_function_type (hp_type
, dn_bufp
, objfile
, 0);
2684 case DNTT_TYPE_LINK
:
2685 /* The LINK record is used to link up templates with instantiations.
2686 * There is no type associated with the LINK record per se.
2688 return lookup_fundamental_type (objfile
, FT_VOID
);
2690 /* Also not yet handled... */
2691 /* case DNTT_TYPE_DYN_ARRAY_DESC: */
2692 /* case DNTT_TYPE_DESC_SUBRANGE: */
2693 /* case DNTT_TYPE_BEGIN_EXT: */
2694 /* case DNTT_TYPE_INLN: */
2695 /* case DNTT_TYPE_INLN_LIST: */
2696 /* case DNTT_TYPE_ALIAS: */
2698 /* A fancy way of returning NULL */
2699 return lookup_fundamental_type (objfile
, FT_VOID
);
2704 hpread_record_lines (subfile
, s_idx
, e_idx
, objfile
, offset
)
2705 struct subfile
*subfile
;
2706 sltpointer s_idx
, e_idx
;
2707 struct objfile
*objfile
;
2710 union sltentry
*sl_bufp
;
2712 while (s_idx
<= e_idx
)
2714 sl_bufp
= hpread_get_slt (s_idx
, objfile
);
2715 /* Only record "normal" entries in the SLT. */
2716 if (sl_bufp
->snorm
.sltdesc
== SLT_NORMAL
2717 || sl_bufp
->snorm
.sltdesc
== SLT_EXIT
)
2718 record_line (subfile
, sl_bufp
->snorm
.line
,
2719 sl_bufp
->snorm
.address
+ offset
);
2720 else if (sl_bufp
->snorm
.sltdesc
== SLT_NORMAL_OFFSET
)
2721 record_line (subfile
, sl_bufp
->snormoff
.line
,
2722 sl_bufp
->snormoff
.address
+ offset
);
2728 /* Given a function "f" which is a member of a class, find
2729 * the classname that it is a member of. Used to construct
2730 * the name (e.g., "c::f") which GDB will put in the
2731 * "demangled name" field of the function's symbol.
2732 * Called from hpread_process_one_debug_symbol()
2733 * If "f" is not a member function, return NULL.
2737 struct type
*functype
;
2739 struct type
*first_param_type
;
2740 char *first_param_name
;
2741 struct type
*pointed_to_type
;
2744 /* Check that the function has a first argument "this",
2745 * and that "this" is a pointer to a class. If not,
2746 * functype is not a member function, so return NULL.
2748 if (TYPE_NFIELDS (functype
) == 0)
2750 first_param_name
= TYPE_FIELD_NAME (functype
, 0);
2751 if (first_param_name
== NULL
)
2752 return NULL
; /* paranoia */
2753 if (strcmp (first_param_name
, "this"))
2755 first_param_type
= TYPE_FIELD_TYPE (functype
, 0);
2756 if (first_param_type
== NULL
)
2757 return NULL
; /* paranoia */
2758 if (TYPE_CODE (first_param_type
) != TYPE_CODE_PTR
)
2761 /* Get the thing that "this" points to, check that
2762 * it's a class, and get its class name.
2764 pointed_to_type
= TYPE_TARGET_TYPE (first_param_type
);
2765 if (pointed_to_type
== NULL
)
2766 return NULL
; /* paranoia */
2767 if (TYPE_CODE (pointed_to_type
) != TYPE_CODE_CLASS
)
2769 class_name
= TYPE_NAME (pointed_to_type
);
2770 if (class_name
== NULL
)
2771 return NULL
; /* paranoia */
2773 /* The class name may be of the form "class c", in which case
2774 * we want to strip off the leading "class ".
2776 if (strncmp (class_name
, "class ", 6) == 0)
2782 /* Internalize one native debug symbol.
2783 * Called in a loop from hpread_expand_symtab().
2792 * index: Index of this symbol
2793 * at_module_boundary_p Pointer to boolean flag to control caller's loop.
2797 hpread_process_one_debug_symbol (dn_bufp
, name
, section_offsets
, objfile
,
2798 text_offset
, text_size
, filename
,
2799 index
, at_module_boundary_p
2801 union dnttentry
*dn_bufp
;
2803 struct section_offsets
*section_offsets
;
2804 struct objfile
*objfile
;
2805 CORE_ADDR text_offset
;
2809 int *at_module_boundary_p
;
2814 int offset
= ANOFFSET (section_offsets
, SECT_OFF_TEXT (objfile
));
2815 int data_offset
= ANOFFSET (section_offsets
, SECT_OFF_DATA (objfile
));
2816 union dnttentry
*dn_temp
;
2817 dnttpointer hp_type
;
2819 struct context_stack
*new;
2820 char *class_scope_name
;
2822 /* Allocate one GDB debug symbol and fill in some default values. */
2823 sym
= (struct symbol
*) obstack_alloc (&objfile
->symbol_obstack
,
2824 sizeof (struct symbol
));
2825 memset (sym
, 0, sizeof (struct symbol
));
2826 SYMBOL_NAME (sym
) = obsavestring (name
, strlen (name
), &objfile
->symbol_obstack
);
2827 SYMBOL_LANGUAGE (sym
) = language_auto
;
2828 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
2829 SYMBOL_LINE (sym
) = 0;
2830 SYMBOL_VALUE (sym
) = 0;
2831 SYMBOL_CLASS (sym
) = LOC_TYPEDEF
;
2833 /* Just a trick in case the SOM debug symbol is a type definition.
2834 * There are routines that are set up to build a GDB type symbol, given
2835 * a SOM dnttpointer. So we set up a dummy SOM dnttpointer "hp_type".
2836 * This allows us to call those same routines.
2838 hp_type
.dnttp
.extension
= 1;
2839 hp_type
.dnttp
.immediate
= 0;
2840 hp_type
.dnttp
.global
= 0;
2841 hp_type
.dnttp
.index
= index
;
2843 /* This "type" is the type of SOM record.
2844 * Switch on SOM type.
2846 type
= dn_bufp
->dblock
.kind
;
2849 case DNTT_TYPE_SRCFILE
:
2850 /* This type of symbol indicates from which source file or
2851 * include file any following data comes. It may indicate:
2853 * o The start of an entirely new source file (and thus
2856 * o The start of a different source file due to #include
2858 * o The end of an include file and the return to the original
2859 * file. Thus if "foo.c" includes "bar.h", we see first
2860 * a SRCFILE for foo.c, then one for bar.h, and then one for
2863 * If it indicates the start of a new module then we must
2864 * finish the symbol table of the previous module
2865 * (if any) and start accumulating a new symbol table.
2869 if (!last_source_file
)
2872 * A note on "last_source_file": this is a char* pointing
2873 * to the actual file name. "start_symtab" sets it,
2874 * "end_symtab" clears it.
2876 * So if "last_source_file" is NULL, then either this is
2877 * the first record we are looking at, or a previous call
2878 * to "end_symtab()" was made to close out the previous
2879 * module. Since we're now quitting the scan loop when we
2880 * see a MODULE END record, we should never get here, except
2881 * in the case that we're not using the quick look-up tables
2882 * and have to use the old system as a fall-back.
2884 start_symtab (name
, NULL
, valu
);
2885 record_debugformat ("HP");
2886 SL_INDEX (objfile
) = dn_bufp
->dsfile
.address
;
2891 /* Either a new include file, or a SRCFILE record
2892 * saying we are back in the main source (or out of
2893 * a nested include file) again.
2895 SL_INDEX (objfile
) = hpread_record_lines (current_subfile
,
2897 dn_bufp
->dsfile
.address
,
2901 /* A note on "start_subfile". This routine will check
2902 * the name we pass it and look for an existing subfile
2903 * of that name. There's thus only one sub-file for the
2904 * actual source (e.g. for "foo.c" in foo.c), despite the
2905 * fact that we'll see lots of SRCFILE entries for foo.c
2908 start_subfile (name
, NULL
);
2911 case DNTT_TYPE_MODULE
:
2913 * We no longer ignore DNTT_TYPE_MODULE symbols. The module
2914 * represents the meaningful semantic structure of a compilation
2915 * unit. We expect to start the psymtab-to-symtab expansion
2916 * looking at a MODULE entry, and to end it at the corresponding
2919 *--Begin outdated comments
2921 * This record signifies the start of a new source module
2922 * In C/C++ there is no explicit "module" construct in the language,
2923 * but each compilation unit is implicitly a module and they
2924 * do emit the DNTT_TYPE_MODULE records.
2925 * The end of the module is marked by a matching DNTT_TYPE_END record.
2927 * The reason GDB gets away with ignoring the DNTT_TYPE_MODULE record
2928 * is it notices the DNTT_TYPE_END record for the previous
2929 * module (see comments under DNTT_TYPE_END case), and then treats
2930 * the next DNTT_TYPE_SRCFILE record as if it were the module-start record.
2931 * (i.e., it makes a start_symtab() call).
2932 * This scheme seems a little convoluted, but I'll leave it
2933 * alone on the principle "if it ain't broke don't fix
2936 *-- End outdated comments
2940 if (!last_source_file
)
2942 /* Start of a new module. We know this because "last_source_file"
2943 * is NULL, which can only happen the first time or if we just
2944 * made a call to end_symtab() to close out the previous module.
2946 start_symtab (name
, NULL
, valu
);
2947 SL_INDEX (objfile
) = dn_bufp
->dmodule
.address
;
2951 /* This really shouldn't happen if we're using the quick
2952 * look-up tables, as it would mean we'd scanned past an
2953 * END MODULE entry. But if we're not using the tables,
2954 * we started the module on the SRCFILE entry, so it's ok.
2955 * For now, accept this.
2957 /* warning( "Error expanding psymtab, missed module end, found entry for %s",
2960 *at_module_boundary_p
= -1;
2963 start_subfile (name
, NULL
);
2966 case DNTT_TYPE_FUNCTION
:
2967 case DNTT_TYPE_ENTRY
:
2968 /* A function or secondary entry point. */
2969 valu
= dn_bufp
->dfunc
.lowaddr
+ offset
;
2971 /* Record lines up to this point. */
2972 SL_INDEX (objfile
) = hpread_record_lines (current_subfile
,
2974 dn_bufp
->dfunc
.address
,
2977 WITHIN_FUNCTION (objfile
) = 1;
2978 CURRENT_FUNCTION_VALUE (objfile
) = valu
;
2980 /* Stack must be empty now. */
2981 if (context_stack_depth
!= 0)
2982 complain (&lbrac_unmatched_complaint
, (char *) symnum
);
2983 new = push_context (0, valu
);
2985 /* Built a type for the function. This includes processing
2986 * the symbol records for the function parameters.
2988 SYMBOL_CLASS (sym
) = LOC_BLOCK
;
2989 SYMBOL_TYPE (sym
) = hpread_read_function_type (hp_type
, dn_bufp
, objfile
, 1);
2991 /* The "SYMBOL_NAME" field is expected to be the mangled name
2992 * (if any), which we get from the "alias" field of the SOM record
2995 if ((dn_bufp
->dfunc
.language
== HP_LANGUAGE_CPLUSPLUS
) &&
2996 dn_bufp
->dfunc
.alias
&& /* has an alias */
2997 *(char *) (VT (objfile
) + dn_bufp
->dfunc
.alias
)) /* not a null string */
2998 SYMBOL_NAME (sym
) = VT (objfile
) + dn_bufp
->dfunc
.alias
;
3000 SYMBOL_NAME (sym
) = VT (objfile
) + dn_bufp
->dfunc
.name
;
3002 /* Special hack to get around HP compilers' insistence on
3003 * reporting "main" as "_MAIN_" for C/C++ */
3004 if ((strcmp (SYMBOL_NAME (sym
), "_MAIN_") == 0) &&
3005 (strcmp (VT (objfile
) + dn_bufp
->dfunc
.name
, "main") == 0))
3006 SYMBOL_NAME (sym
) = VT (objfile
) + dn_bufp
->dfunc
.name
;
3008 /* The SYMBOL_CPLUS_DEMANGLED_NAME field is expected to
3009 * be the demangled name.
3011 if (dn_bufp
->dfunc
.language
== HP_LANGUAGE_CPLUSPLUS
)
3013 /* SYMBOL_INIT_DEMANGLED_NAME is a macro which winds up
3014 * calling the demangler in libiberty (cplus_demangle()) to
3015 * do the job. This generally does the job, even though
3016 * it's intended for the GNU compiler and not the aCC compiler
3017 * Note that SYMBOL_INIT_DEMANGLED_NAME calls the
3018 * demangler with arguments DMGL_PARAMS | DMGL_ANSI.
3019 * Generally, we don't want params when we display
3020 * a demangled name, but when I took out the DMGL_PARAMS,
3021 * some things broke, so I'm leaving it in here, and
3022 * working around the issue in stack.c. - RT
3024 SYMBOL_INIT_DEMANGLED_NAME (sym
, &objfile
->symbol_obstack
);
3025 if ((SYMBOL_NAME (sym
) == VT (objfile
) + dn_bufp
->dfunc
.alias
) &&
3026 (!SYMBOL_CPLUS_DEMANGLED_NAME (sym
)))
3029 /* Well, the symbol name is mangled, but the
3030 * demangler in libiberty failed so the demangled
3031 * field is still NULL. Try to
3032 * do the job ourselves based on the "name" field
3033 * in the SOM record. A complication here is that
3034 * the name field contains only the function name
3035 * (like "f"), whereas we want the class qualification
3036 * (as in "c::f"). Try to reconstruct that.
3041 basename
= VT (objfile
) + dn_bufp
->dfunc
.name
;
3042 classname
= class_of (SYMBOL_TYPE (sym
));
3045 dem_name
= xmalloc (strlen (basename
) + strlen (classname
) + 3);
3046 strcpy (dem_name
, classname
);
3047 strcat (dem_name
, "::");
3048 strcat (dem_name
, basename
);
3049 SYMBOL_CPLUS_DEMANGLED_NAME (sym
) = dem_name
;
3050 SYMBOL_LANGUAGE (sym
) = language_cplus
;
3055 /* Add the function symbol to the list of symbols in this blockvector */
3056 if (dn_bufp
->dfunc
.global
)
3057 add_symbol_to_list (sym
, &global_symbols
);
3059 add_symbol_to_list (sym
, &file_symbols
);
3062 /* Search forward to the next BEGIN and also read
3063 * in the line info up to that point.
3064 * Not sure why this is needed.
3065 * In HP FORTRAN this code is harmful since there
3066 * may not be a BEGIN after the FUNCTION.
3067 * So I made it C/C++ specific. - RT
3069 if (dn_bufp
->dfunc
.language
== HP_LANGUAGE_C
||
3070 dn_bufp
->dfunc
.language
== HP_LANGUAGE_CPLUSPLUS
)
3072 while (dn_bufp
->dblock
.kind
!= DNTT_TYPE_BEGIN
)
3074 dn_bufp
= hpread_get_lntt (++index
, objfile
);
3075 if (dn_bufp
->dblock
.extension
)
3078 SL_INDEX (objfile
) = hpread_record_lines (current_subfile
,
3080 dn_bufp
->dbegin
.address
,
3082 SYMBOL_LINE (sym
) = hpread_get_line (dn_bufp
->dbegin
.address
, objfile
);
3084 record_line (current_subfile
, SYMBOL_LINE (sym
), valu
);
3087 case DNTT_TYPE_DOC_FUNCTION
:
3088 valu
= dn_bufp
->ddocfunc
.lowaddr
+ offset
;
3090 /* Record lines up to this point. */
3091 SL_INDEX (objfile
) = hpread_record_lines (current_subfile
,
3093 dn_bufp
->ddocfunc
.address
,
3096 WITHIN_FUNCTION (objfile
) = 1;
3097 CURRENT_FUNCTION_VALUE (objfile
) = valu
;
3098 /* Stack must be empty now. */
3099 if (context_stack_depth
!= 0)
3100 complain (&lbrac_unmatched_complaint
, (char *) symnum
);
3101 new = push_context (0, valu
);
3103 /* Built a type for the function. This includes processing
3104 * the symbol records for the function parameters.
3106 SYMBOL_CLASS (sym
) = LOC_BLOCK
;
3107 SYMBOL_TYPE (sym
) = hpread_read_doc_function_type (hp_type
, dn_bufp
, objfile
, 1);
3109 /* The "SYMBOL_NAME" field is expected to be the mangled name
3110 * (if any), which we get from the "alias" field of the SOM record
3113 if ((dn_bufp
->ddocfunc
.language
== HP_LANGUAGE_CPLUSPLUS
) &&
3114 dn_bufp
->ddocfunc
.alias
&& /* has an alias */
3115 *(char *) (VT (objfile
) + dn_bufp
->ddocfunc
.alias
)) /* not a null string */
3116 SYMBOL_NAME (sym
) = VT (objfile
) + dn_bufp
->ddocfunc
.alias
;
3118 SYMBOL_NAME (sym
) = VT (objfile
) + dn_bufp
->ddocfunc
.name
;
3120 /* Special hack to get around HP compilers' insistence on
3121 * reporting "main" as "_MAIN_" for C/C++ */
3122 if ((strcmp (SYMBOL_NAME (sym
), "_MAIN_") == 0) &&
3123 (strcmp (VT (objfile
) + dn_bufp
->ddocfunc
.name
, "main") == 0))
3124 SYMBOL_NAME (sym
) = VT (objfile
) + dn_bufp
->ddocfunc
.name
;
3126 if (dn_bufp
->ddocfunc
.language
== HP_LANGUAGE_CPLUSPLUS
)
3129 /* SYMBOL_INIT_DEMANGLED_NAME is a macro which winds up
3130 * calling the demangler in libiberty (cplus_demangle()) to
3131 * do the job. This generally does the job, even though
3132 * it's intended for the GNU compiler and not the aCC compiler
3133 * Note that SYMBOL_INIT_DEMANGLED_NAME calls the
3134 * demangler with arguments DMGL_PARAMS | DMGL_ANSI.
3135 * Generally, we don't want params when we display
3136 * a demangled name, but when I took out the DMGL_PARAMS,
3137 * some things broke, so I'm leaving it in here, and
3138 * working around the issue in stack.c. - RT
3140 SYMBOL_INIT_DEMANGLED_NAME (sym
, &objfile
->symbol_obstack
);
3142 if ((SYMBOL_NAME (sym
) == VT (objfile
) + dn_bufp
->ddocfunc
.alias
) &&
3143 (!SYMBOL_CPLUS_DEMANGLED_NAME (sym
)))
3146 /* Well, the symbol name is mangled, but the
3147 * demangler in libiberty failed so the demangled
3148 * field is still NULL. Try to
3149 * do the job ourselves based on the "name" field
3150 * in the SOM record. A complication here is that
3151 * the name field contains only the function name
3152 * (like "f"), whereas we want the class qualification
3153 * (as in "c::f"). Try to reconstruct that.
3158 basename
= VT (objfile
) + dn_bufp
->ddocfunc
.name
;
3159 classname
= class_of (SYMBOL_TYPE (sym
));
3162 dem_name
= xmalloc (strlen (basename
) + strlen (classname
) + 3);
3163 strcpy (dem_name
, classname
);
3164 strcat (dem_name
, "::");
3165 strcat (dem_name
, basename
);
3166 SYMBOL_CPLUS_DEMANGLED_NAME (sym
) = dem_name
;
3167 SYMBOL_LANGUAGE (sym
) = language_cplus
;
3172 /* Add the function symbol to the list of symbols in this blockvector */
3173 if (dn_bufp
->ddocfunc
.global
)
3174 add_symbol_to_list (sym
, &global_symbols
);
3176 add_symbol_to_list (sym
, &file_symbols
);
3179 /* Search forward to the next BEGIN and also read
3180 * in the line info up to that point.
3181 * Not sure why this is needed.
3182 * In HP FORTRAN this code is harmful since there
3183 * may not be a BEGIN after the FUNCTION.
3184 * So I made it C/C++ specific. - RT
3186 if (dn_bufp
->ddocfunc
.language
== HP_LANGUAGE_C
||
3187 dn_bufp
->ddocfunc
.language
== HP_LANGUAGE_CPLUSPLUS
)
3189 while (dn_bufp
->dblock
.kind
!= DNTT_TYPE_BEGIN
)
3191 dn_bufp
= hpread_get_lntt (++index
, objfile
);
3192 if (dn_bufp
->dblock
.extension
)
3195 SL_INDEX (objfile
) = hpread_record_lines (current_subfile
,
3197 dn_bufp
->dbegin
.address
,
3199 SYMBOL_LINE (sym
) = hpread_get_line (dn_bufp
->dbegin
.address
, objfile
);
3201 record_line (current_subfile
, SYMBOL_LINE (sym
), valu
);
3204 case DNTT_TYPE_BEGIN
:
3205 /* Begin a new scope. */
3206 if (context_stack_depth
== 1 /* this means we're at function level */ &&
3207 context_stack
[0].name
!= NULL
/* this means it's a function */ &&
3208 context_stack
[0].depth
== 0 /* this means it's the first BEGIN
3209 we've seen after the FUNCTION */
3212 /* This is the first BEGIN after a FUNCTION.
3213 * We ignore this one, since HP compilers always insert
3214 * at least one BEGIN, i.e. it's:
3220 * (possibly nested BEGIN ... END's if there are inner { } blocks)
3224 * By ignoring this first BEGIN, the local symbols get treated
3225 * as belonging to the function scope, and "print func::local_sym"
3226 * works (which is what we want).
3229 /* All we do here is increase the depth count associated with
3230 * the FUNCTION entry in the context stack. This ensures that
3231 * the next BEGIN we see (if any), representing a real nested { }
3232 * block, will get processed.
3235 context_stack
[0].depth
++;
3241 /* Record lines up to this SLT pointer. */
3242 SL_INDEX (objfile
) = hpread_record_lines (current_subfile
,
3244 dn_bufp
->dbegin
.address
,
3246 /* Calculate start address of new scope */
3247 valu
= hpread_get_location (dn_bufp
->dbegin
.address
, objfile
);
3248 valu
+= offset
; /* Relocate for dynamic loading */
3249 /* We use the scope start DNTT index as nesting depth identifier! */
3250 desc
= hpread_get_scope_start (dn_bufp
->dbegin
.address
, objfile
);
3251 new = push_context (desc
, valu
);
3258 /* Valid end kinds are:
3267 SL_INDEX (objfile
) = hpread_record_lines (current_subfile
,
3269 dn_bufp
->dend
.address
,
3271 switch (dn_bufp
->dend
.endkind
)
3273 case DNTT_TYPE_MODULE
:
3274 /* Ending a module ends the symbol table for that module.
3275 * Calling end_symtab() has the side effect of clearing the
3276 * last_source_file pointer, which in turn signals
3277 * process_one_debug_symbol() to treat the next DNTT_TYPE_SRCFILE
3278 * record as a module-begin.
3280 valu
= text_offset
+ text_size
+ offset
;
3282 /* Tell our caller that we're done with expanding the
3283 * debug information for a module.
3285 *at_module_boundary_p
= 1;
3287 /* Don't do this, as our caller will do it!
3289 * (void) end_symtab (valu, objfile, 0);
3293 case DNTT_TYPE_FUNCTION
:
3294 /* Ending a function, well, ends the function's scope. */
3295 dn_temp
= hpread_get_lntt (dn_bufp
->dend
.beginscope
.dnttp
.index
,
3297 valu
= dn_temp
->dfunc
.hiaddr
+ offset
;
3298 /* Insert func params into local list */
3299 merge_symbol_lists (¶m_symbols
, &local_symbols
);
3300 new = pop_context ();
3301 /* Make a block for the local symbols within. */
3302 finish_block (new->name
, &local_symbols
, new->old_blocks
,
3303 new->start_addr
, valu
, objfile
);
3304 WITHIN_FUNCTION (objfile
) = 0; /* This may have to change for Pascal */
3305 local_symbols
= new->locals
;
3306 param_symbols
= new->params
;
3309 case DNTT_TYPE_BEGIN
:
3310 if (context_stack_depth
== 1 &&
3311 context_stack
[0].name
!= NULL
&&
3312 context_stack
[0].depth
== 1)
3314 /* This is the END corresponding to the
3315 * BEGIN which we ignored - see DNTT_TYPE_BEGIN case above.
3317 context_stack
[0].depth
--;
3321 /* Ending a local scope. */
3322 valu
= hpread_get_location (dn_bufp
->dend
.address
, objfile
);
3323 /* Why in the hell is this needed? */
3324 valu
+= offset
+ 9; /* Relocate for dynamic loading */
3325 new = pop_context ();
3326 desc
= dn_bufp
->dend
.beginscope
.dnttp
.index
;
3327 if (desc
!= new->depth
)
3328 complain (&lbrac_mismatch_complaint
, (char *) symnum
);
3330 /* Make a block for the local symbols within. */
3331 finish_block (new->name
, &local_symbols
, new->old_blocks
,
3332 new->start_addr
, valu
, objfile
);
3333 local_symbols
= new->locals
;
3334 param_symbols
= new->params
;
3338 case DNTT_TYPE_WITH
:
3339 /* Since we ignore the DNTT_TYPE_WITH that starts the scope,
3340 * we can ignore the DNTT_TYPE_END that ends it.
3344 case DNTT_TYPE_COMMON
:
3345 /* End a FORTRAN common block. We don't currently handle these */
3346 complain (&hpread_unhandled_end_common_complaint
);
3349 case DNTT_TYPE_CLASS_SCOPE
:
3351 /* pai: FIXME Not handling nested classes for now -- must
3352 * maintain a stack */
3353 class_scope_name
= NULL
;
3356 /* End a class scope */
3357 valu
= hpread_get_location (dn_bufp
->dend
.address
, objfile
);
3358 /* Why in the hell is this needed? */
3359 valu
+= offset
+ 9; /* Relocate for dynamic loading */
3360 new = pop_context ();
3361 desc
= dn_bufp
->dend
.beginscope
.dnttp
.index
;
3362 if (desc
!= new->depth
)
3363 complain (&lbrac_mismatch_complaint
, (char *) symnum
);
3364 /* Make a block for the local symbols within. */
3365 finish_block (new->name
, &local_symbols
, new->old_blocks
,
3366 new->start_addr
, valu
, objfile
);
3367 local_symbols
= new->locals
;
3368 param_symbols
= new->params
;
3373 complain (&hpread_unexpected_end_complaint
);
3378 /* DNTT_TYPE_IMPORT is not handled */
3380 case DNTT_TYPE_LABEL
:
3381 SYMBOL_NAMESPACE (sym
) = LABEL_NAMESPACE
;
3384 case DNTT_TYPE_FPARAM
:
3385 /* Function parameters. */
3386 /* Note 1: This code was present in the 4.16 sources, and then
3387 removed, because fparams are handled in
3388 hpread_read_function_type(). However, while fparam symbols
3389 are indeed handled twice, this code here cannot be removed
3390 because then they don't get added to the local symbol list of
3391 the function's code block, which leads to a failure to look
3392 up locals, "this"-relative member names, etc. So I've put
3393 this code back in. pai/1997-07-21 */
3394 /* Note 2: To fix a defect, we stopped adding FPARAMS to local_symbols
3395 in hpread_read_function_type(), so FPARAMS had to be handled
3396 here. I changed the location to be the appropriate argument
3397 kinds rather than LOC_LOCAL. pai/1997-08-08 */
3398 /* Note 3: Well, the fix in Note 2 above broke argument printing
3399 in traceback frames, and further it makes assumptions about the
3400 order of the FPARAM entries from HP compilers (cc and aCC in particular
3401 generate them in reverse orders -- fixing one breaks for the other).
3402 So I've added code in hpread_read_function_type() to add fparams
3403 to a param_symbols list for the current context level. These are
3404 then merged into local_symbols when a function end is reached.
3407 break; /* do nothing; handled in hpread_read_function_type() */
3409 #if 0 /* Old code */
3410 if (dn_bufp
->dfparam
.regparam
)
3411 SYMBOL_CLASS (sym
) = LOC_REGISTER
;
3412 else if (dn_bufp
->dfparam
.indirect
)
3413 SYMBOL_CLASS (sym
) = LOC_REF_ARG
;
3415 SYMBOL_CLASS (sym
) = LOC_ARG
;
3416 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
3417 if (dn_bufp
->dfparam
.copyparam
)
3419 SYMBOL_VALUE (sym
) = dn_bufp
->dfparam
.location
;
3420 #ifdef HPREAD_ADJUST_STACK_ADDRESS
3422 += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile
));
3426 SYMBOL_VALUE (sym
) = dn_bufp
->dfparam
.location
;
3427 SYMBOL_TYPE (sym
) = hpread_type_lookup (dn_bufp
->dfparam
.type
, objfile
);
3428 add_symbol_to_list (sym
, &fparam_symbols
);
3432 case DNTT_TYPE_SVAR
:
3433 /* Static variables. */
3434 SYMBOL_CLASS (sym
) = LOC_STATIC
;
3436 /* Note: There is a case that arises with globals in shared
3437 * libraries where we need to set the address to LOC_INDIRECT.
3438 * This case is if you have a global "g" in one library, and
3439 * it is referenced "extern <type> g;" in another library.
3440 * If we're processing the symbols for the referencing library,
3441 * we'll see a global "g", but in this case the address given
3442 * in the symbol table contains a pointer to the real "g".
3443 * We use the storage class LOC_INDIRECT to indicate this. RT
3445 if (is_in_import_list (SYMBOL_NAME (sym
), objfile
))
3446 SYMBOL_CLASS (sym
) = LOC_INDIRECT
;
3448 SYMBOL_VALUE_ADDRESS (sym
) = dn_bufp
->dsvar
.location
+ data_offset
;
3449 SYMBOL_TYPE (sym
) = hpread_type_lookup (dn_bufp
->dsvar
.type
, objfile
);
3451 if (dn_bufp
->dsvar
.global
)
3452 add_symbol_to_list (sym
, &global_symbols
);
3454 else if (WITHIN_FUNCTION (objfile
))
3455 add_symbol_to_list (sym
, &local_symbols
);
3458 add_symbol_to_list (sym
, &file_symbols
);
3460 if (dn_bufp
->dsvar
.thread_specific
)
3462 /* Thread-local variable.
3464 SYMBOL_CLASS (sym
) = LOC_THREAD_LOCAL_STATIC
;
3465 SYMBOL_BASEREG (sym
) = CR27_REGNUM
;
3467 if (objfile
->flags
& OBJF_SHARED
)
3470 * This variable is not only thread local but
3471 * in a shared library.
3473 * Alas, the shared lib structures are private
3474 * to "somsolib.c". But C lets us point to one.
3478 if (objfile
->obj_private
== NULL
)
3479 error ("Internal error in reading shared library information.");
3481 so
= ((obj_private_data_t
*) (objfile
->obj_private
))->so_info
;
3483 error ("Internal error in reading shared library information.");
3485 /* Thread-locals in shared libraries do NOT have the
3486 * standard offset ("data_offset"), so we re-calculate
3487 * where to look for this variable, using a call-back
3488 * to interpret the private shared-library data.
3490 SYMBOL_VALUE_ADDRESS (sym
) = dn_bufp
->dsvar
.location
+
3491 so_lib_thread_start_addr (so
);
3496 case DNTT_TYPE_DVAR
:
3497 /* Dynamic variables. */
3498 if (dn_bufp
->ddvar
.regvar
)
3499 SYMBOL_CLASS (sym
) = LOC_REGISTER
;
3501 SYMBOL_CLASS (sym
) = LOC_LOCAL
;
3503 SYMBOL_VALUE (sym
) = dn_bufp
->ddvar
.location
;
3504 #ifdef HPREAD_ADJUST_STACK_ADDRESS
3506 += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile
));
3508 SYMBOL_TYPE (sym
) = hpread_type_lookup (dn_bufp
->ddvar
.type
, objfile
);
3509 if (dn_bufp
->ddvar
.global
)
3510 add_symbol_to_list (sym
, &global_symbols
);
3511 else if (WITHIN_FUNCTION (objfile
))
3512 add_symbol_to_list (sym
, &local_symbols
);
3514 add_symbol_to_list (sym
, &file_symbols
);
3517 case DNTT_TYPE_CONST
:
3518 /* A constant (pascal?). */
3519 SYMBOL_CLASS (sym
) = LOC_CONST
;
3520 SYMBOL_VALUE (sym
) = dn_bufp
->dconst
.location
;
3521 SYMBOL_TYPE (sym
) = hpread_type_lookup (dn_bufp
->dconst
.type
, objfile
);
3522 if (dn_bufp
->dconst
.global
)
3523 add_symbol_to_list (sym
, &global_symbols
);
3524 else if (WITHIN_FUNCTION (objfile
))
3525 add_symbol_to_list (sym
, &local_symbols
);
3527 add_symbol_to_list (sym
, &file_symbols
);
3530 case DNTT_TYPE_TYPEDEF
:
3531 /* A typedef. We do want to process these, since a name is
3532 * added to the namespace for the typedef'ed name.
3534 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
3535 SYMBOL_TYPE (sym
) = hpread_type_lookup (dn_bufp
->dtype
.type
, objfile
);
3536 if (dn_bufp
->dtype
.global
)
3537 add_symbol_to_list (sym
, &global_symbols
);
3538 else if (WITHIN_FUNCTION (objfile
))
3539 add_symbol_to_list (sym
, &local_symbols
);
3541 add_symbol_to_list (sym
, &file_symbols
);
3544 case DNTT_TYPE_TAGDEF
:
3546 int global
= dn_bufp
->dtag
.global
;
3547 /* Structure, union, enum, template, or class tag definition */
3548 /* We do want to process these, since a name is
3549 * added to the namespace for the tag name (and if C++ class,
3550 * for the typename also).
3552 SYMBOL_NAMESPACE (sym
) = STRUCT_NAMESPACE
;
3554 /* The tag contains in its "type" field a pointer to the
3555 * DNTT_TYPE_STRUCT, DNTT_TYPE_UNION, DNTT_TYPE_ENUM,
3556 * DNTT_TYPE_CLASS or DNTT_TYPE_TEMPLATE
3557 * record that actually defines the type.
3559 SYMBOL_TYPE (sym
) = hpread_type_lookup (dn_bufp
->dtype
.type
, objfile
);
3560 TYPE_NAME (sym
->type
) = SYMBOL_NAME (sym
);
3561 TYPE_TAG_NAME (sym
->type
) = SYMBOL_NAME (sym
);
3562 if (dn_bufp
->dtag
.global
)
3563 add_symbol_to_list (sym
, &global_symbols
);
3564 else if (WITHIN_FUNCTION (objfile
))
3565 add_symbol_to_list (sym
, &local_symbols
);
3567 add_symbol_to_list (sym
, &file_symbols
);
3569 /* If this is a C++ class, then we additionally
3570 * need to define a typedef for the
3571 * class type. E.g., so that the name "c" becomes visible as
3572 * a type name when the user says "class c { ... }".
3573 * In order to figure this out, we need to chase down the "type"
3574 * field to get to the DNTT_TYPE_CLASS record.
3576 * We also add the typename for ENUM. Though this isn't
3577 * strictly correct, it is necessary because of the debug info
3578 * generated by the aCC compiler, in which we cannot
3579 * distinguish between:
3582 * typedef enum { ... } e;
3583 * I.e., the compiler emits the same debug info for the above
3584 * two cases, in both cases "e" appearing as a tagdef.
3585 * Therefore go ahead and generate the typename so that
3586 * "ptype e" will work in the above cases.
3588 * We also add the typename for TEMPLATE, so as to allow "ptype t"
3589 * when "t" is a template name.
3591 if (dn_bufp
->dtype
.type
.dnttp
.index
< LNTT_SYMCOUNT (objfile
))
3592 dn_bufp
= hpread_get_lntt (dn_bufp
->dtag
.type
.dnttp
.index
, objfile
);
3595 complain (&hpread_tagdef_complaint
);
3598 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_CLASS
||
3599 dn_bufp
->dblock
.kind
== DNTT_TYPE_ENUM
||
3600 dn_bufp
->dblock
.kind
== DNTT_TYPE_TEMPLATE
)
3602 struct symbol
*newsym
;
3604 newsym
= (struct symbol
*) obstack_alloc (&objfile
->symbol_obstack
,
3605 sizeof (struct symbol
));
3606 memset (newsym
, 0, sizeof (struct symbol
));
3607 SYMBOL_NAME (newsym
) = name
;
3608 SYMBOL_LANGUAGE (newsym
) = language_auto
;
3609 SYMBOL_NAMESPACE (newsym
) = VAR_NAMESPACE
;
3610 SYMBOL_LINE (newsym
) = 0;
3611 SYMBOL_VALUE (newsym
) = 0;
3612 SYMBOL_CLASS (newsym
) = LOC_TYPEDEF
;
3613 SYMBOL_TYPE (newsym
) = sym
->type
;
3615 add_symbol_to_list (newsym
, &global_symbols
);
3616 else if (WITHIN_FUNCTION (objfile
))
3617 add_symbol_to_list (newsym
, &local_symbols
);
3619 add_symbol_to_list (newsym
, &file_symbols
);
3624 case DNTT_TYPE_POINTER
:
3625 /* Declares a pointer type. Should not be necessary to do anything
3626 * with the type at this level; these are processed
3627 * at the hpread_type_lookup() level.
3631 case DNTT_TYPE_ENUM
:
3632 /* Declares an enum type. Should not be necessary to do anything
3633 * with the type at this level; these are processed
3634 * at the hpread_type_lookup() level.
3638 case DNTT_TYPE_MEMENUM
:
3639 /* Member of enum */
3640 /* Ignored at this level, but hpread_read_enum_type() will take
3641 * care of walking the list of enumeration members.
3646 /* Declares a set type. Should not be necessary to do anything
3647 * with the type at this level; these are processed
3648 * at the hpread_type_lookup() level.
3652 case DNTT_TYPE_SUBRANGE
:
3653 /* Declares a subrange type. Should not be necessary to do anything
3654 * with the type at this level; these are processed
3655 * at the hpread_type_lookup() level.
3659 case DNTT_TYPE_ARRAY
:
3660 /* Declares an array type. Should not be necessary to do anything
3661 * with the type at this level; these are processed
3662 * at the hpread_type_lookup() level.
3666 case DNTT_TYPE_STRUCT
:
3667 case DNTT_TYPE_UNION
:
3668 /* Declares an struct/union type.
3669 * Should not be necessary to do anything
3670 * with the type at this level; these are processed
3671 * at the hpread_type_lookup() level.
3675 case DNTT_TYPE_FIELD
:
3676 /* Structure/union/class field */
3677 /* Ignored at this level, but hpread_read_struct_type() will take
3678 * care of walking the list of structure/union/class members.
3682 /* DNTT_TYPE_VARIANT is not handled by GDB */
3684 /* DNTT_TYPE_FILE is not handled by GDB */
3686 case DNTT_TYPE_FUNCTYPE
:
3688 /* Ignored at this level, handled within hpread_type_lookup() */
3691 case DNTT_TYPE_WITH
:
3692 /* This is emitted within methods to indicate "with <class>"
3693 * scoping rules (i.e., indicate that the class data members
3694 * are directly visible).
3695 * However, since GDB already infers this by looking at the
3696 * "this" argument, interpreting the DNTT_TYPE_WITH
3697 * symbol record is unnecessary.
3701 case DNTT_TYPE_COMMON
:
3702 /* FORTRAN common. Not yet handled. */
3703 complain (&hpread_unhandled_common_complaint
);
3706 /* DNTT_TYPE_COBSTRUCT is not handled by GDB. */
3707 /* DNTT_TYPE_XREF is not handled by GDB. */
3708 /* DNTT_TYPE_SA is not handled by GDB. */
3709 /* DNTT_TYPE_MACRO is not handled by GDB */
3711 case DNTT_TYPE_BLOCKDATA
:
3712 /* Not sure what this is - part of FORTRAN support maybe?
3713 * Anyway, not yet handled.
3715 complain (&hpread_unhandled_blockdata_complaint
);
3718 case DNTT_TYPE_CLASS_SCOPE
:
3722 /* The compiler brackets member functions with a CLASS_SCOPE/END
3723 * pair of records, presumably to put them in a different scope
3724 * from the module scope where they are normally defined.
3725 * E.g., in the situation:
3727 * void c::f() { ...}
3728 * The member function "c::f" will be bracketed by a CLASS_SCOPE/END.
3729 * This causes "break f" at the module level to pick the
3730 * the file-level function f(), not the member function
3731 * (which needs to be referenced via "break c::f").
3733 * Here we record the class name to generate the demangled names of
3734 * member functions later.
3736 * FIXME Not being used now for anything -- cplus_demangle seems
3737 * enough for getting the class-qualified names of functions. We
3738 * may need this for handling nested classes and types. */
3740 /* pai: FIXME Not handling nested classes for now -- need to
3741 * maintain a stack */
3743 dn_temp
= hpread_get_lntt (dn_bufp
->dclass_scope
.type
.dnttp
.index
, objfile
);
3744 if (dn_temp
->dblock
.kind
== DNTT_TYPE_TAGDEF
)
3745 class_scope_name
= VT (objfile
) + dn_temp
->dtag
.name
;
3747 class_scope_name
= NULL
;
3751 /* Begin a new scope. */
3752 SL_INDEX (objfile
) = hpread_record_lines (current_subfile
,
3754 dn_bufp
->dclass_scope
.address
,
3756 valu
= hpread_get_location (dn_bufp
->dclass_scope
.address
, objfile
);
3757 valu
+= offset
; /* Relocate for dynamic loading */
3758 desc
= hpread_get_scope_start (dn_bufp
->dclass_scope
.address
, objfile
);
3759 /* We use the scope start DNTT index as the nesting depth identifier! */
3760 new = push_context (desc
, valu
);
3764 case DNTT_TYPE_REFERENCE
:
3765 /* Declares a C++ reference type. Should not be necessary to do anything
3766 * with the type at this level; these are processed
3767 * at the hpread_type_lookup() level.
3771 case DNTT_TYPE_PTRMEM
:
3772 /* Declares a C++ pointer-to-data-member type. This does not
3773 * need to be handled at this level; being a type description it
3774 * is instead handled at the hpread_type_lookup() level.
3778 case DNTT_TYPE_PTRMEMFUNC
:
3779 /* Declares a C++ pointer-to-function-member type. This does not
3780 * need to be handled at this level; being a type description it
3781 * is instead handled at the hpread_type_lookup() level.
3785 case DNTT_TYPE_CLASS
:
3786 /* Declares a class type.
3787 * Should not be necessary to do anything
3788 * with the type at this level; these are processed
3789 * at the hpread_type_lookup() level.
3793 case DNTT_TYPE_GENFIELD
:
3794 /* I believe this is used for class member functions */
3795 /* Ignored at this level, but hpread_read_struct_type() will take
3796 * care of walking the list of class members.
3800 case DNTT_TYPE_VFUNC
:
3801 /* Virtual function */
3802 /* This does not have to be handled at this level; handled in
3803 * the course of processing class symbols.
3807 case DNTT_TYPE_MEMACCESS
:
3808 /* DDE ignores this symbol table record.
3809 * It has something to do with "modified access" to class members.
3810 * I'll assume we can safely ignore it too.
3814 case DNTT_TYPE_INHERITANCE
:
3815 /* These don't have to be handled here, since they are handled
3816 * within hpread_read_struct_type() in the process of constructing
3821 case DNTT_TYPE_FRIEND_CLASS
:
3822 case DNTT_TYPE_FRIEND_FUNC
:
3823 /* These can safely be ignored, as GDB doesn't need this
3824 * info. DDE only uses it in "describe". We may later want
3825 * to extend GDB's "ptype" to give this info, but for now
3826 * it seems safe enough to ignore it.
3830 case DNTT_TYPE_MODIFIER
:
3831 /* Intended to supply "modified access" to a type */
3832 /* From the way DDE handles this, it looks like it always
3833 * modifies a type. Therefore it is safe to ignore it at this
3834 * level, and handle it in hpread_type_lookup().
3838 case DNTT_TYPE_OBJECT_ID
:
3839 /* Just ignore this - that's all DDE does */
3842 case DNTT_TYPE_MEMFUNC
:
3843 /* Member function */
3844 /* This does not have to be handled at this level; handled in
3845 * the course of processing class symbols.
3849 case DNTT_TYPE_DOC_MEMFUNC
:
3850 /* Member function */
3851 /* This does not have to be handled at this level; handled in
3852 * the course of processing class symbols.
3856 case DNTT_TYPE_TEMPLATE
:
3857 /* Template - sort of the header for a template definition,
3858 * which like a class, points to a member list and also points
3859 * to a TEMPLATE_ARG list of type-arguments.
3860 * We do not need to process TEMPLATE records at this level though.
3864 case DNTT_TYPE_TEMPLATE_ARG
:
3865 /* The TEMPLATE record points to an argument list of
3866 * TEMPLATE_ARG records, each of which describes one
3867 * of the type-arguments.
3868 * We do not need to process TEMPLATE_ARG records at this level though.
3872 case DNTT_TYPE_FUNC_TEMPLATE
:
3873 /* This will get emitted for member functions of templates.
3874 * But we don't need to process this record at this level though,
3875 * we will process it in the course of processing a TEMPLATE
3880 case DNTT_TYPE_LINK
:
3881 /* The LINK record is used to link up templates with instantiations. */
3882 /* It is not clear why this is needed, and furthermore aCC does
3883 * not appear to generate this, so I think we can safely ignore it. - RT
3887 /* DNTT_TYPE_DYN_ARRAY_DESC is not handled by GDB */
3888 /* DNTT_TYPE_DESC_SUBRANGE is not handled by GDB */
3889 /* DNTT_TYPE_BEGIN_EXT is not handled by GDB */
3890 /* DNTT_TYPE_INLN is not handled by GDB */
3891 /* DNTT_TYPE_INLN_LIST is not handled by GDB */
3892 /* DNTT_TYPE_ALIAS is not handled by GDB */
3899 /* Get nesting depth for a DNTT entry.
3900 * DN_BUFP points to a DNTT entry.
3901 * OBJFILE is the object file.
3902 * REPORT_NESTED is a flag; if 0, real nesting depth is
3903 * reported, if it is 1, the function simply returns a
3904 * non-zero value if the nesting depth is anything > 0.
3906 * Return value is an integer. 0 => not a local type / name
3907 * positive return => type or name is local to some
3908 * block or function.
3912 /* elz: ATTENTION: FIXME: NOTE: WARNING!!!!
3913 this function now returns 0 right away. It was taking too much time
3914 at start up. Now, though, the local types are not handled correctly.
3919 hpread_get_scope_depth (dn_bufp
, objfile
, report_nested
)
3920 union dnttentry
*dn_bufp
;
3921 struct objfile
*objfile
;
3925 register union dnttentry
*dn_tmp
;
3926 register short depth
= 0;
3927 /****************************/
3929 /****************************/
3931 index
= (((char *) dn_bufp
) - LNTT (objfile
)) / (sizeof (struct dntt_type_block
));
3933 while (--index
>= 0)
3935 dn_tmp
= hpread_get_lntt (index
, objfile
);
3936 switch (dn_tmp
->dblock
.kind
)
3938 case DNTT_TYPE_MODULE
:
3941 /* index is signed int; dnttp.index is 29-bit unsigned int! */
3942 index
= (int) dn_tmp
->dend
.beginscope
.dnttp
.index
;
3944 case DNTT_TYPE_BEGIN
:
3945 case DNTT_TYPE_FUNCTION
:
3946 case DNTT_TYPE_DOC_FUNCTION
:
3947 case DNTT_TYPE_WITH
:
3948 case DNTT_TYPE_COMMON
:
3949 case DNTT_TYPE_CLASS_SCOPE
:
3961 /* Adjust the bitoffsets for all fields of an anonymous union of
3962 type TYPE by negative BITS. This handles HP aCC's hideous habit
3963 of giving members of anonymous unions bit offsets relative to the
3964 enclosing structure instead of relative to the union itself. */
3967 hpread_adjust_bitoffsets (type
, bits
)
3973 /* This is done only for unions; caller had better check that
3974 it is an anonymous one. */
3975 if (TYPE_CODE (type
) != TYPE_CODE_UNION
)
3978 /* Adjust each field; since this is a union, there are no base
3979 classes. Also no static membes. Also, no need for recursion as
3980 the members of this union if themeselves structs or unions, have
3981 the correct bitoffsets; if an anonymous union is a member of this
3982 anonymous union, the code in hpread_read_struct_type() will
3985 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
3986 TYPE_FIELD_BITPOS (type
, i
) -= bits
;
3989 /* Because of quirks in HP compilers' treatment of anonymous unions inside
3990 classes, we have to chase through a chain of threaded FIELD entries.
3991 If we encounter an anonymous union in the chain, we must recursively skip over
3994 This function does a "next" in the chain of FIELD entries, but transparently
3995 skips over anonymous unions' fields (recursively).
3997 Inputs are the number of times to do "next" at the top level, the dnttpointer
3998 (FIELD) and entry pointer (FIELDP) for the dntt record corresponding to it,
3999 and the ubiquitous objfile parameter. (Note: FIELDP is a **.) Return value
4000 is a dnttpointer for the new field after all the skipped ones */
4003 hpread_get_next_skip_over_anon_unions (skip_fields
, field
, fieldp
, objfile
)
4006 union dnttentry
**fieldp
;
4007 struct objfile
*objfile
;
4009 struct type
*anon_type
;
4014 for (i
= 0; i
< skip_fields
; i
++)
4016 /* Get type of item we're looking at now; recursively processes the types
4017 of these intermediate items we skip over, so they aren't lost. */
4018 anon_type
= hpread_type_lookup ((*fieldp
)->dfield
.type
, objfile
);
4019 anon_type
= CHECK_TYPEDEF (anon_type
);
4020 bitoffset
= (*fieldp
)->dfield
.bitoffset
;
4021 name
= VT (objfile
) + (*fieldp
)->dfield
.name
;
4022 /* First skip over one item to avoid stack death on recursion */
4023 field
= (*fieldp
)->dfield
.nextfield
;
4024 *fieldp
= hpread_get_lntt (field
.dnttp
.index
, objfile
);
4025 /* Do we have another anonymous union? If so, adjust the bitoffsets
4026 of its members and skip over its members. */
4027 if ((TYPE_CODE (anon_type
) == TYPE_CODE_UNION
) &&
4028 (!name
|| STREQ (name
, "")))
4030 hpread_adjust_bitoffsets (anon_type
, bitoffset
);
4031 field
= hpread_get_next_skip_over_anon_unions (TYPE_NFIELDS (anon_type
), field
, fieldp
, objfile
);