diff options
author | Tom Tromey <tromey@redhat.com> | 2014-06-10 13:11:19 -0600 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2014-06-18 08:16:59 -0600 |
commit | 346d1dfebdbc5b7c8ce7d84f9250cbb8f4ec3e6c (patch) | |
tree | 1d18666acbd47c55c2fb23cc21fafa28337096a7 | |
parent | 1834676b5f9a7f425b68d181da85f96fe246e03b (diff) | |
download | gdb-346d1dfebdbc5b7c8ce7d84f9250cbb8f4ec3e6c.zip gdb-346d1dfebdbc5b7c8ce7d84f9250cbb8f4ec3e6c.tar.gz gdb-346d1dfebdbc5b7c8ce7d84f9250cbb8f4ec3e6c.tar.bz2 |
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.
-rw-r--r-- | gdb/ChangeLog | 32 | ||||
-rw-r--r-- | gdb/ada-lang.c | 2 | ||||
-rw-r--r-- | gdb/block.c | 12 | ||||
-rw-r--r-- | gdb/block.h | 12 | ||||
-rw-r--r-- | gdb/breakpoint.c | 2 | ||||
-rw-r--r-- | gdb/buildsym.c | 2 | ||||
-rw-r--r-- | gdb/dwarf2read.c | 2 | ||||
-rw-r--r-- | gdb/inline-frame.c | 2 | ||||
-rw-r--r-- | gdb/jit.c | 15 | ||||
-rw-r--r-- | gdb/jv-lang.c | 2 | ||||
-rw-r--r-- | gdb/mdebugread.c | 26 | ||||
-rw-r--r-- | gdb/objfiles.c | 2 | ||||
-rw-r--r-- | gdb/psymtab.c | 4 | ||||
-rw-r--r-- | gdb/python/py-symtab.c | 4 | ||||
-rw-r--r-- | gdb/spu-tdep.c | 2 | ||||
-rw-r--r-- | gdb/symmisc.c | 2 | ||||
-rw-r--r-- | gdb/symtab.c | 16 | ||||
-rw-r--r-- | gdb/symtab.h | 2 |
18 files changed, 89 insertions, 52 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 64351cb..d851f71 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,37 @@ 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. * completer.h (complete_line): Update. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index fb627b7..6956909 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -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++) diff --git a/gdb/block.c b/gdb/block.c index e388d69..a4b9ef5 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -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); diff --git a/gdb/block.h b/gdb/block.h index 2c3012a..0e5d0be 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -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, - struct obj_section *, - const struct block **, - struct symtab *); +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); diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index c2e0aed..b04f3b7 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -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; diff --git a/gdb/buildsym.c b/gdb/buildsym.c index b367d18..c49ed68 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -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) { diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 3e441dc..9a9f5aa 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -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); diff --git a/gdb/inline-frame.c b/gdb/inline-frame.c index 9027617..50f492a 100644 --- a/gdb/inline-frame.c +++ b/gdb/inline-frame.c @@ -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); @@ -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); } } diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c index 243a45a..3e5f096 100644 --- a/gdb/jv-lang.c +++ b/gdb/jv-lang.c @@ -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); } diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 2303010..2e9608b 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -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); diff --git a/gdb/objfiles.c b/gdb/objfiles.c index a86e8bc..0a0b1cb 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -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. */ diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 2787f4c..ba6a58a 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -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; diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c index d4c2dad..8f4208d 100644 --- a/gdb/python/py-symtab.c +++ b/gdb/python/py-symtab.c @@ -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); diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c index d251e4d..3980fe7 100644 --- a/gdb/spu-tdep.c +++ b/gdb/spu-tdep.c @@ -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; diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 7ea97bd..de2e166 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -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; diff --git a/gdb/symtab.c b/gdb/symtab.c index 3c9e0dd..655c6e8 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -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; diff --git a/gdb/symtab.h b/gdb/symtab.h index 94b9c60..5ccc7ec 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -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. */ |