From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTP id 0D9B63982403 for ; Wed, 3 Mar 2021 19:04:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0D9B63982403 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey@adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id CE128116BAB; Wed, 3 Mar 2021 14:04:24 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id LwGcxvjFPS9f; Wed, 3 Mar 2021 14:04:24 -0500 (EST) Received: from murgatroyd.Home (71-211-165-100.hlrn.qwest.net [71.211.165.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 89D791169E7; Wed, 3 Mar 2021 14:04:24 -0500 (EST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [pushed] Minor Ada-related cleanups Date: Wed, 3 Mar 2021 12:04:21 -0700 Message-Id: <20210303190421.4003754-1-tromey@adacore.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Mar 2021 19:04:26 -0000 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(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index a7e0ccbe5b1..36375d9b8b3 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 7d94586c7f2..f8bf407fa6c 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, -- 2.26.2