diff options
author | Jim Blandy <jimb@codesourcery.com> | 2001-10-24 17:10:18 +0000 |
---|---|---|
committer | Jim Blandy <jimb@codesourcery.com> | 2001-10-24 17:10:18 +0000 |
commit | 3973eaddf42f21fd7f36696381b8a2f9d210215a (patch) | |
tree | 7a05d0dc9222d5f18cc42ecc7c225f7a37cb601a /gdb | |
parent | 908d94bfcd7598fb97015ed5a7474a1d26cf56a5 (diff) | |
download | gdb-3973eaddf42f21fd7f36696381b8a2f9d210215a.zip gdb-3973eaddf42f21fd7f36696381b8a2f9d210215a.tar.gz gdb-3973eaddf42f21fd7f36696381b8a2f9d210215a.tar.bz2 |
Isolate STABS readers' use of the `textlow' and `texthigh' fields
of `struct partial_symtab' to only a few locations. This change
is not supposed to affect the way the values are computed, only
where they live.
* dbxread.c (struct symloc): Add `textlow' and `texthigh' fields
to the reader-specific structure.
* mdebugread.c (struct symloc): Same.
* dbxread.c (TEXTLOW, TEXTHIGH): New accessor macros.
* mdebugread.c (TEXTLOW, TEXTHIGH): Same.
* dbxread.c (dbx_symfile_read): After we've built all our partial
symbol tables, set each partial symtab's `textlow' and `texthigh'
fields from our reader-specific structure.
* mdebugread.c (mdebug_build_psymtabs): Same.
* dbxread.c (start_psymtab): Initialize the reader-specific
structure's `textlow' and `texthigh' from the new psymtab's.
* mdebugread.c (parse_partial_symbols, new_psymtab): Same.
* dbxread.c (read_dbx_symtab, end_psymtab, read_ofile_symtab): Use
the reader-specific `textlow' and `texthigh', not the generic
psymtab fields.
* mdebugread.c (parse_lines, parse_partial_symbols,
psymtab_to_symtab_1): Same.
* partial-stab.h: Same.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 26 | ||||
-rw-r--r-- | gdb/dbxread.c | 54 | ||||
-rw-r--r-- | gdb/mdebugread.c | 68 | ||||
-rw-r--r-- | gdb/partial-stab.h | 26 | ||||
-rw-r--r-- | gdb/symfile.c | 1 |
5 files changed, 124 insertions, 51 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1a57cca..66dc87a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,29 @@ +2001-10-23 Jim Blandy <jimb@redhat.com> + + Isolate STABS readers' use of the `textlow' and `texthigh' fields + of `struct partial_symtab' to only a few locations. This change + is not supposed to affect the way the values are computed, only + where they live. + + * dbxread.c (struct symloc): Add `textlow' and `texthigh' fields + to the reader-specific structure. + * mdebugread.c (struct symloc): Same. + * dbxread.c (TEXTLOW, TEXTHIGH): New accessor macros. + * mdebugread.c (TEXTLOW, TEXTHIGH): Same. + * dbxread.c (dbx_symfile_read): After we've built all our partial + symbol tables, set each partial symtab's `textlow' and `texthigh' + fields from our reader-specific structure. + * mdebugread.c (mdebug_build_psymtabs): Same. + * dbxread.c (start_psymtab): Initialize the reader-specific + structure's `textlow' and `texthigh' from the new psymtab's. + * mdebugread.c (parse_partial_symbols, new_psymtab): Same. + * dbxread.c (read_dbx_symtab, end_psymtab, read_ofile_symtab): Use + the reader-specific `textlow' and `texthigh', not the generic + psymtab fields. + * mdebugread.c (parse_lines, parse_partial_symbols, + psymtab_to_symtab_1): Same. + * partial-stab.h: Same. + Tue Oct 23 18:59:42 2001 Andrew Cagney <cagney@redhat.com> * hp-psymtab-read.c, hppah-nat.c, hppa-tdep.c: Fix -Wformat diff --git a/gdb/dbxread.c b/gdb/dbxread.c index ca688d8..75a1ba7 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -76,6 +76,13 @@ struct symloc { + /* The start (inclusive) and end (exclusive) addresses for this + partial symtab's text. STABS doesn't reliably give us nice + start and end addresses for each function. Instead, we are + told the addresses of various boundary points, and we have to + gather those together to build ranges. These are our running + best guess as to the range of text addresses for this psymtab. */ + CORE_ADDR textlow, texthigh; /* Offset within the file symbol table of first local symbol for this file. */ @@ -105,6 +112,8 @@ struct symloc #define LDSYMOFF(p) (((struct symloc *)((p)->read_symtab_private))->ldsymoff) #define LDSYMLEN(p) (((struct symloc *)((p)->read_symtab_private))->ldsymlen) #define SYMLOC(p) ((struct symloc *)((p)->read_symtab_private)) +#define TEXTLOW(p) (SYMLOC(p)->textlow) +#define TEXTHIGH(p) (SYMLOC(p)->texthigh) #define SYMBOL_SIZE(p) (SYMLOC(p)->symbol_size) #define SYMBOL_OFFSET(p) (SYMLOC(p)->symbol_offset) #define STRING_OFFSET(p) (SYMLOC(p)->string_offset) @@ -599,6 +608,19 @@ dbx_symfile_read (struct objfile *objfile, int mainline) read_dbx_dynamic_symtab (objfile); + /* Take the text ranges the STABS partial symbol scanner computed + for each of the psymtabs and convert it into the canonical form + for psymtabs. */ + { + struct partial_symtab *p; + + ALL_OBJFILE_PSYMTABS (objfile, p) + { + p->textlow = TEXTLOW (p); + p->texthigh = TEXTHIGH (p); + } + } + /* Install any minimal symbols that have been collected as the current minimal symbols for this objfile. */ @@ -1341,7 +1363,7 @@ read_dbx_symtab (struct objfile *objfile) end_psymtab (pst, psymtab_include_list, includes_used, symnum * symbol_size, - text_end > pst->texthigh ? text_end : pst->texthigh, + text_end > TEXTHIGH (pst) ? text_end : TEXTHIGH (pst), dependency_list, dependencies_used, textlow_not_set); } @@ -1367,6 +1389,8 @@ start_psymtab (struct objfile *objfile, char *filename, CORE_ADDR textlow, result->read_symtab_private = (char *) obstack_alloc (&objfile->psymbol_obstack, sizeof (struct symloc)); + TEXTLOW (result) = result->textlow; + TEXTHIGH (result) = result->texthigh; LDSYMOFF (result) = ldsymoff; result->read_symtab = dbx_psymtab_to_symtab; SYMBOL_SIZE (result) = symbol_size; @@ -1402,7 +1426,7 @@ end_psymtab (struct partial_symtab *pst, char **include_list, int num_includes, if (capping_symbol_offset != -1) LDSYMLEN (pst) = capping_symbol_offset - LDSYMOFF (pst); - pst->texthigh = capping_text; + TEXTHIGH (pst) = capping_text; #ifdef SOFUN_ADDRESS_MAYBE_MISSING /* Under Solaris, the N_SO symbols always have a value of 0, @@ -1420,7 +1444,7 @@ end_psymtab (struct partial_symtab *pst, char **include_list, int num_includes, a reliable texthigh by taking the address plus size of the last function in the file. */ - if (pst->texthigh == 0 && last_function_name) + if (TEXTHIGH (pst) == 0 && last_function_name) { char *p; int n; @@ -1446,14 +1470,14 @@ end_psymtab (struct partial_symtab *pst, char **include_list, int num_includes, } if (minsym) - pst->texthigh = SYMBOL_VALUE_ADDRESS (minsym) + MSYMBOL_SIZE (minsym); + TEXTHIGH (pst) = SYMBOL_VALUE_ADDRESS (minsym) + MSYMBOL_SIZE (minsym); last_function_name = NULL; } /* this test will be true if the last .o file is only data */ if (textlow_not_set) - pst->textlow = pst->texthigh; + TEXTLOW (pst) = TEXTHIGH (pst); else { struct partial_symtab *p1; @@ -1466,12 +1490,12 @@ end_psymtab (struct partial_symtab *pst, char **include_list, int num_includes, ALL_OBJFILE_PSYMTABS (objfile, p1) { - if (p1->texthigh == 0 && p1->textlow != 0 && p1 != pst) + if (TEXTHIGH (p1) == 0 && TEXTLOW (p1) != 0 && p1 != pst) { - p1->texthigh = pst->textlow; + TEXTHIGH (p1) = TEXTLOW (pst); /* if this file has only data, then make textlow match texthigh */ - if (p1->textlow == 0) - p1->textlow = p1->texthigh; + if (TEXTLOW (p1) == 0) + TEXTLOW (p1) = TEXTHIGH (p1); } } } @@ -1508,8 +1532,8 @@ end_psymtab (struct partial_symtab *pst, char **include_list, int num_includes, sizeof (struct symloc)); LDSYMOFF (subpst) = LDSYMLEN (subpst) = - subpst->textlow = - subpst->texthigh = 0; + TEXTLOW (subpst) = + TEXTHIGH (subpst) = 0; /* We could save slight bits of space by only making one of these, shared by the entire set of include files. FIXME-someday. */ @@ -1677,8 +1701,8 @@ read_ofile_symtab (struct partial_symtab *pst) objfile = pst->objfile; sym_offset = LDSYMOFF (pst); sym_size = LDSYMLEN (pst); - text_offset = pst->textlow; - text_size = pst->texthigh - pst->textlow; + text_offset = TEXTLOW (pst); + text_size = TEXTHIGH (pst) - TEXTLOW (pst); /* This cannot be simply objfile->section_offsets because of elfstab_offset_sections() which initializes the psymtab section offsets information in a special way, and that is different from @@ -1823,13 +1847,13 @@ read_ofile_symtab (struct partial_symtab *pst) /* In a Solaris elf file, this variable, which comes from the value of the N_SO symbol, will still be 0. Luckily, text_offset, - which comes from pst->textlow is correct. */ + which comes from TEXTLOW (pst) is correct. */ if (last_source_start_addr == 0) last_source_start_addr = text_offset; /* In reordered executables last_source_start_addr may not be the lower bound for this symtab, instead use text_offset which comes - from pst->textlow which is correct. */ + from TEXTLOW (pst) which is correct. */ if (last_source_start_addr > text_offset) last_source_start_addr = text_offset; diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 130a458..255ad99 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -105,6 +105,11 @@ extern void _initialize_mdebugread (void); struct symloc { + /* Our running best guess as to the range of text addresses for + this psymtab. After we've read everything in, we use this to + build pst->text_addrs. */ + CORE_ADDR textlow, texthigh; + /* Index of the FDR that this psymtab represents. */ int fdr_idx; /* The BFD that the psymtab was created from. */ @@ -120,6 +125,8 @@ struct symloc }; #define PST_PRIVATE(p) ((struct symloc *)(p)->read_symtab_private) +#define TEXTLOW(p) (PST_PRIVATE(p)->textlow) +#define TEXTHIGH(p) (PST_PRIVATE(p)->texthigh) #define FDR_IDX(p) (PST_PRIVATE(p)->fdr_idx) #define CUR_BFD(p) (PST_PRIVATE(p)->cur_bfd) #define DEBUG_SWAP(p) (PST_PRIVATE(p)->debug_swap) @@ -516,6 +523,19 @@ mdebug_build_psymtabs (struct objfile *objfile, parse_partial_symbols (objfile); + /* Take the text ranges the partial symbol scanner computed for each + of the psymtabs and convert it into the canonical form for + psymtabs. */ + { + struct partial_symtab *p; + + ALL_OBJFILE_PSYMTABS (objfile, p) + { + p->textlow = TEXTLOW (p); + p->texthigh = TEXTHIGH (p); + } + } + #if 0 /* Check to make sure file was compiled with -g. If not, warn the user of this limitation. */ @@ -2174,7 +2194,7 @@ parse_lines (FDR *fh, PDR *pr, struct linetable *lt, int maxlines, halt = base + fh->cbLine; base += pr->cbLineOffset; - adr = pst->textlow + pr->adr - lowest_pdr_addr; + adr = TEXTLOW (pst) + pr->adr - lowest_pdr_addr; l = adr >> 2; /* in words */ for (lineno = pr->lnLow; base < halt;) @@ -2509,6 +2529,8 @@ parse_partial_symbols (struct objfile *objfile) memset ((PTR) pst->read_symtab_private, 0, sizeof (struct symloc)); save_pst = pst; + TEXTLOW (pst) = pst->textlow; + TEXTHIGH (pst) = pst->texthigh; FDR_IDX (pst) = f_idx; CUR_BFD (pst) = cur_bfd; DEBUG_SWAP (pst) = debug_swap; @@ -2544,7 +2566,7 @@ parse_partial_symbols (struct objfile *objfile) psymtab_language = prev_language; PST_PRIVATE (pst)->pst_language = psymtab_language; - pst->texthigh = pst->textlow; + TEXTHIGH (pst) = TEXTLOW (pst); /* For stabs-in-ecoff files, the second symbol must be @stab. This symbol is emitted by mips-tfile to signal that the @@ -2611,10 +2633,10 @@ parse_partial_symbols (struct objfile *objfile) /* Kludge for Irix 5.2 zero fh->adr. */ if (!relocatable - && (pst->textlow == 0 || procaddr < pst->textlow)) - pst->textlow = procaddr; - if (high > pst->texthigh) - pst->texthigh = high; + && (TEXTLOW (pst) == 0 || procaddr < TEXTLOW (pst))) + TEXTLOW (pst) = procaddr; + if (high > TEXTHIGH (pst)) + TEXTHIGH (pst) = high; } } else if (sh.st == stStatic) @@ -2703,7 +2725,7 @@ parse_partial_symbols (struct objfile *objfile) (pst = save_pst) #define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps,textlow_not_set) (void)0 #define HANDLE_RBRAC(val) \ - if ((val) > save_pst->texthigh) save_pst->texthigh = (val); + if ((val) > TEXTHIGH (save_pst)) TEXTHIGH (save_pst) = (val); #include "partial-stab.h" if (stabstring @@ -2836,12 +2858,12 @@ parse_partial_symbols (struct objfile *objfile) /* Kludge for Irix 5.2 zero fh->adr. */ if (!relocatable - && (pst->textlow == 0 || procaddr < pst->textlow)) - pst->textlow = procaddr; + && (TEXTLOW (pst) == 0 || procaddr < TEXTLOW (pst))) + TEXTLOW (pst) = procaddr; high = procaddr + sh.value; - if (high > pst->texthigh) - pst->texthigh = high; + if (high > TEXTHIGH (pst)) + TEXTHIGH (pst) = high; continue; case stStatic: /* Variable */ @@ -3015,16 +3037,16 @@ parse_partial_symbols (struct objfile *objfile) empty and put on the free list. */ fdr_to_pst[f_idx].pst = end_psymtab (save_pst, psymtab_include_list, includes_used, - -1, save_pst->texthigh, + -1, TEXTHIGH (save_pst), dependency_list, dependencies_used, textlow_not_set); includes_used = 0; dependencies_used = 0; - if (objfile->ei.entry_point >= save_pst->textlow && - objfile->ei.entry_point < save_pst->texthigh) + if (objfile->ei.entry_point >= TEXTLOW (save_pst) && + objfile->ei.entry_point < TEXTHIGH (save_pst)) { - objfile->ei.entry_file_lowpc = save_pst->textlow; - objfile->ei.entry_file_highpc = save_pst->texthigh; + objfile->ei.entry_file_lowpc = TEXTLOW (save_pst); + objfile->ei.entry_file_highpc = TEXTHIGH (save_pst); } /* The objfile has its functions reordered if this partial symbol @@ -3040,15 +3062,15 @@ parse_partial_symbols (struct objfile *objfile) other cases. */ save_pst = fdr_to_pst[f_idx].pst; if (save_pst != NULL - && save_pst->textlow != 0 + && TEXTLOW (save_pst) != 0 && !(objfile->flags & OBJF_REORDERED)) { ALL_OBJFILE_PSYMTABS (objfile, pst) { if (save_pst != pst - && save_pst->textlow >= pst->textlow - && save_pst->textlow < pst->texthigh - && save_pst->texthigh > pst->texthigh) + && TEXTLOW (save_pst) >= TEXTLOW (pst) + && TEXTLOW (save_pst) < TEXTHIGH (pst) + && TEXTHIGH (save_pst) > TEXTHIGH (pst)) { objfile->flags |= OBJF_REORDERED; break; @@ -3252,7 +3274,7 @@ psymtab_to_symtab_1 (struct partial_symtab *pst, char *filename) /* Do nothing if this is a dummy psymtab. */ if (pst->n_global_syms == 0 && pst->n_static_syms == 0 - && pst->textlow == 0 && pst->texthigh == 0) + && TEXTLOW (pst) == 0 && TEXTHIGH (pst) == 0) return; /* Now read the symbols for this symtab */ @@ -3400,7 +3422,7 @@ psymtab_to_symtab_1 (struct partial_symtab *pst, char *filename) if (! last_symtab_ended) { - st = end_symtab (pst->texthigh, pst->objfile, SECT_OFF_TEXT (pst->objfile)); + st = end_symtab (TEXTHIGH (pst), pst->objfile, SECT_OFF_TEXT (pst->objfile)); end_stabs (); } @@ -3490,7 +3512,7 @@ psymtab_to_symtab_1 (struct partial_symtab *pst, char *filename) top_stack->cur_st = st; top_stack->cur_block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (st), STATIC_BLOCK); - BLOCK_START (top_stack->cur_block) = pst->textlow; + BLOCK_START (top_stack->cur_block) = TEXTLOW (pst); BLOCK_END (top_stack->cur_block) = 0; top_stack->blocktype = stFile; top_stack->maxsyms = 2 * f_max; diff --git a/gdb/partial-stab.h b/gdb/partial-stab.h index e18cabb..dff74c2 100644 --- a/gdb/partial-stab.h +++ b/gdb/partial-stab.h @@ -104,12 +104,12 @@ switch (CUR_SYMBOL_TYPE) if (past_first_source_file && pst /* The gould NP1 uses low values for .o and -l symbols which are not the address. */ - && CUR_SYMBOL_VALUE >= pst->textlow) + && CUR_SYMBOL_VALUE >= TEXTLOW (pst)) { END_PSYMTAB (pst, psymtab_include_list, includes_used, symnum * symbol_size, - CUR_SYMBOL_VALUE > pst->texthigh - ? CUR_SYMBOL_VALUE : pst->texthigh, + CUR_SYMBOL_VALUE > TEXTHIGH (pst) + ? CUR_SYMBOL_VALUE : TEXTHIGH (pst), dependency_list, dependencies_used, textlow_not_set); pst = (struct partial_symtab *) 0; includes_used = 0; @@ -236,7 +236,7 @@ switch (CUR_SYMBOL_TYPE) { END_PSYMTAB (pst, psymtab_include_list, includes_used, symnum * symbol_size, - valu > pst->texthigh ? valu : pst->texthigh, + valu > TEXTHIGH (pst) ? valu : TEXTHIGH (pst), dependency_list, dependencies_used, prev_textlow_not_set); pst = (struct partial_symtab *) 0; @@ -405,8 +405,8 @@ switch (CUR_SYMBOL_TYPE) function relative stabs, or the address of the function's end for old style stabs. */ valu = CUR_SYMBOL_VALUE + last_function_start; - if (pst->texthigh == 0 || valu > pst->texthigh) - pst->texthigh = valu; + if (TEXTHIGH (pst) == 0 || valu > TEXTHIGH (pst)) + TEXTHIGH (pst) = valu; break; } #endif @@ -610,7 +610,7 @@ switch (CUR_SYMBOL_TYPE) } if (pst && textlow_not_set) { - pst->textlow = CUR_SYMBOL_VALUE; + TEXTLOW (pst) = CUR_SYMBOL_VALUE; textlow_not_set = 0; } #endif @@ -626,12 +626,12 @@ switch (CUR_SYMBOL_TYPE) the partial symbol table. */ if (pst && (textlow_not_set - || (CUR_SYMBOL_VALUE < pst->textlow + || (CUR_SYMBOL_VALUE < TEXTLOW (pst) && (CUR_SYMBOL_VALUE != ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)))))) { - pst->textlow = CUR_SYMBOL_VALUE; + TEXTLOW (pst) = CUR_SYMBOL_VALUE; textlow_not_set = 0; } #endif /* DBXREAD_ONLY */ @@ -677,7 +677,7 @@ switch (CUR_SYMBOL_TYPE) } if (pst && textlow_not_set) { - pst->textlow = CUR_SYMBOL_VALUE; + TEXTLOW (pst) = CUR_SYMBOL_VALUE; textlow_not_set = 0; } #endif @@ -693,12 +693,12 @@ switch (CUR_SYMBOL_TYPE) the partial symbol table. */ if (pst && (textlow_not_set - || (CUR_SYMBOL_VALUE < pst->textlow + || (CUR_SYMBOL_VALUE < TEXTLOW (pst) && (CUR_SYMBOL_VALUE != ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)))))) { - pst->textlow = CUR_SYMBOL_VALUE; + TEXTLOW (pst) = CUR_SYMBOL_VALUE; textlow_not_set = 0; } #endif /* DBXREAD_ONLY */ @@ -813,7 +813,7 @@ switch (CUR_SYMBOL_TYPE) case N_ENDM: #ifdef SOFUN_ADDRESS_MAYBE_MISSING /* Solaris 2 end of module, finish current partial symbol table. - END_PSYMTAB will set pst->texthigh to the proper value, which + END_PSYMTAB will set TEXTHIGH (pst) to the proper value, which is necessary if a module compiled without debugging info follows this module. */ if (pst) diff --git a/gdb/symfile.c b/gdb/symfile.c index 7f3fdc6..ebd0427 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1989,6 +1989,7 @@ allocate_psymtab (char *filename, struct objfile *objfile) psymtab->filename = obsavestring (filename, strlen (filename), &objfile->psymbol_obstack); psymtab->symtab = NULL; + psymtab->text_addrs = addrset_new (&objfile->psymbol_obstack); /* Prepend it to the psymtab list for the objfile it belongs to. Psymtabs are searched in most recent inserted -> least recent |