1 /* Read hp debug symbols and convert to internal format, for GDB.
2 Copyright 1993, 1996, 1998, 1999 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
21 Written by the Center for Software Science at the University of Utah
22 and by Cygnus Support. */
24 /* Common include file for hp_symtab_read.c and hp_psymtab_read.c.
25 This has nested includes of a bunch of stuff. */
29 /* To generate dumping code, uncomment this define. The dumping
30 itself is controlled by routine-local statics called "dumping". */
31 /* #define DUMPING 1 */
33 /* To use the quick look-up tables, uncomment this define. */
34 #define QUICK_LOOK_UP 1
36 /* To call PXDB to process un-processed files, uncomment this define. */
39 /* Forward procedure declarations */
41 void hpread_symfile_init (struct objfile
*);
45 void hpread_build_psymtabs (struct objfile
*, int);
47 void hpread_symfile_finish (struct objfile
*);
49 static union dnttentry
*hpread_get_gntt (int, struct objfile
*);
51 static unsigned long hpread_get_textlow (int, int, struct objfile
*, int);
53 static struct partial_symtab
*hpread_start_psymtab
54 (struct objfile
*, char *, CORE_ADDR
, int,
55 struct partial_symbol
**, struct partial_symbol
**);
57 static struct partial_symtab
*hpread_end_psymtab
58 (struct partial_symtab
*, char **, int, int, CORE_ADDR
,
59 struct partial_symtab
**, int);
61 /* End of forward routine declarations */
65 /* NOTE use of system files! May not be portable. */
67 #define PXDB_SVR4 "/opt/langtools/bin/pxdb"
68 #define PXDB_BSD "/usr/bin/pxdb"
73 /* check for the existance of a file, given its full pathname */
75 file_exists (filename
)
79 return (access (filename
, F_OK
) == 0);
84 /* Translate from the "hp_language" enumeration in hp-symtab.h
85 used in the debug info to gdb's generic enumeration in defs.h. */
88 enum hp_language in_lang
;
90 if (in_lang
== HP_LANGUAGE_C
)
93 else if (in_lang
== HP_LANGUAGE_CPLUSPLUS
)
94 return language_cplus
;
96 else if (in_lang
== HP_LANGUAGE_FORTRAN
)
97 return language_fortran
;
100 return language_unknown
;
103 static char main_string
[] = "main";
105 /* Call PXDB to process our file.
107 Approach copied from DDE's "dbgk_run_pxdb". Note: we
108 don't check for BSD location of pxdb, nor for existance
111 NOTE: uses system function and string functions directly.
113 Return value: 1 if ok, 0 if not */
115 hpread_call_pxdb (file_name
)
122 if (file_exists (PXDB_SVR4
))
124 p
= malloc (strlen (PXDB_SVR4
) + strlen (file_name
) + 2);
125 strcpy (p
, PXDB_SVR4
);
127 strcat (p
, file_name
);
129 warning ("File not processed by pxdb--about to process now.\n");
132 retval
= (status
== 0);
136 warning ("pxdb not found at standard location: /opt/langtools/bin\ngdb will not be able to debug %s.\nPlease install pxdb at the above location and then restart gdb.\nYou can also run pxdb on %s with the command\n\"pxdb %s\" and then restart gdb.", file_name
, file_name
, file_name
);
141 } /* hpread_call_pxdb */
144 /* Return 1 if the file turns out to need pre-processing
145 by PXDB, and we have thus called PXDB to do this processing
146 and the file therefore needs to be re-loaded. Otherwise
149 hpread_pxdb_needed (sym_bfd
)
152 asection
*pinfo_section
, *debug_section
, *header_section
;
153 unsigned int do_pxdb
;
155 bfd_size_type header_section_size
;
160 header_section
= bfd_get_section_by_name (sym_bfd
, "$HEADER$");
163 return 0; /* No header at all, can't recover... */
166 debug_section
= bfd_get_section_by_name (sym_bfd
, "$DEBUG$");
167 pinfo_section
= bfd_get_section_by_name (sym_bfd
, "$PINFO$");
169 if (pinfo_section
&& !debug_section
)
171 /* Debug info with DOC, has different header format.
172 this only happens if the file was pxdbed and compiled optimized
173 otherwise the PINFO section is not there. */
174 header_section_size
= bfd_section_size (objfile
->obfd
, header_section
);
176 if (header_section_size
== (bfd_size_type
) sizeof (DOC_info_PXDB_header
))
178 buf
= alloca (sizeof (DOC_info_PXDB_header
));
180 if (!bfd_get_section_contents (sym_bfd
,
183 header_section_size
))
184 error ("bfd_get_section_contents\n");
186 tmp
= bfd_get_32 (sym_bfd
, (bfd_byte
*) (buf
+ sizeof (int) * 4));
187 pxdbed
= (tmp
>> 31) & 0x1;
190 error ("file debug header info invalid\n");
195 error ("invalid $HEADER$ size in executable \n");
201 /* this can be three different cases:
202 1. pxdbed and not doc
203 - DEBUG and HEADER sections are there
204 - header is PXDB_header type
205 - pxdbed flag is set to 1
207 2. not pxdbed and doc
208 - DEBUG and HEADER sections are there
209 - header is DOC_info_header type
210 - pxdbed flag is set to 0
212 3. not pxdbed and not doc
213 - DEBUG and HEADER sections are there
214 - header is XDB_header type
215 - pxdbed flag is set to 0
217 NOTE: the pxdbed flag is meaningful also in the not
218 already pxdb processed version of the header,
219 because in case on non-already processed by pxdb files
220 that same bit in the header would be always zero.
221 Why? Because the bit is the leftmost bit of a word
222 which contains a 'length' which is always a positive value
223 so that bit is never set to 1 (otherwise it would be negative)
225 Given the above, we have two choices : either we ignore the
226 size of the header itself and just look at the pxdbed field,
227 or we check the size and then we (for safety and paranoia related
228 issues) check the bit.
229 The first solution is used by DDE, the second by PXDB itself.
230 I am using the second one here, because I already wrote it,
231 and it is the end of a long day.
232 Also, using the first approach would still involve size issues
233 because we need to read in the contents of the header section, and
234 give the correct amount of stuff we want to read to the
235 get_bfd_section_contents function. */
237 /* decide which case depending on the size of the header section.
238 The size is as defined in hp-symtab.h */
240 header_section_size
= bfd_section_size (objfile
->obfd
, header_section
);
242 if (header_section_size
== (bfd_size_type
) sizeof (PXDB_header
)) /* pxdb and not doc */
245 buf
= alloca (sizeof (PXDB_header
));
246 if (!bfd_get_section_contents (sym_bfd
,
249 header_section_size
))
250 error ("bfd_get_section_contents\n");
252 tmp
= bfd_get_32 (sym_bfd
, (bfd_byte
*) (buf
+ sizeof (int) * 3));
253 pxdbed
= (tmp
>> 31) & 0x1;
258 error ("file debug header invalid\n");
260 else /*not pxdbed and doc OR not pxdbed and non doc */
272 } /* hpread_pxdb_needed */
276 /* Check whether the file needs to be preprocessed by pxdb.
283 /* The following code is HP-specific. The "right" way of
284 doing this is unknown, but we bet would involve a target-
285 specific pre-file-load check using a generic mechanism. */
287 /* This code will not be executed if the file is not in SOM
288 format (i.e. if compiled with gcc) */
289 if (hpread_pxdb_needed (sym_bfd
))
291 /*This file has not been pre-processed. Preprocess now */
293 if (hpread_call_pxdb (sym_bfd
->filename
))
295 /* The call above has changed the on-disk file,
296 we can close the file anyway, because the
297 symbols will be reread in when the target is run */
307 /* Code to handle quick lookup-tables follows. */
310 /* Some useful macros */
311 #define VALID_FILE(i) ((i) < pxdb_header_p->fd_entries)
312 #define VALID_MODULE(i) ((i) < pxdb_header_p->md_entries)
313 #define VALID_PROC(i) ((i) < pxdb_header_p->pd_entries)
314 #define VALID_CLASS(i) ((i) < pxdb_header_p->cd_entries)
316 #define FILE_START(i) (qFD[i].adrStart)
317 #define MODULE_START(i) (qMD[i].adrStart)
318 #define PROC_START(i) (qPD[i].adrStart)
320 #define FILE_END(i) (qFD[i].adrEnd)
321 #define MODULE_END(i) (qMD[i].adrEnd)
322 #define PROC_END(i) (qPD[i].adrEnd)
324 #define FILE_ISYM(i) (qFD[i].isym)
325 #define MODULE_ISYM(i) (qMD[i].isym)
326 #define PROC_ISYM(i) (qPD[i].isym)
328 #define VALID_CURR_FILE (curr_fd < pxdb_header_p->fd_entries)
329 #define VALID_CURR_MODULE (curr_md < pxdb_header_p->md_entries)
330 #define VALID_CURR_PROC (curr_pd < pxdb_header_p->pd_entries)
331 #define VALID_CURR_CLASS (curr_cd < pxdb_header_p->cd_entries)
333 #define CURR_FILE_START (qFD[curr_fd].adrStart)
334 #define CURR_MODULE_START (qMD[curr_md].adrStart)
335 #define CURR_PROC_START (qPD[curr_pd].adrStart)
337 #define CURR_FILE_END (qFD[curr_fd].adrEnd)
338 #define CURR_MODULE_END (qMD[curr_md].adrEnd)
339 #define CURR_PROC_END (qPD[curr_pd].adrEnd)
341 #define CURR_FILE_ISYM (qFD[curr_fd].isym)
342 #define CURR_MODULE_ISYM (qMD[curr_md].isym)
343 #define CURR_PROC_ISYM (qPD[curr_pd].isym)
345 #define TELL_OBJFILE \
347 if( !told_objfile ) { \
349 warning ("\nIn object file \"%s\":\n", \
356 /* Keeping track of the start/end symbol table (LNTT) indices of
357 psymtabs created so far */
366 static pst_syms_struct
*pst_syms_array
= 0;
368 static pst_syms_count
= 0;
369 static pst_syms_size
= 0;
371 /* used by the TELL_OBJFILE macro */
372 static boolean told_objfile
= 0;
374 /* Set up psymtab symbol index stuff */
380 pst_syms_array
= (pst_syms_struct
*) xmalloc (20 * sizeof (pst_syms_struct
));
383 /* Clean up psymtab symbol index stuff */
389 free (pst_syms_array
);
393 /* Add information about latest psymtab to symbol index table */
395 record_pst_syms (start_sym
, end_sym
)
399 if (++pst_syms_count
> pst_syms_size
)
401 pst_syms_array
= (pst_syms_struct
*) xrealloc (pst_syms_array
,
402 2 * pst_syms_size
* sizeof (pst_syms_struct
));
405 pst_syms_array
[pst_syms_count
- 1].start
= start_sym
;
406 pst_syms_array
[pst_syms_count
- 1].end
= end_sym
;
409 /* Find a suitable symbol table index which can serve as the upper
410 bound of a psymtab that starts at INDEX
412 This scans backwards in the psymtab symbol index table to find a
413 "hole" in which the given index can fit. This is a heuristic!!
414 We don't search the entire table to check for multiple holes,
415 we don't care about overlaps, etc.
417 Return 0 => not found */
419 find_next_pst_start (index
)
424 for (i
= pst_syms_count
- 1; i
>= 0; i
--)
425 if (pst_syms_array
[i
].end
<= index
)
426 return (i
== pst_syms_count
- 1) ? 0 : pst_syms_array
[i
+ 1].start
- 1;
428 if (pst_syms_array
[0].start
> index
)
429 return pst_syms_array
[0].start
- 1;
436 /* Utility functions to find the ending symbol index for a psymtab */
438 /* Find the next file entry that begins beyond INDEX, and return
439 its starting symbol index - 1.
440 QFD is the file table, CURR_FD is the file entry from where to start,
441 PXDB_HEADER_P as in hpread_quick_traverse (to allow macros to work).
443 Return 0 => not found */
445 find_next_file_isym (index
, qFD
, curr_fd
, pxdb_header_p
)
447 quick_file_entry
*qFD
;
449 PXDB_header_ptr pxdb_header_p
;
451 while (VALID_CURR_FILE
)
453 if (CURR_FILE_ISYM
>= index
)
454 return CURR_FILE_ISYM
- 1;
460 /* Find the next procedure entry that begins beyond INDEX, and return
461 its starting symbol index - 1.
462 QPD is the procedure table, CURR_PD is the proc entry from where to start,
463 PXDB_HEADER_P as in hpread_quick_traverse (to allow macros to work).
465 Return 0 => not found */
467 find_next_proc_isym (index
, qPD
, curr_pd
, pxdb_header_p
)
469 quick_procedure_entry
*qPD
;
471 PXDB_header_ptr pxdb_header_p
;
473 while (VALID_CURR_PROC
)
475 if (CURR_PROC_ISYM
>= index
)
476 return CURR_PROC_ISYM
- 1;
482 /* Find the next module entry that begins beyond INDEX, and return
483 its starting symbol index - 1.
484 QMD is the module table, CURR_MD is the modue entry from where to start,
485 PXDB_HEADER_P as in hpread_quick_traverse (to allow macros to work).
487 Return 0 => not found */
489 find_next_module_isym (index
, qMD
, curr_md
, pxdb_header_p
)
491 quick_module_entry
*qMD
;
493 PXDB_header_ptr pxdb_header_p
;
495 while (VALID_CURR_MODULE
)
497 if (CURR_MODULE_ISYM
>= index
)
498 return CURR_MODULE_ISYM
- 1;
504 /* Scan and record partial symbols for all functions starting from index
505 pointed to by CURR_PD_P, and between code addresses START_ADR and END_ADR.
506 Other parameters are explained in comments below. */
508 /* This used to be inline in hpread_quick_traverse, but now that we do essentially the
509 same thing for two different cases (modules and module-less files), it's better
510 organized in a separate routine, although it does take lots of arguments. pai/1997-10-08 */
513 scan_procs (curr_pd_p
, qPD
, max_procs
, start_adr
, end_adr
, pst
, vt_bits
, objfile
)
514 int *curr_pd_p
; /* pointer to current proc index */
515 quick_procedure_entry
*qPD
; /* the procedure quick lookup table */
516 int max_procs
; /* number of entries in proc. table */
517 CORE_ADDR start_adr
; /* beginning of code range for current psymtab */
518 CORE_ADDR end_adr
; /* end of code range for current psymtab */
519 struct partial_symtab
*pst
; /* current psymtab */
520 char *vt_bits
; /* strings table of SOM debug space */
521 struct objfile
*objfile
; /* current object file */
523 union dnttentry
*dn_bufp
;
524 int symbol_count
= 0; /* Total number of symbols in this psymtab */
525 int curr_pd
= *curr_pd_p
; /* Convenience variable -- avoid dereferencing pointer all the time */
528 /* Turn this on for lots of debugging information in this routine */
529 static int dumping
= 0;
535 printf ("Scan_procs called, addresses %x to %x, proc %x\n", start_adr
, end_adr
, curr_pd
);
539 while ((CURR_PROC_START
<= end_adr
) && (curr_pd
< max_procs
))
542 char *rtn_name
; /* mangled name */
543 char *rtn_dem_name
; /* qualified demangled name */
547 if ((trans_lang ((enum hp_language
) qPD
[curr_pd
].language
) == language_cplus
) &&
548 vt_bits
[(long) qPD
[curr_pd
].sbAlias
]) /* not a null string */
550 /* Get mangled name for the procedure, and demangle it */
551 rtn_name
= &vt_bits
[(long) qPD
[curr_pd
].sbAlias
];
552 rtn_dem_name
= cplus_demangle (rtn_name
, DMGL_ANSI
| DMGL_PARAMS
);
556 rtn_name
= &vt_bits
[(long) qPD
[curr_pd
].sbProc
];
560 /* Hack to get around HP C/C++ compilers' insistence on providing
561 "_MAIN_" as an alternate name for "main" */
562 if ((strcmp (rtn_name
, "_MAIN_") == 0) &&
563 (strcmp (&vt_bits
[(long) qPD
[curr_pd
].sbProc
], "main") == 0))
564 rtn_dem_name
= rtn_name
= main_string
;
569 printf ("..add %s (demangled %s), index %x to this psymtab\n", rtn_name
, rtn_dem_name
, curr_pd
);
573 /* Check for module-spanning routines. */
574 if (CURR_PROC_END
> end_adr
)
577 warning ("Procedure \"%s\" [0x%x] spans file or module boundaries.", rtn_name
, curr_pd
);
580 /* Add this routine symbol to the list in the objfile.
581 Unfortunately we have to go to the LNTT to determine the
582 correct list to put it on. An alternative (which the
583 code used to do) would be to not check and always throw
584 it on the "static" list. But if we go that route, then
585 symbol_lookup() needs to be tweaked a bit to account
586 for the fact that the function might not be found on
587 the correct list in the psymtab. - RT */
588 dn_bufp
= hpread_get_lntt (qPD
[curr_pd
].isym
, objfile
);
589 if (dn_bufp
->dfunc
.global
)
590 add_psymbol_with_dem_name_to_list (rtn_name
,
593 strlen (rtn_dem_name
),
595 LOC_BLOCK
, /* "I am a routine" */
596 &objfile
->global_psymbols
,
597 (qPD
[curr_pd
].adrStart
+ /* Starting address of rtn */
598 ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT (objfile
))),
600 trans_lang ((enum hp_language
) qPD
[curr_pd
].language
),
603 add_psymbol_with_dem_name_to_list (rtn_name
,
606 strlen (rtn_dem_name
),
608 LOC_BLOCK
, /* "I am a routine" */
609 &objfile
->static_psymbols
,
610 (qPD
[curr_pd
].adrStart
+ /* Starting address of rtn */
611 ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT (objfile
))),
613 trans_lang ((enum hp_language
) qPD
[curr_pd
].language
),
617 *curr_pd_p
= ++curr_pd
; /* bump up count & reflect in caller */
618 } /* loop over procedures */
623 if (symbol_count
== 0)
624 printf ("Scan_procs: no symbols found!\n");
632 /* Traverse the quick look-up tables, building a set of psymtabs.
634 This constructs a psymtab for modules and files in the quick lookup
637 Mostly, modules correspond to compilation units, so we try to
638 create psymtabs that correspond to modules; however, in some cases
639 a file can result in a compiled object which does not have a module
640 entry for it, so in such cases we create a psymtab for the file. */
643 hpread_quick_traverse (objfile
, gntt_bits
, vt_bits
, pxdb_header_p
)
644 struct objfile
*objfile
; /* The object file descriptor */
645 char *gntt_bits
; /* GNTT entries, loaded in from the file */
646 char *vt_bits
; /* VT (string) entries ditto. */
647 PXDB_header_ptr pxdb_header_p
; /* Pointer to pxdb header ditto */
649 struct partial_symtab
*pst
;
653 quick_procedure_entry
*qPD
;
654 quick_file_entry
*qFD
;
655 quick_module_entry
*qMD
;
656 quick_class_entry
*qCD
;
660 CORE_ADDR start_adr
; /* current psymtab's starting code addr */
661 CORE_ADDR end_adr
; /* current psymtab's ending code addr */
662 CORE_ADDR next_mod_adr
; /* next module's starting code addr */
663 int curr_pd
; /* current procedure */
664 int curr_fd
; /* current file */
665 int curr_md
; /* current module */
666 int start_sym
; /* current psymtab's starting symbol index */
667 int end_sym
; /* current psymtab's ending symbol index */
668 int max_LNTT_sym_index
;
670 B_TYPE
*class_entered
;
672 struct partial_symbol
**global_syms
; /* We'll be filling in the "global" */
673 struct partial_symbol
**static_syms
; /* and "static" tables in the objfile
674 as we go, so we need a pair of
678 /* Turn this on for lots of debugging information in this routine.
679 You get a blow-by-blow account of quick lookup table reading */
680 static int dumping
= 0;
683 pst
= (struct partial_symtab
*) 0;
685 /* Clear out some globals */
689 /* Demangling style -- if EDG style already set, don't change it,
690 as HP style causes some problems with the KAI EDG compiler */
691 if (current_demangling_style
!= edg_demangling
)
693 /* Otherwise, ensure that we are using HP style demangling */
694 set_demangling_style (HP_DEMANGLING_STYLE_STRING
);
697 /* First we need to find the starting points of the quick
698 look-up tables in the GNTT. */
702 qPD
= (quick_procedure_entry_ptr
) addr
;
703 addr
+= pxdb_header_p
->pd_entries
* sizeof (quick_procedure_entry
);
708 printf ("\n Printing routines as we see them\n");
709 for (i
= 0; VALID_PROC (i
); i
++)
711 idx
= (long) qPD
[i
].sbProc
;
712 printf ("%s %x..%x\n", &vt_bits
[idx
],
713 (int) PROC_START (i
),
719 qFD
= (quick_file_entry_ptr
) addr
;
720 addr
+= pxdb_header_p
->fd_entries
* sizeof (quick_file_entry
);
725 printf ("\n Printing files as we see them\n");
726 for (i
= 0; VALID_FILE (i
); i
++)
728 idx
= (long) qFD
[i
].sbFile
;
729 printf ("%s %x..%x\n", &vt_bits
[idx
],
730 (int) FILE_START (i
),
736 qMD
= (quick_module_entry_ptr
) addr
;
737 addr
+= pxdb_header_p
->md_entries
* sizeof (quick_module_entry
);
742 printf ("\n Printing modules as we see them\n");
743 for (i
= 0; i
< pxdb_header_p
->md_entries
; i
++)
745 idx
= (long) qMD
[i
].sbMod
;
746 printf ("%s\n", &vt_bits
[idx
]);
751 qCD
= (quick_class_entry_ptr
) addr
;
752 addr
+= pxdb_header_p
->cd_entries
* sizeof (quick_class_entry
);
757 printf ("\n Printing classes as we see them\n");
758 for (i
= 0; VALID_CLASS (i
); i
++)
760 idx
= (long) qCD
[i
].sbClass
;
761 printf ("%s\n", &vt_bits
[idx
]);
764 printf ("\n Done with dump, on to build!\n");
768 /* We need this index only while hp-symtab-read.c expects
769 a byte offset to the end of the LNTT entries for a given
770 psymtab. Thus the need for it should go away someday.
772 When it goes away, then we won't have any need to load the
773 LNTT from the objfile at psymtab-time, and start-up will be
774 faster. To make that work, we'll need some way to create
775 a null pst for the "globals" pseudo-module. */
776 max_LNTT_sym_index
= LNTT_SYMCOUNT (objfile
);
778 /* Scan the module descriptors and make a psymtab for each.
780 We know the MDs, FDs and the PDs are in order by starting
781 address. We use that fact to traverse all three arrays in
782 parallel, knowing when the next PD is in a new file
783 and we need to create a new psymtab. */
784 curr_pd
= 0; /* Current procedure entry */
785 curr_fd
= 0; /* Current file entry */
786 curr_md
= 0; /* Current module entry */
788 start_adr
= 0; /* Current psymtab code range */
791 start_sym
= 0; /* Current psymtab symbol range */
794 syms_in_pst
= 0; /* Symbol count for psymtab */
796 /* Psts actually just have pointers into the objfile's
797 symbol table, not their own symbol tables. */
798 global_syms
= objfile
->global_psymbols
.list
;
799 static_syms
= objfile
->static_psymbols
.list
;
802 /* First skip over pseudo-entries with address 0. These represent inlined
803 routines and abstract (uninstantiated) template routines.
804 FIXME: These should be read in and available -- even if we can't set
805 breakpoints, etc., there's some information that can be presented
806 to the user. pai/1997-10-08 */
808 while (VALID_CURR_PROC
&& (CURR_PROC_START
== 0))
811 /* Loop over files, modules, and procedures in code address order. Each
812 time we enter an iteration of this loop, curr_pd points to the first
813 unprocessed procedure, curr_fd points to the first unprocessed file, and
814 curr_md to the first unprocessed module. Each iteration of this loop
815 updates these as required -- any or all of them may be bumpd up
816 each time around. When we exit this loop, we are done with all files
817 and modules in the tables -- there may still be some procedures, however.
819 Note: This code used to loop only over module entries, under the assumption
820 that files can occur via inclusions and are thus unreliable, while a
821 compiled object always corresponds to a module. With CTTI in the HP aCC
822 compiler, it turns out that compiled objects may have only files and no
823 modules; so we have to loop over files and modules, creating psymtabs for
824 either as appropriate. Unfortunately there are some problems (notably:
825 1. the lack of "SRC_FILE_END" entries in the LNTT, 2. the lack of pointers
826 to the ending symbol indices of a module or a file) which make it quite hard
827 to do this correctly. Currently it uses a bunch of heuristics to start and
828 end psymtabs; they seem to work well with most objects generated by aCC, but
829 who knows when that will change... */
831 while (VALID_CURR_FILE
|| VALID_CURR_MODULE
)
834 char *mod_name_string
;
835 char *full_name_string
;
837 /* First check for modules like "version.c", which have no code
838 in them but still have qMD entries. They also have no qFD or
839 qPD entries. Their start address is -1 and their end address
841 if (VALID_CURR_MODULE
&& (CURR_MODULE_START
== -1) && (CURR_MODULE_END
== 0))
844 mod_name_string
= &vt_bits
[(long) qMD
[curr_md
].sbMod
];
848 printf ("Module with data only %s\n", mod_name_string
);
851 /* We'll skip the rest (it makes error-checking easier), and
852 just make an empty pst. Right now empty psts are not put
853 in the pst chain, so all this is for naught, but later it
856 pst
= hpread_start_psymtab (objfile
,
858 CURR_MODULE_START
, /* Low text address: bogus! */
859 (CURR_MODULE_ISYM
* sizeof (struct dntt_type_block
)),
864 pst
= hpread_end_psymtab (pst
,
865 NULL
, /* psymtab_include_list */
866 0, /* includes_used */
867 end_sym
* sizeof (struct dntt_type_block
),
868 /* byte index in LNTT of end
869 = capping symbol offset
870 = LDSYMOFF of nextfile */
872 NULL
, /* dependency_list */
873 0); /* dependencies_used */
875 global_syms
= objfile
->global_psymbols
.next
;
876 static_syms
= objfile
->static_psymbols
.next
;
880 else if (VALID_CURR_MODULE
&&
881 ((CURR_MODULE_START
== 0) || (CURR_MODULE_START
== -1) ||
882 (CURR_MODULE_END
== 0) || (CURR_MODULE_END
== -1)))
885 warning ("Module \"%s\" [0x%x] has non-standard addresses. It starts at 0x%x, ends at 0x%x, and will be skipped.",
886 mod_name_string
, curr_md
, start_adr
, end_adr
);
887 /* On to next module */
892 /* First check if we are looking at a file with code in it
893 that does not overlap the current module's code range */
895 if (VALID_CURR_FILE
? (VALID_CURR_MODULE
? (CURR_FILE_END
< CURR_MODULE_START
) : 1) : 0)
898 /* Looking at file not corresponding to any module,
899 create a psymtab for it */
900 full_name_string
= &vt_bits
[(long) qFD
[curr_fd
].sbFile
];
901 start_adr
= CURR_FILE_START
;
902 end_adr
= CURR_FILE_END
;
903 start_sym
= CURR_FILE_ISYM
;
905 /* Check if there are any procedures not handled until now, that
906 begin before the start address of this file, and if so, adjust
907 this module's start address to include them. This handles routines that
908 are in between file or module ranges for some reason (probably
909 indicates a compiler bug */
911 if (CURR_PROC_START
< start_adr
)
914 warning ("Found procedure \"%s\" [0x%x] that is not in any file or module.",
915 &vt_bits
[(long) qPD
[curr_pd
].sbProc
], curr_pd
);
916 start_adr
= CURR_PROC_START
;
917 if (CURR_PROC_ISYM
< start_sym
)
918 start_sym
= CURR_PROC_ISYM
;
921 /* Sometimes (compiler bug -- COBOL) the module end address is higher
922 than the start address of the next module, so check for that and
923 adjust accordingly */
925 if (VALID_FILE (curr_fd
+ 1) && (FILE_START (curr_fd
+ 1) <= end_adr
))
928 warning ("File \"%s\" [0x%x] has ending address after starting address of next file; adjusting ending address down.",
929 full_name_string
, curr_fd
);
930 end_adr
= FILE_START (curr_fd
+ 1) - 1; /* Is -4 (or -8 for 64-bit) better? */
932 if (VALID_MODULE (curr_md
) && (CURR_MODULE_START
<= end_adr
))
935 warning ("File \"%s\" [0x%x] has ending address after starting address of next module; adjusting ending address down.",
936 full_name_string
, curr_fd
);
937 end_adr
= CURR_MODULE_START
- 1; /* Is -4 (or -8 for 64-bit) better? */
944 printf ("Make new psymtab for file %s (%x to %x).\n",
945 full_name_string
, start_adr
, end_adr
);
948 /* Create the basic psymtab, connecting it in the list
949 for this objfile and pointing its symbol entries
950 to the current end of the symbol areas in the objfile.
952 The "ldsymoff" parameter is the byte offset in the LNTT
953 of the first symbol in this file. Some day we should
954 turn this into an index (fix in hp-symtab-read.c as well).
955 And it's not even the right byte offset, as we're using
956 the size of a union! FIXME! */
957 pst
= hpread_start_psymtab (objfile
,
959 start_adr
, /* Low text address */
960 (start_sym
* sizeof (struct dntt_type_block
)),
965 /* Set up to only enter each class referenced in this module once. */
966 class_entered
= malloc (B_BYTES (pxdb_header_p
->cd_entries
));
967 B_CLRALL (class_entered
, pxdb_header_p
->cd_entries
);
969 /* Scan the procedure descriptors for procedures in the current
970 file, based on the starting addresses. */
972 syms_in_pst
= scan_procs (&curr_pd
, qPD
, pxdb_header_p
->pd_entries
,
973 start_adr
, end_adr
, pst
, vt_bits
, objfile
);
975 /* Get ending symbol offset */
978 /* First check for starting index before previous psymtab */
979 if (pst_syms_count
&& start_sym
< pst_syms_array
[pst_syms_count
- 1].end
)
981 end_sym
= find_next_pst_start (start_sym
);
983 /* Look for next start index of a file or module, or procedure */
986 int next_file_isym
= find_next_file_isym (start_sym
, qFD
, curr_fd
+ 1, pxdb_header_p
);
987 int next_module_isym
= find_next_module_isym (start_sym
, qMD
, curr_md
, pxdb_header_p
);
988 int next_proc_isym
= find_next_proc_isym (start_sym
, qPD
, curr_pd
, pxdb_header_p
);
990 if (next_file_isym
&& next_module_isym
)
992 /* pick lower of next file or module start index */
993 end_sym
= min (next_file_isym
, next_module_isym
);
997 /* one of them is zero, pick the other */
998 end_sym
= max (next_file_isym
, next_module_isym
);
1001 /* As a precaution, check next procedure index too */
1003 end_sym
= next_proc_isym
;
1005 end_sym
= min (end_sym
, next_proc_isym
);
1008 /* Couldn't find procedure, file, or module, use globals as default */
1010 end_sym
= pxdb_header_p
->globals
;
1015 printf ("File psymtab indices: %x to %x\n", start_sym
, end_sym
);
1019 pst
= hpread_end_psymtab (pst
,
1020 NULL
, /* psymtab_include_list */
1021 0, /* includes_used */
1022 end_sym
* sizeof (struct dntt_type_block
),
1023 /* byte index in LNTT of end
1024 = capping symbol offset
1025 = LDSYMOFF of nextfile */
1026 end_adr
, /* text high */
1027 NULL
, /* dependency_list */
1028 0); /* dependencies_used */
1030 record_pst_syms (start_sym
, end_sym
);
1033 warning ("No symbols in psymtab for file \"%s\" [0x%x].", full_name_string
, curr_fd
);
1038 printf ("Made new psymtab for file %s (%x to %x), sym %x to %x.\n",
1039 full_name_string
, start_adr
, end_adr
, CURR_FILE_ISYM
, end_sym
);
1042 /* Prepare for the next psymtab. */
1043 global_syms
= objfile
->global_psymbols
.next
;
1044 static_syms
= objfile
->static_psymbols
.next
;
1045 free (class_entered
);
1048 } /* Psymtab for file */
1051 /* We have a module for which we create a psymtab */
1053 mod_name_string
= &vt_bits
[(long) qMD
[curr_md
].sbMod
];
1055 /* We will include the code ranges of any files that happen to
1056 overlap with this module */
1058 /* So, first pick the lower of the file's and module's start addresses */
1059 start_adr
= CURR_MODULE_START
;
1060 if (VALID_CURR_FILE
)
1062 if (CURR_FILE_START
< CURR_MODULE_START
)
1065 warning ("File \"%s\" [0x%x] crosses beginning of module \"%s\".",
1066 &vt_bits
[(long) qFD
[curr_fd
].sbFile
],
1067 curr_fd
, mod_name_string
);
1069 start_adr
= CURR_FILE_START
;
1073 /* Also pick the lower of the file's and the module's start symbol indices */
1074 start_sym
= CURR_MODULE_ISYM
;
1075 if (VALID_CURR_FILE
&& (CURR_FILE_ISYM
< CURR_MODULE_ISYM
))
1076 start_sym
= CURR_FILE_ISYM
;
1078 /* For the end address, we scan through the files till we find one
1079 that overlaps the current module but ends beyond it; if no such file exists we
1080 simply use the module's start address.
1081 (Note, if file entries themselves overlap
1082 we take the longest overlapping extension beyond the end of the module...)
1083 We assume that modules never overlap. */
1085 end_adr
= CURR_MODULE_END
;
1087 if (VALID_CURR_FILE
)
1089 while (VALID_CURR_FILE
&& (CURR_FILE_START
< end_adr
))
1094 printf ("Maybe skipping file %s which overlaps with module %s\n",
1095 &vt_bits
[(long) qFD
[curr_fd
].sbFile
], mod_name_string
);
1097 if (CURR_FILE_END
> end_adr
)
1100 warning ("File \"%s\" [0x%x] crosses end of module \"%s\".",
1101 &vt_bits
[(long) qFD
[curr_fd
].sbFile
],
1102 curr_fd
, mod_name_string
);
1103 end_adr
= CURR_FILE_END
;
1107 curr_fd
--; /* back up after going too far */
1110 /* Sometimes (compiler bug -- COBOL) the module end address is higher
1111 than the start address of the next module, so check for that and
1112 adjust accordingly */
1114 if (VALID_MODULE (curr_md
+ 1) && (MODULE_START (curr_md
+ 1) <= end_adr
))
1117 warning ("Module \"%s\" [0x%x] has ending address after starting address of next module; adjusting ending address down.",
1118 mod_name_string
, curr_md
);
1119 end_adr
= MODULE_START (curr_md
+ 1) - 1; /* Is -4 (or -8 for 64-bit) better? */
1121 if (VALID_FILE (curr_fd
+ 1) && (FILE_START (curr_fd
+ 1) <= end_adr
))
1124 warning ("Module \"%s\" [0x%x] has ending address after starting address of next file; adjusting ending address down.",
1125 mod_name_string
, curr_md
);
1126 end_adr
= FILE_START (curr_fd
+ 1) - 1; /* Is -4 (or -8 for 64-bit) better? */
1129 /* Use one file to get the full name for the module. This
1130 situation can arise if there is executable code in a #include
1131 file. Each file with code in it gets a qFD. Files which don't
1132 contribute code don't get a qFD, even if they include files
1137 #include "rtn.h" return x;
1140 There will a qFD for "rtn.h",and a qMD for "body.c",
1141 but no qMD for "rtn.h" or qFD for "body.c"!
1143 We pick the name of the last file to overlap with this
1144 module. C convention is to put include files first. In a
1145 perfect world, we could check names and use the file whose full
1146 path name ends with the module name. */
1148 if (VALID_CURR_FILE
)
1149 full_name_string
= &vt_bits
[(long) qFD
[curr_fd
].sbFile
];
1151 full_name_string
= mod_name_string
;
1153 /* Check if there are any procedures not handled until now, that
1154 begin before the start address we have now, and if so, adjust
1155 this psymtab's start address to include them. This handles routines that
1156 are in between file or module ranges for some reason (probably
1157 indicates a compiler bug */
1159 if (CURR_PROC_START
< start_adr
)
1162 warning ("Found procedure \"%s\" [0x%x] that is not in any file or module.",
1163 &vt_bits
[(long) qPD
[curr_pd
].sbProc
], curr_pd
);
1164 start_adr
= CURR_PROC_START
;
1165 if (CURR_PROC_ISYM
< start_sym
)
1166 start_sym
= CURR_PROC_ISYM
;
1172 printf ("Make new psymtab for module %s (%x to %x), using file %s\n",
1173 mod_name_string
, start_adr
, end_adr
, full_name_string
);
1176 /* Create the basic psymtab, connecting it in the list
1177 for this objfile and pointing its symbol entries
1178 to the current end of the symbol areas in the objfile.
1180 The "ldsymoff" parameter is the byte offset in the LNTT
1181 of the first symbol in this file. Some day we should
1182 turn this into an index (fix in hp-symtab-read.c as well).
1183 And it's not even the right byte offset, as we're using
1184 the size of a union! FIXME! */
1185 pst
= hpread_start_psymtab (objfile
,
1187 start_adr
, /* Low text address */
1188 (start_sym
* sizeof (struct dntt_type_block
)),
1193 /* Set up to only enter each class referenced in this module once. */
1194 class_entered
= malloc (B_BYTES (pxdb_header_p
->cd_entries
));
1195 B_CLRALL (class_entered
, pxdb_header_p
->cd_entries
);
1197 /* Scan the procedure descriptors for procedures in the current
1198 module, based on the starting addresses. */
1200 syms_in_pst
= scan_procs (&curr_pd
, qPD
, pxdb_header_p
->pd_entries
,
1201 start_adr
, end_adr
, pst
, vt_bits
, objfile
);
1203 /* Get ending symbol offset */
1206 /* First check for starting index before previous psymtab */
1207 if (pst_syms_count
&& start_sym
< pst_syms_array
[pst_syms_count
- 1].end
)
1209 end_sym
= find_next_pst_start (start_sym
);
1211 /* Look for next start index of a file or module, or procedure */
1214 int next_file_isym
= find_next_file_isym (start_sym
, qFD
, curr_fd
+ 1, pxdb_header_p
);
1215 int next_module_isym
= find_next_module_isym (start_sym
, qMD
, curr_md
+ 1, pxdb_header_p
);
1216 int next_proc_isym
= find_next_proc_isym (start_sym
, qPD
, curr_pd
, pxdb_header_p
);
1218 if (next_file_isym
&& next_module_isym
)
1220 /* pick lower of next file or module start index */
1221 end_sym
= min (next_file_isym
, next_module_isym
);
1225 /* one of them is zero, pick the other */
1226 end_sym
= max (next_file_isym
, next_module_isym
);
1229 /* As a precaution, check next procedure index too */
1231 end_sym
= next_proc_isym
;
1233 end_sym
= min (end_sym
, next_proc_isym
);
1236 /* Couldn't find procedure, file, or module, use globals as default */
1238 end_sym
= pxdb_header_p
->globals
;
1243 printf ("Module psymtab indices: %x to %x\n", start_sym
, end_sym
);
1247 pst
= hpread_end_psymtab (pst
,
1248 NULL
, /* psymtab_include_list */
1249 0, /* includes_used */
1250 end_sym
* sizeof (struct dntt_type_block
),
1251 /* byte index in LNTT of end
1252 = capping symbol offset
1253 = LDSYMOFF of nextfile */
1254 end_adr
, /* text high */
1255 NULL
, /* dependency_list */
1256 0); /* dependencies_used */
1258 record_pst_syms (start_sym
, end_sym
);
1261 warning ("No symbols in psymtab for module \"%s\" [0x%x].", mod_name_string
, curr_md
);
1266 printf ("Made new psymtab for module %s (%x to %x), sym %x to %x.\n",
1267 mod_name_string
, start_adr
, end_adr
, CURR_MODULE_ISYM
, end_sym
);
1271 /* Prepare for the next psymtab. */
1272 global_syms
= objfile
->global_psymbols
.next
;
1273 static_syms
= objfile
->static_psymbols
.next
;
1274 free (class_entered
);
1278 } /* psymtab for module */
1279 } /* psymtab for non-bogus file or module */
1280 } /* End of while loop over all files & modules */
1282 /* There may be some routines after all files and modules -- these will get
1283 inserted in a separate new module of their own */
1284 if (VALID_CURR_PROC
)
1286 start_adr
= CURR_PROC_START
;
1287 end_adr
= qPD
[pxdb_header_p
->pd_entries
- 1].adrEnd
;
1289 warning ("Found functions beyond end of all files and modules [0x%x].", curr_pd
);
1293 printf ("Orphan functions at end, PD %d and beyond (%x to %x)\n",
1294 curr_pd
, start_adr
, end_adr
);
1297 pst
= hpread_start_psymtab (objfile
,
1299 start_adr
, /* Low text address */
1300 (CURR_PROC_ISYM
* sizeof (struct dntt_type_block
)),
1305 scan_procs (&curr_pd
, qPD
, pxdb_header_p
->pd_entries
,
1306 start_adr
, end_adr
, pst
, vt_bits
, objfile
);
1308 pst
= hpread_end_psymtab (pst
,
1309 NULL
, /* psymtab_include_list */
1310 0, /* includes_used */
1311 pxdb_header_p
->globals
* sizeof (struct dntt_type_block
),
1312 /* byte index in LNTT of end
1313 = capping symbol offset
1314 = LDSYMOFF of nextfile */
1315 end_adr
, /* text high */
1316 NULL
, /* dependency_list */
1317 0); /* dependencies_used */
1322 /* Now build psts for non-module things (in the tail of
1323 the LNTT, after the last END MODULE entry).
1325 If null psts were kept on the chain, this would be
1326 a solution. FIXME */
1327 pst
= hpread_start_psymtab (objfile
,
1330 (pxdb_header_p
->globals
1331 * sizeof (struct dntt_type_block
)),
1332 objfile
->global_psymbols
.next
,
1333 objfile
->static_psymbols
.next
);
1334 hpread_end_psymtab (pst
,
1336 (max_LNTT_sym_index
* sizeof (struct dntt_type_block
)),
1345 } /* End of hpread_quick_traverse. */
1348 /* Get appropriate header, based on pxdb type.
1349 Return value: 1 if ok, 0 if not */
1351 hpread_get_header (objfile
, pxdb_header_p
)
1352 struct objfile
*objfile
;
1353 PXDB_header_ptr pxdb_header_p
;
1355 asection
*pinfo_section
, *debug_section
, *header_section
;
1358 /* Turn on for debugging information */
1359 static int dumping
= 0;
1362 header_section
= bfd_get_section_by_name (objfile
->obfd
, "$HEADER$");
1363 if (!header_section
)
1365 /* We don't have either PINFO or DEBUG sections. But
1366 stuff like "libc.sl" has no debug info. There's no
1367 need to warn the user of this, as it may be ok. The
1368 caller will figure it out and issue any needed
1372 printf ("==No debug info at all for %s.\n", objfile
->name
);
1378 /* We would like either a $DEBUG$ or $PINFO$ section.
1379 Once we know which, we can understand the header
1380 data (which we have defined to suit the more common
1382 debug_section
= bfd_get_section_by_name (objfile
->obfd
, "$DEBUG$");
1383 pinfo_section
= bfd_get_section_by_name (objfile
->obfd
, "$PINFO$");
1386 /* The expected case: normal pxdb header. */
1387 bfd_get_section_contents (objfile
->obfd
, header_section
,
1388 pxdb_header_p
, 0, sizeof (PXDB_header
));
1390 if (!pxdb_header_p
->pxdbed
)
1392 /* This shouldn't happen if we check in "symfile.c". */
1394 } /* DEBUG section */
1397 else if (pinfo_section
)
1399 /* The DOC case; we need to translate this into a
1401 DOC_info_PXDB_header doc_header
;
1406 printf ("==OOps, PINFO, let's try to handle this, %s.\n", objfile
->name
);
1410 bfd_get_section_contents (objfile
->obfd
,
1413 sizeof (DOC_info_PXDB_header
));
1415 if (!doc_header
.pxdbed
)
1417 /* This shouldn't happen if we check in "symfile.c". */
1418 warning ("File \"%s\" not processed by pxdb!", objfile
->name
);
1422 /* Copy relevent fields to standard header passed in. */
1423 pxdb_header_p
->pd_entries
= doc_header
.pd_entries
;
1424 pxdb_header_p
->fd_entries
= doc_header
.fd_entries
;
1425 pxdb_header_p
->md_entries
= doc_header
.md_entries
;
1426 pxdb_header_p
->pxdbed
= doc_header
.pxdbed
;
1427 pxdb_header_p
->bighdr
= doc_header
.bighdr
;
1428 pxdb_header_p
->sa_header
= doc_header
.sa_header
;
1429 pxdb_header_p
->inlined
= doc_header
.inlined
;
1430 pxdb_header_p
->globals
= doc_header
.globals
;
1431 pxdb_header_p
->time
= doc_header
.time
;
1432 pxdb_header_p
->pg_entries
= doc_header
.pg_entries
;
1433 pxdb_header_p
->functions
= doc_header
.functions
;
1434 pxdb_header_p
->files
= doc_header
.files
;
1435 pxdb_header_p
->cd_entries
= doc_header
.cd_entries
;
1436 pxdb_header_p
->aa_entries
= doc_header
.aa_entries
;
1437 pxdb_header_p
->oi_entries
= doc_header
.oi_entries
;
1438 pxdb_header_p
->version
= doc_header
.version
;
1439 } /* PINFO section */
1445 printf ("==No debug info at all for %s.\n", objfile
->name
);
1453 } /* End of hpread_get_header */
1454 #endif /* QUICK_LOOK_UP */
1457 /* Initialization for reading native HP C debug symbols from OBJFILE.
1459 Its only purpose in life is to set up the symbol reader's private
1460 per-objfile data structures, and read in the raw contents of the debug
1461 sections (attaching pointers to the debug info into the private data
1464 Since BFD doesn't know how to read debug symbols in a format-independent
1465 way (and may never do so...), we have to do it ourselves. Note we may
1466 be called on a file without native HP C debugging symbols.
1468 FIXME, there should be a cleaner peephole into the BFD environment
1471 hpread_symfile_init (objfile
)
1472 struct objfile
*objfile
;
1474 asection
*vt_section
, *slt_section
, *lntt_section
, *gntt_section
;
1476 /* Allocate struct to keep track of the symfile */
1477 objfile
->sym_private
= (PTR
)
1478 xmmalloc (objfile
->md
, sizeof (struct hpread_symfile_info
));
1479 memset (objfile
->sym_private
, 0, sizeof (struct hpread_symfile_info
));
1481 /* We haven't read in any types yet. */
1482 TYPE_VECTOR (objfile
) = 0;
1484 /* Read in data from the $GNTT$ subspace. */
1485 gntt_section
= bfd_get_section_by_name (objfile
->obfd
, "$GNTT$");
1490 = obstack_alloc (&objfile
->symbol_obstack
,
1491 bfd_section_size (objfile
->obfd
, gntt_section
));
1493 bfd_get_section_contents (objfile
->obfd
, gntt_section
, GNTT (objfile
),
1494 0, bfd_section_size (objfile
->obfd
, gntt_section
));
1496 GNTT_SYMCOUNT (objfile
)
1497 = bfd_section_size (objfile
->obfd
, gntt_section
)
1498 / sizeof (struct dntt_type_block
);
1500 /* Read in data from the $LNTT$ subspace. Also keep track of the number
1503 FIXME: this could be moved into the psymtab-to-symtab expansion
1504 code, and save startup time. At the moment this data is
1505 still used, though. We'd need a way to tell hp-symtab-read.c
1506 whether or not to load the LNTT. */
1507 lntt_section
= bfd_get_section_by_name (objfile
->obfd
, "$LNTT$");
1512 = obstack_alloc (&objfile
->symbol_obstack
,
1513 bfd_section_size (objfile
->obfd
, lntt_section
));
1515 bfd_get_section_contents (objfile
->obfd
, lntt_section
, LNTT (objfile
),
1516 0, bfd_section_size (objfile
->obfd
, lntt_section
));
1518 LNTT_SYMCOUNT (objfile
)
1519 = bfd_section_size (objfile
->obfd
, lntt_section
)
1520 / sizeof (struct dntt_type_block
);
1522 /* Read in data from the $SLT$ subspace. $SLT$ contains information
1523 on source line numbers. */
1524 slt_section
= bfd_get_section_by_name (objfile
->obfd
, "$SLT$");
1529 obstack_alloc (&objfile
->symbol_obstack
,
1530 bfd_section_size (objfile
->obfd
, slt_section
));
1532 bfd_get_section_contents (objfile
->obfd
, slt_section
, SLT (objfile
),
1533 0, bfd_section_size (objfile
->obfd
, slt_section
));
1535 /* Read in data from the $VT$ subspace. $VT$ contains things like
1536 names and constants. Keep track of the number of symbols in the VT. */
1537 vt_section
= bfd_get_section_by_name (objfile
->obfd
, "$VT$");
1541 VT_SIZE (objfile
) = bfd_section_size (objfile
->obfd
, vt_section
);
1544 (char *) obstack_alloc (&objfile
->symbol_obstack
,
1547 bfd_get_section_contents (objfile
->obfd
, vt_section
, VT (objfile
),
1548 0, VT_SIZE (objfile
));
1551 /* Scan and build partial symbols for a symbol file.
1553 The minimal symbol table (either SOM or HP a.out) has already been
1554 read in; all we need to do is setup partial symbols based on the
1555 native debugging information.
1557 Note that the minimal table is produced by the linker, and has
1558 only global routines in it; the psymtab is based on compiler-
1559 generated debug information and has non-global
1560 routines in it as well as files and class information.
1562 We assume hpread_symfile_init has been called to initialize the
1563 symbol reader's private data structures.
1565 MAINLINE is true if we are reading the main symbol table (as
1566 opposed to a shared lib or dynamically loaded file). */
1569 hpread_build_psymtabs (objfile
, mainline
)
1570 struct objfile
*objfile
;
1575 /* Turn this on to get debugging output. */
1576 static int dumping
= 0;
1580 int past_first_source_file
= 0;
1581 struct cleanup
*old_chain
;
1583 int hp_symnum
, symcount
, i
;
1586 union dnttentry
*dn_bufp
;
1592 /* Current partial symtab */
1593 struct partial_symtab
*pst
;
1595 /* List of current psymtab's include files */
1596 char **psymtab_include_list
;
1597 int includes_allocated
;
1600 /* Index within current psymtab dependency list */
1601 struct partial_symtab
**dependency_list
;
1602 int dependencies_used
, dependencies_allocated
;
1604 /* Just in case the stabs reader left turds lying around. */
1605 free_pending_blocks ();
1606 make_cleanup (really_free_pendings
, 0);
1608 pst
= (struct partial_symtab
*) 0;
1610 /* We shouldn't use alloca, instead use malloc/free. Doing so avoids
1611 a number of problems with cross compilation and creating useless holes
1612 in the stack when we have to allocate new entries. FIXME. */
1614 includes_allocated
= 30;
1616 psymtab_include_list
= (char **) alloca (includes_allocated
*
1619 dependencies_allocated
= 30;
1620 dependencies_used
= 0;
1622 (struct partial_symtab
**) alloca (dependencies_allocated
*
1623 sizeof (struct partial_symtab
*));
1625 old_chain
= make_cleanup_free_objfile (objfile
);
1627 last_source_file
= 0;
1629 #ifdef QUICK_LOOK_UP
1631 /* Begin code for new-style loading of quick look-up tables. */
1633 /* elz: this checks whether the file has beeen processed by pxdb.
1634 If not we would like to try to read the psymbols in
1635 anyway, but it turns out to be not so easy. So this could
1636 actually be commented out, but I leave it in, just in case
1637 we decide to add support for non-pxdb-ed stuff in the future. */
1638 PXDB_header pxdb_header
;
1639 int found_modules_in_program
;
1641 if (hpread_get_header (objfile
, &pxdb_header
))
1643 /* Build a minimal table. No types, no global variables,
1644 no include files.... */
1647 printf ("\nNew method for %s\n", objfile
->name
);
1650 /* elz: quick_traverse returns true if it found
1651 some modules in the main source file, other
1653 In C and C++, all the files have MODULES entries
1654 in the LNTT, and the quick table traverse is all
1655 based on finding these MODULES entries. Without
1656 those it cannot work.
1657 It happens that F77 programs don't have MODULES
1658 so the quick traverse gets confused. F90 programs
1659 have modules, and the quick method still works.
1660 So, if modules (other than those in end.c) are
1661 not found we give up on the quick table stuff,
1662 and fall back on the slower method */
1663 found_modules_in_program
= hpread_quick_traverse (objfile
,
1668 discard_cleanups (old_chain
);
1670 /* Set up to scan the global section of the LNTT.
1672 This field is not always correct: if there are
1673 no globals, it will point to the last record in
1674 the regular LNTT, which is usually an END MODULE.
1676 Since it might happen that there could be a file
1677 with just one global record, there's no way to
1678 tell other than by looking at the record, so that's
1680 if (found_modules_in_program
)
1681 scan_start
= pxdb_header
.globals
;
1687 printf ("\nGoing on to old method for %s\n", objfile
->name
);
1691 #endif /* QUICK_LOOK_UP */
1693 /* Make two passes, one over the GNTT symbols, the other for the
1696 JB comment: above isn't true--they only make one pass, over
1698 for (i
= 0; i
< 1; i
++)
1700 int within_function
= 0;
1703 symcount
= GNTT_SYMCOUNT (objfile
);
1705 symcount
= LNTT_SYMCOUNT (objfile
);
1708 for (hp_symnum
= scan_start
; hp_symnum
< symcount
; hp_symnum
++)
1712 dn_bufp
= hpread_get_gntt (hp_symnum
, objfile
);
1714 dn_bufp
= hpread_get_lntt (hp_symnum
, objfile
);
1716 if (dn_bufp
->dblock
.extension
)
1719 /* Only handle things which are necessary for minimal symbols.
1720 everything else is ignored. */
1721 switch (dn_bufp
->dblock
.kind
)
1723 case DNTT_TYPE_SRCFILE
:
1725 #ifdef QUICK_LOOK_UP
1726 if (scan_start
== hp_symnum
1727 && symcount
== hp_symnum
+ 1)
1729 /* If there are NO globals in an executable,
1730 PXDB's index to the globals will point to
1731 the last record in the file, which
1732 could be this record. (this happened for F77 libraries)
1733 ignore it and be done! */
1736 #endif /* QUICK_LOOK_UP */
1738 /* A source file of some kind. Note this may simply
1739 be an included file. */
1740 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
1742 /* Check if this is the source file we are already working
1744 if (pst
&& !strcmp (namestring
, pst
->filename
))
1747 /* Check if this is an include file, if so check if we have
1748 already seen it. Add it to the include list */
1749 p
= strrchr (namestring
, '.');
1750 if (!strcmp (p
, ".h"))
1755 for (j
= 0; j
< includes_used
; j
++)
1756 if (!strcmp (namestring
, psymtab_include_list
[j
]))
1764 /* Add it to the list of includes seen so far and
1765 allocate more include space if necessary. */
1766 psymtab_include_list
[includes_used
++] = namestring
;
1767 if (includes_used
>= includes_allocated
)
1769 char **orig
= psymtab_include_list
;
1771 psymtab_include_list
= (char **)
1772 alloca ((includes_allocated
*= 2) *
1774 memcpy ((PTR
) psymtab_include_list
, (PTR
) orig
,
1775 includes_used
* sizeof (char *));
1784 pst
->filename
= (char *)
1785 obstack_alloc (&pst
->objfile
->psymbol_obstack
,
1786 strlen (namestring
) + 1);
1787 strcpy (pst
->filename
, namestring
);
1794 /* This is a bonafide new source file.
1795 End the current partial symtab and start a new one. */
1797 if (pst
&& past_first_source_file
)
1799 hpread_end_psymtab (pst
, psymtab_include_list
,
1802 * sizeof (struct dntt_type_block
)),
1804 dependency_list
, dependencies_used
);
1805 pst
= (struct partial_symtab
*) 0;
1807 dependencies_used
= 0;
1810 past_first_source_file
= 1;
1812 valu
= hpread_get_textlow (i
, hp_symnum
, objfile
, symcount
);
1813 valu
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT (objfile
));
1814 pst
= hpread_start_psymtab (objfile
,
1817 * sizeof (struct dntt_type_block
)),
1818 objfile
->global_psymbols
.next
,
1819 objfile
->static_psymbols
.next
);
1825 case DNTT_TYPE_MODULE
:
1826 /* A source file. It's still unclear to me what the
1827 real difference between a DNTT_TYPE_SRCFILE and DNTT_TYPE_MODULE
1828 is supposed to be. */
1830 /* First end the previous psymtab */
1833 hpread_end_psymtab (pst
, psymtab_include_list
, includes_used
,
1835 * sizeof (struct dntt_type_block
)),
1837 dependency_list
, dependencies_used
);
1838 pst
= (struct partial_symtab
*) 0;
1840 dependencies_used
= 0;
1844 /* Now begin a new module and a new psymtab for it */
1845 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
1846 valu
= hpread_get_textlow (i
, hp_symnum
, objfile
, symcount
);
1847 valu
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT (objfile
));
1850 pst
= hpread_start_psymtab (objfile
,
1853 * sizeof (struct dntt_type_block
)),
1854 objfile
->global_psymbols
.next
,
1855 objfile
->static_psymbols
.next
);
1861 case DNTT_TYPE_FUNCTION
:
1862 case DNTT_TYPE_ENTRY
:
1863 /* The beginning of a function. DNTT_TYPE_ENTRY may also denote
1864 a secondary entry point. */
1865 valu
= dn_bufp
->dfunc
.hiaddr
+ ANOFFSET (objfile
->section_offsets
,
1866 SECT_OFF_TEXT (objfile
));
1867 if (valu
> texthigh
)
1869 valu
= dn_bufp
->dfunc
.lowaddr
+
1870 ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT (objfile
));
1871 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
1872 if (dn_bufp
->dfunc
.global
)
1873 add_psymbol_to_list (namestring
, strlen (namestring
),
1874 VAR_NAMESPACE
, LOC_BLOCK
,
1875 &objfile
->global_psymbols
, valu
,
1876 0, language_unknown
, objfile
);
1878 add_psymbol_to_list (namestring
, strlen (namestring
),
1879 VAR_NAMESPACE
, LOC_BLOCK
,
1880 &objfile
->static_psymbols
, valu
,
1881 0, language_unknown
, objfile
);
1882 within_function
= 1;
1885 case DNTT_TYPE_DOC_FUNCTION
:
1886 valu
= dn_bufp
->ddocfunc
.hiaddr
+ ANOFFSET (objfile
->section_offsets
,
1887 SECT_OFF_TEXT (objfile
));
1888 if (valu
> texthigh
)
1890 valu
= dn_bufp
->ddocfunc
.lowaddr
+
1891 ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT (objfile
));
1892 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
1893 if (dn_bufp
->ddocfunc
.global
)
1894 add_psymbol_to_list (namestring
, strlen (namestring
),
1895 VAR_NAMESPACE
, LOC_BLOCK
,
1896 &objfile
->global_psymbols
, valu
,
1897 0, language_unknown
, objfile
);
1899 add_psymbol_to_list (namestring
, strlen (namestring
),
1900 VAR_NAMESPACE
, LOC_BLOCK
,
1901 &objfile
->static_psymbols
, valu
,
1902 0, language_unknown
, objfile
);
1903 within_function
= 1;
1906 case DNTT_TYPE_BEGIN
:
1908 /* We don't check MODULE end here, because there can be
1909 symbols beyond the module end which properly belong to the
1910 current psymtab -- so we wait till the next MODULE start */
1913 #ifdef QUICK_LOOK_UP
1914 if (scan_start
== hp_symnum
1915 && symcount
== hp_symnum
+ 1)
1917 /* If there are NO globals in an executable,
1918 PXDB's index to the globals will point to
1919 the last record in the file, which is
1920 probably an END MODULE, i.e. this record.
1921 ignore it and be done! */
1924 #endif /* QUICK_LOOK_UP */
1926 /* Scope block begin/end. We only care about function
1927 and file blocks right now. */
1929 if ((dn_bufp
->dend
.endkind
== DNTT_TYPE_FUNCTION
) ||
1930 (dn_bufp
->dend
.endkind
== DNTT_TYPE_DOC_FUNCTION
))
1931 within_function
= 0;
1934 case DNTT_TYPE_SVAR
:
1935 case DNTT_TYPE_DVAR
:
1936 case DNTT_TYPE_TYPEDEF
:
1937 case DNTT_TYPE_TAGDEF
:
1939 /* Variables, typedefs an the like. */
1940 enum address_class storage
;
1941 namespace_enum
namespace;
1943 /* Don't add locals to the partial symbol table. */
1945 && (dn_bufp
->dblock
.kind
== DNTT_TYPE_SVAR
1946 || dn_bufp
->dblock
.kind
== DNTT_TYPE_DVAR
))
1949 /* TAGDEFs go into the structure namespace. */
1950 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_TAGDEF
)
1951 namespace = STRUCT_NAMESPACE
;
1953 namespace = VAR_NAMESPACE
;
1955 /* What kind of "storage" does this use? */
1956 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_SVAR
)
1957 storage
= LOC_STATIC
;
1958 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_DVAR
1959 && dn_bufp
->ddvar
.regvar
)
1960 storage
= LOC_REGISTER
;
1961 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_DVAR
)
1962 storage
= LOC_LOCAL
;
1964 storage
= LOC_UNDEF
;
1966 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
1969 pst
= hpread_start_psymtab (objfile
,
1972 * sizeof (struct dntt_type_block
)),
1973 objfile
->global_psymbols
.next
,
1974 objfile
->static_psymbols
.next
);
1977 /* Compute address of the data symbol */
1978 valu
= dn_bufp
->dsvar
.location
;
1979 /* Relocate in case it's in a shared library */
1980 if (storage
== LOC_STATIC
)
1981 valu
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_DATA (objfile
));
1983 /* Luckily, dvar, svar, typedef, and tagdef all
1984 have their "global" bit in the same place, so it works
1985 (though it's bad programming practice) to reference
1986 "dsvar.global" even though we may be looking at
1987 any of the above four types. */
1988 if (dn_bufp
->dsvar
.global
)
1990 add_psymbol_to_list (namestring
, strlen (namestring
),
1992 &objfile
->global_psymbols
,
1994 0, language_unknown
, objfile
);
1998 add_psymbol_to_list (namestring
, strlen (namestring
),
2000 &objfile
->static_psymbols
,
2002 0, language_unknown
, objfile
);
2005 /* For TAGDEF's, the above code added the tagname to the
2006 struct namespace. This will cause tag "t" to be found
2007 on a reference of the form "(struct t) x". But for
2008 C++ classes, "t" will also be a typename, which we
2009 want to find on a reference of the form "ptype t".
2010 Therefore, we also add "t" to the var namespace.
2011 Do the same for enum's due to the way aCC generates
2012 debug info for these (see more extended comment
2013 in hp-symtab-read.c).
2014 We do the same for templates, so that "ptype t"
2015 where "t" is a template also works. */
2016 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_TAGDEF
&&
2017 dn_bufp
->dtype
.type
.dnttp
.index
< LNTT_SYMCOUNT (objfile
))
2019 int global
= dn_bufp
->dtag
.global
;
2020 /* Look ahead to see if it's a C++ class */
2021 dn_bufp
= hpread_get_lntt (dn_bufp
->dtype
.type
.dnttp
.index
, objfile
);
2022 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_CLASS
||
2023 dn_bufp
->dblock
.kind
== DNTT_TYPE_ENUM
||
2024 dn_bufp
->dblock
.kind
== DNTT_TYPE_TEMPLATE
)
2028 add_psymbol_to_list (namestring
, strlen (namestring
),
2029 VAR_NAMESPACE
, storage
,
2030 &objfile
->global_psymbols
,
2031 dn_bufp
->dsvar
.location
,
2032 0, language_unknown
, objfile
);
2036 add_psymbol_to_list (namestring
, strlen (namestring
),
2037 VAR_NAMESPACE
, storage
,
2038 &objfile
->static_psymbols
,
2039 dn_bufp
->dsvar
.location
,
2040 0, language_unknown
, objfile
);
2047 case DNTT_TYPE_MEMENUM
:
2048 case DNTT_TYPE_CONST
:
2049 /* Constants and members of enumerated types. */
2050 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
2053 pst
= hpread_start_psymtab (objfile
,
2056 * sizeof (struct dntt_type_block
)),
2057 objfile
->global_psymbols
.next
,
2058 objfile
->static_psymbols
.next
);
2060 if (dn_bufp
->dconst
.global
)
2061 add_psymbol_to_list (namestring
, strlen (namestring
),
2062 VAR_NAMESPACE
, LOC_CONST
,
2063 &objfile
->global_psymbols
, 0,
2064 0, language_unknown
, objfile
);
2066 add_psymbol_to_list (namestring
, strlen (namestring
),
2067 VAR_NAMESPACE
, LOC_CONST
,
2068 &objfile
->static_psymbols
, 0,
2069 0, language_unknown
, objfile
);
2077 /* End any pending partial symbol table. */
2080 hpread_end_psymtab (pst
, psymtab_include_list
, includes_used
,
2081 hp_symnum
* sizeof (struct dntt_type_block
),
2082 0, dependency_list
, dependencies_used
);
2085 discard_cleanups (old_chain
);
2088 /* Perform any local cleanups required when we are done with a particular
2089 objfile. I.E, we are in the process of discarding all symbol information
2090 for an objfile, freeing up all memory held for it, and unlinking the
2091 objfile struct from the global list of known objfiles. */
2094 hpread_symfile_finish (objfile
)
2095 struct objfile
*objfile
;
2097 if (objfile
->sym_private
!= NULL
)
2099 mfree (objfile
->md
, objfile
->sym_private
);
2104 /* The remaining functions are all for internal use only. */
2106 /* Various small functions to get entries in the debug symbol sections. */
2109 hpread_get_lntt (index
, objfile
)
2111 struct objfile
*objfile
;
2113 return (union dnttentry
*)
2114 &(LNTT (objfile
)[(index
* sizeof (struct dntt_type_block
))]);
2117 static union dnttentry
*
2118 hpread_get_gntt (index
, objfile
)
2120 struct objfile
*objfile
;
2122 return (union dnttentry
*)
2123 &(GNTT (objfile
)[(index
* sizeof (struct dntt_type_block
))]);
2127 hpread_get_slt (index
, objfile
)
2129 struct objfile
*objfile
;
2131 return (union sltentry
*) &(SLT (objfile
)[index
* sizeof (union sltentry
)]);
2134 /* Get the low address associated with some symbol (typically the start
2135 of a particular source file or module). Since that information is not
2136 stored as part of the DNTT_TYPE_MODULE or DNTT_TYPE_SRCFILE symbol we must infer it from
2137 the existance of DNTT_TYPE_FUNCTION symbols. */
2139 static unsigned long
2140 hpread_get_textlow (global
, index
, objfile
, symcount
)
2143 struct objfile
*objfile
;
2146 union dnttentry
*dn_bufp
;
2147 struct minimal_symbol
*msymbol
;
2149 /* Look for a DNTT_TYPE_FUNCTION symbol. */
2150 if (index
< symcount
) /* symcount is the number of symbols in */
2151 { /* the dbinfo, LNTT table */
2155 dn_bufp
= hpread_get_gntt (index
++, objfile
);
2157 dn_bufp
= hpread_get_lntt (index
++, objfile
);
2159 while (dn_bufp
->dblock
.kind
!= DNTT_TYPE_FUNCTION
2160 && dn_bufp
->dblock
.kind
!= DNTT_TYPE_DOC_FUNCTION
2161 && dn_bufp
->dblock
.kind
!= DNTT_TYPE_END
2162 && index
< symcount
);
2165 /* Avoid going past a DNTT_TYPE_END when looking for a DNTT_TYPE_FUNCTION. This
2166 might happen when a sourcefile has no functions. */
2167 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_END
)
2170 /* Avoid going past the end of the LNTT file */
2171 if (index
== symcount
)
2174 /* The minimal symbols are typically more accurate for some reason. */
2175 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_FUNCTION
)
2176 msymbol
= lookup_minimal_symbol (dn_bufp
->dfunc
.name
+ VT (objfile
), NULL
,
2178 else /* must be a DNTT_TYPE_DOC_FUNCTION */
2179 msymbol
= lookup_minimal_symbol (dn_bufp
->ddocfunc
.name
+ VT (objfile
), NULL
,
2183 return SYMBOL_VALUE_ADDRESS (msymbol
);
2185 return dn_bufp
->dfunc
.lowaddr
;
2188 /* Allocate and partially fill a partial symtab. It will be
2189 completely filled at the end of the symbol list.
2191 SYMFILE_NAME is the name of the symbol-file we are reading from, and ADDR
2192 is the address relative to which its symbols are (incremental) or 0
2195 static struct partial_symtab
*
2196 hpread_start_psymtab (objfile
,
2197 filename
, textlow
, ldsymoff
, global_syms
, static_syms
)
2198 struct objfile
*objfile
;
2202 struct partial_symbol
**global_syms
;
2203 struct partial_symbol
**static_syms
;
2205 int offset
= ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT (objfile
));
2206 extern void hpread_psymtab_to_symtab ();
2207 struct partial_symtab
*result
=
2208 start_psymtab_common (objfile
, objfile
->section_offsets
,
2209 filename
, textlow
, global_syms
, static_syms
);
2211 result
->textlow
+= offset
;
2212 result
->read_symtab_private
= (char *)
2213 obstack_alloc (&objfile
->psymbol_obstack
, sizeof (struct symloc
));
2214 LDSYMOFF (result
) = ldsymoff
;
2215 result
->read_symtab
= hpread_psymtab_to_symtab
;
2221 /* Close off the current usage of PST.
2222 Returns PST or NULL if the partial symtab was empty and thrown away.
2224 capping_symbol_offset --Byte index in LNTT or GNTT of the
2225 last symbol processed during the build
2226 of the previous pst.
2228 FIXME: List variables and peculiarities of same. */
2230 static struct partial_symtab
*
2231 hpread_end_psymtab (pst
, include_list
, num_includes
, capping_symbol_offset
,
2232 capping_text
, dependency_list
, number_dependencies
)
2233 struct partial_symtab
*pst
;
2234 char **include_list
;
2236 int capping_symbol_offset
;
2237 CORE_ADDR capping_text
;
2238 struct partial_symtab
**dependency_list
;
2239 int number_dependencies
;
2242 struct objfile
*objfile
= pst
->objfile
;
2243 int offset
= ANOFFSET (pst
->section_offsets
, SECT_OFF_TEXT (objfile
));
2246 /* Turn on to see what kind of a psymtab we've built. */
2247 static int dumping
= 0;
2250 if (capping_symbol_offset
!= -1)
2251 LDSYMLEN (pst
) = capping_symbol_offset
- LDSYMOFF (pst
);
2254 pst
->texthigh
= capping_text
+ offset
;
2256 pst
->n_global_syms
=
2257 objfile
->global_psymbols
.next
- (objfile
->global_psymbols
.list
+ pst
->globals_offset
);
2258 pst
->n_static_syms
=
2259 objfile
->static_psymbols
.next
- (objfile
->static_psymbols
.list
+ pst
->statics_offset
);
2264 printf ("\nPst %s, LDSYMOFF %x (%x), LDSYMLEN %x (%x), globals %d, statics %d\n",
2267 LDSYMOFF (pst
) / sizeof (struct dntt_type_block
),
2269 LDSYMLEN (pst
) / sizeof (struct dntt_type_block
),
2270 pst
->n_global_syms
, pst
->n_static_syms
);
2274 pst
->number_of_dependencies
= number_dependencies
;
2275 if (number_dependencies
)
2277 pst
->dependencies
= (struct partial_symtab
**)
2278 obstack_alloc (&objfile
->psymbol_obstack
,
2279 number_dependencies
* sizeof (struct partial_symtab
*));
2280 memcpy (pst
->dependencies
, dependency_list
,
2281 number_dependencies
* sizeof (struct partial_symtab
*));
2284 pst
->dependencies
= 0;
2286 for (i
= 0; i
< num_includes
; i
++)
2288 struct partial_symtab
*subpst
=
2289 allocate_psymtab (include_list
[i
], objfile
);
2291 subpst
->section_offsets
= pst
->section_offsets
;
2292 subpst
->read_symtab_private
=
2293 (char *) obstack_alloc (&objfile
->psymbol_obstack
,
2294 sizeof (struct symloc
));
2298 subpst
->texthigh
= 0;
2300 /* We could save slight bits of space by only making one of these,
2301 shared by the entire set of include files. FIXME-someday. */
2302 subpst
->dependencies
= (struct partial_symtab
**)
2303 obstack_alloc (&objfile
->psymbol_obstack
,
2304 sizeof (struct partial_symtab
*));
2305 subpst
->dependencies
[0] = pst
;
2306 subpst
->number_of_dependencies
= 1;
2308 subpst
->globals_offset
=
2309 subpst
->n_global_syms
=
2310 subpst
->statics_offset
=
2311 subpst
->n_static_syms
= 0;
2315 subpst
->read_symtab
= pst
->read_symtab
;
2318 sort_pst_symbols (pst
);
2320 /* If there is already a psymtab or symtab for a file of this name, remove it.
2321 (If there is a symtab, more drastic things also happen.)
2322 This happens in VxWorks. */
2323 free_named_symtabs (pst
->filename
);
2325 if (num_includes
== 0
2326 && number_dependencies
== 0
2327 && pst
->n_global_syms
== 0
2328 && pst
->n_static_syms
== 0)
2330 /* Throw away this psymtab, it's empty. We can't deallocate it, since
2331 it is on the obstack, but we can forget to chain it on the list.
2332 Empty psymtabs happen as a result of header files which don't have
2333 any symbols in them. There can be a lot of them. But this check
2334 is wrong, in that a psymtab with N_SLINE entries but nothing else
2335 is not empty, but we don't realize that. Fixing that without slowing
2336 things down might be tricky.
2337 It's also wrong if we're using the quick look-up tables, as
2338 we can get empty psymtabs from modules with no routines in
2341 discard_psymtab (pst
);
2343 /* Indicate that psymtab was thrown away. */
2344 pst
= (struct partial_symtab
*) NULL
;
2351 /* End of hp-psymtab-read.c */
2353 /* Set indentation to 4 spaces for Emacs; this file is
2354 mostly non-GNU-ish in its style :-( */
2357 ***c
- basic
- offset
:4