mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-27 03:51:15 +08:00
Some constification in psymtab
This patch changes some spots in psymtab.[ch] to use 'const'. This is just preparation for a subsequent patch. Note that psymbols are conceptually const, and since they were changed to be objfile-indepdendent, they are truly never modified -- which is what makes this patch reasonably short.
This commit is contained in:
parent
c12221171b
commit
56fefe83f7
@ -37,18 +37,15 @@
|
||||
#include <set>
|
||||
#include "gdbsupport/buildargv.h"
|
||||
|
||||
static struct partial_symbol *lookup_partial_symbol (struct objfile *,
|
||||
struct partial_symtab *,
|
||||
const lookup_name_info &,
|
||||
int,
|
||||
domain_search_flags);
|
||||
static const struct partial_symbol *lookup_partial_symbol
|
||||
(struct objfile *, struct partial_symtab *, const lookup_name_info &,
|
||||
int, domain_search_flags);
|
||||
|
||||
static const char *psymtab_to_fullname (struct partial_symtab *ps);
|
||||
|
||||
static struct partial_symbol *find_pc_sect_psymbol (struct objfile *,
|
||||
struct partial_symtab *,
|
||||
CORE_ADDR,
|
||||
struct obj_section *);
|
||||
static const struct partial_symbol *find_pc_sect_psymbol
|
||||
(struct objfile *, struct partial_symtab *, CORE_ADDR,
|
||||
struct obj_section *);
|
||||
|
||||
static struct compunit_symtab *psymtab_to_symtab (struct objfile *objfile,
|
||||
struct partial_symtab *pst);
|
||||
@ -117,7 +114,7 @@ find_pc_sect_psymtab_closer (struct objfile *objfile,
|
||||
{
|
||||
if (pc >= tpst->text_low (objfile) && pc < tpst->text_high (objfile))
|
||||
{
|
||||
struct partial_symbol *p;
|
||||
const struct partial_symbol *p;
|
||||
CORE_ADDR this_addr;
|
||||
|
||||
/* NOTE: This assumes that every psymbol has a
|
||||
@ -212,12 +209,12 @@ psymbol_functions::find_pc_sect_compunit_symtab
|
||||
/* Find which partial symbol within a psymtab matches PC and SECTION.
|
||||
Return NULL if none. */
|
||||
|
||||
static struct partial_symbol *
|
||||
static const struct partial_symbol *
|
||||
find_pc_sect_psymbol (struct objfile *objfile,
|
||||
struct partial_symtab *psymtab, CORE_ADDR pc,
|
||||
struct obj_section *section)
|
||||
{
|
||||
struct partial_symbol *best = NULL;
|
||||
const struct partial_symbol *best = NULL;
|
||||
CORE_ADDR best_pc;
|
||||
const CORE_ADDR textlow = psymtab->text_low (objfile);
|
||||
|
||||
@ -229,7 +226,7 @@ find_pc_sect_psymbol (struct objfile *objfile,
|
||||
/* Search the global symbols as well as the static symbols, so that
|
||||
find_pc_partial_function doesn't use a minimal symbol and thus
|
||||
cache a bad endaddr. */
|
||||
for (partial_symbol *p : psymtab->global_psymbols)
|
||||
for (const partial_symbol *p : psymtab->global_psymbols)
|
||||
{
|
||||
if (p->domain == VAR_DOMAIN
|
||||
&& p->aclass == LOC_BLOCK
|
||||
@ -249,7 +246,7 @@ find_pc_sect_psymbol (struct objfile *objfile,
|
||||
}
|
||||
}
|
||||
|
||||
for (partial_symbol *p : psymtab->static_psymbols)
|
||||
for (const partial_symbol *p : psymtab->static_psymbols)
|
||||
{
|
||||
if (p->domain == VAR_DOMAIN
|
||||
&& p->aclass == LOC_BLOCK
|
||||
@ -289,7 +286,7 @@ psymbol_functions::lookup_global_symbol_language (struct objfile *objfile,
|
||||
|
||||
for (partial_symtab *ps : partial_symbols (objfile))
|
||||
{
|
||||
struct partial_symbol *psym;
|
||||
const struct partial_symbol *psym;
|
||||
if (ps->readin_p (objfile))
|
||||
continue;
|
||||
|
||||
@ -307,7 +304,7 @@ psymbol_functions::lookup_global_symbol_language (struct objfile *objfile,
|
||||
/* Returns true if PSYM matches LOOKUP_NAME. */
|
||||
|
||||
static bool
|
||||
psymbol_name_matches (partial_symbol *psym,
|
||||
psymbol_name_matches (const partial_symbol *psym,
|
||||
const lookup_name_info &lookup_name)
|
||||
{
|
||||
const language_defn *lang = language_def (psym->ginfo.language ());
|
||||
@ -320,14 +317,14 @@ psymbol_name_matches (partial_symbol *psym,
|
||||
LOOKUP_NAME. Check the global symbols if GLOBAL, the static
|
||||
symbols if not. */
|
||||
|
||||
static struct partial_symbol *
|
||||
static const struct partial_symbol *
|
||||
lookup_partial_symbol (struct objfile *objfile,
|
||||
struct partial_symtab *pst,
|
||||
const lookup_name_info &lookup_name,
|
||||
int global, domain_search_flags domain)
|
||||
{
|
||||
struct partial_symbol **start, **psym;
|
||||
struct partial_symbol **top, **real_top, **bottom, **center;
|
||||
const struct partial_symbol **start, **psym;
|
||||
const struct partial_symbol **top, **real_top, **bottom, **center;
|
||||
int length = (global
|
||||
? pst->global_psymbols.size ()
|
||||
: pst->static_psymbols.size ());
|
||||
@ -497,11 +494,11 @@ psymbol_functions::forget_cached_source_info (struct objfile *objfile)
|
||||
|
||||
static void
|
||||
print_partial_symbols (struct gdbarch *gdbarch, struct objfile *objfile,
|
||||
const std::vector<partial_symbol *> &symbols,
|
||||
const std::vector<const partial_symbol *> &symbols,
|
||||
const char *what, struct ui_file *outfile)
|
||||
{
|
||||
gdb_printf (outfile, " %s partial symbols:\n", what);
|
||||
for (partial_symbol *p : symbols)
|
||||
for (const partial_symbol *p : symbols)
|
||||
{
|
||||
QUIT;
|
||||
gdb_printf (outfile, " `%s'", p->ginfo.linkage_name ());
|
||||
@ -830,15 +827,15 @@ recursively_search_psymtabs
|
||||
}
|
||||
}
|
||||
|
||||
partial_symbol **gbound = (ps->global_psymbols.data ()
|
||||
+ ps->global_psymbols.size ());
|
||||
partial_symbol **sbound = (ps->static_psymbols.data ()
|
||||
+ ps->static_psymbols.size ());
|
||||
partial_symbol **bound = gbound;
|
||||
const partial_symbol **gbound = (ps->global_psymbols.data ()
|
||||
+ ps->global_psymbols.size ());
|
||||
const partial_symbol **sbound = (ps->static_psymbols.data ()
|
||||
+ ps->static_psymbols.size ());
|
||||
const partial_symbol **bound = gbound;
|
||||
|
||||
/* Go through all of the symbols stored in a partial
|
||||
symtab in one loop. */
|
||||
partial_symbol **psym = ps->global_psymbols.data ();
|
||||
const partial_symbol **psym = ps->global_psymbols.data ();
|
||||
|
||||
if ((search_flags & SEARCH_GLOBAL_BLOCK) == 0)
|
||||
{
|
||||
@ -1006,7 +1003,7 @@ partial_symtab::end ()
|
||||
/* Sort the global list; don't sort the static list. */
|
||||
std::sort (global_psymbols.begin (),
|
||||
global_psymbols.end (),
|
||||
[] (partial_symbol *s1, partial_symbol *s2)
|
||||
[] (const partial_symbol *s1, const partial_symbol *s2)
|
||||
{
|
||||
return strcmp_iw_ordered (s1->ginfo.search_name (),
|
||||
s2->ginfo.search_name ()) < 0;
|
||||
@ -1075,7 +1072,7 @@ partial_symtab::add_psymbol (const partial_symbol &psymbol,
|
||||
return;
|
||||
|
||||
/* Save pointer to partial symbol in psymtab, growing symtab if needed. */
|
||||
std::vector<partial_symbol *> &list
|
||||
std::vector<const partial_symbol *> &list
|
||||
= (where == psymbol_placement::STATIC
|
||||
? static_psymbols
|
||||
: global_psymbols);
|
||||
@ -1496,7 +1493,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
|
||||
continue;
|
||||
bv = cust->blockvector ();
|
||||
b = bv->static_block ();
|
||||
for (partial_symbol *psym : ps->static_psymbols)
|
||||
for (const partial_symbol *psym : ps->static_psymbols)
|
||||
{
|
||||
/* Skip symbols for inlined functions without address. These may
|
||||
or may not have a match in the full symtab. */
|
||||
@ -1518,7 +1515,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
|
||||
}
|
||||
}
|
||||
b = bv->global_block ();
|
||||
for (partial_symbol *psym : ps->global_psymbols)
|
||||
for (const partial_symbol *psym : ps->global_psymbols)
|
||||
{
|
||||
lookup_name_info lookup_name
|
||||
(psym->ginfo.search_name (), symbol_name_match_type::SEARCH_NAME);
|
||||
|
@ -444,7 +444,7 @@ struct partial_symtab
|
||||
improve access. Binary search will be the usual method of
|
||||
finding a symbol within it. */
|
||||
|
||||
std::vector<partial_symbol *> global_psymbols;
|
||||
std::vector<const partial_symbol *> global_psymbols;
|
||||
|
||||
/* Static symbol list. This list will *not* be sorted after readin;
|
||||
to find a symbol in it, exhaustive search must be used. This is
|
||||
@ -453,7 +453,7 @@ struct partial_symtab
|
||||
to take a *lot* of time; check) or an error (and we don't care
|
||||
how long errors take). */
|
||||
|
||||
std::vector<partial_symbol *> static_psymbols;
|
||||
std::vector<const partial_symbol *> static_psymbols;
|
||||
|
||||
/* True if the name of this partial symtab is not a source file name. */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user