1 |
578 |
markom |
/* Read hp debug symbols and convert to internal format, for GDB.
|
2 |
|
|
Copyright 1993, 1996, 1998, 1999, 2000 Free Software Foundation, Inc.
|
3 |
|
|
|
4 |
|
|
This file is part of GDB.
|
5 |
|
|
|
6 |
|
|
This program is free software; you can redistribute it and/or modify
|
7 |
|
|
it under the terms of the GNU General Public License as published by
|
8 |
|
|
the Free Software Foundation; either version 2 of the License, or
|
9 |
|
|
(at your option) any later version.
|
10 |
|
|
|
11 |
|
|
This program is distributed in the hope that it will be useful,
|
12 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
|
|
GNU General Public License for more details.
|
15 |
|
|
|
16 |
|
|
You should have received a copy of the GNU General Public License
|
17 |
|
|
along with this program; if not, write to the Free Software
|
18 |
|
|
Foundation, Inc., 59 Temple Place - Suite 330,
|
19 |
|
|
Boston, MA 02111-1307, USA.
|
20 |
|
|
|
21 |
|
|
Written by the Center for Software Science at the University of Utah
|
22 |
|
|
and by Cygnus Support. */
|
23 |
|
|
|
24 |
|
|
/* Common include file for hp_symtab_read.c and hp_psymtab_read.c.
|
25 |
|
|
This has nested includes of a bunch of stuff. */
|
26 |
|
|
#include "hpread.h"
|
27 |
|
|
#include "demangle.h"
|
28 |
|
|
|
29 |
|
|
/* To generate dumping code, uncomment this define. The dumping
|
30 |
|
|
itself is controlled by routine-local statics called "dumping". */
|
31 |
|
|
/* #define DUMPING 1 */
|
32 |
|
|
|
33 |
|
|
/* To use the quick look-up tables, uncomment this define. */
|
34 |
|
|
#define QUICK_LOOK_UP 1
|
35 |
|
|
|
36 |
|
|
/* To call PXDB to process un-processed files, uncomment this define. */
|
37 |
|
|
#define USE_PXDB 1
|
38 |
|
|
|
39 |
|
|
/* Forward procedure declarations */
|
40 |
|
|
|
41 |
|
|
void hpread_symfile_init (struct objfile *);
|
42 |
|
|
|
43 |
|
|
void do_pxdb (bfd *);
|
44 |
|
|
|
45 |
|
|
void hpread_build_psymtabs (struct objfile *, int);
|
46 |
|
|
|
47 |
|
|
void hpread_symfile_finish (struct objfile *);
|
48 |
|
|
|
49 |
|
|
static union dnttentry *hpread_get_gntt (int, struct objfile *);
|
50 |
|
|
|
51 |
|
|
static unsigned long hpread_get_textlow (int, int, struct objfile *, int);
|
52 |
|
|
|
53 |
|
|
static struct partial_symtab *hpread_start_psymtab
|
54 |
|
|
(struct objfile *, char *, CORE_ADDR, int,
|
55 |
|
|
struct partial_symbol **, struct partial_symbol **);
|
56 |
|
|
|
57 |
|
|
static struct partial_symtab *hpread_end_psymtab
|
58 |
|
|
(struct partial_symtab *, char **, int, int, CORE_ADDR,
|
59 |
|
|
struct partial_symtab **, int);
|
60 |
|
|
|
61 |
|
|
/* End of forward routine declarations */
|
62 |
|
|
|
63 |
|
|
#ifdef USE_PXDB
|
64 |
|
|
|
65 |
|
|
/* NOTE use of system files! May not be portable. */
|
66 |
|
|
|
67 |
|
|
#define PXDB_SVR4 "/opt/langtools/bin/pxdb"
|
68 |
|
|
#define PXDB_BSD "/usr/bin/pxdb"
|
69 |
|
|
|
70 |
|
|
#include <stdlib.h>
|
71 |
|
|
#include <string.h>
|
72 |
|
|
|
73 |
|
|
/* check for the existence of a file, given its full pathname */
|
74 |
|
|
int
|
75 |
|
|
file_exists (char *filename)
|
76 |
|
|
{
|
77 |
|
|
if (filename)
|
78 |
|
|
return (access (filename, F_OK) == 0);
|
79 |
|
|
return 0;
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
/* Translate from the "hp_language" enumeration in hp-symtab.h
|
84 |
|
|
used in the debug info to gdb's generic enumeration in defs.h. */
|
85 |
|
|
static enum language
|
86 |
|
|
trans_lang (enum hp_language in_lang)
|
87 |
|
|
{
|
88 |
|
|
if (in_lang == HP_LANGUAGE_C)
|
89 |
|
|
return language_c;
|
90 |
|
|
|
91 |
|
|
else if (in_lang == HP_LANGUAGE_CPLUSPLUS)
|
92 |
|
|
return language_cplus;
|
93 |
|
|
|
94 |
|
|
else if (in_lang == HP_LANGUAGE_FORTRAN)
|
95 |
|
|
return language_fortran;
|
96 |
|
|
|
97 |
|
|
else
|
98 |
|
|
return language_unknown;
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
static char main_string[] = "main";
|
102 |
|
|
|
103 |
|
|
/* Call PXDB to process our file.
|
104 |
|
|
|
105 |
|
|
Approach copied from DDE's "dbgk_run_pxdb". Note: we
|
106 |
|
|
don't check for BSD location of pxdb, nor for existence
|
107 |
|
|
of pxdb itself, etc.
|
108 |
|
|
|
109 |
|
|
NOTE: uses system function and string functions directly.
|
110 |
|
|
|
111 |
|
|
Return value: 1 if ok, 0 if not */
|
112 |
|
|
int
|
113 |
|
|
hpread_call_pxdb (char *file_name)
|
114 |
|
|
{
|
115 |
|
|
char *p;
|
116 |
|
|
int status;
|
117 |
|
|
int retval;
|
118 |
|
|
|
119 |
|
|
if (file_exists (PXDB_SVR4))
|
120 |
|
|
{
|
121 |
|
|
p = xmalloc (strlen (PXDB_SVR4) + strlen (file_name) + 2);
|
122 |
|
|
strcpy (p, PXDB_SVR4);
|
123 |
|
|
strcat (p, " ");
|
124 |
|
|
strcat (p, file_name);
|
125 |
|
|
|
126 |
|
|
warning ("File not processed by pxdb--about to process now.\n");
|
127 |
|
|
status = system (p);
|
128 |
|
|
|
129 |
|
|
retval = (status == 0);
|
130 |
|
|
}
|
131 |
|
|
else
|
132 |
|
|
{
|
133 |
|
|
warning ("pxdb not found at standard location: /opt/langtools/bin\ngdb will not be able to debug %s.\nPlease install pxdb at the above location and then restart gdb.\nYou can also run pxdb on %s with the command\n\"pxdb %s\" and then restart gdb.", file_name, file_name, file_name);
|
134 |
|
|
|
135 |
|
|
retval = 0;
|
136 |
|
|
}
|
137 |
|
|
return retval;
|
138 |
|
|
} /* hpread_call_pxdb */
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
/* Return 1 if the file turns out to need pre-processing
|
142 |
|
|
by PXDB, and we have thus called PXDB to do this processing
|
143 |
|
|
and the file therefore needs to be re-loaded. Otherwise
|
144 |
|
|
return 0. */
|
145 |
|
|
int
|
146 |
|
|
hpread_pxdb_needed (bfd *sym_bfd)
|
147 |
|
|
{
|
148 |
|
|
asection *pinfo_section, *debug_section, *header_section;
|
149 |
|
|
unsigned int do_pxdb;
|
150 |
|
|
char *buf;
|
151 |
|
|
bfd_size_type header_section_size;
|
152 |
|
|
|
153 |
|
|
unsigned long tmp;
|
154 |
|
|
unsigned int pxdbed;
|
155 |
|
|
|
156 |
|
|
header_section = bfd_get_section_by_name (sym_bfd, "$HEADER$");
|
157 |
|
|
if (!header_section)
|
158 |
|
|
{
|
159 |
|
|
return 0; /* No header at all, can't recover... */
|
160 |
|
|
}
|
161 |
|
|
|
162 |
|
|
debug_section = bfd_get_section_by_name (sym_bfd, "$DEBUG$");
|
163 |
|
|
pinfo_section = bfd_get_section_by_name (sym_bfd, "$PINFO$");
|
164 |
|
|
|
165 |
|
|
if (pinfo_section && !debug_section)
|
166 |
|
|
{
|
167 |
|
|
/* Debug info with DOC, has different header format.
|
168 |
|
|
this only happens if the file was pxdbed and compiled optimized
|
169 |
|
|
otherwise the PINFO section is not there. */
|
170 |
|
|
header_section_size = bfd_section_size (objfile->obfd, header_section);
|
171 |
|
|
|
172 |
|
|
if (header_section_size == (bfd_size_type) sizeof (DOC_info_PXDB_header))
|
173 |
|
|
{
|
174 |
|
|
buf = alloca (sizeof (DOC_info_PXDB_header));
|
175 |
|
|
|
176 |
|
|
if (!bfd_get_section_contents (sym_bfd,
|
177 |
|
|
header_section,
|
178 |
|
|
buf, 0,
|
179 |
|
|
header_section_size))
|
180 |
|
|
error ("bfd_get_section_contents\n");
|
181 |
|
|
|
182 |
|
|
tmp = bfd_get_32 (sym_bfd, (bfd_byte *) (buf + sizeof (int) * 4));
|
183 |
|
|
pxdbed = (tmp >> 31) & 0x1;
|
184 |
|
|
|
185 |
|
|
if (!pxdbed)
|
186 |
|
|
error ("file debug header info invalid\n");
|
187 |
|
|
do_pxdb = 0;
|
188 |
|
|
}
|
189 |
|
|
|
190 |
|
|
else
|
191 |
|
|
error ("invalid $HEADER$ size in executable \n");
|
192 |
|
|
}
|
193 |
|
|
|
194 |
|
|
else
|
195 |
|
|
{
|
196 |
|
|
|
197 |
|
|
/* this can be three different cases:
|
198 |
|
|
1. pxdbed and not doc
|
199 |
|
|
- DEBUG and HEADER sections are there
|
200 |
|
|
- header is PXDB_header type
|
201 |
|
|
- pxdbed flag is set to 1
|
202 |
|
|
|
203 |
|
|
2. not pxdbed and doc
|
204 |
|
|
- DEBUG and HEADER sections are there
|
205 |
|
|
- header is DOC_info_header type
|
206 |
|
|
- pxdbed flag is set to 0
|
207 |
|
|
|
208 |
|
|
3. not pxdbed and not doc
|
209 |
|
|
- DEBUG and HEADER sections are there
|
210 |
|
|
- header is XDB_header type
|
211 |
|
|
- pxdbed flag is set to 0
|
212 |
|
|
|
213 |
|
|
NOTE: the pxdbed flag is meaningful also in the not
|
214 |
|
|
already pxdb processed version of the header,
|
215 |
|
|
because in case on non-already processed by pxdb files
|
216 |
|
|
that same bit in the header would be always zero.
|
217 |
|
|
Why? Because the bit is the leftmost bit of a word
|
218 |
|
|
which contains a 'length' which is always a positive value
|
219 |
|
|
so that bit is never set to 1 (otherwise it would be negative)
|
220 |
|
|
|
221 |
|
|
Given the above, we have two choices : either we ignore the
|
222 |
|
|
size of the header itself and just look at the pxdbed field,
|
223 |
|
|
or we check the size and then we (for safety and paranoia related
|
224 |
|
|
issues) check the bit.
|
225 |
|
|
The first solution is used by DDE, the second by PXDB itself.
|
226 |
|
|
I am using the second one here, because I already wrote it,
|
227 |
|
|
and it is the end of a long day.
|
228 |
|
|
Also, using the first approach would still involve size issues
|
229 |
|
|
because we need to read in the contents of the header section, and
|
230 |
|
|
give the correct amount of stuff we want to read to the
|
231 |
|
|
get_bfd_section_contents function. */
|
232 |
|
|
|
233 |
|
|
/* decide which case depending on the size of the header section.
|
234 |
|
|
The size is as defined in hp-symtab.h */
|
235 |
|
|
|
236 |
|
|
header_section_size = bfd_section_size (objfile->obfd, header_section);
|
237 |
|
|
|
238 |
|
|
if (header_section_size == (bfd_size_type) sizeof (PXDB_header)) /* pxdb and not doc */
|
239 |
|
|
{
|
240 |
|
|
|
241 |
|
|
buf = alloca (sizeof (PXDB_header));
|
242 |
|
|
if (!bfd_get_section_contents (sym_bfd,
|
243 |
|
|
header_section,
|
244 |
|
|
buf, 0,
|
245 |
|
|
header_section_size))
|
246 |
|
|
error ("bfd_get_section_contents\n");
|
247 |
|
|
|
248 |
|
|
tmp = bfd_get_32 (sym_bfd, (bfd_byte *) (buf + sizeof (int) * 3));
|
249 |
|
|
pxdbed = (tmp >> 31) & 0x1;
|
250 |
|
|
|
251 |
|
|
if (pxdbed)
|
252 |
|
|
do_pxdb = 0;
|
253 |
|
|
else
|
254 |
|
|
error ("file debug header invalid\n");
|
255 |
|
|
}
|
256 |
|
|
else /*not pxdbed and doc OR not pxdbed and non doc */
|
257 |
|
|
do_pxdb = 1;
|
258 |
|
|
}
|
259 |
|
|
|
260 |
|
|
if (do_pxdb)
|
261 |
|
|
{
|
262 |
|
|
return 1;
|
263 |
|
|
}
|
264 |
|
|
else
|
265 |
|
|
{
|
266 |
|
|
return 0;
|
267 |
|
|
}
|
268 |
|
|
} /* hpread_pxdb_needed */
|
269 |
|
|
|
270 |
|
|
#endif
|
271 |
|
|
|
272 |
|
|
/* Check whether the file needs to be preprocessed by pxdb.
|
273 |
|
|
If so, call pxdb. */
|
274 |
|
|
|
275 |
|
|
void
|
276 |
|
|
do_pxdb (bfd *sym_bfd)
|
277 |
|
|
{
|
278 |
|
|
/* The following code is HP-specific. The "right" way of
|
279 |
|
|
doing this is unknown, but we bet would involve a target-
|
280 |
|
|
specific pre-file-load check using a generic mechanism. */
|
281 |
|
|
|
282 |
|
|
/* This code will not be executed if the file is not in SOM
|
283 |
|
|
format (i.e. if compiled with gcc) */
|
284 |
|
|
if (hpread_pxdb_needed (sym_bfd))
|
285 |
|
|
{
|
286 |
|
|
/*This file has not been pre-processed. Preprocess now */
|
287 |
|
|
|
288 |
|
|
if (hpread_call_pxdb (sym_bfd->filename))
|
289 |
|
|
{
|
290 |
|
|
/* The call above has changed the on-disk file,
|
291 |
|
|
we can close the file anyway, because the
|
292 |
|
|
symbols will be reread in when the target is run */
|
293 |
|
|
bfd_close (sym_bfd);
|
294 |
|
|
}
|
295 |
|
|
}
|
296 |
|
|
}
|
297 |
|
|
|
298 |
|
|
|
299 |
|
|
|
300 |
|
|
#ifdef QUICK_LOOK_UP
|
301 |
|
|
|
302 |
|
|
/* Code to handle quick lookup-tables follows. */
|
303 |
|
|
|
304 |
|
|
|
305 |
|
|
/* Some useful macros */
|
306 |
|
|
#define VALID_FILE(i) ((i) < pxdb_header_p->fd_entries)
|
307 |
|
|
#define VALID_MODULE(i) ((i) < pxdb_header_p->md_entries)
|
308 |
|
|
#define VALID_PROC(i) ((i) < pxdb_header_p->pd_entries)
|
309 |
|
|
#define VALID_CLASS(i) ((i) < pxdb_header_p->cd_entries)
|
310 |
|
|
|
311 |
|
|
#define FILE_START(i) (qFD[i].adrStart)
|
312 |
|
|
#define MODULE_START(i) (qMD[i].adrStart)
|
313 |
|
|
#define PROC_START(i) (qPD[i].adrStart)
|
314 |
|
|
|
315 |
|
|
#define FILE_END(i) (qFD[i].adrEnd)
|
316 |
|
|
#define MODULE_END(i) (qMD[i].adrEnd)
|
317 |
|
|
#define PROC_END(i) (qPD[i].adrEnd)
|
318 |
|
|
|
319 |
|
|
#define FILE_ISYM(i) (qFD[i].isym)
|
320 |
|
|
#define MODULE_ISYM(i) (qMD[i].isym)
|
321 |
|
|
#define PROC_ISYM(i) (qPD[i].isym)
|
322 |
|
|
|
323 |
|
|
#define VALID_CURR_FILE (curr_fd < pxdb_header_p->fd_entries)
|
324 |
|
|
#define VALID_CURR_MODULE (curr_md < pxdb_header_p->md_entries)
|
325 |
|
|
#define VALID_CURR_PROC (curr_pd < pxdb_header_p->pd_entries)
|
326 |
|
|
#define VALID_CURR_CLASS (curr_cd < pxdb_header_p->cd_entries)
|
327 |
|
|
|
328 |
|
|
#define CURR_FILE_START (qFD[curr_fd].adrStart)
|
329 |
|
|
#define CURR_MODULE_START (qMD[curr_md].adrStart)
|
330 |
|
|
#define CURR_PROC_START (qPD[curr_pd].adrStart)
|
331 |
|
|
|
332 |
|
|
#define CURR_FILE_END (qFD[curr_fd].adrEnd)
|
333 |
|
|
#define CURR_MODULE_END (qMD[curr_md].adrEnd)
|
334 |
|
|
#define CURR_PROC_END (qPD[curr_pd].adrEnd)
|
335 |
|
|
|
336 |
|
|
#define CURR_FILE_ISYM (qFD[curr_fd].isym)
|
337 |
|
|
#define CURR_MODULE_ISYM (qMD[curr_md].isym)
|
338 |
|
|
#define CURR_PROC_ISYM (qPD[curr_pd].isym)
|
339 |
|
|
|
340 |
|
|
#define TELL_OBJFILE \
|
341 |
|
|
do { \
|
342 |
|
|
if( !told_objfile ) { \
|
343 |
|
|
told_objfile = 1; \
|
344 |
|
|
warning ("\nIn object file \"%s\":\n", \
|
345 |
|
|
objfile->name); \
|
346 |
|
|
} \
|
347 |
|
|
} while (0)
|
348 |
|
|
|
349 |
|
|
|
350 |
|
|
|
351 |
|
|
/* Keeping track of the start/end symbol table (LNTT) indices of
|
352 |
|
|
psymtabs created so far */
|
353 |
|
|
|
354 |
|
|
typedef struct
|
355 |
|
|
{
|
356 |
|
|
int start;
|
357 |
|
|
int end;
|
358 |
|
|
}
|
359 |
|
|
pst_syms_struct;
|
360 |
|
|
|
361 |
|
|
static pst_syms_struct *pst_syms_array = 0;
|
362 |
|
|
|
363 |
|
|
static pst_syms_count = 0;
|
364 |
|
|
static pst_syms_size = 0;
|
365 |
|
|
|
366 |
|
|
/* used by the TELL_OBJFILE macro */
|
367 |
|
|
static boolean told_objfile = 0;
|
368 |
|
|
|
369 |
|
|
/* Set up psymtab symbol index stuff */
|
370 |
|
|
static void
|
371 |
|
|
init_pst_syms (void)
|
372 |
|
|
{
|
373 |
|
|
pst_syms_count = 0;
|
374 |
|
|
pst_syms_size = 20;
|
375 |
|
|
pst_syms_array = (pst_syms_struct *) xmalloc (20 * sizeof (pst_syms_struct));
|
376 |
|
|
}
|
377 |
|
|
|
378 |
|
|
/* Clean up psymtab symbol index stuff */
|
379 |
|
|
static void
|
380 |
|
|
clear_pst_syms (void)
|
381 |
|
|
{
|
382 |
|
|
pst_syms_count = 0;
|
383 |
|
|
pst_syms_size = 0;
|
384 |
|
|
xfree (pst_syms_array);
|
385 |
|
|
pst_syms_array = 0;
|
386 |
|
|
}
|
387 |
|
|
|
388 |
|
|
/* Add information about latest psymtab to symbol index table */
|
389 |
|
|
static void
|
390 |
|
|
record_pst_syms (int start_sym, int end_sym)
|
391 |
|
|
{
|
392 |
|
|
if (++pst_syms_count > pst_syms_size)
|
393 |
|
|
{
|
394 |
|
|
pst_syms_array = (pst_syms_struct *) xrealloc (pst_syms_array,
|
395 |
|
|
2 * pst_syms_size * sizeof (pst_syms_struct));
|
396 |
|
|
pst_syms_size *= 2;
|
397 |
|
|
}
|
398 |
|
|
pst_syms_array[pst_syms_count - 1].start = start_sym;
|
399 |
|
|
pst_syms_array[pst_syms_count - 1].end = end_sym;
|
400 |
|
|
}
|
401 |
|
|
|
402 |
|
|
/* Find a suitable symbol table index which can serve as the upper
|
403 |
|
|
bound of a psymtab that starts at INDEX
|
404 |
|
|
|
405 |
|
|
This scans backwards in the psymtab symbol index table to find a
|
406 |
|
|
"hole" in which the given index can fit. This is a heuristic!!
|
407 |
|
|
We don't search the entire table to check for multiple holes,
|
408 |
|
|
we don't care about overlaps, etc.
|
409 |
|
|
|
410 |
|
|
Return 0 => not found */
|
411 |
|
|
static int
|
412 |
|
|
find_next_pst_start (int index)
|
413 |
|
|
{
|
414 |
|
|
int i;
|
415 |
|
|
|
416 |
|
|
for (i = pst_syms_count - 1; i >= 0; i--)
|
417 |
|
|
if (pst_syms_array[i].end <= index)
|
418 |
|
|
return (i == pst_syms_count - 1) ? 0 : pst_syms_array[i + 1].start - 1;
|
419 |
|
|
|
420 |
|
|
if (pst_syms_array[0].start > index)
|
421 |
|
|
return pst_syms_array[0].start - 1;
|
422 |
|
|
|
423 |
|
|
return 0;
|
424 |
|
|
}
|
425 |
|
|
|
426 |
|
|
|
427 |
|
|
|
428 |
|
|
/* Utility functions to find the ending symbol index for a psymtab */
|
429 |
|
|
|
430 |
|
|
/* Find the next file entry that begins beyond INDEX, and return
|
431 |
|
|
its starting symbol index - 1.
|
432 |
|
|
QFD is the file table, CURR_FD is the file entry from where to start,
|
433 |
|
|
PXDB_HEADER_P as in hpread_quick_traverse (to allow macros to work).
|
434 |
|
|
|
435 |
|
|
Return 0 => not found */
|
436 |
|
|
static int
|
437 |
|
|
find_next_file_isym (int index, quick_file_entry *qFD, int curr_fd,
|
438 |
|
|
PXDB_header_ptr pxdb_header_p)
|
439 |
|
|
{
|
440 |
|
|
while (VALID_CURR_FILE)
|
441 |
|
|
{
|
442 |
|
|
if (CURR_FILE_ISYM >= index)
|
443 |
|
|
return CURR_FILE_ISYM - 1;
|
444 |
|
|
curr_fd++;
|
445 |
|
|
}
|
446 |
|
|
return 0;
|
447 |
|
|
}
|
448 |
|
|
|
449 |
|
|
/* Find the next procedure entry that begins beyond INDEX, and return
|
450 |
|
|
its starting symbol index - 1.
|
451 |
|
|
QPD is the procedure table, CURR_PD is the proc entry from where to start,
|
452 |
|
|
PXDB_HEADER_P as in hpread_quick_traverse (to allow macros to work).
|
453 |
|
|
|
454 |
|
|
Return 0 => not found */
|
455 |
|
|
static int
|
456 |
|
|
find_next_proc_isym (int index, quick_procedure_entry *qPD, int curr_pd,
|
457 |
|
|
PXDB_header_ptr pxdb_header_p)
|
458 |
|
|
{
|
459 |
|
|
while (VALID_CURR_PROC)
|
460 |
|
|
{
|
461 |
|
|
if (CURR_PROC_ISYM >= index)
|
462 |
|
|
return CURR_PROC_ISYM - 1;
|
463 |
|
|
curr_pd++;
|
464 |
|
|
}
|
465 |
|
|
return 0;
|
466 |
|
|
}
|
467 |
|
|
|
468 |
|
|
/* Find the next module entry that begins beyond INDEX, and return
|
469 |
|
|
its starting symbol index - 1.
|
470 |
|
|
QMD is the module table, CURR_MD is the modue entry from where to start,
|
471 |
|
|
PXDB_HEADER_P as in hpread_quick_traverse (to allow macros to work).
|
472 |
|
|
|
473 |
|
|
Return 0 => not found */
|
474 |
|
|
static int
|
475 |
|
|
find_next_module_isym (int index, quick_module_entry *qMD, int curr_md,
|
476 |
|
|
PXDB_header_ptr pxdb_header_p)
|
477 |
|
|
{
|
478 |
|
|
while (VALID_CURR_MODULE)
|
479 |
|
|
{
|
480 |
|
|
if (CURR_MODULE_ISYM >= index)
|
481 |
|
|
return CURR_MODULE_ISYM - 1;
|
482 |
|
|
curr_md++;
|
483 |
|
|
}
|
484 |
|
|
return 0;
|
485 |
|
|
}
|
486 |
|
|
|
487 |
|
|
/* Scan and record partial symbols for all functions starting from index
|
488 |
|
|
pointed to by CURR_PD_P, and between code addresses START_ADR and END_ADR.
|
489 |
|
|
Other parameters are explained in comments below. */
|
490 |
|
|
|
491 |
|
|
/* This used to be inline in hpread_quick_traverse, but now that we do
|
492 |
|
|
essentially the same thing for two different cases (modules and
|
493 |
|
|
module-less files), it's better organized in a separate routine,
|
494 |
|
|
although it does take lots of arguments. pai/1997-10-08
|
495 |
|
|
|
496 |
|
|
CURR_PD_P is the pointer to the current proc index. QPD is the
|
497 |
|
|
procedure quick lookup table. MAX_PROCS is the number of entries
|
498 |
|
|
in the proc. table. START_ADR is the beginning of the code range
|
499 |
|
|
for the current psymtab. end_adr is the end of the code range for
|
500 |
|
|
the current psymtab. PST is the current psymtab. VT_bits is
|
501 |
|
|
a pointer to the strings table of SOM debug space. OBJFILE is
|
502 |
|
|
the current object file. */
|
503 |
|
|
|
504 |
|
|
static int
|
505 |
|
|
scan_procs (int *curr_pd_p, quick_procedure_entry *qPD, int max_procs,
|
506 |
|
|
CORE_ADDR start_adr, CORE_ADDR end_adr, struct partial_symtab *pst,
|
507 |
|
|
char *vt_bits, struct objfile *objfile)
|
508 |
|
|
{
|
509 |
|
|
union dnttentry *dn_bufp;
|
510 |
|
|
int symbol_count = 0; /* Total number of symbols in this psymtab */
|
511 |
|
|
int curr_pd = *curr_pd_p; /* Convenience variable -- avoid dereferencing pointer all the time */
|
512 |
|
|
|
513 |
|
|
#ifdef DUMPING
|
514 |
|
|
/* Turn this on for lots of debugging information in this routine */
|
515 |
|
|
static int dumping = 0;
|
516 |
|
|
#endif
|
517 |
|
|
|
518 |
|
|
#ifdef DUMPING
|
519 |
|
|
if (dumping)
|
520 |
|
|
{
|
521 |
|
|
printf ("Scan_procs called, addresses %x to %x, proc %x\n", start_adr, end_adr, curr_pd);
|
522 |
|
|
}
|
523 |
|
|
#endif
|
524 |
|
|
|
525 |
|
|
while ((CURR_PROC_START <= end_adr) && (curr_pd < max_procs))
|
526 |
|
|
{
|
527 |
|
|
|
528 |
|
|
char *rtn_name; /* mangled name */
|
529 |
|
|
char *rtn_dem_name; /* qualified demangled name */
|
530 |
|
|
char *class_name;
|
531 |
|
|
int class;
|
532 |
|
|
|
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 */
|
535 |
|
|
{
|
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);
|
539 |
|
|
}
|
540 |
|
|
else
|
541 |
|
|
{
|
542 |
|
|
rtn_name = &vt_bits[(long) qPD[curr_pd].sbProc];
|
543 |
|
|
rtn_dem_name = NULL;
|
544 |
|
|
}
|
545 |
|
|
|
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;
|
551 |
|
|
|
552 |
|
|
#ifdef DUMPING
|
553 |
|
|
if (dumping)
|
554 |
|
|
{
|
555 |
|
|
printf ("..add %s (demangled %s), index %x to this psymtab\n", rtn_name, rtn_dem_name, curr_pd);
|
556 |
|
|
}
|
557 |
|
|
#endif
|
558 |
|
|
|
559 |
|
|
/* Check for module-spanning routines. */
|
560 |
|
|
if (CURR_PROC_END > end_adr)
|
561 |
|
|
{
|
562 |
|
|
TELL_OBJFILE;
|
563 |
|
|
warning ("Procedure \"%s\" [0x%x] spans file or module boundaries.", rtn_name, curr_pd);
|
564 |
|
|
}
|
565 |
|
|
|
566 |
|
|
/* Add this routine symbol to the list in the objfile.
|
567 |
|
|
Unfortunately we have to go to the LNTT to determine the
|
568 |
|
|
correct list to put it on. An alternative (which the
|
569 |
|
|
code used to do) would be to not check and always throw
|
570 |
|
|
it on the "static" list. But if we go that route, then
|
571 |
|
|
symbol_lookup() needs to be tweaked a bit to account
|
572 |
|
|
for the fact that the function might not be found on
|
573 |
|
|
the correct list in the psymtab. - RT */
|
574 |
|
|
dn_bufp = hpread_get_lntt (qPD[curr_pd].isym, objfile);
|
575 |
|
|
if (dn_bufp->dfunc.global)
|
576 |
|
|
add_psymbol_with_dem_name_to_list (rtn_name,
|
577 |
|
|
strlen (rtn_name),
|
578 |
|
|
rtn_dem_name,
|
579 |
|
|
strlen (rtn_dem_name),
|
580 |
|
|
VAR_NAMESPACE,
|
581 |
|
|
LOC_BLOCK, /* "I am a routine" */
|
582 |
|
|
&objfile->global_psymbols,
|
583 |
|
|
(qPD[curr_pd].adrStart + /* Starting address of rtn */
|
584 |
|
|
ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile))),
|
585 |
|
|
0, /* core addr?? */
|
586 |
|
|
trans_lang ((enum hp_language) qPD[curr_pd].language),
|
587 |
|
|
objfile);
|
588 |
|
|
else
|
589 |
|
|
add_psymbol_with_dem_name_to_list (rtn_name,
|
590 |
|
|
strlen (rtn_name),
|
591 |
|
|
rtn_dem_name,
|
592 |
|
|
strlen (rtn_dem_name),
|
593 |
|
|
VAR_NAMESPACE,
|
594 |
|
|
LOC_BLOCK, /* "I am a routine" */
|
595 |
|
|
&objfile->static_psymbols,
|
596 |
|
|
(qPD[curr_pd].adrStart + /* Starting address of rtn */
|
597 |
|
|
ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile))),
|
598 |
|
|
0, /* core addr?? */
|
599 |
|
|
trans_lang ((enum hp_language) qPD[curr_pd].language),
|
600 |
|
|
objfile);
|
601 |
|
|
|
602 |
|
|
symbol_count++;
|
603 |
|
|
*curr_pd_p = ++curr_pd; /* bump up count & reflect in caller */
|
604 |
|
|
} /* loop over procedures */
|
605 |
|
|
|
606 |
|
|
#ifdef DUMPING
|
607 |
|
|
if (dumping)
|
608 |
|
|
{
|
609 |
|
|
if (symbol_count == 0)
|
610 |
|
|
printf ("Scan_procs: no symbols found!\n");
|
611 |
|
|
}
|
612 |
|
|
#endif
|
613 |
|
|
|
614 |
|
|
return symbol_count;
|
615 |
|
|
}
|
616 |
|
|
|
617 |
|
|
|
618 |
|
|
/* Traverse the quick look-up tables, building a set of psymtabs.
|
619 |
|
|
|
620 |
|
|
This constructs a psymtab for modules and files in the quick lookup
|
621 |
|
|
tables.
|
622 |
|
|
|
623 |
|
|
Mostly, modules correspond to compilation units, so we try to
|
624 |
|
|
create psymtabs that correspond to modules; however, in some cases
|
625 |
|
|
a file can result in a compiled object which does not have a module
|
626 |
|
|
entry for it, so in such cases we create a psymtab for the file. */
|
627 |
|
|
|
628 |
|
|
int
|
629 |
|
|
hpread_quick_traverse (struct objfile *objfile, char *gntt_bits,
|
630 |
|
|
char *vt_bits, PXDB_header_ptr pxdb_header_p)
|
631 |
|
|
{
|
632 |
|
|
struct partial_symtab *pst;
|
633 |
|
|
|
634 |
|
|
char *addr;
|
635 |
|
|
|
636 |
|
|
quick_procedure_entry *qPD;
|
637 |
|
|
quick_file_entry *qFD;
|
638 |
|
|
quick_module_entry *qMD;
|
639 |
|
|
quick_class_entry *qCD;
|
640 |
|
|
|
641 |
|
|
int idx;
|
642 |
|
|
int i;
|
643 |
|
|
CORE_ADDR start_adr; /* current psymtab's starting code addr */
|
644 |
|
|
CORE_ADDR end_adr; /* current psymtab's ending code addr */
|
645 |
|
|
CORE_ADDR next_mod_adr; /* next module's starting code addr */
|
646 |
|
|
int curr_pd; /* current procedure */
|
647 |
|
|
int curr_fd; /* current file */
|
648 |
|
|
int curr_md; /* current module */
|
649 |
|
|
int start_sym; /* current psymtab's starting symbol index */
|
650 |
|
|
int end_sym; /* current psymtab's ending symbol index */
|
651 |
|
|
int max_LNTT_sym_index;
|
652 |
|
|
int syms_in_pst;
|
653 |
|
|
B_TYPE *class_entered;
|
654 |
|
|
|
655 |
|
|
struct partial_symbol **global_syms; /* We'll be filling in the "global" */
|
656 |
|
|
struct partial_symbol **static_syms; /* and "static" tables in the objfile
|
657 |
|
|
as we go, so we need a pair of
|
658 |
|
|
current pointers. */
|
659 |
|
|
|
660 |
|
|
#ifdef DUMPING
|
661 |
|
|
/* Turn this on for lots of debugging information in this routine.
|
662 |
|
|
You get a blow-by-blow account of quick lookup table reading */
|
663 |
|
|
static int dumping = 0;
|
664 |
|
|
#endif
|
665 |
|
|
|
666 |
|
|
pst = (struct partial_symtab *) 0;
|
667 |
|
|
|
668 |
|
|
/* Clear out some globals */
|
669 |
|
|
init_pst_syms ();
|
670 |
|
|
told_objfile = 0;
|
671 |
|
|
|
672 |
|
|
/* Demangling style -- if EDG style already set, don't change it,
|
673 |
|
|
as HP style causes some problems with the KAI EDG compiler */
|
674 |
|
|
if (current_demangling_style != edg_demangling)
|
675 |
|
|
{
|
676 |
|
|
/* Otherwise, ensure that we are using HP style demangling */
|
677 |
|
|
set_demangling_style (HP_DEMANGLING_STYLE_STRING);
|
678 |
|
|
}
|
679 |
|
|
|
680 |
|
|
/* First we need to find the starting points of the quick
|
681 |
|
|
look-up tables in the GNTT. */
|
682 |
|
|
|
683 |
|
|
addr = gntt_bits;
|
684 |
|
|
|
685 |
|
|
qPD = (quick_procedure_entry_ptr) addr;
|
686 |
|
|
addr += pxdb_header_p->pd_entries * sizeof (quick_procedure_entry);
|
687 |
|
|
|
688 |
|
|
#ifdef DUMPING
|
689 |
|
|
if (dumping)
|
690 |
|
|
{
|
691 |
|
|
printf ("\n Printing routines as we see them\n");
|
692 |
|
|
for (i = 0; VALID_PROC (i); i++)
|
693 |
|
|
{
|
694 |
|
|
idx = (long) qPD[i].sbProc;
|
695 |
|
|
printf ("%s %x..%x\n", &vt_bits[idx],
|
696 |
|
|
(int) PROC_START (i),
|
697 |
|
|
(int) PROC_END (i));
|
698 |
|
|
}
|
699 |
|
|
}
|
700 |
|
|
#endif
|
701 |
|
|
|
702 |
|
|
qFD = (quick_file_entry_ptr) addr;
|
703 |
|
|
addr += pxdb_header_p->fd_entries * sizeof (quick_file_entry);
|
704 |
|
|
|
705 |
|
|
#ifdef DUMPING
|
706 |
|
|
if (dumping)
|
707 |
|
|
{
|
708 |
|
|
printf ("\n Printing files as we see them\n");
|
709 |
|
|
for (i = 0; VALID_FILE (i); i++)
|
710 |
|
|
{
|
711 |
|
|
idx = (long) qFD[i].sbFile;
|
712 |
|
|
printf ("%s %x..%x\n", &vt_bits[idx],
|
713 |
|
|
(int) FILE_START (i),
|
714 |
|
|
(int) FILE_END (i));
|
715 |
|
|
}
|
716 |
|
|
}
|
717 |
|
|
#endif
|
718 |
|
|
|
719 |
|
|
qMD = (quick_module_entry_ptr) addr;
|
720 |
|
|
addr += pxdb_header_p->md_entries * sizeof (quick_module_entry);
|
721 |
|
|
|
722 |
|
|
#ifdef DUMPING
|
723 |
|
|
if (dumping)
|
724 |
|
|
{
|
725 |
|
|
printf ("\n Printing modules as we see them\n");
|
726 |
|
|
for (i = 0; i < pxdb_header_p->md_entries; i++)
|
727 |
|
|
{
|
728 |
|
|
idx = (long) qMD[i].sbMod;
|
729 |
|
|
printf ("%s\n", &vt_bits[idx]);
|
730 |
|
|
}
|
731 |
|
|
}
|
732 |
|
|
#endif
|
733 |
|
|
|
734 |
|
|
qCD = (quick_class_entry_ptr) addr;
|
735 |
|
|
addr += pxdb_header_p->cd_entries * sizeof (quick_class_entry);
|
736 |
|
|
|
737 |
|
|
#ifdef DUMPING
|
738 |
|
|
if (dumping)
|
739 |
|
|
{
|
740 |
|
|
printf ("\n Printing classes as we see them\n");
|
741 |
|
|
for (i = 0; VALID_CLASS (i); i++)
|
742 |
|
|
{
|
743 |
|
|
idx = (long) qCD[i].sbClass;
|
744 |
|
|
printf ("%s\n", &vt_bits[idx]);
|
745 |
|
|
}
|
746 |
|
|
|
747 |
|
|
printf ("\n Done with dump, on to build!\n");
|
748 |
|
|
}
|
749 |
|
|
#endif
|
750 |
|
|
|
751 |
|
|
/* We need this index only while hp-symtab-read.c expects
|
752 |
|
|
a byte offset to the end of the LNTT entries for a given
|
753 |
|
|
psymtab. Thus the need for it should go away someday.
|
754 |
|
|
|
755 |
|
|
When it goes away, then we won't have any need to load the
|
756 |
|
|
LNTT from the objfile at psymtab-time, and start-up will be
|
757 |
|
|
faster. To make that work, we'll need some way to create
|
758 |
|
|
a null pst for the "globals" pseudo-module. */
|
759 |
|
|
max_LNTT_sym_index = LNTT_SYMCOUNT (objfile);
|
760 |
|
|
|
761 |
|
|
/* Scan the module descriptors and make a psymtab for each.
|
762 |
|
|
|
763 |
|
|
We know the MDs, FDs and the PDs are in order by starting
|
764 |
|
|
address. We use that fact to traverse all three arrays in
|
765 |
|
|
parallel, knowing when the next PD is in a new file
|
766 |
|
|
and we need to create a new psymtab. */
|
767 |
|
|
curr_pd = 0; /* Current procedure entry */
|
768 |
|
|
curr_fd = 0; /* Current file entry */
|
769 |
|
|
curr_md = 0; /* Current module entry */
|
770 |
|
|
|
771 |
|
|
start_adr = 0; /* Current psymtab code range */
|
772 |
|
|
end_adr = 0;
|
773 |
|
|
|
774 |
|
|
start_sym = 0; /* Current psymtab symbol range */
|
775 |
|
|
end_sym = 0;
|
776 |
|
|
|
777 |
|
|
syms_in_pst = 0; /* Symbol count for psymtab */
|
778 |
|
|
|
779 |
|
|
/* Psts actually just have pointers into the objfile's
|
780 |
|
|
symbol table, not their own symbol tables. */
|
781 |
|
|
global_syms = objfile->global_psymbols.list;
|
782 |
|
|
static_syms = objfile->static_psymbols.list;
|
783 |
|
|
|
784 |
|
|
|
785 |
|
|
/* First skip over pseudo-entries with address 0. These represent inlined
|
786 |
|
|
routines and abstract (uninstantiated) template routines.
|
787 |
|
|
FIXME: These should be read in and available -- even if we can't set
|
788 |
|
|
breakpoints, etc., there's some information that can be presented
|
789 |
|
|
to the user. pai/1997-10-08 */
|
790 |
|
|
|
791 |
|
|
while (VALID_CURR_PROC && (CURR_PROC_START == 0))
|
792 |
|
|
curr_pd++;
|
793 |
|
|
|
794 |
|
|
/* Loop over files, modules, and procedures in code address order. Each
|
795 |
|
|
time we enter an iteration of this loop, curr_pd points to the first
|
796 |
|
|
unprocessed procedure, curr_fd points to the first unprocessed file, and
|
797 |
|
|
curr_md to the first unprocessed module. Each iteration of this loop
|
798 |
|
|
updates these as required -- any or all of them may be bumpd up
|
799 |
|
|
each time around. When we exit this loop, we are done with all files
|
800 |
|
|
and modules in the tables -- there may still be some procedures, however.
|
801 |
|
|
|
802 |
|
|
Note: This code used to loop only over module entries, under the assumption
|
803 |
|
|
that files can occur via inclusions and are thus unreliable, while a
|
804 |
|
|
compiled object always corresponds to a module. With CTTI in the HP aCC
|
805 |
|
|
compiler, it turns out that compiled objects may have only files and no
|
806 |
|
|
modules; so we have to loop over files and modules, creating psymtabs for
|
807 |
|
|
either as appropriate. Unfortunately there are some problems (notably:
|
808 |
|
|
1. the lack of "SRC_FILE_END" entries in the LNTT, 2. the lack of pointers
|
809 |
|
|
to the ending symbol indices of a module or a file) which make it quite hard
|
810 |
|
|
to do this correctly. Currently it uses a bunch of heuristics to start and
|
811 |
|
|
end psymtabs; they seem to work well with most objects generated by aCC, but
|
812 |
|
|
who knows when that will change... */
|
813 |
|
|
|
814 |
|
|
while (VALID_CURR_FILE || VALID_CURR_MODULE)
|
815 |
|
|
{
|
816 |
|
|
|
817 |
|
|
char *mod_name_string;
|
818 |
|
|
char *full_name_string;
|
819 |
|
|
|
820 |
|
|
/* First check for modules like "version.c", which have no code
|
821 |
|
|
in them but still have qMD entries. They also have no qFD or
|
822 |
|
|
qPD entries. Their start address is -1 and their end address
|
823 |
|
|
is 0. */
|
824 |
|
|
if (VALID_CURR_MODULE && (CURR_MODULE_START == -1) && (CURR_MODULE_END == 0))
|
825 |
|
|
{
|
826 |
|
|
|
827 |
|
|
mod_name_string = &vt_bits[(long) qMD[curr_md].sbMod];
|
828 |
|
|
|
829 |
|
|
#ifdef DUMPING
|
830 |
|
|
if (dumping)
|
831 |
|
|
printf ("Module with data only %s\n", mod_name_string);
|
832 |
|
|
#endif
|
833 |
|
|
|
834 |
|
|
/* We'll skip the rest (it makes error-checking easier), and
|
835 |
|
|
just make an empty pst. Right now empty psts are not put
|
836 |
|
|
in the pst chain, so all this is for naught, but later it
|
837 |
|
|
might help. */
|
838 |
|
|
|
839 |
|
|
pst = hpread_start_psymtab (objfile,
|
840 |
|
|
mod_name_string,
|
841 |
|
|
CURR_MODULE_START, /* Low text address: bogus! */
|
842 |
|
|
(CURR_MODULE_ISYM * sizeof (struct dntt_type_block)),
|
843 |
|
|
/* ldsymoff */
|
844 |
|
|
global_syms,
|
845 |
|
|
static_syms);
|
846 |
|
|
|
847 |
|
|
pst = hpread_end_psymtab (pst,
|
848 |
|
|
NULL, /* psymtab_include_list */
|
849 |
|
|
0, /* includes_used */
|
850 |
|
|
end_sym * sizeof (struct dntt_type_block),
|
851 |
|
|
/* byte index in LNTT of end
|
852 |
|
|
= capping symbol offset
|
853 |
|
|
= LDSYMOFF of nextfile */
|
854 |
|
|
0, /* text high */
|
855 |
|
|
NULL, /* dependency_list */
|
856 |
|
|
0); /* dependencies_used */
|
857 |
|
|
|
858 |
|
|
global_syms = objfile->global_psymbols.next;
|
859 |
|
|
static_syms = objfile->static_psymbols.next;
|
860 |
|
|
|
861 |
|
|
curr_md++;
|
862 |
|
|
}
|
863 |
|
|
else if (VALID_CURR_MODULE &&
|
864 |
|
|
((CURR_MODULE_START == 0) || (CURR_MODULE_START == -1) ||
|
865 |
|
|
(CURR_MODULE_END == 0) || (CURR_MODULE_END == -1)))
|
866 |
|
|
{
|
867 |
|
|
TELL_OBJFILE;
|
868 |
|
|
warning ("Module \"%s\" [0x%x] has non-standard addresses. It starts at 0x%x, ends at 0x%x, and will be skipped.",
|
869 |
|
|
mod_name_string, curr_md, start_adr, end_adr);
|
870 |
|
|
/* On to next module */
|
871 |
|
|
curr_md++;
|
872 |
|
|
}
|
873 |
|
|
else
|
874 |
|
|
{
|
875 |
|
|
/* First check if we are looking at a file with code in it
|
876 |
|
|
that does not overlap the current module's code range */
|
877 |
|
|
|
878 |
|
|
if (VALID_CURR_FILE ? (VALID_CURR_MODULE ? (CURR_FILE_END < CURR_MODULE_START) : 1) : 0)
|
879 |
|
|
{
|
880 |
|
|
|
881 |
|
|
/* Looking at file not corresponding to any module,
|
882 |
|
|
create a psymtab for it */
|
883 |
|
|
full_name_string = &vt_bits[(long) qFD[curr_fd].sbFile];
|
884 |
|
|
start_adr = CURR_FILE_START;
|
885 |
|
|
end_adr = CURR_FILE_END;
|
886 |
|
|
start_sym = CURR_FILE_ISYM;
|
887 |
|
|
|
888 |
|
|
/* Check if there are any procedures not handled until now, that
|
889 |
|
|
begin before the start address of this file, and if so, adjust
|
890 |
|
|
this module's start address to include them. This handles routines that
|
891 |
|
|
are in between file or module ranges for some reason (probably
|
892 |
|
|
indicates a compiler bug */
|
893 |
|
|
|
894 |
|
|
if (CURR_PROC_START < start_adr)
|
895 |
|
|
{
|
896 |
|
|
TELL_OBJFILE;
|
897 |
|
|
warning ("Found procedure \"%s\" [0x%x] that is not in any file or module.",
|
898 |
|
|
&vt_bits[(long) qPD[curr_pd].sbProc], curr_pd);
|
899 |
|
|
start_adr = CURR_PROC_START;
|
900 |
|
|
if (CURR_PROC_ISYM < start_sym)
|
901 |
|
|
start_sym = CURR_PROC_ISYM;
|
902 |
|
|
}
|
903 |
|
|
|
904 |
|
|
/* Sometimes (compiler bug -- COBOL) the module end address is higher
|
905 |
|
|
than the start address of the next module, so check for that and
|
906 |
|
|
adjust accordingly */
|
907 |
|
|
|
908 |
|
|
if (VALID_FILE (curr_fd + 1) && (FILE_START (curr_fd + 1) <= end_adr))
|
909 |
|
|
{
|
910 |
|
|
TELL_OBJFILE;
|
911 |
|
|
warning ("File \"%s\" [0x%x] has ending address after starting address of next file; adjusting ending address down.",
|
912 |
|
|
full_name_string, curr_fd);
|
913 |
|
|
end_adr = FILE_START (curr_fd + 1) - 1; /* Is -4 (or -8 for 64-bit) better? */
|
914 |
|
|
}
|
915 |
|
|
if (VALID_MODULE (curr_md) && (CURR_MODULE_START <= end_adr))
|
916 |
|
|
{
|
917 |
|
|
TELL_OBJFILE;
|
918 |
|
|
warning ("File \"%s\" [0x%x] has ending address after starting address of next module; adjusting ending address down.",
|
919 |
|
|
full_name_string, curr_fd);
|
920 |
|
|
end_adr = CURR_MODULE_START - 1; /* Is -4 (or -8 for 64-bit) better? */
|
921 |
|
|
}
|
922 |
|
|
|
923 |
|
|
|
924 |
|
|
#ifdef DUMPING
|
925 |
|
|
if (dumping)
|
926 |
|
|
{
|
927 |
|
|
printf ("Make new psymtab for file %s (%x to %x).\n",
|
928 |
|
|
full_name_string, start_adr, end_adr);
|
929 |
|
|
}
|
930 |
|
|
#endif
|
931 |
|
|
/* Create the basic psymtab, connecting it in the list
|
932 |
|
|
for this objfile and pointing its symbol entries
|
933 |
|
|
to the current end of the symbol areas in the objfile.
|
934 |
|
|
|
935 |
|
|
The "ldsymoff" parameter is the byte offset in the LNTT
|
936 |
|
|
of the first symbol in this file. Some day we should
|
937 |
|
|
turn this into an index (fix in hp-symtab-read.c as well).
|
938 |
|
|
And it's not even the right byte offset, as we're using
|
939 |
|
|
the size of a union! FIXME! */
|
940 |
|
|
pst = hpread_start_psymtab (objfile,
|
941 |
|
|
full_name_string,
|
942 |
|
|
start_adr, /* Low text address */
|
943 |
|
|
(start_sym * sizeof (struct dntt_type_block)),
|
944 |
|
|
/* ldsymoff */
|
945 |
|
|
global_syms,
|
946 |
|
|
static_syms);
|
947 |
|
|
|
948 |
|
|
/* Set up to only enter each class referenced in this module once. */
|
949 |
|
|
class_entered = xmalloc (B_BYTES (pxdb_header_p->cd_entries));
|
950 |
|
|
B_CLRALL (class_entered, pxdb_header_p->cd_entries);
|
951 |
|
|
|
952 |
|
|
/* Scan the procedure descriptors for procedures in the current
|
953 |
|
|
file, based on the starting addresses. */
|
954 |
|
|
|
955 |
|
|
syms_in_pst = scan_procs (&curr_pd, qPD, pxdb_header_p->pd_entries,
|
956 |
|
|
start_adr, end_adr, pst, vt_bits, objfile);
|
957 |
|
|
|
958 |
|
|
/* Get ending symbol offset */
|
959 |
|
|
|
960 |
|
|
end_sym = 0;
|
961 |
|
|
/* First check for starting index before previous psymtab */
|
962 |
|
|
if (pst_syms_count && start_sym < pst_syms_array[pst_syms_count - 1].end)
|
963 |
|
|
{
|
964 |
|
|
end_sym = find_next_pst_start (start_sym);
|
965 |
|
|
}
|
966 |
|
|
/* Look for next start index of a file or module, or procedure */
|
967 |
|
|
if (!end_sym)
|
968 |
|
|
{
|
969 |
|
|
int next_file_isym = find_next_file_isym (start_sym, qFD, curr_fd + 1, pxdb_header_p);
|
970 |
|
|
int next_module_isym = find_next_module_isym (start_sym, qMD, curr_md, pxdb_header_p);
|
971 |
|
|
int next_proc_isym = find_next_proc_isym (start_sym, qPD, curr_pd, pxdb_header_p);
|
972 |
|
|
|
973 |
|
|
if (next_file_isym && next_module_isym)
|
974 |
|
|
{
|
975 |
|
|
/* pick lower of next file or module start index */
|
976 |
|
|
end_sym = min (next_file_isym, next_module_isym);
|
977 |
|
|
}
|
978 |
|
|
else
|
979 |
|
|
{
|
980 |
|
|
/* one of them is zero, pick the other */
|
981 |
|
|
end_sym = max (next_file_isym, next_module_isym);
|
982 |
|
|
}
|
983 |
|
|
|
984 |
|
|
/* As a precaution, check next procedure index too */
|
985 |
|
|
if (!end_sym)
|
986 |
|
|
end_sym = next_proc_isym;
|
987 |
|
|
else
|
988 |
|
|
end_sym = min (end_sym, next_proc_isym);
|
989 |
|
|
}
|
990 |
|
|
|
991 |
|
|
/* Couldn't find procedure, file, or module, use globals as default */
|
992 |
|
|
if (!end_sym)
|
993 |
|
|
end_sym = pxdb_header_p->globals;
|
994 |
|
|
|
995 |
|
|
#ifdef DUMPING
|
996 |
|
|
if (dumping)
|
997 |
|
|
{
|
998 |
|
|
printf ("File psymtab indices: %x to %x\n", start_sym, end_sym);
|
999 |
|
|
}
|
1000 |
|
|
#endif
|
1001 |
|
|
|
1002 |
|
|
pst = hpread_end_psymtab (pst,
|
1003 |
|
|
NULL, /* psymtab_include_list */
|
1004 |
|
|
0, /* includes_used */
|
1005 |
|
|
end_sym * sizeof (struct dntt_type_block),
|
1006 |
|
|
/* byte index in LNTT of end
|
1007 |
|
|
= capping symbol offset
|
1008 |
|
|
= LDSYMOFF of nextfile */
|
1009 |
|
|
end_adr, /* text high */
|
1010 |
|
|
NULL, /* dependency_list */
|
1011 |
|
|
0); /* dependencies_used */
|
1012 |
|
|
|
1013 |
|
|
record_pst_syms (start_sym, end_sym);
|
1014 |
|
|
|
1015 |
|
|
if (NULL == pst)
|
1016 |
|
|
warning ("No symbols in psymtab for file \"%s\" [0x%x].", full_name_string, curr_fd);
|
1017 |
|
|
|
1018 |
|
|
#ifdef DUMPING
|
1019 |
|
|
if (dumping)
|
1020 |
|
|
{
|
1021 |
|
|
printf ("Made new psymtab for file %s (%x to %x), sym %x to %x.\n",
|
1022 |
|
|
full_name_string, start_adr, end_adr, CURR_FILE_ISYM, end_sym);
|
1023 |
|
|
}
|
1024 |
|
|
#endif
|
1025 |
|
|
/* Prepare for the next psymtab. */
|
1026 |
|
|
global_syms = objfile->global_psymbols.next;
|
1027 |
|
|
static_syms = objfile->static_psymbols.next;
|
1028 |
|
|
xfree (class_entered);
|
1029 |
|
|
|
1030 |
|
|
curr_fd++;
|
1031 |
|
|
} /* Psymtab for file */
|
1032 |
|
|
else
|
1033 |
|
|
{
|
1034 |
|
|
/* We have a module for which we create a psymtab */
|
1035 |
|
|
|
1036 |
|
|
mod_name_string = &vt_bits[(long) qMD[curr_md].sbMod];
|
1037 |
|
|
|
1038 |
|
|
/* We will include the code ranges of any files that happen to
|
1039 |
|
|
overlap with this module */
|
1040 |
|
|
|
1041 |
|
|
/* So, first pick the lower of the file's and module's start addresses */
|
1042 |
|
|
start_adr = CURR_MODULE_START;
|
1043 |
|
|
if (VALID_CURR_FILE)
|
1044 |
|
|
{
|
1045 |
|
|
if (CURR_FILE_START < CURR_MODULE_START)
|
1046 |
|
|
{
|
1047 |
|
|
TELL_OBJFILE;
|
1048 |
|
|
warning ("File \"%s\" [0x%x] crosses beginning of module \"%s\".",
|
1049 |
|
|
&vt_bits[(long) qFD[curr_fd].sbFile],
|
1050 |
|
|
curr_fd, mod_name_string);
|
1051 |
|
|
|
1052 |
|
|
start_adr = CURR_FILE_START;
|
1053 |
|
|
}
|
1054 |
|
|
}
|
1055 |
|
|
|
1056 |
|
|
/* Also pick the lower of the file's and the module's start symbol indices */
|
1057 |
|
|
start_sym = CURR_MODULE_ISYM;
|
1058 |
|
|
if (VALID_CURR_FILE && (CURR_FILE_ISYM < CURR_MODULE_ISYM))
|
1059 |
|
|
start_sym = CURR_FILE_ISYM;
|
1060 |
|
|
|
1061 |
|
|
/* For the end address, we scan through the files till we find one
|
1062 |
|
|
that overlaps the current module but ends beyond it; if no such file exists we
|
1063 |
|
|
simply use the module's start address.
|
1064 |
|
|
(Note, if file entries themselves overlap
|
1065 |
|
|
we take the longest overlapping extension beyond the end of the module...)
|
1066 |
|
|
We assume that modules never overlap. */
|
1067 |
|
|
|
1068 |
|
|
end_adr = CURR_MODULE_END;
|
1069 |
|
|
|
1070 |
|
|
if (VALID_CURR_FILE)
|
1071 |
|
|
{
|
1072 |
|
|
while (VALID_CURR_FILE && (CURR_FILE_START < end_adr))
|
1073 |
|
|
{
|
1074 |
|
|
|
1075 |
|
|
#ifdef DUMPING
|
1076 |
|
|
if (dumping)
|
1077 |
|
|
printf ("Maybe skipping file %s which overlaps with module %s\n",
|
1078 |
|
|
&vt_bits[(long) qFD[curr_fd].sbFile], mod_name_string);
|
1079 |
|
|
#endif
|
1080 |
|
|
if (CURR_FILE_END > end_adr)
|
1081 |
|
|
{
|
1082 |
|
|
TELL_OBJFILE;
|
1083 |
|
|
warning ("File \"%s\" [0x%x] crosses end of module \"%s\".",
|
1084 |
|
|
&vt_bits[(long) qFD[curr_fd].sbFile],
|
1085 |
|
|
curr_fd, mod_name_string);
|
1086 |
|
|
end_adr = CURR_FILE_END;
|
1087 |
|
|
}
|
1088 |
|
|
curr_fd++;
|
1089 |
|
|
}
|
1090 |
|
|
curr_fd--; /* back up after going too far */
|
1091 |
|
|
}
|
1092 |
|
|
|
1093 |
|
|
/* Sometimes (compiler bug -- COBOL) the module end address is higher
|
1094 |
|
|
than the start address of the next module, so check for that and
|
1095 |
|
|
adjust accordingly */
|
1096 |
|
|
|
1097 |
|
|
if (VALID_MODULE (curr_md + 1) && (MODULE_START (curr_md + 1) <= end_adr))
|
1098 |
|
|
{
|
1099 |
|
|
TELL_OBJFILE;
|
1100 |
|
|
warning ("Module \"%s\" [0x%x] has ending address after starting address of next module; adjusting ending address down.",
|
1101 |
|
|
mod_name_string, curr_md);
|
1102 |
|
|
end_adr = MODULE_START (curr_md + 1) - 1; /* Is -4 (or -8 for 64-bit) better? */
|
1103 |
|
|
}
|
1104 |
|
|
if (VALID_FILE (curr_fd + 1) && (FILE_START (curr_fd + 1) <= end_adr))
|
1105 |
|
|
{
|
1106 |
|
|
TELL_OBJFILE;
|
1107 |
|
|
warning ("Module \"%s\" [0x%x] has ending address after starting address of next file; adjusting ending address down.",
|
1108 |
|
|
mod_name_string, curr_md);
|
1109 |
|
|
end_adr = FILE_START (curr_fd + 1) - 1; /* Is -4 (or -8 for 64-bit) better? */
|
1110 |
|
|
}
|
1111 |
|
|
|
1112 |
|
|
/* Use one file to get the full name for the module. This
|
1113 |
|
|
situation can arise if there is executable code in a #include
|
1114 |
|
|
file. Each file with code in it gets a qFD. Files which don't
|
1115 |
|
|
contribute code don't get a qFD, even if they include files
|
1116 |
|
|
which do, e.g.:
|
1117 |
|
|
|
1118 |
|
|
body.c: rtn.h:
|
1119 |
|
|
int x; int main() {
|
1120 |
|
|
#include "rtn.h" return x;
|
1121 |
|
|
}
|
1122 |
|
|
|
1123 |
|
|
There will a qFD for "rtn.h",and a qMD for "body.c",
|
1124 |
|
|
but no qMD for "rtn.h" or qFD for "body.c"!
|
1125 |
|
|
|
1126 |
|
|
We pick the name of the last file to overlap with this
|
1127 |
|
|
module. C convention is to put include files first. In a
|
1128 |
|
|
perfect world, we could check names and use the file whose full
|
1129 |
|
|
path name ends with the module name. */
|
1130 |
|
|
|
1131 |
|
|
if (VALID_CURR_FILE)
|
1132 |
|
|
full_name_string = &vt_bits[(long) qFD[curr_fd].sbFile];
|
1133 |
|
|
else
|
1134 |
|
|
full_name_string = mod_name_string;
|
1135 |
|
|
|
1136 |
|
|
/* Check if there are any procedures not handled until now, that
|
1137 |
|
|
begin before the start address we have now, and if so, adjust
|
1138 |
|
|
this psymtab's start address to include them. This handles routines that
|
1139 |
|
|
are in between file or module ranges for some reason (probably
|
1140 |
|
|
indicates a compiler bug */
|
1141 |
|
|
|
1142 |
|
|
if (CURR_PROC_START < start_adr)
|
1143 |
|
|
{
|
1144 |
|
|
TELL_OBJFILE;
|
1145 |
|
|
warning ("Found procedure \"%s\" [0x%x] that is not in any file or module.",
|
1146 |
|
|
&vt_bits[(long) qPD[curr_pd].sbProc], curr_pd);
|
1147 |
|
|
start_adr = CURR_PROC_START;
|
1148 |
|
|
if (CURR_PROC_ISYM < start_sym)
|
1149 |
|
|
start_sym = CURR_PROC_ISYM;
|
1150 |
|
|
}
|
1151 |
|
|
|
1152 |
|
|
#ifdef DUMPING
|
1153 |
|
|
if (dumping)
|
1154 |
|
|
{
|
1155 |
|
|
printf ("Make new psymtab for module %s (%x to %x), using file %s\n",
|
1156 |
|
|
mod_name_string, start_adr, end_adr, full_name_string);
|
1157 |
|
|
}
|
1158 |
|
|
#endif
|
1159 |
|
|
/* Create the basic psymtab, connecting it in the list
|
1160 |
|
|
for this objfile and pointing its symbol entries
|
1161 |
|
|
to the current end of the symbol areas in the objfile.
|
1162 |
|
|
|
1163 |
|
|
The "ldsymoff" parameter is the byte offset in the LNTT
|
1164 |
|
|
of the first symbol in this file. Some day we should
|
1165 |
|
|
turn this into an index (fix in hp-symtab-read.c as well).
|
1166 |
|
|
And it's not even the right byte offset, as we're using
|
1167 |
|
|
the size of a union! FIXME! */
|
1168 |
|
|
pst = hpread_start_psymtab (objfile,
|
1169 |
|
|
full_name_string,
|
1170 |
|
|
start_adr, /* Low text address */
|
1171 |
|
|
(start_sym * sizeof (struct dntt_type_block)),
|
1172 |
|
|
/* ldsymoff */
|
1173 |
|
|
global_syms,
|
1174 |
|
|
static_syms);
|
1175 |
|
|
|
1176 |
|
|
/* Set up to only enter each class referenced in this module once. */
|
1177 |
|
|
class_entered = xmalloc (B_BYTES (pxdb_header_p->cd_entries));
|
1178 |
|
|
B_CLRALL (class_entered, pxdb_header_p->cd_entries);
|
1179 |
|
|
|
1180 |
|
|
/* Scan the procedure descriptors for procedures in the current
|
1181 |
|
|
module, based on the starting addresses. */
|
1182 |
|
|
|
1183 |
|
|
syms_in_pst = scan_procs (&curr_pd, qPD, pxdb_header_p->pd_entries,
|
1184 |
|
|
start_adr, end_adr, pst, vt_bits, objfile);
|
1185 |
|
|
|
1186 |
|
|
/* Get ending symbol offset */
|
1187 |
|
|
|
1188 |
|
|
end_sym = 0;
|
1189 |
|
|
/* First check for starting index before previous psymtab */
|
1190 |
|
|
if (pst_syms_count && start_sym < pst_syms_array[pst_syms_count - 1].end)
|
1191 |
|
|
{
|
1192 |
|
|
end_sym = find_next_pst_start (start_sym);
|
1193 |
|
|
}
|
1194 |
|
|
/* Look for next start index of a file or module, or procedure */
|
1195 |
|
|
if (!end_sym)
|
1196 |
|
|
{
|
1197 |
|
|
int next_file_isym = find_next_file_isym (start_sym, qFD, curr_fd + 1, pxdb_header_p);
|
1198 |
|
|
int next_module_isym = find_next_module_isym (start_sym, qMD, curr_md + 1, pxdb_header_p);
|
1199 |
|
|
int next_proc_isym = find_next_proc_isym (start_sym, qPD, curr_pd, pxdb_header_p);
|
1200 |
|
|
|
1201 |
|
|
if (next_file_isym && next_module_isym)
|
1202 |
|
|
{
|
1203 |
|
|
/* pick lower of next file or module start index */
|
1204 |
|
|
end_sym = min (next_file_isym, next_module_isym);
|
1205 |
|
|
}
|
1206 |
|
|
else
|
1207 |
|
|
{
|
1208 |
|
|
/* one of them is zero, pick the other */
|
1209 |
|
|
end_sym = max (next_file_isym, next_module_isym);
|
1210 |
|
|
}
|
1211 |
|
|
|
1212 |
|
|
/* As a precaution, check next procedure index too */
|
1213 |
|
|
if (!end_sym)
|
1214 |
|
|
end_sym = next_proc_isym;
|
1215 |
|
|
else
|
1216 |
|
|
end_sym = min (end_sym, next_proc_isym);
|
1217 |
|
|
}
|
1218 |
|
|
|
1219 |
|
|
/* Couldn't find procedure, file, or module, use globals as default */
|
1220 |
|
|
if (!end_sym)
|
1221 |
|
|
end_sym = pxdb_header_p->globals;
|
1222 |
|
|
|
1223 |
|
|
#ifdef DUMPING
|
1224 |
|
|
if (dumping)
|
1225 |
|
|
{
|
1226 |
|
|
printf ("Module psymtab indices: %x to %x\n", start_sym, end_sym);
|
1227 |
|
|
}
|
1228 |
|
|
#endif
|
1229 |
|
|
|
1230 |
|
|
pst = hpread_end_psymtab (pst,
|
1231 |
|
|
NULL, /* psymtab_include_list */
|
1232 |
|
|
0, /* includes_used */
|
1233 |
|
|
end_sym * sizeof (struct dntt_type_block),
|
1234 |
|
|
/* byte index in LNTT of end
|
1235 |
|
|
= capping symbol offset
|
1236 |
|
|
= LDSYMOFF of nextfile */
|
1237 |
|
|
end_adr, /* text high */
|
1238 |
|
|
NULL, /* dependency_list */
|
1239 |
|
|
0); /* dependencies_used */
|
1240 |
|
|
|
1241 |
|
|
record_pst_syms (start_sym, end_sym);
|
1242 |
|
|
|
1243 |
|
|
if (NULL == pst)
|
1244 |
|
|
warning ("No symbols in psymtab for module \"%s\" [0x%x].", mod_name_string, curr_md);
|
1245 |
|
|
|
1246 |
|
|
#ifdef DUMPING
|
1247 |
|
|
if (dumping)
|
1248 |
|
|
{
|
1249 |
|
|
printf ("Made new psymtab for module %s (%x to %x), sym %x to %x.\n",
|
1250 |
|
|
mod_name_string, start_adr, end_adr, CURR_MODULE_ISYM, end_sym);
|
1251 |
|
|
}
|
1252 |
|
|
#endif
|
1253 |
|
|
|
1254 |
|
|
/* Prepare for the next psymtab. */
|
1255 |
|
|
global_syms = objfile->global_psymbols.next;
|
1256 |
|
|
static_syms = objfile->static_psymbols.next;
|
1257 |
|
|
xfree (class_entered);
|
1258 |
|
|
|
1259 |
|
|
curr_md++;
|
1260 |
|
|
curr_fd++;
|
1261 |
|
|
} /* psymtab for module */
|
1262 |
|
|
} /* psymtab for non-bogus file or module */
|
1263 |
|
|
} /* End of while loop over all files & modules */
|
1264 |
|
|
|
1265 |
|
|
/* There may be some routines after all files and modules -- these will get
|
1266 |
|
|
inserted in a separate new module of their own */
|
1267 |
|
|
if (VALID_CURR_PROC)
|
1268 |
|
|
{
|
1269 |
|
|
start_adr = CURR_PROC_START;
|
1270 |
|
|
end_adr = qPD[pxdb_header_p->pd_entries - 1].adrEnd;
|
1271 |
|
|
TELL_OBJFILE;
|
1272 |
|
|
warning ("Found functions beyond end of all files and modules [0x%x].", curr_pd);
|
1273 |
|
|
#ifdef DUMPING
|
1274 |
|
|
if (dumping)
|
1275 |
|
|
{
|
1276 |
|
|
printf ("Orphan functions at end, PD %d and beyond (%x to %x)\n",
|
1277 |
|
|
curr_pd, start_adr, end_adr);
|
1278 |
|
|
}
|
1279 |
|
|
#endif
|
1280 |
|
|
pst = hpread_start_psymtab (objfile,
|
1281 |
|
|
"orphans",
|
1282 |
|
|
start_adr, /* Low text address */
|
1283 |
|
|
(CURR_PROC_ISYM * sizeof (struct dntt_type_block)),
|
1284 |
|
|
/* ldsymoff */
|
1285 |
|
|
global_syms,
|
1286 |
|
|
static_syms);
|
1287 |
|
|
|
1288 |
|
|
scan_procs (&curr_pd, qPD, pxdb_header_p->pd_entries,
|
1289 |
|
|
start_adr, end_adr, pst, vt_bits, objfile);
|
1290 |
|
|
|
1291 |
|
|
pst = hpread_end_psymtab (pst,
|
1292 |
|
|
NULL, /* psymtab_include_list */
|
1293 |
|
|
0, /* includes_used */
|
1294 |
|
|
pxdb_header_p->globals * sizeof (struct dntt_type_block),
|
1295 |
|
|
/* byte index in LNTT of end
|
1296 |
|
|
= capping symbol offset
|
1297 |
|
|
= LDSYMOFF of nextfile */
|
1298 |
|
|
end_adr, /* text high */
|
1299 |
|
|
NULL, /* dependency_list */
|
1300 |
|
|
0); /* dependencies_used */
|
1301 |
|
|
}
|
1302 |
|
|
|
1303 |
|
|
|
1304 |
|
|
#ifdef NEVER_NEVER
|
1305 |
|
|
/* Now build psts for non-module things (in the tail of
|
1306 |
|
|
the LNTT, after the last END MODULE entry).
|
1307 |
|
|
|
1308 |
|
|
If null psts were kept on the chain, this would be
|
1309 |
|
|
a solution. FIXME */
|
1310 |
|
|
pst = hpread_start_psymtab (objfile,
|
1311 |
|
|
"globals",
|
1312 |
|
|
0,
|
1313 |
|
|
(pxdb_header_p->globals
|
1314 |
|
|
* sizeof (struct dntt_type_block)),
|
1315 |
|
|
objfile->global_psymbols.next,
|
1316 |
|
|
objfile->static_psymbols.next);
|
1317 |
|
|
hpread_end_psymtab (pst,
|
1318 |
|
|
NULL, 0,
|
1319 |
|
|
(max_LNTT_sym_index * sizeof (struct dntt_type_block)),
|
1320 |
|
|
0,
|
1321 |
|
|
NULL, 0);
|
1322 |
|
|
#endif
|
1323 |
|
|
|
1324 |
|
|
clear_pst_syms ();
|
1325 |
|
|
|
1326 |
|
|
return 1;
|
1327 |
|
|
|
1328 |
|
|
} /* End of hpread_quick_traverse. */
|
1329 |
|
|
|
1330 |
|
|
|
1331 |
|
|
/* Get appropriate header, based on pxdb type.
|
1332 |
|
|
Return value: 1 if ok, 0 if not */
|
1333 |
|
|
int
|
1334 |
|
|
hpread_get_header (struct objfile *objfile, PXDB_header_ptr pxdb_header_p)
|
1335 |
|
|
{
|
1336 |
|
|
asection *pinfo_section, *debug_section, *header_section;
|
1337 |
|
|
|
1338 |
|
|
#ifdef DUMPING
|
1339 |
|
|
/* Turn on for debugging information */
|
1340 |
|
|
static int dumping = 0;
|
1341 |
|
|
#endif
|
1342 |
|
|
|
1343 |
|
|
header_section = bfd_get_section_by_name (objfile->obfd, "$HEADER$");
|
1344 |
|
|
if (!header_section)
|
1345 |
|
|
{
|
1346 |
|
|
/* We don't have either PINFO or DEBUG sections. But
|
1347 |
|
|
stuff like "libc.sl" has no debug info. There's no
|
1348 |
|
|
need to warn the user of this, as it may be ok. The
|
1349 |
|
|
caller will figure it out and issue any needed
|
1350 |
|
|
messages. */
|
1351 |
|
|
#ifdef DUMPING
|
1352 |
|
|
if (dumping)
|
1353 |
|
|
printf ("==No debug info at all for %s.\n", objfile->name);
|
1354 |
|
|
#endif
|
1355 |
|
|
|
1356 |
|
|
return 0;
|
1357 |
|
|
}
|
1358 |
|
|
|
1359 |
|
|
/* We would like either a $DEBUG$ or $PINFO$ section.
|
1360 |
|
|
Once we know which, we can understand the header
|
1361 |
|
|
data (which we have defined to suit the more common
|
1362 |
|
|
$DEBUG$ case). */
|
1363 |
|
|
debug_section = bfd_get_section_by_name (objfile->obfd, "$DEBUG$");
|
1364 |
|
|
pinfo_section = bfd_get_section_by_name (objfile->obfd, "$PINFO$");
|
1365 |
|
|
if (debug_section)
|
1366 |
|
|
{
|
1367 |
|
|
/* The expected case: normal pxdb header. */
|
1368 |
|
|
bfd_get_section_contents (objfile->obfd, header_section,
|
1369 |
|
|
pxdb_header_p, 0, sizeof (PXDB_header));
|
1370 |
|
|
|
1371 |
|
|
if (!pxdb_header_p->pxdbed)
|
1372 |
|
|
{
|
1373 |
|
|
/* This shouldn't happen if we check in "symfile.c". */
|
1374 |
|
|
return 0;
|
1375 |
|
|
} /* DEBUG section */
|
1376 |
|
|
}
|
1377 |
|
|
|
1378 |
|
|
else if (pinfo_section)
|
1379 |
|
|
{
|
1380 |
|
|
/* The DOC case; we need to translate this into a
|
1381 |
|
|
regular header. */
|
1382 |
|
|
DOC_info_PXDB_header doc_header;
|
1383 |
|
|
|
1384 |
|
|
#ifdef DUMPING
|
1385 |
|
|
if (dumping)
|
1386 |
|
|
{
|
1387 |
|
|
printf ("==OOps, PINFO, let's try to handle this, %s.\n", objfile->name);
|
1388 |
|
|
}
|
1389 |
|
|
#endif
|
1390 |
|
|
|
1391 |
|
|
bfd_get_section_contents (objfile->obfd,
|
1392 |
|
|
header_section,
|
1393 |
|
|
&doc_header, 0,
|
1394 |
|
|
sizeof (DOC_info_PXDB_header));
|
1395 |
|
|
|
1396 |
|
|
if (!doc_header.pxdbed)
|
1397 |
|
|
{
|
1398 |
|
|
/* This shouldn't happen if we check in "symfile.c". */
|
1399 |
|
|
warning ("File \"%s\" not processed by pxdb!", objfile->name);
|
1400 |
|
|
return 0;
|
1401 |
|
|
}
|
1402 |
|
|
|
1403 |
|
|
/* Copy relevent fields to standard header passed in. */
|
1404 |
|
|
pxdb_header_p->pd_entries = doc_header.pd_entries;
|
1405 |
|
|
pxdb_header_p->fd_entries = doc_header.fd_entries;
|
1406 |
|
|
pxdb_header_p->md_entries = doc_header.md_entries;
|
1407 |
|
|
pxdb_header_p->pxdbed = doc_header.pxdbed;
|
1408 |
|
|
pxdb_header_p->bighdr = doc_header.bighdr;
|
1409 |
|
|
pxdb_header_p->sa_header = doc_header.sa_header;
|
1410 |
|
|
pxdb_header_p->inlined = doc_header.inlined;
|
1411 |
|
|
pxdb_header_p->globals = doc_header.globals;
|
1412 |
|
|
pxdb_header_p->time = doc_header.time;
|
1413 |
|
|
pxdb_header_p->pg_entries = doc_header.pg_entries;
|
1414 |
|
|
pxdb_header_p->functions = doc_header.functions;
|
1415 |
|
|
pxdb_header_p->files = doc_header.files;
|
1416 |
|
|
pxdb_header_p->cd_entries = doc_header.cd_entries;
|
1417 |
|
|
pxdb_header_p->aa_entries = doc_header.aa_entries;
|
1418 |
|
|
pxdb_header_p->oi_entries = doc_header.oi_entries;
|
1419 |
|
|
pxdb_header_p->version = doc_header.version;
|
1420 |
|
|
} /* PINFO section */
|
1421 |
|
|
|
1422 |
|
|
else
|
1423 |
|
|
{
|
1424 |
|
|
#ifdef DUMPING
|
1425 |
|
|
if (dumping)
|
1426 |
|
|
printf ("==No debug info at all for %s.\n", objfile->name);
|
1427 |
|
|
#endif
|
1428 |
|
|
|
1429 |
|
|
return 0;
|
1430 |
|
|
|
1431 |
|
|
}
|
1432 |
|
|
|
1433 |
|
|
return 1;
|
1434 |
|
|
} /* End of hpread_get_header */
|
1435 |
|
|
#endif /* QUICK_LOOK_UP */
|
1436 |
|
|
|
1437 |
|
|
|
1438 |
|
|
/* Initialization for reading native HP C debug symbols from OBJFILE.
|
1439 |
|
|
|
1440 |
|
|
Its only purpose in life is to set up the symbol reader's private
|
1441 |
|
|
per-objfile data structures, and read in the raw contents of the debug
|
1442 |
|
|
sections (attaching pointers to the debug info into the private data
|
1443 |
|
|
structures).
|
1444 |
|
|
|
1445 |
|
|
Since BFD doesn't know how to read debug symbols in a format-independent
|
1446 |
|
|
way (and may never do so...), we have to do it ourselves. Note we may
|
1447 |
|
|
be called on a file without native HP C debugging symbols.
|
1448 |
|
|
|
1449 |
|
|
FIXME, there should be a cleaner peephole into the BFD environment
|
1450 |
|
|
here. */
|
1451 |
|
|
void
|
1452 |
|
|
hpread_symfile_init (struct objfile *objfile)
|
1453 |
|
|
{
|
1454 |
|
|
asection *vt_section, *slt_section, *lntt_section, *gntt_section;
|
1455 |
|
|
|
1456 |
|
|
/* Allocate struct to keep track of the symfile */
|
1457 |
|
|
objfile->sym_private = (PTR)
|
1458 |
|
|
xmmalloc (objfile->md, sizeof (struct hpread_symfile_info));
|
1459 |
|
|
memset (objfile->sym_private, 0, sizeof (struct hpread_symfile_info));
|
1460 |
|
|
|
1461 |
|
|
/* We haven't read in any types yet. */
|
1462 |
|
|
TYPE_VECTOR (objfile) = 0;
|
1463 |
|
|
|
1464 |
|
|
/* Read in data from the $GNTT$ subspace. */
|
1465 |
|
|
gntt_section = bfd_get_section_by_name (objfile->obfd, "$GNTT$");
|
1466 |
|
|
if (!gntt_section)
|
1467 |
|
|
return;
|
1468 |
|
|
|
1469 |
|
|
GNTT (objfile)
|
1470 |
|
|
= obstack_alloc (&objfile->symbol_obstack,
|
1471 |
|
|
bfd_section_size (objfile->obfd, gntt_section));
|
1472 |
|
|
|
1473 |
|
|
bfd_get_section_contents (objfile->obfd, gntt_section, GNTT (objfile),
|
1474 |
|
|
0, bfd_section_size (objfile->obfd, gntt_section));
|
1475 |
|
|
|
1476 |
|
|
GNTT_SYMCOUNT (objfile)
|
1477 |
|
|
= bfd_section_size (objfile->obfd, gntt_section)
|
1478 |
|
|
/ sizeof (struct dntt_type_block);
|
1479 |
|
|
|
1480 |
|
|
/* Read in data from the $LNTT$ subspace. Also keep track of the number
|
1481 |
|
|
of LNTT symbols.
|
1482 |
|
|
|
1483 |
|
|
FIXME: this could be moved into the psymtab-to-symtab expansion
|
1484 |
|
|
code, and save startup time. At the moment this data is
|
1485 |
|
|
still used, though. We'd need a way to tell hp-symtab-read.c
|
1486 |
|
|
whether or not to load the LNTT. */
|
1487 |
|
|
lntt_section = bfd_get_section_by_name (objfile->obfd, "$LNTT$");
|
1488 |
|
|
if (!lntt_section)
|
1489 |
|
|
return;
|
1490 |
|
|
|
1491 |
|
|
LNTT (objfile)
|
1492 |
|
|
= obstack_alloc (&objfile->symbol_obstack,
|
1493 |
|
|
bfd_section_size (objfile->obfd, lntt_section));
|
1494 |
|
|
|
1495 |
|
|
bfd_get_section_contents (objfile->obfd, lntt_section, LNTT (objfile),
|
1496 |
|
|
0, bfd_section_size (objfile->obfd, lntt_section));
|
1497 |
|
|
|
1498 |
|
|
LNTT_SYMCOUNT (objfile)
|
1499 |
|
|
= bfd_section_size (objfile->obfd, lntt_section)
|
1500 |
|
|
/ sizeof (struct dntt_type_block);
|
1501 |
|
|
|
1502 |
|
|
/* Read in data from the $SLT$ subspace. $SLT$ contains information
|
1503 |
|
|
on source line numbers. */
|
1504 |
|
|
slt_section = bfd_get_section_by_name (objfile->obfd, "$SLT$");
|
1505 |
|
|
if (!slt_section)
|
1506 |
|
|
return;
|
1507 |
|
|
|
1508 |
|
|
SLT (objfile) =
|
1509 |
|
|
obstack_alloc (&objfile->symbol_obstack,
|
1510 |
|
|
bfd_section_size (objfile->obfd, slt_section));
|
1511 |
|
|
|
1512 |
|
|
bfd_get_section_contents (objfile->obfd, slt_section, SLT (objfile),
|
1513 |
|
|
0, bfd_section_size (objfile->obfd, slt_section));
|
1514 |
|
|
|
1515 |
|
|
/* Read in data from the $VT$ subspace. $VT$ contains things like
|
1516 |
|
|
names and constants. Keep track of the number of symbols in the VT. */
|
1517 |
|
|
vt_section = bfd_get_section_by_name (objfile->obfd, "$VT$");
|
1518 |
|
|
if (!vt_section)
|
1519 |
|
|
return;
|
1520 |
|
|
|
1521 |
|
|
VT_SIZE (objfile) = bfd_section_size (objfile->obfd, vt_section);
|
1522 |
|
|
|
1523 |
|
|
VT (objfile) =
|
1524 |
|
|
(char *) obstack_alloc (&objfile->symbol_obstack,
|
1525 |
|
|
VT_SIZE (objfile));
|
1526 |
|
|
|
1527 |
|
|
bfd_get_section_contents (objfile->obfd, vt_section, VT (objfile),
|
1528 |
|
|
0, VT_SIZE (objfile));
|
1529 |
|
|
}
|
1530 |
|
|
|
1531 |
|
|
/* Scan and build partial symbols for a symbol file.
|
1532 |
|
|
|
1533 |
|
|
The minimal symbol table (either SOM or HP a.out) has already been
|
1534 |
|
|
read in; all we need to do is setup partial symbols based on the
|
1535 |
|
|
native debugging information.
|
1536 |
|
|
|
1537 |
|
|
Note that the minimal table is produced by the linker, and has
|
1538 |
|
|
only global routines in it; the psymtab is based on compiler-
|
1539 |
|
|
generated debug information and has non-global
|
1540 |
|
|
routines in it as well as files and class information.
|
1541 |
|
|
|
1542 |
|
|
We assume hpread_symfile_init has been called to initialize the
|
1543 |
|
|
symbol reader's private data structures.
|
1544 |
|
|
|
1545 |
|
|
MAINLINE is true if we are reading the main symbol table (as
|
1546 |
|
|
opposed to a shared lib or dynamically loaded file). */
|
1547 |
|
|
|
1548 |
|
|
void
|
1549 |
|
|
hpread_build_psymtabs (struct objfile *objfile, int mainline)
|
1550 |
|
|
{
|
1551 |
|
|
|
1552 |
|
|
#ifdef DUMPING
|
1553 |
|
|
/* Turn this on to get debugging output. */
|
1554 |
|
|
static int dumping = 0;
|
1555 |
|
|
#endif
|
1556 |
|
|
|
1557 |
|
|
char *namestring;
|
1558 |
|
|
int past_first_source_file = 0;
|
1559 |
|
|
struct cleanup *old_chain;
|
1560 |
|
|
|
1561 |
|
|
int hp_symnum, symcount, i;
|
1562 |
|
|
int scan_start = 0;
|
1563 |
|
|
|
1564 |
|
|
union dnttentry *dn_bufp;
|
1565 |
|
|
unsigned long valu;
|
1566 |
|
|
char *p;
|
1567 |
|
|
int texthigh = 0;
|
1568 |
|
|
int have_name = 0;
|
1569 |
|
|
|
1570 |
|
|
/* Current partial symtab */
|
1571 |
|
|
struct partial_symtab *pst;
|
1572 |
|
|
|
1573 |
|
|
/* List of current psymtab's include files */
|
1574 |
|
|
char **psymtab_include_list;
|
1575 |
|
|
int includes_allocated;
|
1576 |
|
|
int includes_used;
|
1577 |
|
|
|
1578 |
|
|
/* Index within current psymtab dependency list */
|
1579 |
|
|
struct partial_symtab **dependency_list;
|
1580 |
|
|
int dependencies_used, dependencies_allocated;
|
1581 |
|
|
|
1582 |
|
|
/* Just in case the stabs reader left turds lying around. */
|
1583 |
|
|
free_pending_blocks ();
|
1584 |
|
|
make_cleanup (really_free_pendings, 0);
|
1585 |
|
|
|
1586 |
|
|
pst = (struct partial_symtab *) 0;
|
1587 |
|
|
|
1588 |
|
|
/* We shouldn't use alloca, instead use malloc/free. Doing so avoids
|
1589 |
|
|
a number of problems with cross compilation and creating useless holes
|
1590 |
|
|
in the stack when we have to allocate new entries. FIXME. */
|
1591 |
|
|
|
1592 |
|
|
includes_allocated = 30;
|
1593 |
|
|
includes_used = 0;
|
1594 |
|
|
psymtab_include_list = (char **) alloca (includes_allocated *
|
1595 |
|
|
sizeof (char *));
|
1596 |
|
|
|
1597 |
|
|
dependencies_allocated = 30;
|
1598 |
|
|
dependencies_used = 0;
|
1599 |
|
|
dependency_list =
|
1600 |
|
|
(struct partial_symtab **) alloca (dependencies_allocated *
|
1601 |
|
|
sizeof (struct partial_symtab *));
|
1602 |
|
|
|
1603 |
|
|
old_chain = make_cleanup_free_objfile (objfile);
|
1604 |
|
|
|
1605 |
|
|
last_source_file = 0;
|
1606 |
|
|
|
1607 |
|
|
#ifdef QUICK_LOOK_UP
|
1608 |
|
|
{
|
1609 |
|
|
/* Begin code for new-style loading of quick look-up tables. */
|
1610 |
|
|
|
1611 |
|
|
/* elz: this checks whether the file has beeen processed by pxdb.
|
1612 |
|
|
If not we would like to try to read the psymbols in
|
1613 |
|
|
anyway, but it turns out to be not so easy. So this could
|
1614 |
|
|
actually be commented out, but I leave it in, just in case
|
1615 |
|
|
we decide to add support for non-pxdb-ed stuff in the future. */
|
1616 |
|
|
PXDB_header pxdb_header;
|
1617 |
|
|
int found_modules_in_program;
|
1618 |
|
|
|
1619 |
|
|
if (hpread_get_header (objfile, &pxdb_header))
|
1620 |
|
|
{
|
1621 |
|
|
/* Build a minimal table. No types, no global variables,
|
1622 |
|
|
no include files.... */
|
1623 |
|
|
#ifdef DUMPING
|
1624 |
|
|
if (dumping)
|
1625 |
|
|
printf ("\nNew method for %s\n", objfile->name);
|
1626 |
|
|
#endif
|
1627 |
|
|
|
1628 |
|
|
/* elz: quick_traverse returns true if it found
|
1629 |
|
|
some modules in the main source file, other
|
1630 |
|
|
than those in end.c
|
1631 |
|
|
In C and C++, all the files have MODULES entries
|
1632 |
|
|
in the LNTT, and the quick table traverse is all
|
1633 |
|
|
based on finding these MODULES entries. Without
|
1634 |
|
|
those it cannot work.
|
1635 |
|
|
It happens that F77 programs don't have MODULES
|
1636 |
|
|
so the quick traverse gets confused. F90 programs
|
1637 |
|
|
have modules, and the quick method still works.
|
1638 |
|
|
So, if modules (other than those in end.c) are
|
1639 |
|
|
not found we give up on the quick table stuff,
|
1640 |
|
|
and fall back on the slower method */
|
1641 |
|
|
found_modules_in_program = hpread_quick_traverse (objfile,
|
1642 |
|
|
GNTT (objfile),
|
1643 |
|
|
VT (objfile),
|
1644 |
|
|
&pxdb_header);
|
1645 |
|
|
|
1646 |
|
|
discard_cleanups (old_chain);
|
1647 |
|
|
|
1648 |
|
|
/* Set up to scan the global section of the LNTT.
|
1649 |
|
|
|
1650 |
|
|
This field is not always correct: if there are
|
1651 |
|
|
no globals, it will point to the last record in
|
1652 |
|
|
the regular LNTT, which is usually an END MODULE.
|
1653 |
|
|
|
1654 |
|
|
Since it might happen that there could be a file
|
1655 |
|
|
with just one global record, there's no way to
|
1656 |
|
|
tell other than by looking at the record, so that's
|
1657 |
|
|
done below. */
|
1658 |
|
|
if (found_modules_in_program)
|
1659 |
|
|
scan_start = pxdb_header.globals;
|
1660 |
|
|
}
|
1661 |
|
|
#ifdef DUMPING
|
1662 |
|
|
else
|
1663 |
|
|
{
|
1664 |
|
|
if (dumping)
|
1665 |
|
|
printf ("\nGoing on to old method for %s\n", objfile->name);
|
1666 |
|
|
}
|
1667 |
|
|
#endif
|
1668 |
|
|
}
|
1669 |
|
|
#endif /* QUICK_LOOK_UP */
|
1670 |
|
|
|
1671 |
|
|
/* Make two passes, one over the GNTT symbols, the other for the
|
1672 |
|
|
LNTT symbols.
|
1673 |
|
|
|
1674 |
|
|
JB comment: above isn't true--they only make one pass, over
|
1675 |
|
|
the LNTT. */
|
1676 |
|
|
for (i = 0; i < 1; i++)
|
1677 |
|
|
{
|
1678 |
|
|
int within_function = 0;
|
1679 |
|
|
|
1680 |
|
|
if (i)
|
1681 |
|
|
symcount = GNTT_SYMCOUNT (objfile);
|
1682 |
|
|
else
|
1683 |
|
|
symcount = LNTT_SYMCOUNT (objfile);
|
1684 |
|
|
|
1685 |
|
|
|
1686 |
|
|
for (hp_symnum = scan_start; hp_symnum < symcount; hp_symnum++)
|
1687 |
|
|
{
|
1688 |
|
|
QUIT;
|
1689 |
|
|
if (i)
|
1690 |
|
|
dn_bufp = hpread_get_gntt (hp_symnum, objfile);
|
1691 |
|
|
else
|
1692 |
|
|
dn_bufp = hpread_get_lntt (hp_symnum, objfile);
|
1693 |
|
|
|
1694 |
|
|
if (dn_bufp->dblock.extension)
|
1695 |
|
|
continue;
|
1696 |
|
|
|
1697 |
|
|
/* Only handle things which are necessary for minimal symbols.
|
1698 |
|
|
everything else is ignored. */
|
1699 |
|
|
switch (dn_bufp->dblock.kind)
|
1700 |
|
|
{
|
1701 |
|
|
case DNTT_TYPE_SRCFILE:
|
1702 |
|
|
{
|
1703 |
|
|
#ifdef QUICK_LOOK_UP
|
1704 |
|
|
if (scan_start == hp_symnum
|
1705 |
|
|
&& symcount == hp_symnum + 1)
|
1706 |
|
|
{
|
1707 |
|
|
/* If there are NO globals in an executable,
|
1708 |
|
|
PXDB's index to the globals will point to
|
1709 |
|
|
the last record in the file, which
|
1710 |
|
|
could be this record. (this happened for F77 libraries)
|
1711 |
|
|
ignore it and be done! */
|
1712 |
|
|
continue;
|
1713 |
|
|
}
|
1714 |
|
|
#endif /* QUICK_LOOK_UP */
|
1715 |
|
|
|
1716 |
|
|
/* A source file of some kind. Note this may simply
|
1717 |
|
|
be an included file. */
|
1718 |
|
|
SET_NAMESTRING (dn_bufp, &namestring, objfile);
|
1719 |
|
|
|
1720 |
|
|
/* Check if this is the source file we are already working
|
1721 |
|
|
with. */
|
1722 |
|
|
if (pst && !strcmp (namestring, pst->filename))
|
1723 |
|
|
continue;
|
1724 |
|
|
|
1725 |
|
|
/* Check if this is an include file, if so check if we have
|
1726 |
|
|
already seen it. Add it to the include list */
|
1727 |
|
|
p = strrchr (namestring, '.');
|
1728 |
|
|
if (!strcmp (p, ".h"))
|
1729 |
|
|
{
|
1730 |
|
|
int j, found;
|
1731 |
|
|
|
1732 |
|
|
found = 0;
|
1733 |
|
|
for (j = 0; j < includes_used; j++)
|
1734 |
|
|
if (!strcmp (namestring, psymtab_include_list[j]))
|
1735 |
|
|
{
|
1736 |
|
|
found = 1;
|
1737 |
|
|
break;
|
1738 |
|
|
}
|
1739 |
|
|
if (found)
|
1740 |
|
|
continue;
|
1741 |
|
|
|
1742 |
|
|
/* Add it to the list of includes seen so far and
|
1743 |
|
|
allocate more include space if necessary. */
|
1744 |
|
|
psymtab_include_list[includes_used++] = namestring;
|
1745 |
|
|
if (includes_used >= includes_allocated)
|
1746 |
|
|
{
|
1747 |
|
|
char **orig = psymtab_include_list;
|
1748 |
|
|
|
1749 |
|
|
psymtab_include_list = (char **)
|
1750 |
|
|
alloca ((includes_allocated *= 2) *
|
1751 |
|
|
sizeof (char *));
|
1752 |
|
|
memcpy ((PTR) psymtab_include_list, (PTR) orig,
|
1753 |
|
|
includes_used * sizeof (char *));
|
1754 |
|
|
}
|
1755 |
|
|
continue;
|
1756 |
|
|
}
|
1757 |
|
|
|
1758 |
|
|
if (pst)
|
1759 |
|
|
{
|
1760 |
|
|
if (!have_name)
|
1761 |
|
|
{
|
1762 |
|
|
pst->filename = (char *)
|
1763 |
|
|
obstack_alloc (&pst->objfile->psymbol_obstack,
|
1764 |
|
|
strlen (namestring) + 1);
|
1765 |
|
|
strcpy (pst->filename, namestring);
|
1766 |
|
|
have_name = 1;
|
1767 |
|
|
continue;
|
1768 |
|
|
}
|
1769 |
|
|
continue;
|
1770 |
|
|
}
|
1771 |
|
|
|
1772 |
|
|
/* This is a bonafide new source file.
|
1773 |
|
|
End the current partial symtab and start a new one. */
|
1774 |
|
|
|
1775 |
|
|
if (pst && past_first_source_file)
|
1776 |
|
|
{
|
1777 |
|
|
hpread_end_psymtab (pst, psymtab_include_list,
|
1778 |
|
|
includes_used,
|
1779 |
|
|
(hp_symnum
|
1780 |
|
|
* sizeof (struct dntt_type_block)),
|
1781 |
|
|
texthigh,
|
1782 |
|
|
dependency_list, dependencies_used);
|
1783 |
|
|
pst = (struct partial_symtab *) 0;
|
1784 |
|
|
includes_used = 0;
|
1785 |
|
|
dependencies_used = 0;
|
1786 |
|
|
}
|
1787 |
|
|
else
|
1788 |
|
|
past_first_source_file = 1;
|
1789 |
|
|
|
1790 |
|
|
valu = hpread_get_textlow (i, hp_symnum, objfile, symcount);
|
1791 |
|
|
valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
|
1792 |
|
|
pst = hpread_start_psymtab (objfile,
|
1793 |
|
|
namestring, valu,
|
1794 |
|
|
(hp_symnum
|
1795 |
|
|
* sizeof (struct dntt_type_block)),
|
1796 |
|
|
objfile->global_psymbols.next,
|
1797 |
|
|
objfile->static_psymbols.next);
|
1798 |
|
|
texthigh = valu;
|
1799 |
|
|
have_name = 1;
|
1800 |
|
|
continue;
|
1801 |
|
|
}
|
1802 |
|
|
|
1803 |
|
|
case DNTT_TYPE_MODULE:
|
1804 |
|
|
/* A source file. It's still unclear to me what the
|
1805 |
|
|
real difference between a DNTT_TYPE_SRCFILE and DNTT_TYPE_MODULE
|
1806 |
|
|
is supposed to be. */
|
1807 |
|
|
|
1808 |
|
|
/* First end the previous psymtab */
|
1809 |
|
|
if (pst)
|
1810 |
|
|
{
|
1811 |
|
|
hpread_end_psymtab (pst, psymtab_include_list, includes_used,
|
1812 |
|
|
((hp_symnum - 1)
|
1813 |
|
|
* sizeof (struct dntt_type_block)),
|
1814 |
|
|
texthigh,
|
1815 |
|
|
dependency_list, dependencies_used);
|
1816 |
|
|
pst = (struct partial_symtab *) 0;
|
1817 |
|
|
includes_used = 0;
|
1818 |
|
|
dependencies_used = 0;
|
1819 |
|
|
have_name = 0;
|
1820 |
|
|
}
|
1821 |
|
|
|
1822 |
|
|
/* Now begin a new module and a new psymtab for it */
|
1823 |
|
|
SET_NAMESTRING (dn_bufp, &namestring, objfile);
|
1824 |
|
|
valu = hpread_get_textlow (i, hp_symnum, objfile, symcount);
|
1825 |
|
|
valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
|
1826 |
|
|
if (!pst)
|
1827 |
|
|
{
|
1828 |
|
|
pst = hpread_start_psymtab (objfile,
|
1829 |
|
|
namestring, valu,
|
1830 |
|
|
(hp_symnum
|
1831 |
|
|
* sizeof (struct dntt_type_block)),
|
1832 |
|
|
objfile->global_psymbols.next,
|
1833 |
|
|
objfile->static_psymbols.next);
|
1834 |
|
|
texthigh = valu;
|
1835 |
|
|
have_name = 0;
|
1836 |
|
|
}
|
1837 |
|
|
continue;
|
1838 |
|
|
|
1839 |
|
|
case DNTT_TYPE_FUNCTION:
|
1840 |
|
|
case DNTT_TYPE_ENTRY:
|
1841 |
|
|
/* The beginning of a function. DNTT_TYPE_ENTRY may also denote
|
1842 |
|
|
a secondary entry point. */
|
1843 |
|
|
valu = dn_bufp->dfunc.hiaddr + ANOFFSET (objfile->section_offsets,
|
1844 |
|
|
SECT_OFF_TEXT (objfile));
|
1845 |
|
|
if (valu > texthigh)
|
1846 |
|
|
texthigh = valu;
|
1847 |
|
|
valu = dn_bufp->dfunc.lowaddr +
|
1848 |
|
|
ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
|
1849 |
|
|
SET_NAMESTRING (dn_bufp, &namestring, objfile);
|
1850 |
|
|
if (dn_bufp->dfunc.global)
|
1851 |
|
|
add_psymbol_to_list (namestring, strlen (namestring),
|
1852 |
|
|
VAR_NAMESPACE, LOC_BLOCK,
|
1853 |
|
|
&objfile->global_psymbols, valu,
|
1854 |
|
|
0, language_unknown, objfile);
|
1855 |
|
|
else
|
1856 |
|
|
add_psymbol_to_list (namestring, strlen (namestring),
|
1857 |
|
|
VAR_NAMESPACE, LOC_BLOCK,
|
1858 |
|
|
&objfile->static_psymbols, valu,
|
1859 |
|
|
0, language_unknown, objfile);
|
1860 |
|
|
within_function = 1;
|
1861 |
|
|
continue;
|
1862 |
|
|
|
1863 |
|
|
case DNTT_TYPE_DOC_FUNCTION:
|
1864 |
|
|
valu = dn_bufp->ddocfunc.hiaddr + ANOFFSET (objfile->section_offsets,
|
1865 |
|
|
SECT_OFF_TEXT (objfile));
|
1866 |
|
|
if (valu > texthigh)
|
1867 |
|
|
texthigh = valu;
|
1868 |
|
|
valu = dn_bufp->ddocfunc.lowaddr +
|
1869 |
|
|
ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
|
1870 |
|
|
SET_NAMESTRING (dn_bufp, &namestring, objfile);
|
1871 |
|
|
if (dn_bufp->ddocfunc.global)
|
1872 |
|
|
add_psymbol_to_list (namestring, strlen (namestring),
|
1873 |
|
|
VAR_NAMESPACE, LOC_BLOCK,
|
1874 |
|
|
&objfile->global_psymbols, valu,
|
1875 |
|
|
0, language_unknown, objfile);
|
1876 |
|
|
else
|
1877 |
|
|
add_psymbol_to_list (namestring, strlen (namestring),
|
1878 |
|
|
VAR_NAMESPACE, LOC_BLOCK,
|
1879 |
|
|
&objfile->static_psymbols, valu,
|
1880 |
|
|
0, language_unknown, objfile);
|
1881 |
|
|
within_function = 1;
|
1882 |
|
|
continue;
|
1883 |
|
|
|
1884 |
|
|
case DNTT_TYPE_BEGIN:
|
1885 |
|
|
case DNTT_TYPE_END:
|
1886 |
|
|
/* We don't check MODULE end here, because there can be
|
1887 |
|
|
symbols beyond the module end which properly belong to the
|
1888 |
|
|
current psymtab -- so we wait till the next MODULE start */
|
1889 |
|
|
|
1890 |
|
|
|
1891 |
|
|
#ifdef QUICK_LOOK_UP
|
1892 |
|
|
if (scan_start == hp_symnum
|
1893 |
|
|
&& symcount == hp_symnum + 1)
|
1894 |
|
|
{
|
1895 |
|
|
/* If there are NO globals in an executable,
|
1896 |
|
|
PXDB's index to the globals will point to
|
1897 |
|
|
the last record in the file, which is
|
1898 |
|
|
probably an END MODULE, i.e. this record.
|
1899 |
|
|
ignore it and be done! */
|
1900 |
|
|
continue;
|
1901 |
|
|
}
|
1902 |
|
|
#endif /* QUICK_LOOK_UP */
|
1903 |
|
|
|
1904 |
|
|
/* Scope block begin/end. We only care about function
|
1905 |
|
|
and file blocks right now. */
|
1906 |
|
|
|
1907 |
|
|
if ((dn_bufp->dend.endkind == DNTT_TYPE_FUNCTION) ||
|
1908 |
|
|
(dn_bufp->dend.endkind == DNTT_TYPE_DOC_FUNCTION))
|
1909 |
|
|
within_function = 0;
|
1910 |
|
|
continue;
|
1911 |
|
|
|
1912 |
|
|
case DNTT_TYPE_SVAR:
|
1913 |
|
|
case DNTT_TYPE_DVAR:
|
1914 |
|
|
case DNTT_TYPE_TYPEDEF:
|
1915 |
|
|
case DNTT_TYPE_TAGDEF:
|
1916 |
|
|
{
|
1917 |
|
|
/* Variables, typedefs an the like. */
|
1918 |
|
|
enum address_class storage;
|
1919 |
|
|
namespace_enum namespace;
|
1920 |
|
|
|
1921 |
|
|
/* Don't add locals to the partial symbol table. */
|
1922 |
|
|
if (within_function
|
1923 |
|
|
&& (dn_bufp->dblock.kind == DNTT_TYPE_SVAR
|
1924 |
|
|
|| dn_bufp->dblock.kind == DNTT_TYPE_DVAR))
|
1925 |
|
|
continue;
|
1926 |
|
|
|
1927 |
|
|
/* TAGDEFs go into the structure namespace. */
|
1928 |
|
|
if (dn_bufp->dblock.kind == DNTT_TYPE_TAGDEF)
|
1929 |
|
|
namespace = STRUCT_NAMESPACE;
|
1930 |
|
|
else
|
1931 |
|
|
namespace = VAR_NAMESPACE;
|
1932 |
|
|
|
1933 |
|
|
/* What kind of "storage" does this use? */
|
1934 |
|
|
if (dn_bufp->dblock.kind == DNTT_TYPE_SVAR)
|
1935 |
|
|
storage = LOC_STATIC;
|
1936 |
|
|
else if (dn_bufp->dblock.kind == DNTT_TYPE_DVAR
|
1937 |
|
|
&& dn_bufp->ddvar.regvar)
|
1938 |
|
|
storage = LOC_REGISTER;
|
1939 |
|
|
else if (dn_bufp->dblock.kind == DNTT_TYPE_DVAR)
|
1940 |
|
|
storage = LOC_LOCAL;
|
1941 |
|
|
else
|
1942 |
|
|
storage = LOC_UNDEF;
|
1943 |
|
|
|
1944 |
|
|
SET_NAMESTRING (dn_bufp, &namestring, objfile);
|
1945 |
|
|
if (!pst)
|
1946 |
|
|
{
|
1947 |
|
|
pst = hpread_start_psymtab (objfile,
|
1948 |
|
|
"globals", 0,
|
1949 |
|
|
(hp_symnum
|
1950 |
|
|
* sizeof (struct dntt_type_block)),
|
1951 |
|
|
objfile->global_psymbols.next,
|
1952 |
|
|
objfile->static_psymbols.next);
|
1953 |
|
|
}
|
1954 |
|
|
|
1955 |
|
|
/* Compute address of the data symbol */
|
1956 |
|
|
valu = dn_bufp->dsvar.location;
|
1957 |
|
|
/* Relocate in case it's in a shared library */
|
1958 |
|
|
if (storage == LOC_STATIC)
|
1959 |
|
|
valu += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
|
1960 |
|
|
|
1961 |
|
|
/* Luckily, dvar, svar, typedef, and tagdef all
|
1962 |
|
|
have their "global" bit in the same place, so it works
|
1963 |
|
|
(though it's bad programming practice) to reference
|
1964 |
|
|
"dsvar.global" even though we may be looking at
|
1965 |
|
|
any of the above four types. */
|
1966 |
|
|
if (dn_bufp->dsvar.global)
|
1967 |
|
|
{
|
1968 |
|
|
add_psymbol_to_list (namestring, strlen (namestring),
|
1969 |
|
|
namespace, storage,
|
1970 |
|
|
&objfile->global_psymbols,
|
1971 |
|
|
valu,
|
1972 |
|
|
0, language_unknown, objfile);
|
1973 |
|
|
}
|
1974 |
|
|
else
|
1975 |
|
|
{
|
1976 |
|
|
add_psymbol_to_list (namestring, strlen (namestring),
|
1977 |
|
|
namespace, storage,
|
1978 |
|
|
&objfile->static_psymbols,
|
1979 |
|
|
valu,
|
1980 |
|
|
0, language_unknown, objfile);
|
1981 |
|
|
}
|
1982 |
|
|
|
1983 |
|
|
/* For TAGDEF's, the above code added the tagname to the
|
1984 |
|
|
struct namespace. This will cause tag "t" to be found
|
1985 |
|
|
on a reference of the form "(struct t) x". But for
|
1986 |
|
|
C++ classes, "t" will also be a typename, which we
|
1987 |
|
|
want to find on a reference of the form "ptype t".
|
1988 |
|
|
Therefore, we also add "t" to the var namespace.
|
1989 |
|
|
Do the same for enum's due to the way aCC generates
|
1990 |
|
|
debug info for these (see more extended comment
|
1991 |
|
|
in hp-symtab-read.c).
|
1992 |
|
|
We do the same for templates, so that "ptype t"
|
1993 |
|
|
where "t" is a template also works. */
|
1994 |
|
|
if (dn_bufp->dblock.kind == DNTT_TYPE_TAGDEF &&
|
1995 |
|
|
dn_bufp->dtype.type.dnttp.index < LNTT_SYMCOUNT (objfile))
|
1996 |
|
|
{
|
1997 |
|
|
int global = dn_bufp->dtag.global;
|
1998 |
|
|
/* Look ahead to see if it's a C++ class */
|
1999 |
|
|
dn_bufp = hpread_get_lntt (dn_bufp->dtype.type.dnttp.index, objfile);
|
2000 |
|
|
if (dn_bufp->dblock.kind == DNTT_TYPE_CLASS ||
|
2001 |
|
|
dn_bufp->dblock.kind == DNTT_TYPE_ENUM ||
|
2002 |
|
|
dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE)
|
2003 |
|
|
{
|
2004 |
|
|
if (global)
|
2005 |
|
|
{
|
2006 |
|
|
add_psymbol_to_list (namestring, strlen (namestring),
|
2007 |
|
|
VAR_NAMESPACE, storage,
|
2008 |
|
|
&objfile->global_psymbols,
|
2009 |
|
|
dn_bufp->dsvar.location,
|
2010 |
|
|
0, language_unknown, objfile);
|
2011 |
|
|
}
|
2012 |
|
|
else
|
2013 |
|
|
{
|
2014 |
|
|
add_psymbol_to_list (namestring, strlen (namestring),
|
2015 |
|
|
VAR_NAMESPACE, storage,
|
2016 |
|
|
&objfile->static_psymbols,
|
2017 |
|
|
dn_bufp->dsvar.location,
|
2018 |
|
|
0, language_unknown, objfile);
|
2019 |
|
|
}
|
2020 |
|
|
}
|
2021 |
|
|
}
|
2022 |
|
|
}
|
2023 |
|
|
continue;
|
2024 |
|
|
|
2025 |
|
|
case DNTT_TYPE_MEMENUM:
|
2026 |
|
|
case DNTT_TYPE_CONST:
|
2027 |
|
|
/* Constants and members of enumerated types. */
|
2028 |
|
|
SET_NAMESTRING (dn_bufp, &namestring, objfile);
|
2029 |
|
|
if (!pst)
|
2030 |
|
|
{
|
2031 |
|
|
pst = hpread_start_psymtab (objfile,
|
2032 |
|
|
"globals", 0,
|
2033 |
|
|
(hp_symnum
|
2034 |
|
|
* sizeof (struct dntt_type_block)),
|
2035 |
|
|
objfile->global_psymbols.next,
|
2036 |
|
|
objfile->static_psymbols.next);
|
2037 |
|
|
}
|
2038 |
|
|
if (dn_bufp->dconst.global)
|
2039 |
|
|
add_psymbol_to_list (namestring, strlen (namestring),
|
2040 |
|
|
VAR_NAMESPACE, LOC_CONST,
|
2041 |
|
|
&objfile->global_psymbols, 0,
|
2042 |
|
|
0, language_unknown, objfile);
|
2043 |
|
|
else
|
2044 |
|
|
add_psymbol_to_list (namestring, strlen (namestring),
|
2045 |
|
|
VAR_NAMESPACE, LOC_CONST,
|
2046 |
|
|
&objfile->static_psymbols, 0,
|
2047 |
|
|
0, language_unknown, objfile);
|
2048 |
|
|
continue;
|
2049 |
|
|
default:
|
2050 |
|
|
continue;
|
2051 |
|
|
}
|
2052 |
|
|
}
|
2053 |
|
|
}
|
2054 |
|
|
|
2055 |
|
|
/* End any pending partial symbol table. */
|
2056 |
|
|
if (pst)
|
2057 |
|
|
{
|
2058 |
|
|
hpread_end_psymtab (pst, psymtab_include_list, includes_used,
|
2059 |
|
|
hp_symnum * sizeof (struct dntt_type_block),
|
2060 |
|
|
0, dependency_list, dependencies_used);
|
2061 |
|
|
}
|
2062 |
|
|
|
2063 |
|
|
discard_cleanups (old_chain);
|
2064 |
|
|
}
|
2065 |
|
|
|
2066 |
|
|
/* Perform any local cleanups required when we are done with a particular
|
2067 |
|
|
objfile. I.E, we are in the process of discarding all symbol information
|
2068 |
|
|
for an objfile, freeing up all memory held for it, and unlinking the
|
2069 |
|
|
objfile struct from the global list of known objfiles. */
|
2070 |
|
|
|
2071 |
|
|
void
|
2072 |
|
|
hpread_symfile_finish (struct objfile *objfile)
|
2073 |
|
|
{
|
2074 |
|
|
if (objfile->sym_private != NULL)
|
2075 |
|
|
{
|
2076 |
|
|
mfree (objfile->md, objfile->sym_private);
|
2077 |
|
|
}
|
2078 |
|
|
}
|
2079 |
|
|
|
2080 |
|
|
|
2081 |
|
|
/* The remaining functions are all for internal use only. */
|
2082 |
|
|
|
2083 |
|
|
/* Various small functions to get entries in the debug symbol sections. */
|
2084 |
|
|
|
2085 |
|
|
union dnttentry *
|
2086 |
|
|
hpread_get_lntt (int index, struct objfile *objfile)
|
2087 |
|
|
{
|
2088 |
|
|
return (union dnttentry *)
|
2089 |
|
|
&(LNTT (objfile)[(index * sizeof (struct dntt_type_block))]);
|
2090 |
|
|
}
|
2091 |
|
|
|
2092 |
|
|
static union dnttentry *
|
2093 |
|
|
hpread_get_gntt (int index, struct objfile *objfile)
|
2094 |
|
|
{
|
2095 |
|
|
return (union dnttentry *)
|
2096 |
|
|
&(GNTT (objfile)[(index * sizeof (struct dntt_type_block))]);
|
2097 |
|
|
}
|
2098 |
|
|
|
2099 |
|
|
union sltentry *
|
2100 |
|
|
hpread_get_slt (int index, struct objfile *objfile)
|
2101 |
|
|
{
|
2102 |
|
|
return (union sltentry *) &(SLT (objfile)[index * sizeof (union sltentry)]);
|
2103 |
|
|
}
|
2104 |
|
|
|
2105 |
|
|
/* Get the low address associated with some symbol (typically the start
|
2106 |
|
|
of a particular source file or module). Since that information is not
|
2107 |
|
|
stored as part of the DNTT_TYPE_MODULE or DNTT_TYPE_SRCFILE symbol we
|
2108 |
|
|
must infer it from the existence of DNTT_TYPE_FUNCTION symbols. */
|
2109 |
|
|
|
2110 |
|
|
static unsigned long
|
2111 |
|
|
hpread_get_textlow (int global, int index, struct objfile *objfile,
|
2112 |
|
|
int symcount)
|
2113 |
|
|
{
|
2114 |
|
|
union dnttentry *dn_bufp;
|
2115 |
|
|
struct minimal_symbol *msymbol;
|
2116 |
|
|
|
2117 |
|
|
/* Look for a DNTT_TYPE_FUNCTION symbol. */
|
2118 |
|
|
if (index < symcount) /* symcount is the number of symbols in */
|
2119 |
|
|
{ /* the dbinfo, LNTT table */
|
2120 |
|
|
do
|
2121 |
|
|
{
|
2122 |
|
|
if (global)
|
2123 |
|
|
dn_bufp = hpread_get_gntt (index++, objfile);
|
2124 |
|
|
else
|
2125 |
|
|
dn_bufp = hpread_get_lntt (index++, objfile);
|
2126 |
|
|
}
|
2127 |
|
|
while (dn_bufp->dblock.kind != DNTT_TYPE_FUNCTION
|
2128 |
|
|
&& dn_bufp->dblock.kind != DNTT_TYPE_DOC_FUNCTION
|
2129 |
|
|
&& dn_bufp->dblock.kind != DNTT_TYPE_END
|
2130 |
|
|
&& index < symcount);
|
2131 |
|
|
}
|
2132 |
|
|
|
2133 |
|
|
/* Avoid going past a DNTT_TYPE_END when looking for a DNTT_TYPE_FUNCTION. This
|
2134 |
|
|
might happen when a sourcefile has no functions. */
|
2135 |
|
|
if (dn_bufp->dblock.kind == DNTT_TYPE_END)
|
2136 |
|
|
return 0;
|
2137 |
|
|
|
2138 |
|
|
/* Avoid going past the end of the LNTT file */
|
2139 |
|
|
if (index == symcount)
|
2140 |
|
|
return 0;
|
2141 |
|
|
|
2142 |
|
|
/* The minimal symbols are typically more accurate for some reason. */
|
2143 |
|
|
if (dn_bufp->dblock.kind == DNTT_TYPE_FUNCTION)
|
2144 |
|
|
msymbol = lookup_minimal_symbol (dn_bufp->dfunc.name + VT (objfile), NULL,
|
2145 |
|
|
objfile);
|
2146 |
|
|
else /* must be a DNTT_TYPE_DOC_FUNCTION */
|
2147 |
|
|
msymbol = lookup_minimal_symbol (dn_bufp->ddocfunc.name + VT (objfile), NULL,
|
2148 |
|
|
objfile);
|
2149 |
|
|
|
2150 |
|
|
if (msymbol)
|
2151 |
|
|
return SYMBOL_VALUE_ADDRESS (msymbol);
|
2152 |
|
|
else
|
2153 |
|
|
return dn_bufp->dfunc.lowaddr;
|
2154 |
|
|
}
|
2155 |
|
|
|
2156 |
|
|
/* Allocate and partially fill a partial symtab. It will be
|
2157 |
|
|
completely filled at the end of the symbol list.
|
2158 |
|
|
|
2159 |
|
|
SYMFILE_NAME is the name of the symbol-file we are reading from, and ADDR
|
2160 |
|
|
is the address relative to which its symbols are (incremental) or 0
|
2161 |
|
|
(normal). */
|
2162 |
|
|
|
2163 |
|
|
static struct partial_symtab *
|
2164 |
|
|
hpread_start_psymtab (struct objfile *objfile, char *filename,
|
2165 |
|
|
CORE_ADDR textlow, int ldsymoff,
|
2166 |
|
|
struct partial_symbol **global_syms,
|
2167 |
|
|
struct partial_symbol **static_syms)
|
2168 |
|
|
{
|
2169 |
|
|
int offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
|
2170 |
|
|
extern void hpread_psymtab_to_symtab ();
|
2171 |
|
|
struct partial_symtab *result =
|
2172 |
|
|
start_psymtab_common (objfile, objfile->section_offsets,
|
2173 |
|
|
filename, textlow, global_syms, static_syms);
|
2174 |
|
|
|
2175 |
|
|
result->textlow += offset;
|
2176 |
|
|
result->read_symtab_private = (char *)
|
2177 |
|
|
obstack_alloc (&objfile->psymbol_obstack, sizeof (struct symloc));
|
2178 |
|
|
LDSYMOFF (result) = ldsymoff;
|
2179 |
|
|
result->read_symtab = hpread_psymtab_to_symtab;
|
2180 |
|
|
|
2181 |
|
|
return result;
|
2182 |
|
|
}
|
2183 |
|
|
|
2184 |
|
|
|
2185 |
|
|
/* Close off the current usage of PST.
|
2186 |
|
|
Returns PST or NULL if the partial symtab was empty and thrown away.
|
2187 |
|
|
|
2188 |
|
|
capping_symbol_offset --Byte index in LNTT or GNTT of the
|
2189 |
|
|
last symbol processed during the build
|
2190 |
|
|
of the previous pst.
|
2191 |
|
|
|
2192 |
|
|
FIXME: List variables and peculiarities of same. */
|
2193 |
|
|
|
2194 |
|
|
static struct partial_symtab *
|
2195 |
|
|
hpread_end_psymtab (struct partial_symtab *pst, char **include_list,
|
2196 |
|
|
int num_includes, int capping_symbol_offset,
|
2197 |
|
|
CORE_ADDR capping_text,
|
2198 |
|
|
struct partial_symtab **dependency_list,
|
2199 |
|
|
int number_dependencies)
|
2200 |
|
|
{
|
2201 |
|
|
int i;
|
2202 |
|
|
struct objfile *objfile = pst->objfile;
|
2203 |
|
|
int offset = ANOFFSET (pst->section_offsets, SECT_OFF_TEXT (objfile));
|
2204 |
|
|
|
2205 |
|
|
#ifdef DUMPING
|
2206 |
|
|
/* Turn on to see what kind of a psymtab we've built. */
|
2207 |
|
|
static int dumping = 0;
|
2208 |
|
|
#endif
|
2209 |
|
|
|
2210 |
|
|
if (capping_symbol_offset != -1)
|
2211 |
|
|
LDSYMLEN (pst) = capping_symbol_offset - LDSYMOFF (pst);
|
2212 |
|
|
else
|
2213 |
|
|
LDSYMLEN (pst) = 0;
|
2214 |
|
|
pst->texthigh = capping_text + offset;
|
2215 |
|
|
|
2216 |
|
|
pst->n_global_syms =
|
2217 |
|
|
objfile->global_psymbols.next - (objfile->global_psymbols.list + pst->globals_offset);
|
2218 |
|
|
pst->n_static_syms =
|
2219 |
|
|
objfile->static_psymbols.next - (objfile->static_psymbols.list + pst->statics_offset);
|
2220 |
|
|
|
2221 |
|
|
#ifdef DUMPING
|
2222 |
|
|
if (dumping)
|
2223 |
|
|
{
|
2224 |
|
|
printf ("\nPst %s, LDSYMOFF %x (%x), LDSYMLEN %x (%x), globals %d, statics %d\n",
|
2225 |
|
|
pst->filename,
|
2226 |
|
|
LDSYMOFF (pst),
|
2227 |
|
|
LDSYMOFF (pst) / sizeof (struct dntt_type_block),
|
2228 |
|
|
LDSYMLEN (pst),
|
2229 |
|
|
LDSYMLEN (pst) / sizeof (struct dntt_type_block),
|
2230 |
|
|
pst->n_global_syms, pst->n_static_syms);
|
2231 |
|
|
}
|
2232 |
|
|
#endif
|
2233 |
|
|
|
2234 |
|
|
pst->number_of_dependencies = number_dependencies;
|
2235 |
|
|
if (number_dependencies)
|
2236 |
|
|
{
|
2237 |
|
|
pst->dependencies = (struct partial_symtab **)
|
2238 |
|
|
obstack_alloc (&objfile->psymbol_obstack,
|
2239 |
|
|
number_dependencies * sizeof (struct partial_symtab *));
|
2240 |
|
|
memcpy (pst->dependencies, dependency_list,
|
2241 |
|
|
number_dependencies * sizeof (struct partial_symtab *));
|
2242 |
|
|
}
|
2243 |
|
|
else
|
2244 |
|
|
pst->dependencies = 0;
|
2245 |
|
|
|
2246 |
|
|
for (i = 0; i < num_includes; i++)
|
2247 |
|
|
{
|
2248 |
|
|
struct partial_symtab *subpst =
|
2249 |
|
|
allocate_psymtab (include_list[i], objfile);
|
2250 |
|
|
|
2251 |
|
|
subpst->section_offsets = pst->section_offsets;
|
2252 |
|
|
subpst->read_symtab_private =
|
2253 |
|
|
(char *) obstack_alloc (&objfile->psymbol_obstack,
|
2254 |
|
|
sizeof (struct symloc));
|
2255 |
|
|
LDSYMOFF (subpst) =
|
2256 |
|
|
LDSYMLEN (subpst) =
|
2257 |
|
|
subpst->textlow =
|
2258 |
|
|
subpst->texthigh = 0;
|
2259 |
|
|
|
2260 |
|
|
/* We could save slight bits of space by only making one of these,
|
2261 |
|
|
shared by the entire set of include files. FIXME-someday. */
|
2262 |
|
|
subpst->dependencies = (struct partial_symtab **)
|
2263 |
|
|
obstack_alloc (&objfile->psymbol_obstack,
|
2264 |
|
|
sizeof (struct partial_symtab *));
|
2265 |
|
|
subpst->dependencies[0] = pst;
|
2266 |
|
|
subpst->number_of_dependencies = 1;
|
2267 |
|
|
|
2268 |
|
|
subpst->globals_offset =
|
2269 |
|
|
subpst->n_global_syms =
|
2270 |
|
|
subpst->statics_offset =
|
2271 |
|
|
subpst->n_static_syms = 0;
|
2272 |
|
|
|
2273 |
|
|
subpst->readin = 0;
|
2274 |
|
|
subpst->symtab = 0;
|
2275 |
|
|
subpst->read_symtab = pst->read_symtab;
|
2276 |
|
|
}
|
2277 |
|
|
|
2278 |
|
|
sort_pst_symbols (pst);
|
2279 |
|
|
|
2280 |
|
|
/* If there is already a psymtab or symtab for a file of this name, remove it.
|
2281 |
|
|
(If there is a symtab, more drastic things also happen.)
|
2282 |
|
|
This happens in VxWorks. */
|
2283 |
|
|
free_named_symtabs (pst->filename);
|
2284 |
|
|
|
2285 |
|
|
if (num_includes == 0
|
2286 |
|
|
&& number_dependencies == 0
|
2287 |
|
|
&& pst->n_global_syms == 0
|
2288 |
|
|
&& pst->n_static_syms == 0)
|
2289 |
|
|
{
|
2290 |
|
|
/* Throw away this psymtab, it's empty. We can't deallocate it, since
|
2291 |
|
|
it is on the obstack, but we can forget to chain it on the list.
|
2292 |
|
|
Empty psymtabs happen as a result of header files which don't have
|
2293 |
|
|
any symbols in them. There can be a lot of them. But this check
|
2294 |
|
|
is wrong, in that a psymtab with N_SLINE entries but nothing else
|
2295 |
|
|
is not empty, but we don't realize that. Fixing that without slowing
|
2296 |
|
|
things down might be tricky.
|
2297 |
|
|
It's also wrong if we're using the quick look-up tables, as
|
2298 |
|
|
we can get empty psymtabs from modules with no routines in
|
2299 |
|
|
them. */
|
2300 |
|
|
|
2301 |
|
|
discard_psymtab (pst);
|
2302 |
|
|
|
2303 |
|
|
/* Indicate that psymtab was thrown away. */
|
2304 |
|
|
pst = (struct partial_symtab *) NULL;
|
2305 |
|
|
|
2306 |
|
|
}
|
2307 |
|
|
return pst;
|
2308 |
|
|
}
|
2309 |
|
|
|
2310 |
|
|
|
2311 |
|
|
/* End of hp-psymtab-read.c */
|
2312 |
|
|
|
2313 |
|
|
/* Set indentation to 4 spaces for Emacs; this file is
|
2314 |
|
|
mostly non-GNU-ish in its style :-( */
|
2315 |
|
|
#if 0
|
2316 |
|
|
***Local Variables:
|
2317 |
|
|
***c - basic - offset:4
|
2318 |
|
|
*** End:
|
2319 |
|
|
#endif
|