From 1bfa81acbf33cd1157f3b34727136d963505a3d2 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 3 Mar 2021 12:02:16 -0700 Subject: Minor Ada-related cleanups This patch addresses some review comments that I forgot to deal with in an earlier patch. See the comments here: https://sourceware.org/pipermail/gdb-patches/2021-February/176278.html For the most part this is fixing up comments, but it also includes adding a constructor and initializers to "match_data". Regression tested on x86-64 Fedora 32. gdb/ChangeLog 2021-03-03 Tom Tromey * ada-lang.c (ada_resolve_function): Update comment. (is_nonfunction, add_symbols_from_enclosing_procs) (remove_extra_symbols): Likewise. (struct match_data): Add constructor, initializers. (add_nonlocal_symbols): Remove memset. (aux_add_nonlocal_symbols): Update comment. (ada_add_block_renamings, add_nonlocal_symbols) (ada_add_all_symbols): Likewise. * ada-exp.y (write_var_or_type): Clean up trailing whitespace. --- gdb/ChangeLog | 12 ++++++++++++ gdb/ada-exp.y | 2 +- gdb/ada-lang.c | 34 ++++++++++++++++++---------------- 3 files changed, 31 insertions(+), 17 deletions(-) (limited to 'gdb') diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 518e5c2..0587752 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +2021-03-03 Tom Tromey + + * ada-lang.c (ada_resolve_function): Update comment. + (is_nonfunction, add_symbols_from_enclosing_procs) + (remove_extra_symbols): Likewise. + (struct match_data): Add constructor, initializers. + (add_nonlocal_symbols): Remove memset. + (aux_add_nonlocal_symbols): Update comment. + (ada_add_block_renamings, add_nonlocal_symbols) + (ada_add_all_symbols): Likewise. + * ada-exp.y (write_var_or_type): Clean up trailing whitespace. + 2021-03-02 Tom Tromey * ada-lang.c (cast_from_gnat_encoded_fixed_point_type) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index a7e0ccb..36375d9 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -1297,7 +1297,7 @@ write_var_or_type (struct parser_state *par_state, write_selectors (par_state, encoded_name + tail_index); return NULL; } - else if (syms.empty ()) + else if (syms.empty ()) { struct bound_minimal_symbol msym = ada_lookup_simple_minsym (encoded_name); diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 7d94586..f8bf407 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -3903,7 +3903,7 @@ return_match (struct type *func_type, struct type *context_type) } -/* Returns the index in SYMS[0..NSYMS-1] that contains the symbol for the +/* Returns the index in SYMS that contains the symbol for the function (if any) that matches the types of the NARGS arguments in ARGS. If CONTEXT_TYPE is non-null and there is at least one match that returns that type, then eliminate matches that don't. If @@ -4684,7 +4684,7 @@ standard_lookup (const char *name, const struct block *block, /* Non-zero iff there is at least one non-function/non-enumeral symbol - in the symbol fields of SYMS[0..N-1]. We treat enumerals as functions, + in the symbol fields of SYMS. We treat enumerals as functions, since they contend in overloading in the same way. */ static int is_nonfunction (const std::vector &syms) @@ -4838,7 +4838,7 @@ ada_lookup_simple_minsym (const char *name) /* For all subprograms that statically enclose the subprogram of the selected frame, add symbols matching identifier NAME in DOMAIN - and their blocks to the list of data in OBSTACKP, as for + and their blocks to the list of data in RESULT, as for ada_add_block_symbols (q.v.). If WILD_MATCH_P, treat as NAME with a wildcard prefix. */ @@ -4966,8 +4966,7 @@ symbols_are_identical_enums (const std::vector &syms) duplicate other symbols in the list (The only case I know of where this happens is when object files containing stabs-in-ecoff are linked with files containing ordinary ecoff debugging symbols (or no - debugging symbols)). Modifies SYMS to squeeze out deleted entries. - Returns the number of items in the modified list. */ + debugging symbols)). Modifies SYMS to squeeze out deleted entries. */ static void remove_extra_symbols (std::vector *syms) @@ -5291,15 +5290,21 @@ ada_add_local_symbols (std::vector &result, struct match_data { - struct objfile *objfile; + explicit match_data (std::vector *rp) + : resultp (rp) + { + } + DISABLE_COPY_AND_ASSIGN (match_data); + + struct objfile *objfile = nullptr; std::vector *resultp; - struct symbol *arg_sym; - int found_sym; + struct symbol *arg_sym = nullptr; + int found_sym = 0; }; /* A callback for add_nonlocal_symbols that adds symbol, found in BSYM, to a list of symbols. DATA is a pointer to a struct match_data * - containing the obstack that collects the symbol list, the file that SYM + containing the vector that collects the symbol list, the file that SYM must come from, a flag indicating whether a non-argument symbol has been found in the current block, and the last argument symbol passed in SYM within the current block (if any). When SYM is null, @@ -5341,7 +5346,7 @@ aux_add_nonlocal_symbols (struct block_symbol *bsym, /* Helper for add_nonlocal_symbols. Find symbols in DOMAIN which are targeted by renamings matching LOOKUP_NAME in BLOCK. Add these - symbols to OBSTACKP. Return whether we found such symbols. */ + symbols to RESULT. Return whether we found such symbols. */ static int ada_add_block_renamings (std::vector &result, @@ -5490,7 +5495,7 @@ ada_lookup_name (const lookup_name_info &lookup_name) return lookup_name.ada ().lookup_name ().c_str (); } -/* Add to OBSTACKP all non-local symbols whose name and domain match +/* Add to RESULT all non-local symbols whose name and domain match LOOKUP_NAME and DOMAIN respectively. The search is performed on GLOBAL_BLOCK symbols if GLOBAL is non-zero, or on STATIC_BLOCK symbols otherwise. */ @@ -5500,10 +5505,7 @@ add_nonlocal_symbols (std::vector &result, const lookup_name_info &lookup_name, domain_enum domain, int global) { - struct match_data data; - - memset (&data, 0, sizeof data); - data.resultp = &result; + struct match_data data (&result); bool is_wild_match = lookup_name.ada ().wild_match_p (); @@ -5552,7 +5554,7 @@ add_nonlocal_symbols (std::vector &result, /* Find symbols in DOMAIN matching LOOKUP_NAME, in BLOCK and, if FULL_SEARCH is non-zero, enclosing scope and in global scopes, - returning the number of matches. Add these to OBSTACKP. + returning the number of matches. Add these to RESULT. When FULL_SEARCH is non-zero, any non-function/non-enumeral symbol match within the nest of blocks whose innermost member is BLOCK, -- cgit v1.1