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