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
42 PARAMS ((struct objfile
*));
45 do_pxdb
PARAMS ((bfd
*));
47 void hpread_build_psymtabs
48 PARAMS ((struct objfile
*, int));
50 void hpread_symfile_finish
51 PARAMS ((struct objfile
*));
53 static union dnttentry
*hpread_get_gntt
54 PARAMS ((int, struct objfile
*));
56 static unsigned long hpread_get_textlow
57 PARAMS ((int, int, struct objfile
*, int));
59 static struct partial_symtab
*hpread_start_psymtab
60 PARAMS ((struct objfile
*, char *, CORE_ADDR
, int,
61 struct partial_symbol
**, struct partial_symbol
**));
63 static struct partial_symtab
*hpread_end_psymtab
64 PARAMS ((struct partial_symtab
*, char **, int, int, CORE_ADDR
,
65 struct partial_symtab
**, int));
67 /* End of forward routine declarations */
71 /* NOTE use of system files! May not be portable. */
73 #define PXDB_SVR4 "/opt/langtools/bin/pxdb"
74 #define PXDB_BSD "/usr/bin/pxdb"
79 /* check for the existance of a file, given its full pathname */
81 file_exists (filename
)
85 return (access (filename
, F_OK
) == 0);
90 /* Translate from the "hp_language" enumeration in hp-symtab.h
91 used in the debug info to gdb's generic enumeration in defs.h. */
94 enum hp_language in_lang
;
96 if (in_lang
== HP_LANGUAGE_C
)
99 else if (in_lang
== HP_LANGUAGE_CPLUSPLUS
)
100 return language_cplus
;
102 else if (in_lang
== HP_LANGUAGE_FORTRAN
)
103 return language_fortran
;
106 return language_unknown
;
109 static char main_string
[] = "main";
111 /* Call PXDB to process our file.
113 Approach copied from DDE's "dbgk_run_pxdb". Note: we
114 don't check for BSD location of pxdb, nor for existance
117 NOTE: uses system function and string functions directly.
119 Return value: 1 if ok, 0 if not */
121 hpread_call_pxdb (file_name
)
128 if (file_exists (PXDB_SVR4
))
130 p
= malloc (strlen (PXDB_SVR4
) + strlen (file_name
) + 2);
131 strcpy (p
, PXDB_SVR4
);
133 strcat (p
, file_name
);
135 warning ("File not processed by pxdb--about to process now.\n");
138 retval
= (status
== 0);
142 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
);
147 } /* hpread_call_pxdb */
150 /* Return 1 if the file turns out to need pre-processing
151 by PXDB, and we have thus called PXDB to do this processing
152 and the file therefore needs to be re-loaded. Otherwise
155 hpread_pxdb_needed (sym_bfd
)
158 asection
*pinfo_section
, *debug_section
, *header_section
;
159 unsigned int do_pxdb
;
161 bfd_size_type header_section_size
;
166 header_section
= bfd_get_section_by_name (sym_bfd
, "$HEADER$");
169 return 0; /* No header at all, can't recover... */
172 debug_section
= bfd_get_section_by_name (sym_bfd
, "$DEBUG$");
173 pinfo_section
= bfd_get_section_by_name (sym_bfd
, "$PINFO$");
175 if (pinfo_section
&& !debug_section
)
177 /* Debug info with DOC, has different header format.
178 this only happens if the file was pxdbed and compiled optimized
179 otherwise the PINFO section is not there. */
180 header_section_size
= bfd_section_size (objfile
->obfd
, header_section
);
182 if (header_section_size
== (bfd_size_type
) sizeof (DOC_info_PXDB_header
))
184 buf
= alloca (sizeof (DOC_info_PXDB_header
));
186 if (!bfd_get_section_contents (sym_bfd
,
189 header_section_size
))
190 error ("bfd_get_section_contents\n");
192 tmp
= bfd_get_32 (sym_bfd
, (bfd_byte
*) (buf
+ sizeof (int) * 4));
193 pxdbed
= (tmp
>> 31) & 0x1;
196 error ("file debug header info invalid\n");
201 error ("invalid $HEADER$ size in executable \n");
207 /* this can be three different cases:
208 1. pxdbed and not doc
209 - DEBUG and HEADER sections are there
210 - header is PXDB_header type
211 - pxdbed flag is set to 1
213 2. not pxdbed and doc
214 - DEBUG and HEADER sections are there
215 - header is DOC_info_header type
216 - pxdbed flag is set to 0
218 3. not pxdbed and not doc
219 - DEBUG and HEADER sections are there
220 - header is XDB_header type
221 - pxdbed flag is set to 0
223 NOTE: the pxdbed flag is meaningful also in the not
224 already pxdb processed version of the header,
225 because in case on non-already processed by pxdb files
226 that same bit in the header would be always zero.
227 Why? Because the bit is the leftmost bit of a word
228 which contains a 'length' which is always a positive value
229 so that bit is never set to 1 (otherwise it would be negative)
231 Given the above, we have two choices : either we ignore the
232 size of the header itself and just look at the pxdbed field,
233 or we check the size and then we (for safety and paranoia related
234 issues) check the bit.
235 The first solution is used by DDE, the second by PXDB itself.
236 I am using the second one here, because I already wrote it,
237 and it is the end of a long day.
238 Also, using the first approach would still involve size issues
239 because we need to read in the contents of the header section, and
240 give the correct amount of stuff we want to read to the
241 get_bfd_section_contents function. */
243 /* decide which case depending on the size of the header section.
244 The size is as defined in hp-symtab.h */
246 header_section_size
= bfd_section_size (objfile
->obfd
, header_section
);
248 if (header_section_size
== (bfd_size_type
) sizeof (PXDB_header
)) /* pxdb and not doc */
251 buf
= alloca (sizeof (PXDB_header
));
252 if (!bfd_get_section_contents (sym_bfd
,
255 header_section_size
))
256 error ("bfd_get_section_contents\n");
258 tmp
= bfd_get_32 (sym_bfd
, (bfd_byte
*) (buf
+ sizeof (int) * 3));
259 pxdbed
= (tmp
>> 31) & 0x1;
264 error ("file debug header invalid\n");
266 else /*not pxdbed and doc OR not pxdbed and non doc */
278 } /* hpread_pxdb_needed */
282 /* Check whether the file needs to be preprocessed by pxdb.
289 /* The following code is HP-specific. The "right" way of
290 doing this is unknown, but we bet would involve a target-
291 specific pre-file-load check using a generic mechanism. */
293 /* This code will not be executed if the file is not in SOM
294 format (i.e. if compiled with gcc) */
295 if (hpread_pxdb_needed (sym_bfd
))
297 /*This file has not been pre-processed. Preprocess now */
299 if (hpread_call_pxdb (sym_bfd
->filename
))
301 /* The call above has changed the on-disk file,
302 we can close the file anyway, because the
303 symbols will be reread in when the target is run */
313 /* Code to handle quick lookup-tables follows. */
316 /* Some useful macros */
317 #define VALID_FILE(i) ((i) < pxdb_header_p->fd_entries)
318 #define VALID_MODULE(i) ((i) < pxdb_header_p->md_entries)
319 #define VALID_PROC(i) ((i) < pxdb_header_p->pd_entries)
320 #define VALID_CLASS(i) ((i) < pxdb_header_p->cd_entries)
322 #define FILE_START(i) (qFD[i].adrStart)
323 #define MODULE_START(i) (qMD[i].adrStart)
324 #define PROC_START(i) (qPD[i].adrStart)
326 #define FILE_END(i) (qFD[i].adrEnd)
327 #define MODULE_END(i) (qMD[i].adrEnd)
328 #define PROC_END(i) (qPD[i].adrEnd)
330 #define FILE_ISYM(i) (qFD[i].isym)
331 #define MODULE_ISYM(i) (qMD[i].isym)
332 #define PROC_ISYM(i) (qPD[i].isym)
334 #define VALID_CURR_FILE (curr_fd < pxdb_header_p->fd_entries)
335 #define VALID_CURR_MODULE (curr_md < pxdb_header_p->md_entries)
336 #define VALID_CURR_PROC (curr_pd < pxdb_header_p->pd_entries)
337 #define VALID_CURR_CLASS (curr_cd < pxdb_header_p->cd_entries)
339 #define CURR_FILE_START (qFD[curr_fd].adrStart)
340 #define CURR_MODULE_START (qMD[curr_md].adrStart)
341 #define CURR_PROC_START (qPD[curr_pd].adrStart)
343 #define CURR_FILE_END (qFD[curr_fd].adrEnd)
344 #define CURR_MODULE_END (qMD[curr_md].adrEnd)
345 #define CURR_PROC_END (qPD[curr_pd].adrEnd)
347 #define CURR_FILE_ISYM (qFD[curr_fd].isym)
348 #define CURR_MODULE_ISYM (qMD[curr_md].isym)
349 #define CURR_PROC_ISYM (qPD[curr_pd].isym)
351 #define TELL_OBJFILE \
353 if( !told_objfile ) { \
355 warning ("\nIn object file \"%s\":\n", \
362 /* Keeping track of the start/end symbol table (LNTT) indices of
363 psymtabs created so far */
372 static pst_syms_struct
*pst_syms_array
= 0;
374 static pst_syms_count
= 0;
375 static pst_syms_size
= 0;
377 /* used by the TELL_OBJFILE macro */
378 static boolean told_objfile
= 0;
380 /* Set up psymtab symbol index stuff */
386 pst_syms_array
= (pst_syms_struct
*) xmalloc (20 * sizeof (pst_syms_struct
));
389 /* Clean up psymtab symbol index stuff */
395 free (pst_syms_array
);
399 /* Add information about latest psymtab to symbol index table */
401 record_pst_syms (start_sym
, end_sym
)
405 if (++pst_syms_count
> pst_syms_size
)
407 pst_syms_array
= (pst_syms_struct
*) xrealloc (pst_syms_array
,
408 2 * pst_syms_size
* sizeof (pst_syms_struct
));
411 pst_syms_array
[pst_syms_count
- 1].start
= start_sym
;
412 pst_syms_array
[pst_syms_count
- 1].end
= end_sym
;
415 /* Find a suitable symbol table index which can serve as the upper
416 bound of a psymtab that starts at INDEX
418 This scans backwards in the psymtab symbol index table to find a
419 "hole" in which the given index can fit. This is a heuristic!!
420 We don't search the entire table to check for multiple holes,
421 we don't care about overlaps, etc.
423 Return 0 => not found */
425 find_next_pst_start (index
)
430 for (i
= pst_syms_count
- 1; i
>= 0; i
--)
431 if (pst_syms_array
[i
].end
<= index
)
432 return (i
== pst_syms_count
- 1) ? 0 : pst_syms_array
[i
+ 1].start
- 1;
434 if (pst_syms_array
[0].start
> index
)
435 return pst_syms_array
[0].start
- 1;
442 /* Utility functions to find the ending symbol index for a psymtab */
444 /* Find the next file entry that begins beyond INDEX, and return
445 its starting symbol index - 1.
446 QFD is the file table, CURR_FD is the file entry from where to start,
447 PXDB_HEADER_P as in hpread_quick_traverse (to allow macros to work).
449 Return 0 => not found */
451 find_next_file_isym (index
, qFD
, curr_fd
, pxdb_header_p
)
453 quick_file_entry
*qFD
;
455 PXDB_header_ptr pxdb_header_p
;
457 while (VALID_CURR_FILE
)
459 if (CURR_FILE_ISYM
>= index
)
460 return CURR_FILE_ISYM
- 1;
466 /* Find the next procedure entry that begins beyond INDEX, and return
467 its starting symbol index - 1.
468 QPD is the procedure table, CURR_PD is the proc entry from where to start,
469 PXDB_HEADER_P as in hpread_quick_traverse (to allow macros to work).
471 Return 0 => not found */
473 find_next_proc_isym (index
, qPD
, curr_pd
, pxdb_header_p
)
475 quick_procedure_entry
*qPD
;
477 PXDB_header_ptr pxdb_header_p
;
479 while (VALID_CURR_PROC
)
481 if (CURR_PROC_ISYM
>= index
)
482 return CURR_PROC_ISYM
- 1;
488 /* Find the next module entry that begins beyond INDEX, and return
489 its starting symbol index - 1.
490 QMD is the module table, CURR_MD is the modue entry from where to start,
491 PXDB_HEADER_P as in hpread_quick_traverse (to allow macros to work).
493 Return 0 => not found */
495 find_next_module_isym (index
, qMD
, curr_md
, pxdb_header_p
)
497 quick_module_entry
*qMD
;
499 PXDB_header_ptr pxdb_header_p
;
501 while (VALID_CURR_MODULE
)
503 if (CURR_MODULE_ISYM
>= index
)
504 return CURR_MODULE_ISYM
- 1;
510 /* Scan and record partial symbols for all functions starting from index
511 pointed to by CURR_PD_P, and between code addresses START_ADR and END_ADR.
512 Other parameters are explained in comments below. */
514 /* This used to be inline in hpread_quick_traverse, but now that we do essentially the
515 same thing for two different cases (modules and module-less files), it's better
516 organized in a separate routine, although it does take lots of arguments. pai/1997-10-08 */
519 scan_procs (curr_pd_p
, qPD
, max_procs
, start_adr
, end_adr
, pst
, vt_bits
, objfile
)
520 int *curr_pd_p
; /* pointer to current proc index */
521 quick_procedure_entry
*qPD
; /* the procedure quick lookup table */
522 int max_procs
; /* number of entries in proc. table */
523 CORE_ADDR start_adr
; /* beginning of code range for current psymtab */
524 CORE_ADDR end_adr
; /* end of code range for current psymtab */
525 struct partial_symtab
*pst
; /* current psymtab */
526 char *vt_bits
; /* strings table of SOM debug space */
527 struct objfile
*objfile
; /* current object file */
529 union dnttentry
*dn_bufp
;
530 int symbol_count
= 0; /* Total number of symbols in this psymtab */
531 int curr_pd
= *curr_pd_p
; /* Convenience variable -- avoid dereferencing pointer all the time */
534 /* Turn this on for lots of debugging information in this routine */
535 static int dumping
= 0;
541 printf ("Scan_procs called, addresses %x to %x, proc %x\n", start_adr
, end_adr
, curr_pd
);
545 while ((CURR_PROC_START
<= end_adr
) && (curr_pd
< max_procs
))
548 char *rtn_name
; /* mangled name */
549 char *rtn_dem_name
; /* qualified demangled name */
553 if ((trans_lang ((enum hp_language
) qPD
[curr_pd
].language
) == language_cplus
) &&
554 vt_bits
[(long) qPD
[curr_pd
].sbAlias
]) /* not a null string */
556 /* Get mangled name for the procedure, and demangle it */
557 rtn_name
= &vt_bits
[(long) qPD
[curr_pd
].sbAlias
];
558 rtn_dem_name
= cplus_demangle (rtn_name
, DMGL_ANSI
| DMGL_PARAMS
);
562 rtn_name
= &vt_bits
[(long) qPD
[curr_pd
].sbProc
];
566 /* Hack to get around HP C/C++ compilers' insistence on providing
567 "_MAIN_" as an alternate name for "main" */
568 if ((strcmp (rtn_name
, "_MAIN_") == 0) &&
569 (strcmp (&vt_bits
[(long) qPD
[curr_pd
].sbProc
], "main") == 0))
570 rtn_dem_name
= rtn_name
= main_string
;
575 printf ("..add %s (demangled %s), index %x to this psymtab\n", rtn_name
, rtn_dem_name
, curr_pd
);
579 /* Check for module-spanning routines. */
580 if (CURR_PROC_END
> end_adr
)
583 warning ("Procedure \"%s\" [0x%x] spans file or module boundaries.", rtn_name
, curr_pd
);
586 /* Add this routine symbol to the list in the objfile.
587 Unfortunately we have to go to the LNTT to determine the
588 correct list to put it on. An alternative (which the
589 code used to do) would be to not check and always throw
590 it on the "static" list. But if we go that route, then
591 symbol_lookup() needs to be tweaked a bit to account
592 for the fact that the function might not be found on
593 the correct list in the psymtab. - RT */
594 dn_bufp
= hpread_get_lntt (qPD
[curr_pd
].isym
, objfile
);
595 if (dn_bufp
->dfunc
.global
)
596 add_psymbol_with_dem_name_to_list (rtn_name
,
599 strlen (rtn_dem_name
),
601 LOC_BLOCK
, /* "I am a routine" */
602 &objfile
->global_psymbols
,
603 (qPD
[curr_pd
].adrStart
+ /* Starting address of rtn */
604 ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT
)),
606 trans_lang ((enum hp_language
) qPD
[curr_pd
].language
),
609 add_psymbol_with_dem_name_to_list (rtn_name
,
612 strlen (rtn_dem_name
),
614 LOC_BLOCK
, /* "I am a routine" */
615 &objfile
->static_psymbols
,
616 (qPD
[curr_pd
].adrStart
+ /* Starting address of rtn */
617 ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT
)),
619 trans_lang ((enum hp_language
) qPD
[curr_pd
].language
),
623 *curr_pd_p
= ++curr_pd
; /* bump up count & reflect in caller */
624 } /* loop over procedures */
629 if (symbol_count
== 0)
630 printf ("Scan_procs: no symbols found!\n");
638 /* Traverse the quick look-up tables, building a set of psymtabs.
640 This constructs a psymtab for modules and files in the quick lookup
643 Mostly, modules correspond to compilation units, so we try to
644 create psymtabs that correspond to modules; however, in some cases
645 a file can result in a compiled object which does not have a module
646 entry for it, so in such cases we create a psymtab for the file. */
649 hpread_quick_traverse (objfile
, gntt_bits
, vt_bits
, pxdb_header_p
)
650 struct objfile
*objfile
; /* The object file descriptor */
651 char *gntt_bits
; /* GNTT entries, loaded in from the file */
652 char *vt_bits
; /* VT (string) entries ditto. */
653 PXDB_header_ptr pxdb_header_p
; /* Pointer to pxdb header ditto */
655 struct partial_symtab
*pst
;
659 quick_procedure_entry
*qPD
;
660 quick_file_entry
*qFD
;
661 quick_module_entry
*qMD
;
662 quick_class_entry
*qCD
;
666 CORE_ADDR start_adr
; /* current psymtab's starting code addr */
667 CORE_ADDR end_adr
; /* current psymtab's ending code addr */
668 CORE_ADDR next_mod_adr
; /* next module's starting code addr */
669 int curr_pd
; /* current procedure */
670 int curr_fd
; /* current file */
671 int curr_md
; /* current module */
672 int start_sym
; /* current psymtab's starting symbol index */
673 int end_sym
; /* current psymtab's ending symbol index */
674 int max_LNTT_sym_index
;
676 B_TYPE
*class_entered
;
678 struct partial_symbol
**global_syms
; /* We'll be filling in the "global" */
679 struct partial_symbol
**static_syms
; /* and "static" tables in the objfile
680 as we go, so we need a pair of
684 /* Turn this on for lots of debugging information in this routine.
685 You get a blow-by-blow account of quick lookup table reading */
686 static int dumping
= 0;
689 pst
= (struct partial_symtab
*) 0;
691 /* Clear out some globals */
695 /* Demangling style -- if EDG style already set, don't change it,
696 as HP style causes some problems with the KAI EDG compiler */
697 if (current_demangling_style
!= edg_demangling
)
699 /* Otherwise, ensure that we are using HP style demangling */
700 set_demangling_style (HP_DEMANGLING_STYLE_STRING
);
703 /* First we need to find the starting points of the quick
704 look-up tables in the GNTT. */
708 qPD
= (quick_procedure_entry_ptr
) addr
;
709 addr
+= pxdb_header_p
->pd_entries
* sizeof (quick_procedure_entry
);
714 printf ("\n Printing routines as we see them\n");
715 for (i
= 0; VALID_PROC (i
); i
++)
717 idx
= (long) qPD
[i
].sbProc
;
718 printf ("%s %x..%x\n", &vt_bits
[idx
],
719 (int) PROC_START (i
),
725 qFD
= (quick_file_entry_ptr
) addr
;
726 addr
+= pxdb_header_p
->fd_entries
* sizeof (quick_file_entry
);
731 printf ("\n Printing files as we see them\n");
732 for (i
= 0; VALID_FILE (i
); i
++)
734 idx
= (long) qFD
[i
].sbFile
;
735 printf ("%s %x..%x\n", &vt_bits
[idx
],
736 (int) FILE_START (i
),
742 qMD
= (quick_module_entry_ptr
) addr
;
743 addr
+= pxdb_header_p
->md_entries
* sizeof (quick_module_entry
);
748 printf ("\n Printing modules as we see them\n");
749 for (i
= 0; i
< pxdb_header_p
->md_entries
; i
++)
751 idx
= (long) qMD
[i
].sbMod
;
752 printf ("%s\n", &vt_bits
[idx
]);
757 qCD
= (quick_class_entry_ptr
) addr
;
758 addr
+= pxdb_header_p
->cd_entries
* sizeof (quick_class_entry
);
763 printf ("\n Printing classes as we see them\n");
764 for (i
= 0; VALID_CLASS (i
); i
++)
766 idx
= (long) qCD
[i
].sbClass
;
767 printf ("%s\n", &vt_bits
[idx
]);
770 printf ("\n Done with dump, on to build!\n");
774 /* We need this index only while hp-symtab-read.c expects
775 a byte offset to the end of the LNTT entries for a given
776 psymtab. Thus the need for it should go away someday.
778 When it goes away, then we won't have any need to load the
779 LNTT from the objfile at psymtab-time, and start-up will be
780 faster. To make that work, we'll need some way to create
781 a null pst for the "globals" pseudo-module. */
782 max_LNTT_sym_index
= LNTT_SYMCOUNT (objfile
);
784 /* Scan the module descriptors and make a psymtab for each.
786 We know the MDs, FDs and the PDs are in order by starting
787 address. We use that fact to traverse all three arrays in
788 parallel, knowing when the next PD is in a new file
789 and we need to create a new psymtab. */
790 curr_pd
= 0; /* Current procedure entry */
791 curr_fd
= 0; /* Current file entry */
792 curr_md
= 0; /* Current module entry */
794 start_adr
= 0; /* Current psymtab code range */
797 start_sym
= 0; /* Current psymtab symbol range */
800 syms_in_pst
= 0; /* Symbol count for psymtab */
802 /* Psts actually just have pointers into the objfile's
803 symbol table, not their own symbol tables. */
804 global_syms
= objfile
->global_psymbols
.list
;
805 static_syms
= objfile
->static_psymbols
.list
;
808 /* First skip over pseudo-entries with address 0. These represent inlined
809 routines and abstract (uninstantiated) template routines.
810 FIXME: These should be read in and available -- even if we can't set
811 breakpoints, etc., there's some information that can be presented
812 to the user. pai/1997-10-08 */
814 while (VALID_CURR_PROC
&& (CURR_PROC_START
== 0))
817 /* Loop over files, modules, and procedures in code address order. Each
818 time we enter an iteration of this loop, curr_pd points to the first
819 unprocessed procedure, curr_fd points to the first unprocessed file, and
820 curr_md to the first unprocessed module. Each iteration of this loop
821 updates these as required -- any or all of them may be bumpd up
822 each time around. When we exit this loop, we are done with all files
823 and modules in the tables -- there may still be some procedures, however.
825 Note: This code used to loop only over module entries, under the assumption
826 that files can occur via inclusions and are thus unreliable, while a
827 compiled object always corresponds to a module. With CTTI in the HP aCC
828 compiler, it turns out that compiled objects may have only files and no
829 modules; so we have to loop over files and modules, creating psymtabs for
830 either as appropriate. Unfortunately there are some problems (notably:
831 1. the lack of "SRC_FILE_END" entries in the LNTT, 2. the lack of pointers
832 to the ending symbol indices of a module or a file) which make it quite hard
833 to do this correctly. Currently it uses a bunch of heuristics to start and
834 end psymtabs; they seem to work well with most objects generated by aCC, but
835 who knows when that will change... */
837 while (VALID_CURR_FILE
|| VALID_CURR_MODULE
)
840 char *mod_name_string
;
841 char *full_name_string
;
843 /* First check for modules like "version.c", which have no code
844 in them but still have qMD entries. They also have no qFD or
845 qPD entries. Their start address is -1 and their end address
847 if (VALID_CURR_MODULE
&& (CURR_MODULE_START
== -1) && (CURR_MODULE_END
== 0))
850 mod_name_string
= &vt_bits
[(long) qMD
[curr_md
].sbMod
];
854 printf ("Module with data only %s\n", mod_name_string
);
857 /* We'll skip the rest (it makes error-checking easier), and
858 just make an empty pst. Right now empty psts are not put
859 in the pst chain, so all this is for naught, but later it
862 pst
= hpread_start_psymtab (objfile
,
864 CURR_MODULE_START
, /* Low text address: bogus! */
865 (CURR_MODULE_ISYM
* sizeof (struct dntt_type_block
)),
870 pst
= hpread_end_psymtab (pst
,
871 NULL
, /* psymtab_include_list */
872 0, /* includes_used */
873 end_sym
* sizeof (struct dntt_type_block
),
874 /* byte index in LNTT of end
875 = capping symbol offset
876 = LDSYMOFF of nextfile */
878 NULL
, /* dependency_list */
879 0); /* dependencies_used */
881 global_syms
= objfile
->global_psymbols
.next
;
882 static_syms
= objfile
->static_psymbols
.next
;
886 else if (VALID_CURR_MODULE
&&
887 ((CURR_MODULE_START
== 0) || (CURR_MODULE_START
== -1) ||
888 (CURR_MODULE_END
== 0) || (CURR_MODULE_END
== -1)))
891 warning ("Module \"%s\" [0x%x] has non-standard addresses. It starts at 0x%x, ends at 0x%x, and will be skipped.",
892 mod_name_string
, curr_md
, start_adr
, end_adr
);
893 /* On to next module */
898 /* First check if we are looking at a file with code in it
899 that does not overlap the current module's code range */
901 if (VALID_CURR_FILE
? (VALID_CURR_MODULE
? (CURR_FILE_END
< CURR_MODULE_START
) : 1) : 0)
904 /* Looking at file not corresponding to any module,
905 create a psymtab for it */
906 full_name_string
= &vt_bits
[(long) qFD
[curr_fd
].sbFile
];
907 start_adr
= CURR_FILE_START
;
908 end_adr
= CURR_FILE_END
;
909 start_sym
= CURR_FILE_ISYM
;
911 /* Check if there are any procedures not handled until now, that
912 begin before the start address of this file, and if so, adjust
913 this module's start address to include them. This handles routines that
914 are in between file or module ranges for some reason (probably
915 indicates a compiler bug */
917 if (CURR_PROC_START
< start_adr
)
920 warning ("Found procedure \"%s\" [0x%x] that is not in any file or module.",
921 &vt_bits
[(long) qPD
[curr_pd
].sbProc
], curr_pd
);
922 start_adr
= CURR_PROC_START
;
923 if (CURR_PROC_ISYM
< start_sym
)
924 start_sym
= CURR_PROC_ISYM
;
927 /* Sometimes (compiler bug -- COBOL) the module end address is higher
928 than the start address of the next module, so check for that and
929 adjust accordingly */
931 if (VALID_FILE (curr_fd
+ 1) && (FILE_START (curr_fd
+ 1) <= end_adr
))
934 warning ("File \"%s\" [0x%x] has ending address after starting address of next file; adjusting ending address down.",
935 full_name_string
, curr_fd
);
936 end_adr
= FILE_START (curr_fd
+ 1) - 1; /* Is -4 (or -8 for 64-bit) better? */
938 if (VALID_MODULE (curr_md
) && (CURR_MODULE_START
<= end_adr
))
941 warning ("File \"%s\" [0x%x] has ending address after starting address of next module; adjusting ending address down.",
942 full_name_string
, curr_fd
);
943 end_adr
= CURR_MODULE_START
- 1; /* Is -4 (or -8 for 64-bit) better? */
950 printf ("Make new psymtab for file %s (%x to %x).\n",
951 full_name_string
, start_adr
, end_adr
);
954 /* Create the basic psymtab, connecting it in the list
955 for this objfile and pointing its symbol entries
956 to the current end of the symbol areas in the objfile.
958 The "ldsymoff" parameter is the byte offset in the LNTT
959 of the first symbol in this file. Some day we should
960 turn this into an index (fix in hp-symtab-read.c as well).
961 And it's not even the right byte offset, as we're using
962 the size of a union! FIXME! */
963 pst
= hpread_start_psymtab (objfile
,
965 start_adr
, /* Low text address */
966 (start_sym
* sizeof (struct dntt_type_block
)),
971 /* Set up to only enter each class referenced in this module once. */
972 class_entered
= malloc (B_BYTES (pxdb_header_p
->cd_entries
));
973 B_CLRALL (class_entered
, pxdb_header_p
->cd_entries
);
975 /* Scan the procedure descriptors for procedures in the current
976 file, based on the starting addresses. */
978 syms_in_pst
= scan_procs (&curr_pd
, qPD
, pxdb_header_p
->pd_entries
,
979 start_adr
, end_adr
, pst
, vt_bits
, objfile
);
981 /* Get ending symbol offset */
984 /* First check for starting index before previous psymtab */
985 if (pst_syms_count
&& start_sym
< pst_syms_array
[pst_syms_count
- 1].end
)
987 end_sym
= find_next_pst_start (start_sym
);
989 /* Look for next start index of a file or module, or procedure */
992 int next_file_isym
= find_next_file_isym (start_sym
, qFD
, curr_fd
+ 1, pxdb_header_p
);
993 int next_module_isym
= find_next_module_isym (start_sym
, qMD
, curr_md
, pxdb_header_p
);
994 int next_proc_isym
= find_next_proc_isym (start_sym
, qPD
, curr_pd
, pxdb_header_p
);
996 if (next_file_isym
&& next_module_isym
)
998 /* pick lower of next file or module start index */
999 end_sym
= min (next_file_isym
, next_module_isym
);
1003 /* one of them is zero, pick the other */
1004 end_sym
= max (next_file_isym
, next_module_isym
);
1007 /* As a precaution, check next procedure index too */
1009 end_sym
= next_proc_isym
;
1011 end_sym
= min (end_sym
, next_proc_isym
);
1014 /* Couldn't find procedure, file, or module, use globals as default */
1016 end_sym
= pxdb_header_p
->globals
;
1021 printf ("File psymtab indices: %x to %x\n", start_sym
, end_sym
);
1025 pst
= hpread_end_psymtab (pst
,
1026 NULL
, /* psymtab_include_list */
1027 0, /* includes_used */
1028 end_sym
* sizeof (struct dntt_type_block
),
1029 /* byte index in LNTT of end
1030 = capping symbol offset
1031 = LDSYMOFF of nextfile */
1032 end_adr
, /* text high */
1033 NULL
, /* dependency_list */
1034 0); /* dependencies_used */
1036 record_pst_syms (start_sym
, end_sym
);
1039 warning ("No symbols in psymtab for file \"%s\" [0x%x].", full_name_string
, curr_fd
);
1044 printf ("Made new psymtab for file %s (%x to %x), sym %x to %x.\n",
1045 full_name_string
, start_adr
, end_adr
, CURR_FILE_ISYM
, end_sym
);
1048 /* Prepare for the next psymtab. */
1049 global_syms
= objfile
->global_psymbols
.next
;
1050 static_syms
= objfile
->static_psymbols
.next
;
1051 free (class_entered
);
1054 } /* Psymtab for file */
1057 /* We have a module for which we create a psymtab */
1059 mod_name_string
= &vt_bits
[(long) qMD
[curr_md
].sbMod
];
1061 /* We will include the code ranges of any files that happen to
1062 overlap with this module */
1064 /* So, first pick the lower of the file's and module's start addresses */
1065 start_adr
= CURR_MODULE_START
;
1066 if (VALID_CURR_FILE
)
1068 if (CURR_FILE_START
< CURR_MODULE_START
)
1071 warning ("File \"%s\" [0x%x] crosses beginning of module \"%s\".",
1072 &vt_bits
[(long) qFD
[curr_fd
].sbFile
],
1073 curr_fd
, mod_name_string
);
1075 start_adr
= CURR_FILE_START
;
1079 /* Also pick the lower of the file's and the module's start symbol indices */
1080 start_sym
= CURR_MODULE_ISYM
;
1081 if (VALID_CURR_FILE
&& (CURR_FILE_ISYM
< CURR_MODULE_ISYM
))
1082 start_sym
= CURR_FILE_ISYM
;
1084 /* For the end address, we scan through the files till we find one
1085 that overlaps the current module but ends beyond it; if no such file exists we
1086 simply use the module's start address.
1087 (Note, if file entries themselves overlap
1088 we take the longest overlapping extension beyond the end of the module...)
1089 We assume that modules never overlap. */
1091 end_adr
= CURR_MODULE_END
;
1093 if (VALID_CURR_FILE
)
1095 while (VALID_CURR_FILE
&& (CURR_FILE_START
< end_adr
))
1100 printf ("Maybe skipping file %s which overlaps with module %s\n",
1101 &vt_bits
[(long) qFD
[curr_fd
].sbFile
], mod_name_string
);
1103 if (CURR_FILE_END
> end_adr
)
1106 warning ("File \"%s\" [0x%x] crosses end of module \"%s\".",
1107 &vt_bits
[(long) qFD
[curr_fd
].sbFile
],
1108 curr_fd
, mod_name_string
);
1109 end_adr
= CURR_FILE_END
;
1113 curr_fd
--; /* back up after going too far */
1116 /* Sometimes (compiler bug -- COBOL) the module end address is higher
1117 than the start address of the next module, so check for that and
1118 adjust accordingly */
1120 if (VALID_MODULE (curr_md
+ 1) && (MODULE_START (curr_md
+ 1) <= end_adr
))
1123 warning ("Module \"%s\" [0x%x] has ending address after starting address of next module; adjusting ending address down.",
1124 mod_name_string
, curr_md
);
1125 end_adr
= MODULE_START (curr_md
+ 1) - 1; /* Is -4 (or -8 for 64-bit) better? */
1127 if (VALID_FILE (curr_fd
+ 1) && (FILE_START (curr_fd
+ 1) <= end_adr
))
1130 warning ("Module \"%s\" [0x%x] has ending address after starting address of next file; adjusting ending address down.",
1131 mod_name_string
, curr_md
);
1132 end_adr
= FILE_START (curr_fd
+ 1) - 1; /* Is -4 (or -8 for 64-bit) better? */
1135 /* Use one file to get the full name for the module. This
1136 situation can arise if there is executable code in a #include
1137 file. Each file with code in it gets a qFD. Files which don't
1138 contribute code don't get a qFD, even if they include files
1143 #include "rtn.h" return x;
1146 There will a qFD for "rtn.h",and a qMD for "body.c",
1147 but no qMD for "rtn.h" or qFD for "body.c"!
1149 We pick the name of the last file to overlap with this
1150 module. C convention is to put include files first. In a
1151 perfect world, we could check names and use the file whose full
1152 path name ends with the module name. */
1154 if (VALID_CURR_FILE
)
1155 full_name_string
= &vt_bits
[(long) qFD
[curr_fd
].sbFile
];
1157 full_name_string
= mod_name_string
;
1159 /* Check if there are any procedures not handled until now, that
1160 begin before the start address we have now, and if so, adjust
1161 this psymtab's start address to include them. This handles routines that
1162 are in between file or module ranges for some reason (probably
1163 indicates a compiler bug */
1165 if (CURR_PROC_START
< start_adr
)
1168 warning ("Found procedure \"%s\" [0x%x] that is not in any file or module.",
1169 &vt_bits
[(long) qPD
[curr_pd
].sbProc
], curr_pd
);
1170 start_adr
= CURR_PROC_START
;
1171 if (CURR_PROC_ISYM
< start_sym
)
1172 start_sym
= CURR_PROC_ISYM
;
1178 printf ("Make new psymtab for module %s (%x to %x), using file %s\n",
1179 mod_name_string
, start_adr
, end_adr
, full_name_string
);
1182 /* Create the basic psymtab, connecting it in the list
1183 for this objfile and pointing its symbol entries
1184 to the current end of the symbol areas in the objfile.
1186 The "ldsymoff" parameter is the byte offset in the LNTT
1187 of the first symbol in this file. Some day we should
1188 turn this into an index (fix in hp-symtab-read.c as well).
1189 And it's not even the right byte offset, as we're using
1190 the size of a union! FIXME! */
1191 pst
= hpread_start_psymtab (objfile
,
1193 start_adr
, /* Low text address */
1194 (start_sym
* sizeof (struct dntt_type_block
)),
1199 /* Set up to only enter each class referenced in this module once. */
1200 class_entered
= malloc (B_BYTES (pxdb_header_p
->cd_entries
));
1201 B_CLRALL (class_entered
, pxdb_header_p
->cd_entries
);
1203 /* Scan the procedure descriptors for procedures in the current
1204 module, based on the starting addresses. */
1206 syms_in_pst
= scan_procs (&curr_pd
, qPD
, pxdb_header_p
->pd_entries
,
1207 start_adr
, end_adr
, pst
, vt_bits
, objfile
);
1209 /* Get ending symbol offset */
1212 /* First check for starting index before previous psymtab */
1213 if (pst_syms_count
&& start_sym
< pst_syms_array
[pst_syms_count
- 1].end
)
1215 end_sym
= find_next_pst_start (start_sym
);
1217 /* Look for next start index of a file or module, or procedure */
1220 int next_file_isym
= find_next_file_isym (start_sym
, qFD
, curr_fd
+ 1, pxdb_header_p
);
1221 int next_module_isym
= find_next_module_isym (start_sym
, qMD
, curr_md
+ 1, pxdb_header_p
);
1222 int next_proc_isym
= find_next_proc_isym (start_sym
, qPD
, curr_pd
, pxdb_header_p
);
1224 if (next_file_isym
&& next_module_isym
)
1226 /* pick lower of next file or module start index */
1227 end_sym
= min (next_file_isym
, next_module_isym
);
1231 /* one of them is zero, pick the other */
1232 end_sym
= max (next_file_isym
, next_module_isym
);
1235 /* As a precaution, check next procedure index too */
1237 end_sym
= next_proc_isym
;
1239 end_sym
= min (end_sym
, next_proc_isym
);
1242 /* Couldn't find procedure, file, or module, use globals as default */
1244 end_sym
= pxdb_header_p
->globals
;
1249 printf ("Module psymtab indices: %x to %x\n", start_sym
, end_sym
);
1253 pst
= hpread_end_psymtab (pst
,
1254 NULL
, /* psymtab_include_list */
1255 0, /* includes_used */
1256 end_sym
* sizeof (struct dntt_type_block
),
1257 /* byte index in LNTT of end
1258 = capping symbol offset
1259 = LDSYMOFF of nextfile */
1260 end_adr
, /* text high */
1261 NULL
, /* dependency_list */
1262 0); /* dependencies_used */
1264 record_pst_syms (start_sym
, end_sym
);
1267 warning ("No symbols in psymtab for module \"%s\" [0x%x].", mod_name_string
, curr_md
);
1272 printf ("Made new psymtab for module %s (%x to %x), sym %x to %x.\n",
1273 mod_name_string
, start_adr
, end_adr
, CURR_MODULE_ISYM
, end_sym
);
1277 /* Prepare for the next psymtab. */
1278 global_syms
= objfile
->global_psymbols
.next
;
1279 static_syms
= objfile
->static_psymbols
.next
;
1280 free (class_entered
);
1284 } /* psymtab for module */
1285 } /* psymtab for non-bogus file or module */
1286 } /* End of while loop over all files & modules */
1288 /* There may be some routines after all files and modules -- these will get
1289 inserted in a separate new module of their own */
1290 if (VALID_CURR_PROC
)
1292 start_adr
= CURR_PROC_START
;
1293 end_adr
= qPD
[pxdb_header_p
->pd_entries
- 1].adrEnd
;
1295 warning ("Found functions beyond end of all files and modules [0x%x].", curr_pd
);
1299 printf ("Orphan functions at end, PD %d and beyond (%x to %x)\n",
1300 curr_pd
, start_adr
, end_adr
);
1303 pst
= hpread_start_psymtab (objfile
,
1305 start_adr
, /* Low text address */
1306 (CURR_PROC_ISYM
* sizeof (struct dntt_type_block
)),
1311 scan_procs (&curr_pd
, qPD
, pxdb_header_p
->pd_entries
,
1312 start_adr
, end_adr
, pst
, vt_bits
, objfile
);
1314 pst
= hpread_end_psymtab (pst
,
1315 NULL
, /* psymtab_include_list */
1316 0, /* includes_used */
1317 pxdb_header_p
->globals
* sizeof (struct dntt_type_block
),
1318 /* byte index in LNTT of end
1319 = capping symbol offset
1320 = LDSYMOFF of nextfile */
1321 end_adr
, /* text high */
1322 NULL
, /* dependency_list */
1323 0); /* dependencies_used */
1328 /* Now build psts for non-module things (in the tail of
1329 the LNTT, after the last END MODULE entry).
1331 If null psts were kept on the chain, this would be
1332 a solution. FIXME */
1333 pst
= hpread_start_psymtab (objfile
,
1336 (pxdb_header_p
->globals
1337 * sizeof (struct dntt_type_block
)),
1338 objfile
->global_psymbols
.next
,
1339 objfile
->static_psymbols
.next
);
1340 hpread_end_psymtab (pst
,
1342 (max_LNTT_sym_index
* sizeof (struct dntt_type_block
)),
1351 } /* End of hpread_quick_traverse. */
1354 /* Get appropriate header, based on pxdb type.
1355 Return value: 1 if ok, 0 if not */
1357 hpread_get_header (objfile
, pxdb_header_p
)
1358 struct objfile
*objfile
;
1359 PXDB_header_ptr pxdb_header_p
;
1361 asection
*pinfo_section
, *debug_section
, *header_section
;
1364 /* Turn on for debugging information */
1365 static int dumping
= 0;
1368 header_section
= bfd_get_section_by_name (objfile
->obfd
, "$HEADER$");
1369 if (!header_section
)
1371 /* We don't have either PINFO or DEBUG sections. But
1372 stuff like "libc.sl" has no debug info. There's no
1373 need to warn the user of this, as it may be ok. The
1374 caller will figure it out and issue any needed
1378 printf ("==No debug info at all for %s.\n", objfile
->name
);
1384 /* We would like either a $DEBUG$ or $PINFO$ section.
1385 Once we know which, we can understand the header
1386 data (which we have defined to suit the more common
1388 debug_section
= bfd_get_section_by_name (objfile
->obfd
, "$DEBUG$");
1389 pinfo_section
= bfd_get_section_by_name (objfile
->obfd
, "$PINFO$");
1392 /* The expected case: normal pxdb header. */
1393 bfd_get_section_contents (objfile
->obfd
, header_section
,
1394 pxdb_header_p
, 0, sizeof (PXDB_header
));
1396 if (!pxdb_header_p
->pxdbed
)
1398 /* This shouldn't happen if we check in "symfile.c". */
1400 } /* DEBUG section */
1403 else if (pinfo_section
)
1405 /* The DOC case; we need to translate this into a
1407 DOC_info_PXDB_header doc_header
;
1412 printf ("==OOps, PINFO, let's try to handle this, %s.\n", objfile
->name
);
1416 bfd_get_section_contents (objfile
->obfd
,
1419 sizeof (DOC_info_PXDB_header
));
1421 if (!doc_header
.pxdbed
)
1423 /* This shouldn't happen if we check in "symfile.c". */
1424 warning ("File \"%s\" not processed by pxdb!", objfile
->name
);
1428 /* Copy relevent fields to standard header passed in. */
1429 pxdb_header_p
->pd_entries
= doc_header
.pd_entries
;
1430 pxdb_header_p
->fd_entries
= doc_header
.fd_entries
;
1431 pxdb_header_p
->md_entries
= doc_header
.md_entries
;
1432 pxdb_header_p
->pxdbed
= doc_header
.pxdbed
;
1433 pxdb_header_p
->bighdr
= doc_header
.bighdr
;
1434 pxdb_header_p
->sa_header
= doc_header
.sa_header
;
1435 pxdb_header_p
->inlined
= doc_header
.inlined
;
1436 pxdb_header_p
->globals
= doc_header
.globals
;
1437 pxdb_header_p
->time
= doc_header
.time
;
1438 pxdb_header_p
->pg_entries
= doc_header
.pg_entries
;
1439 pxdb_header_p
->functions
= doc_header
.functions
;
1440 pxdb_header_p
->files
= doc_header
.files
;
1441 pxdb_header_p
->cd_entries
= doc_header
.cd_entries
;
1442 pxdb_header_p
->aa_entries
= doc_header
.aa_entries
;
1443 pxdb_header_p
->oi_entries
= doc_header
.oi_entries
;
1444 pxdb_header_p
->version
= doc_header
.version
;
1445 } /* PINFO section */
1451 printf ("==No debug info at all for %s.\n", objfile
->name
);
1459 } /* End of hpread_get_header */
1460 #endif /* QUICK_LOOK_UP */
1463 /* Initialization for reading native HP C debug symbols from OBJFILE.
1465 Its only purpose in life is to set up the symbol reader's private
1466 per-objfile data structures, and read in the raw contents of the debug
1467 sections (attaching pointers to the debug info into the private data
1470 Since BFD doesn't know how to read debug symbols in a format-independent
1471 way (and may never do so...), we have to do it ourselves. Note we may
1472 be called on a file without native HP C debugging symbols.
1474 FIXME, there should be a cleaner peephole into the BFD environment
1477 hpread_symfile_init (objfile
)
1478 struct objfile
*objfile
;
1480 asection
*vt_section
, *slt_section
, *lntt_section
, *gntt_section
;
1482 /* Allocate struct to keep track of the symfile */
1483 objfile
->sym_private
= (PTR
)
1484 xmmalloc (objfile
->md
, sizeof (struct hpread_symfile_info
));
1485 memset (objfile
->sym_private
, 0, sizeof (struct hpread_symfile_info
));
1487 /* We haven't read in any types yet. */
1488 TYPE_VECTOR (objfile
) = 0;
1490 /* Read in data from the $GNTT$ subspace. */
1491 gntt_section
= bfd_get_section_by_name (objfile
->obfd
, "$GNTT$");
1496 = obstack_alloc (&objfile
->symbol_obstack
,
1497 bfd_section_size (objfile
->obfd
, gntt_section
));
1499 bfd_get_section_contents (objfile
->obfd
, gntt_section
, GNTT (objfile
),
1500 0, bfd_section_size (objfile
->obfd
, gntt_section
));
1502 GNTT_SYMCOUNT (objfile
)
1503 = bfd_section_size (objfile
->obfd
, gntt_section
)
1504 / sizeof (struct dntt_type_block
);
1506 /* Read in data from the $LNTT$ subspace. Also keep track of the number
1509 FIXME: this could be moved into the psymtab-to-symtab expansion
1510 code, and save startup time. At the moment this data is
1511 still used, though. We'd need a way to tell hp-symtab-read.c
1512 whether or not to load the LNTT. */
1513 lntt_section
= bfd_get_section_by_name (objfile
->obfd
, "$LNTT$");
1518 = obstack_alloc (&objfile
->symbol_obstack
,
1519 bfd_section_size (objfile
->obfd
, lntt_section
));
1521 bfd_get_section_contents (objfile
->obfd
, lntt_section
, LNTT (objfile
),
1522 0, bfd_section_size (objfile
->obfd
, lntt_section
));
1524 LNTT_SYMCOUNT (objfile
)
1525 = bfd_section_size (objfile
->obfd
, lntt_section
)
1526 / sizeof (struct dntt_type_block
);
1528 /* Read in data from the $SLT$ subspace. $SLT$ contains information
1529 on source line numbers. */
1530 slt_section
= bfd_get_section_by_name (objfile
->obfd
, "$SLT$");
1535 obstack_alloc (&objfile
->symbol_obstack
,
1536 bfd_section_size (objfile
->obfd
, slt_section
));
1538 bfd_get_section_contents (objfile
->obfd
, slt_section
, SLT (objfile
),
1539 0, bfd_section_size (objfile
->obfd
, slt_section
));
1541 /* Read in data from the $VT$ subspace. $VT$ contains things like
1542 names and constants. Keep track of the number of symbols in the VT. */
1543 vt_section
= bfd_get_section_by_name (objfile
->obfd
, "$VT$");
1547 VT_SIZE (objfile
) = bfd_section_size (objfile
->obfd
, vt_section
);
1550 (char *) obstack_alloc (&objfile
->symbol_obstack
,
1553 bfd_get_section_contents (objfile
->obfd
, vt_section
, VT (objfile
),
1554 0, VT_SIZE (objfile
));
1557 /* Scan and build partial symbols for a symbol file.
1559 The minimal symbol table (either SOM or HP a.out) has already been
1560 read in; all we need to do is setup partial symbols based on the
1561 native debugging information.
1563 Note that the minimal table is produced by the linker, and has
1564 only global routines in it; the psymtab is based on compiler-
1565 generated debug information and has non-global
1566 routines in it as well as files and class information.
1568 We assume hpread_symfile_init has been called to initialize the
1569 symbol reader's private data structures.
1571 MAINLINE is true if we are reading the main symbol table (as
1572 opposed to a shared lib or dynamically loaded file). */
1575 hpread_build_psymtabs (objfile
, mainline
)
1576 struct objfile
*objfile
;
1581 /* Turn this on to get debugging output. */
1582 static int dumping
= 0;
1586 int past_first_source_file
= 0;
1587 struct cleanup
*old_chain
;
1589 int hp_symnum
, symcount
, i
;
1592 union dnttentry
*dn_bufp
;
1598 /* Current partial symtab */
1599 struct partial_symtab
*pst
;
1601 /* List of current psymtab's include files */
1602 char **psymtab_include_list
;
1603 int includes_allocated
;
1606 /* Index within current psymtab dependency list */
1607 struct partial_symtab
**dependency_list
;
1608 int dependencies_used
, dependencies_allocated
;
1610 /* Just in case the stabs reader left turds lying around. */
1611 free_pending_blocks ();
1612 make_cleanup (really_free_pendings
, 0);
1614 pst
= (struct partial_symtab
*) 0;
1616 /* We shouldn't use alloca, instead use malloc/free. Doing so avoids
1617 a number of problems with cross compilation and creating useless holes
1618 in the stack when we have to allocate new entries. FIXME. */
1620 includes_allocated
= 30;
1622 psymtab_include_list
= (char **) alloca (includes_allocated
*
1625 dependencies_allocated
= 30;
1626 dependencies_used
= 0;
1628 (struct partial_symtab
**) alloca (dependencies_allocated
*
1629 sizeof (struct partial_symtab
*));
1631 old_chain
= make_cleanup ((make_cleanup_func
) free_objfile
, objfile
);
1633 last_source_file
= 0;
1635 #ifdef QUICK_LOOK_UP
1637 /* Begin code for new-style loading of quick look-up tables. */
1639 /* elz: this checks whether the file has beeen processed by pxdb.
1640 If not we would like to try to read the psymbols in
1641 anyway, but it turns out to be not so easy. So this could
1642 actually be commented out, but I leave it in, just in case
1643 we decide to add support for non-pxdb-ed stuff in the future. */
1644 PXDB_header pxdb_header
;
1645 int found_modules_in_program
;
1647 if (hpread_get_header (objfile
, &pxdb_header
))
1649 /* Build a minimal table. No types, no global variables,
1650 no include files.... */
1653 printf ("\nNew method for %s\n", objfile
->name
);
1656 /* elz: quick_traverse returns true if it found
1657 some modules in the main source file, other
1659 In C and C++, all the files have MODULES entries
1660 in the LNTT, and the quick table traverse is all
1661 based on finding these MODULES entries. Without
1662 those it cannot work.
1663 It happens that F77 programs don't have MODULES
1664 so the quick traverse gets confused. F90 programs
1665 have modules, and the quick method still works.
1666 So, if modules (other than those in end.c) are
1667 not found we give up on the quick table stuff,
1668 and fall back on the slower method */
1669 found_modules_in_program
= hpread_quick_traverse (objfile
,
1674 discard_cleanups (old_chain
);
1676 /* Set up to scan the global section of the LNTT.
1678 This field is not always correct: if there are
1679 no globals, it will point to the last record in
1680 the regular LNTT, which is usually an END MODULE.
1682 Since it might happen that there could be a file
1683 with just one global record, there's no way to
1684 tell other than by looking at the record, so that's
1686 if (found_modules_in_program
)
1687 scan_start
= pxdb_header
.globals
;
1693 printf ("\nGoing on to old method for %s\n", objfile
->name
);
1697 #endif /* QUICK_LOOK_UP */
1699 /* Make two passes, one over the GNTT symbols, the other for the
1702 JB comment: above isn't true--they only make one pass, over
1704 for (i
= 0; i
< 1; i
++)
1706 int within_function
= 0;
1709 symcount
= GNTT_SYMCOUNT (objfile
);
1711 symcount
= LNTT_SYMCOUNT (objfile
);
1714 for (hp_symnum
= scan_start
; hp_symnum
< symcount
; hp_symnum
++)
1718 dn_bufp
= hpread_get_gntt (hp_symnum
, objfile
);
1720 dn_bufp
= hpread_get_lntt (hp_symnum
, objfile
);
1722 if (dn_bufp
->dblock
.extension
)
1725 /* Only handle things which are necessary for minimal symbols.
1726 everything else is ignored. */
1727 switch (dn_bufp
->dblock
.kind
)
1729 case DNTT_TYPE_SRCFILE
:
1731 #ifdef QUICK_LOOK_UP
1732 if (scan_start
== hp_symnum
1733 && symcount
== hp_symnum
+ 1)
1735 /* If there are NO globals in an executable,
1736 PXDB's index to the globals will point to
1737 the last record in the file, which
1738 could be this record. (this happened for F77 libraries)
1739 ignore it and be done! */
1742 #endif /* QUICK_LOOK_UP */
1744 /* A source file of some kind. Note this may simply
1745 be an included file. */
1746 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
1748 /* Check if this is the source file we are already working
1750 if (pst
&& !strcmp (namestring
, pst
->filename
))
1753 /* Check if this is an include file, if so check if we have
1754 already seen it. Add it to the include list */
1755 p
= strrchr (namestring
, '.');
1756 if (!strcmp (p
, ".h"))
1761 for (j
= 0; j
< includes_used
; j
++)
1762 if (!strcmp (namestring
, psymtab_include_list
[j
]))
1770 /* Add it to the list of includes seen so far and
1771 allocate more include space if necessary. */
1772 psymtab_include_list
[includes_used
++] = namestring
;
1773 if (includes_used
>= includes_allocated
)
1775 char **orig
= psymtab_include_list
;
1777 psymtab_include_list
= (char **)
1778 alloca ((includes_allocated
*= 2) *
1780 memcpy ((PTR
) psymtab_include_list
, (PTR
) orig
,
1781 includes_used
* sizeof (char *));
1790 pst
->filename
= (char *)
1791 obstack_alloc (&pst
->objfile
->psymbol_obstack
,
1792 strlen (namestring
) + 1);
1793 strcpy (pst
->filename
, namestring
);
1800 /* This is a bonafide new source file.
1801 End the current partial symtab and start a new one. */
1803 if (pst
&& past_first_source_file
)
1805 hpread_end_psymtab (pst
, psymtab_include_list
,
1808 * sizeof (struct dntt_type_block
)),
1810 dependency_list
, dependencies_used
);
1811 pst
= (struct partial_symtab
*) 0;
1813 dependencies_used
= 0;
1816 past_first_source_file
= 1;
1818 valu
= hpread_get_textlow (i
, hp_symnum
, objfile
, symcount
);
1819 valu
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT
);
1820 pst
= hpread_start_psymtab (objfile
,
1823 * sizeof (struct dntt_type_block
)),
1824 objfile
->global_psymbols
.next
,
1825 objfile
->static_psymbols
.next
);
1831 case DNTT_TYPE_MODULE
:
1832 /* A source file. It's still unclear to me what the
1833 real difference between a DNTT_TYPE_SRCFILE and DNTT_TYPE_MODULE
1834 is supposed to be. */
1836 /* First end the previous psymtab */
1839 hpread_end_psymtab (pst
, psymtab_include_list
, includes_used
,
1841 * sizeof (struct dntt_type_block
)),
1843 dependency_list
, dependencies_used
);
1844 pst
= (struct partial_symtab
*) 0;
1846 dependencies_used
= 0;
1850 /* Now begin a new module and a new psymtab for it */
1851 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
1852 valu
= hpread_get_textlow (i
, hp_symnum
, objfile
, symcount
);
1853 valu
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT
);
1856 pst
= hpread_start_psymtab (objfile
,
1859 * sizeof (struct dntt_type_block
)),
1860 objfile
->global_psymbols
.next
,
1861 objfile
->static_psymbols
.next
);
1867 case DNTT_TYPE_FUNCTION
:
1868 case DNTT_TYPE_ENTRY
:
1869 /* The beginning of a function. DNTT_TYPE_ENTRY may also denote
1870 a secondary entry point. */
1871 valu
= dn_bufp
->dfunc
.hiaddr
+ ANOFFSET (objfile
->section_offsets
,
1873 if (valu
> texthigh
)
1875 valu
= dn_bufp
->dfunc
.lowaddr
+
1876 ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT
);
1877 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
1878 if (dn_bufp
->dfunc
.global
)
1879 add_psymbol_to_list (namestring
, strlen (namestring
),
1880 VAR_NAMESPACE
, LOC_BLOCK
,
1881 &objfile
->global_psymbols
, valu
,
1882 0, language_unknown
, objfile
);
1884 add_psymbol_to_list (namestring
, strlen (namestring
),
1885 VAR_NAMESPACE
, LOC_BLOCK
,
1886 &objfile
->static_psymbols
, valu
,
1887 0, language_unknown
, objfile
);
1888 within_function
= 1;
1891 case DNTT_TYPE_DOC_FUNCTION
:
1892 valu
= dn_bufp
->ddocfunc
.hiaddr
+ ANOFFSET (objfile
->section_offsets
,
1894 if (valu
> texthigh
)
1896 valu
= dn_bufp
->ddocfunc
.lowaddr
+
1897 ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT
);
1898 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
1899 if (dn_bufp
->ddocfunc
.global
)
1900 add_psymbol_to_list (namestring
, strlen (namestring
),
1901 VAR_NAMESPACE
, LOC_BLOCK
,
1902 &objfile
->global_psymbols
, valu
,
1903 0, language_unknown
, objfile
);
1905 add_psymbol_to_list (namestring
, strlen (namestring
),
1906 VAR_NAMESPACE
, LOC_BLOCK
,
1907 &objfile
->static_psymbols
, valu
,
1908 0, language_unknown
, objfile
);
1909 within_function
= 1;
1912 case DNTT_TYPE_BEGIN
:
1914 /* We don't check MODULE end here, because there can be
1915 symbols beyond the module end which properly belong to the
1916 current psymtab -- so we wait till the next MODULE start */
1919 #ifdef QUICK_LOOK_UP
1920 if (scan_start
== hp_symnum
1921 && symcount
== hp_symnum
+ 1)
1923 /* If there are NO globals in an executable,
1924 PXDB's index to the globals will point to
1925 the last record in the file, which is
1926 probably an END MODULE, i.e. this record.
1927 ignore it and be done! */
1930 #endif /* QUICK_LOOK_UP */
1932 /* Scope block begin/end. We only care about function
1933 and file blocks right now. */
1935 if ((dn_bufp
->dend
.endkind
== DNTT_TYPE_FUNCTION
) ||
1936 (dn_bufp
->dend
.endkind
== DNTT_TYPE_DOC_FUNCTION
))
1937 within_function
= 0;
1940 case DNTT_TYPE_SVAR
:
1941 case DNTT_TYPE_DVAR
:
1942 case DNTT_TYPE_TYPEDEF
:
1943 case DNTT_TYPE_TAGDEF
:
1945 /* Variables, typedefs an the like. */
1946 enum address_class storage
;
1947 namespace_enum
namespace;
1949 /* Don't add locals to the partial symbol table. */
1951 && (dn_bufp
->dblock
.kind
== DNTT_TYPE_SVAR
1952 || dn_bufp
->dblock
.kind
== DNTT_TYPE_DVAR
))
1955 /* TAGDEFs go into the structure namespace. */
1956 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_TAGDEF
)
1957 namespace = STRUCT_NAMESPACE
;
1959 namespace = VAR_NAMESPACE
;
1961 /* What kind of "storage" does this use? */
1962 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_SVAR
)
1963 storage
= LOC_STATIC
;
1964 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_DVAR
1965 && dn_bufp
->ddvar
.regvar
)
1966 storage
= LOC_REGISTER
;
1967 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_DVAR
)
1968 storage
= LOC_LOCAL
;
1970 storage
= LOC_UNDEF
;
1972 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
1975 pst
= hpread_start_psymtab (objfile
,
1978 * sizeof (struct dntt_type_block
)),
1979 objfile
->global_psymbols
.next
,
1980 objfile
->static_psymbols
.next
);
1983 /* Compute address of the data symbol */
1984 valu
= dn_bufp
->dsvar
.location
;
1985 /* Relocate in case it's in a shared library */
1986 if (storage
== LOC_STATIC
)
1987 valu
+= ANOFFSET (objfile
->section_offsets
, SECT_OFF_DATA
);
1989 /* Luckily, dvar, svar, typedef, and tagdef all
1990 have their "global" bit in the same place, so it works
1991 (though it's bad programming practice) to reference
1992 "dsvar.global" even though we may be looking at
1993 any of the above four types. */
1994 if (dn_bufp
->dsvar
.global
)
1996 add_psymbol_to_list (namestring
, strlen (namestring
),
1998 &objfile
->global_psymbols
,
2000 0, language_unknown
, objfile
);
2004 add_psymbol_to_list (namestring
, strlen (namestring
),
2006 &objfile
->static_psymbols
,
2008 0, language_unknown
, objfile
);
2011 /* For TAGDEF's, the above code added the tagname to the
2012 struct namespace. This will cause tag "t" to be found
2013 on a reference of the form "(struct t) x". But for
2014 C++ classes, "t" will also be a typename, which we
2015 want to find on a reference of the form "ptype t".
2016 Therefore, we also add "t" to the var namespace.
2017 Do the same for enum's due to the way aCC generates
2018 debug info for these (see more extended comment
2019 in hp-symtab-read.c).
2020 We do the same for templates, so that "ptype t"
2021 where "t" is a template also works. */
2022 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_TAGDEF
&&
2023 dn_bufp
->dtype
.type
.dnttp
.index
< LNTT_SYMCOUNT (objfile
))
2025 int global
= dn_bufp
->dtag
.global
;
2026 /* Look ahead to see if it's a C++ class */
2027 dn_bufp
= hpread_get_lntt (dn_bufp
->dtype
.type
.dnttp
.index
, objfile
);
2028 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_CLASS
||
2029 dn_bufp
->dblock
.kind
== DNTT_TYPE_ENUM
||
2030 dn_bufp
->dblock
.kind
== DNTT_TYPE_TEMPLATE
)
2034 add_psymbol_to_list (namestring
, strlen (namestring
),
2035 VAR_NAMESPACE
, storage
,
2036 &objfile
->global_psymbols
,
2037 dn_bufp
->dsvar
.location
,
2038 0, language_unknown
, objfile
);
2042 add_psymbol_to_list (namestring
, strlen (namestring
),
2043 VAR_NAMESPACE
, storage
,
2044 &objfile
->static_psymbols
,
2045 dn_bufp
->dsvar
.location
,
2046 0, language_unknown
, objfile
);
2053 case DNTT_TYPE_MEMENUM
:
2054 case DNTT_TYPE_CONST
:
2055 /* Constants and members of enumerated types. */
2056 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
2059 pst
= hpread_start_psymtab (objfile
,
2062 * sizeof (struct dntt_type_block
)),
2063 objfile
->global_psymbols
.next
,
2064 objfile
->static_psymbols
.next
);
2066 if (dn_bufp
->dconst
.global
)
2067 add_psymbol_to_list (namestring
, strlen (namestring
),
2068 VAR_NAMESPACE
, LOC_CONST
,
2069 &objfile
->global_psymbols
, 0,
2070 0, language_unknown
, objfile
);
2072 add_psymbol_to_list (namestring
, strlen (namestring
),
2073 VAR_NAMESPACE
, LOC_CONST
,
2074 &objfile
->static_psymbols
, 0,
2075 0, language_unknown
, objfile
);
2083 /* End any pending partial symbol table. */
2086 hpread_end_psymtab (pst
, psymtab_include_list
, includes_used
,
2087 hp_symnum
* sizeof (struct dntt_type_block
),
2088 0, dependency_list
, dependencies_used
);
2091 discard_cleanups (old_chain
);
2094 /* Perform any local cleanups required when we are done with a particular
2095 objfile. I.E, we are in the process of discarding all symbol information
2096 for an objfile, freeing up all memory held for it, and unlinking the
2097 objfile struct from the global list of known objfiles. */
2100 hpread_symfile_finish (objfile
)
2101 struct objfile
*objfile
;
2103 if (objfile
->sym_private
!= NULL
)
2105 mfree (objfile
->md
, objfile
->sym_private
);
2110 /* The remaining functions are all for internal use only. */
2112 /* Various small functions to get entries in the debug symbol sections. */
2115 hpread_get_lntt (index
, objfile
)
2117 struct objfile
*objfile
;
2119 return (union dnttentry
*)
2120 &(LNTT (objfile
)[(index
* sizeof (struct dntt_type_block
))]);
2123 static union dnttentry
*
2124 hpread_get_gntt (index
, objfile
)
2126 struct objfile
*objfile
;
2128 return (union dnttentry
*)
2129 &(GNTT (objfile
)[(index
* sizeof (struct dntt_type_block
))]);
2133 hpread_get_slt (index
, objfile
)
2135 struct objfile
*objfile
;
2137 return (union sltentry
*) &(SLT (objfile
)[index
* sizeof (union sltentry
)]);
2140 /* Get the low address associated with some symbol (typically the start
2141 of a particular source file or module). Since that information is not
2142 stored as part of the DNTT_TYPE_MODULE or DNTT_TYPE_SRCFILE symbol we must infer it from
2143 the existance of DNTT_TYPE_FUNCTION symbols. */
2145 static unsigned long
2146 hpread_get_textlow (global
, index
, objfile
, symcount
)
2149 struct objfile
*objfile
;
2152 union dnttentry
*dn_bufp
;
2153 struct minimal_symbol
*msymbol
;
2155 /* Look for a DNTT_TYPE_FUNCTION symbol. */
2156 if (index
< symcount
) /* symcount is the number of symbols in */
2157 { /* the dbinfo, LNTT table */
2161 dn_bufp
= hpread_get_gntt (index
++, objfile
);
2163 dn_bufp
= hpread_get_lntt (index
++, objfile
);
2165 while (dn_bufp
->dblock
.kind
!= DNTT_TYPE_FUNCTION
2166 && dn_bufp
->dblock
.kind
!= DNTT_TYPE_DOC_FUNCTION
2167 && dn_bufp
->dblock
.kind
!= DNTT_TYPE_END
2168 && index
< symcount
);
2171 /* Avoid going past a DNTT_TYPE_END when looking for a DNTT_TYPE_FUNCTION. This
2172 might happen when a sourcefile has no functions. */
2173 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_END
)
2176 /* Avoid going past the end of the LNTT file */
2177 if (index
== symcount
)
2180 /* The minimal symbols are typically more accurate for some reason. */
2181 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_FUNCTION
)
2182 msymbol
= lookup_minimal_symbol (dn_bufp
->dfunc
.name
+ VT (objfile
), NULL
,
2184 else /* must be a DNTT_TYPE_DOC_FUNCTION */
2185 msymbol
= lookup_minimal_symbol (dn_bufp
->ddocfunc
.name
+ VT (objfile
), NULL
,
2189 return SYMBOL_VALUE_ADDRESS (msymbol
);
2191 return dn_bufp
->dfunc
.lowaddr
;
2194 /* Allocate and partially fill a partial symtab. It will be
2195 completely filled at the end of the symbol list.
2197 SYMFILE_NAME is the name of the symbol-file we are reading from, and ADDR
2198 is the address relative to which its symbols are (incremental) or 0
2201 static struct partial_symtab
*
2202 hpread_start_psymtab (objfile
,
2203 filename
, textlow
, ldsymoff
, global_syms
, static_syms
)
2204 struct objfile
*objfile
;
2208 struct partial_symbol
**global_syms
;
2209 struct partial_symbol
**static_syms
;
2211 int offset
= ANOFFSET (objfile
->section_offsets
, SECT_OFF_TEXT
);
2212 extern void hpread_psymtab_to_symtab ();
2213 struct partial_symtab
*result
=
2214 start_psymtab_common (objfile
, objfile
->section_offsets
,
2215 filename
, textlow
, global_syms
, static_syms
);
2217 result
->textlow
+= offset
;
2218 result
->read_symtab_private
= (char *)
2219 obstack_alloc (&objfile
->psymbol_obstack
, sizeof (struct symloc
));
2220 LDSYMOFF (result
) = ldsymoff
;
2221 result
->read_symtab
= hpread_psymtab_to_symtab
;
2227 /* Close off the current usage of PST.
2228 Returns PST or NULL if the partial symtab was empty and thrown away.
2230 capping_symbol_offset --Byte index in LNTT or GNTT of the
2231 last symbol processed during the build
2232 of the previous pst.
2234 FIXME: List variables and peculiarities of same. */
2236 static struct partial_symtab
*
2237 hpread_end_psymtab (pst
, include_list
, num_includes
, capping_symbol_offset
,
2238 capping_text
, dependency_list
, number_dependencies
)
2239 struct partial_symtab
*pst
;
2240 char **include_list
;
2242 int capping_symbol_offset
;
2243 CORE_ADDR capping_text
;
2244 struct partial_symtab
**dependency_list
;
2245 int number_dependencies
;
2248 struct objfile
*objfile
= pst
->objfile
;
2249 int offset
= ANOFFSET (pst
->section_offsets
, SECT_OFF_TEXT
);
2252 /* Turn on to see what kind of a psymtab we've built. */
2253 static int dumping
= 0;
2256 if (capping_symbol_offset
!= -1)
2257 LDSYMLEN (pst
) = capping_symbol_offset
- LDSYMOFF (pst
);
2260 pst
->texthigh
= capping_text
+ offset
;
2262 pst
->n_global_syms
=
2263 objfile
->global_psymbols
.next
- (objfile
->global_psymbols
.list
+ pst
->globals_offset
);
2264 pst
->n_static_syms
=
2265 objfile
->static_psymbols
.next
- (objfile
->static_psymbols
.list
+ pst
->statics_offset
);
2270 printf ("\nPst %s, LDSYMOFF %x (%x), LDSYMLEN %x (%x), globals %d, statics %d\n",
2273 LDSYMOFF (pst
) / sizeof (struct dntt_type_block
),
2275 LDSYMLEN (pst
) / sizeof (struct dntt_type_block
),
2276 pst
->n_global_syms
, pst
->n_static_syms
);
2280 pst
->number_of_dependencies
= number_dependencies
;
2281 if (number_dependencies
)
2283 pst
->dependencies
= (struct partial_symtab
**)
2284 obstack_alloc (&objfile
->psymbol_obstack
,
2285 number_dependencies
* sizeof (struct partial_symtab
*));
2286 memcpy (pst
->dependencies
, dependency_list
,
2287 number_dependencies
* sizeof (struct partial_symtab
*));
2290 pst
->dependencies
= 0;
2292 for (i
= 0; i
< num_includes
; i
++)
2294 struct partial_symtab
*subpst
=
2295 allocate_psymtab (include_list
[i
], objfile
);
2297 subpst
->section_offsets
= pst
->section_offsets
;
2298 subpst
->read_symtab_private
=
2299 (char *) obstack_alloc (&objfile
->psymbol_obstack
,
2300 sizeof (struct symloc
));
2304 subpst
->texthigh
= 0;
2306 /* We could save slight bits of space by only making one of these,
2307 shared by the entire set of include files. FIXME-someday. */
2308 subpst
->dependencies
= (struct partial_symtab
**)
2309 obstack_alloc (&objfile
->psymbol_obstack
,
2310 sizeof (struct partial_symtab
*));
2311 subpst
->dependencies
[0] = pst
;
2312 subpst
->number_of_dependencies
= 1;
2314 subpst
->globals_offset
=
2315 subpst
->n_global_syms
=
2316 subpst
->statics_offset
=
2317 subpst
->n_static_syms
= 0;
2321 subpst
->read_symtab
= pst
->read_symtab
;
2324 sort_pst_symbols (pst
);
2326 /* If there is already a psymtab or symtab for a file of this name, remove it.
2327 (If there is a symtab, more drastic things also happen.)
2328 This happens in VxWorks. */
2329 free_named_symtabs (pst
->filename
);
2331 if (num_includes
== 0
2332 && number_dependencies
== 0
2333 && pst
->n_global_syms
== 0
2334 && pst
->n_static_syms
== 0)
2336 /* Throw away this psymtab, it's empty. We can't deallocate it, since
2337 it is on the obstack, but we can forget to chain it on the list.
2338 Empty psymtabs happen as a result of header files which don't have
2339 any symbols in them. There can be a lot of them. But this check
2340 is wrong, in that a psymtab with N_SLINE entries but nothing else
2341 is not empty, but we don't realize that. Fixing that without slowing
2342 things down might be tricky.
2343 It's also wrong if we're using the quick look-up tables, as
2344 we can get empty psymtabs from modules with no routines in
2347 discard_psymtab (pst
);
2349 /* Indicate that psymtab was thrown away. */
2350 pst
= (struct partial_symtab
*) NULL
;
2357 /* End of hp-psymtab-read.c */
2359 /* Set indentation to 4 spaces for Emacs; this file is
2360 mostly non-GNU-ish in its style :-( */
2363 ***c
- basic
- offset
:4