]>
Commit | Line | Data |
---|---|---|
98c0e047 JL |
1 | /* Read hp debug symbols and convert to internal format, for GDB. |
2 | Copyright 1993 Free Software Foundation, Inc. | |
3 | ||
4 | This file is part of GDB. | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2 of the License, or | |
9 | (at your option) any later version. | |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with this program; if not, write to the Free Software | |
6c9638b4 | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
98c0e047 JL |
19 | |
20 | Written by the Center for Software Science at the University of Utah | |
21 | and by Cygnus Support. */ | |
22 | ||
23 | #include "defs.h" | |
24 | #include "bfd.h" | |
2b576293 | 25 | #include "gdb_string.h" |
2848f793 | 26 | #include "hp-symtab.h" |
98c0e047 JL |
27 | #include "syms.h" |
28 | #include "symtab.h" | |
29 | #include "symfile.h" | |
30 | #include "objfiles.h" | |
31 | #include "buildsym.h" | |
32 | #include "complaints.h" | |
33 | #include "gdb-stabs.h" | |
34 | #include "gdbtypes.h" | |
35 | ||
36 | /* Private information attached to an objfile which we use to find | |
37 | and internalize the HP C debug symbols within that objfile. */ | |
38 | ||
39 | struct hpread_symfile_info | |
40 | { | |
41 | /* The contents of each of the debug sections (there are 4 of them). */ | |
42 | char *gntt; | |
43 | char *lntt; | |
44 | char *slt; | |
45 | char *vt; | |
46 | ||
47 | /* We keep the size of the $VT$ section for range checking. */ | |
48 | unsigned int vt_size; | |
49 | ||
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; | |
54 | ||
55 | /* To keep track of all the types we've processed. */ | |
56 | struct type **type_vector; | |
57 | int type_vector_length; | |
58 | ||
59 | /* Keeps track of the beginning of a range of source lines. */ | |
2848f793 | 60 | sltpointer sl_index; |
98c0e047 JL |
61 | |
62 | /* Some state variables we'll need. */ | |
98c0e047 JL |
63 | int within_function; |
64 | ||
38ab0632 JL |
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; | |
98c0e047 JL |
68 | }; |
69 | ||
70 | /* Accessor macros to get at the fields. */ | |
71 | #define HPUX_SYMFILE_INFO(o) \ | |
72 | ((struct hpread_symfile_info *)((o)->sym_private)) | |
73 | #define GNTT(o) (HPUX_SYMFILE_INFO(o)->gntt) | |
74 | #define LNTT(o) (HPUX_SYMFILE_INFO(o)->lntt) | |
75 | #define SLT(o) (HPUX_SYMFILE_INFO(o)->slt) | |
76 | #define VT(o) (HPUX_SYMFILE_INFO(o)->vt) | |
77 | #define VT_SIZE(o) (HPUX_SYMFILE_INFO(o)->vt_size) | |
78 | #define LNTT_SYMCOUNT(o) (HPUX_SYMFILE_INFO(o)->lntt_symcount) | |
79 | #define GNTT_SYMCOUNT(o) (HPUX_SYMFILE_INFO(o)->gntt_symcount) | |
80 | #define TYPE_VECTOR(o) (HPUX_SYMFILE_INFO(o)->type_vector) | |
81 | #define TYPE_VECTOR_LENGTH(o) (HPUX_SYMFILE_INFO(o)->type_vector_length) | |
82 | #define SL_INDEX(o) (HPUX_SYMFILE_INFO(o)->sl_index) | |
98c0e047 JL |
83 | #define WITHIN_FUNCTION(o) (HPUX_SYMFILE_INFO(o)->within_function) |
84 | #define CURRENT_FUNCTION_VALUE(o) (HPUX_SYMFILE_INFO(o)->current_function_value) | |
85 | ||
86 | /* Given the native debug symbol SYM, set NAMEP to the name associated | |
87 | with the debug symbol. Note we may be called with a debug symbol which | |
88 | has no associated name, in that case we return an empty string. | |
89 | ||
90 | Also note we "know" that the name for any symbol is always in the | |
91 | same place. Hence we don't have to conditionalize on the symbol type. */ | |
92 | #define SET_NAMESTRING(SYM, NAMEP, OBJFILE) \ | |
93 | if (! hpread_has_name ((SYM)->dblock.kind)) \ | |
94 | *NAMEP = ""; \ | |
95 | else if (((unsigned)(SYM)->dsfile.name) >= VT_SIZE (OBJFILE)) \ | |
96 | { \ | |
97 | complain (&string_table_offset_complaint, (char *) symnum); \ | |
98 | *NAMEP = ""; \ | |
99 | } \ | |
100 | else \ | |
101 | *NAMEP = (SYM)->dsfile.name + VT (OBJFILE) | |
989d9cba | 102 | \f |
f133a597 JK |
103 | /* We put a pointer to this structure in the read_symtab_private field |
104 | of the psymtab. */ | |
98c0e047 JL |
105 | |
106 | struct symloc | |
107 | { | |
989d9cba JK |
108 | /* The offset within the file symbol table of first local symbol for |
109 | this file. */ | |
110 | ||
98c0e047 | 111 | int ldsymoff; |
989d9cba JK |
112 | |
113 | /* Length (in bytes) of the section of the symbol table devoted to | |
114 | this file's symbols (actually, the section bracketed may contain | |
115 | more than just this file's symbols). If ldsymlen is 0, the only | |
116 | reason for this thing's existence is the dependency list. | |
117 | Nothing else will happen when it is read in. */ | |
118 | ||
98c0e047 JL |
119 | int ldsymlen; |
120 | }; | |
121 | ||
989d9cba JK |
122 | #define LDSYMOFF(p) (((struct symloc *)((p)->read_symtab_private))->ldsymoff) |
123 | #define LDSYMLEN(p) (((struct symloc *)((p)->read_symtab_private))->ldsymlen) | |
124 | #define SYMLOC(p) ((struct symloc *)((p)->read_symtab_private)) | |
125 | \f | |
98c0e047 JL |
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; | |
129 | ||
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; | |
134 | ||
135 | \f | |
136 | void hpread_symfile_init PARAMS ((struct objfile *)); | |
137 | ||
138 | static struct type *hpread_alloc_type | |
2848f793 | 139 | PARAMS ((dnttpointer, struct objfile *)); |
98c0e047 JL |
140 | |
141 | static struct type **hpread_lookup_type | |
2848f793 | 142 | PARAMS ((dnttpointer, struct objfile *)); |
98c0e047 JL |
143 | |
144 | static struct type *hpread_read_enum_type | |
2848f793 | 145 | PARAMS ((dnttpointer, union dnttentry *, struct objfile *)); |
98c0e047 JL |
146 | |
147 | static struct type *hpread_read_set_type | |
2848f793 | 148 | PARAMS ((dnttpointer, union dnttentry *, struct objfile *)); |
98c0e047 JL |
149 | |
150 | static struct type *hpread_read_subrange_type | |
2848f793 | 151 | PARAMS ((dnttpointer, union dnttentry *, struct objfile *)); |
98c0e047 JL |
152 | |
153 | static struct type *hpread_read_struct_type | |
2848f793 | 154 | PARAMS ((dnttpointer, union dnttentry *, struct objfile *)); |
98c0e047 JL |
155 | |
156 | void hpread_build_psymtabs | |
157 | PARAMS ((struct objfile *, struct section_offsets *, int)); | |
158 | ||
159 | void hpread_symfile_finish PARAMS ((struct objfile *)); | |
160 | ||
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 *)); | |
164 | ||
165 | static struct partial_symtab *hpread_end_psymtab | |
166 | PARAMS ((struct partial_symtab *, char **, int, int, CORE_ADDR, | |
167 | struct partial_symtab **, int)); | |
168 | ||
169 | static struct symtab *hpread_expand_symtab | |
170 | PARAMS ((struct objfile *, int, int, CORE_ADDR, int, | |
171 | struct section_offsets *, char *)); | |
172 | ||
173 | static void hpread_process_one_debug_symbol | |
174 | PARAMS ((union dnttentry *, char *, struct section_offsets *, | |
175 | struct objfile *, CORE_ADDR, int, char *, int)); | |
176 | ||
2848f793 | 177 | static sltpointer hpread_record_lines |
3a0fbb3b JL |
178 | PARAMS ((struct subfile *, sltpointer, sltpointer, |
179 | struct objfile *, CORE_ADDR)); | |
98c0e047 JL |
180 | |
181 | static struct type *hpread_read_function_type | |
2848f793 | 182 | PARAMS ((dnttpointer, union dnttentry *, struct objfile *)); |
98c0e047 JL |
183 | |
184 | static struct type * hpread_type_lookup | |
2848f793 | 185 | PARAMS ((dnttpointer, struct objfile *)); |
98c0e047 JL |
186 | |
187 | static unsigned long hpread_get_depth | |
2848f793 | 188 | PARAMS ((sltpointer, struct objfile *)); |
98c0e047 JL |
189 | |
190 | static unsigned long hpread_get_line | |
2848f793 | 191 | PARAMS ((sltpointer, struct objfile *)); |
98c0e047 | 192 | |
2848f793 JL |
193 | static CORE_ADDR hpread_get_location |
194 | PARAMS ((sltpointer, struct objfile *)); | |
98c0e047 | 195 | |
2848f793 | 196 | static int hpread_type_translate PARAMS ((dnttpointer)); |
98c0e047 JL |
197 | static unsigned long hpread_get_textlow PARAMS ((int, int, struct objfile *)); |
198 | static union dnttentry *hpread_get_gntt PARAMS ((int, struct objfile *)); | |
199 | static union dnttentry *hpread_get_lntt PARAMS ((int, struct objfile *)); | |
200 | static union sltentry *hpread_get_slt PARAMS ((int, struct objfile *)); | |
201 | static void hpread_psymtab_to_symtab PARAMS ((struct partial_symtab *)); | |
202 | static void hpread_psymtab_to_symtab_1 PARAMS ((struct partial_symtab *)); | |
2848f793 | 203 | static int hpread_has_name PARAMS ((enum dntt_entry_type)); |
98c0e047 JL |
204 | |
205 | \f | |
206 | /* Initialization for reading native HP C debug symbols from OBJFILE. | |
207 | ||
208 | It's only purpose in life is to set up the symbol reader's private | |
209 | per-objfile data structures, and read in the raw contents of the debug | |
210 | sections (attaching pointers to the debug info into the private data | |
2848f793 | 211 | structures). |
98c0e047 JL |
212 | |
213 | Since BFD doesn't know how to read debug symbols in a format-independent | |
214 | way (and may never do so...), we have to do it ourselves. Note we may | |
215 | be called on a file without native HP C debugging symbols. | |
216 | FIXME, there should be a cleaner peephole into the BFD environment here. */ | |
217 | ||
218 | void | |
219 | hpread_symfile_init (objfile) | |
220 | struct objfile *objfile; | |
221 | { | |
222 | asection *vt_section, *slt_section, *lntt_section, *gntt_section; | |
223 | ||
224 | /* Allocate struct to keep track of the symfile */ | |
225 | objfile->sym_private = (PTR) | |
226 | xmmalloc (objfile->md, sizeof (struct hpread_symfile_info)); | |
227 | memset (objfile->sym_private, 0, sizeof (struct hpread_symfile_info)); | |
228 | ||
229 | /* We haven't read in any types yet. */ | |
230 | TYPE_VECTOR (objfile) = 0; | |
231 | ||
232 | /* Read in data from the $GNTT$ subspace. */ | |
233 | gntt_section = bfd_get_section_by_name (objfile->obfd, "$GNTT$"); | |
234 | if (!gntt_section) | |
235 | return; | |
236 | ||
237 | GNTT (objfile) | |
238 | = obstack_alloc (&objfile->symbol_obstack, | |
239 | bfd_section_size (objfile->obfd, gntt_section)); | |
240 | ||
241 | bfd_get_section_contents (objfile->obfd, gntt_section, GNTT (objfile), | |
242 | 0, bfd_section_size (objfile->obfd, gntt_section)); | |
243 | ||
244 | GNTT_SYMCOUNT (objfile) | |
2848f793 JL |
245 | = bfd_section_size (objfile->obfd, gntt_section) |
246 | / sizeof (struct dntt_type_block); | |
98c0e047 JL |
247 | |
248 | /* Read in data from the $LNTT$ subspace. Also keep track of the number | |
249 | of LNTT symbols. */ | |
250 | lntt_section = bfd_get_section_by_name (objfile->obfd, "$LNTT$"); | |
251 | if (!lntt_section) | |
252 | return; | |
253 | ||
254 | LNTT (objfile) | |
255 | = obstack_alloc (&objfile->symbol_obstack, | |
256 | bfd_section_size (objfile->obfd, lntt_section)); | |
257 | ||
258 | bfd_get_section_contents (objfile->obfd, lntt_section, LNTT (objfile), | |
259 | 0, bfd_section_size (objfile->obfd, lntt_section)); | |
260 | ||
261 | LNTT_SYMCOUNT (objfile) | |
2848f793 JL |
262 | = bfd_section_size (objfile->obfd, lntt_section) |
263 | / sizeof (struct dntt_type_block); | |
98c0e047 JL |
264 | |
265 | /* Read in data from the $SLT$ subspace. $SLT$ contains information | |
266 | on source line numbers. */ | |
267 | slt_section = bfd_get_section_by_name (objfile->obfd, "$SLT$"); | |
268 | if (!slt_section) | |
269 | return; | |
270 | ||
271 | SLT (objfile) = | |
272 | obstack_alloc (&objfile->symbol_obstack, | |
273 | bfd_section_size (objfile->obfd, slt_section)); | |
274 | ||
275 | bfd_get_section_contents (objfile->obfd, slt_section, SLT (objfile), | |
276 | 0, bfd_section_size (objfile->obfd, slt_section)); | |
277 | ||
278 | /* Read in data from the $VT$ subspace. $VT$ contains things like | |
279 | names and constants. Keep track of the number of symbols in the VT. */ | |
280 | vt_section = bfd_get_section_by_name (objfile->obfd, "$VT$"); | |
281 | if (!vt_section) | |
282 | return; | |
283 | ||
284 | VT_SIZE (objfile) = bfd_section_size (objfile->obfd, vt_section); | |
285 | ||
286 | VT (objfile) = | |
287 | (char *) obstack_alloc (&objfile->symbol_obstack, | |
288 | VT_SIZE (objfile)); | |
289 | ||
290 | bfd_get_section_contents (objfile->obfd, vt_section, VT (objfile), | |
291 | 0, VT_SIZE (objfile)); | |
292 | } | |
293 | ||
294 | /* Scan and build partial symbols for a symbol file. | |
295 | ||
296 | The minimal symbol table (either SOM or HP a.out) has already been | |
297 | read in; all we need to do is setup partial symbols based on the | |
298 | native debugging information. | |
299 | ||
300 | We assume hpread_symfile_init has been called to initialize the | |
301 | symbol reader's private data structures. | |
302 | ||
303 | SECTION_OFFSETS contains offsets relative to which the symbols in the | |
304 | various sections are (depending where the sections were actually loaded). | |
305 | MAINLINE is true if we are reading the main symbol | |
306 | table (as opposed to a shared lib or dynamically loaded file). */ | |
307 | ||
308 | void | |
309 | hpread_build_psymtabs (objfile, section_offsets, mainline) | |
310 | struct objfile *objfile; | |
311 | struct section_offsets *section_offsets; | |
312 | int mainline; | |
313 | { | |
314 | char *namestring; | |
315 | int past_first_source_file = 0; | |
316 | struct cleanup *old_chain; | |
317 | ||
318 | int hp_symnum, symcount, i; | |
319 | ||
320 | union dnttentry *dn_bufp; | |
321 | unsigned long valu; | |
322 | char *p; | |
323 | int texthigh = 0; | |
324 | int have_name = 0; | |
325 | ||
326 | /* Current partial symtab */ | |
327 | struct partial_symtab *pst; | |
328 | ||
329 | /* List of current psymtab's include files */ | |
330 | char **psymtab_include_list; | |
331 | int includes_allocated; | |
332 | int includes_used; | |
333 | ||
334 | /* Index within current psymtab dependency list */ | |
335 | struct partial_symtab **dependency_list; | |
336 | int dependencies_used, dependencies_allocated; | |
337 | ||
338 | /* Just in case the stabs reader left turds lying around. */ | |
339 | pending_blocks = 0; | |
340 | make_cleanup (really_free_pendings, 0); | |
341 | ||
342 | pst = (struct partial_symtab *) 0; | |
343 | ||
344 | /* We shouldn't use alloca, instead use malloc/free. Doing so avoids | |
345 | a number of problems with cross compilation and creating useless holes | |
346 | in the stack when we have to allocate new entries. FIXME. */ | |
347 | ||
348 | includes_allocated = 30; | |
349 | includes_used = 0; | |
350 | psymtab_include_list = (char **) alloca (includes_allocated * | |
351 | sizeof (char *)); | |
352 | ||
353 | dependencies_allocated = 30; | |
354 | dependencies_used = 0; | |
355 | dependency_list = | |
356 | (struct partial_symtab **) alloca (dependencies_allocated * | |
357 | sizeof (struct partial_symtab *)); | |
358 | ||
359 | old_chain = make_cleanup (free_objfile, objfile); | |
360 | ||
361 | last_source_file = 0; | |
362 | ||
363 | /* Make two passes, one ofr the GNTT symbols, the other for the | |
364 | LNTT symbols. */ | |
365 | for (i = 0; i < 1; i++) | |
366 | { | |
367 | int within_function = 0; | |
368 | ||
369 | if (i) | |
370 | symcount = GNTT_SYMCOUNT (objfile); | |
371 | else | |
372 | symcount = LNTT_SYMCOUNT (objfile); | |
373 | ||
374 | for (hp_symnum = 0; hp_symnum < symcount; hp_symnum++) | |
375 | { | |
376 | QUIT; | |
377 | if (i) | |
378 | dn_bufp = hpread_get_gntt (hp_symnum, objfile); | |
379 | else | |
380 | dn_bufp = hpread_get_lntt (hp_symnum, objfile); | |
381 | ||
382 | if (dn_bufp->dblock.extension) | |
383 | continue; | |
384 | ||
385 | /* Only handle things which are necessary for minimal symbols. | |
386 | everything else is ignored. */ | |
387 | switch (dn_bufp->dblock.kind) | |
388 | { | |
2848f793 | 389 | case DNTT_TYPE_SRCFILE: |
98c0e047 JL |
390 | { |
391 | /* A source file of some kind. Note this may simply | |
392 | be an included file. */ | |
393 | SET_NAMESTRING (dn_bufp, &namestring, objfile); | |
394 | ||
395 | /* Check if this is the source file we are already working | |
396 | with. */ | |
397 | if (pst && !strcmp (namestring, pst->filename)) | |
398 | continue; | |
399 | ||
400 | /* Check if this is an include file, if so check if we have | |
401 | already seen it. Add it to the include list */ | |
402 | p = strrchr (namestring, '.'); | |
403 | if (!strcmp (p, ".h")) | |
404 | { | |
405 | int j, found; | |
406 | ||
407 | found = 0; | |
408 | for (j = 0; j < includes_used; j++) | |
409 | if (!strcmp (namestring, psymtab_include_list[j])) | |
410 | { | |
411 | found = 1; | |
412 | break; | |
413 | } | |
414 | if (found) | |
415 | continue; | |
416 | ||
417 | /* Add it to the list of includes seen so far and | |
418 | allocate more include space if necessary. */ | |
419 | psymtab_include_list[includes_used++] = namestring; | |
420 | if (includes_used >= includes_allocated) | |
421 | { | |
422 | char **orig = psymtab_include_list; | |
423 | ||
424 | psymtab_include_list = (char **) | |
425 | alloca ((includes_allocated *= 2) * | |
426 | sizeof (char *)); | |
427 | memcpy ((PTR) psymtab_include_list, (PTR) orig, | |
428 | includes_used * sizeof (char *)); | |
429 | } | |
430 | continue; | |
431 | } | |
432 | ||
433 | ||
38ab0632 | 434 | if (pst) |
98c0e047 JL |
435 | { |
436 | if (!have_name) | |
437 | { | |
38ab0632 JL |
438 | pst->filename = (char *) |
439 | obstack_alloc (&pst->objfile->psymbol_obstack, | |
440 | strlen (namestring) + 1); | |
98c0e047 JL |
441 | strcpy (pst->filename, namestring); |
442 | have_name = 1; | |
443 | continue; | |
444 | } | |
445 | continue; | |
446 | } | |
447 | ||
448 | /* This is a bonafide new source file. | |
449 | End the current partial symtab and start a new one. */ | |
450 | ||
451 | if (pst && past_first_source_file) | |
452 | { | |
98c0e047 JL |
453 | hpread_end_psymtab (pst, psymtab_include_list, |
454 | includes_used, | |
2848f793 JL |
455 | (hp_symnum |
456 | * sizeof (struct dntt_type_block)), | |
457 | texthigh, | |
98c0e047 JL |
458 | dependency_list, dependencies_used); |
459 | pst = (struct partial_symtab *) 0; | |
460 | includes_used = 0; | |
461 | dependencies_used = 0; | |
462 | } | |
463 | else | |
464 | past_first_source_file = 1; | |
465 | ||
466 | valu = hpread_get_textlow (i, hp_symnum, objfile); | |
467 | valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); | |
468 | pst = hpread_start_psymtab (objfile, section_offsets, | |
469 | namestring, valu, | |
2848f793 JL |
470 | (hp_symnum |
471 | * sizeof (struct dntt_type_block)), | |
98c0e047 JL |
472 | objfile->global_psymbols.next, |
473 | objfile->static_psymbols.next); | |
474 | texthigh = valu; | |
38ab0632 | 475 | have_name = 1; |
98c0e047 JL |
476 | continue; |
477 | } | |
478 | ||
2848f793 | 479 | case DNTT_TYPE_MODULE: |
98c0e047 | 480 | /* A source file. It's still unclear to me what the |
2848f793 | 481 | real difference between a DNTT_TYPE_SRCFILE and DNTT_TYPE_MODULE |
98c0e047 JL |
482 | is supposed to be. */ |
483 | SET_NAMESTRING (dn_bufp, &namestring, objfile); | |
484 | valu = hpread_get_textlow (i, hp_symnum, objfile); | |
485 | valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); | |
38ab0632 JL |
486 | if (!pst) |
487 | { | |
488 | pst = hpread_start_psymtab (objfile, section_offsets, | |
489 | namestring, valu, | |
2848f793 JL |
490 | (hp_symnum |
491 | * sizeof (struct dntt_type_block)), | |
38ab0632 JL |
492 | objfile->global_psymbols.next, |
493 | objfile->static_psymbols.next); | |
494 | texthigh = valu; | |
495 | have_name = 0; | |
496 | } | |
98c0e047 | 497 | continue; |
2848f793 JL |
498 | case DNTT_TYPE_FUNCTION: |
499 | case DNTT_TYPE_ENTRY: | |
500 | /* The beginning of a function. DNTT_TYPE_ENTRY may also denote | |
98c0e047 | 501 | a secondary entry point. */ |
3a0fbb3b JL |
502 | valu = dn_bufp->dfunc.hiaddr + ANOFFSET (section_offsets, |
503 | SECT_OFF_TEXT); | |
504 | if (valu > texthigh) | |
505 | texthigh = valu; | |
98c0e047 JL |
506 | valu = dn_bufp->dfunc.lowaddr + |
507 | ANOFFSET (section_offsets, SECT_OFF_TEXT); | |
98c0e047 JL |
508 | SET_NAMESTRING (dn_bufp, &namestring, objfile); |
509 | ADD_PSYMBOL_TO_LIST (namestring, strlen (namestring), | |
510 | VAR_NAMESPACE, LOC_BLOCK, | |
511 | objfile->static_psymbols, valu, | |
512 | language_unknown, objfile); | |
513 | within_function = 1; | |
514 | continue; | |
2848f793 JL |
515 | case DNTT_TYPE_BEGIN: |
516 | case DNTT_TYPE_END: | |
98c0e047 JL |
517 | /* Scope block begin/end. We only care about function |
518 | and file blocks right now. */ | |
2848f793 | 519 | if (dn_bufp->dend.endkind == DNTT_TYPE_MODULE) |
98c0e047 | 520 | { |
98c0e047 | 521 | hpread_end_psymtab (pst, psymtab_include_list, includes_used, |
2848f793 JL |
522 | (hp_symnum |
523 | * sizeof (struct dntt_type_block)), | |
524 | texthigh, | |
98c0e047 JL |
525 | dependency_list, dependencies_used); |
526 | pst = (struct partial_symtab *) 0; | |
527 | includes_used = 0; | |
528 | dependencies_used = 0; | |
98c0e047 JL |
529 | have_name = 0; |
530 | } | |
2848f793 | 531 | if (dn_bufp->dend.endkind == DNTT_TYPE_FUNCTION) |
98c0e047 JL |
532 | within_function = 0; |
533 | continue; | |
2848f793 JL |
534 | case DNTT_TYPE_SVAR: |
535 | case DNTT_TYPE_DVAR: | |
536 | case DNTT_TYPE_TYPEDEF: | |
537 | case DNTT_TYPE_TAGDEF: | |
98c0e047 JL |
538 | { |
539 | /* Variables, typedefs an the like. */ | |
540 | enum address_class storage; | |
541 | enum namespace namespace; | |
542 | ||
543 | /* Don't add locals to the partial symbol table. */ | |
544 | if (within_function | |
2848f793 JL |
545 | && (dn_bufp->dblock.kind == DNTT_TYPE_SVAR |
546 | || dn_bufp->dblock.kind == DNTT_TYPE_DVAR)) | |
98c0e047 JL |
547 | continue; |
548 | ||
549 | /* TAGDEFs go into the structure namespace. */ | |
2848f793 | 550 | if (dn_bufp->dblock.kind == DNTT_TYPE_TAGDEF) |
98c0e047 JL |
551 | namespace = STRUCT_NAMESPACE; |
552 | else | |
553 | namespace = VAR_NAMESPACE; | |
554 | ||
555 | /* What kind of "storage" does this use? */ | |
2848f793 | 556 | if (dn_bufp->dblock.kind == DNTT_TYPE_SVAR) |
98c0e047 | 557 | storage = LOC_STATIC; |
2848f793 | 558 | else if (dn_bufp->dblock.kind == DNTT_TYPE_DVAR |
98c0e047 JL |
559 | && dn_bufp->ddvar.regvar) |
560 | storage = LOC_REGISTER; | |
2848f793 | 561 | else if (dn_bufp->dblock.kind == DNTT_TYPE_DVAR) |
98c0e047 JL |
562 | storage = LOC_LOCAL; |
563 | else | |
564 | storage = LOC_UNDEF; | |
565 | ||
566 | SET_NAMESTRING (dn_bufp, &namestring, objfile); | |
567 | if (!pst) | |
568 | { | |
569 | pst = hpread_start_psymtab (objfile, section_offsets, | |
570 | "globals", 0, | |
2848f793 JL |
571 | (hp_symnum |
572 | * sizeof (struct dntt_type_block)), | |
98c0e047 JL |
573 | objfile->global_psymbols.next, |
574 | objfile->static_psymbols.next); | |
575 | } | |
2848f793 | 576 | if (dn_bufp->dsvar.global) |
98c0e047 JL |
577 | { |
578 | ADD_PSYMBOL_TO_LIST (namestring, strlen (namestring), | |
579 | namespace, storage, | |
580 | objfile->global_psymbols, | |
581 | dn_bufp->dsvar.location, | |
582 | language_unknown, objfile); | |
583 | } | |
584 | else | |
585 | { | |
586 | ADD_PSYMBOL_TO_LIST (namestring, strlen (namestring), | |
587 | namespace, storage, | |
588 | objfile->static_psymbols, | |
589 | dn_bufp->dsvar.location, | |
590 | language_unknown, objfile); | |
591 | } | |
592 | continue; | |
593 | } | |
2848f793 JL |
594 | case DNTT_TYPE_MEMENUM: |
595 | case DNTT_TYPE_CONST: | |
98c0e047 JL |
596 | /* Constants and members of enumerated types. */ |
597 | SET_NAMESTRING (dn_bufp, &namestring, objfile); | |
598 | if (!pst) | |
599 | { | |
600 | pst = hpread_start_psymtab (objfile, section_offsets, | |
601 | "globals", 0, | |
2848f793 JL |
602 | (hp_symnum |
603 | * sizeof (struct dntt_type_block)), | |
98c0e047 JL |
604 | objfile->global_psymbols.next, |
605 | objfile->static_psymbols.next); | |
606 | } | |
607 | ADD_PSYMBOL_TO_LIST (namestring, strlen (namestring), | |
608 | VAR_NAMESPACE, LOC_CONST, | |
609 | objfile->static_psymbols, 0, | |
610 | language_unknown, objfile); | |
611 | continue; | |
612 | default: | |
613 | continue; | |
614 | } | |
615 | } | |
616 | } | |
617 | ||
618 | /* End any pending partial symbol table. */ | |
619 | if (pst) | |
620 | { | |
621 | hpread_end_psymtab (pst, psymtab_include_list, includes_used, | |
2848f793 JL |
622 | hp_symnum * sizeof (struct dntt_type_block), |
623 | 0, dependency_list, dependencies_used); | |
98c0e047 JL |
624 | } |
625 | ||
626 | discard_cleanups (old_chain); | |
627 | } | |
628 | ||
629 | /* Perform any local cleanups required when we are done with a particular | |
630 | objfile. I.E, we are in the process of discarding all symbol information | |
631 | for an objfile, freeing up all memory held for it, and unlinking the | |
632 | objfile struct from the global list of known objfiles. */ | |
633 | ||
634 | void | |
635 | hpread_symfile_finish (objfile) | |
636 | struct objfile *objfile; | |
637 | { | |
638 | if (objfile->sym_private != NULL) | |
639 | { | |
640 | mfree (objfile->md, objfile->sym_private); | |
641 | } | |
642 | } | |
643 | \f | |
644 | ||
645 | /* The remaining functions are all for internal use only. */ | |
646 | ||
647 | /* Various small functions to get entries in the debug symbol sections. */ | |
648 | ||
649 | static union dnttentry * | |
650 | hpread_get_lntt (index, objfile) | |
651 | int index; | |
652 | struct objfile *objfile; | |
653 | { | |
2848f793 JL |
654 | return (union dnttentry *) |
655 | &(LNTT (objfile)[(index * sizeof (struct dntt_type_block))]); | |
98c0e047 JL |
656 | } |
657 | ||
658 | static union dnttentry * | |
659 | hpread_get_gntt (index, objfile) | |
660 | int index; | |
661 | struct objfile *objfile; | |
662 | { | |
2848f793 JL |
663 | return (union dnttentry *) |
664 | &(GNTT (objfile)[(index * sizeof (struct dntt_type_block))]); | |
98c0e047 JL |
665 | } |
666 | ||
667 | static union sltentry * | |
668 | hpread_get_slt (index, objfile) | |
669 | int index; | |
670 | struct objfile *objfile; | |
671 | { | |
2848f793 | 672 | return (union sltentry *)&(SLT (objfile)[index * sizeof (union sltentry)]); |
98c0e047 JL |
673 | } |
674 | ||
675 | /* Get the low address associated with some symbol (typically the start | |
676 | of a particular source file or module). Since that information is not | |
2848f793 JL |
677 | stored as part of the DNTT_TYPE_MODULE or DNTT_TYPE_SRCFILE symbol we must infer it from |
678 | the existance of DNTT_TYPE_FUNCTION symbols. */ | |
98c0e047 JL |
679 | |
680 | static unsigned long | |
681 | hpread_get_textlow (global, index, objfile) | |
682 | int global; | |
683 | int index; | |
684 | struct objfile *objfile; | |
685 | { | |
686 | union dnttentry *dn_bufp; | |
687 | struct minimal_symbol *msymbol; | |
688 | ||
2848f793 | 689 | /* Look for a DNTT_TYPE_FUNCTION symbol. */ |
98c0e047 JL |
690 | do |
691 | { | |
692 | if (global) | |
693 | dn_bufp = hpread_get_gntt (index++, objfile); | |
694 | else | |
695 | dn_bufp = hpread_get_lntt (index++, objfile); | |
2848f793 JL |
696 | } while (dn_bufp->dblock.kind != DNTT_TYPE_FUNCTION |
697 | && dn_bufp->dblock.kind != DNTT_TYPE_END); | |
98c0e047 | 698 | |
2848f793 | 699 | /* Avoid going past a DNTT_TYPE_END when looking for a DNTT_TYPE_FUNCTION. This |
98c0e047 | 700 | might happen when a sourcefile has no functions. */ |
2848f793 | 701 | if (dn_bufp->dblock.kind == DNTT_TYPE_END) |
98c0e047 JL |
702 | return 0; |
703 | ||
704 | /* The minimal symbols are typically more accurate for some reason. */ | |
2d336b1b | 705 | msymbol = lookup_minimal_symbol (dn_bufp->dfunc.name + VT (objfile), NULL, |
98c0e047 JL |
706 | objfile); |
707 | if (msymbol) | |
708 | return SYMBOL_VALUE_ADDRESS (msymbol); | |
709 | else | |
710 | return dn_bufp->dfunc.lowaddr; | |
711 | } | |
712 | ||
713 | /* Get the nesting depth for the source line identified by INDEX. */ | |
714 | ||
715 | static unsigned long | |
716 | hpread_get_depth (index, objfile) | |
2848f793 | 717 | sltpointer index; |
98c0e047 JL |
718 | struct objfile *objfile; |
719 | { | |
720 | union sltentry *sl_bufp; | |
721 | ||
722 | sl_bufp = hpread_get_slt (index, objfile); | |
723 | return sl_bufp->sspec.backptr.dnttp.index; | |
724 | } | |
725 | ||
726 | /* Get the source line number the the line identified by INDEX. */ | |
727 | ||
728 | static unsigned long | |
729 | hpread_get_line (index, objfile) | |
2848f793 | 730 | sltpointer index; |
98c0e047 JL |
731 | struct objfile *objfile; |
732 | { | |
733 | union sltentry *sl_bufp; | |
734 | ||
735 | sl_bufp = hpread_get_slt (index, objfile); | |
736 | return sl_bufp->snorm.line; | |
737 | } | |
738 | ||
2848f793 | 739 | static CORE_ADDR |
98c0e047 | 740 | hpread_get_location (index, objfile) |
2848f793 | 741 | sltpointer index; |
98c0e047 JL |
742 | struct objfile *objfile; |
743 | { | |
744 | union sltentry *sl_bufp; | |
745 | int i; | |
746 | ||
747 | /* code location of special sltentrys is determined from context */ | |
748 | sl_bufp = hpread_get_slt (index, objfile); | |
749 | ||
750 | if (sl_bufp->snorm.sltdesc == SLT_END) | |
751 | { | |
752 | /* find previous normal sltentry and get address */ | |
753 | for (i = 0; ((sl_bufp->snorm.sltdesc != SLT_NORMAL) && | |
754 | (sl_bufp->snorm.sltdesc != SLT_EXIT)); i++) | |
755 | sl_bufp = hpread_get_slt (index - i, objfile); | |
756 | return sl_bufp->snorm.address; | |
757 | } | |
758 | ||
759 | /* find next normal sltentry and get address */ | |
760 | for (i = 0; ((sl_bufp->snorm.sltdesc != SLT_NORMAL) && | |
761 | (sl_bufp->snorm.sltdesc != SLT_EXIT)); i++) | |
762 | sl_bufp = hpread_get_slt (index + i, objfile); | |
763 | return sl_bufp->snorm.address; | |
764 | } | |
765 | \f | |
766 | ||
767 | /* Return 1 if an HP debug symbol of type KIND has a name associated with | |
768 | it, else return 0. */ | |
769 | ||
770 | static int | |
771 | hpread_has_name (kind) | |
2848f793 | 772 | enum dntt_entry_type kind; |
98c0e047 JL |
773 | { |
774 | switch (kind) | |
775 | { | |
2848f793 JL |
776 | case DNTT_TYPE_SRCFILE: |
777 | case DNTT_TYPE_MODULE: | |
778 | case DNTT_TYPE_FUNCTION: | |
779 | case DNTT_TYPE_ENTRY: | |
780 | case DNTT_TYPE_IMPORT: | |
781 | case DNTT_TYPE_LABEL: | |
782 | case DNTT_TYPE_FPARAM: | |
783 | case DNTT_TYPE_SVAR: | |
784 | case DNTT_TYPE_DVAR: | |
785 | case DNTT_TYPE_CONST: | |
786 | case DNTT_TYPE_TYPEDEF: | |
787 | case DNTT_TYPE_TAGDEF: | |
788 | case DNTT_TYPE_MEMENUM: | |
789 | case DNTT_TYPE_FIELD: | |
790 | case DNTT_TYPE_SA: | |
98c0e047 JL |
791 | return 1; |
792 | ||
2848f793 JL |
793 | case DNTT_TYPE_BEGIN: |
794 | case DNTT_TYPE_END: | |
795 | case DNTT_TYPE_WITH: | |
796 | case DNTT_TYPE_COMMON: | |
797 | case DNTT_TYPE_POINTER: | |
798 | case DNTT_TYPE_ENUM: | |
799 | case DNTT_TYPE_SET: | |
800 | case DNTT_TYPE_SUBRANGE: | |
801 | case DNTT_TYPE_ARRAY: | |
802 | case DNTT_TYPE_STRUCT: | |
803 | case DNTT_TYPE_UNION: | |
804 | case DNTT_TYPE_VARIANT: | |
805 | case DNTT_TYPE_FILE: | |
806 | case DNTT_TYPE_FUNCTYPE: | |
807 | case DNTT_TYPE_COBSTRUCT: | |
808 | case DNTT_TYPE_XREF: | |
809 | case DNTT_TYPE_MACRO: | |
98c0e047 JL |
810 | default: |
811 | return 0; | |
812 | } | |
813 | } | |
814 | ||
815 | /* Allocate and partially fill a partial symtab. It will be | |
816 | completely filled at the end of the symbol list. | |
817 | ||
818 | SYMFILE_NAME is the name of the symbol-file we are reading from, and ADDR | |
819 | is the address relative to which its symbols are (incremental) or 0 | |
820 | (normal). */ | |
821 | ||
822 | static struct partial_symtab * | |
823 | hpread_start_psymtab (objfile, section_offsets, | |
824 | filename, textlow, ldsymoff, global_syms, static_syms) | |
825 | struct objfile *objfile; | |
826 | struct section_offsets *section_offsets; | |
827 | char *filename; | |
828 | CORE_ADDR textlow; | |
829 | int ldsymoff; | |
830 | struct partial_symbol *global_syms; | |
831 | struct partial_symbol *static_syms; | |
832 | { | |
833 | struct partial_symtab *result = | |
834 | start_psymtab_common (objfile, section_offsets, | |
835 | filename, textlow, global_syms, static_syms); | |
836 | ||
837 | result->read_symtab_private = (char *) | |
838 | obstack_alloc (&objfile->psymbol_obstack, sizeof (struct symloc)); | |
839 | LDSYMOFF (result) = ldsymoff; | |
840 | result->read_symtab = hpread_psymtab_to_symtab; | |
841 | ||
842 | return result; | |
843 | } | |
844 | \f | |
845 | ||
846 | /* Close off the current usage of PST. | |
847 | Returns PST or NULL if the partial symtab was empty and thrown away. | |
848 | ||
849 | FIXME: List variables and peculiarities of same. */ | |
850 | ||
851 | static struct partial_symtab * | |
852 | hpread_end_psymtab (pst, include_list, num_includes, capping_symbol_offset, | |
853 | capping_text, dependency_list, number_dependencies) | |
854 | struct partial_symtab *pst; | |
855 | char **include_list; | |
856 | int num_includes; | |
857 | int capping_symbol_offset; | |
858 | CORE_ADDR capping_text; | |
859 | struct partial_symtab **dependency_list; | |
860 | int number_dependencies; | |
861 | { | |
862 | int i; | |
863 | struct objfile *objfile = pst -> objfile; | |
864 | ||
865 | if (capping_symbol_offset != -1) | |
866 | LDSYMLEN(pst) = capping_symbol_offset - LDSYMOFF(pst); | |
867 | pst->texthigh = capping_text; | |
868 | ||
869 | pst->n_global_syms = | |
870 | objfile->global_psymbols.next - (objfile->global_psymbols.list + pst->globals_offset); | |
871 | pst->n_static_syms = | |
872 | objfile->static_psymbols.next - (objfile->static_psymbols.list + pst->statics_offset); | |
873 | ||
874 | pst->number_of_dependencies = number_dependencies; | |
875 | if (number_dependencies) | |
876 | { | |
877 | pst->dependencies = (struct partial_symtab **) | |
878 | obstack_alloc (&objfile->psymbol_obstack, | |
879 | number_dependencies * sizeof (struct partial_symtab *)); | |
880 | memcpy (pst->dependencies, dependency_list, | |
881 | number_dependencies * sizeof (struct partial_symtab *)); | |
882 | } | |
883 | else | |
884 | pst->dependencies = 0; | |
885 | ||
886 | for (i = 0; i < num_includes; i++) | |
887 | { | |
888 | struct partial_symtab *subpst = | |
889 | allocate_psymtab (include_list[i], objfile); | |
890 | ||
891 | subpst->section_offsets = pst->section_offsets; | |
892 | subpst->read_symtab_private = | |
893 | (char *) obstack_alloc (&objfile->psymbol_obstack, | |
894 | sizeof (struct symloc)); | |
895 | LDSYMOFF(subpst) = | |
896 | LDSYMLEN(subpst) = | |
897 | subpst->textlow = | |
898 | subpst->texthigh = 0; | |
899 | ||
900 | /* We could save slight bits of space by only making one of these, | |
901 | shared by the entire set of include files. FIXME-someday. */ | |
902 | subpst->dependencies = (struct partial_symtab **) | |
903 | obstack_alloc (&objfile->psymbol_obstack, | |
904 | sizeof (struct partial_symtab *)); | |
905 | subpst->dependencies[0] = pst; | |
906 | subpst->number_of_dependencies = 1; | |
907 | ||
908 | subpst->globals_offset = | |
909 | subpst->n_global_syms = | |
910 | subpst->statics_offset = | |
911 | subpst->n_static_syms = 0; | |
912 | ||
913 | subpst->readin = 0; | |
914 | subpst->symtab = 0; | |
915 | subpst->read_symtab = pst->read_symtab; | |
916 | } | |
917 | ||
918 | sort_pst_symbols (pst); | |
919 | ||
920 | /* If there is already a psymtab or symtab for a file of this name, remove it. | |
921 | (If there is a symtab, more drastic things also happen.) | |
922 | This happens in VxWorks. */ | |
923 | free_named_symtabs (pst->filename); | |
924 | ||
925 | if (num_includes == 0 | |
926 | && number_dependencies == 0 | |
927 | && pst->n_global_syms == 0 | |
928 | && pst->n_static_syms == 0) | |
929 | { | |
930 | /* Throw away this psymtab, it's empty. We can't deallocate it, since | |
931 | it is on the obstack, but we can forget to chain it on the list. */ | |
932 | /* Empty psymtabs happen as a result of header files which don't have | |
933 | any symbols in them. There can be a lot of them. But this check | |
934 | is wrong, in that a psymtab with N_SLINE entries but nothing else | |
935 | is not empty, but we don't realize that. Fixing that without slowing | |
936 | things down might be tricky. */ | |
937 | struct partial_symtab *prev_pst; | |
938 | ||
939 | /* First, snip it out of the psymtab chain */ | |
940 | ||
941 | if (pst->objfile->psymtabs == pst) | |
942 | pst->objfile->psymtabs = pst->next; | |
943 | else | |
944 | for (prev_pst = pst->objfile->psymtabs; prev_pst; prev_pst = pst->next) | |
945 | if (prev_pst->next == pst) | |
946 | prev_pst->next = pst->next; | |
947 | ||
948 | /* Next, put it on a free list for recycling */ | |
949 | ||
950 | pst->next = pst->objfile->free_psymtabs; | |
951 | pst->objfile->free_psymtabs = pst; | |
952 | ||
953 | /* Indicate that psymtab was thrown away. */ | |
954 | pst = (struct partial_symtab *)NULL; | |
955 | } | |
956 | return pst; | |
957 | } | |
958 | \f | |
959 | /* Do the dirty work of reading in the full symbol from a partial symbol | |
960 | table. */ | |
961 | ||
962 | static void | |
963 | hpread_psymtab_to_symtab_1 (pst) | |
964 | struct partial_symtab *pst; | |
965 | { | |
966 | struct cleanup *old_chain; | |
967 | int i; | |
968 | ||
969 | /* Get out quick if passed junk. */ | |
970 | if (!pst) | |
971 | return; | |
972 | ||
973 | /* Complain if we've already read in this symbol table. */ | |
974 | if (pst->readin) | |
975 | { | |
976 | fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n", | |
977 | pst->filename); | |
978 | return; | |
979 | } | |
980 | ||
981 | /* Read in all partial symtabs on which this one is dependent */ | |
982 | for (i = 0; i < pst->number_of_dependencies; i++) | |
983 | if (!pst->dependencies[i]->readin) | |
984 | { | |
985 | /* Inform about additional files that need to be read in. */ | |
986 | if (info_verbose) | |
987 | { | |
988 | fputs_filtered (" ", stdout); | |
989 | wrap_here (""); | |
990 | fputs_filtered ("and ", stdout); | |
991 | wrap_here (""); | |
992 | printf_filtered ("%s...", pst->dependencies[i]->filename); | |
993 | wrap_here (""); /* Flush output */ | |
994 | fflush (stdout); | |
995 | } | |
996 | hpread_psymtab_to_symtab_1 (pst->dependencies[i]); | |
997 | } | |
998 | ||
999 | /* If it's real... */ | |
1000 | if (LDSYMLEN (pst)) | |
1001 | { | |
1002 | /* Init stuff necessary for reading in symbols */ | |
1003 | buildsym_init (); | |
1004 | old_chain = make_cleanup (really_free_pendings, 0); | |
1005 | ||
1006 | pst->symtab = | |
1007 | hpread_expand_symtab (pst->objfile, LDSYMOFF (pst), LDSYMLEN (pst), | |
1008 | pst->textlow, pst->texthigh - pst->textlow, | |
1009 | pst->section_offsets, pst->filename); | |
1010 | sort_symtab_syms (pst->symtab); | |
1011 | ||
1012 | do_cleanups (old_chain); | |
1013 | } | |
1014 | ||
1015 | pst->readin = 1; | |
1016 | } | |
1017 | ||
1018 | /* Read in all of the symbols for a given psymtab for real. | |
1019 | Be verbose about it if the user wants that. */ | |
1020 | ||
1021 | static void | |
1022 | hpread_psymtab_to_symtab (pst) | |
1023 | struct partial_symtab *pst; | |
1024 | { | |
1025 | /* Get out quick if given junk. */ | |
1026 | if (!pst) | |
1027 | return; | |
1028 | ||
1029 | /* Sanity check. */ | |
1030 | if (pst->readin) | |
1031 | { | |
1032 | fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n", | |
1033 | pst->filename); | |
1034 | return; | |
1035 | } | |
1036 | ||
1037 | if (LDSYMLEN (pst) || pst->number_of_dependencies) | |
1038 | { | |
1039 | /* Print the message now, before reading the string table, | |
1040 | to avoid disconcerting pauses. */ | |
1041 | if (info_verbose) | |
1042 | { | |
1043 | printf_filtered ("Reading in symbols for %s...", pst->filename); | |
1044 | fflush (stdout); | |
1045 | } | |
1046 | ||
1047 | hpread_psymtab_to_symtab_1 (pst); | |
1048 | ||
1049 | /* Match with global symbols. This only needs to be done once, | |
1050 | after all of the symtabs and dependencies have been read in. */ | |
1051 | scan_file_globals (pst->objfile); | |
1052 | ||
1053 | /* Finish up the debug error message. */ | |
1054 | if (info_verbose) | |
1055 | printf_filtered ("done.\n"); | |
1056 | } | |
1057 | } | |
1058 | /* Read in a defined section of a specific object file's symbols. | |
1059 | ||
1060 | DESC is the file descriptor for the file, positioned at the | |
1061 | beginning of the symtab | |
1062 | SYM_OFFSET is the offset within the file of | |
1063 | the beginning of the symbols we want to read | |
1064 | SYM_SIZE is the size of the symbol info to read in. | |
1065 | TEXT_OFFSET is the beginning of the text segment we are reading symbols for | |
1066 | TEXT_SIZE is the size of the text segment read in. | |
1067 | SECTION_OFFSETS are the relocation offsets which get added to each symbol. */ | |
1068 | ||
1069 | static struct symtab * | |
1070 | hpread_expand_symtab (objfile, sym_offset, sym_size, text_offset, text_size, | |
1071 | section_offsets, filename) | |
1072 | struct objfile *objfile; | |
1073 | int sym_offset; | |
1074 | int sym_size; | |
1075 | CORE_ADDR text_offset; | |
1076 | int text_size; | |
1077 | struct section_offsets *section_offsets; | |
1078 | char *filename; | |
1079 | { | |
1080 | char *namestring; | |
1081 | union dnttentry *dn_bufp; | |
1082 | unsigned max_symnum; | |
1083 | ||
2848f793 | 1084 | int sym_index = sym_offset / sizeof (struct dntt_type_block); |
98c0e047 JL |
1085 | |
1086 | current_objfile = objfile; | |
1087 | subfile_stack = 0; | |
1088 | ||
1089 | last_source_file = 0; | |
1090 | ||
1091 | dn_bufp = hpread_get_lntt (sym_index, objfile); | |
2848f793 JL |
1092 | if (!((dn_bufp->dblock.kind == (unsigned char) DNTT_TYPE_SRCFILE) || |
1093 | (dn_bufp->dblock.kind == (unsigned char) DNTT_TYPE_MODULE))) | |
98c0e047 JL |
1094 | start_symtab ("globals", NULL, 0); |
1095 | ||
2848f793 | 1096 | max_symnum = sym_size / sizeof (struct dntt_type_block); |
98c0e047 JL |
1097 | |
1098 | /* Read in and process each debug symbol within the specified range. */ | |
1099 | for (symnum = 0; | |
1100 | symnum < max_symnum; | |
1101 | symnum++) | |
1102 | { | |
1103 | QUIT; /* Allow this to be interruptable */ | |
1104 | dn_bufp = hpread_get_lntt (sym_index + symnum, objfile); | |
1105 | ||
1106 | if (dn_bufp->dblock.extension) | |
1107 | continue; | |
1108 | ||
1109 | /* Yow! We call SET_NAMESTRING on things without names! */ | |
1110 | SET_NAMESTRING (dn_bufp, &namestring, objfile); | |
1111 | ||
1112 | hpread_process_one_debug_symbol (dn_bufp, namestring, section_offsets, | |
1113 | objfile, text_offset, text_size, | |
1114 | filename, symnum + sym_index); | |
1115 | } | |
1116 | ||
1117 | current_objfile = NULL; | |
1118 | ||
1119 | return end_symtab (text_offset + text_size, 0, 0, objfile, 0); | |
1120 | } | |
1121 | \f | |
1122 | ||
1123 | /* Convert basic types from HP debug format into GDB internal format. */ | |
1124 | ||
1125 | static int | |
1126 | hpread_type_translate (typep) | |
2848f793 | 1127 | dnttpointer typep; |
98c0e047 JL |
1128 | { |
1129 | if (!typep.dntti.immediate) | |
1130 | abort (); | |
1131 | ||
1132 | switch (typep.dntti.type) | |
1133 | { | |
2848f793 JL |
1134 | case HP_TYPE_BOOLEAN: |
1135 | case HP_TYPE_BOOLEAN_S300_COMPAT: | |
1136 | case HP_TYPE_BOOLEAN_VAX_COMPAT: | |
98c0e047 JL |
1137 | return FT_BOOLEAN; |
1138 | /* Ugh. No way to distinguish between signed and unsigned chars. */ | |
2848f793 JL |
1139 | case HP_TYPE_CHAR: |
1140 | case HP_TYPE_WIDE_CHAR: | |
98c0e047 | 1141 | return FT_CHAR; |
2848f793 | 1142 | case HP_TYPE_INT: |
98c0e047 JL |
1143 | if (typep.dntti.bitlength <= 8) |
1144 | return FT_CHAR; | |
1145 | if (typep.dntti.bitlength <= 16) | |
1146 | return FT_SHORT; | |
1147 | if (typep.dntti.bitlength <= 32) | |
1148 | return FT_INTEGER; | |
1149 | return FT_LONG_LONG; | |
2848f793 | 1150 | case HP_TYPE_LONG: |
98c0e047 | 1151 | return FT_LONG; |
2848f793 | 1152 | case HP_TYPE_UNSIGNED_LONG: |
510ceea9 JL |
1153 | if (typep.dntti.bitlength <= 8) |
1154 | return FT_UNSIGNED_CHAR; | |
1155 | if (typep.dntti.bitlength <= 16) | |
1156 | return FT_UNSIGNED_SHORT; | |
1157 | if (typep.dntti.bitlength <= 32) | |
1158 | return FT_UNSIGNED_LONG; | |
1159 | return FT_UNSIGNED_LONG_LONG; | |
2848f793 | 1160 | case HP_TYPE_UNSIGNED_INT: |
98c0e047 JL |
1161 | if (typep.dntti.bitlength <= 8) |
1162 | return FT_UNSIGNED_CHAR; | |
1163 | if (typep.dntti.bitlength <= 16) | |
1164 | return FT_UNSIGNED_SHORT; | |
1165 | if (typep.dntti.bitlength <= 32) | |
1166 | return FT_UNSIGNED_INTEGER; | |
1167 | return FT_UNSIGNED_LONG_LONG; | |
2848f793 JL |
1168 | case HP_TYPE_REAL: |
1169 | case HP_TYPE_REAL_3000: | |
1170 | case HP_TYPE_DOUBLE: | |
98c0e047 JL |
1171 | if (typep.dntti.bitlength == 64) |
1172 | return FT_DBL_PREC_FLOAT; | |
1173 | if (typep.dntti.bitlength == 128) | |
1174 | return FT_EXT_PREC_FLOAT; | |
1175 | return FT_FLOAT; | |
2848f793 JL |
1176 | case HP_TYPE_COMPLEX: |
1177 | case HP_TYPE_COMPLEXS3000: | |
98c0e047 JL |
1178 | if (typep.dntti.bitlength == 128) |
1179 | return FT_DBL_PREC_COMPLEX; | |
1180 | if (typep.dntti.bitlength == 192) | |
1181 | return FT_EXT_PREC_COMPLEX; | |
1182 | return FT_COMPLEX; | |
2848f793 JL |
1183 | case HP_TYPE_STRING200: |
1184 | case HP_TYPE_LONGSTRING200: | |
1185 | case HP_TYPE_FTN_STRING_SPEC: | |
1186 | case HP_TYPE_MOD_STRING_SPEC: | |
1187 | case HP_TYPE_MOD_STRING_3000: | |
1188 | case HP_TYPE_FTN_STRING_S300_COMPAT: | |
1189 | case HP_TYPE_FTN_STRING_VAX_COMPAT: | |
98c0e047 JL |
1190 | return FT_STRING; |
1191 | default: | |
1192 | abort (); | |
1193 | } | |
1194 | } | |
1195 | ||
1196 | /* Return the type associated with the index found in HP_TYPE. */ | |
1197 | ||
1198 | static struct type ** | |
1199 | hpread_lookup_type (hp_type, objfile) | |
2848f793 | 1200 | dnttpointer hp_type; |
98c0e047 JL |
1201 | struct objfile *objfile; |
1202 | { | |
1203 | unsigned old_len; | |
1204 | int index = hp_type.dnttp.index; | |
1205 | ||
1206 | if (hp_type.dntti.immediate) | |
1207 | return NULL; | |
1208 | ||
1209 | if (index < LNTT_SYMCOUNT (objfile)) | |
1210 | { | |
1211 | if (index >= TYPE_VECTOR_LENGTH (objfile)) | |
1212 | { | |
1213 | old_len = TYPE_VECTOR_LENGTH (objfile); | |
1214 | if (old_len == 0) | |
1215 | { | |
1216 | TYPE_VECTOR_LENGTH (objfile) = 100; | |
1217 | TYPE_VECTOR (objfile) = (struct type **) | |
1218 | malloc (TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *)); | |
1219 | } | |
1220 | while (index >= TYPE_VECTOR_LENGTH (objfile)) | |
1221 | TYPE_VECTOR_LENGTH (objfile) *= 2; | |
1222 | TYPE_VECTOR (objfile) = (struct type **) | |
1223 | xrealloc ((char *) TYPE_VECTOR (objfile), | |
1224 | (TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *))); | |
1225 | memset (&TYPE_VECTOR (objfile)[old_len], 0, | |
1226 | (TYPE_VECTOR_LENGTH (objfile) - old_len) * | |
1227 | sizeof (struct type *)); | |
1228 | } | |
1229 | return &TYPE_VECTOR (objfile)[index]; | |
1230 | } | |
1231 | else | |
1232 | return NULL; | |
1233 | } | |
1234 | ||
1235 | /* Possibly allocate a GDB internal type so we can internalize HP_TYPE. | |
1236 | Note we'll just return the address of a GDB internal type if we already | |
1237 | have it lying around. */ | |
1238 | ||
1239 | static struct type * | |
1240 | hpread_alloc_type (hp_type, objfile) | |
2848f793 | 1241 | dnttpointer hp_type; |
98c0e047 JL |
1242 | struct objfile *objfile; |
1243 | { | |
1244 | struct type **type_addr; | |
1245 | ||
1246 | type_addr = hpread_lookup_type (hp_type, objfile); | |
1247 | if (*type_addr == 0) | |
1248 | *type_addr = alloc_type (objfile); | |
1249 | ||
1250 | TYPE_CPLUS_SPECIFIC (*type_addr) | |
1251 | = (struct cplus_struct_type *) &cplus_struct_default; | |
1252 | return *type_addr; | |
1253 | } | |
1254 | ||
1255 | /* Read a native enumerated type and return it in GDB internal form. */ | |
1256 | ||
1257 | static struct type * | |
1258 | hpread_read_enum_type (hp_type, dn_bufp, objfile) | |
2848f793 | 1259 | dnttpointer hp_type; |
98c0e047 JL |
1260 | union dnttentry *dn_bufp; |
1261 | struct objfile *objfile; | |
1262 | { | |
1263 | struct type *type; | |
1264 | struct pending **symlist, *osyms, *syms; | |
1265 | int o_nsyms, nsyms = 0; | |
2848f793 | 1266 | dnttpointer mem; |
98c0e047 JL |
1267 | union dnttentry *memp; |
1268 | char *name; | |
1269 | long n; | |
1270 | struct symbol *sym; | |
1271 | ||
1272 | type = hpread_alloc_type (hp_type, objfile); | |
1273 | TYPE_LENGTH (type) = 4; | |
1274 | ||
1275 | symlist = &file_symbols; | |
1276 | osyms = *symlist; | |
1277 | o_nsyms = osyms ? osyms->nsyms : 0; | |
1278 | ||
1279 | /* Get a name for each member and add it to our list of members. */ | |
1280 | mem = dn_bufp->denum.firstmem; | |
1281 | while (mem.dnttp.extension && mem.word != DNTTNIL) | |
1282 | { | |
1283 | memp = hpread_get_lntt (mem.dnttp.index, objfile); | |
1284 | ||
1285 | name = VT (objfile) + memp->dmember.name; | |
1286 | sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack, | |
1287 | sizeof (struct symbol)); | |
1288 | memset (sym, 0, sizeof (struct symbol)); | |
1289 | SYMBOL_NAME (sym) = name; | |
1290 | SYMBOL_CLASS (sym) = LOC_CONST; | |
1291 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
1292 | SYMBOL_VALUE (sym) = memp->dmember.value; | |
1293 | add_symbol_to_list (sym, symlist); | |
1294 | nsyms++; | |
1295 | mem = memp->dmember.nextmem; | |
1296 | } | |
1297 | ||
1298 | /* Now that we know more about the enum, fill in more info. */ | |
1299 | TYPE_CODE (type) = TYPE_CODE_ENUM; | |
1300 | TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB; | |
1301 | TYPE_NFIELDS (type) = nsyms; | |
1302 | TYPE_FIELDS (type) = (struct field *) | |
1303 | obstack_alloc (&objfile->type_obstack, sizeof (struct field) * nsyms); | |
1304 | ||
1305 | /* Find the symbols for the members and put them into the type. | |
1306 | The symbols can be found in the symlist that we put them on | |
1307 | to cause them to be defined. osyms contains the old value | |
1308 | of that symlist; everything up to there was defined by us. | |
1309 | ||
1310 | Note that we preserve the order of the enum constants, so | |
1311 | that in something like "enum {FOO, LAST_THING=FOO}" we print | |
1312 | FOO, not LAST_THING. */ | |
1313 | for (syms = *symlist, n = 0; syms; syms = syms->next) | |
1314 | { | |
1315 | int j = 0; | |
1316 | if (syms == osyms) | |
1317 | j = o_nsyms; | |
1318 | for (; j < syms->nsyms; j++, n++) | |
1319 | { | |
1320 | struct symbol *xsym = syms->symbol[j]; | |
1321 | SYMBOL_TYPE (xsym) = type; | |
1322 | TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym); | |
1323 | TYPE_FIELD_VALUE (type, n) = 0; | |
1324 | TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (xsym); | |
1325 | TYPE_FIELD_BITSIZE (type, n) = 0; | |
1326 | } | |
1327 | if (syms == osyms) | |
1328 | break; | |
1329 | } | |
1330 | ||
1331 | return type; | |
1332 | } | |
1333 | ||
1334 | /* Read and internalize a native function debug symbol. */ | |
1335 | ||
1336 | static struct type * | |
1337 | hpread_read_function_type (hp_type, dn_bufp, objfile) | |
2848f793 | 1338 | dnttpointer hp_type; |
98c0e047 JL |
1339 | union dnttentry *dn_bufp; |
1340 | struct objfile *objfile; | |
1341 | { | |
1342 | struct type *type, *type1; | |
1343 | struct pending **symlist, *osyms, *syms; | |
1344 | int o_nsyms, nsyms = 0; | |
2848f793 | 1345 | dnttpointer param; |
98c0e047 JL |
1346 | union dnttentry *paramp; |
1347 | char *name; | |
1348 | long n; | |
1349 | struct symbol *sym; | |
1350 | ||
1351 | param = dn_bufp->dfunc.firstparam; | |
1352 | ||
1353 | /* See if we've already read in this type. */ | |
1354 | type = hpread_alloc_type (hp_type, objfile); | |
1355 | if (TYPE_CODE (type) == TYPE_CODE_FUNC) | |
1356 | return type; | |
1357 | ||
1358 | /* Nope, so read it in and store it away. */ | |
1359 | type1 = lookup_function_type (hpread_type_lookup (dn_bufp->dfunc.retval, | |
1360 | objfile)); | |
1361 | memcpy ((char *) type, (char *) type1, sizeof (struct type)); | |
1362 | ||
1363 | symlist = &local_symbols; | |
1364 | osyms = *symlist; | |
1365 | o_nsyms = osyms ? osyms->nsyms : 0; | |
1366 | ||
1367 | /* Now examine each parameter noting its type, location, and a | |
1368 | wealth of other information. */ | |
1369 | while (param.word && param.word != DNTTNIL) | |
1370 | { | |
1371 | paramp = hpread_get_lntt (param.dnttp.index, objfile); | |
1372 | nsyms++; | |
1373 | param = paramp->dfparam.nextparam; | |
1374 | ||
1375 | /* Get the name. */ | |
1376 | name = VT (objfile) + paramp->dfparam.name; | |
1377 | sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack, | |
1378 | sizeof (struct symbol)); | |
1379 | (void) memset (sym, 0, sizeof (struct symbol)); | |
1380 | SYMBOL_NAME (sym) = name; | |
1381 | ||
1382 | /* Figure out where it lives. */ | |
1383 | if (paramp->dfparam.regparam) | |
1384 | SYMBOL_CLASS (sym) = LOC_REGPARM; | |
1385 | else if (paramp->dfparam.indirect) | |
1386 | SYMBOL_CLASS (sym) = LOC_REF_ARG; | |
1387 | else | |
1388 | SYMBOL_CLASS (sym) = LOC_ARG; | |
1389 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
1390 | if (paramp->dfparam.copyparam) | |
1391 | { | |
1392 | SYMBOL_VALUE (sym) = paramp->dfparam.location ; | |
1393 | #ifdef HPREAD_ADJUST_STACK_ADDRESS | |
1394 | SYMBOL_VALUE (sym) | |
1395 | += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile)); | |
1396 | #endif | |
1397 | /* This is likely a pass-by-invisible reference parameter, | |
1398 | Hack on the symbol class to make GDB happy. */ | |
1399 | SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR; | |
1400 | } | |
1401 | else | |
1402 | SYMBOL_VALUE (sym) = paramp->dfparam.location; | |
1403 | ||
1404 | /* Get its type. */ | |
1405 | SYMBOL_TYPE (sym) = hpread_type_lookup (paramp->dfparam.type, objfile); | |
1406 | ||
1407 | /* Add it to the list. */ | |
1408 | add_symbol_to_list (sym, symlist); | |
1409 | } | |
1410 | ||
1411 | /* Note how many parameters we found. */ | |
1412 | TYPE_NFIELDS (type) = nsyms; | |
1413 | TYPE_FIELDS (type) = (struct field *) | |
1414 | obstack_alloc (&objfile->type_obstack, | |
1415 | sizeof (struct field) * nsyms); | |
1416 | ||
1417 | /* Find the symbols for the values and put them into the type. | |
1418 | The symbols can be found in the symlist that we put them on | |
1419 | to cause them to be defined. osyms contains the old value | |
1420 | of that symlist; everything up to there was defined by us. */ | |
1421 | /* Note that we preserve the order of the parameters, so | |
1422 | that in something like "enum {FOO, LAST_THING=FOO}" we print | |
1423 | FOO, not LAST_THING. */ | |
1424 | for (syms = *symlist, n = 0; syms; syms = syms->next) | |
1425 | { | |
1426 | int j = 0; | |
1427 | if (syms == osyms) | |
1428 | j = o_nsyms; | |
1429 | for (; j < syms->nsyms; j++, n++) | |
1430 | { | |
1431 | struct symbol *xsym = syms->symbol[j]; | |
1432 | TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym); | |
1433 | TYPE_FIELD_TYPE (type, n) = SYMBOL_TYPE (xsym); | |
1434 | TYPE_FIELD_BITPOS (type, n) = n; | |
1435 | TYPE_FIELD_BITSIZE (type, n) = 0; | |
1436 | } | |
1437 | if (syms == osyms) | |
1438 | break; | |
1439 | } | |
1440 | return type; | |
1441 | } | |
1442 | ||
1443 | /* Read in and internalize a structure definition. */ | |
1444 | ||
1445 | static struct type * | |
1446 | hpread_read_struct_type (hp_type, dn_bufp, objfile) | |
2848f793 | 1447 | dnttpointer hp_type; |
98c0e047 JL |
1448 | union dnttentry *dn_bufp; |
1449 | struct objfile *objfile; | |
1450 | { | |
1451 | struct nextfield | |
1452 | { | |
1453 | struct nextfield *next; | |
1454 | struct field field; | |
1455 | }; | |
1456 | ||
1457 | struct type *type; | |
1458 | struct nextfield *list = 0; | |
1459 | struct nextfield *new; | |
1460 | int n, nfields = 0; | |
2848f793 | 1461 | dnttpointer field; |
98c0e047 JL |
1462 | union dnttentry *fieldp; |
1463 | ||
1464 | /* Is it something we've already dealt with? */ | |
1465 | type = hpread_alloc_type (hp_type, objfile); | |
1466 | if ((TYPE_CODE (type) == TYPE_CODE_STRUCT) || | |
1467 | (TYPE_CODE (type) == TYPE_CODE_UNION)) | |
1468 | return type; | |
1469 | ||
1470 | /* Get the basic type correct. */ | |
2848f793 | 1471 | if (dn_bufp->dblock.kind == DNTT_TYPE_STRUCT) |
98c0e047 JL |
1472 | { |
1473 | TYPE_CODE (type) = TYPE_CODE_STRUCT; | |
1474 | TYPE_LENGTH (type) = dn_bufp->dstruct.bitlength / 8; | |
1475 | } | |
2848f793 | 1476 | else if (dn_bufp->dblock.kind == DNTT_TYPE_UNION) |
98c0e047 JL |
1477 | { |
1478 | TYPE_CODE (type) = TYPE_CODE_UNION; | |
1479 | TYPE_LENGTH (type) = dn_bufp->dunion.bitlength / 8; | |
1480 | } | |
1481 | else | |
1482 | return type; | |
1483 | ||
1484 | ||
1485 | TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB; | |
1486 | ||
1487 | /* Read in and internalize all the fields. */ | |
1488 | field = dn_bufp->dstruct.firstfield; | |
1489 | while (field.word != DNTTNIL && field.dnttp.extension) | |
1490 | { | |
1491 | fieldp = hpread_get_lntt (field.dnttp.index, objfile); | |
1492 | ||
1493 | /* Get space to record the next field's data. */ | |
1494 | new = (struct nextfield *) alloca (sizeof (struct nextfield)); | |
1495 | new->next = list; | |
1496 | list = new; | |
1497 | ||
1498 | list->field.name = VT (objfile) + fieldp->dfield.name; | |
1499 | list->field.bitpos = fieldp->dfield.bitoffset; | |
1500 | if (fieldp->dfield.bitlength % 8) | |
1501 | list->field.bitsize = fieldp->dfield.bitlength; | |
1502 | else | |
1503 | list->field.bitsize = 0; | |
1504 | nfields++; | |
1505 | field = fieldp->dfield.nextfield; | |
1506 | list->field.type = hpread_type_lookup (fieldp->dfield.type, objfile); | |
1507 | } | |
1508 | ||
1509 | TYPE_NFIELDS (type) = nfields; | |
1510 | TYPE_FIELDS (type) = (struct field *) | |
1511 | obstack_alloc (&objfile->type_obstack, sizeof (struct field) * nfields); | |
1512 | ||
1513 | /* Copy the saved-up fields into the field vector. */ | |
1514 | for (n = nfields; list; list = list->next) | |
1515 | { | |
1516 | n -= 1; | |
1517 | TYPE_FIELD (type, n) = list->field; | |
1518 | } | |
1519 | return type; | |
1520 | } | |
1521 | ||
1522 | /* Read in and internalize a set debug symbol. */ | |
1523 | ||
1524 | static struct type * | |
1525 | hpread_read_set_type (hp_type, dn_bufp, objfile) | |
2848f793 | 1526 | dnttpointer hp_type; |
98c0e047 JL |
1527 | union dnttentry *dn_bufp; |
1528 | struct objfile *objfile; | |
1529 | { | |
1530 | struct type *type; | |
1531 | ||
1532 | /* See if it's something we've already deal with. */ | |
1533 | type = hpread_alloc_type (hp_type, objfile); | |
1534 | if (TYPE_CODE (type) == TYPE_CODE_SET) | |
1535 | return type; | |
1536 | ||
1537 | /* Nope. Fill in the appropriate fields. */ | |
1538 | TYPE_CODE (type) = TYPE_CODE_SET; | |
1539 | TYPE_LENGTH (type) = dn_bufp->dset.bitlength / 8; | |
1540 | TYPE_NFIELDS (type) = 0; | |
1541 | TYPE_TARGET_TYPE (type) = hpread_type_lookup (dn_bufp->dset.subtype, | |
1542 | objfile); | |
1543 | return type; | |
1544 | } | |
1545 | ||
1546 | /* Read in and internalize an array debug symbol. */ | |
1547 | ||
1548 | static struct type * | |
1549 | hpread_read_array_type (hp_type, dn_bufp, objfile) | |
2848f793 | 1550 | dnttpointer hp_type; |
98c0e047 JL |
1551 | union dnttentry *dn_bufp; |
1552 | struct objfile *objfile; | |
1553 | { | |
1554 | struct type *type; | |
1555 | union dnttentry save; | |
1556 | save = *dn_bufp; | |
1557 | ||
1558 | /* Why no check here? Because it kept us from properly determining | |
1559 | the size of the array! */ | |
1560 | type = hpread_alloc_type (hp_type, objfile); | |
1561 | ||
1562 | TYPE_CODE (type) = TYPE_CODE_ARRAY; | |
1563 | ||
1564 | /* values are not normalized. */ | |
1565 | if (!((dn_bufp->darray.arrayisbytes && dn_bufp->darray.elemisbytes) | |
1566 | || (!dn_bufp->darray.arrayisbytes && !dn_bufp->darray.elemisbytes))) | |
1567 | abort (); | |
1568 | else if (dn_bufp->darray.arraylength == 0x7fffffff) | |
1569 | { | |
1570 | /* The HP debug format represents char foo[]; as an array with | |
1571 | length 0x7fffffff. Internally GDB wants to represent this | |
e042d326 JL |
1572 | as an array of length zero. */ |
1573 | TYPE_LENGTH (type) = 0; | |
98c0e047 JL |
1574 | } |
1575 | else | |
1576 | TYPE_LENGTH (type) = dn_bufp->darray.arraylength / 8; | |
1577 | ||
1578 | TYPE_NFIELDS (type) = 1; | |
1579 | TYPE_TARGET_TYPE (type) = hpread_type_lookup (dn_bufp->darray.elemtype, | |
1580 | objfile); | |
1581 | dn_bufp = &save; | |
1582 | TYPE_FIELDS (type) = (struct field *) | |
1583 | obstack_alloc (&objfile->type_obstack, sizeof (struct field)); | |
1584 | TYPE_FIELD_TYPE (type, 0) = hpread_type_lookup (dn_bufp->darray.indextype, | |
1585 | objfile); | |
1586 | return type; | |
1587 | } | |
1588 | ||
1589 | /* Read in and internalize a subrange debug symbol. */ | |
1590 | static struct type * | |
1591 | hpread_read_subrange_type (hp_type, dn_bufp, objfile) | |
2848f793 | 1592 | dnttpointer hp_type; |
98c0e047 JL |
1593 | union dnttentry *dn_bufp; |
1594 | struct objfile *objfile; | |
1595 | { | |
1596 | struct type *type; | |
1597 | ||
1598 | /* Is it something we've already dealt with. */ | |
1599 | type = hpread_alloc_type (hp_type, objfile); | |
1600 | if (TYPE_CODE (type) == TYPE_CODE_RANGE) | |
1601 | return type; | |
1602 | ||
1603 | /* Nope, internalize it. */ | |
1604 | TYPE_CODE (type) = TYPE_CODE_RANGE; | |
1605 | TYPE_LENGTH (type) = dn_bufp->dsubr.bitlength / 8; | |
1606 | TYPE_NFIELDS (type) = 2; | |
3a0fbb3b JL |
1607 | TYPE_FIELDS (type) |
1608 | = (struct field *) obstack_alloc (&objfile->type_obstack, | |
1609 | 2 * sizeof (struct field)); | |
98c0e047 JL |
1610 | |
1611 | if (dn_bufp->dsubr.dyn_low) | |
1612 | TYPE_FIELD_BITPOS (type, 0) = 0; | |
1613 | else | |
1614 | TYPE_FIELD_BITPOS (type, 0) = dn_bufp->dsubr.lowbound; | |
1615 | ||
1616 | if (dn_bufp->dsubr.dyn_high) | |
1617 | TYPE_FIELD_BITPOS (type, 1) = -1; | |
1618 | else | |
1619 | TYPE_FIELD_BITPOS (type, 1) = dn_bufp->dsubr.highbound; | |
1620 | TYPE_TARGET_TYPE (type) = hpread_type_lookup (dn_bufp->dsubr.subtype, | |
1621 | objfile); | |
1622 | return type; | |
1623 | } | |
1624 | ||
1625 | static struct type * | |
1626 | hpread_type_lookup (hp_type, objfile) | |
2848f793 | 1627 | dnttpointer hp_type; |
98c0e047 JL |
1628 | struct objfile *objfile; |
1629 | { | |
1630 | union dnttentry *dn_bufp; | |
1631 | ||
1632 | /* First see if it's a simple builtin type. */ | |
1633 | if (hp_type.dntti.immediate) | |
1634 | return lookup_fundamental_type (objfile, hpread_type_translate (hp_type)); | |
1635 | ||
1636 | /* Not a builtin type. We'll have to read it in. */ | |
1637 | if (hp_type.dnttp.index < LNTT_SYMCOUNT (objfile)) | |
1638 | dn_bufp = hpread_get_lntt (hp_type.dnttp.index, objfile); | |
1639 | else | |
1640 | return lookup_fundamental_type (objfile, FT_VOID); | |
1641 | ||
1642 | switch (dn_bufp->dblock.kind) | |
1643 | { | |
2848f793 JL |
1644 | case DNTT_TYPE_SRCFILE: |
1645 | case DNTT_TYPE_MODULE: | |
1646 | case DNTT_TYPE_FUNCTION: | |
1647 | case DNTT_TYPE_ENTRY: | |
1648 | case DNTT_TYPE_BEGIN: | |
1649 | case DNTT_TYPE_END: | |
1650 | case DNTT_TYPE_IMPORT: | |
1651 | case DNTT_TYPE_LABEL: | |
1652 | case DNTT_TYPE_WITH: | |
1653 | case DNTT_TYPE_COMMON: | |
1654 | case DNTT_TYPE_FPARAM: | |
1655 | case DNTT_TYPE_SVAR: | |
1656 | case DNTT_TYPE_DVAR: | |
1657 | case DNTT_TYPE_CONST: | |
98c0e047 JL |
1658 | /* Opps. Something went very wrong. */ |
1659 | return lookup_fundamental_type (objfile, FT_VOID); | |
1660 | ||
2848f793 | 1661 | case DNTT_TYPE_TYPEDEF: |
98c0e047 JL |
1662 | { |
1663 | struct type *structtype = hpread_type_lookup (dn_bufp->dtype.type, | |
1664 | objfile); | |
1665 | char *suffix; | |
1666 | suffix = VT (objfile) + dn_bufp->dtype.name; | |
1667 | ||
1668 | TYPE_CPLUS_SPECIFIC (structtype) | |
1669 | = (struct cplus_struct_type *) &cplus_struct_default; | |
1670 | TYPE_NAME (structtype) = suffix; | |
1671 | return structtype; | |
1672 | } | |
1673 | ||
2848f793 | 1674 | case DNTT_TYPE_TAGDEF: |
98c0e047 JL |
1675 | { |
1676 | /* Just a little different from above. We have to tack on | |
1677 | an identifier of some kind (struct, union, enum, etc). */ | |
1678 | struct type *structtype = hpread_type_lookup (dn_bufp->dtype.type, | |
1679 | objfile); | |
1680 | char *prefix, *suffix; | |
1681 | suffix = VT (objfile) + dn_bufp->dtype.name; | |
1682 | ||
1683 | /* Lookup the next type in the list. It should be a structure, | |
1684 | union, or enum type. We will need to attach that to our name. */ | |
1685 | if (dn_bufp->dtype.type.dnttp.index < LNTT_SYMCOUNT (objfile)) | |
1686 | dn_bufp = hpread_get_lntt (dn_bufp->dtype.type.dnttp.index, objfile); | |
1687 | else | |
1688 | abort (); | |
1689 | ||
2848f793 | 1690 | if (dn_bufp->dblock.kind == DNTT_TYPE_STRUCT) |
98c0e047 | 1691 | prefix = "struct "; |
2848f793 | 1692 | else if (dn_bufp->dblock.kind == DNTT_TYPE_UNION) |
98c0e047 JL |
1693 | prefix = "union "; |
1694 | else | |
1695 | prefix = "enum "; | |
1696 | ||
1697 | /* Build the correct name. */ | |
1698 | structtype->name | |
1699 | = (char *) obstack_alloc (&objfile->type_obstack, | |
1700 | strlen (prefix) + strlen (suffix) + 1); | |
1701 | TYPE_NAME (structtype) = strcpy (TYPE_NAME (structtype), prefix); | |
1702 | TYPE_NAME (structtype) = strcat (TYPE_NAME (structtype), suffix); | |
1703 | TYPE_TAG_NAME (structtype) = suffix; | |
1704 | ||
1705 | TYPE_CPLUS_SPECIFIC (structtype) | |
1706 | = (struct cplus_struct_type *) &cplus_struct_default; | |
1707 | ||
1708 | return structtype; | |
1709 | } | |
2848f793 | 1710 | case DNTT_TYPE_POINTER: |
98c0e047 JL |
1711 | return lookup_pointer_type (hpread_type_lookup (dn_bufp->dptr.pointsto, |
1712 | objfile)); | |
2848f793 | 1713 | case DNTT_TYPE_ENUM: |
98c0e047 | 1714 | return hpread_read_enum_type (hp_type, dn_bufp, objfile); |
2848f793 | 1715 | case DNTT_TYPE_MEMENUM: |
98c0e047 | 1716 | return lookup_fundamental_type (objfile, FT_VOID); |
2848f793 | 1717 | case DNTT_TYPE_SET: |
98c0e047 | 1718 | return hpread_read_set_type (hp_type, dn_bufp, objfile); |
2848f793 | 1719 | case DNTT_TYPE_SUBRANGE: |
98c0e047 | 1720 | return hpread_read_subrange_type (hp_type, dn_bufp, objfile); |
2848f793 | 1721 | case DNTT_TYPE_ARRAY: |
98c0e047 | 1722 | return hpread_read_array_type (hp_type, dn_bufp, objfile); |
2848f793 JL |
1723 | case DNTT_TYPE_STRUCT: |
1724 | case DNTT_TYPE_UNION: | |
98c0e047 | 1725 | return hpread_read_struct_type (hp_type, dn_bufp, objfile); |
2848f793 | 1726 | case DNTT_TYPE_FIELD: |
98c0e047 | 1727 | return hpread_type_lookup (dn_bufp->dfield.type, objfile); |
2848f793 JL |
1728 | case DNTT_TYPE_VARIANT: |
1729 | case DNTT_TYPE_FILE: | |
98c0e047 | 1730 | return lookup_fundamental_type (objfile, FT_VOID); |
2848f793 | 1731 | case DNTT_TYPE_FUNCTYPE: |
98c0e047 JL |
1732 | return lookup_function_type (hpread_type_lookup (dn_bufp->dfunctype.retval, |
1733 | objfile)); | |
2848f793 JL |
1734 | case DNTT_TYPE_COBSTRUCT: |
1735 | case DNTT_TYPE_XREF: | |
1736 | case DNTT_TYPE_SA: | |
1737 | case DNTT_TYPE_MACRO: | |
98c0e047 JL |
1738 | default: |
1739 | return lookup_fundamental_type (objfile, FT_VOID); | |
1740 | } | |
1741 | } | |
1742 | ||
2848f793 | 1743 | static sltpointer |
3a0fbb3b | 1744 | hpread_record_lines (subfile, s_idx, e_idx, objfile, offset) |
98c0e047 | 1745 | struct subfile *subfile; |
2848f793 | 1746 | sltpointer s_idx, e_idx; |
98c0e047 | 1747 | struct objfile *objfile; |
3a0fbb3b | 1748 | CORE_ADDR offset; |
98c0e047 JL |
1749 | { |
1750 | union sltentry *sl_bufp; | |
1751 | ||
1752 | while (s_idx <= e_idx) | |
1753 | { | |
1754 | sl_bufp = hpread_get_slt (s_idx, objfile); | |
1755 | /* Only record "normal" entries in the SLT. */ | |
1756 | if (sl_bufp->snorm.sltdesc == SLT_NORMAL | |
1757 | || sl_bufp->snorm.sltdesc == SLT_EXIT) | |
3a0fbb3b JL |
1758 | record_line (subfile, sl_bufp->snorm.line, |
1759 | sl_bufp->snorm.address + offset); | |
98c0e047 JL |
1760 | s_idx++; |
1761 | } | |
1762 | return e_idx; | |
1763 | } | |
1764 | ||
1765 | /* Internalize one native debug symbol. */ | |
1766 | ||
1767 | static void | |
1768 | hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, | |
1769 | text_offset, text_size, filename, index) | |
1770 | union dnttentry *dn_bufp; | |
1771 | char *name; | |
1772 | struct section_offsets *section_offsets; | |
1773 | struct objfile *objfile; | |
1774 | CORE_ADDR text_offset; | |
1775 | int text_size; | |
1776 | char *filename; | |
1777 | int index; | |
1778 | { | |
1779 | unsigned long desc; | |
1780 | int type; | |
1781 | CORE_ADDR valu; | |
1782 | int offset = ANOFFSET (section_offsets, SECT_OFF_TEXT); | |
1783 | union dnttentry *dn_temp; | |
2848f793 | 1784 | dnttpointer hp_type; |
98c0e047 JL |
1785 | struct symbol *sym; |
1786 | struct context_stack *new; | |
98c0e047 JL |
1787 | |
1788 | /* Allocate one GDB debug symbol and fill in some default values. */ | |
1789 | sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack, | |
1790 | sizeof (struct symbol)); | |
1791 | memset (sym, 0, sizeof (struct symbol)); | |
1792 | SYMBOL_NAME (sym) = name; | |
1793 | SYMBOL_LANGUAGE (sym) = language_auto; | |
1794 | SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack); | |
1795 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
1796 | SYMBOL_LINE (sym) = 0; | |
1797 | SYMBOL_VALUE (sym) = 0; | |
1798 | SYMBOL_CLASS (sym) = LOC_TYPEDEF; | |
1799 | ||
1800 | hp_type.dnttp.extension = 1; | |
1801 | hp_type.dnttp.immediate = 0; | |
1802 | hp_type.dnttp.global = 0; | |
1803 | hp_type.dnttp.index = index; | |
1804 | ||
1805 | type = dn_bufp->dblock.kind; | |
1806 | ||
1807 | switch (type) | |
1808 | { | |
2848f793 | 1809 | case DNTT_TYPE_SRCFILE: |
98c0e047 JL |
1810 | /* This type of symbol indicates from which source file or include file |
1811 | the following data comes. If there are no modules it also may | |
1812 | indicate the start of a new source file, in which case we must | |
1813 | finish the symbol table of the previous source file | |
1814 | (if any) and start accumulating a new symbol table. */ | |
1815 | ||
3a0fbb3b | 1816 | valu = text_offset; |
38ab0632 | 1817 | if (!last_source_file) |
3a0fbb3b JL |
1818 | { |
1819 | start_symtab (name, NULL, valu); | |
1820 | SL_INDEX (objfile) = dn_bufp->dsfile.address; | |
1821 | } | |
1822 | else | |
1823 | { | |
1824 | SL_INDEX (objfile) = hpread_record_lines (current_subfile, | |
1825 | SL_INDEX (objfile), | |
1826 | dn_bufp->dsfile.address, | |
1827 | objfile, offset); | |
1828 | } | |
38ab0632 | 1829 | start_subfile (name, NULL); |
98c0e047 | 1830 | break; |
38ab0632 | 1831 | |
2848f793 JL |
1832 | case DNTT_TYPE_MODULE: |
1833 | /* No need to do anything with these DNTT_TYPE_MODULE symbols anymore. */ | |
98c0e047 JL |
1834 | break; |
1835 | ||
2848f793 JL |
1836 | case DNTT_TYPE_FUNCTION: |
1837 | case DNTT_TYPE_ENTRY: | |
98c0e047 JL |
1838 | /* A function or secondary entry point. */ |
1839 | valu = dn_bufp->dfunc.lowaddr + offset; | |
1840 | SL_INDEX (objfile) = hpread_record_lines (current_subfile, | |
1841 | SL_INDEX (objfile), | |
1842 | dn_bufp->dfunc.address, | |
3a0fbb3b | 1843 | objfile, offset); |
98c0e047 JL |
1844 | |
1845 | WITHIN_FUNCTION (objfile) = 1; | |
1846 | CURRENT_FUNCTION_VALUE (objfile) = valu; | |
1847 | ||
1848 | /* Stack must be empty now. */ | |
1849 | if (context_stack_depth != 0) | |
1850 | complain (&lbrac_unmatched_complaint, (char *) symnum); | |
1851 | new = push_context (0, valu); | |
1852 | ||
1853 | SYMBOL_CLASS (sym) = LOC_BLOCK; | |
1854 | SYMBOL_TYPE (sym) = hpread_read_function_type (hp_type, dn_bufp, objfile); | |
2848f793 | 1855 | if (dn_bufp->dfunc.global) |
98c0e047 JL |
1856 | add_symbol_to_list (sym, &global_symbols); |
1857 | else | |
1858 | add_symbol_to_list (sym, &file_symbols); | |
1859 | new->name = sym; | |
1860 | ||
1861 | /* Search forward to the next scope beginning. */ | |
2848f793 | 1862 | while (dn_bufp->dblock.kind != DNTT_TYPE_BEGIN) |
98c0e047 JL |
1863 | { |
1864 | dn_bufp = hpread_get_lntt (++index, objfile); | |
1865 | if (dn_bufp->dblock.extension) | |
1866 | continue; | |
1867 | } | |
1868 | SL_INDEX (objfile) = hpread_record_lines (current_subfile, | |
1869 | SL_INDEX (objfile), | |
1870 | dn_bufp->dbegin.address, | |
3a0fbb3b | 1871 | objfile, offset); |
98c0e047 JL |
1872 | SYMBOL_LINE (sym) = hpread_get_line (dn_bufp->dbegin.address, objfile); |
1873 | record_line (current_subfile, SYMBOL_LINE (sym), valu); | |
1874 | break; | |
1875 | ||
2848f793 | 1876 | case DNTT_TYPE_BEGIN: |
98c0e047 JL |
1877 | /* Begin a new scope. */ |
1878 | SL_INDEX (objfile) = hpread_record_lines (current_subfile, | |
1879 | SL_INDEX (objfile), | |
1880 | dn_bufp->dbegin.address, | |
3a0fbb3b | 1881 | objfile, offset); |
98c0e047 JL |
1882 | valu = hpread_get_location (dn_bufp->dbegin.address, objfile); |
1883 | valu += offset; /* Relocate for dynamic loading */ | |
1884 | desc = hpread_get_depth (dn_bufp->dbegin.address, objfile); | |
1885 | new = push_context (desc, valu); | |
1886 | break; | |
1887 | ||
2848f793 | 1888 | case DNTT_TYPE_END: |
98c0e047 JL |
1889 | /* End a scope. */ |
1890 | SL_INDEX (objfile) = hpread_record_lines (current_subfile, | |
1891 | SL_INDEX (objfile), | |
1892 | dn_bufp->dend.address + 1, | |
3a0fbb3b | 1893 | objfile, offset); |
98c0e047 JL |
1894 | switch (dn_bufp->dend.endkind) |
1895 | { | |
2848f793 | 1896 | case DNTT_TYPE_MODULE: |
98c0e047 JL |
1897 | /* Ending a module ends the symbol table for that module. */ |
1898 | valu = text_offset + text_size + offset; | |
1899 | (void) end_symtab (valu, 0, 0, objfile, 0); | |
1900 | break; | |
1901 | ||
2848f793 | 1902 | case DNTT_TYPE_FUNCTION: |
98c0e047 JL |
1903 | /* Ending a function, well, ends the function's scope. */ |
1904 | dn_temp = hpread_get_lntt (dn_bufp->dend.beginscope.dnttp.index, | |
1905 | objfile); | |
1906 | valu = dn_temp->dfunc.hiaddr + offset; | |
1907 | new = pop_context (); | |
1908 | /* Make a block for the local symbols within. */ | |
1909 | finish_block (new->name, &local_symbols, new->old_blocks, | |
1910 | new->start_addr, valu, objfile); | |
1911 | WITHIN_FUNCTION (objfile) = 0; | |
1912 | break; | |
2848f793 | 1913 | case DNTT_TYPE_BEGIN: |
98c0e047 JL |
1914 | /* Just ending a local scope. */ |
1915 | valu = hpread_get_location (dn_bufp->dend.address, objfile); | |
1916 | /* Why in the hell is this needed? */ | |
1917 | valu += offset + 9; /* Relocate for dynamic loading */ | |
1918 | new = pop_context (); | |
1919 | desc = dn_bufp->dend.beginscope.dnttp.index; | |
1920 | if (desc != new->depth) | |
1921 | complain (&lbrac_mismatch_complaint, (char *) symnum); | |
1922 | /* Make a block for the local symbols within. */ | |
1923 | finish_block (new->name, &local_symbols, new->old_blocks, | |
1924 | new->start_addr, valu, objfile); | |
1925 | local_symbols = new->locals; | |
1926 | break; | |
1927 | } | |
1928 | break; | |
2848f793 | 1929 | case DNTT_TYPE_LABEL: |
98c0e047 JL |
1930 | SYMBOL_NAMESPACE (sym) = LABEL_NAMESPACE; |
1931 | break; | |
2848f793 | 1932 | case DNTT_TYPE_FPARAM: |
98c0e047 JL |
1933 | /* Function parameters. */ |
1934 | if (dn_bufp->dfparam.regparam) | |
1935 | SYMBOL_CLASS (sym) = LOC_REGISTER; | |
1936 | else | |
1937 | SYMBOL_CLASS (sym) = LOC_LOCAL; | |
1938 | if (dn_bufp->dfparam.copyparam) | |
1939 | { | |
1940 | SYMBOL_VALUE (sym) = dn_bufp->dfparam.location; | |
1941 | #ifdef HPREAD_ADJUST_STACK_ADDRESS | |
1942 | SYMBOL_VALUE (sym) | |
1943 | += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile)); | |
1944 | #endif | |
1945 | } | |
1946 | else | |
1947 | SYMBOL_VALUE (sym) = dn_bufp->dfparam.location; | |
1948 | SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dfparam.type, objfile); | |
1949 | add_symbol_to_list (sym, &local_symbols); | |
1950 | break; | |
2848f793 | 1951 | case DNTT_TYPE_SVAR: |
98c0e047 JL |
1952 | /* Static variables. */ |
1953 | SYMBOL_CLASS (sym) = LOC_STATIC; | |
1954 | SYMBOL_VALUE_ADDRESS (sym) = dn_bufp->dsvar.location; | |
1955 | SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dsvar.type, objfile); | |
2848f793 | 1956 | if (dn_bufp->dsvar.global) |
98c0e047 JL |
1957 | add_symbol_to_list (sym, &global_symbols); |
1958 | else if (WITHIN_FUNCTION (objfile)) | |
1959 | add_symbol_to_list (sym, &local_symbols); | |
1960 | else | |
1961 | add_symbol_to_list (sym, &file_symbols); | |
1962 | break; | |
2848f793 | 1963 | case DNTT_TYPE_DVAR: |
98c0e047 JL |
1964 | /* Dynamic variables. */ |
1965 | if (dn_bufp->ddvar.regvar) | |
1966 | SYMBOL_CLASS (sym) = LOC_REGISTER; | |
1967 | else | |
1968 | SYMBOL_CLASS (sym) = LOC_LOCAL; | |
1969 | SYMBOL_VALUE (sym) = dn_bufp->ddvar.location; | |
dc192b86 | 1970 | #ifdef HPREAD_ADJUST_STACK_ADDRESS |
98c0e047 | 1971 | SYMBOL_VALUE (sym) |
dc192b86 | 1972 | += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile)); |
98c0e047 JL |
1973 | #endif |
1974 | SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->ddvar.type, objfile); | |
2848f793 | 1975 | if (dn_bufp->ddvar.global) |
98c0e047 JL |
1976 | add_symbol_to_list (sym, &global_symbols); |
1977 | else if (WITHIN_FUNCTION (objfile)) | |
1978 | add_symbol_to_list (sym, &local_symbols); | |
1979 | else | |
1980 | add_symbol_to_list (sym, &file_symbols); | |
1981 | break; | |
2848f793 | 1982 | case DNTT_TYPE_CONST: |
98c0e047 JL |
1983 | /* A constant (pascal?). */ |
1984 | SYMBOL_CLASS (sym) = LOC_CONST; | |
1985 | SYMBOL_VALUE (sym) = dn_bufp->dconst.location; | |
1986 | SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dconst.type, objfile); | |
2848f793 | 1987 | if (dn_bufp->dconst.global) |
98c0e047 JL |
1988 | add_symbol_to_list (sym, &global_symbols); |
1989 | else if (WITHIN_FUNCTION (objfile)) | |
1990 | add_symbol_to_list (sym, &local_symbols); | |
1991 | else | |
1992 | add_symbol_to_list (sym, &file_symbols); | |
1993 | break; | |
2848f793 | 1994 | case DNTT_TYPE_TYPEDEF: |
98c0e047 JL |
1995 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; |
1996 | SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dtype.type, objfile); | |
2848f793 | 1997 | if (dn_bufp->dtype.global) |
98c0e047 JL |
1998 | add_symbol_to_list (sym, &global_symbols); |
1999 | else if (WITHIN_FUNCTION (objfile)) | |
2000 | add_symbol_to_list (sym, &local_symbols); | |
2001 | else | |
2002 | add_symbol_to_list (sym, &file_symbols); | |
2003 | break; | |
2848f793 | 2004 | case DNTT_TYPE_TAGDEF: |
98c0e047 JL |
2005 | SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE; |
2006 | SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dtype.type, objfile); | |
2007 | TYPE_NAME (sym->type) = SYMBOL_NAME (sym); | |
2008 | TYPE_TAG_NAME (sym->type) = SYMBOL_NAME (sym); | |
2848f793 | 2009 | if (dn_bufp->dtype.global) |
98c0e047 JL |
2010 | add_symbol_to_list (sym, &global_symbols); |
2011 | else if (WITHIN_FUNCTION (objfile)) | |
2012 | add_symbol_to_list (sym, &local_symbols); | |
2013 | else | |
2014 | add_symbol_to_list (sym, &file_symbols); | |
2015 | break; | |
2848f793 | 2016 | case DNTT_TYPE_POINTER: |
98c0e047 JL |
2017 | SYMBOL_TYPE (sym) = lookup_pointer_type (hpread_type_lookup |
2018 | (dn_bufp->dptr.pointsto, | |
2019 | objfile)); | |
2020 | add_symbol_to_list (sym, &file_symbols); | |
2021 | break; | |
2848f793 | 2022 | case DNTT_TYPE_ENUM: |
98c0e047 JL |
2023 | SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE; |
2024 | SYMBOL_TYPE (sym) = hpread_read_enum_type (hp_type, dn_bufp, objfile); | |
2025 | add_symbol_to_list (sym, &file_symbols); | |
2026 | break; | |
2848f793 | 2027 | case DNTT_TYPE_MEMENUM: |
98c0e047 | 2028 | break; |
2848f793 | 2029 | case DNTT_TYPE_SET: |
98c0e047 JL |
2030 | SYMBOL_TYPE (sym) = hpread_read_set_type (hp_type, dn_bufp, objfile); |
2031 | add_symbol_to_list (sym, &file_symbols); | |
2032 | break; | |
2848f793 | 2033 | case DNTT_TYPE_SUBRANGE: |
98c0e047 JL |
2034 | SYMBOL_TYPE (sym) = hpread_read_subrange_type (hp_type, dn_bufp, |
2035 | objfile); | |
2036 | add_symbol_to_list (sym, &file_symbols); | |
2037 | break; | |
2848f793 | 2038 | case DNTT_TYPE_ARRAY: |
98c0e047 JL |
2039 | SYMBOL_TYPE (sym) = hpread_read_array_type (hp_type, dn_bufp, objfile); |
2040 | add_symbol_to_list (sym, &file_symbols); | |
2041 | break; | |
2848f793 JL |
2042 | case DNTT_TYPE_STRUCT: |
2043 | case DNTT_TYPE_UNION: | |
98c0e047 JL |
2044 | SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE; |
2045 | SYMBOL_TYPE (sym) = hpread_read_struct_type (hp_type, dn_bufp, objfile); | |
2046 | add_symbol_to_list (sym, &file_symbols); | |
2047 | break; | |
2048 | default: | |
2049 | break; | |
2050 | } | |
2051 | } |