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