1 /* Read hp debug symbols and convert to internal format, for GDB.
2 Copyright 1993 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., 675 Mass Ave, Cambridge, MA 02139, USA.
20 Written by the Center for Software Science at the University of Utah
21 and by Cygnus Support. */
26 #include "hpux-symtab.h"
32 #include "complaints.h"
33 #include "gdb-stabs.h"
36 /* Private information attached to an objfile which we use to find
37 and internalize the HP C debug symbols within that objfile. */
39 struct hpread_symfile_info
41 /* The contents of each of the debug sections (there are 4 of them). */
47 /* We keep the size of the $VT$ section for range checking. */
50 /* Some routines still need to know the number of symbols in the
51 main debug sections ($LNTT$ and $GNTT$). */
52 unsigned int lntt_symcount;
53 unsigned int gntt_symcount;
55 /* To keep track of all the types we've processed. */
56 struct type **type_vector;
57 int type_vector_length;
59 /* Keeps track of the beginning of a range of source lines. */
62 /* Some state variables we'll need. */
65 /* Keep track of the current function's address. We may need to look
66 up something based on this address. */
67 unsigned int current_function_value;
71 /* Accessor macros to get at the fields. */
72 #define HPUX_SYMFILE_INFO(o) \
73 ((struct hpread_symfile_info *)((o)->sym_private))
74 #define GNTT(o) (HPUX_SYMFILE_INFO(o)->gntt)
75 #define LNTT(o) (HPUX_SYMFILE_INFO(o)->lntt)
76 #define SLT(o) (HPUX_SYMFILE_INFO(o)->slt)
77 #define VT(o) (HPUX_SYMFILE_INFO(o)->vt)
78 #define VT_SIZE(o) (HPUX_SYMFILE_INFO(o)->vt_size)
79 #define LNTT_SYMCOUNT(o) (HPUX_SYMFILE_INFO(o)->lntt_symcount)
80 #define GNTT_SYMCOUNT(o) (HPUX_SYMFILE_INFO(o)->gntt_symcount)
81 #define TYPE_VECTOR(o) (HPUX_SYMFILE_INFO(o)->type_vector)
82 #define TYPE_VECTOR_LENGTH(o) (HPUX_SYMFILE_INFO(o)->type_vector_length)
83 #define SL_INDEX(o) (HPUX_SYMFILE_INFO(o)->sl_index)
84 #define WITHIN_FUNCTION(o) (HPUX_SYMFILE_INFO(o)->within_function)
85 #define CURRENT_FUNCTION_VALUE(o) (HPUX_SYMFILE_INFO(o)->current_function_value)
87 /* Given the native debug symbol SYM, set NAMEP to the name associated
88 with the debug symbol. Note we may be called with a debug symbol which
89 has no associated name, in that case we return an empty string.
91 Also note we "know" that the name for any symbol is always in the
92 same place. Hence we don't have to conditionalize on the symbol type. */
93 #define SET_NAMESTRING(SYM, NAMEP, OBJFILE) \
94 if (! hpread_has_name ((SYM)->dblock.kind)) \
96 else if (((unsigned)(SYM)->dsfile.name) >= VT_SIZE (OBJFILE)) \
98 complain (&string_table_offset_complaint, (char *) symnum); \
102 *NAMEP = (SYM)->dsfile.name + VT (OBJFILE)
104 /* Each partial symbol table entry contains a pointer to private data for the
105 read_symtab() function to use when expanding a partial symbol table entry
106 to a full symbol table entry.
108 For hpuxread this structure contains the offset within the file symbol table
109 of first local symbol for this file, and length (in bytes) of the section
110 of the symbol table devoted to this file's symbols (actually, the section
111 bracketed may contain more than just this file's symbols).
113 If ldsymlen is 0, the only reason for this thing's existence is the
114 dependency list. Nothing else will happen when it is read in. */
116 #define LDSYMOFF(p) (((struct symloc *)((p)->read_symtab_private))->ldsymoff)
117 #define LDSYMLEN(p) (((struct symloc *)((p)->read_symtab_private))->ldsymlen)
118 #define SYMLOC(p) ((struct symloc *)((p)->read_symtab_private))
126 /* FIXME: Shouldn't this stuff be in a .h file somewhere? */
127 /* Nonzero means give verbose info on gdb action. */
128 extern int info_verbose;
130 /* Complaints about the symbols we have encountered. */
131 extern struct complaint string_table_offset_complaint;
132 extern struct complaint lbrac_unmatched_complaint;
133 extern struct complaint lbrac_mismatch_complaint;
136 void hpread_symfile_init PARAMS ((struct objfile *));
138 static struct type *hpread_alloc_type
139 PARAMS ((DNTTPOINTER, struct objfile *));
141 static struct type **hpread_lookup_type
142 PARAMS ((DNTTPOINTER, struct objfile *));
144 static struct type *hpread_read_enum_type
145 PARAMS ((DNTTPOINTER, union dnttentry *, struct objfile *));
147 static struct type *hpread_read_set_type
148 PARAMS ((DNTTPOINTER, union dnttentry *, struct objfile *));
150 static struct type *hpread_read_subrange_type
151 PARAMS ((DNTTPOINTER, union dnttentry *, struct objfile *));
153 static struct type *hpread_read_struct_type
154 PARAMS ((DNTTPOINTER, union dnttentry *, struct objfile *));
156 void hpread_build_psymtabs
157 PARAMS ((struct objfile *, struct section_offsets *, int));
159 void hpread_symfile_finish PARAMS ((struct objfile *));
161 static struct partial_symtab *hpread_start_psymtab
162 PARAMS ((struct objfile *, struct section_offsets *, char *, CORE_ADDR, int,
163 struct partial_symbol *, struct partial_symbol *));
165 static struct partial_symtab *hpread_end_psymtab
166 PARAMS ((struct partial_symtab *, char **, int, int, CORE_ADDR,
167 struct partial_symtab **, int));
169 static struct symtab *hpread_expand_symtab
170 PARAMS ((struct objfile *, int, int, CORE_ADDR, int,
171 struct section_offsets *, char *));
173 static void hpread_process_one_debug_symbol
174 PARAMS ((union dnttentry *, char *, struct section_offsets *,
175 struct objfile *, CORE_ADDR, int, char *, int));
177 static SLTPOINTER hpread_record_lines
178 PARAMS ((struct subfile *, SLTPOINTER, SLTPOINTER, struct objfile *));
180 static struct type *hpread_read_function_type
181 PARAMS ((DNTTPOINTER, union dnttentry *, struct objfile *));
183 static struct type * hpread_type_lookup
184 PARAMS ((DNTTPOINTER, struct objfile *));
186 static unsigned long hpread_get_depth
187 PARAMS ((SLTPOINTER, struct objfile *));
189 static unsigned long hpread_get_line
190 PARAMS ((SLTPOINTER, struct objfile *));
192 static ADDRESS hpread_get_location
193 PARAMS ((SLTPOINTER, struct objfile *));
195 static int hpread_type_translate PARAMS ((DNTTPOINTER));
196 static unsigned long hpread_get_textlow PARAMS ((int, int, struct objfile *));
197 static union dnttentry *hpread_get_gntt PARAMS ((int, struct objfile *));
198 static union dnttentry *hpread_get_lntt PARAMS ((int, struct objfile *));
199 static union sltentry *hpread_get_slt PARAMS ((int, struct objfile *));
200 static void hpread_psymtab_to_symtab PARAMS ((struct partial_symtab *));
201 static void hpread_psymtab_to_symtab_1 PARAMS ((struct partial_symtab *));
202 static int hpread_has_name PARAMS ((KINDTYPE));
205 /* Initialization for reading native HP C debug symbols from OBJFILE.
207 It's only purpose in life is to set up the symbol reader's private
208 per-objfile data structures, and read in the raw contents of the debug
209 sections (attaching pointers to the debug info into the private data
212 Since BFD doesn't know how to read debug symbols in a format-independent
213 way (and may never do so...), we have to do it ourselves. Note we may
214 be called on a file without native HP C debugging symbols.
215 FIXME, there should be a cleaner peephole into the BFD environment here. */
218 hpread_symfile_init (objfile)
219 struct objfile *objfile;
221 asection *vt_section, *slt_section, *lntt_section, *gntt_section;
223 /* Allocate struct to keep track of the symfile */
224 objfile->sym_private = (PTR)
225 xmmalloc (objfile->md, sizeof (struct hpread_symfile_info));
226 memset (objfile->sym_private, 0, sizeof (struct hpread_symfile_info));
228 /* We haven't read in any types yet. */
229 TYPE_VECTOR (objfile) = 0;
231 /* Read in data from the $GNTT$ subspace. */
232 gntt_section = bfd_get_section_by_name (objfile->obfd, "$GNTT$");
237 = obstack_alloc (&objfile->symbol_obstack,
238 bfd_section_size (objfile->obfd, gntt_section));
240 bfd_get_section_contents (objfile->obfd, gntt_section, GNTT (objfile),
241 0, bfd_section_size (objfile->obfd, gntt_section));
243 GNTT_SYMCOUNT (objfile)
244 = bfd_section_size (objfile->obfd, gntt_section) / DNTTBLOCKSIZE;
246 /* Read in data from the $LNTT$ subspace. Also keep track of the number
248 lntt_section = bfd_get_section_by_name (objfile->obfd, "$LNTT$");
253 = obstack_alloc (&objfile->symbol_obstack,
254 bfd_section_size (objfile->obfd, lntt_section));
256 bfd_get_section_contents (objfile->obfd, lntt_section, LNTT (objfile),
257 0, bfd_section_size (objfile->obfd, lntt_section));
259 LNTT_SYMCOUNT (objfile)
260 = bfd_section_size (objfile->obfd, lntt_section) / DNTTBLOCKSIZE;
262 /* Read in data from the $SLT$ subspace. $SLT$ contains information
263 on source line numbers. */
264 slt_section = bfd_get_section_by_name (objfile->obfd, "$SLT$");
269 obstack_alloc (&objfile->symbol_obstack,
270 bfd_section_size (objfile->obfd, slt_section));
272 bfd_get_section_contents (objfile->obfd, slt_section, SLT (objfile),
273 0, bfd_section_size (objfile->obfd, slt_section));
275 /* Read in data from the $VT$ subspace. $VT$ contains things like
276 names and constants. Keep track of the number of symbols in the VT. */
277 vt_section = bfd_get_section_by_name (objfile->obfd, "$VT$");
281 VT_SIZE (objfile) = bfd_section_size (objfile->obfd, vt_section);
284 (char *) obstack_alloc (&objfile->symbol_obstack,
287 bfd_get_section_contents (objfile->obfd, vt_section, VT (objfile),
288 0, VT_SIZE (objfile));
291 /* Scan and build partial symbols for a symbol file.
293 The minimal symbol table (either SOM or HP a.out) has already been
294 read in; all we need to do is setup partial symbols based on the
295 native debugging information.
297 We assume hpread_symfile_init has been called to initialize the
298 symbol reader's private data structures.
300 SECTION_OFFSETS contains offsets relative to which the symbols in the
301 various sections are (depending where the sections were actually loaded).
302 MAINLINE is true if we are reading the main symbol
303 table (as opposed to a shared lib or dynamically loaded file). */
306 hpread_build_psymtabs (objfile, section_offsets, mainline)
307 struct objfile *objfile;
308 struct section_offsets *section_offsets;
312 int past_first_source_file = 0;
313 struct cleanup *old_chain;
315 int hp_symnum, symcount, i;
317 union dnttentry *dn_bufp;
323 /* Current partial symtab */
324 struct partial_symtab *pst;
326 /* List of current psymtab's include files */
327 char **psymtab_include_list;
328 int includes_allocated;
331 /* Index within current psymtab dependency list */
332 struct partial_symtab **dependency_list;
333 int dependencies_used, dependencies_allocated;
335 /* Just in case the stabs reader left turds lying around. */
337 make_cleanup (really_free_pendings, 0);
339 pst = (struct partial_symtab *) 0;
341 /* We shouldn't use alloca, instead use malloc/free. Doing so avoids
342 a number of problems with cross compilation and creating useless holes
343 in the stack when we have to allocate new entries. FIXME. */
345 includes_allocated = 30;
347 psymtab_include_list = (char **) alloca (includes_allocated *
350 dependencies_allocated = 30;
351 dependencies_used = 0;
353 (struct partial_symtab **) alloca (dependencies_allocated *
354 sizeof (struct partial_symtab *));
356 old_chain = make_cleanup (free_objfile, objfile);
358 last_source_file = 0;
360 /* Make two passes, one ofr the GNTT symbols, the other for the
362 for (i = 0; i < 1; i++)
364 int within_function = 0;
367 symcount = GNTT_SYMCOUNT (objfile);
369 symcount = LNTT_SYMCOUNT (objfile);
371 for (hp_symnum = 0; hp_symnum < symcount; hp_symnum++)
375 dn_bufp = hpread_get_gntt (hp_symnum, objfile);
377 dn_bufp = hpread_get_lntt (hp_symnum, objfile);
379 if (dn_bufp->dblock.extension)
382 /* Only handle things which are necessary for minimal symbols.
383 everything else is ignored. */
384 switch (dn_bufp->dblock.kind)
388 /* A source file of some kind. Note this may simply
389 be an included file. */
390 SET_NAMESTRING (dn_bufp, &namestring, objfile);
392 /* Check if this is the source file we are already working
394 if (pst && !strcmp (namestring, pst->filename))
397 /* Check if this is an include file, if so check if we have
398 already seen it. Add it to the include list */
399 p = strrchr (namestring, '.');
400 if (!strcmp (p, ".h"))
405 for (j = 0; j < includes_used; j++)
406 if (!strcmp (namestring, psymtab_include_list[j]))
414 /* Add it to the list of includes seen so far and
415 allocate more include space if necessary. */
416 psymtab_include_list[includes_used++] = namestring;
417 if (includes_used >= includes_allocated)
419 char **orig = psymtab_include_list;
421 psymtab_include_list = (char **)
422 alloca ((includes_allocated *= 2) *
424 memcpy ((PTR) psymtab_include_list, (PTR) orig,
425 includes_used * sizeof (char *));
435 pst->filename = (char *)
436 obstack_alloc (&pst->objfile->psymbol_obstack,
437 strlen (namestring) + 1);
438 strcpy (pst->filename, namestring);
445 /* This is a bonafide new source file.
446 End the current partial symtab and start a new one. */
448 if (pst && past_first_source_file)
450 texthigh += ANOFFSET (section_offsets, SECT_OFF_TEXT);
451 hpread_end_psymtab (pst, psymtab_include_list,
453 hp_symnum * DNTTBLOCKSIZE, texthigh,
454 dependency_list, dependencies_used);
455 pst = (struct partial_symtab *) 0;
457 dependencies_used = 0;
460 past_first_source_file = 1;
462 valu = hpread_get_textlow (i, hp_symnum, objfile);
463 valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
464 pst = hpread_start_psymtab (objfile, section_offsets,
466 hp_symnum * DNTTBLOCKSIZE,
467 objfile->global_psymbols.next,
468 objfile->static_psymbols.next);
475 /* A source file. It's still unclear to me what the
476 real difference between a K_SRCFILE and K_MODULE
477 is supposed to be. */
478 SET_NAMESTRING (dn_bufp, &namestring, objfile);
479 valu = hpread_get_textlow (i, hp_symnum, objfile);
480 valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
483 pst = hpread_start_psymtab (objfile, section_offsets,
485 hp_symnum * DNTTBLOCKSIZE,
486 objfile->global_psymbols.next,
487 objfile->static_psymbols.next);
494 /* The beginning of a function. K_ENTRY may also denote
495 a secondary entry point. */
496 valu = dn_bufp->dfunc.lowaddr +
497 ANOFFSET (section_offsets, SECT_OFF_TEXT);
498 if (dn_bufp->dfunc.hiaddr > texthigh)
499 texthigh = dn_bufp->dfunc.hiaddr;
500 SET_NAMESTRING (dn_bufp, &namestring, objfile);
501 ADD_PSYMBOL_TO_LIST (namestring, strlen (namestring),
502 VAR_NAMESPACE, LOC_BLOCK,
503 objfile->static_psymbols, valu,
504 language_unknown, objfile);
509 /* Scope block begin/end. We only care about function
510 and file blocks right now. */
511 if (dn_bufp->dend.endkind == K_MODULE)
513 texthigh += ANOFFSET (section_offsets, SECT_OFF_TEXT);
514 hpread_end_psymtab (pst, psymtab_include_list, includes_used,
515 hp_symnum * DNTTBLOCKSIZE, texthigh,
516 dependency_list, dependencies_used);
517 pst = (struct partial_symtab *) 0;
519 dependencies_used = 0;
522 if (dn_bufp->dend.endkind == K_FUNCTION)
530 /* Variables, typedefs an the like. */
531 enum address_class storage;
532 enum namespace namespace;
534 /* Don't add locals to the partial symbol table. */
536 && (dn_bufp->dblock.kind == K_SVAR
537 || dn_bufp->dblock.kind == K_DVAR))
540 /* TAGDEFs go into the structure namespace. */
541 if (dn_bufp->dblock.kind == K_TAGDEF)
542 namespace = STRUCT_NAMESPACE;
544 namespace = VAR_NAMESPACE;
546 /* What kind of "storage" does this use? */
547 if (dn_bufp->dblock.kind == K_SVAR)
548 storage = LOC_STATIC;
549 else if (dn_bufp->dblock.kind == K_DVAR
550 && dn_bufp->ddvar.regvar)
551 storage = LOC_REGISTER;
552 else if (dn_bufp->dblock.kind == K_DVAR)
557 SET_NAMESTRING (dn_bufp, &namestring, objfile);
560 pst = hpread_start_psymtab (objfile, section_offsets,
562 hp_symnum * DNTTBLOCKSIZE,
563 objfile->global_psymbols.next,
564 objfile->static_psymbols.next);
566 if (dn_bufp->dsvar.public)
568 ADD_PSYMBOL_TO_LIST (namestring, strlen (namestring),
570 objfile->global_psymbols,
571 dn_bufp->dsvar.location,
572 language_unknown, objfile);
576 ADD_PSYMBOL_TO_LIST (namestring, strlen (namestring),
578 objfile->static_psymbols,
579 dn_bufp->dsvar.location,
580 language_unknown, objfile);
586 /* Constants and members of enumerated types. */
587 SET_NAMESTRING (dn_bufp, &namestring, objfile);
590 pst = hpread_start_psymtab (objfile, section_offsets,
592 hp_symnum * DNTTBLOCKSIZE,
593 objfile->global_psymbols.next,
594 objfile->static_psymbols.next);
596 ADD_PSYMBOL_TO_LIST (namestring, strlen (namestring),
597 VAR_NAMESPACE, LOC_CONST,
598 objfile->static_psymbols, 0,
599 language_unknown, objfile);
607 /* End any pending partial symbol table. */
610 hpread_end_psymtab (pst, psymtab_include_list, includes_used,
611 hp_symnum * DNTTBLOCKSIZE, 0,
612 dependency_list, dependencies_used);
615 discard_cleanups (old_chain);
618 /* Perform any local cleanups required when we are done with a particular
619 objfile. I.E, we are in the process of discarding all symbol information
620 for an objfile, freeing up all memory held for it, and unlinking the
621 objfile struct from the global list of known objfiles. */
624 hpread_symfile_finish (objfile)
625 struct objfile *objfile;
627 if (objfile->sym_private != NULL)
629 mfree (objfile->md, objfile->sym_private);
634 /* The remaining functions are all for internal use only. */
636 /* Various small functions to get entries in the debug symbol sections. */
638 static union dnttentry *
639 hpread_get_lntt (index, objfile)
641 struct objfile *objfile;
643 return (union dnttentry *)&(LNTT (objfile)[index * DNTTBLOCKSIZE]);
646 static union dnttentry *
647 hpread_get_gntt (index, objfile)
649 struct objfile *objfile;
651 return (union dnttentry *)&(GNTT (objfile)[index * DNTTBLOCKSIZE]);
654 static union sltentry *
655 hpread_get_slt (index, objfile)
657 struct objfile *objfile;
659 return (union sltentry *)&(SLT (objfile)[index * SLTBLOCKSIZE]);
662 /* Get the low address associated with some symbol (typically the start
663 of a particular source file or module). Since that information is not
664 stored as part of the K_MODULE or K_SRCFILE symbol we must infer it from
665 the existance of K_FUNCTION symbols. */
668 hpread_get_textlow (global, index, objfile)
671 struct objfile *objfile;
673 union dnttentry *dn_bufp;
674 struct minimal_symbol *msymbol;
676 /* Look for a K_FUNCTION symbol. */
680 dn_bufp = hpread_get_gntt (index++, objfile);
682 dn_bufp = hpread_get_lntt (index++, objfile);
683 } while (dn_bufp->dblock.kind != K_FUNCTION
684 && dn_bufp->dblock.kind != K_END);
686 /* Avoid going past a K_END when looking for a K_FUNCTION. This
687 might happen when a sourcefile has no functions. */
688 if (dn_bufp->dblock.kind == K_END)
691 /* The minimal symbols are typically more accurate for some reason. */
692 msymbol = lookup_minimal_symbol (dn_bufp->dfunc.name + VT (objfile),
695 return SYMBOL_VALUE_ADDRESS (msymbol);
697 return dn_bufp->dfunc.lowaddr;
700 /* Get the nesting depth for the source line identified by INDEX. */
703 hpread_get_depth (index, objfile)
705 struct objfile *objfile;
707 union sltentry *sl_bufp;
709 sl_bufp = hpread_get_slt (index, objfile);
710 return sl_bufp->sspec.backptr.dnttp.index;
713 /* Get the source line number the the line identified by INDEX. */
716 hpread_get_line (index, objfile)
718 struct objfile *objfile;
720 union sltentry *sl_bufp;
722 sl_bufp = hpread_get_slt (index, objfile);
723 return sl_bufp->snorm.line;
727 hpread_get_location (index, objfile)
729 struct objfile *objfile;
731 union sltentry *sl_bufp;
734 /* code location of special sltentrys is determined from context */
735 sl_bufp = hpread_get_slt (index, objfile);
737 if (sl_bufp->snorm.sltdesc == SLT_END)
739 /* find previous normal sltentry and get address */
740 for (i = 0; ((sl_bufp->snorm.sltdesc != SLT_NORMAL) &&
741 (sl_bufp->snorm.sltdesc != SLT_EXIT)); i++)
742 sl_bufp = hpread_get_slt (index - i, objfile);
743 return sl_bufp->snorm.address;
746 /* find next normal sltentry and get address */
747 for (i = 0; ((sl_bufp->snorm.sltdesc != SLT_NORMAL) &&
748 (sl_bufp->snorm.sltdesc != SLT_EXIT)); i++)
749 sl_bufp = hpread_get_slt (index + i, objfile);
750 return sl_bufp->snorm.address;
754 /* Return 1 if an HP debug symbol of type KIND has a name associated with
755 it, else return 0. */
758 hpread_has_name (kind)
802 /* Allocate and partially fill a partial symtab. It will be
803 completely filled at the end of the symbol list.
805 SYMFILE_NAME is the name of the symbol-file we are reading from, and ADDR
806 is the address relative to which its symbols are (incremental) or 0
809 static struct partial_symtab *
810 hpread_start_psymtab (objfile, section_offsets,
811 filename, textlow, ldsymoff, global_syms, static_syms)
812 struct objfile *objfile;
813 struct section_offsets *section_offsets;
817 struct partial_symbol *global_syms;
818 struct partial_symbol *static_syms;
820 struct partial_symtab *result =
821 start_psymtab_common (objfile, section_offsets,
822 filename, textlow, global_syms, static_syms);
824 result->read_symtab_private = (char *)
825 obstack_alloc (&objfile->psymbol_obstack, sizeof (struct symloc));
826 LDSYMOFF (result) = ldsymoff;
827 result->read_symtab = hpread_psymtab_to_symtab;
833 /* Close off the current usage of PST.
834 Returns PST or NULL if the partial symtab was empty and thrown away.
836 FIXME: List variables and peculiarities of same. */
838 static struct partial_symtab *
839 hpread_end_psymtab (pst, include_list, num_includes, capping_symbol_offset,
840 capping_text, dependency_list, number_dependencies)
841 struct partial_symtab *pst;
844 int capping_symbol_offset;
845 CORE_ADDR capping_text;
846 struct partial_symtab **dependency_list;
847 int number_dependencies;
850 struct objfile *objfile = pst -> objfile;
852 if (capping_symbol_offset != -1)
853 LDSYMLEN(pst) = capping_symbol_offset - LDSYMOFF(pst);
854 pst->texthigh = capping_text;
857 objfile->global_psymbols.next - (objfile->global_psymbols.list + pst->globals_offset);
859 objfile->static_psymbols.next - (objfile->static_psymbols.list + pst->statics_offset);
861 pst->number_of_dependencies = number_dependencies;
862 if (number_dependencies)
864 pst->dependencies = (struct partial_symtab **)
865 obstack_alloc (&objfile->psymbol_obstack,
866 number_dependencies * sizeof (struct partial_symtab *));
867 memcpy (pst->dependencies, dependency_list,
868 number_dependencies * sizeof (struct partial_symtab *));
871 pst->dependencies = 0;
873 for (i = 0; i < num_includes; i++)
875 struct partial_symtab *subpst =
876 allocate_psymtab (include_list[i], objfile);
878 subpst->section_offsets = pst->section_offsets;
879 subpst->read_symtab_private =
880 (char *) obstack_alloc (&objfile->psymbol_obstack,
881 sizeof (struct symloc));
885 subpst->texthigh = 0;
887 /* We could save slight bits of space by only making one of these,
888 shared by the entire set of include files. FIXME-someday. */
889 subpst->dependencies = (struct partial_symtab **)
890 obstack_alloc (&objfile->psymbol_obstack,
891 sizeof (struct partial_symtab *));
892 subpst->dependencies[0] = pst;
893 subpst->number_of_dependencies = 1;
895 subpst->globals_offset =
896 subpst->n_global_syms =
897 subpst->statics_offset =
898 subpst->n_static_syms = 0;
902 subpst->read_symtab = pst->read_symtab;
905 sort_pst_symbols (pst);
907 /* If there is already a psymtab or symtab for a file of this name, remove it.
908 (If there is a symtab, more drastic things also happen.)
909 This happens in VxWorks. */
910 free_named_symtabs (pst->filename);
912 if (num_includes == 0
913 && number_dependencies == 0
914 && pst->n_global_syms == 0
915 && pst->n_static_syms == 0)
917 /* Throw away this psymtab, it's empty. We can't deallocate it, since
918 it is on the obstack, but we can forget to chain it on the list. */
919 /* Empty psymtabs happen as a result of header files which don't have
920 any symbols in them. There can be a lot of them. But this check
921 is wrong, in that a psymtab with N_SLINE entries but nothing else
922 is not empty, but we don't realize that. Fixing that without slowing
923 things down might be tricky. */
924 struct partial_symtab *prev_pst;
926 /* First, snip it out of the psymtab chain */
928 if (pst->objfile->psymtabs == pst)
929 pst->objfile->psymtabs = pst->next;
931 for (prev_pst = pst->objfile->psymtabs; prev_pst; prev_pst = pst->next)
932 if (prev_pst->next == pst)
933 prev_pst->next = pst->next;
935 /* Next, put it on a free list for recycling */
937 pst->next = pst->objfile->free_psymtabs;
938 pst->objfile->free_psymtabs = pst;
940 /* Indicate that psymtab was thrown away. */
941 pst = (struct partial_symtab *)NULL;
946 /* Do the dirty work of reading in the full symbol from a partial symbol
950 hpread_psymtab_to_symtab_1 (pst)
951 struct partial_symtab *pst;
953 struct cleanup *old_chain;
956 /* Get out quick if passed junk. */
960 /* Complain if we've already read in this symbol table. */
963 fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
968 /* Read in all partial symtabs on which this one is dependent */
969 for (i = 0; i < pst->number_of_dependencies; i++)
970 if (!pst->dependencies[i]->readin)
972 /* Inform about additional files that need to be read in. */
975 fputs_filtered (" ", stdout);
977 fputs_filtered ("and ", stdout);
979 printf_filtered ("%s...", pst->dependencies[i]->filename);
980 wrap_here (""); /* Flush output */
983 hpread_psymtab_to_symtab_1 (pst->dependencies[i]);
986 /* If it's real... */
989 /* Init stuff necessary for reading in symbols */
991 old_chain = make_cleanup (really_free_pendings, 0);
994 hpread_expand_symtab (pst->objfile, LDSYMOFF (pst), LDSYMLEN (pst),
995 pst->textlow, pst->texthigh - pst->textlow,
996 pst->section_offsets, pst->filename);
997 sort_symtab_syms (pst->symtab);
999 do_cleanups (old_chain);
1005 /* Read in all of the symbols for a given psymtab for real.
1006 Be verbose about it if the user wants that. */
1009 hpread_psymtab_to_symtab (pst)
1010 struct partial_symtab *pst;
1012 /* Get out quick if given junk. */
1019 fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
1024 if (LDSYMLEN (pst) || pst->number_of_dependencies)
1026 /* Print the message now, before reading the string table,
1027 to avoid disconcerting pauses. */
1030 printf_filtered ("Reading in symbols for %s...", pst->filename);
1034 hpread_psymtab_to_symtab_1 (pst);
1036 /* Match with global symbols. This only needs to be done once,
1037 after all of the symtabs and dependencies have been read in. */
1038 scan_file_globals (pst->objfile);
1040 /* Finish up the debug error message. */
1042 printf_filtered ("done.\n");
1045 /* Read in a defined section of a specific object file's symbols.
1047 DESC is the file descriptor for the file, positioned at the
1048 beginning of the symtab
1049 SYM_OFFSET is the offset within the file of
1050 the beginning of the symbols we want to read
1051 SYM_SIZE is the size of the symbol info to read in.
1052 TEXT_OFFSET is the beginning of the text segment we are reading symbols for
1053 TEXT_SIZE is the size of the text segment read in.
1054 SECTION_OFFSETS are the relocation offsets which get added to each symbol. */
1056 static struct symtab *
1057 hpread_expand_symtab (objfile, sym_offset, sym_size, text_offset, text_size,
1058 section_offsets, filename)
1059 struct objfile *objfile;
1062 CORE_ADDR text_offset;
1064 struct section_offsets *section_offsets;
1068 union dnttentry *dn_bufp;
1069 unsigned max_symnum;
1071 int sym_index = sym_offset / DNTTBLOCKSIZE;
1073 current_objfile = objfile;
1076 last_source_file = 0;
1078 dn_bufp = hpread_get_lntt (sym_index, objfile);
1079 if (!((dn_bufp->dblock.kind == (unsigned char) K_SRCFILE) ||
1080 (dn_bufp->dblock.kind == (unsigned char) K_MODULE)))
1081 start_symtab ("globals", NULL, 0);
1083 max_symnum = sym_size / DNTTBLOCKSIZE;
1085 /* Read in and process each debug symbol within the specified range. */
1087 symnum < max_symnum;
1090 QUIT; /* Allow this to be interruptable */
1091 dn_bufp = hpread_get_lntt (sym_index + symnum, objfile);
1093 if (dn_bufp->dblock.extension)
1096 /* Yow! We call SET_NAMESTRING on things without names! */
1097 SET_NAMESTRING (dn_bufp, &namestring, objfile);
1099 hpread_process_one_debug_symbol (dn_bufp, namestring, section_offsets,
1100 objfile, text_offset, text_size,
1101 filename, symnum + sym_index);
1104 current_objfile = NULL;
1106 return end_symtab (text_offset + text_size, 0, 0, objfile, 0);
1110 /* Convert basic types from HP debug format into GDB internal format. */
1113 hpread_type_translate (typep)
1116 if (!typep.dntti.immediate)
1119 switch (typep.dntti.type)
1122 case T_BOOLEAN_S300_COMPAT:
1123 case T_BOOLEAN_VAX_COMPAT:
1125 /* Ugh. No way to distinguish between signed and unsigned chars. */
1130 if (typep.dntti.bitlength <= 8)
1132 if (typep.dntti.bitlength <= 16)
1134 if (typep.dntti.bitlength <= 32)
1136 return FT_LONG_LONG;
1140 return FT_UNSIGNED_LONG;
1142 if (typep.dntti.bitlength <= 8)
1143 return FT_UNSIGNED_CHAR;
1144 if (typep.dntti.bitlength <= 16)
1145 return FT_UNSIGNED_SHORT;
1146 if (typep.dntti.bitlength <= 32)
1147 return FT_UNSIGNED_INTEGER;
1148 return FT_UNSIGNED_LONG_LONG;
1152 if (typep.dntti.bitlength == 64)
1153 return FT_DBL_PREC_FLOAT;
1154 if (typep.dntti.bitlength == 128)
1155 return FT_EXT_PREC_FLOAT;
1158 case T_COMPLEXS3000:
1159 if (typep.dntti.bitlength == 128)
1160 return FT_DBL_PREC_COMPLEX;
1161 if (typep.dntti.bitlength == 192)
1162 return FT_EXT_PREC_COMPLEX;
1165 case T_LONGSTRING200:
1166 case T_FTN_STRING_SPEC:
1167 case T_MOD_STRING_SPEC:
1168 case T_MOD_STRING_3000:
1169 case T_FTN_STRING_S300_COMPAT:
1170 case T_FTN_STRING_VAX_COMPAT:
1177 /* Return the type associated with the index found in HP_TYPE. */
1179 static struct type **
1180 hpread_lookup_type (hp_type, objfile)
1181 DNTTPOINTER hp_type;
1182 struct objfile *objfile;
1185 int index = hp_type.dnttp.index;
1187 if (hp_type.dntti.immediate)
1190 if (index < LNTT_SYMCOUNT (objfile))
1192 if (index >= TYPE_VECTOR_LENGTH (objfile))
1194 old_len = TYPE_VECTOR_LENGTH (objfile);
1197 TYPE_VECTOR_LENGTH (objfile) = 100;
1198 TYPE_VECTOR (objfile) = (struct type **)
1199 malloc (TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *));
1201 while (index >= TYPE_VECTOR_LENGTH (objfile))
1202 TYPE_VECTOR_LENGTH (objfile) *= 2;
1203 TYPE_VECTOR (objfile) = (struct type **)
1204 xrealloc ((char *) TYPE_VECTOR (objfile),
1205 (TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *)));
1206 memset (&TYPE_VECTOR (objfile)[old_len], 0,
1207 (TYPE_VECTOR_LENGTH (objfile) - old_len) *
1208 sizeof (struct type *));
1210 return &TYPE_VECTOR (objfile)[index];
1216 /* Possibly allocate a GDB internal type so we can internalize HP_TYPE.
1217 Note we'll just return the address of a GDB internal type if we already
1218 have it lying around. */
1220 static struct type *
1221 hpread_alloc_type (hp_type, objfile)
1222 DNTTPOINTER hp_type;
1223 struct objfile *objfile;
1225 struct type **type_addr;
1227 type_addr = hpread_lookup_type (hp_type, objfile);
1228 if (*type_addr == 0)
1229 *type_addr = alloc_type (objfile);
1231 TYPE_CPLUS_SPECIFIC (*type_addr)
1232 = (struct cplus_struct_type *) &cplus_struct_default;
1236 /* Read a native enumerated type and return it in GDB internal form. */
1238 static struct type *
1239 hpread_read_enum_type (hp_type, dn_bufp, objfile)
1240 DNTTPOINTER hp_type;
1241 union dnttentry *dn_bufp;
1242 struct objfile *objfile;
1245 struct pending **symlist, *osyms, *syms;
1246 int o_nsyms, nsyms = 0;
1248 union dnttentry *memp;
1253 type = hpread_alloc_type (hp_type, objfile);
1254 TYPE_LENGTH (type) = 4;
1256 symlist = &file_symbols;
1258 o_nsyms = osyms ? osyms->nsyms : 0;
1260 /* Get a name for each member and add it to our list of members. */
1261 mem = dn_bufp->denum.firstmem;
1262 while (mem.dnttp.extension && mem.word != DNTTNIL)
1264 memp = hpread_get_lntt (mem.dnttp.index, objfile);
1266 name = VT (objfile) + memp->dmember.name;
1267 sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
1268 sizeof (struct symbol));
1269 memset (sym, 0, sizeof (struct symbol));
1270 SYMBOL_NAME (sym) = name;
1271 SYMBOL_CLASS (sym) = LOC_CONST;
1272 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1273 SYMBOL_VALUE (sym) = memp->dmember.value;
1274 add_symbol_to_list (sym, symlist);
1276 mem = memp->dmember.nextmem;
1279 /* Now that we know more about the enum, fill in more info. */
1280 TYPE_CODE (type) = TYPE_CODE_ENUM;
1281 TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
1282 TYPE_NFIELDS (type) = nsyms;
1283 TYPE_FIELDS (type) = (struct field *)
1284 obstack_alloc (&objfile->type_obstack, sizeof (struct field) * nsyms);
1286 /* Find the symbols for the members and put them into the type.
1287 The symbols can be found in the symlist that we put them on
1288 to cause them to be defined. osyms contains the old value
1289 of that symlist; everything up to there was defined by us.
1291 Note that we preserve the order of the enum constants, so
1292 that in something like "enum {FOO, LAST_THING=FOO}" we print
1293 FOO, not LAST_THING. */
1294 for (syms = *symlist, n = 0; syms; syms = syms->next)
1299 for (; j < syms->nsyms; j++, n++)
1301 struct symbol *xsym = syms->symbol[j];
1302 SYMBOL_TYPE (xsym) = type;
1303 TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym);
1304 TYPE_FIELD_VALUE (type, n) = 0;
1305 TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (xsym);
1306 TYPE_FIELD_BITSIZE (type, n) = 0;
1315 /* Read and internalize a native function debug symbol. */
1317 static struct type *
1318 hpread_read_function_type (hp_type, dn_bufp, objfile)
1319 DNTTPOINTER hp_type;
1320 union dnttentry *dn_bufp;
1321 struct objfile *objfile;
1323 struct type *type, *type1;
1324 struct pending **symlist, *osyms, *syms;
1325 int o_nsyms, nsyms = 0;
1327 union dnttentry *paramp;
1332 param = dn_bufp->dfunc.firstparam;
1334 /* See if we've already read in this type. */
1335 type = hpread_alloc_type (hp_type, objfile);
1336 if (TYPE_CODE (type) == TYPE_CODE_FUNC)
1339 /* Nope, so read it in and store it away. */
1340 type1 = lookup_function_type (hpread_type_lookup (dn_bufp->dfunc.retval,
1342 memcpy ((char *) type, (char *) type1, sizeof (struct type));
1344 symlist = &local_symbols;
1346 o_nsyms = osyms ? osyms->nsyms : 0;
1348 /* Now examine each parameter noting its type, location, and a
1349 wealth of other information. */
1350 while (param.word && param.word != DNTTNIL)
1352 paramp = hpread_get_lntt (param.dnttp.index, objfile);
1354 param = paramp->dfparam.nextparam;
1357 name = VT (objfile) + paramp->dfparam.name;
1358 sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
1359 sizeof (struct symbol));
1360 (void) memset (sym, 0, sizeof (struct symbol));
1361 SYMBOL_NAME (sym) = name;
1363 /* Figure out where it lives. */
1364 if (paramp->dfparam.regparam)
1365 SYMBOL_CLASS (sym) = LOC_REGPARM;
1366 else if (paramp->dfparam.indirect)
1367 SYMBOL_CLASS (sym) = LOC_REF_ARG;
1369 SYMBOL_CLASS (sym) = LOC_ARG;
1370 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1371 if (paramp->dfparam.copyparam)
1373 SYMBOL_VALUE (sym) = paramp->dfparam.location ;
1374 #ifdef HPREAD_ADJUST_STACK_ADDRESS
1376 += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile));
1378 /* This is likely a pass-by-invisible reference parameter,
1379 Hack on the symbol class to make GDB happy. */
1380 SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
1383 SYMBOL_VALUE (sym) = paramp->dfparam.location;
1386 SYMBOL_TYPE (sym) = hpread_type_lookup (paramp->dfparam.type, objfile);
1388 /* Add it to the list. */
1389 add_symbol_to_list (sym, symlist);
1392 /* Note how many parameters we found. */
1393 TYPE_NFIELDS (type) = nsyms;
1394 TYPE_FIELDS (type) = (struct field *)
1395 obstack_alloc (&objfile->type_obstack,
1396 sizeof (struct field) * nsyms);
1398 /* Find the symbols for the values and put them into the type.
1399 The symbols can be found in the symlist that we put them on
1400 to cause them to be defined. osyms contains the old value
1401 of that symlist; everything up to there was defined by us. */
1402 /* Note that we preserve the order of the parameters, so
1403 that in something like "enum {FOO, LAST_THING=FOO}" we print
1404 FOO, not LAST_THING. */
1405 for (syms = *symlist, n = 0; syms; syms = syms->next)
1410 for (; j < syms->nsyms; j++, n++)
1412 struct symbol *xsym = syms->symbol[j];
1413 TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym);
1414 TYPE_FIELD_TYPE (type, n) = SYMBOL_TYPE (xsym);
1415 TYPE_FIELD_BITPOS (type, n) = n;
1416 TYPE_FIELD_BITSIZE (type, n) = 0;
1424 /* Read in and internalize a structure definition. */
1426 static struct type *
1427 hpread_read_struct_type (hp_type, dn_bufp, objfile)
1428 DNTTPOINTER hp_type;
1429 union dnttentry *dn_bufp;
1430 struct objfile *objfile;
1434 struct nextfield *next;
1439 struct nextfield *list = 0;
1440 struct nextfield *new;
1443 union dnttentry *fieldp;
1445 /* Is it something we've already dealt with? */
1446 type = hpread_alloc_type (hp_type, objfile);
1447 if ((TYPE_CODE (type) == TYPE_CODE_STRUCT) ||
1448 (TYPE_CODE (type) == TYPE_CODE_UNION))
1451 /* Get the basic type correct. */
1452 if (dn_bufp->dblock.kind == K_STRUCT)
1454 TYPE_CODE (type) = TYPE_CODE_STRUCT;
1455 TYPE_LENGTH (type) = dn_bufp->dstruct.bitlength / 8;
1457 else if (dn_bufp->dblock.kind == K_UNION)
1459 TYPE_CODE (type) = TYPE_CODE_UNION;
1460 TYPE_LENGTH (type) = dn_bufp->dunion.bitlength / 8;
1466 TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
1468 /* Read in and internalize all the fields. */
1469 field = dn_bufp->dstruct.firstfield;
1470 while (field.word != DNTTNIL && field.dnttp.extension)
1472 fieldp = hpread_get_lntt (field.dnttp.index, objfile);
1474 /* Get space to record the next field's data. */
1475 new = (struct nextfield *) alloca (sizeof (struct nextfield));
1479 list->field.name = VT (objfile) + fieldp->dfield.name;
1480 list->field.bitpos = fieldp->dfield.bitoffset;
1481 if (fieldp->dfield.bitlength % 8)
1482 list->field.bitsize = fieldp->dfield.bitlength;
1484 list->field.bitsize = 0;
1486 field = fieldp->dfield.nextfield;
1487 list->field.type = hpread_type_lookup (fieldp->dfield.type, objfile);
1490 TYPE_NFIELDS (type) = nfields;
1491 TYPE_FIELDS (type) = (struct field *)
1492 obstack_alloc (&objfile->type_obstack, sizeof (struct field) * nfields);
1494 /* Copy the saved-up fields into the field vector. */
1495 for (n = nfields; list; list = list->next)
1498 TYPE_FIELD (type, n) = list->field;
1503 /* Read in and internalize a set debug symbol. */
1505 static struct type *
1506 hpread_read_set_type (hp_type, dn_bufp, objfile)
1507 DNTTPOINTER hp_type;
1508 union dnttentry *dn_bufp;
1509 struct objfile *objfile;
1513 /* See if it's something we've already deal with. */
1514 type = hpread_alloc_type (hp_type, objfile);
1515 if (TYPE_CODE (type) == TYPE_CODE_SET)
1518 /* Nope. Fill in the appropriate fields. */
1519 TYPE_CODE (type) = TYPE_CODE_SET;
1520 TYPE_LENGTH (type) = dn_bufp->dset.bitlength / 8;
1521 TYPE_NFIELDS (type) = 0;
1522 TYPE_TARGET_TYPE (type) = hpread_type_lookup (dn_bufp->dset.subtype,
1527 /* Read in and internalize an array debug symbol. */
1529 static struct type *
1530 hpread_read_array_type (hp_type, dn_bufp, objfile)
1531 DNTTPOINTER hp_type;
1532 union dnttentry *dn_bufp;
1533 struct objfile *objfile;
1536 union dnttentry save;
1539 /* Why no check here? Because it kept us from properly determining
1540 the size of the array! */
1541 type = hpread_alloc_type (hp_type, objfile);
1543 TYPE_CODE (type) = TYPE_CODE_ARRAY;
1545 /* values are not normalized. */
1546 if (!((dn_bufp->darray.arrayisbytes && dn_bufp->darray.elemisbytes)
1547 || (!dn_bufp->darray.arrayisbytes && !dn_bufp->darray.elemisbytes)))
1549 else if (dn_bufp->darray.arraylength == 0x7fffffff)
1551 /* The HP debug format represents char foo[]; as an array with
1552 length 0x7fffffff. Internally GDB wants to represent this
1553 as a pointer. Ugh. */
1554 TYPE_CODE (type) = TYPE_CODE_PTR;
1555 TYPE_LENGTH (type) = 4;
1558 TYPE_LENGTH (type) = dn_bufp->darray.arraylength / 8;
1560 TYPE_NFIELDS (type) = 1;
1561 TYPE_TARGET_TYPE (type) = hpread_type_lookup (dn_bufp->darray.elemtype,
1564 TYPE_FIELDS (type) = (struct field *)
1565 obstack_alloc (&objfile->type_obstack, sizeof (struct field));
1566 TYPE_FIELD_TYPE (type, 0) = hpread_type_lookup (dn_bufp->darray.indextype,
1571 /* Read in and internalize a subrange debug symbol. */
1572 static struct type *
1573 hpread_read_subrange_type (hp_type, dn_bufp, objfile)
1574 DNTTPOINTER hp_type;
1575 union dnttentry *dn_bufp;
1576 struct objfile *objfile;
1580 /* Is it something we've already dealt with. */
1581 type = hpread_alloc_type (hp_type, objfile);
1582 if (TYPE_CODE (type) == TYPE_CODE_RANGE)
1585 /* Nope, internalize it. */
1586 TYPE_CODE (type) = TYPE_CODE_RANGE;
1587 TYPE_LENGTH (type) = dn_bufp->dsubr.bitlength / 8;
1588 TYPE_NFIELDS (type) = 2;
1589 TYPE_FIELDS (type) = (struct field *) obstack_alloc
1590 (&objfile->type_obstack, 2 * sizeof (struct field));
1592 if (dn_bufp->dsubr.dyn_low)
1593 TYPE_FIELD_BITPOS (type, 0) = 0;
1595 TYPE_FIELD_BITPOS (type, 0) = dn_bufp->dsubr.lowbound;
1597 if (dn_bufp->dsubr.dyn_high)
1598 TYPE_FIELD_BITPOS (type, 1) = -1;
1600 TYPE_FIELD_BITPOS (type, 1) = dn_bufp->dsubr.highbound;
1601 TYPE_TARGET_TYPE (type) = hpread_type_lookup (dn_bufp->dsubr.subtype,
1606 static struct type *
1607 hpread_type_lookup (hp_type, objfile)
1608 DNTTPOINTER hp_type;
1609 struct objfile *objfile;
1611 union dnttentry *dn_bufp;
1613 /* First see if it's a simple builtin type. */
1614 if (hp_type.dntti.immediate)
1615 return lookup_fundamental_type (objfile, hpread_type_translate (hp_type));
1617 /* Not a builtin type. We'll have to read it in. */
1618 if (hp_type.dnttp.index < LNTT_SYMCOUNT (objfile))
1619 dn_bufp = hpread_get_lntt (hp_type.dnttp.index, objfile);
1621 return lookup_fundamental_type (objfile, FT_VOID);
1623 switch (dn_bufp->dblock.kind)
1639 /* Opps. Something went very wrong. */
1640 return lookup_fundamental_type (objfile, FT_VOID);
1644 struct type *structtype = hpread_type_lookup (dn_bufp->dtype.type,
1647 suffix = VT (objfile) + dn_bufp->dtype.name;
1649 TYPE_CPLUS_SPECIFIC (structtype)
1650 = (struct cplus_struct_type *) &cplus_struct_default;
1651 TYPE_NAME (structtype) = suffix;
1657 /* Just a little different from above. We have to tack on
1658 an identifier of some kind (struct, union, enum, etc). */
1659 struct type *structtype = hpread_type_lookup (dn_bufp->dtype.type,
1661 char *prefix, *suffix;
1662 suffix = VT (objfile) + dn_bufp->dtype.name;
1664 /* Lookup the next type in the list. It should be a structure,
1665 union, or enum type. We will need to attach that to our name. */
1666 if (dn_bufp->dtype.type.dnttp.index < LNTT_SYMCOUNT (objfile))
1667 dn_bufp = hpread_get_lntt (dn_bufp->dtype.type.dnttp.index, objfile);
1671 if (dn_bufp->dblock.kind == K_STRUCT)
1673 else if (dn_bufp->dblock.kind == K_UNION)
1678 /* Build the correct name. */
1680 = (char *) obstack_alloc (&objfile->type_obstack,
1681 strlen (prefix) + strlen (suffix) + 1);
1682 TYPE_NAME (structtype) = strcpy (TYPE_NAME (structtype), prefix);
1683 TYPE_NAME (structtype) = strcat (TYPE_NAME (structtype), suffix);
1684 TYPE_TAG_NAME (structtype) = suffix;
1686 TYPE_CPLUS_SPECIFIC (structtype)
1687 = (struct cplus_struct_type *) &cplus_struct_default;
1692 return lookup_pointer_type (hpread_type_lookup (dn_bufp->dptr.pointsto,
1695 return hpread_read_enum_type (hp_type, dn_bufp, objfile);
1697 return lookup_fundamental_type (objfile, FT_VOID);
1699 return hpread_read_set_type (hp_type, dn_bufp, objfile);
1701 return hpread_read_subrange_type (hp_type, dn_bufp, objfile);
1703 return hpread_read_array_type (hp_type, dn_bufp, objfile);
1706 return hpread_read_struct_type (hp_type, dn_bufp, objfile);
1708 return hpread_type_lookup (dn_bufp->dfield.type, objfile);
1711 return lookup_fundamental_type (objfile, FT_VOID);
1713 return lookup_function_type (hpread_type_lookup (dn_bufp->dfunctype.retval,
1720 return lookup_fundamental_type (objfile, FT_VOID);
1725 hpread_record_lines (subfile, s_idx, e_idx, objfile)
1726 struct subfile *subfile;
1727 SLTPOINTER s_idx, e_idx;
1728 struct objfile *objfile;
1730 union sltentry *sl_bufp;
1732 while (s_idx <= e_idx)
1734 sl_bufp = hpread_get_slt (s_idx, objfile);
1735 /* Only record "normal" entries in the SLT. */
1736 if (sl_bufp->snorm.sltdesc == SLT_NORMAL
1737 || sl_bufp->snorm.sltdesc == SLT_EXIT)
1738 record_line (subfile, sl_bufp->snorm.line, sl_bufp->snorm.address);
1744 /* Internalize one native debug symbol. */
1747 hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile,
1748 text_offset, text_size, filename, index)
1749 union dnttentry *dn_bufp;
1751 struct section_offsets *section_offsets;
1752 struct objfile *objfile;
1753 CORE_ADDR text_offset;
1761 int offset = ANOFFSET (section_offsets, SECT_OFF_TEXT);
1762 union dnttentry *dn_temp;
1763 DNTTPOINTER hp_type;
1765 struct context_stack *new;
1767 /* Allocate one GDB debug symbol and fill in some default values. */
1768 sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
1769 sizeof (struct symbol));
1770 memset (sym, 0, sizeof (struct symbol));
1771 SYMBOL_NAME (sym) = name;
1772 SYMBOL_LANGUAGE (sym) = language_auto;
1773 SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack);
1774 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1775 SYMBOL_LINE (sym) = 0;
1776 SYMBOL_VALUE (sym) = 0;
1777 SYMBOL_CLASS (sym) = LOC_TYPEDEF;
1779 hp_type.dnttp.extension = 1;
1780 hp_type.dnttp.immediate = 0;
1781 hp_type.dnttp.global = 0;
1782 hp_type.dnttp.index = index;
1784 type = dn_bufp->dblock.kind;
1789 /* This type of symbol indicates from which source file or include file
1790 the following data comes. If there are no modules it also may
1791 indicate the start of a new source file, in which case we must
1792 finish the symbol table of the previous source file
1793 (if any) and start accumulating a new symbol table. */
1795 valu = text_offset + offset; /* Relocate for dynamic loading */
1796 if (!last_source_file)
1797 start_symtab (name, NULL, valu);
1799 SL_INDEX (objfile) = hpread_record_lines (current_subfile,
1801 dn_bufp->dsfile.address,
1803 start_subfile (name, NULL);
1807 /* No need to do anything with these K_MODULE symbols anymore. */
1812 /* A function or secondary entry point. */
1813 valu = dn_bufp->dfunc.lowaddr + offset;
1814 SL_INDEX (objfile) = hpread_record_lines (current_subfile,
1816 dn_bufp->dfunc.address,
1819 WITHIN_FUNCTION (objfile) = 1;
1820 CURRENT_FUNCTION_VALUE (objfile) = valu;
1822 /* Stack must be empty now. */
1823 if (context_stack_depth != 0)
1824 complain (&lbrac_unmatched_complaint, (char *) symnum);
1825 new = push_context (0, valu);
1827 SYMBOL_CLASS (sym) = LOC_BLOCK;
1828 SYMBOL_TYPE (sym) = hpread_read_function_type (hp_type, dn_bufp, objfile);
1829 if (dn_bufp->dfunc.public)
1830 add_symbol_to_list (sym, &global_symbols);
1832 add_symbol_to_list (sym, &file_symbols);
1835 /* Search forward to the next scope beginning. */
1836 while (dn_bufp->dblock.kind != K_BEGIN)
1838 dn_bufp = hpread_get_lntt (++index, objfile);
1839 if (dn_bufp->dblock.extension)
1842 SL_INDEX (objfile) = hpread_record_lines (current_subfile,
1844 dn_bufp->dbegin.address,
1846 SYMBOL_LINE (sym) = hpread_get_line (dn_bufp->dbegin.address, objfile);
1847 record_line (current_subfile, SYMBOL_LINE (sym), valu);
1851 /* Begin a new scope. */
1852 SL_INDEX (objfile) = hpread_record_lines (current_subfile,
1854 dn_bufp->dbegin.address,
1856 valu = hpread_get_location (dn_bufp->dbegin.address, objfile);
1857 valu += offset; /* Relocate for dynamic loading */
1858 desc = hpread_get_depth (dn_bufp->dbegin.address, objfile);
1859 new = push_context (desc, valu);
1864 SL_INDEX (objfile) = hpread_record_lines (current_subfile,
1866 dn_bufp->dend.address + 1,
1868 switch (dn_bufp->dend.endkind)
1871 /* Ending a module ends the symbol table for that module. */
1872 valu = text_offset + text_size + offset;
1873 (void) end_symtab (valu, 0, 0, objfile, 0);
1877 /* Ending a function, well, ends the function's scope. */
1878 dn_temp = hpread_get_lntt (dn_bufp->dend.beginscope.dnttp.index,
1880 valu = dn_temp->dfunc.hiaddr + offset;
1881 new = pop_context ();
1882 /* Make a block for the local symbols within. */
1883 finish_block (new->name, &local_symbols, new->old_blocks,
1884 new->start_addr, valu, objfile);
1885 WITHIN_FUNCTION (objfile) = 0;
1888 /* Just ending a local scope. */
1889 valu = hpread_get_location (dn_bufp->dend.address, objfile);
1890 /* Why in the hell is this needed? */
1891 valu += offset + 9; /* Relocate for dynamic loading */
1892 new = pop_context ();
1893 desc = dn_bufp->dend.beginscope.dnttp.index;
1894 if (desc != new->depth)
1895 complain (&lbrac_mismatch_complaint, (char *) symnum);
1896 /* Make a block for the local symbols within. */
1897 finish_block (new->name, &local_symbols, new->old_blocks,
1898 new->start_addr, valu, objfile);
1899 local_symbols = new->locals;
1904 SYMBOL_NAMESPACE (sym) = LABEL_NAMESPACE;
1907 /* Function parameters. */
1908 if (dn_bufp->dfparam.regparam)
1909 SYMBOL_CLASS (sym) = LOC_REGISTER;
1911 SYMBOL_CLASS (sym) = LOC_LOCAL;
1912 if (dn_bufp->dfparam.copyparam)
1914 SYMBOL_VALUE (sym) = dn_bufp->dfparam.location;
1915 #ifdef HPREAD_ADJUST_STACK_ADDRESS
1917 += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile));
1921 SYMBOL_VALUE (sym) = dn_bufp->dfparam.location;
1922 SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dfparam.type, objfile);
1923 add_symbol_to_list (sym, &local_symbols);
1926 /* Static variables. */
1927 SYMBOL_CLASS (sym) = LOC_STATIC;
1928 SYMBOL_VALUE_ADDRESS (sym) = dn_bufp->dsvar.location;
1929 SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dsvar.type, objfile);
1930 if (dn_bufp->dsvar.public)
1931 add_symbol_to_list (sym, &global_symbols);
1932 else if (WITHIN_FUNCTION (objfile))
1933 add_symbol_to_list (sym, &local_symbols);
1935 add_symbol_to_list (sym, &file_symbols);
1938 /* Dynamic variables. */
1939 if (dn_bufp->ddvar.regvar)
1940 SYMBOL_CLASS (sym) = LOC_REGISTER;
1942 SYMBOL_CLASS (sym) = LOC_LOCAL;
1943 SYMBOL_VALUE (sym) = dn_bufp->ddvar.location;
1944 #ifdef HPREAD_ADJUST_STACK_ADDRESS
1946 += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile));
1948 SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->ddvar.type, objfile);
1949 if (dn_bufp->ddvar.public)
1950 add_symbol_to_list (sym, &global_symbols);
1951 else if (WITHIN_FUNCTION (objfile))
1952 add_symbol_to_list (sym, &local_symbols);
1954 add_symbol_to_list (sym, &file_symbols);
1957 /* A constant (pascal?). */
1958 SYMBOL_CLASS (sym) = LOC_CONST;
1959 SYMBOL_VALUE (sym) = dn_bufp->dconst.location;
1960 SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dconst.type, objfile);
1961 if (dn_bufp->dconst.public)
1962 add_symbol_to_list (sym, &global_symbols);
1963 else if (WITHIN_FUNCTION (objfile))
1964 add_symbol_to_list (sym, &local_symbols);
1966 add_symbol_to_list (sym, &file_symbols);
1969 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1970 SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dtype.type, objfile);
1971 if (dn_bufp->dtype.public)
1972 add_symbol_to_list (sym, &global_symbols);
1973 else if (WITHIN_FUNCTION (objfile))
1974 add_symbol_to_list (sym, &local_symbols);
1976 add_symbol_to_list (sym, &file_symbols);
1979 SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE;
1980 SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dtype.type, objfile);
1981 TYPE_NAME (sym->type) = SYMBOL_NAME (sym);
1982 TYPE_TAG_NAME (sym->type) = SYMBOL_NAME (sym);
1983 if (dn_bufp->dtype.public)
1984 add_symbol_to_list (sym, &global_symbols);
1985 else if (WITHIN_FUNCTION (objfile))
1986 add_symbol_to_list (sym, &local_symbols);
1988 add_symbol_to_list (sym, &file_symbols);
1991 SYMBOL_TYPE (sym) = lookup_pointer_type (hpread_type_lookup
1992 (dn_bufp->dptr.pointsto,
1994 add_symbol_to_list (sym, &file_symbols);
1997 SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE;
1998 SYMBOL_TYPE (sym) = hpread_read_enum_type (hp_type, dn_bufp, objfile);
1999 add_symbol_to_list (sym, &file_symbols);
2004 SYMBOL_TYPE (sym) = hpread_read_set_type (hp_type, dn_bufp, objfile);
2005 add_symbol_to_list (sym, &file_symbols);
2008 SYMBOL_TYPE (sym) = hpread_read_subrange_type (hp_type, dn_bufp,
2010 add_symbol_to_list (sym, &file_symbols);
2013 SYMBOL_TYPE (sym) = hpread_read_array_type (hp_type, dn_bufp, objfile);
2014 add_symbol_to_list (sym, &file_symbols);
2018 SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE;
2019 SYMBOL_TYPE (sym) = hpread_read_struct_type (hp_type, dn_bufp, objfile);
2020 add_symbol_to_list (sym, &file_symbols);