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