1 |
578 |
markom |
/* Shared code to pre-read a stab (dbx-style), when building a psymtab.
|
2 |
|
|
Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
|
3 |
|
|
1996, 1997, 1998, 1999, 2000, 2001
|
4 |
|
|
Free Software Foundation, Inc.
|
5 |
|
|
|
6 |
|
|
This file is part of GDB.
|
7 |
|
|
|
8 |
|
|
This program is free software; you can redistribute it and/or modify
|
9 |
|
|
it under the terms of the GNU General Public License as published by
|
10 |
|
|
the Free Software Foundation; either version 2 of the License, or
|
11 |
|
|
(at your option) any later version.
|
12 |
|
|
|
13 |
|
|
This program is distributed in the hope that it will be useful,
|
14 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
|
|
GNU General Public License for more details.
|
17 |
|
|
|
18 |
|
|
You should have received a copy of the GNU General Public License
|
19 |
|
|
along with this program; if not, write to the Free Software
|
20 |
|
|
Foundation, Inc., 59 Temple Place - Suite 330,
|
21 |
|
|
Boston, MA 02111-1307, USA. */
|
22 |
|
|
|
23 |
|
|
/* The following need to be defined:
|
24 |
|
|
SET_NAMESTRING() --Set namestring to name of symbol.
|
25 |
|
|
CUR_SYMBOL_TYPE --Type code of current symbol.
|
26 |
|
|
CUR_SYMBOL_VALUE --Value field of current symbol. May be adjusted here.
|
27 |
|
|
namestring - variable pointing to the name of the stab.
|
28 |
|
|
pst - the partial symbol table being built.
|
29 |
|
|
|
30 |
|
|
psymtab_include_list, includes_used, includes_allocated - list of include
|
31 |
|
|
file names (N_SOL) seen so far.
|
32 |
|
|
dependency_list, dependencies_used, dependencies_allocated - list of
|
33 |
|
|
N_EXCL stabs seen so far.
|
34 |
|
|
|
35 |
|
|
END_PSYMTAB -- end a partial symbol table.
|
36 |
|
|
START_PSYMTAB -- start a partial symbol table.
|
37 |
|
|
*/
|
38 |
|
|
|
39 |
|
|
/* End of macro definitions, now let's handle them symbols! */
|
40 |
|
|
|
41 |
|
|
switch (CUR_SYMBOL_TYPE)
|
42 |
|
|
{
|
43 |
|
|
static struct complaint function_outside_compilation_unit = {
|
44 |
|
|
"function `%s' appears to be defined outside of all compilation units", 0, 0
|
45 |
|
|
};
|
46 |
|
|
char *p;
|
47 |
|
|
/*
|
48 |
|
|
* Standard, external, non-debugger, symbols
|
49 |
|
|
*/
|
50 |
|
|
|
51 |
|
|
case N_TEXT | N_EXT:
|
52 |
|
|
case N_NBTEXT | N_EXT:
|
53 |
|
|
CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
|
54 |
|
|
goto record_it;
|
55 |
|
|
|
56 |
|
|
case N_DATA | N_EXT:
|
57 |
|
|
case N_NBDATA | N_EXT:
|
58 |
|
|
CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
|
59 |
|
|
goto record_it;
|
60 |
|
|
|
61 |
|
|
case N_BSS:
|
62 |
|
|
case N_BSS | N_EXT:
|
63 |
|
|
case N_NBBSS | N_EXT:
|
64 |
|
|
case N_SETV | N_EXT: /* FIXME, is this in BSS? */
|
65 |
|
|
CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));
|
66 |
|
|
goto record_it;
|
67 |
|
|
|
68 |
|
|
case N_ABS | N_EXT:
|
69 |
|
|
record_it:
|
70 |
|
|
#ifdef DBXREAD_ONLY
|
71 |
|
|
SET_NAMESTRING ();
|
72 |
|
|
|
73 |
|
|
bss_ext_symbol:
|
74 |
|
|
record_minimal_symbol (namestring, CUR_SYMBOL_VALUE,
|
75 |
|
|
CUR_SYMBOL_TYPE, objfile); /* Always */
|
76 |
|
|
#endif /* DBXREAD_ONLY */
|
77 |
|
|
continue;
|
78 |
|
|
|
79 |
|
|
/* Standard, local, non-debugger, symbols */
|
80 |
|
|
|
81 |
|
|
case N_NBTEXT:
|
82 |
|
|
|
83 |
|
|
/* We need to be able to deal with both N_FN or N_TEXT,
|
84 |
|
|
because we have no way of knowing whether the sys-supplied ld
|
85 |
|
|
or GNU ld was used to make the executable. Sequents throw
|
86 |
|
|
in another wrinkle -- they renumbered N_FN. */
|
87 |
|
|
|
88 |
|
|
case N_FN:
|
89 |
|
|
case N_FN_SEQ:
|
90 |
|
|
case N_TEXT:
|
91 |
|
|
#ifdef DBXREAD_ONLY
|
92 |
|
|
CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
|
93 |
|
|
SET_NAMESTRING ();
|
94 |
|
|
if ((namestring[0] == '-' && namestring[1] == 'l')
|
95 |
|
|
|| (namestring[(nsl = strlen (namestring)) - 1] == 'o'
|
96 |
|
|
&& namestring[nsl - 2] == '.'))
|
97 |
|
|
{
|
98 |
|
|
if (objfile->ei.entry_point < CUR_SYMBOL_VALUE &&
|
99 |
|
|
objfile->ei.entry_point >= last_o_file_start)
|
100 |
|
|
{
|
101 |
|
|
objfile->ei.entry_file_lowpc = last_o_file_start;
|
102 |
|
|
objfile->ei.entry_file_highpc = CUR_SYMBOL_VALUE;
|
103 |
|
|
}
|
104 |
|
|
if (past_first_source_file && pst
|
105 |
|
|
/* The gould NP1 uses low values for .o and -l symbols
|
106 |
|
|
which are not the address. */
|
107 |
|
|
&& CUR_SYMBOL_VALUE >= pst->textlow)
|
108 |
|
|
{
|
109 |
|
|
END_PSYMTAB (pst, psymtab_include_list, includes_used,
|
110 |
|
|
symnum * symbol_size,
|
111 |
|
|
CUR_SYMBOL_VALUE > pst->texthigh
|
112 |
|
|
? CUR_SYMBOL_VALUE : pst->texthigh,
|
113 |
|
|
dependency_list, dependencies_used, textlow_not_set);
|
114 |
|
|
pst = (struct partial_symtab *) 0;
|
115 |
|
|
includes_used = 0;
|
116 |
|
|
dependencies_used = 0;
|
117 |
|
|
}
|
118 |
|
|
else
|
119 |
|
|
past_first_source_file = 1;
|
120 |
|
|
last_o_file_start = CUR_SYMBOL_VALUE;
|
121 |
|
|
}
|
122 |
|
|
else
|
123 |
|
|
goto record_it;
|
124 |
|
|
#endif /* DBXREAD_ONLY */
|
125 |
|
|
continue;
|
126 |
|
|
|
127 |
|
|
case N_DATA:
|
128 |
|
|
CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
|
129 |
|
|
goto record_it;
|
130 |
|
|
|
131 |
|
|
case N_UNDF | N_EXT:
|
132 |
|
|
#ifdef DBXREAD_ONLY
|
133 |
|
|
if (CUR_SYMBOL_VALUE != 0)
|
134 |
|
|
{
|
135 |
|
|
/* This is a "Fortran COMMON" symbol. See if the target
|
136 |
|
|
environment knows where it has been relocated to. */
|
137 |
|
|
|
138 |
|
|
CORE_ADDR reladdr;
|
139 |
|
|
|
140 |
|
|
SET_NAMESTRING ();
|
141 |
|
|
if (target_lookup_symbol (namestring, &reladdr))
|
142 |
|
|
{
|
143 |
|
|
continue; /* Error in lookup; ignore symbol for now. */
|
144 |
|
|
}
|
145 |
|
|
CUR_SYMBOL_TYPE ^= (N_BSS ^ N_UNDF); /* Define it as a bss-symbol */
|
146 |
|
|
CUR_SYMBOL_VALUE = reladdr;
|
147 |
|
|
goto bss_ext_symbol;
|
148 |
|
|
}
|
149 |
|
|
#endif /* DBXREAD_ONLY */
|
150 |
|
|
continue; /* Just undefined, not COMMON */
|
151 |
|
|
|
152 |
|
|
case N_UNDF:
|
153 |
|
|
#ifdef DBXREAD_ONLY
|
154 |
|
|
if (processing_acc_compilation && CUR_SYMBOL_STRX == 1)
|
155 |
|
|
{
|
156 |
|
|
/* Deal with relative offsets in the string table
|
157 |
|
|
used in ELF+STAB under Solaris. If we want to use the
|
158 |
|
|
n_strx field, which contains the name of the file,
|
159 |
|
|
we must adjust file_string_table_offset *before* calling
|
160 |
|
|
SET_NAMESTRING(). */
|
161 |
|
|
past_first_source_file = 1;
|
162 |
|
|
file_string_table_offset = next_file_string_table_offset;
|
163 |
|
|
next_file_string_table_offset =
|
164 |
|
|
file_string_table_offset + CUR_SYMBOL_VALUE;
|
165 |
|
|
if (next_file_string_table_offset < file_string_table_offset)
|
166 |
|
|
error ("string table offset backs up at %d", symnum);
|
167 |
|
|
/* FIXME -- replace error() with complaint. */
|
168 |
|
|
continue;
|
169 |
|
|
}
|
170 |
|
|
#endif /* DBXREAD_ONLY */
|
171 |
|
|
continue;
|
172 |
|
|
|
173 |
|
|
/* Lots of symbol types we can just ignore. */
|
174 |
|
|
|
175 |
|
|
case N_ABS:
|
176 |
|
|
case N_NBDATA:
|
177 |
|
|
case N_NBBSS:
|
178 |
|
|
continue;
|
179 |
|
|
|
180 |
|
|
/* Keep going . . . */
|
181 |
|
|
|
182 |
|
|
/*
|
183 |
|
|
* Special symbol types for GNU
|
184 |
|
|
*/
|
185 |
|
|
case N_INDR:
|
186 |
|
|
case N_INDR | N_EXT:
|
187 |
|
|
case N_SETA:
|
188 |
|
|
case N_SETA | N_EXT:
|
189 |
|
|
case N_SETT:
|
190 |
|
|
case N_SETT | N_EXT:
|
191 |
|
|
case N_SETD:
|
192 |
|
|
case N_SETD | N_EXT:
|
193 |
|
|
case N_SETB:
|
194 |
|
|
case N_SETB | N_EXT:
|
195 |
|
|
case N_SETV:
|
196 |
|
|
continue;
|
197 |
|
|
|
198 |
|
|
/*
|
199 |
|
|
* Debugger symbols
|
200 |
|
|
*/
|
201 |
|
|
|
202 |
|
|
case N_SO:
|
203 |
|
|
{
|
204 |
|
|
unsigned long valu;
|
205 |
|
|
static int prev_so_symnum = -10;
|
206 |
|
|
static int first_so_symnum;
|
207 |
|
|
char *p;
|
208 |
|
|
int prev_textlow_not_set;
|
209 |
|
|
|
210 |
|
|
valu = CUR_SYMBOL_VALUE + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
|
211 |
|
|
|
212 |
|
|
prev_textlow_not_set = textlow_not_set;
|
213 |
|
|
|
214 |
|
|
#ifdef SOFUN_ADDRESS_MAYBE_MISSING
|
215 |
|
|
/* A zero value is probably an indication for the SunPRO 3.0
|
216 |
|
|
compiler. end_psymtab explicitly tests for zero, so
|
217 |
|
|
don't relocate it. */
|
218 |
|
|
|
219 |
|
|
if (CUR_SYMBOL_VALUE == 0)
|
220 |
|
|
{
|
221 |
|
|
textlow_not_set = 1;
|
222 |
|
|
valu = 0;
|
223 |
|
|
}
|
224 |
|
|
else
|
225 |
|
|
textlow_not_set = 0;
|
226 |
|
|
#else
|
227 |
|
|
textlow_not_set = 0;
|
228 |
|
|
#endif
|
229 |
|
|
past_first_source_file = 1;
|
230 |
|
|
|
231 |
|
|
if (prev_so_symnum != symnum - 1)
|
232 |
|
|
{ /* Here if prev stab wasn't N_SO */
|
233 |
|
|
first_so_symnum = symnum;
|
234 |
|
|
|
235 |
|
|
if (pst)
|
236 |
|
|
{
|
237 |
|
|
END_PSYMTAB (pst, psymtab_include_list, includes_used,
|
238 |
|
|
symnum * symbol_size,
|
239 |
|
|
valu > pst->texthigh ? valu : pst->texthigh,
|
240 |
|
|
dependency_list, dependencies_used,
|
241 |
|
|
prev_textlow_not_set);
|
242 |
|
|
pst = (struct partial_symtab *) 0;
|
243 |
|
|
includes_used = 0;
|
244 |
|
|
dependencies_used = 0;
|
245 |
|
|
}
|
246 |
|
|
}
|
247 |
|
|
|
248 |
|
|
prev_so_symnum = symnum;
|
249 |
|
|
|
250 |
|
|
/* End the current partial symtab and start a new one */
|
251 |
|
|
|
252 |
|
|
SET_NAMESTRING ();
|
253 |
|
|
|
254 |
|
|
/* Null name means end of .o file. Don't start a new one. */
|
255 |
|
|
if (*namestring == '\000')
|
256 |
|
|
continue;
|
257 |
|
|
|
258 |
|
|
/* Some compilers (including gcc) emit a pair of initial N_SOs.
|
259 |
|
|
The first one is a directory name; the second the file name.
|
260 |
|
|
If pst exists, is empty, and has a filename ending in '/',
|
261 |
|
|
we assume the previous N_SO was a directory name. */
|
262 |
|
|
|
263 |
|
|
p = strrchr (namestring, '/');
|
264 |
|
|
if (p && *(p + 1) == '\000')
|
265 |
|
|
continue; /* Simply ignore directory name SOs */
|
266 |
|
|
|
267 |
|
|
/* Some other compilers (C++ ones in particular) emit useless
|
268 |
|
|
SOs for non-existant .c files. We ignore all subsequent SOs that
|
269 |
|
|
immediately follow the first. */
|
270 |
|
|
|
271 |
|
|
if (!pst)
|
272 |
|
|
pst = START_PSYMTAB (objfile,
|
273 |
|
|
namestring, valu,
|
274 |
|
|
first_so_symnum * symbol_size,
|
275 |
|
|
objfile->global_psymbols.next,
|
276 |
|
|
objfile->static_psymbols.next);
|
277 |
|
|
continue;
|
278 |
|
|
}
|
279 |
|
|
|
280 |
|
|
case N_BINCL:
|
281 |
|
|
{
|
282 |
|
|
#ifdef DBXREAD_ONLY
|
283 |
|
|
enum language tmp_language;
|
284 |
|
|
/* Add this bincl to the bincl_list for future EXCLs. No
|
285 |
|
|
need to save the string; it'll be around until
|
286 |
|
|
read_dbx_symtab function returns */
|
287 |
|
|
|
288 |
|
|
SET_NAMESTRING ();
|
289 |
|
|
|
290 |
|
|
tmp_language = deduce_language_from_filename (namestring);
|
291 |
|
|
|
292 |
|
|
/* Only change the psymtab's language if we've learned
|
293 |
|
|
something useful (eg. tmp_language is not language_unknown).
|
294 |
|
|
In addition, to match what start_subfile does, never change
|
295 |
|
|
from C++ to C. */
|
296 |
|
|
if (tmp_language != language_unknown
|
297 |
|
|
&& (tmp_language != language_c
|
298 |
|
|
|| psymtab_language != language_cplus))
|
299 |
|
|
psymtab_language = tmp_language;
|
300 |
|
|
|
301 |
|
|
if (pst == NULL)
|
302 |
|
|
{
|
303 |
|
|
/* FIXME: we should not get here without a PST to work on.
|
304 |
|
|
Attempt to recover. */
|
305 |
|
|
complain (&unclaimed_bincl_complaint, namestring, symnum);
|
306 |
|
|
continue;
|
307 |
|
|
}
|
308 |
|
|
add_bincl_to_list (pst, namestring, CUR_SYMBOL_VALUE);
|
309 |
|
|
|
310 |
|
|
/* Mark down an include file in the current psymtab */
|
311 |
|
|
|
312 |
|
|
goto record_include_file;
|
313 |
|
|
|
314 |
|
|
#else /* DBXREAD_ONLY */
|
315 |
|
|
continue;
|
316 |
|
|
#endif
|
317 |
|
|
}
|
318 |
|
|
|
319 |
|
|
case N_SOL:
|
320 |
|
|
{
|
321 |
|
|
enum language tmp_language;
|
322 |
|
|
/* Mark down an include file in the current psymtab */
|
323 |
|
|
|
324 |
|
|
SET_NAMESTRING ();
|
325 |
|
|
|
326 |
|
|
tmp_language = deduce_language_from_filename (namestring);
|
327 |
|
|
|
328 |
|
|
/* Only change the psymtab's language if we've learned
|
329 |
|
|
something useful (eg. tmp_language is not language_unknown).
|
330 |
|
|
In addition, to match what start_subfile does, never change
|
331 |
|
|
from C++ to C. */
|
332 |
|
|
if (tmp_language != language_unknown
|
333 |
|
|
&& (tmp_language != language_c
|
334 |
|
|
|| psymtab_language != language_cplus))
|
335 |
|
|
psymtab_language = tmp_language;
|
336 |
|
|
|
337 |
|
|
/* In C++, one may expect the same filename to come round many
|
338 |
|
|
times, when code is coming alternately from the main file
|
339 |
|
|
and from inline functions in other files. So I check to see
|
340 |
|
|
if this is a file we've seen before -- either the main
|
341 |
|
|
source file, or a previously included file.
|
342 |
|
|
|
343 |
|
|
This seems to be a lot of time to be spending on N_SOL, but
|
344 |
|
|
things like "break c-exp.y:435" need to work (I
|
345 |
|
|
suppose the psymtab_include_list could be hashed or put
|
346 |
|
|
in a binary tree, if profiling shows this is a major hog). */
|
347 |
|
|
if (pst && STREQ (namestring, pst->filename))
|
348 |
|
|
continue;
|
349 |
|
|
{
|
350 |
|
|
register int i;
|
351 |
|
|
for (i = 0; i < includes_used; i++)
|
352 |
|
|
if (STREQ (namestring, psymtab_include_list[i]))
|
353 |
|
|
{
|
354 |
|
|
i = -1;
|
355 |
|
|
break;
|
356 |
|
|
}
|
357 |
|
|
if (i == -1)
|
358 |
|
|
continue;
|
359 |
|
|
}
|
360 |
|
|
|
361 |
|
|
#ifdef DBXREAD_ONLY
|
362 |
|
|
record_include_file:
|
363 |
|
|
#endif
|
364 |
|
|
|
365 |
|
|
psymtab_include_list[includes_used++] = namestring;
|
366 |
|
|
if (includes_used >= includes_allocated)
|
367 |
|
|
{
|
368 |
|
|
char **orig = psymtab_include_list;
|
369 |
|
|
|
370 |
|
|
psymtab_include_list = (char **)
|
371 |
|
|
alloca ((includes_allocated *= 2) *
|
372 |
|
|
sizeof (char *));
|
373 |
|
|
memcpy ((PTR) psymtab_include_list, (PTR) orig,
|
374 |
|
|
includes_used * sizeof (char *));
|
375 |
|
|
}
|
376 |
|
|
continue;
|
377 |
|
|
}
|
378 |
|
|
case N_LSYM: /* Typedef or automatic variable. */
|
379 |
|
|
case N_STSYM: /* Data seg var -- static */
|
380 |
|
|
case N_LCSYM: /* BSS " */
|
381 |
|
|
case N_ROSYM: /* Read-only data seg var -- static. */
|
382 |
|
|
case N_NBSTS: /* Gould nobase. */
|
383 |
|
|
case N_NBLCS: /* symbols. */
|
384 |
|
|
case N_FUN:
|
385 |
|
|
case N_GSYM: /* Global (extern) variable; can be
|
386 |
|
|
data or bss (sigh FIXME). */
|
387 |
|
|
|
388 |
|
|
/* Following may probably be ignored; I'll leave them here
|
389 |
|
|
for now (until I do Pascal and Modula 2 extensions). */
|
390 |
|
|
|
391 |
|
|
case N_PC: /* I may or may not need this; I
|
392 |
|
|
suspect not. */
|
393 |
|
|
case N_M2C: /* I suspect that I can ignore this here. */
|
394 |
|
|
case N_SCOPE: /* Same. */
|
395 |
|
|
|
396 |
|
|
SET_NAMESTRING ();
|
397 |
|
|
|
398 |
|
|
#ifdef DBXREAD_ONLY
|
399 |
|
|
/* See if this is an end of function stab. */
|
400 |
|
|
if (pst && CUR_SYMBOL_TYPE == N_FUN && *namestring == '\000')
|
401 |
|
|
{
|
402 |
|
|
unsigned long valu;
|
403 |
|
|
|
404 |
|
|
/* It's value is the size (in bytes) of the function for
|
405 |
|
|
function relative stabs, or the address of the function's
|
406 |
|
|
end for old style stabs. */
|
407 |
|
|
valu = CUR_SYMBOL_VALUE + last_function_start;
|
408 |
|
|
if (pst->texthigh == 0 || valu > pst->texthigh)
|
409 |
|
|
pst->texthigh = valu;
|
410 |
|
|
break;
|
411 |
|
|
}
|
412 |
|
|
#endif
|
413 |
|
|
|
414 |
|
|
p = (char *) strchr (namestring, ':');
|
415 |
|
|
if (!p)
|
416 |
|
|
continue; /* Not a debugging symbol. */
|
417 |
|
|
|
418 |
|
|
|
419 |
|
|
|
420 |
|
|
/* Main processing section for debugging symbols which
|
421 |
|
|
the initial read through the symbol tables needs to worry
|
422 |
|
|
about. If we reach this point, the symbol which we are
|
423 |
|
|
considering is definitely one we are interested in.
|
424 |
|
|
p must also contain the (valid) index into the namestring
|
425 |
|
|
which indicates the debugging type symbol. */
|
426 |
|
|
|
427 |
|
|
switch (p[1])
|
428 |
|
|
{
|
429 |
|
|
case 'S':
|
430 |
|
|
CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
|
431 |
|
|
#ifdef STATIC_TRANSFORM_NAME
|
432 |
|
|
namestring = STATIC_TRANSFORM_NAME (namestring);
|
433 |
|
|
#endif
|
434 |
|
|
add_psymbol_to_list (namestring, p - namestring,
|
435 |
|
|
VAR_NAMESPACE, LOC_STATIC,
|
436 |
|
|
&objfile->static_psymbols,
|
437 |
|
|
0, CUR_SYMBOL_VALUE,
|
438 |
|
|
psymtab_language, objfile);
|
439 |
|
|
continue;
|
440 |
|
|
case 'G':
|
441 |
|
|
CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
|
442 |
|
|
/* The addresses in these entries are reported to be
|
443 |
|
|
wrong. See the code that reads 'G's for symtabs. */
|
444 |
|
|
add_psymbol_to_list (namestring, p - namestring,
|
445 |
|
|
VAR_NAMESPACE, LOC_STATIC,
|
446 |
|
|
&objfile->global_psymbols,
|
447 |
|
|
0, CUR_SYMBOL_VALUE,
|
448 |
|
|
psymtab_language, objfile);
|
449 |
|
|
continue;
|
450 |
|
|
|
451 |
|
|
case 'T':
|
452 |
|
|
/* When a 'T' entry is defining an anonymous enum, it
|
453 |
|
|
may have a name which is the empty string, or a
|
454 |
|
|
single space. Since they're not really defining a
|
455 |
|
|
symbol, those shouldn't go in the partial symbol
|
456 |
|
|
table. We do pick up the elements of such enums at
|
457 |
|
|
'check_enum:', below. */
|
458 |
|
|
if (p >= namestring + 2
|
459 |
|
|
|| (p == namestring + 1
|
460 |
|
|
&& namestring[0] != ' '))
|
461 |
|
|
{
|
462 |
|
|
add_psymbol_to_list (namestring, p - namestring,
|
463 |
|
|
STRUCT_NAMESPACE, LOC_TYPEDEF,
|
464 |
|
|
&objfile->static_psymbols,
|
465 |
|
|
CUR_SYMBOL_VALUE, 0,
|
466 |
|
|
psymtab_language, objfile);
|
467 |
|
|
if (p[2] == 't')
|
468 |
|
|
{
|
469 |
|
|
/* Also a typedef with the same name. */
|
470 |
|
|
add_psymbol_to_list (namestring, p - namestring,
|
471 |
|
|
VAR_NAMESPACE, LOC_TYPEDEF,
|
472 |
|
|
&objfile->static_psymbols,
|
473 |
|
|
CUR_SYMBOL_VALUE, 0,
|
474 |
|
|
psymtab_language, objfile);
|
475 |
|
|
p += 1;
|
476 |
|
|
}
|
477 |
|
|
/* The semantics of C++ state that "struct foo { ... }"
|
478 |
|
|
also defines a typedef for "foo". Unfortuantely, cfront
|
479 |
|
|
never makes the typedef when translating from C++ to C.
|
480 |
|
|
We make the typedef here so that "ptype foo" works as
|
481 |
|
|
expected for cfront translated code. */
|
482 |
|
|
else if (psymtab_language == language_cplus)
|
483 |
|
|
{
|
484 |
|
|
/* Also a typedef with the same name. */
|
485 |
|
|
add_psymbol_to_list (namestring, p - namestring,
|
486 |
|
|
VAR_NAMESPACE, LOC_TYPEDEF,
|
487 |
|
|
&objfile->static_psymbols,
|
488 |
|
|
CUR_SYMBOL_VALUE, 0,
|
489 |
|
|
psymtab_language, objfile);
|
490 |
|
|
}
|
491 |
|
|
}
|
492 |
|
|
goto check_enum;
|
493 |
|
|
case 't':
|
494 |
|
|
if (p != namestring) /* a name is there, not just :T... */
|
495 |
|
|
{
|
496 |
|
|
add_psymbol_to_list (namestring, p - namestring,
|
497 |
|
|
VAR_NAMESPACE, LOC_TYPEDEF,
|
498 |
|
|
&objfile->static_psymbols,
|
499 |
|
|
CUR_SYMBOL_VALUE, 0,
|
500 |
|
|
psymtab_language, objfile);
|
501 |
|
|
}
|
502 |
|
|
check_enum:
|
503 |
|
|
/* If this is an enumerated type, we need to
|
504 |
|
|
add all the enum constants to the partial symbol
|
505 |
|
|
table. This does not cover enums without names, e.g.
|
506 |
|
|
"enum {a, b} c;" in C, but fortunately those are
|
507 |
|
|
rare. There is no way for GDB to find those from the
|
508 |
|
|
enum type without spending too much time on it. Thus
|
509 |
|
|
to solve this problem, the compiler needs to put out the
|
510 |
|
|
enum in a nameless type. GCC2 does this. */
|
511 |
|
|
|
512 |
|
|
/* We are looking for something of the form
|
513 |
|
|
<name> ":" ("t" | "T") [<number> "="] "e"
|
514 |
|
|
{<constant> ":" <value> ","} ";". */
|
515 |
|
|
|
516 |
|
|
/* Skip over the colon and the 't' or 'T'. */
|
517 |
|
|
p += 2;
|
518 |
|
|
/* This type may be given a number. Also, numbers can come
|
519 |
|
|
in pairs like (0,26). Skip over it. */
|
520 |
|
|
while ((*p >= '0' && *p <= '9')
|
521 |
|
|
|| *p == '(' || *p == ',' || *p == ')'
|
522 |
|
|
|| *p == '=')
|
523 |
|
|
p++;
|
524 |
|
|
|
525 |
|
|
if (*p++ == 'e')
|
526 |
|
|
{
|
527 |
|
|
/* The aix4 compiler emits extra crud before the members. */
|
528 |
|
|
if (*p == '-')
|
529 |
|
|
{
|
530 |
|
|
/* Skip over the type (?). */
|
531 |
|
|
while (*p != ':')
|
532 |
|
|
p++;
|
533 |
|
|
|
534 |
|
|
/* Skip over the colon. */
|
535 |
|
|
p++;
|
536 |
|
|
}
|
537 |
|
|
|
538 |
|
|
/* We have found an enumerated type. */
|
539 |
|
|
/* According to comments in read_enum_type
|
540 |
|
|
a comma could end it instead of a semicolon.
|
541 |
|
|
I don't know where that happens.
|
542 |
|
|
Accept either. */
|
543 |
|
|
while (*p && *p != ';' && *p != ',')
|
544 |
|
|
{
|
545 |
|
|
char *q;
|
546 |
|
|
|
547 |
|
|
/* Check for and handle cretinous dbx symbol name
|
548 |
|
|
continuation! */
|
549 |
|
|
if (*p == '\\' || (*p == '?' && p[1] == '\0'))
|
550 |
|
|
p = next_symbol_text (objfile);
|
551 |
|
|
|
552 |
|
|
/* Point to the character after the name
|
553 |
|
|
of the enum constant. */
|
554 |
|
|
for (q = p; *q && *q != ':'; q++)
|
555 |
|
|
;
|
556 |
|
|
/* Note that the value doesn't matter for
|
557 |
|
|
enum constants in psymtabs, just in symtabs. */
|
558 |
|
|
add_psymbol_to_list (p, q - p,
|
559 |
|
|
VAR_NAMESPACE, LOC_CONST,
|
560 |
|
|
&objfile->static_psymbols, 0,
|
561 |
|
|
0, psymtab_language, objfile);
|
562 |
|
|
/* Point past the name. */
|
563 |
|
|
p = q;
|
564 |
|
|
/* Skip over the value. */
|
565 |
|
|
while (*p && *p != ',')
|
566 |
|
|
p++;
|
567 |
|
|
/* Advance past the comma. */
|
568 |
|
|
if (*p)
|
569 |
|
|
p++;
|
570 |
|
|
}
|
571 |
|
|
}
|
572 |
|
|
continue;
|
573 |
|
|
case 'c':
|
574 |
|
|
/* Constant, e.g. from "const" in Pascal. */
|
575 |
|
|
add_psymbol_to_list (namestring, p - namestring,
|
576 |
|
|
VAR_NAMESPACE, LOC_CONST,
|
577 |
|
|
&objfile->static_psymbols, CUR_SYMBOL_VALUE,
|
578 |
|
|
0, psymtab_language, objfile);
|
579 |
|
|
continue;
|
580 |
|
|
|
581 |
|
|
case 'f':
|
582 |
|
|
if (! pst)
|
583 |
|
|
{
|
584 |
|
|
int name_len = p - namestring;
|
585 |
|
|
char *name = xmalloc (name_len + 1);
|
586 |
|
|
memcpy (name, namestring, name_len);
|
587 |
|
|
name[name_len] = '\0';
|
588 |
|
|
complain (&function_outside_compilation_unit, name);
|
589 |
|
|
xfree (name);
|
590 |
|
|
}
|
591 |
|
|
CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
|
592 |
|
|
#ifdef DBXREAD_ONLY
|
593 |
|
|
/* Kludges for ELF/STABS with Sun ACC */
|
594 |
|
|
last_function_name = namestring;
|
595 |
|
|
#ifdef SOFUN_ADDRESS_MAYBE_MISSING
|
596 |
|
|
/* Do not fix textlow==0 for .o or NLM files, as 0 is a legit
|
597 |
|
|
value for the bottom of the text seg in those cases. */
|
598 |
|
|
if (pst && textlow_not_set)
|
599 |
|
|
{
|
600 |
|
|
pst->textlow =
|
601 |
|
|
find_stab_function_addr (namestring, pst->filename, objfile);
|
602 |
|
|
textlow_not_set = 0;
|
603 |
|
|
}
|
604 |
|
|
#endif
|
605 |
|
|
/* End kludge. */
|
606 |
|
|
|
607 |
|
|
/* Keep track of the start of the last function so we
|
608 |
|
|
can handle end of function symbols. */
|
609 |
|
|
last_function_start = CUR_SYMBOL_VALUE;
|
610 |
|
|
|
611 |
|
|
/* In reordered executables this function may lie outside
|
612 |
|
|
the bounds created by N_SO symbols. If that's the case
|
613 |
|
|
use the address of this function as the low bound for
|
614 |
|
|
the partial symbol table. */
|
615 |
|
|
if (pst
|
616 |
|
|
&& (textlow_not_set
|
617 |
|
|
|| (CUR_SYMBOL_VALUE < pst->textlow
|
618 |
|
|
&& (CUR_SYMBOL_VALUE
|
619 |
|
|
!= ANOFFSET (objfile->section_offsets,
|
620 |
|
|
SECT_OFF_TEXT (objfile))))))
|
621 |
|
|
{
|
622 |
|
|
pst->textlow = CUR_SYMBOL_VALUE;
|
623 |
|
|
textlow_not_set = 0;
|
624 |
|
|
}
|
625 |
|
|
#endif /* DBXREAD_ONLY */
|
626 |
|
|
add_psymbol_to_list (namestring, p - namestring,
|
627 |
|
|
VAR_NAMESPACE, LOC_BLOCK,
|
628 |
|
|
&objfile->static_psymbols,
|
629 |
|
|
0, CUR_SYMBOL_VALUE,
|
630 |
|
|
psymtab_language, objfile);
|
631 |
|
|
continue;
|
632 |
|
|
|
633 |
|
|
/* Global functions were ignored here, but now they
|
634 |
|
|
are put into the global psymtab like one would expect.
|
635 |
|
|
They're also in the minimal symbol table. */
|
636 |
|
|
case 'F':
|
637 |
|
|
if (! pst)
|
638 |
|
|
{
|
639 |
|
|
int name_len = p - namestring;
|
640 |
|
|
char *name = xmalloc (name_len + 1);
|
641 |
|
|
memcpy (name, namestring, name_len);
|
642 |
|
|
name[name_len] = '\0';
|
643 |
|
|
complain (&function_outside_compilation_unit, name);
|
644 |
|
|
xfree (name);
|
645 |
|
|
}
|
646 |
|
|
CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
|
647 |
|
|
#ifdef DBXREAD_ONLY
|
648 |
|
|
/* Kludges for ELF/STABS with Sun ACC */
|
649 |
|
|
last_function_name = namestring;
|
650 |
|
|
#ifdef SOFUN_ADDRESS_MAYBE_MISSING
|
651 |
|
|
/* Do not fix textlow==0 for .o or NLM files, as 0 is a legit
|
652 |
|
|
value for the bottom of the text seg in those cases. */
|
653 |
|
|
if (CUR_SYMBOL_VALUE == ANOFFSET (objfile->section_offsets,
|
654 |
|
|
SECT_OFF_TEXT (objfile)))
|
655 |
|
|
CUR_SYMBOL_VALUE =
|
656 |
|
|
find_stab_function_addr (namestring, pst->filename, objfile);
|
657 |
|
|
if (pst && textlow_not_set)
|
658 |
|
|
{
|
659 |
|
|
pst->textlow = CUR_SYMBOL_VALUE;
|
660 |
|
|
textlow_not_set = 0;
|
661 |
|
|
}
|
662 |
|
|
#endif
|
663 |
|
|
/* End kludge. */
|
664 |
|
|
|
665 |
|
|
/* Keep track of the start of the last function so we
|
666 |
|
|
can handle end of function symbols. */
|
667 |
|
|
last_function_start = CUR_SYMBOL_VALUE;
|
668 |
|
|
|
669 |
|
|
/* In reordered executables this function may lie outside
|
670 |
|
|
the bounds created by N_SO symbols. If that's the case
|
671 |
|
|
use the address of this function as the low bound for
|
672 |
|
|
the partial symbol table. */
|
673 |
|
|
if (pst
|
674 |
|
|
&& (textlow_not_set
|
675 |
|
|
|| (CUR_SYMBOL_VALUE < pst->textlow
|
676 |
|
|
&& (CUR_SYMBOL_VALUE
|
677 |
|
|
!= ANOFFSET (objfile->section_offsets,
|
678 |
|
|
SECT_OFF_TEXT (objfile))))))
|
679 |
|
|
{
|
680 |
|
|
pst->textlow = CUR_SYMBOL_VALUE;
|
681 |
|
|
textlow_not_set = 0;
|
682 |
|
|
}
|
683 |
|
|
#endif /* DBXREAD_ONLY */
|
684 |
|
|
add_psymbol_to_list (namestring, p - namestring,
|
685 |
|
|
VAR_NAMESPACE, LOC_BLOCK,
|
686 |
|
|
&objfile->global_psymbols,
|
687 |
|
|
0, CUR_SYMBOL_VALUE,
|
688 |
|
|
psymtab_language, objfile);
|
689 |
|
|
continue;
|
690 |
|
|
|
691 |
|
|
/* Two things show up here (hopefully); static symbols of
|
692 |
|
|
local scope (static used inside braces) or extensions
|
693 |
|
|
of structure symbols. We can ignore both. */
|
694 |
|
|
case 'V':
|
695 |
|
|
case '(':
|
696 |
|
|
case '0':
|
697 |
|
|
case '1':
|
698 |
|
|
case '2':
|
699 |
|
|
case '3':
|
700 |
|
|
case '4':
|
701 |
|
|
case '5':
|
702 |
|
|
case '6':
|
703 |
|
|
case '7':
|
704 |
|
|
case '8':
|
705 |
|
|
case '9':
|
706 |
|
|
case '-':
|
707 |
|
|
case '#': /* for symbol identification (used in live ranges) */
|
708 |
|
|
/* added to support cfront stabs strings */
|
709 |
|
|
case 'Z': /* for definition continuations */
|
710 |
|
|
case 'P': /* for prototypes */
|
711 |
|
|
continue;
|
712 |
|
|
|
713 |
|
|
case ':':
|
714 |
|
|
/* It is a C++ nested symbol. We don't need to record it
|
715 |
|
|
(I don't think); if we try to look up foo::bar::baz,
|
716 |
|
|
then symbols for the symtab containing foo should get
|
717 |
|
|
read in, I think. */
|
718 |
|
|
/* Someone says sun cc puts out symbols like
|
719 |
|
|
/foo/baz/maclib::/usr/local/bin/maclib,
|
720 |
|
|
which would get here with a symbol type of ':'. */
|
721 |
|
|
continue;
|
722 |
|
|
|
723 |
|
|
default:
|
724 |
|
|
/* Unexpected symbol descriptor. The second and subsequent stabs
|
725 |
|
|
of a continued stab can show up here. The question is
|
726 |
|
|
whether they ever can mimic a normal stab--it would be
|
727 |
|
|
nice if not, since we certainly don't want to spend the
|
728 |
|
|
time searching to the end of every string looking for
|
729 |
|
|
a backslash. */
|
730 |
|
|
|
731 |
|
|
complain (&unknown_symchar_complaint, p[1]);
|
732 |
|
|
|
733 |
|
|
/* Ignore it; perhaps it is an extension that we don't
|
734 |
|
|
know about. */
|
735 |
|
|
continue;
|
736 |
|
|
}
|
737 |
|
|
|
738 |
|
|
case N_EXCL:
|
739 |
|
|
#ifdef DBXREAD_ONLY
|
740 |
|
|
|
741 |
|
|
SET_NAMESTRING ();
|
742 |
|
|
|
743 |
|
|
/* Find the corresponding bincl and mark that psymtab on the
|
744 |
|
|
psymtab dependency list */
|
745 |
|
|
{
|
746 |
|
|
struct partial_symtab *needed_pst =
|
747 |
|
|
find_corresponding_bincl_psymtab (namestring, CUR_SYMBOL_VALUE);
|
748 |
|
|
|
749 |
|
|
/* If this include file was defined earlier in this file,
|
750 |
|
|
leave it alone. */
|
751 |
|
|
if (needed_pst == pst)
|
752 |
|
|
continue;
|
753 |
|
|
|
754 |
|
|
if (needed_pst)
|
755 |
|
|
{
|
756 |
|
|
int i;
|
757 |
|
|
int found = 0;
|
758 |
|
|
|
759 |
|
|
for (i = 0; i < dependencies_used; i++)
|
760 |
|
|
if (dependency_list[i] == needed_pst)
|
761 |
|
|
{
|
762 |
|
|
found = 1;
|
763 |
|
|
break;
|
764 |
|
|
}
|
765 |
|
|
|
766 |
|
|
/* If it's already in the list, skip the rest. */
|
767 |
|
|
if (found)
|
768 |
|
|
continue;
|
769 |
|
|
|
770 |
|
|
dependency_list[dependencies_used++] = needed_pst;
|
771 |
|
|
if (dependencies_used >= dependencies_allocated)
|
772 |
|
|
{
|
773 |
|
|
struct partial_symtab **orig = dependency_list;
|
774 |
|
|
dependency_list =
|
775 |
|
|
(struct partial_symtab **)
|
776 |
|
|
alloca ((dependencies_allocated *= 2)
|
777 |
|
|
* sizeof (struct partial_symtab *));
|
778 |
|
|
memcpy ((PTR) dependency_list, (PTR) orig,
|
779 |
|
|
(dependencies_used
|
780 |
|
|
* sizeof (struct partial_symtab *)));
|
781 |
|
|
#ifdef DEBUG_INFO
|
782 |
|
|
fprintf_unfiltered (gdb_stderr, "Had to reallocate dependency list.\n");
|
783 |
|
|
fprintf_unfiltered (gdb_stderr, "New dependencies allocated: %d\n",
|
784 |
|
|
dependencies_allocated);
|
785 |
|
|
#endif
|
786 |
|
|
}
|
787 |
|
|
}
|
788 |
|
|
}
|
789 |
|
|
#endif /* DBXREAD_ONLY */
|
790 |
|
|
continue;
|
791 |
|
|
|
792 |
|
|
case N_ENDM:
|
793 |
|
|
#ifdef SOFUN_ADDRESS_MAYBE_MISSING
|
794 |
|
|
/* Solaris 2 end of module, finish current partial symbol table.
|
795 |
|
|
END_PSYMTAB will set pst->texthigh to the proper value, which
|
796 |
|
|
is necessary if a module compiled without debugging info
|
797 |
|
|
follows this module. */
|
798 |
|
|
if (pst)
|
799 |
|
|
{
|
800 |
|
|
END_PSYMTAB (pst, psymtab_include_list, includes_used,
|
801 |
|
|
symnum * symbol_size,
|
802 |
|
|
(CORE_ADDR) 0,
|
803 |
|
|
dependency_list, dependencies_used, textlow_not_set);
|
804 |
|
|
pst = (struct partial_symtab *) 0;
|
805 |
|
|
includes_used = 0;
|
806 |
|
|
dependencies_used = 0;
|
807 |
|
|
}
|
808 |
|
|
#endif
|
809 |
|
|
continue;
|
810 |
|
|
|
811 |
|
|
case N_RBRAC:
|
812 |
|
|
#ifdef HANDLE_RBRAC
|
813 |
|
|
HANDLE_RBRAC (CUR_SYMBOL_VALUE);
|
814 |
|
|
continue;
|
815 |
|
|
#endif
|
816 |
|
|
case N_EINCL:
|
817 |
|
|
case N_DSLINE:
|
818 |
|
|
case N_BSLINE:
|
819 |
|
|
case N_SSYM: /* Claim: Structure or union element.
|
820 |
|
|
Hopefully, I can ignore this. */
|
821 |
|
|
case N_ENTRY: /* Alternate entry point; can ignore. */
|
822 |
|
|
case N_MAIN: /* Can definitely ignore this. */
|
823 |
|
|
case N_CATCH: /* These are GNU C++ extensions */
|
824 |
|
|
case N_EHDECL: /* that can safely be ignored here. */
|
825 |
|
|
case N_LENG:
|
826 |
|
|
case N_BCOMM:
|
827 |
|
|
case N_ECOMM:
|
828 |
|
|
case N_ECOML:
|
829 |
|
|
case N_FNAME:
|
830 |
|
|
case N_SLINE:
|
831 |
|
|
case N_RSYM:
|
832 |
|
|
case N_PSYM:
|
833 |
|
|
case N_LBRAC:
|
834 |
|
|
case N_NSYMS: /* Ultrix 4.0: symbol count */
|
835 |
|
|
case N_DEFD: /* GNU Modula-2 */
|
836 |
|
|
case N_ALIAS: /* SunPro F77: alias name, ignore for now. */
|
837 |
|
|
|
838 |
|
|
case N_OBJ: /* useless types from Solaris */
|
839 |
|
|
case N_OPT:
|
840 |
|
|
/* These symbols aren't interesting; don't worry about them */
|
841 |
|
|
|
842 |
|
|
continue;
|
843 |
|
|
|
844 |
|
|
default:
|
845 |
|
|
/* If we haven't found it yet, ignore it. It's probably some
|
846 |
|
|
new type we don't know about yet. */
|
847 |
|
|
complain (&unknown_symtype_complaint,
|
848 |
|
|
local_hex_string (CUR_SYMBOL_TYPE));
|
849 |
|
|
continue;
|
850 |
|
|
}
|