1 /* Read hp debug symbols and convert to internal format, for GDB.
2 Copyright 1993, 1996 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, Boston, MA 02111-1307, USA.
20 Written by the Center for Software Science at the University of Utah
21 and by Cygnus Support. */
23 /* Common include file for hp_symtab_read.c and hp_psymtab_read.c.
24 * 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".
32 /* #define DUMPING 1 */
34 /* To use the quick look-up tables, uncomment this define.
36 #define QUICK_LOOK_UP 0
38 /* To call PXDB to process un-processed files, uncomment this define.
42 /* Forward procedure declarations */
44 void hpread_symfile_init
45 PARAMS ((struct objfile
*));
47 void hpread_build_psymtabs
48 PARAMS ((struct objfile
*, struct section_offsets
*, 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
*, struct section_offsets
*, 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 /**************************************************
73 * NOTE use of system files! May not be portable.
76 #define PXDB_SVR4 "/opt/langtools/bin/pxdb"
77 #define PXDB_BSD "/usr/bin/pxdb"
83 /* check for the existance of a file, given its full pathname */
85 file_exists (filename
)
89 return (access (filename
, F_OK
) == 0);
94 /* Translate from the "hp_language" enumeration in hp-symtab.h
95 used in the debug info to gdb's generic enumeration in defs.h. */
98 enum hp_language in_lang
;
100 if (in_lang
== HP_LANGUAGE_C
)
103 else if (in_lang
== HP_LANGUAGE_CPLUSPLUS
)
104 return language_cplus
;
106 else if (in_lang
== HP_LANGUAGE_F77
)
107 return language_fortran
;
109 else return language_unknown
;
112 static char main_string
[] = "main";
115 /* Call PXDB to process our file.
117 Approach copied from DDE's "dbgk_run_pxdb". Note: we
118 don't check for BSD location of pxdb, nor for existance
121 NOTE: uses system function and string functions directly.
123 Return value: 1 if ok, 0 if not */
125 hpread_call_pxdb (file_name
)
132 if (file_exists (PXDB_SVR4
))
134 p
= malloc (strlen (PXDB_SVR4
) + strlen (file_name
) + 2);
135 strcpy (p
, PXDB_SVR4
);
137 strcat (p
, file_name
);
139 warning ("File not processed by pxdb--about to process now.\n");
142 retval
= (status
== 0);
146 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
);
151 } /* hpread_call_pxdb */
154 /* Return 1 if the file turns out to need pre-processing
155 by PXDB, and we have thus called PXDB to do this processing
156 and the file therefore needs to be re-loaded. Otherwise
159 hpread_pxdb_needed (sym_bfd
)
162 asection
*pinfo_section
, *debug_section
, *header_section
;
163 unsigned int do_pxdb
;
165 bfd_size_type header_section_size
;
170 header_section
= bfd_get_section_by_name (sym_bfd
, "$HEADER$");
173 return 0; /* No header at all, can't recover... */
176 debug_section
= bfd_get_section_by_name (sym_bfd
, "$DEBUG$");
177 pinfo_section
= bfd_get_section_by_name (sym_bfd
, "$PINFO$");
179 if (pinfo_section
&& !debug_section
)
181 /* Debug info with DOC, has different header format. */
182 /* this only happens if the file was pxdbed and compiled optimized
183 otherwise the PINFO section is not there. */
184 header_section_size
= bfd_section_size (objfile
->obfd
, header_section
);
186 if (header_section_size
== (bfd_size_type
)sizeof (DOC_info_PXDB_header
))
188 buf
= alloca (sizeof (DOC_info_PXDB_header
));
190 if (!bfd_get_section_contents (sym_bfd
,
193 header_section_size
))
194 error ("bfd_get_section_contents\n");
196 tmp
= bfd_get_32 (sym_bfd
, (bfd_byte
*)(buf
+ sizeof (int)*4));
197 pxdbed
= (tmp
>> 31) & 0x1;
199 if (!pxdbed
) error ("file debug header info invalid\n");
203 else error ("invalid $HEADER$ size in executable \n");
208 /* this can be three different cases:
209 1. pxdbed and not doc
210 - DEBUG and HEADER sections are there
211 - header is PXDB_header type
212 - pxdbed flag is set to 1
214 2. not pxdbed and doc
215 - DEBUG and HEADER sections are there
216 - header is DOC_info_header type
217 - pxdbed flag is set to 0
219 3. not pxdbed and not doc
220 - DEBUG and HEADER sections are there
221 - header is XDB_header type
222 - pxdbed flag is set to 0
224 NOTE: the pxdbed flag is meaningful also in the not
225 already pxdb processed version of the header,
226 because in case on non-already processed by pxdb files
227 that same bit in the header would be always zero.
228 Why? Because the bit is the leftmost bit of a word
229 which contains a 'length' which is always a positive value
230 so that bit is never set to 1 (otherwise it would be negative)
232 Given the above, we have two choices : either we ignore the
233 size of the header itself and just look at the pxdbed field,
234 or we check the size and then we (for safety and paranoia related
235 issues) check the bit.
236 The first solution is used by DDE, the second by PXDB itself.
237 I am using the second one here, because I already wrote it,
238 and it is the end of a long day.
239 Also, using the first approach would still involve size issues
240 because we need to read in the contents of the header section, and
241 give the correct amount of stuff we want to read to the
242 get_bfd_section_contents function. */
244 /* decide which case depending on the size of the header section.
245 The size is as defined in hp-symtab.h */
247 header_section_size
= bfd_section_size (objfile
->obfd
, header_section
);
249 if (header_section_size
== (bfd_size_type
)sizeof (PXDB_header
)) /* pxdb and not doc*/
252 buf
= alloca (sizeof(PXDB_header
));
253 if (!bfd_get_section_contents (sym_bfd
,
256 header_section_size
))
257 error ("bfd_get_section_contents\n");
259 tmp
= bfd_get_32 (sym_bfd
, (bfd_byte
*)(buf
+ sizeof(int)*3));
260 pxdbed
= (tmp
>> 31) & 0x1;
264 else error ("file debug header invalid\n");
266 else /*not pxdbed and doc OR not pxdbed and non doc*/
278 } /* hpread_pxdb_needed */
284 /********************
286 * This flag can be set to zero to use the old
287 * style psymtab (build from a scan of the LNTT)
288 * or to one to try to use the quick look-up
291 int psym_new_style
= 1;
295 /* Code to handle quick lookup-tables follows */
298 /* Some useful macros */
299 #define VALID_FILE(i) ((i) < pxdb_header_p->fd_entries)
300 #define VALID_MODULE(i) ((i) < pxdb_header_p->md_entries)
301 #define VALID_PROC(i) ((i) < pxdb_header_p->pd_entries)
302 #define VALID_CLASS(i) ((i) < pxdb_header_p->cd_entries)
304 #define FILE_START(i) (qFD[i].adrStart)
305 #define MODULE_START(i) (qMD[i].adrStart)
306 #define PROC_START(i) (qPD[i].adrStart)
308 #define FILE_END(i) (qFD[i].adrEnd)
309 #define MODULE_END(i) (qMD[i].adrEnd)
310 #define PROC_END(i) (qPD[i].adrEnd)
312 #define FILE_ISYM(i) (qFD[i].isym)
313 #define MODULE_ISYM(i) (qMD[i].isym)
314 #define PROC_ISYM(i) (qPD[i].isym)
316 #define VALID_CURR_FILE (curr_fd < pxdb_header_p->fd_entries)
317 #define VALID_CURR_MODULE (curr_md < pxdb_header_p->md_entries)
318 #define VALID_CURR_PROC (curr_pd < pxdb_header_p->pd_entries)
319 #define VALID_CURR_CLASS (curr_cd < pxdb_header_p->cd_entries)
321 #define CURR_FILE_START (qFD[curr_fd].adrStart)
322 #define CURR_MODULE_START (qMD[curr_md].adrStart)
323 #define CURR_PROC_START (qPD[curr_pd].adrStart)
325 #define CURR_FILE_END (qFD[curr_fd].adrEnd)
326 #define CURR_MODULE_END (qMD[curr_md].adrEnd)
327 #define CURR_PROC_END (qPD[curr_pd].adrEnd)
329 #define CURR_FILE_ISYM (qFD[curr_fd].isym)
330 #define CURR_MODULE_ISYM (qMD[curr_md].isym)
331 #define CURR_PROC_ISYM (qPD[curr_pd].isym)
333 #define TELL_OBJFILE \
335 if( !told_objfile ) { \
337 warning ("\nIn object file \"%s\":\n", \
344 /* Keeping track of the start/end symbol table (LNTT) indices of
345 psymtabs created so far */
352 static pst_syms_struct
* pst_syms_array
= 0;
354 static pst_syms_count
= 0;
355 static pst_syms_size
= 0;
357 /* used by the TELL_OBJFILE macro */
358 static boolean told_objfile
= 0;
360 /* Set up psymtab symbol index stuff */
366 pst_syms_array
= (pst_syms_struct
*) xmalloc (20 * sizeof (pst_syms_struct
));
369 /* Clean up psymtab symbol index stuff */
375 free (pst_syms_array
);
379 /* Add information about latest psymtab to symbol index table */
381 record_pst_syms (start_sym
, end_sym
)
385 if (++pst_syms_count
> pst_syms_size
)
387 pst_syms_array
= (pst_syms_struct
*) xrealloc (pst_syms_array
,
388 2 * pst_syms_size
* sizeof (pst_syms_struct
));
391 pst_syms_array
[pst_syms_count
- 1].start
= start_sym
;
392 pst_syms_array
[pst_syms_count
- 1].end
= end_sym
;
395 /* Find a suitable symbol table index which can serve as the upper
396 bound of a psymtab that starts at INDEX
398 This scans backwards in the psymtab symbol index table to find a
399 "hole" in which the given index can fit. This is a heuristic!!
400 We don't search the entire table to check for multiple holes,
401 we don't care about overlaps, etc.
403 Return 0 => not found */
406 find_next_pst_start (index
)
411 for (i
= pst_syms_count
- 1; i
>= 0; i
--)
412 if (pst_syms_array
[i
].end
<= index
)
413 return (i
== pst_syms_count
- 1) ? 0 : pst_syms_array
[i
+1].start
- 1;
415 if (pst_syms_array
[0].start
> index
)
416 return pst_syms_array
[0].start
- 1;
423 /* Utility functions to find the ending symbol index for a psymtab */
425 /* Find the next file entry that begins beyond INDEX, and return
426 its starting symbol index - 1.
427 QFD is the file table, CURR_FD is the file entry from where to start,
428 PXDB_HEADER_P as in hpread_quick_traverse (to allow macros to work).
430 Return 0 => not found */
433 find_next_file_isym (index
, qFD
, curr_fd
, pxdb_header_p
)
435 quick_file_entry
*qFD
;
437 PXDB_header_ptr pxdb_header_p
;
439 while (VALID_CURR_FILE
) {
440 if (CURR_FILE_ISYM
>= index
)
441 return CURR_FILE_ISYM
- 1;
447 /* Find the next procedure entry that begins beyond INDEX, and return
448 its starting symbol index - 1.
449 QPD is the procedure table, CURR_PD is the proc entry from where to start,
450 PXDB_HEADER_P as in hpread_quick_traverse (to allow macros to work).
452 Return 0 => not found */
455 find_next_proc_isym (index
, qPD
, curr_pd
, pxdb_header_p
)
457 quick_procedure_entry
*qPD
;
459 PXDB_header_ptr pxdb_header_p
;
461 while (VALID_CURR_PROC
) {
462 if (CURR_PROC_ISYM
>= index
)
463 return CURR_PROC_ISYM
- 1;
469 /* Find the next module entry that begins beyond INDEX, and return
470 its starting symbol index - 1.
471 QMD is the module table, CURR_MD is the modue entry from where to start,
472 PXDB_HEADER_P as in hpread_quick_traverse (to allow macros to work).
474 Return 0 => not found */
477 find_next_module_isym (index
, qMD
, curr_md
, pxdb_header_p
)
479 quick_module_entry
*qMD
;
481 PXDB_header_ptr pxdb_header_p
;
483 while (VALID_CURR_MODULE
) {
484 if (CURR_MODULE_ISYM
>= index
)
485 return CURR_MODULE_ISYM
- 1;
491 /* Scan and record partial symbols for all functions starting from index
492 pointed to by CURR_PD_P, and between code addresses START_ADR and END_ADR.
493 Other parameters are explained in comments below. */
495 /* This used to be inline in hpread_quick_traverse, but now that we do essentially the
496 same thing for two different cases (modules and module-less files), it's better
497 organized in a separate routine, although it does take lots of arguments. pai/1997-10-08 */
500 scan_procs (curr_pd_p
, qPD
, max_procs
, start_adr
, end_adr
, pst
, vt_bits
, objfile
, section_offsets
)
501 int * curr_pd_p
; /* pointer to current proc index */
502 quick_procedure_entry
* qPD
; /* the procedure quick lookup table */
503 int max_procs
; /* number of entries in proc. table */
504 CORE_ADDR start_adr
; /* beginning of code range for current psymtab */
505 CORE_ADDR end_adr
; /* end of code range for current psymtab */
506 struct partial_symtab
* pst
; /* current psymtab */
507 char * vt_bits
; /* strings table of SOM debug space */
508 struct objfile
* objfile
; /* current object file */
509 struct section_offsets
* section_offsets
; /* not really used for HP-UX currently */
511 union dnttentry
*dn_bufp
;
512 int symbol_count
= 0; /* Total number of symbols in this psymtab */
513 int curr_pd
= *curr_pd_p
; /* Convenience variable -- avoid dereferencing pointer all the time */
516 /* Turn this on for lots of debugging information in this routine */
517 static int dumping
= 0;
522 printf ("Scan_procs called, addresses %x to %x, proc %x\n", start_adr
, end_adr
, curr_pd
);
526 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
;
554 printf( "..add %s (demangled %s), index %x to this psymtab\n", rtn_name
, rtn_dem_name
, curr_pd
);
558 /* Check for module-spanning routines.
560 if(CURR_PROC_END
> end_adr
) {
562 warning ("Procedure \"%s\" [0x%x] spans file or module boundaries.", rtn_name
, curr_pd
);
565 /* I asked for this in the hope it would fix bug CHFts22228, but
566 * later decided it's not the right fix. I'm leaving the code
567 * commented out for now in case we decide we actually want to do this.
571 /* Check this routine--if it's a class member function,
572 * add the class to the psymtab. We only need to add
573 * the class once in each module, so check.
575 if( qPD
[curr_pd
].member
) {
577 class = qPD
[curr_pd
].icd
;
578 if( ! B_TST( class_entered
, class)) { /* pai: (temp) class_entered not a parameter */
580 class_name
= &vt_bits
[ (long)qCD
[class].sbClass
];
582 /* Add to both the struct and var namespace */
584 add_psymbol_to_list (
586 strlen( class_name
),
588 LOC_UNDEF
, /* "I have no storage" */
589 &objfile
->global_psymbols
, /* assume classname is global */
591 trans_lang ((enum hp_language
) qPD
[curr_pd
].language
),
594 add_psymbol_to_list (
596 strlen( class_name
),
598 LOC_UNDEF
, /* "I have no storage" */
599 &objfile
->global_psymbols
, /* assume classname is global */
601 trans_lang ((enum hp_language
) qPD
[curr_pd
].language
),
604 B_SET( class_entered
, class ); /* pai: (temp) class_entered not a parameter */
610 /* Add this routine symbol to the list in the objfile. */
611 /* Unfortunately we have to go to the LNTT to determine the
612 * correct list to put it on. An alternative (which the
613 * code used to do) would be to not check and always throw
614 * it on the "static" list. But if we go that route, then
615 * symbol_lookup() needs to be tweaked a bit to account
616 * for the fact that the function might not be found on
617 * the correct list in the psymtab. - RT
619 dn_bufp
= hpread_get_lntt (qPD
[curr_pd
].isym
, objfile
);
620 if (dn_bufp
->dfunc
.global
)
621 add_psymbol_with_dem_name_to_list (
625 strlen( rtn_dem_name
),
627 LOC_BLOCK
, /* "I am a routine" */
628 &objfile
->global_psymbols
,
629 ( qPD
[curr_pd
].adrStart
+ /* Starting address of rtn */
630 ANOFFSET (section_offsets
, SECT_OFF_TEXT
)),
632 trans_lang ((enum hp_language
) qPD
[curr_pd
].language
),
635 add_psymbol_with_dem_name_to_list (
639 strlen( rtn_dem_name
),
641 LOC_BLOCK
, /* "I am a routine" */
642 &objfile
->static_psymbols
,
643 ( qPD
[curr_pd
].adrStart
+ /* Starting address of rtn */
644 ANOFFSET (section_offsets
, SECT_OFF_TEXT
)),
646 trans_lang ((enum hp_language
) qPD
[curr_pd
].language
),
650 *curr_pd_p
= ++curr_pd
; /* bump up count & reflect in caller */
651 } /* loop over procedures */
655 if( symbol_count
== 0 )
656 printf( "Scan_procs: no symbols found!\n");
664 /* Traverse the quick look-up tables, building a set of psymtabs.
666 * This constructs a psymtab for modules and files in the quick lookup
669 * Mostly, modules correspond to compilation units, so we try to
670 * create psymtabs that correspond to modules; however, in some cases
671 * a file can result in a compiled object which does not have a module
672 * entry for it, so in such cases we create a psymtab for the file.
676 hpread_quick_traverse(
677 objfile
, /* The object file descriptor */
678 section_offsets
, /* ?? Null for HP */
679 gntt_bits
, /* GNTT entries, loaded in from the file */
680 vt_bits
, /* VT (string) entries ditto. */
681 pxdb_header_p
) /* Pointer to pxdb header ditto */
683 struct objfile
*objfile
;
684 struct section_offsets
*section_offsets
;
687 PXDB_header_ptr pxdb_header_p
;
689 struct partial_symtab
*pst
;
693 quick_procedure_entry
*qPD
;
694 quick_file_entry
*qFD
;
695 quick_module_entry
*qMD
;
696 quick_class_entry
*qCD
;
700 CORE_ADDR start_adr
; /* current psymtab's starting code addr */
701 CORE_ADDR end_adr
; /* current psymtab's ending code addr */
702 CORE_ADDR next_mod_adr
; /* next module's starting code addr */
703 int curr_pd
; /* current procedure */
704 int curr_fd
; /* current file */
705 int curr_md
; /* current module */
706 int start_sym
; /* current psymtab's starting symbol index */
707 int end_sym
; /* current psymtab's ending symbol index */
708 int max_LNTT_sym_index
;
710 B_TYPE
*class_entered
;
712 struct partial_symbol
**global_syms
; /* We'll be filling in the "global" */
713 struct partial_symbol
**static_syms
; /* and "static" tables in the objfile */
714 /* as we go, so we need a pair of */
715 /* current pointers. */
718 /* Turn this on for lots of debugging information in this routine.
719 You get a blow-by-blow account of quick lookup table reading */
720 static int dumping
= 0;
723 pst
= (struct partial_symtab
*) 0;
725 /* Clear out some globals */
729 /* Demangling style -- if EDG style already set, don't change it,
730 as HP style causes some problems with the KAI EDG compiler */
731 if (current_demangling_style
!= edg_demangling
) {
732 /* Otherwise, ensure that we are using HP style demangling */
733 set_demangling_style (HP_DEMANGLING_STYLE_STRING
);
736 /* First we need to find the starting points of the quick
737 * look-up tables in the GNTT. */
741 qPD
= (quick_procedure_entry_ptr
) addr
;
742 addr
+= pxdb_header_p
->pd_entries
* sizeof( quick_procedure_entry
);
746 printf( "\n Printing routines as we see them\n" );
747 for( i
= 0; VALID_PROC (i
); i
++ ){
748 idx
= (long) qPD
[i
].sbProc
;
749 printf( "%s %x..%x\n", &vt_bits
[idx
],
750 (int) PROC_START (i
),
751 (int) PROC_END (i
) );
756 qFD
= (quick_file_entry_ptr
) addr
;
757 addr
+= pxdb_header_p
->fd_entries
* sizeof( quick_file_entry
);
761 printf( "\n Printing files as we see them\n" );
762 for( i
= 0; VALID_FILE (i
); i
++ ){
763 idx
= (long) qFD
[i
].sbFile
;
764 printf( "%s %x..%x\n", &vt_bits
[idx
],
771 qMD
= (quick_module_entry_ptr
) addr
;
772 addr
+= pxdb_header_p
->md_entries
* sizeof( quick_module_entry
);
776 printf( "\n Printing modules as we see them\n" );
777 for( i
= 0; i
< pxdb_header_p
->md_entries
; i
++ ){
778 idx
= (long) qMD
[i
].sbMod
;
779 printf( "%s\n", &vt_bits
[idx
] );
784 qCD
= (quick_class_entry_ptr
) addr
;
785 addr
+= pxdb_header_p
->cd_entries
* sizeof( quick_class_entry
);
789 printf( "\n Printing classes as we see them\n" );
790 for( i
= 0; VALID_CLASS (i
); i
++ ){
791 idx
= (long) qCD
[i
].sbClass
;
792 printf( "%s\n", &vt_bits
[idx
] );
795 printf( "\n Done with dump, on to build!\n" );
799 /* We need this index only while hp-symtab-read.c expects
800 * a byte offset to the end of the LNTT entries for a given
801 * psymtab. Thus the need for it should go away someday.
803 * When it goes away, then we won't have any need to load the
804 * LNTT from the objfile at psymtab-time, and start-up will be
805 * faster. To make that work, we'll need some way to create
806 * a null pst for the "globals" pseudo-module.
808 max_LNTT_sym_index
= LNTT_SYMCOUNT (objfile
);
810 /* Scan the module descriptors and make a psymtab for each.
812 * We know the MDs, FDs and the PDs are in order by starting
813 * address. We use that fact to traverse all three arrays in
814 * parallel, knowing when the next PD is in a new file
815 * and we need to create a new psymtab.
817 curr_pd
= 0; /* Current procedure entry */
818 curr_fd
= 0; /* Current file entry */
819 curr_md
= 0; /* Current module entry */
821 start_adr
= 0; /* Current psymtab code range */
824 start_sym
= 0; /* Current psymtab symbol range */
827 syms_in_pst
= 0; /* Symbol count for psymtab */
829 /* Psts actually just have pointers into the objfile's
830 * symbol table, not their own symbol tables.
832 global_syms
= objfile
-> global_psymbols
.list
;
833 static_syms
= objfile
-> static_psymbols
.list
;
835 #if 0 /* pai: (temp) we don't need this any more */
836 /* elz: if the first module we see in the table is for
837 end.c, then return immediately with false. This happens
838 for F77 programs, for which there is no MODULE information
839 produced in the debug info.
840 Returning false from this function will make the caller
841 (build_psymbols) scan the table from the beginning and
842 not use the quick lookup tables.
843 F90 has modules so this poses no porblem.
845 if (!strcmp (&vt_bits
[(long)qMD
[0].sbMod
], "end.c"))
849 /* First skip over pseudo-entries with address 0. These represent inlined
850 routines and abstract (uninstantiated) template routines.
851 FIXME: These should be read in and available -- even if we can't set
852 breakpoints, etc., there's some information that can be presented
853 to the user. pai/1997-10-08 */
855 while (VALID_CURR_PROC
&& (CURR_PROC_START
== 0))
858 /* Loop over files, modules, and procedures in code address order. Each
859 time we enter an iteration of this loop, curr_pd points to the first
860 unprocessed procedure, curr_fd points to the first unprocessed file, and
861 curr_md to the first unprocessed module. Each iteration of this loop
862 updates these as required -- any or all of them may be bumpd up
863 each time around. When we exit this loop, we are done with all files
864 and modules in the tables -- there may still be some procedures, however.
866 Note: This code used to loop only over module entries, under the assumption
867 that files can occur via inclusions and are thus unreliable, while a
868 compiled object always corresponds to a module. With CTTI in the HP aCC
869 compiler, it turns out that compiled objects may have only files and no
870 modules; so we have to loop over files and modules, creating psymtabs for
871 either as appropriate. Unfortunately there are some problems (notably:
872 1. the lack of "SRC_FILE_END" entries in the LNTT, 2. the lack of pointers
873 to the ending symbol indices of a module or a file) which make it quite hard
874 to do this correctly. Currently it uses a bunch of heuristics to start and
875 end psymtabs; they seem to work well with most objects generated by aCC, but
876 who knows when that will change... */
878 while (VALID_CURR_FILE
|| VALID_CURR_MODULE
) {
880 char *mod_name_string
;
881 char *full_name_string
;
883 /* First check for modules like "version.c", which have no code
884 * in them but still have qMD entries. They also have no qFD or
885 * qPD entries. Their start address is -1 and their end address
887 if(VALID_CURR_MODULE
&& (CURR_MODULE_START
== -1) && (CURR_MODULE_END
== NULL
)) {
889 mod_name_string
= &vt_bits
[(long) qMD
[curr_md
].sbMod
];
893 printf( "Module with data only %s\n", mod_name_string
);
896 /* We'll skip the rest (it makes error-checking easier), and
897 * just make an empty pst. Right now empty psts are not put
898 * in the pst chain, so all this is for naught, but later it
901 pst
= hpread_start_psymtab( objfile
,
902 section_offsets
, /* ?? */
904 CURR_MODULE_START
, /* Low text address: bogus! */
905 (CURR_MODULE_ISYM
* sizeof (struct dntt_type_block
)),
910 pst
= hpread_end_psymtab (
912 NULL
, /* psymtab_include_list */
913 0, /* includes_used */
914 end_sym
* sizeof (struct dntt_type_block
),
915 /* byte index in LNTT of end */
916 /* = capping symbol offset */
917 /* = LDSYMOFF of nextfile */
918 NULL
, /* text high */
919 NULL
, /* dependency_list */
920 0 ); /* dependencies_used */
922 global_syms
= objfile
->global_psymbols
.next
;
923 static_syms
= objfile
->static_psymbols
.next
;
927 else if (VALID_CURR_MODULE
&&
928 ((CURR_MODULE_START
== 0) || (CURR_MODULE_START
== -1) ||
929 (CURR_MODULE_END
== 0) || (CURR_MODULE_END
== -1))) {
931 warning ("Module \"%s\" [0x%x] has non-standard addresses. It starts at 0x%x, ends at 0x%x, and will be skipped.",
932 mod_name_string
, curr_md
, start_adr
, end_adr
);
933 /* On to next module */
937 /* First check if we are looking at a file with code in it
938 that does not overlap the current module's code range */
940 if (VALID_CURR_FILE
? (VALID_CURR_MODULE
? (CURR_FILE_END
< CURR_MODULE_START
) : 1) : 0) {
942 /* Looking at file not corresponding to any module,
943 create a psymtab for it */
944 full_name_string
= &vt_bits
[(long) qFD
[curr_fd
].sbFile
];
945 start_adr
= CURR_FILE_START
;
946 end_adr
= CURR_FILE_END
;
947 start_sym
= CURR_FILE_ISYM
;
949 /* Check if there are any procedures not handled until now, that
950 begin before the start address of this file, and if so, adjust
951 this module's start address to include them. This handles routines that
952 are in between file or module ranges for some reason (probably
953 indicates a compiler bug */
955 if (CURR_PROC_START
< start_adr
) {
957 warning ("Found procedure \"%s\" [0x%x] that is not in any file or module.",
958 &vt_bits
[(long) qPD
[curr_pd
].sbProc
], curr_pd
);
959 start_adr
= CURR_PROC_START
;
960 if (CURR_PROC_ISYM
< start_sym
)
961 start_sym
= CURR_PROC_ISYM
;
964 /* Sometimes (compiler bug -- COBOL) the module end address is higher
965 than the start address of the next module, so check for that and
966 adjust accordingly */
968 if (VALID_FILE (curr_fd
+ 1) && (FILE_START (curr_fd
+ 1) <= end_adr
)) {
970 warning("File \"%s\" [0x%x] has ending address after starting address of next file; adjusting ending address down.",
971 full_name_string
, curr_fd
);
972 end_adr
= FILE_START (curr_fd
+ 1) - 1; /* Is -4 (or -8 for 64-bit) better? */
974 if (VALID_MODULE (curr_md
) && (CURR_MODULE_START
<= end_adr
)) {
976 warning("File \"%s\" [0x%x] has ending address after starting address of next module; adjusting ending address down.",
977 full_name_string
, curr_fd
);
978 end_adr
= CURR_MODULE_START
- 1; /* Is -4 (or -8 for 64-bit) better? */
984 printf( "Make new psymtab for file %s (%x to %x).\n",
985 full_name_string
, start_adr
, end_adr
);
988 /* Create the basic psymtab, connecting it in the list
989 * for this objfile and pointing its symbol entries
990 * to the current end of the symbol areas in the objfile.
992 * The "ldsymoff" parameter is the byte offset in the LNTT
993 * of the first symbol in this file. Some day we should
994 * turn this into an index (fix in hp-symtab-read.c as well).
995 * And it's not even the right byte offset, as we're using
996 * the size of a union! FIXME! */
997 pst
= hpread_start_psymtab( objfile
,
998 section_offsets
, /* ?? */
1000 start_adr
, /* Low text address */
1001 (start_sym
* sizeof (struct dntt_type_block
)),
1006 /* Set up to only enter each class referenced in this module once. */
1007 class_entered
= malloc( B_BYTES( pxdb_header_p
->cd_entries
));
1008 B_CLRALL( class_entered
, pxdb_header_p
->cd_entries
);
1010 /* Scan the procedure descriptors for procedures in the current
1011 * file, based on the starting addresses. */
1013 syms_in_pst
= scan_procs (&curr_pd
, qPD
, pxdb_header_p
->pd_entries
,
1015 pst
, vt_bits
, objfile
, section_offsets
);
1017 /* Get ending symbol offset */
1020 /* First check for starting index before previous psymtab */
1021 if (pst_syms_count
&& start_sym
< pst_syms_array
[pst_syms_count
- 1].end
) {
1022 end_sym
= find_next_pst_start (start_sym
);
1024 /* Look for next start index of a file or module, or procedure */
1026 int next_file_isym
= find_next_file_isym (start_sym
, qFD
, curr_fd
+ 1, pxdb_header_p
);
1027 int next_module_isym
= find_next_module_isym (start_sym
, qMD
, curr_md
, pxdb_header_p
);
1028 int next_proc_isym
= find_next_proc_isym (start_sym
, qPD
, curr_pd
, pxdb_header_p
);
1030 if (next_file_isym
&& next_module_isym
) {
1031 /* pick lower of next file or module start index */
1032 end_sym
= min (next_file_isym
, next_module_isym
);
1035 /* one of them is zero, pick the other */
1036 end_sym
= max (next_file_isym
, next_module_isym
);
1039 /* As a precaution, check next procedure index too */
1041 end_sym
= next_proc_isym
;
1043 end_sym
= min (end_sym
, next_proc_isym
);
1046 /* Couldn't find procedure, file, or module, use globals as default */
1048 end_sym
= pxdb_header_p
->globals
;
1052 printf ("File psymtab indices: %x to %x\n", start_sym
, end_sym
);
1056 pst
= hpread_end_psymtab (
1058 NULL
, /* psymtab_include_list */
1059 0, /* includes_used */
1060 end_sym
* sizeof (struct dntt_type_block
),
1061 /* byte index in LNTT of end */
1062 /* = capping symbol offset */
1063 /* = LDSYMOFF of nextfile */
1064 end_adr
, /* text high */
1065 NULL
, /* dependency_list */
1066 0 ); /* dependencies_used */
1068 record_pst_syms (start_sym
, end_sym
);
1071 warning ("No symbols in psymtab for file \"%s\" [0x%x].", full_name_string
, curr_fd
);
1075 printf( "Made new psymtab for file %s (%x to %x), sym %x to %x.\n",
1076 full_name_string
, start_adr
, end_adr
, CURR_FILE_ISYM
, end_sym
);
1079 /* Prepare for the next psymtab.
1081 global_syms
= objfile
->global_psymbols
.next
;
1082 static_syms
= objfile
->static_psymbols
.next
;
1083 free( class_entered
);
1086 } /* Psymtab for file */
1088 /* We have a module for which we create a psymtab */
1090 mod_name_string
= &vt_bits
[(long) qMD
[curr_md
].sbMod
];
1092 /* We will include the code ranges of any files that happen to
1093 overlap with this module */
1095 /* So, first pick the lower of the file's and module's start addresses */
1096 start_adr
= CURR_MODULE_START
;
1097 if (VALID_CURR_FILE
) {
1098 if (CURR_FILE_START
< CURR_MODULE_START
) {
1100 warning ("File \"%s\" [0x%x] crosses beginning of module \"%s\".",
1101 &vt_bits
[ (long) qFD
[curr_fd
].sbFile
],
1102 curr_fd
, mod_name_string
);
1104 start_adr
= CURR_FILE_START
;
1108 /* Also pick the lower of the file's and the module's start symbol indices */
1109 start_sym
= CURR_MODULE_ISYM
;
1110 if (VALID_CURR_FILE
&& (CURR_FILE_ISYM
< CURR_MODULE_ISYM
))
1111 start_sym
= CURR_FILE_ISYM
;
1113 /* For the end address, we scan through the files till we find one
1114 that overlaps the current module but ends beyond it; if no such file exists we
1115 simply use the module's start address. (Note, if file entries themselves overlap
1116 we take the longest overlapping extension beyond the end of the module...)
1117 We assume that modules never overlap. */
1119 end_adr
= CURR_MODULE_END
;
1121 if (VALID_CURR_FILE
) {
1122 while (VALID_CURR_FILE
&& (CURR_FILE_START
< end_adr
)) {
1126 printf( "Maybe skipping file %s which overlaps with module %s\n",
1127 &vt_bits
[ (long) qFD
[ curr_fd
].sbFile
], mod_name_string
);
1129 if (CURR_FILE_END
> end_adr
) {
1131 warning ("File \"%s\" [0x%x] crosses end of module \"%s\".",
1132 &vt_bits
[ (long) qFD
[curr_fd
].sbFile
],
1133 curr_fd
, mod_name_string
);
1134 end_adr
= CURR_FILE_END
;
1138 curr_fd
--; /* back up after going too far */
1141 /* Sometimes (compiler bug -- COBOL) the module end address is higher
1142 than the start address of the next module, so check for that and
1143 adjust accordingly */
1145 if (VALID_MODULE (curr_md
+ 1) && (MODULE_START (curr_md
+ 1) <= end_adr
)) {
1147 warning ("Module \"%s\" [0x%x] has ending address after starting address of next module; adjusting ending address down.",
1148 mod_name_string
, curr_md
);
1149 end_adr
= MODULE_START (curr_md
+ 1) - 1; /* Is -4 (or -8 for 64-bit) better? */
1151 if (VALID_FILE (curr_fd
+ 1) && (FILE_START (curr_fd
+ 1) <= end_adr
)) {
1153 warning ("Module \"%s\" [0x%x] has ending address after starting address of next file; adjusting ending address down.",
1154 mod_name_string
, curr_md
);
1155 end_adr
= FILE_START (curr_fd
+ 1) - 1; /* Is -4 (or -8 for 64-bit) better? */
1158 /* Use one file to get the full name for the module. This
1159 * situation can arise if there is executable code in a #include
1160 * file. Each file with code in it gets a qFD. Files which don't
1161 * contribute code don't get a qFD, even if they include files
1165 * int x; int main() {
1166 * #include "rtn.h" return x;
1169 * There will a qFD for "rtn.h",and a qMD for "body.c",
1170 * but no qMD for "rtn.h" or qFD for "body.c"!
1172 * We pick the name of the last file to overlap with this
1173 * module. C convention is to put include files first. In a
1174 * perfect world, we could check names and use the file whose full
1175 * path name ends with the module name. */
1177 if (VALID_CURR_FILE
)
1178 full_name_string
= &vt_bits
[ (long) qFD
[curr_fd
].sbFile
];
1180 full_name_string
= mod_name_string
;
1182 /* Check if there are any procedures not handled until now, that
1183 begin before the start address we have now, and if so, adjust
1184 this psymtab's start address to include them. This handles routines that
1185 are in between file or module ranges for some reason (probably
1186 indicates a compiler bug */
1188 if (CURR_PROC_START
< start_adr
) {
1190 warning ("Found procedure \"%s\" [0x%x] that is not in any file or module.",
1191 &vt_bits
[(long) qPD
[curr_pd
].sbProc
], curr_pd
);
1192 start_adr
= CURR_PROC_START
;
1193 if (CURR_PROC_ISYM
< start_sym
)
1194 start_sym
= CURR_PROC_ISYM
;
1199 printf( "Make new psymtab for module %s (%x to %x), using file %s\n",
1200 mod_name_string
, start_adr
, end_adr
, full_name_string
);
1203 /* Create the basic psymtab, connecting it in the list
1204 * for this objfile and pointing its symbol entries
1205 * to the current end of the symbol areas in the objfile.
1207 * The "ldsymoff" parameter is the byte offset in the LNTT
1208 * of the first symbol in this file. Some day we should
1209 * turn this into an index (fix in hp-symtab-read.c as well).
1210 * And it's not even the right byte offset, as we're using
1211 * the size of a union! FIXME! */
1212 pst
= hpread_start_psymtab( objfile
,
1213 section_offsets
, /* ?? */
1215 start_adr
, /* Low text address */
1216 (start_sym
* sizeof (struct dntt_type_block
)),
1221 /* Set up to only enter each class referenced in this module once. */
1222 class_entered
= malloc( B_BYTES( pxdb_header_p
->cd_entries
));
1223 B_CLRALL( class_entered
, pxdb_header_p
->cd_entries
);
1225 /* Scan the procedure descriptors for procedures in the current
1226 * module, based on the starting addresses. */
1228 syms_in_pst
= scan_procs (&curr_pd
, qPD
, pxdb_header_p
->pd_entries
,
1230 pst
, vt_bits
, objfile
, section_offsets
);
1232 /* Get ending symbol offset */
1235 /* First check for starting index before previous psymtab */
1236 if (pst_syms_count
&& start_sym
< pst_syms_array
[pst_syms_count
- 1].end
) {
1237 end_sym
= find_next_pst_start (start_sym
);
1239 /* Look for next start index of a file or module, or procedure */
1241 int next_file_isym
= find_next_file_isym (start_sym
, qFD
, curr_fd
+ 1, pxdb_header_p
);
1242 int next_module_isym
= find_next_module_isym (start_sym
, qMD
, curr_md
+ 1, pxdb_header_p
);
1243 int next_proc_isym
= find_next_proc_isym (start_sym
, qPD
, curr_pd
, pxdb_header_p
);
1245 if (next_file_isym
&& next_module_isym
) {
1246 /* pick lower of next file or module start index */
1247 end_sym
= min (next_file_isym
, next_module_isym
);
1250 /* one of them is zero, pick the other */
1251 end_sym
= max (next_file_isym
, next_module_isym
);
1254 /* As a precaution, check next procedure index too */
1256 end_sym
= next_proc_isym
;
1258 end_sym
= min (end_sym
, next_proc_isym
);
1261 /* Couldn't find procedure, file, or module, use globals as default */
1263 end_sym
= pxdb_header_p
->globals
;
1267 printf ("Module psymtab indices: %x to %x\n", start_sym
, end_sym
);
1271 pst
= hpread_end_psymtab (
1273 NULL
, /* psymtab_include_list */
1274 0, /* includes_used */
1275 end_sym
* sizeof (struct dntt_type_block
),
1276 /* byte index in LNTT of end */
1277 /* = capping symbol offset */
1278 /* = LDSYMOFF of nextfile */
1279 end_adr
, /* text high */
1280 NULL
, /* dependency_list */
1281 0 ); /* dependencies_used */
1283 record_pst_syms (start_sym
, end_sym
);
1286 warning ("No symbols in psymtab for module \"%s\" [0x%x].", mod_name_string
, curr_md
);
1290 printf( "Made new psymtab for module %s (%x to %x), sym %x to %x.\n",
1291 mod_name_string
, start_adr
, end_adr
, CURR_MODULE_ISYM
, end_sym
);
1295 /* Prepare for the next psymtab.
1297 global_syms
= objfile
->global_psymbols
.next
;
1298 static_syms
= objfile
->static_psymbols
.next
;
1299 free( class_entered
);
1303 } /* psymtab for module */
1304 } /* psymtab for non-bogus file or module */
1305 } /* End of while loop over all files & modules */
1307 /* There may be some routines after all files and modules -- these will get
1308 inserted in a separate new module of their own */
1309 if (VALID_CURR_PROC
) {
1310 start_adr
= CURR_PROC_START
;
1311 end_adr
= qPD
[pxdb_header_p
->pd_entries
-1].adrEnd
;
1313 warning ("Found functions beyond end of all files and modules [0x%x].", curr_pd
);
1316 printf( "Orphan functions at end, PD %d and beyond (%x to %x)\n",
1317 curr_pd
, start_adr
, end_adr
);
1320 pst
= hpread_start_psymtab( objfile
,
1321 section_offsets
, /* ?? */
1323 start_adr
, /* Low text address */
1324 (CURR_PROC_ISYM
* sizeof (struct dntt_type_block
)),
1329 scan_procs (&curr_pd
, qPD
, pxdb_header_p
->pd_entries
,
1331 pst
, vt_bits
, objfile
, section_offsets
);
1333 pst
= hpread_end_psymtab (pst
,
1334 NULL
, /* psymtab_include_list */
1335 0, /* includes_used */
1336 pxdb_header_p
->globals
* sizeof (struct dntt_type_block
),
1337 /* byte index in LNTT of end */
1338 /* = capping symbol offset */
1339 /* = LDSYMOFF of nextfile */
1340 end_adr
, /* text high */
1341 NULL
, /* dependency_list */
1342 0); /* dependencies_used */
1347 /* Now build psts for non-module things (in the tail of
1348 * the LNTT, after the last END MODULE entry).
1350 * If null psts were kept on the chain, this would be
1353 pst
= hpread_start_psymtab( objfile
,
1357 (pxdb_header_p
->globals
1358 * sizeof (struct dntt_type_block
)),
1359 objfile
->global_psymbols
.next
,
1360 objfile
->static_psymbols
.next
);
1361 hpread_end_psymtab( pst
,
1363 (max_LNTT_sym_index
* sizeof (struct dntt_type_block
)),
1372 } /* End of hpread_quick_traverse. */
1375 /* Get appropriate header, based on pxdb type.
1376 Return value: 1 if ok, 0 if not */
1378 hpread_get_header( objfile
, pxdb_header_p
)
1379 struct objfile
*objfile
;
1380 PXDB_header_ptr pxdb_header_p
;
1382 asection
*pinfo_section
, *debug_section
, *header_section
;
1385 /* Turn on for debugging information
1387 static int dumping
= 0;
1390 header_section
= bfd_get_section_by_name (objfile
->obfd
, "$HEADER$");
1391 if( !header_section
) {
1392 /* We don't have either PINFO or DEBUG sections. But
1393 * stuff like "libc.sl" has no debug info. There's no
1394 * need to warn the user of this, as it may be ok. The
1395 * caller will figure it out and issue any needed
1400 printf( "==No debug info at all for %s.\n", objfile
->name
);
1406 /* We would like either a $DEBUG$ or $PINFO$ section.
1407 * Once we know which, we can understand the header
1408 * data (which we have defined to suit the more common
1411 debug_section
= bfd_get_section_by_name (objfile
->obfd
, "$DEBUG$" );
1412 pinfo_section
= bfd_get_section_by_name (objfile
->obfd
, "$PINFO$" );
1413 if( debug_section
) {
1414 /* The expected case: normal pxdb header.
1416 bfd_get_section_contents( objfile
->obfd
, header_section
,
1417 pxdb_header_p
, 0, sizeof( PXDB_header
));
1419 if( !pxdb_header_p
->pxdbed
) {
1420 /* This shouldn't happen if we check in "symfile.c".
1423 } /* DEBUG section */
1426 else if( pinfo_section
) {
1427 /* The DOC case; we need to translate this into a
1430 DOC_info_PXDB_header doc_header
;
1434 printf( "==OOps, PINFO, let's try to handle this, %s.\n", objfile
->name
);
1438 bfd_get_section_contents( objfile
->obfd
,
1441 sizeof( DOC_info_PXDB_header
));
1443 if( !doc_header
.pxdbed
) {
1444 /* This shouldn't happen if we check in "symfile.c".
1446 warning ("File \"%s\" not processed by pxdb!", objfile
->name
);
1450 /* Copy relevent fields to standard header passed in.
1452 pxdb_header_p
->pd_entries
= doc_header
.pd_entries
;
1453 pxdb_header_p
->fd_entries
= doc_header
.fd_entries
;
1454 pxdb_header_p
->md_entries
= doc_header
.md_entries
;
1455 pxdb_header_p
->pxdbed
= doc_header
.pxdbed
;
1456 pxdb_header_p
->bighdr
= doc_header
.bighdr
;
1457 pxdb_header_p
->sa_header
= doc_header
.sa_header
;
1458 pxdb_header_p
->inlined
= doc_header
.inlined
;
1459 pxdb_header_p
->globals
= doc_header
.globals
;
1460 pxdb_header_p
->time
= doc_header
.time
;
1461 pxdb_header_p
->pg_entries
= doc_header
.pg_entries
;
1462 pxdb_header_p
->functions
= doc_header
.functions
;
1463 pxdb_header_p
->files
= doc_header
.files
;
1464 pxdb_header_p
->cd_entries
= doc_header
.cd_entries
;
1465 pxdb_header_p
->aa_entries
= doc_header
.aa_entries
;
1466 pxdb_header_p
->oi_entries
= doc_header
.oi_entries
;
1467 pxdb_header_p
->version
= doc_header
.version
;
1468 } /* PINFO section */
1474 printf( "==No debug info at all for %s.\n", objfile
->name
);
1482 } /* End of hpread_get_header */
1483 #endif /* QUICK_LOOK_UP */
1486 /* Initialization for reading native HP C debug symbols from OBJFILE.
1488 Its only purpose in life is to set up the symbol reader's private
1489 per-objfile data structures, and read in the raw contents of the debug
1490 sections (attaching pointers to the debug info into the private data
1493 Since BFD doesn't know how to read debug symbols in a format-independent
1494 way (and may never do so...), we have to do it ourselves. Note we may
1495 be called on a file without native HP C debugging symbols.
1497 FIXME, there should be a cleaner peephole into the BFD environment
1501 hpread_symfile_init (objfile
)
1502 struct objfile
*objfile
;
1504 asection
*vt_section
, *slt_section
, *lntt_section
, *gntt_section
;
1506 /* Allocate struct to keep track of the symfile */
1507 objfile
->sym_private
= (PTR
)
1508 xmmalloc (objfile
->md
, sizeof (struct hpread_symfile_info
));
1509 memset (objfile
->sym_private
, 0, sizeof (struct hpread_symfile_info
));
1511 /* We haven't read in any types yet. */
1512 TYPE_VECTOR (objfile
) = 0;
1514 /* Read in data from the $GNTT$ subspace. */
1515 gntt_section
= bfd_get_section_by_name (objfile
->obfd
, "$GNTT$");
1520 = obstack_alloc (&objfile
->symbol_obstack
,
1521 bfd_section_size (objfile
->obfd
, gntt_section
));
1523 bfd_get_section_contents (objfile
->obfd
, gntt_section
, GNTT (objfile
),
1524 0, bfd_section_size (objfile
->obfd
, gntt_section
));
1526 GNTT_SYMCOUNT (objfile
)
1527 = bfd_section_size (objfile
->obfd
, gntt_section
)
1528 / sizeof (struct dntt_type_block
);
1530 /* Read in data from the $LNTT$ subspace. Also keep track of the number
1533 * FIXME: this could be moved into the psymtab-to-symtab expansion
1534 * code, and save startup time. At the moment this data is
1535 * still used, though. We'd need a way to tell hp-symtab-read.c
1536 * whether or not to load the LNTT.
1538 lntt_section
= bfd_get_section_by_name (objfile
->obfd
, "$LNTT$");
1543 = obstack_alloc (&objfile
->symbol_obstack
,
1544 bfd_section_size (objfile
->obfd
, lntt_section
));
1546 bfd_get_section_contents (objfile
->obfd
, lntt_section
, LNTT (objfile
),
1547 0, bfd_section_size (objfile
->obfd
, lntt_section
));
1549 LNTT_SYMCOUNT (objfile
)
1550 = bfd_section_size (objfile
->obfd
, lntt_section
)
1551 / sizeof (struct dntt_type_block
);
1553 /* Read in data from the $SLT$ subspace. $SLT$ contains information
1554 on source line numbers. */
1555 slt_section
= bfd_get_section_by_name (objfile
->obfd
, "$SLT$");
1560 obstack_alloc (&objfile
->symbol_obstack
,
1561 bfd_section_size (objfile
->obfd
, slt_section
));
1563 bfd_get_section_contents (objfile
->obfd
, slt_section
, SLT (objfile
),
1564 0, bfd_section_size (objfile
->obfd
, slt_section
));
1566 /* Read in data from the $VT$ subspace. $VT$ contains things like
1567 names and constants. Keep track of the number of symbols in the VT. */
1568 vt_section
= bfd_get_section_by_name (objfile
->obfd
, "$VT$");
1572 VT_SIZE (objfile
) = bfd_section_size (objfile
->obfd
, vt_section
);
1575 (char *) obstack_alloc (&objfile
->symbol_obstack
,
1578 bfd_get_section_contents (objfile
->obfd
, vt_section
, VT (objfile
),
1579 0, VT_SIZE (objfile
));
1582 /* Scan and build partial symbols for a symbol file.
1584 * The minimal symbol table (either SOM or HP a.out) has already been
1585 * read in; all we need to do is setup partial symbols based on the
1586 * native debugging information.
1588 * Note that the minimal table is produced by the linker, and has
1589 * only global routines in it; the psymtab is based on compiler-
1590 * generated debug information and has non-global
1591 * routines in it as well as files and class information.
1593 * We assume hpread_symfile_init has been called to initialize the
1594 * symbol reader's private data structures.
1596 * SECTION_OFFSETS contains offsets relative to which the symbols in the
1597 * various sections are (depending where the sections were actually loaded).
1598 * MAINLINE is true if we are reading the main symbol table (as
1599 * opposed to a shared lib or dynamically loaded file).
1602 hpread_build_psymtabs (objfile
, section_offsets
, mainline
)
1603 struct objfile
*objfile
;
1604 struct section_offsets
*section_offsets
;
1609 /* Turn this on to get debugging output.
1611 static int dumping
= 0;
1615 int past_first_source_file
= 0;
1616 struct cleanup
*old_chain
;
1618 int hp_symnum
, symcount
, i
;
1621 union dnttentry
*dn_bufp
;
1627 /* Current partial symtab */
1628 struct partial_symtab
*pst
;
1630 /* List of current psymtab's include files */
1631 char **psymtab_include_list
;
1632 int includes_allocated
;
1635 /* Index within current psymtab dependency list */
1636 struct partial_symtab
**dependency_list
;
1637 int dependencies_used
, dependencies_allocated
;
1639 /* Just in case the stabs reader left turds lying around. */
1640 free_pending_blocks ();
1641 make_cleanup (really_free_pendings
, 0);
1643 pst
= (struct partial_symtab
*) 0;
1645 /* We shouldn't use alloca, instead use malloc/free. Doing so avoids
1646 a number of problems with cross compilation and creating useless holes
1647 in the stack when we have to allocate new entries. FIXME. */
1649 includes_allocated
= 30;
1651 psymtab_include_list
= (char **) alloca (includes_allocated
*
1654 dependencies_allocated
= 30;
1655 dependencies_used
= 0;
1657 (struct partial_symtab
**) alloca (dependencies_allocated
*
1658 sizeof (struct partial_symtab
*));
1660 old_chain
= make_cleanup (free_objfile
, objfile
);
1662 last_source_file
= 0;
1664 #ifdef QUICK_LOOK_UP
1666 /* Begin code for new-style loading of quick look-up tables.
1669 /* elz: this checks whether the file has beeen processed by pxdb.
1670 If not we would like to try to read the psymbols in
1671 anyway, but it turns out to be not so easy. So this could
1672 actually be commented out, but I leave it in, just in case
1673 we decide to add support for non-pxdb-ed stuff in the future.
1676 abfd
= symfile_bfd_open (objfile
->name
);
1677 if (!hpread_pxdb_needed(abfd
))
1679 if ( psym_new_style
) {
1680 PXDB_header pxdb_header
;
1681 int found_modules_in_program
;
1683 if( hpread_get_header( objfile
, &pxdb_header
)) {
1684 /* Build a minimal table. No types, no global variables,
1685 * no include files....
1689 printf( "\nNew method for %s\n", objfile
->name
);
1692 /* elz: quick_traverse returns true if it found
1693 some modules in the main source file, other
1695 In C and C++, all the files have MODULES entries
1696 in the LNTT, and the quick table traverse is all
1697 based on finding these MODULES entries. Without
1698 those it cannot work.
1699 It happens that F77 programs don't have MODULES
1700 so the quick traverse gets confused. F90 programs
1701 have modules, and the quick method still works.
1702 So, if modules (other than those in end.c) are
1703 not found we give up on the quick table stuff,
1704 and fall back on the slower method
1706 found_modules_in_program
= hpread_quick_traverse(
1713 discard_cleanups (old_chain
);
1715 /* Set up to scan the global section of the LNTT.
1717 * This field is not always correct: if there are
1718 * no globals, it will point to the last record in
1719 * the regular LNTT, which is usually an END MODULE.
1721 * Since it might happen that there could be a file
1722 * with just one global record, there's no way to
1723 * tell other than by looking at the record, so that's
1726 if (found_modules_in_program
)
1727 scan_start
= pxdb_header
.globals
;
1735 printf( "\nGoing on to old method for %s\n", objfile
->name
);
1739 } /* End of new method code */
1740 } /* end of if pxdb exists */
1742 * elz: if pxdb does not exists on the system, then scan the whole debug info
1743 * Actually this will never be reached because we error out in case there
1744 * is no pxdb on the system. It turns out that the debug info cannot be
1745 * handled the same way as after bxdb has been run, and gdb gets very
1746 * very confused. Ileave this in anyway, in case one day we want to
1747 * support non pxdb-ed files.
1749 else scan_start
= 0;
1751 bfd_close(abfd
); /*close the bfd we opened to check for pxdb*/
1753 } /*end of ifdef QUICK_LOOK_UP*/
1755 scan_start
= 0; /* if we don't want quick lookup tables start
1756 from the beginning */
1759 /* Make two passes, one over the GNTT symbols, the other for the
1762 * JB comment: above isn't true--they only make one pass, over
1765 for (i
= 0; i
< 1; i
++)
1767 int within_function
= 0;
1770 symcount
= GNTT_SYMCOUNT (objfile
);
1772 symcount
= LNTT_SYMCOUNT (objfile
);
1775 for (hp_symnum
= scan_start
; hp_symnum
< symcount
; hp_symnum
++)
1779 dn_bufp
= hpread_get_gntt (hp_symnum
, objfile
);
1781 dn_bufp
= hpread_get_lntt (hp_symnum
, objfile
);
1783 if (dn_bufp
->dblock
.extension
)
1786 /* Only handle things which are necessary for minimal symbols.
1787 everything else is ignored. */
1788 switch (dn_bufp
->dblock
.kind
)
1790 case DNTT_TYPE_SRCFILE
:
1792 #ifdef QUICK_LOOK_UP
1793 if (scan_start
== hp_symnum
1794 && symcount
== hp_symnum
+ 1) {
1796 * If there are NO globals in an executable,
1797 * PXDB's index to the globals will point to
1798 * the last record in the file, which
1799 * could be this record. (this happened for F77 libraries)
1800 * ignore it and be done!
1806 /* A source file of some kind. Note this may simply
1807 be an included file. */
1808 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
1810 /* Check if this is the source file we are already working
1812 if (pst
&& !strcmp (namestring
, pst
->filename
))
1815 /* Check if this is an include file, if so check if we have
1816 already seen it. Add it to the include list */
1817 p
= strrchr (namestring
, '.');
1818 if (!strcmp (p
, ".h"))
1823 for (j
= 0; j
< includes_used
; j
++)
1824 if (!strcmp (namestring
, psymtab_include_list
[j
]))
1832 /* Add it to the list of includes seen so far and
1833 allocate more include space if necessary. */
1834 psymtab_include_list
[includes_used
++] = namestring
;
1835 if (includes_used
>= includes_allocated
)
1837 char **orig
= psymtab_include_list
;
1839 psymtab_include_list
= (char **)
1840 alloca ((includes_allocated
*= 2) *
1842 memcpy ((PTR
) psymtab_include_list
, (PTR
) orig
,
1843 includes_used
* sizeof (char *));
1852 pst
->filename
= (char *)
1853 obstack_alloc (&pst
->objfile
->psymbol_obstack
,
1854 strlen (namestring
) + 1);
1855 strcpy (pst
->filename
, namestring
);
1862 /* This is a bonafide new source file.
1863 End the current partial symtab and start a new one. */
1865 if (pst
&& past_first_source_file
)
1867 hpread_end_psymtab (pst
, psymtab_include_list
,
1870 * sizeof (struct dntt_type_block
)),
1872 dependency_list
, dependencies_used
);
1873 pst
= (struct partial_symtab
*) 0;
1875 dependencies_used
= 0;
1878 past_first_source_file
= 1;
1880 valu
= hpread_get_textlow (i
, hp_symnum
, objfile
, symcount
);
1881 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1882 pst
= hpread_start_psymtab (objfile
, section_offsets
,
1885 * sizeof (struct dntt_type_block
)),
1886 objfile
->global_psymbols
.next
,
1887 objfile
->static_psymbols
.next
);
1893 case DNTT_TYPE_MODULE
:
1894 /* A source file. It's still unclear to me what the
1895 real difference between a DNTT_TYPE_SRCFILE and DNTT_TYPE_MODULE
1896 is supposed to be. */
1898 /* First end the previous psymtab */
1900 hpread_end_psymtab (pst
, psymtab_include_list
, includes_used
,
1902 * sizeof (struct dntt_type_block
)),
1904 dependency_list
, dependencies_used
);
1905 pst
= (struct partial_symtab
*) 0;
1907 dependencies_used
= 0;
1911 /* Now begin a new module and a new psymtab for it */
1912 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
1913 valu
= hpread_get_textlow (i
, hp_symnum
, objfile
, symcount
);
1914 valu
+= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1916 pst
= hpread_start_psymtab (objfile
, section_offsets
,
1919 * sizeof (struct dntt_type_block
)),
1920 objfile
->global_psymbols
.next
,
1921 objfile
->static_psymbols
.next
);
1927 case DNTT_TYPE_FUNCTION
:
1928 case DNTT_TYPE_ENTRY
:
1929 /* The beginning of a function. DNTT_TYPE_ENTRY may also denote
1930 a secondary entry point. */
1931 valu
= dn_bufp
->dfunc
.hiaddr
+ ANOFFSET (section_offsets
,
1933 if (valu
> texthigh
)
1935 valu
= dn_bufp
->dfunc
.lowaddr
+
1936 ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1937 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
1938 if (dn_bufp
->dfunc
.global
)
1939 add_psymbol_to_list (namestring
, strlen (namestring
),
1940 VAR_NAMESPACE
, LOC_BLOCK
,
1941 &objfile
->global_psymbols
, valu
,
1942 0, language_unknown
, objfile
);
1944 add_psymbol_to_list (namestring
, strlen (namestring
),
1945 VAR_NAMESPACE
, LOC_BLOCK
,
1946 &objfile
->static_psymbols
, valu
,
1947 0, language_unknown
, objfile
);
1948 within_function
= 1;
1951 case DNTT_TYPE_DOC_FUNCTION
:
1952 valu
= dn_bufp
->ddocfunc
.hiaddr
+ ANOFFSET (section_offsets
,
1954 if (valu
> texthigh
)
1956 valu
= dn_bufp
->ddocfunc
.lowaddr
+
1957 ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
1958 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
1959 if (dn_bufp
->ddocfunc
.global
)
1960 add_psymbol_to_list (namestring
, strlen (namestring
),
1961 VAR_NAMESPACE
, LOC_BLOCK
,
1962 &objfile
->global_psymbols
, valu
,
1963 0, language_unknown
, objfile
);
1965 add_psymbol_to_list (namestring
, strlen (namestring
),
1966 VAR_NAMESPACE
, LOC_BLOCK
,
1967 &objfile
->static_psymbols
, valu
,
1968 0, language_unknown
, objfile
);
1969 within_function
= 1;
1972 case DNTT_TYPE_BEGIN
:
1974 /* We don't check MODULE end here, because there can be
1975 symbols beyond the module end which properly belong to the
1976 current psymtab -- so we wait till the next MODULE start */
1979 #ifdef QUICK_LOOK_UP
1980 if (scan_start
== hp_symnum
1981 && symcount
== hp_symnum
+ 1) {
1983 * If there are NO globals in an executable,
1984 * PXDB's index to the globals will point to
1985 * the last record in the file, which is
1986 * probably an END MODULE, i.e. this record.
1987 * ignore it and be done!
1992 /* Scope block begin/end. We only care about function
1993 and file blocks right now. */
1995 if ((dn_bufp
->dend
.endkind
== DNTT_TYPE_FUNCTION
) ||
1996 (dn_bufp
->dend
.endkind
== DNTT_TYPE_DOC_FUNCTION
))
1997 within_function
= 0;
2000 case DNTT_TYPE_SVAR
:
2001 case DNTT_TYPE_DVAR
:
2002 case DNTT_TYPE_TYPEDEF
:
2003 case DNTT_TYPE_TAGDEF
:
2005 /* Variables, typedefs an the like. */
2006 enum address_class storage
;
2007 namespace_enum
namespace;
2009 /* Don't add locals to the partial symbol table. */
2011 && (dn_bufp
->dblock
.kind
== DNTT_TYPE_SVAR
2012 || dn_bufp
->dblock
.kind
== DNTT_TYPE_DVAR
))
2015 /* TAGDEFs go into the structure namespace. */
2016 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_TAGDEF
)
2017 namespace = STRUCT_NAMESPACE
;
2019 namespace = VAR_NAMESPACE
;
2021 /* What kind of "storage" does this use? */
2022 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_SVAR
)
2023 storage
= LOC_STATIC
;
2024 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_DVAR
2025 && dn_bufp
->ddvar
.regvar
)
2026 storage
= LOC_REGISTER
;
2027 else if (dn_bufp
->dblock
.kind
== DNTT_TYPE_DVAR
)
2028 storage
= LOC_LOCAL
;
2030 storage
= LOC_UNDEF
;
2032 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
2034 pst
= hpread_start_psymtab (objfile
, section_offsets
,
2037 * sizeof (struct dntt_type_block
)),
2038 objfile
->global_psymbols
.next
,
2039 objfile
->static_psymbols
.next
);
2042 /* Compute address of the data symbol */
2043 valu
= dn_bufp
->dsvar
.location
;
2044 /* Relocate in case it's in a shared library */
2045 if (storage
== LOC_STATIC
)
2046 valu
+= ANOFFSET (section_offsets
, SECT_OFF_DATA
);
2048 /* Luckily, dvar, svar, typedef, and tagdef all
2049 * have their "global" bit in the same place, so it works
2050 * (though it's bad programming practice) to reference
2051 * "dsvar.global" even though we may be looking at
2052 * any of the above four types.
2054 if (dn_bufp
->dsvar
.global
)
2056 add_psymbol_to_list (namestring
, strlen (namestring
),
2058 &objfile
->global_psymbols
,
2060 0, language_unknown
, objfile
);
2064 add_psymbol_to_list (namestring
, strlen (namestring
),
2066 &objfile
->static_psymbols
,
2068 0, language_unknown
, objfile
);
2071 /* For TAGDEF's, the above code added the tagname to the
2072 * struct namespace. This will cause tag "t" to be found
2073 * on a reference of the form "(struct t) x". But for
2074 * C++ classes, "t" will also be a typename, which we
2075 * want to find on a reference of the form "ptype t".
2076 * Therefore, we also add "t" to the var namespace.
2077 * Do the same for enum's due to the way aCC generates
2078 * debug info for these (see more extended comment
2079 * in hp-symtab-read.c).
2080 * We do the same for templates, so that "ptype t"
2081 * where "t" is a template also works.
2083 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_TAGDEF
&&
2084 dn_bufp
->dtype
.type
.dnttp
.index
< LNTT_SYMCOUNT (objfile
)) {
2085 int global
= dn_bufp
->dtag
.global
;
2086 /* Look ahead to see if it's a C++ class */
2087 dn_bufp
= hpread_get_lntt (dn_bufp
->dtype
.type
.dnttp
.index
, objfile
);
2088 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_CLASS
||
2089 dn_bufp
->dblock
.kind
== DNTT_TYPE_ENUM
||
2090 dn_bufp
->dblock
.kind
== DNTT_TYPE_TEMPLATE
) {
2092 add_psymbol_to_list (namestring
, strlen (namestring
),
2093 VAR_NAMESPACE
, storage
,
2094 &objfile
->global_psymbols
,
2095 dn_bufp
->dsvar
.location
,
2096 0, language_unknown
, objfile
);
2098 add_psymbol_to_list (namestring
, strlen (namestring
),
2099 VAR_NAMESPACE
, storage
,
2100 &objfile
->static_psymbols
,
2101 dn_bufp
->dsvar
.location
,
2102 0, language_unknown
, objfile
);
2109 case DNTT_TYPE_MEMENUM
:
2110 case DNTT_TYPE_CONST
:
2111 /* Constants and members of enumerated types. */
2112 SET_NAMESTRING (dn_bufp
, &namestring
, objfile
);
2115 pst
= hpread_start_psymtab (objfile
, section_offsets
,
2118 * sizeof (struct dntt_type_block
)),
2119 objfile
->global_psymbols
.next
,
2120 objfile
->static_psymbols
.next
);
2122 if (dn_bufp
->dconst
.global
)
2123 add_psymbol_to_list (namestring
, strlen (namestring
),
2124 VAR_NAMESPACE
, LOC_CONST
,
2125 &objfile
->global_psymbols
, 0,
2126 0, language_unknown
, objfile
);
2128 add_psymbol_to_list (namestring
, strlen (namestring
),
2129 VAR_NAMESPACE
, LOC_CONST
,
2130 &objfile
->static_psymbols
, 0,
2131 0, language_unknown
, objfile
);
2139 /* End any pending partial symbol table.
2143 hpread_end_psymtab (pst
, psymtab_include_list
, includes_used
,
2144 hp_symnum
* sizeof (struct dntt_type_block
),
2145 0, dependency_list
, dependencies_used
);
2148 discard_cleanups (old_chain
);
2151 /* Perform any local cleanups required when we are done with a particular
2152 objfile. I.E, we are in the process of discarding all symbol information
2153 for an objfile, freeing up all memory held for it, and unlinking the
2154 objfile struct from the global list of known objfiles. */
2157 hpread_symfile_finish (objfile
)
2158 struct objfile
*objfile
;
2160 if (objfile
->sym_private
!= NULL
)
2162 mfree (objfile
->md
, objfile
->sym_private
);
2167 /* The remaining functions are all for internal use only. */
2169 /* Various small functions to get entries in the debug symbol sections. */
2172 hpread_get_lntt (index
, objfile
)
2174 struct objfile
*objfile
;
2176 return (union dnttentry
*)
2177 &(LNTT (objfile
)[(index
* sizeof (struct dntt_type_block
))]);
2180 static union dnttentry
*
2181 hpread_get_gntt (index
, objfile
)
2183 struct objfile
*objfile
;
2185 return (union dnttentry
*)
2186 &(GNTT (objfile
)[(index
* sizeof (struct dntt_type_block
))]);
2190 hpread_get_slt (index
, objfile
)
2192 struct objfile
*objfile
;
2194 return (union sltentry
*)&(SLT (objfile
)[index
* sizeof (union sltentry
)]);
2197 /* Get the low address associated with some symbol (typically the start
2198 of a particular source file or module). Since that information is not
2199 stored as part of the DNTT_TYPE_MODULE or DNTT_TYPE_SRCFILE symbol we must infer it from
2200 the existance of DNTT_TYPE_FUNCTION symbols. */
2202 static unsigned long
2203 hpread_get_textlow (global
, index
, objfile
, symcount
)
2206 struct objfile
*objfile
;
2209 union dnttentry
*dn_bufp
;
2210 struct minimal_symbol
*msymbol
;
2212 /* Look for a DNTT_TYPE_FUNCTION symbol. */
2213 if (index
< symcount
) /* symcount is the number of symbols in */
2214 { /* the dbinfo, LNTT table*/
2218 dn_bufp
= hpread_get_gntt (index
++, objfile
);
2220 dn_bufp
= hpread_get_lntt (index
++, objfile
);
2221 } while (dn_bufp
->dblock
.kind
!= DNTT_TYPE_FUNCTION
2222 && dn_bufp
->dblock
.kind
!= DNTT_TYPE_DOC_FUNCTION
2223 && dn_bufp
->dblock
.kind
!= DNTT_TYPE_END
2224 && index
< symcount
);
2227 /* Avoid going past a DNTT_TYPE_END when looking for a DNTT_TYPE_FUNCTION. This
2228 might happen when a sourcefile has no functions. */
2229 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_END
)
2232 /* Avoid going past the end of the LNTT file */
2233 if (index
== symcount
)
2236 /* The minimal symbols are typically more accurate for some reason. */
2237 if (dn_bufp
->dblock
.kind
== DNTT_TYPE_FUNCTION
)
2238 msymbol
= lookup_minimal_symbol (dn_bufp
->dfunc
.name
+ VT (objfile
), NULL
,
2240 else /* must be a DNTT_TYPE_DOC_FUNCTION */
2241 msymbol
= lookup_minimal_symbol (dn_bufp
->ddocfunc
.name
+ VT (objfile
), NULL
,
2245 return SYMBOL_VALUE_ADDRESS (msymbol
);
2247 return dn_bufp
->dfunc
.lowaddr
;
2250 /* Allocate and partially fill a partial symtab. It will be
2251 completely filled at the end of the symbol list.
2253 SYMFILE_NAME is the name of the symbol-file we are reading from, and ADDR
2254 is the address relative to which its symbols are (incremental) or 0
2257 static struct partial_symtab
*
2258 hpread_start_psymtab (objfile
, section_offsets
,
2259 filename
, textlow
, ldsymoff
, global_syms
, static_syms
)
2260 struct objfile
*objfile
;
2261 struct section_offsets
*section_offsets
;
2265 struct partial_symbol
**global_syms
;
2266 struct partial_symbol
**static_syms
;
2268 int offset
= ANOFFSET (section_offsets
, SECT_OFF_TEXT
);
2269 extern void hpread_psymtab_to_symtab();
2270 struct partial_symtab
*result
=
2271 start_psymtab_common (objfile
, section_offsets
,
2272 filename
, textlow
, global_syms
, static_syms
);
2274 result
->textlow
+= offset
;
2275 result
->read_symtab_private
= (char *)
2276 obstack_alloc (&objfile
->psymbol_obstack
, sizeof (struct symloc
));
2277 LDSYMOFF (result
) = ldsymoff
;
2278 result
->read_symtab
= hpread_psymtab_to_symtab
;
2284 /* Close off the current usage of PST.
2285 Returns PST or NULL if the partial symtab was empty and thrown away.
2287 capping_symbol_offset --Byte index in LNTT or GNTT of the
2288 last symbol processed during the build
2289 of the previous pst.
2291 FIXME: List variables and peculiarities of same. */
2293 static struct partial_symtab
*
2294 hpread_end_psymtab (pst
, include_list
, num_includes
, capping_symbol_offset
,
2295 capping_text
, dependency_list
, number_dependencies
)
2296 struct partial_symtab
*pst
;
2297 char **include_list
;
2299 int capping_symbol_offset
;
2300 CORE_ADDR capping_text
;
2301 struct partial_symtab
**dependency_list
;
2302 int number_dependencies
;
2305 struct objfile
*objfile
= pst
-> objfile
;
2306 int offset
= ANOFFSET (pst
->section_offsets
, SECT_OFF_TEXT
);
2309 /* Turn on to see what kind of a psymtab we've built.
2311 static int dumping
= 0;
2314 if (capping_symbol_offset
!= -1)
2315 LDSYMLEN(pst
) = capping_symbol_offset
- LDSYMOFF(pst
);
2318 pst
->texthigh
= capping_text
+ offset
;
2320 pst
->n_global_syms
=
2321 objfile
->global_psymbols
.next
- (objfile
->global_psymbols
.list
+ pst
->globals_offset
);
2322 pst
->n_static_syms
=
2323 objfile
->static_psymbols
.next
- (objfile
->static_psymbols
.list
+ pst
->statics_offset
);
2328 "\nPst %s, LDSYMOFF %x (%x), LDSYMLEN %x (%x), globals %d, statics %d\n",
2331 LDSYMOFF(pst
)/sizeof(struct dntt_type_block
),
2333 LDSYMLEN(pst
)/sizeof(struct dntt_type_block
),
2334 pst
->n_global_syms
, pst
->n_static_syms
);
2338 pst
->number_of_dependencies
= number_dependencies
;
2339 if (number_dependencies
)
2341 pst
->dependencies
= (struct partial_symtab
**)
2342 obstack_alloc (&objfile
->psymbol_obstack
,
2343 number_dependencies
* sizeof (struct partial_symtab
*));
2344 memcpy (pst
->dependencies
, dependency_list
,
2345 number_dependencies
* sizeof (struct partial_symtab
*));
2348 pst
->dependencies
= 0;
2350 for (i
= 0; i
< num_includes
; i
++)
2352 struct partial_symtab
*subpst
=
2353 allocate_psymtab (include_list
[i
], objfile
);
2355 subpst
->section_offsets
= pst
->section_offsets
;
2356 subpst
->read_symtab_private
=
2357 (char *) obstack_alloc (&objfile
->psymbol_obstack
,
2358 sizeof (struct symloc
));
2362 subpst
->texthigh
= 0;
2364 /* We could save slight bits of space by only making one of these,
2365 shared by the entire set of include files. FIXME-someday. */
2366 subpst
->dependencies
= (struct partial_symtab
**)
2367 obstack_alloc (&objfile
->psymbol_obstack
,
2368 sizeof (struct partial_symtab
*));
2369 subpst
->dependencies
[0] = pst
;
2370 subpst
->number_of_dependencies
= 1;
2372 subpst
->globals_offset
=
2373 subpst
->n_global_syms
=
2374 subpst
->statics_offset
=
2375 subpst
->n_static_syms
= 0;
2379 subpst
->read_symtab
= pst
->read_symtab
;
2382 sort_pst_symbols (pst
);
2384 /* If there is already a psymtab or symtab for a file of this name, remove it.
2385 (If there is a symtab, more drastic things also happen.)
2386 This happens in VxWorks. */
2387 free_named_symtabs (pst
->filename
);
2389 if (num_includes
== 0
2390 && number_dependencies
== 0
2391 && pst
->n_global_syms
== 0
2392 && pst
->n_static_syms
== 0)
2394 /* Throw away this psymtab, it's empty. We can't deallocate it, since
2395 it is on the obstack, but we can forget to chain it on the list. */
2396 /* Empty psymtabs happen as a result of header files which don't have
2397 any symbols in them. There can be a lot of them. But this check
2398 is wrong, in that a psymtab with N_SLINE entries but nothing else
2399 is not empty, but we don't realize that. Fixing that without slowing
2400 things down might be tricky.
2402 * It's also wrong if we're using the quick look-up tables, as
2403 * we can get empty psymtabs from modules with no routines in
2407 discard_psymtab (pst
);
2409 /* Indicate that psymtab was thrown away. */
2410 pst
= (struct partial_symtab
*)NULL
;
2417 /* End of hp-psymtab-read.c */
2419 /* Set indentation to 4 spaces for Emacs; this file is
2420 mostly non-GNU-ish in its style :-( */
2422 *** Local Variables
:
2423 *** c
-basic
-offset
: 4