constify some blockvector APIs

Generally, the blockvector ought to be readonly.  So, this patch makes
the blockvector const in the symtab, and also changes various
blockvector APIs to be const.

This patch has a couple of spots that cast away const.  I consider
these to be ok because they occur in mdebugread and are used while
constructing the blockvector.  I have added comments at these spots.

2014-06-18  Tom Tromey  <tromey@redhat.com>

	* symtab.h (struct symtab) <blockvector>: Now const.
	* ada-lang.c (ada_add_global_exceptions): Update.
	* buildsym.c (augment_type_symtab): Update.
	* dwarf2read.c (dw2_lookup_symbol): Update.
	* jit.c (finalize_symtab): Update.
	* jv-lang.c (add_class_symtab_symbol): Update.
	* mdebugread.c (parse_symbol, add_block, sort_blocks, new_symtab):
	Update.
	* objfiles.c (objfile_relocate1): Update.
	* psymtab.c (lookup_symbol_aux_psymtabs)
	(maintenance_check_psymtabs): Update.
	* python/py-symtab.c (stpy_global_block, stpy_static_block):
	Update.
	* spu-tdep.c (spu_catch_start): Update.
	* symmisc.c (dump_symtab_1): Update.
	* symtab.c (lookup_global_symbol_from_objfile)
	(lookup_symbol_aux_objfile, lookup_symbol_aux_quick)
	(basic_lookup_transparent_type_quick)
	(basic_lookup_transparent_type, find_pc_sect_symtab)
	(find_pc_sect_line, search_symbols): Update.
	* block.c (find_block_in_blockvector): Make "bl" const.
	(blockvector_for_pc_sect, blockvector_for_pc): Make return type
	const.
	(blockvector_contains_pc): Make "bv" const.
	(block_for_pc_sect): Update.
	* block.h (blockvector_for_pc, blockvector_for_pc_sect)
	(blockvector_contains_pc): Update.
	* breakpoint.c (resolve_sal_pc): Update.
	* inline-frame.c (block_starting_point_at): Update.
This commit is contained in:
Tom Tromey 2014-06-10 13:11:19 -06:00
parent 1834676b5f
commit 346d1dfebd
18 changed files with 89 additions and 52 deletions

View file

@ -1,3 +1,35 @@
2014-06-18 Tom Tromey <tromey@redhat.com>
* symtab.h (struct symtab) <blockvector>: Now const.
* ada-lang.c (ada_add_global_exceptions): Update.
* buildsym.c (augment_type_symtab): Update.
* dwarf2read.c (dw2_lookup_symbol): Update.
* jit.c (finalize_symtab): Update.
* jv-lang.c (add_class_symtab_symbol): Update.
* mdebugread.c (parse_symbol, add_block, sort_blocks, new_symtab):
Update.
* objfiles.c (objfile_relocate1): Update.
* psymtab.c (lookup_symbol_aux_psymtabs)
(maintenance_check_psymtabs): Update.
* python/py-symtab.c (stpy_global_block, stpy_static_block):
Update.
* spu-tdep.c (spu_catch_start): Update.
* symmisc.c (dump_symtab_1): Update.
* symtab.c (lookup_global_symbol_from_objfile)
(lookup_symbol_aux_objfile, lookup_symbol_aux_quick)
(basic_lookup_transparent_type_quick)
(basic_lookup_transparent_type, find_pc_sect_symtab)
(find_pc_sect_line, search_symbols): Update.
* block.c (find_block_in_blockvector): Make "bl" const.
(blockvector_for_pc_sect, blockvector_for_pc): Make return type
const.
(blockvector_contains_pc): Make "bv" const.
(block_for_pc_sect): Update.
* block.h (blockvector_for_pc, blockvector_for_pc_sect)
(blockvector_contains_pc): Update.
* breakpoint.c (resolve_sal_pc): Update.
* inline-frame.c (block_starting_point_at): Update.
2014-06-18 Tom Tromey <tromey@redhat.com>
* completer.c (complete_line): Make "line_buffer" const.

View file

@ -12819,7 +12819,7 @@ ada_add_global_exceptions (regex_t *preg, VEC(ada_exc_info) **exceptions)
ALL_PRIMARY_SYMTABS (objfile, s)
{
struct blockvector *bv = BLOCKVECTOR (s);
const struct blockvector *bv = BLOCKVECTOR (s);
int i;
for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++)

View file

@ -107,7 +107,7 @@ block_inlined_p (const struct block *bl)
It returns the containing block if there is one, or else NULL. */
static struct block *
find_block_in_blockvector (struct blockvector *bl, CORE_ADDR pc)
find_block_in_blockvector (const struct blockvector *bl, CORE_ADDR pc)
{
struct block *b;
int bot, top, half;
@ -155,11 +155,11 @@ find_block_in_blockvector (struct blockvector *bl, CORE_ADDR pc)
is none. PBLOCK is a pointer to the block. If PBLOCK is NULL, we
don't pass this information back to the caller. */
struct blockvector *
const struct blockvector *
blockvector_for_pc_sect (CORE_ADDR pc, struct obj_section *section,
const struct block **pblock, struct symtab *symtab)
{
struct blockvector *bl;
const struct blockvector *bl;
struct block *b;
if (symtab == 0) /* if no symtab specified by caller */
@ -185,7 +185,7 @@ blockvector_for_pc_sect (CORE_ADDR pc, struct obj_section *section,
/* Return true if the blockvector BV contains PC, false otherwise. */
int
blockvector_contains_pc (struct blockvector *bv, CORE_ADDR pc)
blockvector_contains_pc (const struct blockvector *bv, CORE_ADDR pc)
{
return find_block_in_blockvector (bv, pc) != NULL;
}
@ -227,7 +227,7 @@ call_site_for_pc (struct gdbarch *gdbarch, CORE_ADDR pc)
containing the specified pc value, or 0 if there is none.
Backward compatibility, no section. */
struct blockvector *
const struct blockvector *
blockvector_for_pc (CORE_ADDR pc, const struct block **pblock)
{
return blockvector_for_pc_sect (pc, find_pc_mapped_section (pc),
@ -240,7 +240,7 @@ blockvector_for_pc (CORE_ADDR pc, const struct block **pblock)
const struct block *
block_for_pc_sect (CORE_ADDR pc, struct obj_section *section)
{
struct blockvector *bl;
const struct blockvector *bl;
const struct block *b;
bl = blockvector_for_pc_sect (pc, section, &b, NULL);

View file

@ -145,15 +145,15 @@ extern int block_inlined_p (const struct block *block);
extern int contained_in (const struct block *, const struct block *);
extern struct blockvector *blockvector_for_pc (CORE_ADDR,
extern const struct blockvector *blockvector_for_pc (CORE_ADDR,
const struct block **);
extern struct blockvector *blockvector_for_pc_sect (CORE_ADDR,
extern const struct blockvector *blockvector_for_pc_sect (CORE_ADDR,
struct obj_section *,
const struct block **,
struct symtab *);
extern int blockvector_contains_pc (struct blockvector *bv, CORE_ADDR pc);
extern int blockvector_contains_pc (const struct blockvector *bv, CORE_ADDR pc);
extern struct call_site *call_site_for_pc (struct gdbarch *gdbarch,
CORE_ADDR pc);

View file

@ -10104,7 +10104,7 @@ resolve_sal_pc (struct symtab_and_line *sal)
if (sal->section == 0 && sal->symtab != NULL)
{
struct blockvector *bv;
const struct blockvector *bv;
const struct block *b;
struct symbol *sym;

View file

@ -1390,7 +1390,7 @@ set_missing_symtab (struct pending *pending_list, struct symtab *symtab)
void
augment_type_symtab (struct objfile *objfile, struct symtab *primary_symtab)
{
struct blockvector *blockvector = primary_symtab->blockvector;
const struct blockvector *blockvector = primary_symtab->blockvector;
if (context_stack_depth > 0)
{

View file

@ -3616,7 +3616,7 @@ dw2_lookup_symbol (struct objfile *objfile, int block_index,
information (but NAME might contain it). */
if (stab->primary)
{
struct blockvector *bv = BLOCKVECTOR (stab);
const struct blockvector *bv = BLOCKVECTOR (stab);
struct block *block = BLOCKVECTOR_BLOCK (bv, block_index);
sym = lookup_block_symbol (block, name, domain);

View file

@ -276,7 +276,7 @@ const struct frame_unwind inline_frame_unwind = {
static int
block_starting_point_at (CORE_ADDR pc, const struct block *block)
{
struct blockvector *bv;
const struct blockvector *bv;
struct block *new_block;
bv = blockvector_for_pc (pc, NULL);

View file

@ -639,6 +639,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
struct block *block_iter;
int actual_nblocks, i, blockvector_size;
CORE_ADDR begin, end;
struct blockvector *bv;
actual_nblocks = FIRST_LOCAL_BLOCK + stab->nblocks;
@ -662,16 +663,16 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
blockvector_size = (sizeof (struct blockvector)
+ (actual_nblocks - 1) * sizeof (struct block *));
symtab->blockvector = obstack_alloc (&objfile->objfile_obstack,
blockvector_size);
bv = obstack_alloc (&objfile->objfile_obstack, blockvector_size);
symtab->blockvector = bv;
/* (begin, end) will contain the PC range this entire blockvector
spans. */
set_symtab_primary (symtab, 1);
BLOCKVECTOR_MAP (symtab->blockvector) = NULL;
BLOCKVECTOR_MAP (bv) = NULL;
begin = stab->blocks->begin;
end = stab->blocks->end;
BLOCKVECTOR_NBLOCKS (symtab->blockvector) = actual_nblocks;
BLOCKVECTOR_NBLOCKS (bv) = actual_nblocks;
/* First run over all the gdb_block objects, creating a real block
object for each. Simultaneously, keep setting the real_block
@ -706,7 +707,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
BLOCK_FUNCTION (new_block) = block_name;
BLOCKVECTOR_BLOCK (symtab->blockvector, i) = new_block;
BLOCKVECTOR_BLOCK (bv, i) = new_block;
if (begin > BLOCK_START (new_block))
begin = BLOCK_START (new_block);
if (end < BLOCK_END (new_block))
@ -732,7 +733,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
BLOCK_START (new_block) = (CORE_ADDR) begin;
BLOCK_END (new_block) = (CORE_ADDR) end;
BLOCKVECTOR_BLOCK (symtab->blockvector, i) = new_block;
BLOCKVECTOR_BLOCK (bv, i) = new_block;
if (i == GLOBAL_BLOCK)
set_block_symtab (new_block, symtab);
@ -755,7 +756,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
{
/* And if not, we set a default parent block. */
BLOCK_SUPERBLOCK (gdb_block_iter->real_block) =
BLOCKVECTOR_BLOCK (symtab->blockvector, STATIC_BLOCK);
BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
}
}

View file

@ -175,7 +175,7 @@ add_class_symtab_symbol (struct symbol *sym)
{
struct symtab *symtab
= get_java_class_symtab (get_objfile_arch (SYMBOL_SYMTAB (sym)->objfile));
struct blockvector *bv = BLOCKVECTOR (symtab);
const struct blockvector *bv = BLOCKVECTOR (symtab);
dict_add_symbol (BLOCK_DICT (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)), sym);
}

View file

@ -756,7 +756,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
b = top_stack->cur_block;
if (sh->st == stProc)
{
struct blockvector *bv = BLOCKVECTOR (top_stack->cur_st);
const struct blockvector *bv = BLOCKVECTOR (top_stack->cur_st);
/* The next test should normally be true, but provides a
hook for nested functions (which we don't want to make
@ -1131,7 +1131,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
top_stack->blocktype == stStaticProc))
{
/* Finished with procedure */
struct blockvector *bv = BLOCKVECTOR (top_stack->cur_st);
const struct blockvector *bv = BLOCKVECTOR (top_stack->cur_st);
struct mdebug_extra_func_info *e;
struct block *b = top_stack->cur_block;
struct type *ftype = top_stack->cur_type;
@ -4608,7 +4608,9 @@ add_symbol (struct symbol *s, struct symtab *symtab, struct block *b)
static void
add_block (struct block *b, struct symtab *s)
{
struct blockvector *bv = BLOCKVECTOR (s);
/* Cast away "const", but that's ok because we're building the
symtab and blockvector here. */
struct blockvector *bv = (struct blockvector *) BLOCKVECTOR (s);
bv = (struct blockvector *) xrealloc ((void *) bv,
(sizeof (struct blockvector)
@ -4677,7 +4679,9 @@ compare_blocks (const void *arg1, const void *arg2)
static void
sort_blocks (struct symtab *s)
{
struct blockvector *bv = BLOCKVECTOR (s);
/* We have to cast away const here, but this is ok because we're
constructing the blockvector in this code. */
struct blockvector *bv = (struct blockvector *) BLOCKVECTOR (s);
if (BLOCKVECTOR_NBLOCKS (bv) <= FIRST_LOCAL_BLOCK)
{
@ -4729,17 +4733,17 @@ static struct symtab *
new_symtab (const char *name, int maxlines, struct objfile *objfile)
{
struct symtab *s = allocate_symtab (name, objfile);
struct blockvector *bv;
LINETABLE (s) = new_linetable (maxlines);
/* All symtabs must have at least two blocks. */
BLOCKVECTOR (s) = new_bvect (2);
BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK)
= new_block (NON_FUNCTION_BLOCK);
BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK)
= new_block (NON_FUNCTION_BLOCK);
BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK)) =
BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
bv = new_bvect (2);
BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK) = new_block (NON_FUNCTION_BLOCK);
BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK) = new_block (NON_FUNCTION_BLOCK);
BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) =
BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
BLOCKVECTOR (s) = bv;
s->debugformat = "ECOFF";
return (s);

View file

@ -746,7 +746,7 @@ objfile_relocate1 (struct objfile *objfile,
ALL_OBJFILE_SYMTABS (objfile, s)
{
struct linetable *l;
struct blockvector *bv;
const struct blockvector *bv;
int i;
/* First the line table. */

View file

@ -517,7 +517,7 @@ lookup_symbol_aux_psymtabs (struct objfile *objfile,
information (but NAME might contain it). */
if (stab->primary)
{
struct blockvector *bv = BLOCKVECTOR (stab);
const struct blockvector *bv = BLOCKVECTOR (stab);
struct block *block = BLOCKVECTOR_BLOCK (bv, block_index);
sym = lookup_block_symbol (block, name, domain);
@ -2003,7 +2003,7 @@ maintenance_check_psymtabs (char *ignore, int from_tty)
struct partial_symbol **psym;
struct symtab *s = NULL;
struct partial_symtab *ps;
struct blockvector *bv;
const struct blockvector *bv;
struct objfile *objfile;
struct block *b;
int length;

View file

@ -161,7 +161,7 @@ stpy_global_block (PyObject *self, PyObject *args)
{
struct symtab *symtab = NULL;
struct block *block = NULL;
struct blockvector *blockvector;
const struct blockvector *blockvector;
STPY_REQUIRE_VALID (self, symtab);
@ -177,7 +177,7 @@ stpy_static_block (PyObject *self, PyObject *args)
{
struct symtab *symtab = NULL;
struct block *block = NULL;
struct blockvector *blockvector;
const struct blockvector *blockvector;
STPY_REQUIRE_VALID (self, symtab);

View file

@ -1985,7 +1985,7 @@ spu_catch_start (struct objfile *objfile)
minsym.minsym));
if (symtab != NULL)
{
struct blockvector *bv = BLOCKVECTOR (symtab);
const struct blockvector *bv = BLOCKVECTOR (symtab);
struct block *block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
struct symbol *sym;
struct symtab_and_line sal;

View file

@ -291,7 +291,7 @@ dump_symtab_1 (struct objfile *objfile, struct symtab *symtab,
struct dict_iterator iter;
int len;
struct linetable *l;
struct blockvector *bv;
const struct blockvector *bv;
struct symbol *sym;
struct block *b;
int depth;

View file

@ -1615,7 +1615,7 @@ lookup_global_symbol_from_objfile (const struct objfile *main_objfile,
{
const struct objfile *objfile;
struct symbol *sym;
struct blockvector *bv;
const struct blockvector *bv;
const struct block *block;
struct symtab *s;
@ -1655,7 +1655,7 @@ lookup_symbol_aux_objfile (struct objfile *objfile, int block_index,
const char *name, const domain_enum domain)
{
struct symbol *sym = NULL;
struct blockvector *bv;
const struct blockvector *bv;
const struct block *block;
struct symtab *s;
@ -1758,7 +1758,7 @@ lookup_symbol_aux_quick (struct objfile *objfile, int kind,
const char *name, const domain_enum domain)
{
struct symtab *symtab;
struct blockvector *bv;
const struct blockvector *bv;
const struct block *block;
struct symbol *sym;
@ -1946,7 +1946,7 @@ basic_lookup_transparent_type_quick (struct objfile *objfile, int kind,
const char *name)
{
struct symtab *symtab;
struct blockvector *bv;
const struct blockvector *bv;
struct block *block;
struct symbol *sym;
@ -1979,7 +1979,7 @@ basic_lookup_transparent_type (const char *name)
{
struct symbol *sym;
struct symtab *s = NULL;
struct blockvector *bv;
const struct blockvector *bv;
struct objfile *objfile;
struct block *block;
struct type *t;
@ -2136,7 +2136,7 @@ struct symtab *
find_pc_sect_symtab (CORE_ADDR pc, struct obj_section *section)
{
struct block *b;
struct blockvector *bv;
const struct blockvector *bv;
struct symtab *s = NULL;
struct symtab *best_s = NULL;
struct objfile *objfile;
@ -2279,7 +2279,7 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
int i;
struct linetable_entry *item;
struct symtab_and_line val;
struct blockvector *bv;
const struct blockvector *bv;
struct bound_minimal_symbol msymbol;
struct objfile *objfile;
@ -3516,7 +3516,7 @@ search_symbols (char *regexp, enum search_domain kind,
struct symbol_search **matches)
{
struct symtab *s;
struct blockvector *bv;
const struct blockvector *bv;
struct block *b;
int i = 0;
struct block_iterator iter;

View file

@ -882,7 +882,7 @@ struct symtab
between different symtabs (and normally is for all the symtabs
in a given compilation unit). */
struct blockvector *blockvector;
const struct blockvector *blockvector;
/* Table mapping core addresses to line numbers for this file.
Can be NULL if none. Never shared between different symtabs. */