1 /* Read hp debug symbols and convert to internal format, for GDB.
2 Copyright 1993, 1996, 1998, 1999, 2000 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
21 Written by the Center for Software Science at the University of Utah
22 and by Cygnus Support. */
24 /* Common include 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 existence of a file, given its full pathname */
75 file_exists (char *filename
)
78 return (access (filename
, F_OK
) == 0);
83 /* Translate from the "hp_language" enumeration in hp-symtab.h
84 used in the debug info to gdb's generic enumeration in defs.h. */
86 trans_lang (enum hp_language in_lang
)
88 if (in_lang
== HP_LANGUAGE_C
)
91 else if (in_lang
== HP_LANGUAGE_CPLUSPLUS
)
92 return language_cplus
;
94 else if (in_lang
== HP_LANGUAGE_FORTRAN
)
95 return language_fortran
;
98 return language_unknown
;
101 static char main_string
[] = "main";
103 /* Call PXDB to process our file.
105 Approach copied from DDE's "dbgk_run_pxdb". Note: we
106 don't check for BSD location of pxdb, nor for existence
109 NOTE: uses system function and string functions directly.
111 Return value: 1 if ok, 0 if not */
113 hpread_call_pxdb (char *file_name
)
119 if (file_exists (PXDB_SVR4
))
121 p
= xmalloc (strlen (PXDB_SVR4
) + strlen (file_name
) + 2);
122 strcpy (p
, PXDB_SVR4
);
124 strcat (p
, file_name
);
126 warning ("File not processed by pxdb--about to process now.\n");
129 retval
= (status
== 0);
133 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
);
138 } /* hpread_call_pxdb */
141 /* Return 1 if the file turns out to need pre-processing
142 by PXDB, and we have thus called PXDB to do this processing
143 and the file therefore needs to be re-loaded. Otherwise
146 hpread_pxdb_needed (bfd
*sym_bfd
)
148 asection
*pinfo_section
, *debug_section
, *header_section
;
149 unsigned int do_pxdb
;
151 bfd_size_type header_section_size
;
156 header_section
= bfd_get_section_by_name (sym_bfd
, "$HEADER$");
159 return 0; /* No header at all, can't recover... */
162 debug_section
= bfd_get_section_by_name (sym_bfd
, "$DEBUG$");
163 pinfo_section
= bfd_get_section_by_name (sym_bfd
, "$PINFO$");
165 if (pinfo_section
&& !debug_section
)
167 /* Debug info with DOC, has different header format.
168 this only happens if the file was pxdbed and compiled optimized
169 otherwise the PINFO section is not there. */
170 header_section_size
= bfd_section_size (objfile
->obfd
, header_section
);
172 if (header_section_size
== (bfd_size_type
) sizeof (DOC_info_PXDB_header
))
174 buf
= alloca (sizeof (DOC_info_PXDB_header
));
176 if (!bfd_get_section_contents (sym_bfd
,
179 header_section_size
))
180 error ("bfd_get_section_contents\n");
182 tmp
= bfd_get_32 (sym_bfd
, (bfd_byte
*) (buf
+ sizeof (int) * 4));
183 pxdbed
= (tmp
>> 31) & 0x1;
186 error ("file debug header info invalid\n");
191 error ("invalid $HEADER$ size in executable \n");
197 /* this can be three different cases:
198 1. pxdbed and not doc
199 - DEBUG and HEADER sections are there
200 - header is PXDB_header type
201 - pxdbed flag is set to 1
203 2. not pxdbed and doc
204 - DEBUG and HEADER sections are there
205 - header is DOC_info_header type
206 - pxdbed flag is set to 0
208 3. not pxdbed and not doc
209 - DEBUG and HEADER sections are there
210 - header is XDB_header type
211 - pxdbed flag is set to 0
213 NOTE: the pxdbed flag is meaningful also in the not
214 already pxdb processed version of the header,
215 because in case on non-already processed by pxdb files
216 that same bit in the header would be always zero.
217 Why? Because the bit is the leftmost bit of a word
218 which contains a 'length' which is always a positive value
219 so that bit is never set to 1 (otherwise it would be negative)
221 Given the above, we have two choices : either we ignore the
222 size of the header itself and just look at the pxdbed field,
223 or we check the size and then we (for safety and paranoia related
224 issues) check the bit.
225 The first solution is used by DDE, the second by PXDB itself.
226 I am using the second one here, because I already wrote it,
227 and it is the end of a long day.
228 Also, using the first approach would still involve size issues
229 because we need to read in the contents of the header section, and
230 give the correct amount of stuff we want to read to the
231 get_bfd_section_contents function. */
233 /* decide which case depending on the size of the header section.
234 The size is as defined in hp-symtab.h */
236 header_section_size
= bfd_section_size (objfile
->obfd
, header_section
);
238 if (header_section_size
== (bfd_size_type
) sizeof (PXDB_header
)) /* pxdb and not doc */
241 buf
= alloca (sizeof (PXDB_header
));
242 if (!bfd_get_section_contents (sym_bfd
,
245 header_section_size
))
246 error ("bfd_get_section_contents\n");
248 tmp
= bfd_get_32 (sym_bfd
, (bfd_byte
*) (buf
+ sizeof (int) * 3));
249 pxdbed
= (tmp
>> 31) & 0x1;
254 error ("file debug header invalid\n");
256 else /*not pxdbed and doc OR not pxdbed and non doc */
268 } /* hpread_pxdb_needed */
272 /* Check whether the file needs to be preprocessed by pxdb.
276 do_pxdb (bfd
*sym_bfd
)
278 /* The following code is HP-specific. The "right" way of
279 doing this is unknown, but we bet would involve a target-
280 specific pre-file-load check using a generic mechanism. */
282 /* This code will not be executed if the file is not in SOM
283 format (i.e. if compiled with gcc) */
284 if (hpread_pxdb_needed (sym_bfd
))
286 /*This file has not been pre-processed. Preprocess now */
288 if (hpread_call_pxdb (sym_bfd
->filename
))
290 /* The call above has changed the on-disk file,
291 we can close the file anyway, because the
292 symbols will be reread in when the target is run */
302 /* Code to handle quick lookup-tables follows. */
305 /* Some useful macros */
306 #define VALID_FILE(i) ((i) < pxdb_header_p->fd_entries)
307 #define VALID_MODULE(i) ((i) < pxdb_header_p->md_entries)
308 #define VALID_PROC(i) ((i) < pxdb_header_p->pd_entries)
309 #define VALID_CLASS(i) ((i) < pxdb_header_p->cd_entries)
311 #define FILE_START(i) (qFD[i].adrStart)
312 #define MODULE_START(i) (qMD[i].adrStart)
313 #define PROC_START(i) (qPD[i].adrStart)
315 #define FILE_END(i) (qFD[i].adrEnd)
316 #define MODULE_END(i) (qMD[i].adrEnd)
317 #define PROC_END(i) (qPD[i].adrEnd)
319 #define FILE_ISYM(i) (qFD[i].isym)
320 #define MODULE_ISYM(i) (qMD[i].isym)
321 #define PROC_ISYM(i) (qPD[i].isym)
323 #define VALID_CURR_FILE (curr_fd < pxdb_header_p->fd_entries)
324 #define VALID_CURR_MODULE (curr_md < pxdb_header_p->md_entries)
325 #define VALID_CURR_PROC (curr_pd < pxdb_header_p->pd_entries)
326 #define VALID_CURR_CLASS (curr_cd < pxdb_header_p->cd_entries)
328 #define CURR_FILE_START (qFD[curr_fd].adrStart)
329 #define CURR_MODULE_START (qMD[curr_md].adrStart)
330 #define CURR_PROC_START (qPD[curr_pd].adrStart)
332 #define CURR_FILE_END (qFD[curr_fd].adrEnd)
333 #define CURR_MODULE_END (qMD[curr_md].adrEnd)
334 #define CURR_PROC_END (qPD[curr_pd].adrEnd)
336 #define CURR_FILE_ISYM (qFD[curr_fd].isym)
337 #define CURR_MODULE_ISYM (qMD[curr_md].isym)
338 #define CURR_PROC_ISYM (qPD[curr_pd].isym)
340 #define TELL_OBJFILE \
342 if( !told_objfile ) { \
344 warning ("\nIn object file \"%s\":\n", \
351 /* Keeping track of the start/end symbol table (LNTT) indices of
352 psymtabs created so far */
361 static pst_syms_struct
*pst_syms_array
= 0;
363 static pst_syms_count
= 0;
364 static pst_syms_size
= 0;
366 /* used by the TELL_OBJFILE macro */
367 static boolean told_objfile
= 0;
369 /* Set up psymtab symbol index stuff */
375 pst_syms_array
= (pst_syms_struct
*) xmalloc (20 * sizeof (pst_syms_struct
));
378 /* Clean up psymtab symbol index stuff */
380 clear_pst_syms (void)
384 xfree (pst_syms_array
);
388 /* Add information about latest psymtab to symbol index table */
390 record_pst_syms (int start_sym
, int end_sym
)
392 if (++pst_syms_count
> pst_syms_size
)
394 pst_syms_array
= (pst_syms_struct
*) xrealloc (pst_syms_array
,
395 2 * pst_syms_size
* sizeof (pst_syms_struct
));
398 pst_syms_array
[pst_syms_count
- 1].start
= start_sym
;
399 pst_syms_array
[pst_syms_count
- 1].end
= end_sym
;
402 /* Find a suitable symbol table index which can serve as the upper
403 bound of a psymtab that starts at INDEX
405 This scans backwards in the psymtab symbol index table to find a
406 "hole" in which the given index can fit. This is a heuristic!!
407 We don't search the entire table to check for multiple holes,
408 we don't care about overlaps, etc.
410 Return 0 => not found */
412 find_next_pst_start (int index
)
416 for (i
= pst_syms_count
- 1; i
>= 0; i
--)
417 if (pst_syms_array
[i
].end
<= index
)
418 return (i
== pst_syms_count
- 1) ? 0 : pst_syms_array
[i
+ 1].start
- 1;
420 if (pst_syms_array
[0].start
> index
)
421 return pst_syms_array
[0].start
- 1;
428 /* Utility functions to find the ending symbol index for a psymtab */
430 /* Find the next file entry that begins beyond INDEX, and return
431 its starting symbol index - 1.
432 QFD is the file table, CURR_FD is the file entry from where to start,
433 PXDB_HEADER_P as in hpread_quick_traverse (to allow macros to work).
435 Return 0 => not found */
437 find_next_file_isym (int index
, quick_file_entry
*qFD
, int curr_fd
,
438 PXDB_header_ptr pxdb_header_p
)
440 while (VALID_CURR_FILE
)
442 if (CURR_FILE_ISYM
>= index
)
443 return CURR_FILE_ISYM
- 1;
449 /* Find the next procedure entry that begins beyond INDEX, and return
450 its starting symbol index - 1.
451 QPD is the procedure table, CURR_PD is the proc entry from where to start,
452 PXDB_HEADER_P as in hpread_quick_traverse (to allow macros to work).
454 Return 0 => not found */
456 find_next_proc_isym (int index
, quick_procedure_entry
*qPD
, int curr_pd
,
457 PXDB_header_ptr pxdb_header_p
)
459 while (VALID_CURR_PROC
)
461 if (CURR_PROC_ISYM
>= index
)
462 return CURR_PROC_ISYM
- 1;
468 /* Find the next module entry that begins beyond INDEX, and return
469 its starting symbol index - 1.
470 QMD is the module table, CURR_MD is the modue entry from where to start,
471 PXDB_HEADER_P as in hpread_quick_traverse (to allow macros to work).
473 Return 0 => not found */
475 find_next_module_isym (int index
, quick_module_entry
*qMD
, int curr_md
,
476 PXDB_header_ptr pxdb_header_p
)
478 while (VALID_CURR_MODULE
)
480 if (CURR_MODULE_ISYM
>= index
)
481 return CURR_MODULE_ISYM
- 1;
487 /* Scan and record partial symbols for all functions starting from index
488 pointed to by CURR_PD_P, and between code addresses START_ADR and END_ADR.
489 Other parameters are explained in comments below. */
491 /* This used to be inline in hpread_quick_traverse, but now that we do
492 essentially the same thing for two different cases (modules and
493 module-less files), it's better organized in a separate routine,
494 although it does take lots of arguments. pai/1997-10-08
496 CURR_PD_P is the pointer to the current proc index. QPD is the
497 procedure quick lookup table. MAX_PROCS is the number of entries
498 in the proc. table. START_ADR is the beginning of the code range
499 for the current psymtab. end_adr is the end of the code range for
500 the current psymtab. PST is the current psymtab. VT_bits is
501 a pointer to the strings table of SOM debug space. OBJFILE is
502 the current object file. */
505 scan_procs (int *curr_pd_p
, quick_procedure_entry
*qPD
, int max_procs
,
506 CORE_ADDR start_adr
, CORE_ADDR end_adr
, struct partial_symtab
*pst
,
507 char *vt_bits
, struct objfile
*objfile
)
509 union dnttentry
*dn_bufp
;
510 int symbol_count
= 0; /* Total number of symbols in this psymtab */
511 int curr_pd
= *curr_pd_p
; /* Convenience variable -- avoid dereferencing pointer all the time */
514 /* Turn this on for lots of debugging information in this routine */
515 static int dumping
= 0;
521 printf ("Scan_procs called, addresses %x to %x, proc %x\n", start_adr
, end_adr
, curr_pd
);
525 while ((CURR_PROC_START
<= end_adr
) && (curr_pd
< max_procs
))
528 char *rtn_name
; /* mangled name */
529 char *rtn_dem_name
; /* qualified demangled name */
533 if ((trans_lang ((enum hp_language
) qPD
[curr_pd
].language
) == language_cplus
) &&
534 vt_bits
[(long) qPD
[curr_pd
].sbAlias
]) /* not a null string */
536 /* Get mangled name for the procedure, and demangle it */
537 rtn_name
= &vt_bits
[(long) qPD
[curr_pd
].sbAlias
];
538 rtn_dem_name
= cplus_demangle (rtn_name
, DMGL_ANSI
| DMGL_PARAMS
);
542 rtn_name
= &vt_bits
[(long) qPD
[curr_pd
].sbProc
];
546 /* Hack to get around HP C/C++ compilers' insistence on providing
547 "_MAIN_" as an alternate name for "main" */
548 if ((strcmp (rtn_name
, "_MAIN_") == 0) &&
549 (strcmp (&vt_bits
[(long) qPD
[curr_pd
].sbProc
], "main") == 0))
550 rtn_dem_name
= rtn_name
= main_string
;
555 printf ("..add %s (demangled %s), index %x to this psymtab\n", rtn_name
, rtn_dem_name
, curr_pd
);
559 /* Check for module-spanning routines. */
560 if (CURR_PROC_END
> end_adr
)
563 warning ("Procedure \"%s\" [0x%x] spans file or module boundaries.", rtn_name
, curr_pd
);
566 /* Add this routine symbol to the list in the objfile.
567 Unfortunately we have to go to the LNTT to determine the
568 correct list to put it on. An alternative (which the
569 code used to do) would be to not check and always throw
570 it on the "static" list. But if we go that route, then
571 symbol_lookup() needs to be tweaked a bit to account
572 for the fact that the function might not be found on
573 the correct list in the psymtab. - RT */
574 dn_bufp
= hpread_get_lntt (qPD
[curr_pd
].isym
, objfile
);
575 if (dn_bufp
->dfunc
.global
)
576 add_psymbol_with_dem_name_to_list (rtn_name
,
579 strlen (rtn_dem_name
),
581 LOC_BLOCK
, /* "I am a routine" */
582 &objfile
->global_psymbols
,
583 (qPD
[curr_pd
].adrStart
+ /* Starting address of rtn */
584 ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT (objfile
))),
586 trans_lang ((enum hp_language
) qPD
[curr_pd
].language
),
589 add_psymbol_with_dem_name_to_list (rtn_name
,
592 strlen (rtn_dem_name
),
594 LOC_BLOCK
, /* "I am a routine" */
595 &objfile
->static_psymbols
,
596 (qPD
[curr_pd
].adrStart
+ /* Starting address of rtn */
597 ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT (objfile
))),
599 trans_lang ((enum hp_language
) qPD
[curr_pd
].language
),
603 *curr_pd_p
= ++curr_pd
; /* bump up count & reflect in caller */
604 } /* loop over procedures */
609 if (symbol_count
== 0)
610 printf ("Scan_procs: no symbols found!\n");
618 /* Traverse the quick look-up tables, building a set of psymtabs.
620 This constructs a psymtab for modules and files in the quick lookup
623 Mostly, modules correspond to compilation units, so we try to
624 create psymtabs that correspond to modules; however, in some cases
625 a file can result in a compiled object which does not have a module
626 entry for it, so in such cases we create a psymtab for the file. */
629 hpread_quick_traverse (struct objfile
*objfile
, char *gntt_bits
,
630 char *vt_bits
, PXDB_header_ptr pxdb_header_p
)
632 struct partial_symtab
*pst
;
636 quick_procedure_entry
*qPD
;
637 quick_file_entry
*qFD
;
638 quick_module_entry
*qMD
;
639 quick_class_entry
*qCD
;
643 CORE_ADDR start_adr
; /* current psymtab's starting code addr */
644 CORE_ADDR end_adr
; /* current psymtab's ending code addr */
645 CORE_ADDR next_mod_adr
; /* next module's starting code addr */
646 int curr_pd
; /* current procedure */
647 int curr_fd
; /* current file */
648 int curr_md
; /* current module */
649 int start_sym
; /* current psymtab's starting symbol index */
650 int end_sym
; /* current psymtab's ending symbol index */
651 int max_LNTT_sym_index
;
653 B_TYPE
*class_entered
;
655 struct partial_symbol
**global_syms
; /* We'll be filling in the "global" */
656 struct partial_symbol
**static_syms
; /* and "static" tables in the objfile
657 as we go, so we need a pair of
661 /* Turn this on for lots of debugging information in this routine.
662 You get a blow-by-blow account of quick lookup table reading */
663 static int dumping
= 0;
666 pst
= (struct partial_symtab
*) 0;
668 /* Clear out some globals */
672 /* Demangling style -- if EDG style already set, don't change it,
673 as HP style causes some problems with the KAI EDG compiler */
674 if (current_demangling_style
!= edg_demangling
)
676 /* Otherwise, ensure that we are using HP style demangling */
677 set_demangling_style (HP_DEMANGLING_STYLE_STRING
);
680 /* First we need to find the starting points of the quick
681 look-up tables in the GNTT. */
685 qPD
= (quick_procedure_entry_ptr
) addr
;
686 addr
+= pxdb_header_p
->pd_entries
* sizeof (quick_procedure_entry
);
691 printf ("\n Printing routines as we see them\n");
692 for (i
= 0; VALID_PROC (i
); i
++)
694 idx
= (long) qPD
[i
].sbProc
;
695 printf ("%s %x..%x\n", &vt_bits
[idx
],
696 (int) PROC_START (i
),
702 qFD
= (quick_file_entry_ptr
) addr
;
703 addr
+= pxdb_header_p
->fd_entries
* sizeof (quick_file_entry
);
708 printf ("\n Printing files as we see them\n");
709 for (i
= 0; VALID_FILE (i
); i
++)
711 idx
= (long) qFD
[i
].sbFile
;
712 printf ("%s %x..%x\n", &vt_bits
[idx
],
713 (int) FILE_START (i
),
719 qMD
= (quick_module_entry_ptr
) addr
;
720 addr
+= pxdb_header_p
->md_entries
* sizeof (quick_module_entry
);
725 printf ("\n Printing modules as we see them\n");
726 for (i
= 0; i
< pxdb_header_p
->md_entries
; i
++)
728 idx
= (long) qMD
[i
].sbMod
;
729 printf ("%s\n", &vt_bits
[idx
]);
734 qCD
= (quick_class_entry_ptr
) addr
;
735 addr
+= pxdb_header_p
->cd_entries
* sizeof (quick_class_entry
);
740 printf ("\n Printing classes as we see them\n");
741 for (i
= 0; VALID_CLASS (i
); i
++)
743 idx
= (long) qCD
[i
].sbClass
;
744 printf ("%s\n", &vt_bits
[idx
]);
747 printf ("\n Done with dump, on to build!\n");
751 /* We need this index only while hp-symtab-read.c expects
752 a byte offset to the end of the LNTT entries for a given
753 psymtab. Thus the need for it should go away someday.
755 When it goes away, then we won't have any need to load the
756 LNTT from the objfile at psymtab-time, and start-up will be
757 faster. To make that work, we'll need some way to create
758 a null pst for the "globals" pseudo-module. */
759 max_LNTT_sym_index
= LNTT_SYMCOUNT (objfile
);
761 /* Scan the module descriptors and make a psymtab for each.
763 We know the MDs, FDs and the PDs are in order by starting
764 address. We use that fact to traverse all three arrays in
765 parallel, knowing when the next PD is in a new file
766 and we need to create a new psymtab. */
767 curr_pd
= 0; /* Current procedure entry */
768 curr_fd
= 0; /* Current file entry */
769 curr_md
= 0; /* Current module entry */
771 start_adr
= 0; /* Current psymtab code range */
774 start_sym
= 0; /* Current psymtab symbol range */
777 syms_in_pst
= 0; /* Symbol count for psymtab */
779 /* Psts actually just have pointers into the objfile's
780 symbol table, not their own symbol tables. */
781 global_syms
= objfile
->global_psymbols
.list
;
782 static_syms
= objfile
->static_psymbols
.list
;
785 /* First skip over pseudo-entries with address 0. These represent inlined
786 routines and abstract (uninstantiated) template routines.
787 FIXME: These should be read in and available -- even if we can't set
788 breakpoints, etc., there's some information that can be presented
789 to the user. pai/1997-10-08 */
791 while (VALID_CURR_PROC
&& (CURR_PROC_START
== 0))
794 /* Loop over files, modules, and procedures in code address order. Each
795 time we enter an iteration of this loop, curr_pd points to the first
796 unprocessed procedure, curr_fd points to the first unprocessed file, and
797 curr_md to the first unprocessed module. Each iteration of this loop
798 updates these as required -- any or all of them may be bumpd up
799 each time around. When we exit this loop, we are done with all files
800 and modules in the tables -- there may still be some procedures, however.
802 Note: This code used to loop only over module entries, under the assumption
803 that files can occur via inclusions and are thus unreliable, while a
804 compiled object always corresponds to a module. With CTTI in the HP aCC
805 compiler, it turns out that compiled objects may have only files and no
806 modules; so we have to loop over files and modules, creating psymtabs for
807 either as appropriate. Unfortunately there are some problems (notably:
808 1. the lack of "SRC_FILE_END" entries in the LNTT, 2. the lack of pointers
809 to the ending symbol indices of a module or a file) which make it quite hard
810 to do this correctly. Currently it uses a bunch of heuristics to start and
811 end psymtabs; they seem to work well with most objects generated by aCC, but
812 who knows when that will change... */
814 while (VALID_CURR_FILE
|| VALID_CURR_MODULE
)
817 char *mod_name_string
;
818 char *full_name_string
;
820 /* First check for modules like "version.c", which have no code
821 in them but still have qMD entries. They also have no qFD or
822 qPD entries. Their start address is -1 and their end address
824 if (VALID_CURR_MODULE
&& (CURR_MODULE_START
== -1) && (CURR_MODULE_END
== 0))
827 mod_name_string
= &vt_bits
[(long) qMD
[curr_md
].sbMod
];
831 printf ("Module with data only %s\n", mod_name_string
);
834 /* We'll skip the rest (it makes error-checking easier), and
835 just make an empty pst. Right now empty psts are not put
836 in the pst chain, so all this is for naught, but later it
839 pst
= hpread_start_psymtab (objfile
,
841 CURR_MODULE_START
, /* Low text address: bogus! */
842 (CURR_MODULE_ISYM
* sizeof (struct dntt_type_block
)),
847 pst
= hpread_end_psymtab (pst
,
848 NULL
, /* psymtab_include_list */
849 0, /* includes_used */
850 end_sym
* sizeof (struct dntt_type_block
),
851 /* byte index in LNTT of end
852 = capping symbol offset
853 = LDSYMOFF of nextfile */
855 NULL
, /* dependency_list */
856 0); /* dependencies_used */
858 global_syms
= objfile
->global_psymbols
.next
;
859 static_syms
= objfile
->static_psymbols
.next
;
863 else if (VALID_CURR_MODULE
&&
864 ((CURR_MODULE_START
== 0) || (CURR_MODULE_START
== -1) ||
865 (CURR_MODULE_END
== 0) || (CURR_MODULE_END
== -1)))
868 warning ("Module \"%s\" [0x%x] has non-standard addresses. It starts at 0x%x, ends at 0x%x, and will be skipped.",
869 mod_name_string
, curr_md
, start_adr
, end_adr
);
870 /* On to next module */
875 /* First check if we are looking at a file with code in it
876 that does not overlap the current module's code range */
878 if (VALID_CURR_FILE
? (VALID_CURR_MODULE
? (CURR_FILE_END
< CURR_MODULE_START
) : 1) : 0)
881 /* Looking at file not corresponding to any module,
882 create a psymtab for it */
883 full_name_string
= &vt_bits
[(long) qFD
[curr_fd
].sbFile
];
884 start_adr
= CURR_FILE_START
;
885 end_adr
= CURR_FILE_END
;
886 start_sym
= CURR_FILE_ISYM
;
888 /* Check if there are any procedures not handled until now, that
889 begin before the start address of this file, and if so, adjust
890 this module's start address to include them. This handles routines that
891 are in between file or module ranges for some reason (probably
892 indicates a compiler bug */
894 if (CURR_PROC_START
< start_adr
)
897 warning ("Found procedure \"%s\" [0x%x] that is not in any file or module.",
898 &vt_bits
[(long) qPD
[curr_pd
].sbProc
], curr_pd
);
899 start_adr
= CURR_PROC_START
;
900 if (CURR_PROC_ISYM
< start_sym
)
901 start_sym
= CURR_PROC_ISYM
;
904 /* Sometimes (compiler bug -- COBOL) the module end address is higher
905 than the start address of the next module, so check for that and
906 adjust accordingly */
908 if (VALID_FILE (curr_fd
+ 1) && (FILE_START (curr_fd
+ 1) <= end_adr
))
911 warning ("File \"%s\" [0x%x] has ending address after starting address of next file; adjusting ending address down.",
912 full_name_string
, curr_fd
);
913 end_adr
= FILE_START (curr_fd
+ 1) - 1; /* Is -4 (or -8 for 64-bit) better? */
915 if (VALID_MODULE (curr_md
) && (CURR_MODULE_START
<= end_adr
))
918 warning ("File \"%s\" [0x%x] has ending address after starting address of next module; adjusting ending address down.",
919 full_name_string
, curr_fd
);
920 end_adr
= CURR_MODULE_START
- 1; /* Is -4 (or -8 for 64-bit) better? */
927 printf ("Make new psymtab for file %s (%x to %x).\n",
928 full_name_string
, start_adr
, end_adr
);
931 /* Create the basic psymtab, connecting it in the list
932 for this objfile and pointing its symbol entries
933 to the current end of the symbol areas in the objfile.
935 The "ldsymoff" parameter is the byte offset in the LNTT
936 of the first symbol in this file. Some day we should
937 turn this into an index (fix in hp-symtab-read.c as well).
938 And it's not even the right byte offset, as we're using
939 the size of a union! FIXME! */
940 pst
= hpread_start_psymtab (objfile
,
942 start_adr
, /* Low text address */
943 (start_sym
* sizeof (struct dntt_type_block
)),
948 /* Set up to only enter each class referenced in this module once. */
949 class_entered
= xmalloc (B_BYTES (pxdb_header_p
->cd_entries
));
950 B_CLRALL (class_entered
, pxdb_header_p
->cd_entries
);
952 /* Scan the procedure descriptors for procedures in the current
953 file, based on the starting addresses. */
955 syms_in_pst
= scan_procs (&curr_pd
, qPD
, pxdb_header_p
->pd_entries
,
956 start_adr
, end_adr
, pst
, vt_bits
, objfile
);
958 /* Get ending symbol offset */
961 /* First check for starting index before previous psymtab */
962 if (pst_syms_count
&& start_sym
< pst_syms_array
[pst_syms_count
- 1].end
)
964 end_sym
= find_next_pst_start (start_sym
);
966 /* Look for next start index of a file or module, or procedure */
969 int next_file_isym
= find_next_file_isym (start_sym
, qFD
, curr_fd
+ 1, pxdb_header_p
);
970 int next_module_isym
= find_next_module_isym (start_sym
, qMD
, curr_md
, pxdb_header_p
);
971 int next_proc_isym
= find_next_proc_isym (start_sym
, qPD
, curr_pd
, pxdb_header_p
);
973 if (next_file_isym
&& next_module_isym
)
975 /* pick lower of next file or module start index */
976 end_sym
= min (next_file_isym
, next_module_isym
);
980 /* one of them is zero, pick the other */
981 end_sym
= max (next_file_isym
, next_module_isym
);
984 /* As a precaution, check next procedure index too */
986 end_sym
= next_proc_isym
;
988 end_sym
= min (end_sym
, next_proc_isym
);
991 /* Couldn't find procedure, file, or module, use globals as default */
993 end_sym
= pxdb_header_p
->globals
;
998 printf ("File psymtab indices: %x to %x\n", start_sym
, end_sym
);
1002 pst
= hpread_end_psymtab (pst
,
1003 NULL
, /* psymtab_include_list */
1004 0, /* includes_used */
1005 end_sym
* sizeof (struct dntt_type_block
),
1006 /* byte index in LNTT of end
1007 = capping symbol offset
1008 = LDSYMOFF of nextfile */
1009 end_adr
, /* text high */
1010 NULL
, /* dependency_list */
1011 0); /* dependencies_used */
1013 record_pst_syms (start_sym
, end_sym
);
1016 warning ("No symbols in psymtab for file \"%s\" [0x%x].", full_name_string
, curr_fd
);
1021 printf ("Made new psymtab for file %s (%x to %x), sym %x to %x.\n",
1022 full_name_string
, start_adr
, end_adr
, CURR_FILE_ISYM
, end_sym
);
1025 /* Prepare for the next psymtab. */
1026 global_syms
= objfile
->global_psymbols
.next
;
1027 static_syms
= objfile
->static_psymbols
.next
;
1028 xfree (class_entered
);
1031 } /* Psymtab for file */
1034 /* We have a module for which we create a psymtab */
1036 mod_name_string
= &vt_bits
[(long) qMD
[curr_md
].sbMod
];
1038 /* We will include the code ranges of any files that happen to
1039 overlap with this module */
1041 /* So, first pick the lower of the file's and module's start addresses */
1042 start_adr
= CURR_MODULE_START
;
1043 if (VALID_CURR_FILE
)
1045 if (CURR_FILE_START
< CURR_MODULE_START
)
1048 warning ("File \"%s\" [0x%x] crosses beginning of module \"%s\".",
1049 &vt_bits
[(long) qFD
[curr_fd
].sbFile
],
1050 curr_fd
, mod_name_string
);
1052 start_adr
= CURR_FILE_START
;
1056 /* Also pick the lower of the file's and the module's start symbol indices */
1057 start_sym
= CURR_MODULE_ISYM
;
1058 if (VALID_CURR_FILE
&& (CURR_FILE_ISYM
< CURR_MODULE_ISYM
))
1059 start_sym
= CURR_FILE_ISYM
;
1061 /* For the end address, we scan through the files till we find one
1062 that overlaps the current module but ends beyond it; if no such file exists we
1063 simply use the module's start address.
1064 (Note, if file entries themselves overlap
1065 we take the longest overlapping extension beyond the end of the module...)
1066 We assume that modules never overlap. */
1068 end_adr
= CURR_MODULE_END
;
1070 if (VALID_CURR_FILE
)
1072 while (VALID_CURR_FILE
&& (CURR_FILE_START
< end_adr
))
1077 printf ("Maybe skipping file %s which overlaps with module %s\n",
1078 &vt_bits
[(long) qFD
[curr_fd
].sbFile
], mod_name_string
);
1080 if (CURR_FILE_END
> end_adr
)
1083 warning ("File \"%s\" [0x%x] crosses end of module \"%s\".",
1084 &vt_bits
[(long) qFD
[curr_fd
].sbFile
],
1085 curr_fd
, mod_name_string
);
1086 end_adr
= CURR_FILE_END
;
1090 curr_fd
--; /* back up after going too far */
1093 /* Sometimes (compiler bug -- COBOL) the module end address is higher
1094 than the start address of the next module, so check for that and
1095 adjust accordingly */
1097 if (VALID_MODULE (curr_md
+ 1) && (MODULE_START (curr_md
+ 1) <= end_adr
))
1100 warning ("Module \"%s\" [0x%x] has ending address after starting address of next module; adjusting ending address down.",
1101 mod_name_string
, curr_md
);
1102 end_adr
= MODULE_START (curr_md
+ 1) - 1; /* Is -4 (or -8 for 64-bit) better? */
1104 if (VALID_FILE (curr_fd
+ 1) && (FILE_START (curr_fd
+ 1) <= end_adr
))
1107 warning ("Module \"%s\" [0x%x] has ending address after starting address of next file; adjusting ending address down.",
1108 mod_name_string
, curr_md
);
1109 end_adr
= FILE_START (curr_fd
+ 1) - 1; /* Is -4 (or -8 for 64-bit) better? */
1112 /* Use one file to get the full name for the module. This
1113 situation can arise if there is executable code in a #include
1114 file. Each file with code in it gets a qFD. Files which don't
1115 contribute code don't get a qFD, even if they include files
1120 #include "rtn.h" return x;
1123 There will a qFD for "rtn.h",and a qMD for "body.c",
1124 but no qMD for "rtn.h" or qFD for "body.c"!
1126 We pick the name of the last file to overlap with this
1127 module. C convention is to put include files first. In a
1128 perfect world, we could check names and use the file whose full
1129 path name ends with the module name. */
1131 if (VALID_CURR_FILE
)
1132 full_name_string
= &vt_bits
[(long) qFD
[curr_fd
].sbFile
];
1134 full_name_string
= mod_name_string
;
1136 /* Check if there are any procedures not handled until now, that
1137 begin before the start address we have now, and if so, adjust
1138 this psymtab's start address to include them. This handles routines that
1139 are in between file or module ranges for some reason (probably
1140 indicates a compiler bug */
1142 if (CURR_PROC_START
< start_adr
)
1145 warning ("Found procedure \"%s\" [0x%x] that is not in any file or module.",
1146 &vt_bits
[(long) qPD
[curr_pd
].sbProc
], curr_pd
);
1147 start_adr
= CURR_PROC_START
;
1148 if (CURR_PROC_ISYM
< start_sym
)
1149 start_sym
= CURR_PROC_ISYM
;
1155 printf ("Make new psymtab for module %s (%x to %x), using file %s\n",
1156 mod_name_string
, start_adr
, end_adr
, full_name_string
);
1159 /* Create the basic psymtab, connecting it in the list
1160 for this objfile and pointing its symbol entries
1161 to the current end of the symbol areas in the objfile.
1163 The "ldsymoff" parameter is the byte offset in the LNTT
1164 of the first symbol in this file. Some day we should
1165 turn this into an index (fix in hp-symtab-read.c as well).
1166 And it's not even the right byte offset, as we're using
1167 the size of a union! FIXME! */
1168 pst
= hpread_start_psymtab (objfile
,
1170 start_adr
, /* Low text address */
1171 (start_sym
* sizeof (struct dntt_type_block
)),
1176 /* Set up to only enter each class referenced in this module once. */
1177 class_entered
= xmalloc (B_BYTES (pxdb_header_p
->cd_entries
));
1178 B_CLRALL (class_entered
, pxdb_header_p
->cd_entries
);
1180 /* Scan the procedure descriptors for procedures in the current
1181 module, based on the starting addresses. */
1183 syms_in_pst
= scan_procs (&curr_pd
, qPD
, pxdb_header_p
->pd_entries
,
1184 start_adr
, end_adr
, pst
, vt_bits
, objfile
);
1186 /* Get ending symbol offset */
1189 /* First check for starting index before previous psymtab */
1190 if (pst_syms_count
&& start_sym
< pst_syms_array
[pst_syms_count
- 1].end
)
1192 end_sym
= find_next_pst_start (start_sym
);
1194 /* Look for next start index of a file or module, or procedure */
1197 int next_file_isym
= find_next_file_isym (start_sym
, qFD
, curr_fd
+ 1, pxdb_header_p
);
1198 int next_module_isym
= find_next_module_isym (start_sym
, qMD
, curr_md
+ 1, pxdb_header_p
);
1199 int next_proc_isym
= find_next_proc_isym (start_sym
, qPD
, curr_pd
, pxdb_header_p
);
1201 if (next_file_isym
&& next_module_isym
)
1203 /* pick lower of next file or module start index */
1204 end_sym
= min (next_file_isym
, next_module_isym
);
1208 /* one of them is zero, pick the other */
1209 end_sym
= max (next_file_isym
, next_module_isym
);
1212 /* As a precaution, check next procedure index too */
1214 end_sym
= next_proc_isym
;
1216 end_sym
= min (end_sym
, next_proc_isym
);
1219 /* Couldn't find procedure, file, or module, use globals as default */
1221 end_sym
= pxdb_header_p
->globals
;
1226 printf ("Module psymtab indices: %x to %x\n", start_sym
, end_sym
);
1230 pst
= hpread_end_psymtab (pst
,
1231 NULL
, /* psymtab_include_list */
1232 0, /* includes_used */
1233 end_sym
* sizeof (struct dntt_type_block
),
1234 /* byte index in LNTT of end
1235 = capping symbol offset
1236 = LDSYMOFF of nextfile */
1237 end_adr
, /* text high */
1238 NULL
, /* dependency_list */
1239 0); /* dependencies_used */
1241 record_pst_syms (start_sym
, end_sym
);
1244 warning ("No symbols in psymtab for module \"%s\" [0x%x].", mod_name_string
, curr_md
);
1249 printf ("Made new psymtab for module %s (%x to %x), sym %x to %x.\n",
1250 mod_name_string
, start_adr
, end_adr
, CURR_MODULE_ISYM
, end_sym
);
1254 /* Prepare for the next psymtab. */
1255 global_syms
= objfile
->global_psymbols
.next
;
1256 static_syms
= objfile
->static_psymbols
.next
;
1257 xfree (class_entered
);
1261 } /* psymtab for module */
1262 } /* psymtab for non-bogus file or module */
1263 } /* End of while loop over all files & modules */
1265 /* There may be some routines after all files and modules -- these will get
1266 inserted in a separate new module of their own */
1267 if (VALID_CURR_PROC
)
1269 start_adr
= CURR_PROC_START
;
1270 end_adr
= qPD
[pxdb_header_p
->pd_entries
- 1].adrEnd
;
1272 warning ("Found functions beyond end of all files and modules [0x%x].", curr_pd
);
1276 printf ("Orphan functions at end, PD %d and beyond (%x to %x)\n",
1277 curr_pd
, start_adr
, end_adr
);
1280 pst
= hpread_start_psymtab (objfile
,
1282 start_adr
, /* Low text address */
1283 (CURR_PROC_ISYM
* sizeof (struct dntt_type_block
)),
1288 scan_procs (&curr_pd
, qPD
, pxdb_header_p
->pd_entries
,
1289 start_adr
, end_adr
, pst
, vt_bits
, objfile
);
1291 pst
= hpread_end_psymtab (pst
,
1292 NULL
, /* psymtab_include_list */
1293 0, /* includes_used */
1294 pxdb_header_p
->globals
* sizeof (struct dntt_type_block
),
1295 /* byte index in LNTT of end
1296 = capping symbol offset
1297 = LDSYMOFF of nextfile */
1298 end_adr
, /* text high */
1299 NULL
, /* dependency_list */
1300 0); /* dependencies_used */
1305 /* Now build psts for non-module things (in the tail of
1306 the LNTT, after the last END MODULE entry).
1308 If null psts were kept on the chain, this would be
1309 a solution. FIXME */
1310 pst
= hpread_start_psymtab (objfile
,
1313 (pxdb_header_p
->globals
1314 * sizeof (struct dntt_type_block
)),
1315 objfile
->global_psymbols
.next
,
1316 objfile
->static_psymbols
.next
);
1317 hpread_end_psymtab (pst
,
1319 (max_LNTT_sym_index
* sizeof (struct dntt_type_block
)),
1328 } /* End of hpread_quick_traverse. */
1331 /* Get appropriate header, based on pxdb type.
1332 Return value: 1 if ok, 0 if not */
1334 hpread_get_header (struct objfile
*objfile
, PXDB_header_ptr pxdb_header_p
)
1336 asection
*pinfo_section
, *debug_section
, *header_section
;
1339 /* Turn on for debugging information */
1340 static int dumping
= 0;
1343 header_section
= bfd_get_section_by_name (objfile
->obfd
, "$HEADER$");
1344 if (!header_section
)
1346 /* We don't have either PINFO or DEBUG sections. But
1347 stuff like "libc.sl" has no debug info. There's no
1348 need to warn the user of this, as it may be ok. The
1349 caller will figure it out and issue any needed
1353 printf ("==No debug info at all for %s.\n", objfile
->name
);
1359 /* We would like either a $DEBUG$ or $PINFO$ section.
1360 Once we know which, we can understand the header
1361 data (which we have defined to suit the more common
1363 debug_section
= bfd_get_section_by_name (objfile
->obfd
, "$DEBUG$");
1364 pinfo_section
= bfd_get_section_by_name (objfile
->obfd
, "$PINFO$");
1367 /* The expected case: normal pxdb header. */
1368 bfd_get_section_contents (objfile
->obfd
, header_section
,
1369 pxdb_header_p
, 0, sizeof (PXDB_header
));
1371 if (!pxdb_header_p
->pxdbed
)
1373 /* This shouldn't happen if we check in "symfile.c". */
1375 } /* DEBUG section */
1378 else if (pinfo_section
)
1380 /* The DOC case; we need to translate this into a
1382 DOC_info_PXDB_header doc_header
;
1387 printf ("==OOps, PINFO, let's try to handle this, %s.\n", objfile
->name
);
1391 bfd_get_section_contents (objfile
->obfd
,
1394 sizeof (DOC_info_PXDB_header
));
1396 if (!doc_header
.pxdbed
)
1398 /* This shouldn't happen if we check in "symfile.c". */
1399 warning ("File \"%s\" not processed by pxdb!", objfile
->name
);
1403 /* Copy relevent fields to standard header passed in. */
1404 pxdb_header_p
->pd_entries
= doc_header
.pd_entries
;
1405 pxdb_header_p
->fd_entries
= doc_header
.fd_entries
;
1406 pxdb_header_p
->md_entries
= doc_header
.md_entries
;
1407 pxdb_header_p
->pxdbed
= doc_header
.pxdbed
;
1408 pxdb_header_p
->bighdr
= doc_header
.bighdr
;
1409 pxdb_header_p
->sa_header
= doc_header
.sa_header
;
1410 pxdb_header_p
->inlined
= doc_header
.inlined
;
1411 pxdb_header_p
->globals
= doc_header
.globals
;
1412 pxdb_header_p
->time
= doc_header
.time
;
1413 pxdb_header_p
->pg_entries
= doc_header
.pg_entries
;
1414 pxdb_header_p
->functions
= doc_header
.functions
;
1415 pxdb_header_p
->files
= doc_header
.files
;
1416 pxdb_header_p
->cd_entries
= doc_header
.cd_entries
;
1417 pxdb_header_p
->aa_entries
= doc_header
.aa_entries
;
1418 pxdb_header_p
->oi_entries
= doc_header
.oi_entries
;
1419 pxdb_header_p
->version
= doc_header
.version
;
1420 } /* PINFO section */
1426 printf ("==No debug info at all for %s.\n", objfile
->name
);
1434 } /* End of hpread_get_header */
1435 #endif /* QUICK_LOOK_UP */
1438 /* Initialization for reading native HP C debug symbols from OBJFILE.
1440 Its only purpose in life is to set up the symbol reader's private
1441 per-objfile data structures, and read in the raw contents of the debug
1442 sections (attaching pointers to the debug info into the private data
1445 Since BFD doesn't know how to read debug symbols in a format-independent
1446 way (and may never do so...), we have to do it ourselves. Note we may
1447 be called on a file without native HP C debugging symbols.
1449 FIXME, there should be a cleaner peephole into the BFD environment
1452 hpread_symfile_init (struct objfile
*objfile
)
1454 asection
*vt_section
, *slt_section
, *lntt_section
, *gntt_section
;
1456 /* Allocate struct to keep track of the symfile */
1457 objfile
->sym_private
= (PTR
)
1458 xmmalloc (objfile
->md
, sizeof (struct hpread_symfile_info
));
1459 memset (objfile
->sym_private
, 0, sizeof (struct hpread_symfile_info
));
1461 /* We haven't read in any types yet. */
1462 TYPE_VECTOR (objfile
) = 0;
1464 /* Read in data from the $GNTT$ subspace. */
1465 gntt_section
= bfd_get_section_by_name (objfile
->obfd
, "$GNTT$");
1470 = obstack_alloc (&objfile
->symbol_obstack
,
1471 bfd_section_size (objfile
->obfd
, gntt_section
));
1473 bfd_get_section_contents (objfile
->obfd
, gntt_section
, GNTT (objfile
),
1474 0, bfd_section_size (objfile
->obfd
, gntt_section
));
1476 GNTT_SYMCOUNT (objfile
)
1477 = bfd_section_size (objfile
->obfd
, gntt_section
)
1478 / sizeof (struct dntt_type_block
);
1480 /* Read in data from the $LNTT$ subspace. Also keep track of the number
1483 FIXME: this could be moved into the psymtab-to-symtab expansion
1484 code, and save startup time. At the moment this data is
1485 still used, though. We'd need a way to tell hp-symtab-read.c
1486 whether or not to load the LNTT. */
1487 lntt_section
= bfd_get_section_by_name (objfile
->obfd
, "$LNTT$");
1492 = obstack_alloc (&objfile
->symbol_obstack
,
1493 bfd_section_size (objfile
->obfd
, lntt_section
));
1495 bfd_get_section_contents (objfile
->obfd
, lntt_section
, LNTT (objfile
),
1496 0, bfd_section_size (objfile
->obfd
, lntt_section
));
1498 LNTT_SYMCOUNT (objfile
)
1499 = bfd_section_size (objfile
->obfd
, lntt_section
)
1500 / sizeof (struct dntt_type_block
);
1502 /* Read in data from the $SLT$ subspace. $SLT$ contains information
1503 on source line numbers. */
1504 slt_section
= bfd_get_section_by_name (objfile
->obfd
, "$SLT$");
1509 obstack_alloc (&objfile
->symbol_obstack
,
1510 bfd_section_size (objfile
->obfd
, slt_section
));
1512 bfd_get_section_contents (objfile
->obfd
, slt_section
, SLT (objfile
),
1513 0, bfd_section_size (objfile
->obfd
, slt_section
));
1515 /* Read in data from the $VT$ subspace. $VT$ contains things like
1516 names and constants. Keep track of the number of symbols in the VT. */
1517 vt_section
= bfd_get_section_by_name (objfile
->obfd
, "$VT$");
1521 VT_SIZE (objfile
) = bfd_section_size (objfile
->obfd
, vt_section
);
1524 (char *) obstack_alloc (&objfile
->symbol_obstack
,
1527 bfd_get_section_contents (objfile
->obfd
, vt_section
, VT (objfile
),
1528 0, VT_SIZE (objfile
));
1531 /* Scan and build partial symbols for a symbol file.
1533 The minimal symbol table (either SOM or HP a.out) has already been
1534 read in; all we need to do is setup partial symbols based on the
1535 native debugging information.
1537 Note that the minimal table is produced by the linker, and has
1538 only global routines in it; the psymtab is based on compiler-
1539 generated debug information and has non-global
1540 routines in it as well as files and class information.
1542 We assume hpread_symfile_init has been called to initialize the
1543 symbol reader's private data structures.
1545 MAINLINE is true if we are reading the main symbol table (as
1546 opposed to a shared lib or dynamically loaded file). */
1549 hpread_build_psymtabs (struct objfile
*objfile
, int mainline
)
1553 /* Turn this on to get debugging output. */
1554 static int dumping
= 0;
1558 int past_first_source_file
= 0;
1559 struct cleanup
*old_chain
;
1561 int hp_symnum
, symcount
, i
;
1564 union dnttentry
*dn_bufp
;
1570 /* Current partial symtab */
1571 struct partial_symtab
*pst
;
1573 /* List of current psymtab's include files */
1574 char **psymtab_include_list
;
1575 int includes_allocated
;
1578 /* Index within current psymtab dependency list */
1579 struct partial_symtab
**dependency_list
;
1580 int dependencies_used
, dependencies_allocated
;
1582 /* Just in case the stabs reader left turds lying around. */
1583 free_pending_blocks ();
1584 make_cleanup (really_free_pendings
, 0);
1586 pst
= (struct partial_symtab
*) 0;
1588 /* We shouldn't use alloca, instead use malloc/free. Doing so avoids
1589 a number of problems with cross compilation and creating useless holes
1590 in the stack when we have to allocate new entries. FIXME. */
1592 includes_allocated
= 30;
1594 psymtab_include_list
= (char **) alloca (includes_allocated
*
1597 dependencies_allocated
= 30;
1598 dependencies_used
= 0;
1600 (struct partial_symtab
**) alloca (dependencies_allocated
*
1601 sizeof (struct partial_symtab
*));
1603 old_chain
= make_cleanup_free_objfile (objfile
);
1605 last_source_file
= 0;
1607 #ifdef QUICK_LOOK_UP
1609 /* Begin code for new-style loading of quick look-up tables. */
1611 /* elz: this checks whether the file has beeen processed by pxdb.
1612 If not we would like to try to read the psymbols in
1613 anyway, but it turns out to be not so easy. So this could
1614 actually be commented out, but I leave it in, just in case
1615 we decide to add support for non-pxdb-ed stuff in the future. */
1616 PXDB_header pxdb_header
;
1617 int found_modules_in_program
;
1619 if (hpread_get_header (objfile
, &pxdb_header
))
1621 /* Build a minimal table. No types, no global variables,
1622 no include files.... */
1625 printf ("\nNew method for %s\n", objfile
->name
);
1628 /* elz: quick_traverse returns true if it found
1629 some modules in the main source file, other
1631 In C and C++, all the files have MODULES entries
1632 in the LNTT, and the quick table traverse is all
1633 based on finding these MODULES entries. Without
1634 those it cannot work.
1635 It happens that F77 programs don't have MODULES
1636 so the quick traverse gets confused. F90 programs
1637 have modules, and the quick method still works.
1638 So, if modules (other than those in end.c) are
1639 not found we give up on the quick table stuff,
1640 and fall back on the slower method */
1641 found_modules_in_program
= hpread_quick_traverse (objfile
,
1646 discard_cleanups (old_chain
);
1648 /* Set up to scan the global section of the LNTT.
1650 This field is not always correct: if there are
1651 no globals, it will point to the last record in
1652 the regular LNTT, which is usually an END MODULE.
1654 Since it might happen that there could be a file
1655 with just one global record, there's no way to
1656 tell other than by looking at the record, so that's
1658 if (found_modules_in_program
)
1659 scan_start
= pxdb_header
.globals
;
1665 printf ("\nGoing on to old method for %s\n", objfile
->name
);
1669 #endif /* QUICK_LOOK_UP */
1671 /* Make two passes, one over the GNTT symbols, the other for the
1674 JB comment: above isn't true--they only make one pass, over
1676 for (i
= 0; i
< 1; i
++)
1678 int within_function
= 0;
1681 symcount
= GNTT_SYMCOUNT (objfile
);
1683 symcount
= LNTT_SYMCOUNT (objfile
);
1686 for (hp_symnum
= scan_start
; hp_symnum
< symcount
; hp_symnum
++)
1690 dn_bufp
= hpread_get_gntt (hp_symnum
, objfile
);
1692 dn_bufp
= hpread_get_lntt (hp_symnum
, objfile
);
1694 if (dn_bufp
->dblock
.extension
)
1697 /* Only handle things which are necessary for minimal symbols.
1698 everything else is ignored. */
1699 switch (dn_bufp
->dblock
.kind
)
1701 case DNTT_TYPE_SRCFILE
:
1703 #ifdef QUICK_LOOK_UP
1704 if (scan_start
== hp_symnum
1705 && symcount
== hp_symnum
+ 1)
1707 /* If there are NO globals in an executable,
1708 PXDB's index to the globals will point to
1709 the last record in the file, which
1710 could be this record. (this happened for F77 libraries)
1711 ignore it and be done! */
1714 #endif /* QUICK_LOOK_UP */
1716 /* A source file of some kind. Note this may simply
1717 be an included file. */
1718 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
1720 /* Check if this is the source file we are already working
1722 if (pst
&& !strcmp (namestring
, pst
->filename
))
1725 /* Check if this is an include file, if so check if we have
1726 already seen it. Add it to the include list */
1727 p
= strrchr (namestring
, '.');
1728 if (!strcmp (p
, ".h"))
1733 for (j
= 0; j
< includes_used
; j
++)
1734 if (!strcmp (namestring
, psymtab_include_list
[j
]))
1742 /* Add it to the list of includes seen so far and
1743 allocate more include space if necessary. */
1744 psymtab_include_list
[includes_used
++] = namestring
;
1745 if (includes_used
>= includes_allocated
)
1747 char **orig
= psymtab_include_list
;
1749 psymtab_include_list
= (char **)
1750 alloca ((includes_allocated
*= 2) *
1752 memcpy ((PTR
) psymtab_include_list
, (PTR
) orig
,
1753 includes_used
* sizeof (char *));
1762 pst
->filename
= (char *)
1763 obstack_alloc (&pst
->objfile
->psymbol_obstack
,
1764 strlen (namestring
) + 1);
1765 strcpy (pst
->filename
, namestring
);
1772 /* This is a bonafide new source file.
1773 End the current partial symtab and start a new one. */
1775 if (pst
&& past_first_source_file
)
1777 hpread_end_psymtab (pst
, psymtab_include_list
,
1780 * sizeof (struct dntt_type_block
)),
1782 dependency_list
, dependencies_used
);
1783 pst
= (struct partial_symtab
*) 0;
1785 dependencies_used
= 0;
1788 past_first_source_file
= 1;
1790 valu
= hpread_get_textlow (i
, hp_symnum
, objfile
, symcount
);
1791 valu
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT (objfile
));
1792 pst
= hpread_start_psymtab (objfile
,
1795 * sizeof (struct dntt_type_block
)),
1796 objfile
->global_psymbols
.next
,
1797 objfile
->static_psymbols
.next
);
1803 case DNTT_TYPE_MODULE
:
1804 /* A source file. It's still unclear to me what the
1805 real difference between a DNTT_TYPE_SRCFILE and DNTT_TYPE_MODULE
1806 is supposed to be. */
1808 /* First end the previous psymtab */
1811 hpread_end_psymtab (pst
, psymtab_include_list
, includes_used
,
1813 * sizeof (struct dntt_type_block
)),
1815 dependency_list
, dependencies_used
);
1816 pst
= (struct partial_symtab
*) 0;
1818 dependencies_used
= 0;
1822 /* Now begin a new module and a new psymtab for it */
1823 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
1824 valu
= hpread_get_textlow (i
, hp_symnum
, objfile
, symcount
);
1825 valu
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT (objfile
));
1828 pst
= hpread_start_psymtab (objfile
,
1831 * sizeof (struct dntt_type_block
)),
1832 objfile
->global_psymbols
.next
,
1833 objfile
->static_psymbols
.next
);
1839 case DNTT_TYPE_FUNCTION
:
1840 case DNTT_TYPE_ENTRY
:
1841 /* The beginning of a function. DNTT_TYPE_ENTRY may also denote
1842 a secondary entry point. */
1843 valu
= dn_bufp
->dfunc
.hiaddr
+ ANOFFSET (objfile
->section_offsets
,
1844 SECT_OFF_TEXT (objfile
));
1845 if (valu
> texthigh
)
1847 valu
= dn_bufp
->dfunc
.lowaddr
+
1848 ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT (objfile
));
1849 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
1850 if (dn_bufp
->dfunc
.global
)
1851 add_psymbol_to_list (namestring
, strlen (namestring
),
1852 VAR_NAMESPACE
, LOC_BLOCK
,
1853 &objfile
->global_psymbols
, valu
,
1854 0, language_unknown
, objfile
);
1856 add_psymbol_to_list (namestring
, strlen (namestring
),
1857 VAR_NAMESPACE
, LOC_BLOCK
,
1858 &objfile
->static_psymbols
, valu
,
1859 0, language_unknown
, objfile
);
1860 within_function
= 1;
1863 case DNTT_TYPE_DOC_FUNCTION
:
1864 valu
= dn_bufp
->ddocfunc
.hiaddr
+ ANOFFSET (objfile
->section_offsets
,
1865 SECT_OFF_TEXT (objfile
));
1866 if (valu
> texthigh
)
1868 valu
= dn_bufp
->ddocfunc
.lowaddr
+
1869 ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT (objfile
));
1870 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
1871 if (dn_bufp
->ddocfunc
.global
)
1872 add_psymbol_to_list (namestring
, strlen (namestring
),
1873 VAR_NAMESPACE
, LOC_BLOCK
,
1874 &objfile
->global_psymbols
, valu
,
1875 0, language_unknown
, objfile
);
1877 add_psymbol_to_list (namestring
, strlen (namestring
),
1878 VAR_NAMESPACE
, LOC_BLOCK
,
1879 &objfile
->static_psymbols
, valu
,
1880 0, language_unknown
, objfile
);
1881 within_function
= 1;
1884 case DNTT_TYPE_BEGIN
:
1886 /* We don't check MODULE end here, because there can be
1887 symbols beyond the module end which properly belong to the
1888 current psymtab -- so we wait till the next MODULE start */
1891 #ifdef QUICK_LOOK_UP
1892 if (scan_start
== hp_symnum
1893 && symcount
== hp_symnum
+ 1)
1895 /* If there are NO globals in an executable,
1896 PXDB's index to the globals will point to
1897 the last record in the file, which is
1898 probably an END MODULE, i.e. this record.
1899 ignore it and be done! */
1902 #endif /* QUICK_LOOK_UP */
1904 /* Scope block begin/end. We only care about function
1905 and file blocks right now. */
1907 if ((dn_bufp
->dend
.endkind
== DNTT_TYPE_FUNCTION
) ||
1908 (dn_bufp
->dend
.endkind
== DNTT_TYPE_DOC_FUNCTION
))
1909 within_function
= 0;
1912 case DNTT_TYPE_SVAR
:
1913 case DNTT_TYPE_DVAR
:
1914 case DNTT_TYPE_TYPEDEF
:
1915 case DNTT_TYPE_TAGDEF
:
1917 /* Variables, typedefs an the like. */
1918 enum address_class storage
;
1919 namespace_enum
namespace;
1921 /* Don't add locals to the partial symbol table. */
1923 && (dn_bufp
->dblock
.kind
== DNTT_TYPE_SVAR
1924 || dn_bufp
->dblock
.kind
== DNTT_TYPE_DVAR
))
1927 /* TAGDEFs go into the structure namespace. */
1928 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_TAGDEF
)
1929 namespace = STRUCT_NAMESPACE
;
1931 namespace = VAR_NAMESPACE
;
1933 /* What kind of "storage" does this use? */
1934 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_SVAR
)
1935 storage
= LOC_STATIC
;
1936 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_DVAR
1937 && dn_bufp
->ddvar
.regvar
)
1938 storage
= LOC_REGISTER
;
1939 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_DVAR
)
1940 storage
= LOC_LOCAL
;
1942 storage
= LOC_UNDEF
;
1944 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
1947 pst
= hpread_start_psymtab (objfile
,
1950 * sizeof (struct dntt_type_block
)),
1951 objfile
->global_psymbols
.next
,
1952 objfile
->static_psymbols
.next
);
1955 /* Compute address of the data symbol */
1956 valu
= dn_bufp
->dsvar
.location
;
1957 /* Relocate in case it's in a shared library */
1958 if (storage
== LOC_STATIC
)
1959 valu
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_DATA (objfile
));
1961 /* Luckily, dvar, svar, typedef, and tagdef all
1962 have their "global" bit in the same place, so it works
1963 (though it's bad programming practice) to reference
1964 "dsvar.global" even though we may be looking at
1965 any of the above four types. */
1966 if (dn_bufp
->dsvar
.global
)
1968 add_psymbol_to_list (namestring
, strlen (namestring
),
1970 &objfile
->global_psymbols
,
1972 0, language_unknown
, objfile
);
1976 add_psymbol_to_list (namestring
, strlen (namestring
),
1978 &objfile
->static_psymbols
,
1980 0, language_unknown
, objfile
);
1983 /* For TAGDEF's, the above code added the tagname to the
1984 struct namespace. This will cause tag "t" to be found
1985 on a reference of the form "(struct t) x". But for
1986 C++ classes, "t" will also be a typename, which we
1987 want to find on a reference of the form "ptype t".
1988 Therefore, we also add "t" to the var namespace.
1989 Do the same for enum's due to the way aCC generates
1990 debug info for these (see more extended comment
1991 in hp-symtab-read.c).
1992 We do the same for templates, so that "ptype t"
1993 where "t" is a template also works. */
1994 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_TAGDEF
&&
1995 dn_bufp
->dtype
.type
.dnttp
.index
< LNTT_SYMCOUNT (objfile
))
1997 int global
= dn_bufp
->dtag
.global
;
1998 /* Look ahead to see if it's a C++ class */
1999 dn_bufp
= hpread_get_lntt (dn_bufp
->dtype
.type
.dnttp
.index
, objfile
);
2000 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_CLASS
||
2001 dn_bufp
->dblock
.kind
== DNTT_TYPE_ENUM
||
2002 dn_bufp
->dblock
.kind
== DNTT_TYPE_TEMPLATE
)
2006 add_psymbol_to_list (namestring
, strlen (namestring
),
2007 VAR_NAMESPACE
, storage
,
2008 &objfile
->global_psymbols
,
2009 dn_bufp
->dsvar
.location
,
2010 0, language_unknown
, objfile
);
2014 add_psymbol_to_list (namestring
, strlen (namestring
),
2015 VAR_NAMESPACE
, storage
,
2016 &objfile
->static_psymbols
,
2017 dn_bufp
->dsvar
.location
,
2018 0, language_unknown
, objfile
);
2025 case DNTT_TYPE_MEMENUM
:
2026 case DNTT_TYPE_CONST
:
2027 /* Constants and members of enumerated types. */
2028 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
2031 pst
= hpread_start_psymtab (objfile
,
2034 * sizeof (struct dntt_type_block
)),
2035 objfile
->global_psymbols
.next
,
2036 objfile
->static_psymbols
.next
);
2038 if (dn_bufp
->dconst
.global
)
2039 add_psymbol_to_list (namestring
, strlen (namestring
),
2040 VAR_NAMESPACE
, LOC_CONST
,
2041 &objfile
->global_psymbols
, 0,
2042 0, language_unknown
, objfile
);
2044 add_psymbol_to_list (namestring
, strlen (namestring
),
2045 VAR_NAMESPACE
, LOC_CONST
,
2046 &objfile
->static_psymbols
, 0,
2047 0, language_unknown
, objfile
);
2055 /* End any pending partial symbol table. */
2058 hpread_end_psymtab (pst
, psymtab_include_list
, includes_used
,
2059 hp_symnum
* sizeof (struct dntt_type_block
),
2060 0, dependency_list
, dependencies_used
);
2063 discard_cleanups (old_chain
);
2066 /* Perform any local cleanups required when we are done with a particular
2067 objfile. I.E, we are in the process of discarding all symbol information
2068 for an objfile, freeing up all memory held for it, and unlinking the
2069 objfile struct from the global list of known objfiles. */
2072 hpread_symfile_finish (struct objfile
*objfile
)
2074 if (objfile
->sym_private
!= NULL
)
2076 mfree (objfile
->md
, objfile
->sym_private
);
2081 /* The remaining functions are all for internal use only. */
2083 /* Various small functions to get entries in the debug symbol sections. */
2086 hpread_get_lntt (int index
, struct objfile
*objfile
)
2088 return (union dnttentry
*)
2089 &(LNTT (objfile
)[(index
* sizeof (struct dntt_type_block
))]);
2092 static union dnttentry
*
2093 hpread_get_gntt (int index
, struct objfile
*objfile
)
2095 return (union dnttentry
*)
2096 &(GNTT (objfile
)[(index
* sizeof (struct dntt_type_block
))]);
2100 hpread_get_slt (int index
, struct objfile
*objfile
)
2102 return (union sltentry
*) &(SLT (objfile
)[index
* sizeof (union sltentry
)]);
2105 /* Get the low address associated with some symbol (typically the start
2106 of a particular source file or module). Since that information is not
2107 stored as part of the DNTT_TYPE_MODULE or DNTT_TYPE_SRCFILE symbol we
2108 must infer it from the existence of DNTT_TYPE_FUNCTION symbols. */
2110 static unsigned long
2111 hpread_get_textlow (int global
, int index
, struct objfile
*objfile
,
2114 union dnttentry
*dn_bufp
;
2115 struct minimal_symbol
*msymbol
;
2117 /* Look for a DNTT_TYPE_FUNCTION symbol. */
2118 if (index
< symcount
) /* symcount is the number of symbols in */
2119 { /* the dbinfo, LNTT table */
2123 dn_bufp
= hpread_get_gntt (index
++, objfile
);
2125 dn_bufp
= hpread_get_lntt (index
++, objfile
);
2127 while (dn_bufp
->dblock
.kind
!= DNTT_TYPE_FUNCTION
2128 && dn_bufp
->dblock
.kind
!= DNTT_TYPE_DOC_FUNCTION
2129 && dn_bufp
->dblock
.kind
!= DNTT_TYPE_END
2130 && index
< symcount
);
2133 /* Avoid going past a DNTT_TYPE_END when looking for a DNTT_TYPE_FUNCTION. This
2134 might happen when a sourcefile has no functions. */
2135 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_END
)
2138 /* Avoid going past the end of the LNTT file */
2139 if (index
== symcount
)
2142 /* The minimal symbols are typically more accurate for some reason. */
2143 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_FUNCTION
)
2144 msymbol
= lookup_minimal_symbol (dn_bufp
->dfunc
.name
+ VT (objfile
), NULL
,
2146 else /* must be a DNTT_TYPE_DOC_FUNCTION */
2147 msymbol
= lookup_minimal_symbol (dn_bufp
->ddocfunc
.name
+ VT (objfile
), NULL
,
2151 return SYMBOL_VALUE_ADDRESS (msymbol
);
2153 return dn_bufp
->dfunc
.lowaddr
;
2156 /* Allocate and partially fill a partial symtab. It will be
2157 completely filled at the end of the symbol list.
2159 SYMFILE_NAME is the name of the symbol-file we are reading from, and ADDR
2160 is the address relative to which its symbols are (incremental) or 0
2163 static struct partial_symtab
*
2164 hpread_start_psymtab (struct objfile
*objfile
, char *filename
,
2165 CORE_ADDR textlow
, int ldsymoff
,
2166 struct partial_symbol
**global_syms
,
2167 struct partial_symbol
**static_syms
)
2169 int offset
= ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT (objfile
));
2170 extern void hpread_psymtab_to_symtab ();
2171 struct partial_symtab
*result
=
2172 start_psymtab_common (objfile
, objfile
->section_offsets
,
2173 filename
, textlow
, global_syms
, static_syms
);
2175 result
->textlow
+= offset
;
2176 result
->read_symtab_private
= (char *)
2177 obstack_alloc (&objfile
->psymbol_obstack
, sizeof (struct symloc
));
2178 LDSYMOFF (result
) = ldsymoff
;
2179 result
->read_symtab
= hpread_psymtab_to_symtab
;
2185 /* Close off the current usage of PST.
2186 Returns PST or NULL if the partial symtab was empty and thrown away.
2188 capping_symbol_offset --Byte index in LNTT or GNTT of the
2189 last symbol processed during the build
2190 of the previous pst.
2192 FIXME: List variables and peculiarities of same. */
2194 static struct partial_symtab
*
2195 hpread_end_psymtab (struct partial_symtab
*pst
, char **include_list
,
2196 int num_includes
, int capping_symbol_offset
,
2197 CORE_ADDR capping_text
,
2198 struct partial_symtab
**dependency_list
,
2199 int number_dependencies
)
2202 struct objfile
*objfile
= pst
->objfile
;
2203 int offset
= ANOFFSET (pst
->section_offsets
, SECT_OFF_TEXT (objfile
));
2206 /* Turn on to see what kind of a psymtab we've built. */
2207 static int dumping
= 0;
2210 if (capping_symbol_offset
!= -1)
2211 LDSYMLEN (pst
) = capping_symbol_offset
- LDSYMOFF (pst
);
2214 pst
->texthigh
= capping_text
+ offset
;
2216 pst
->n_global_syms
=
2217 objfile
->global_psymbols
.next
- (objfile
->global_psymbols
.list
+ pst
->globals_offset
);
2218 pst
->n_static_syms
=
2219 objfile
->static_psymbols
.next
- (objfile
->static_psymbols
.list
+ pst
->statics_offset
);
2224 printf ("\nPst %s, LDSYMOFF %x (%x), LDSYMLEN %x (%x), globals %d, statics %d\n",
2227 LDSYMOFF (pst
) / sizeof (struct dntt_type_block
),
2229 LDSYMLEN (pst
) / sizeof (struct dntt_type_block
),
2230 pst
->n_global_syms
, pst
->n_static_syms
);
2234 pst
->number_of_dependencies
= number_dependencies
;
2235 if (number_dependencies
)
2237 pst
->dependencies
= (struct partial_symtab
**)
2238 obstack_alloc (&objfile
->psymbol_obstack
,
2239 number_dependencies
* sizeof (struct partial_symtab
*));
2240 memcpy (pst
->dependencies
, dependency_list
,
2241 number_dependencies
* sizeof (struct partial_symtab
*));
2244 pst
->dependencies
= 0;
2246 for (i
= 0; i
< num_includes
; i
++)
2248 struct partial_symtab
*subpst
=
2249 allocate_psymtab (include_list
[i
], objfile
);
2251 subpst
->section_offsets
= pst
->section_offsets
;
2252 subpst
->read_symtab_private
=
2253 (char *) obstack_alloc (&objfile
->psymbol_obstack
,
2254 sizeof (struct symloc
));
2258 subpst
->texthigh
= 0;
2260 /* We could save slight bits of space by only making one of these,
2261 shared by the entire set of include files. FIXME-someday. */
2262 subpst
->dependencies
= (struct partial_symtab
**)
2263 obstack_alloc (&objfile
->psymbol_obstack
,
2264 sizeof (struct partial_symtab
*));
2265 subpst
->dependencies
[0] = pst
;
2266 subpst
->number_of_dependencies
= 1;
2268 subpst
->globals_offset
=
2269 subpst
->n_global_syms
=
2270 subpst
->statics_offset
=
2271 subpst
->n_static_syms
= 0;
2275 subpst
->read_symtab
= pst
->read_symtab
;
2278 sort_pst_symbols (pst
);
2280 /* If there is already a psymtab or symtab for a file of this name, remove it.
2281 (If there is a symtab, more drastic things also happen.)
2282 This happens in VxWorks. */
2283 free_named_symtabs (pst
->filename
);
2285 if (num_includes
== 0
2286 && number_dependencies
== 0
2287 && pst
->n_global_syms
== 0
2288 && pst
->n_static_syms
== 0)
2290 /* Throw away this psymtab, it's empty. We can't deallocate it, since
2291 it is on the obstack, but we can forget to chain it on the list.
2292 Empty psymtabs happen as a result of header files which don't have
2293 any symbols in them. There can be a lot of them. But this check
2294 is wrong, in that a psymtab with N_SLINE entries but nothing else
2295 is not empty, but we don't realize that. Fixing that without slowing
2296 things down might be tricky.
2297 It's also wrong if we're using the quick look-up tables, as
2298 we can get empty psymtabs from modules with no routines in
2301 discard_psymtab (pst
);
2303 /* Indicate that psymtab was thrown away. */
2304 pst
= (struct partial_symtab
*) NULL
;
2311 /* End of hp-psymtab-read.c */
2313 /* Set indentation to 4 spaces for Emacs; this file is
2314 mostly non-GNU-ish in its style :-( */
2317 ***c
- basic
- offset
:4