Skip to content

Commit 582942f

Browse files
committed
More block constification
I noticed that there are still many places referring to non-const blocks. This constifies all the remaining ones that I found that could be constified. In a few spots, this search found unused variables or fields. I removed these. I've also removed some unnecessary casts to "struct block *". gdb/ChangeLog 2019-03-24 Tom Tromey <[email protected]> * c-exp.y (typebase): Remove casts. * gdbtypes.c (lookup_unsigned_typename, ) (lookup_signed_typename): Remove cast. * eval.c (parse_to_comma_and_eval): Remove cast. * parse.c (write_dollar_variable): Remove cast. * block.h (struct block) <superblock>: Now const. * symfile-debug.c (debug_qf_map_matching_symbols): Update. * psymtab.c (psym_map_matching_symbols): Make "block" const. (map_block): Make "block" const. * symfile.h (struct quick_symbol_functions) <map_matching_symbols>: Constify block argument to "callback". * symtab.c (basic_lookup_transparent_type_quick): Make "block" const. (find_pc_sect_compunit_symtab): Make "b" const. (find_symbol_at_address): Likewise. (search_symbols): Likewise. * dwarf2read.c (dw2_lookup_symbol): Make "block" const. (dw2_debug_names_lookup_symbol): Likewise. (dw2_map_matching_symbols): Update. * p-valprint.c (pascal_val_print): Remove "block". * ada-lang.c (ada_add_global_exceptions): Make "b" const. (aux_add_nonlocal_symbols): Make "block" const. (resolve_subexp): Remove cast. * linespec.c (iterate_over_all_matching_symtabs): Make "block" const. (iterate_over_file_blocks): Likewise. * f-exp.y (%union) <bval>: Remove. * coffread.c (patch_opaque_types): Make "b" const. * spu-tdep.c (spu_catch_start): Make "block" const. * c-valprint.c (print_unpacked_pointer): Remove "block". * symmisc.c (dump_symtab_1): Make "b" const. (block_depth): Make "block" const. * d-exp.y (%union) <bval>: Remove. * cp-support.h (cp_lookup_rtti_type): Update. * cp-support.c (cp_lookup_rtti_type): Make "block" const. * psymtab.c (psym_lookup_symbol): Make "block" const. (maintenance_check_psymtabs): Make "b" const. * python/py-framefilter.c (extract_sym): Make "sym_block" const. (enumerate_locals, enumerate_args): Update. * python/py-symtab.c (stpy_global_block): Make "block" const. (stpy_static_block): Likewise. * inline-frame.c (block_starting_point_at): Make "new_block" const. * block.c (find_block_in_blockvector): Make return type const. (blockvector_for_pc_sect): Make "b" const. (find_block_in_blockvector): Make "b" const.
1 parent 258876e commit 582942f

26 files changed

+99
-53
lines changed

gdb/ChangeLog

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,52 @@
1+
2019-03-24 Tom Tromey <[email protected]>
2+
3+
* c-exp.y (typebase): Remove casts.
4+
* gdbtypes.c (lookup_unsigned_typename, )
5+
(lookup_signed_typename): Remove cast.
6+
* eval.c (parse_to_comma_and_eval): Remove cast.
7+
* parse.c (write_dollar_variable): Remove cast.
8+
* block.h (struct block) <superblock>: Now const.
9+
* symfile-debug.c (debug_qf_map_matching_symbols): Update.
10+
* psymtab.c (psym_map_matching_symbols): Make "block" const.
11+
(map_block): Make "block" const.
12+
* symfile.h (struct quick_symbol_functions)
13+
<map_matching_symbols>: Constify block argument to "callback".
14+
* symtab.c (basic_lookup_transparent_type_quick): Make "block"
15+
const.
16+
(find_pc_sect_compunit_symtab): Make "b" const.
17+
(find_symbol_at_address): Likewise.
18+
(search_symbols): Likewise.
19+
* dwarf2read.c (dw2_lookup_symbol): Make "block" const.
20+
(dw2_debug_names_lookup_symbol): Likewise.
21+
(dw2_map_matching_symbols): Update.
22+
* p-valprint.c (pascal_val_print): Remove "block".
23+
* ada-lang.c (ada_add_global_exceptions): Make "b" const.
24+
(aux_add_nonlocal_symbols): Make "block" const.
25+
(resolve_subexp): Remove cast.
26+
* linespec.c (iterate_over_all_matching_symtabs): Make "block"
27+
const.
28+
(iterate_over_file_blocks): Likewise.
29+
* f-exp.y (%union) <bval>: Remove.
30+
* coffread.c (patch_opaque_types): Make "b" const.
31+
* spu-tdep.c (spu_catch_start): Make "block" const.
32+
* c-valprint.c (print_unpacked_pointer): Remove "block".
33+
* symmisc.c (dump_symtab_1): Make "b" const.
34+
(block_depth): Make "block" const.
35+
* d-exp.y (%union) <bval>: Remove.
36+
* cp-support.h (cp_lookup_rtti_type): Update.
37+
* cp-support.c (cp_lookup_rtti_type): Make "block" const.
38+
* psymtab.c (psym_lookup_symbol): Make "block" const.
39+
(maintenance_check_psymtabs): Make "b" const.
40+
* python/py-framefilter.c (extract_sym): Make "sym_block" const.
41+
(enumerate_locals, enumerate_args): Update.
42+
* python/py-symtab.c (stpy_global_block): Make "block" const.
43+
(stpy_static_block): Likewise.
44+
* inline-frame.c (block_starting_point_at): Make "new_block"
45+
const.
46+
* block.c (find_block_in_blockvector): Make return type const.
47+
(blockvector_for_pc_sect): Make "b" const.
48+
(find_block_in_blockvector): Make "b" const.
49+
150
2019-03-23 Tom Tromey <[email protected]>
251

352
* varobj.c (varobj_create): Update.

gdb/ada-lang.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3562,7 +3562,7 @@ resolve_subexp (expression_up *expp, int *pos, int deprocedure_p,
35623562

35633563
n_candidates =
35643564
ada_lookup_symbol_list (ada_decoded_op_name (op),
3565-
(struct block *) NULL, VAR_DOMAIN,
3565+
NULL, VAR_DOMAIN,
35663566
&candidates);
35673567

35683568
i = ada_resolve_function (candidates.data (), n_candidates, argvec,
@@ -5416,7 +5416,8 @@ struct match_data
54165416
other has been found. */
54175417

54185418
static int
5419-
aux_add_nonlocal_symbols (struct block *block, struct symbol *sym, void *data0)
5419+
aux_add_nonlocal_symbols (const struct block *block, struct symbol *sym,
5420+
void *data0)
54205421
{
54215422
struct match_data *data = (struct match_data *) data0;
54225423

@@ -13560,7 +13561,7 @@ ada_add_global_exceptions (compiled_regex *preg,
1356013561

1356113562
for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++)
1356213563
{
13563-
struct block *b = BLOCKVECTOR_BLOCK (bv, i);
13564+
const struct block *b = BLOCKVECTOR_BLOCK (bv, i);
1356413565
struct block_iterator iter;
1356513566
struct symbol *sym;
1356613567

gdb/block.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,16 @@ block_inlined_p (const struct block *bl)
131131
/* A helper function that checks whether PC is in the blockvector BL.
132132
It returns the containing block if there is one, or else NULL. */
133133

134-
static struct block *
134+
static const struct block *
135135
find_block_in_blockvector (const struct blockvector *bl, CORE_ADDR pc)
136136
{
137-
struct block *b;
137+
const struct block *b;
138138
int bot, top, half;
139139

140140
/* If we have an addrmap mapping code addresses to blocks, then use
141141
that. */
142142
if (BLOCKVECTOR_MAP (bl))
143-
return (struct block *) addrmap_find (BLOCKVECTOR_MAP (bl), pc);
143+
return (const struct block *) addrmap_find (BLOCKVECTOR_MAP (bl), pc);
144144

145145
/* Otherwise, use binary search to find the last block that starts
146146
before PC.
@@ -186,7 +186,7 @@ blockvector_for_pc_sect (CORE_ADDR pc, struct obj_section *section,
186186
struct compunit_symtab *cust)
187187
{
188188
const struct blockvector *bl;
189-
struct block *b;
189+
const struct block *b;
190190

191191
if (cust == NULL)
192192
{

gdb/block.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ struct block
107107
case of C) is the STATIC_BLOCK. The superblock of the
108108
STATIC_BLOCK is the GLOBAL_BLOCK. */
109109

110-
struct block *superblock;
110+
const struct block *superblock;
111111

112112
/* This is used to store the symbols in the block. */
113113

gdb/c-exp.y

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,13 +1391,13 @@ typebase
13911391
{ $$ = lookup_typename (parse_language (pstate),
13921392
parse_gdbarch (pstate),
13931393
"double",
1394-
(struct block *) NULL,
1394+
NULL,
13951395
0); }
13961396
| LONG DOUBLE_KEYWORD
13971397
{ $$ = lookup_typename (parse_language (pstate),
13981398
parse_gdbarch (pstate),
13991399
"long double",
1400-
(struct block *) NULL,
1400+
NULL,
14011401
0); }
14021402
| STRUCT name
14031403
{ $$ = lookup_struct (copy_name ($2),

gdb/c-valprint.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
197197
struct value *vt_val;
198198
struct symbol *wsym = NULL;
199199
struct type *wtype;
200-
struct block *block = NULL;
201200

202201
if (want_space)
203202
fputs_filtered (" ", stream);
@@ -206,7 +205,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
206205
{
207206
const char *search_name
208207
= MSYMBOL_SEARCH_NAME (msymbol.minsym);
209-
wsym = lookup_symbol_search_name (search_name, block,
208+
wsym = lookup_symbol_search_name (search_name, NULL,
210209
VAR_DOMAIN).symbol;
211210
}
212211

gdb/coffread.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,7 @@ patch_type (struct type *type, struct type *real_type)
14961496
static void
14971497
patch_opaque_types (struct symtab *s)
14981498
{
1499-
struct block *b;
1499+
const struct block *b;
15001500
struct block_iterator iter;
15011501
struct symbol *real_sym;
15021502

gdb/cp-support.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ add_symbol_overload_list_qualified (const char *func_name,
14221422
/* Lookup the rtti type for a class name. */
14231423

14241424
struct type *
1425-
cp_lookup_rtti_type (const char *name, struct block *block)
1425+
cp_lookup_rtti_type (const char *name, const struct block *block)
14261426
{
14271427
struct symbol * rtti_sym;
14281428
struct type * rtti_type;

gdb/cp-support.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ extern void add_symbol_overload_list_adl
118118
std::vector<symbol *> *overload_list);
119119

120120
extern struct type *cp_lookup_rtti_type (const char *name,
121-
struct block *block);
121+
const struct block *block);
122122

123123
/* Produce an unsigned hash value from SEARCH_NAME that is compatible
124124
with cp_symbol_name_matches. Only the last component in

gdb/d-exp.y

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ static int type_aggregate_p (struct type *);
9797
struct symtoken ssym;
9898
int ival;
9999
int voidval;
100-
struct block *bval;
101100
enum exp_opcode opcode;
102101
struct stoken_vector svec;
103102
}

0 commit comments

Comments
 (0)