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 /gdb/mdebugread.c | |
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.
Diffstat (limited to 'gdb/mdebugread.c')
-rw-r--r-- | gdb/mdebugread.c | 26 |
1 files changed, 15 insertions, 11 deletions
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); |