From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta38.uswest2.a.cloudfilter.net (omta38.uswest2.a.cloudfilter.net [35.89.44.37]) by sourceware.org (Postfix) with ESMTPS id 6C49A385772F for ; Sun, 5 Nov 2023 18:11:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6C49A385772F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6C49A385772F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699207896; cv=none; b=QPNNPbI2YlG+AEJ2SZexrws9OU4zip0eA4LriHKyV/9Zv21NkweS8YKtxdzzun+8I3TB8Z+iVOTREdjATQ8ouwE5NSATPb0PyoLzqN/dFxNenD5vMa9KNq9Gw6IxaOpqt4AypxvaOORVTTGBpIyz9IUjYFI0hoO31ygYKxqzGkI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699207896; c=relaxed/simple; bh=1MgabHZDhuRVdVLry8UW8p1YSoJxORqagpv3tV8bONY=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=Uce9kN587iRrDHyQr7OPBw/+4WYTmi1YoqXq51vn98jxWUUZ9gvYGUM0bKBV1YCrMpsazCUWR1/hAKtTBTJcaz07ykD8AIM5WEDVT7Z0jqiGPzP5S2X4FK61M2UzQm/Tc7mGZSsFkimCiVexMCNMk67Arn3ynZ2nPIETo1o3D5s= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6002a.ext.cloudfilter.net ([10.0.30.222]) by cmsmtp with ESMTPS id zYhHquDy9KOkLzhauqKH53; Sun, 05 Nov 2023 18:11:32 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id zhatqwKfAGYrgzhatqJRl7; Sun, 05 Nov 2023 18:11:32 +0000 X-Authority-Analysis: v=2.4 cv=bYd47cDB c=1 sm=1 tr=0 ts=6547dad4 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=BNY50KLci1gA:10 a=Qbun_eYptAEA:10 a=qQCp4CSwvVzAQQtHYTcA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=cts6jI5UdGURHbhasINwaHnsudAKSfy1uvSU7m4VjkA=; b=lOQKts0XHlIgNv9EAtjUGUodjp onC4MbsUm3kokf27wKhE0qGOCGctWW8yJquFl73/+pbzjzmh0qNnftPYNtjs5j1cP1hD+dCFUzQ3j cI3zN40P2LqWM+COSPlR0QFbP; Received: from 97-122-77-73.hlrn.qwest.net ([97.122.77.73]:51014 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1qzhat-003Y66-15 for gdb-patches@sourceware.org; Sun, 05 Nov 2023 11:11:31 -0700 From: Tom Tromey Date: Sun, 05 Nov 2023 11:11:49 -0700 Subject: [PATCH v2 11/31] Use block_symbol::address in ada-lang.c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231105-split-objfile-2023-bound-sym-october-v2-11-dbd2d158bbc3@tromey.com> References: <20231105-split-objfile-2023-bound-sym-october-v2-0-dbd2d158bbc3@tromey.com> In-Reply-To: <20231105-split-objfile-2023-bound-sym-october-v2-0-dbd2d158bbc3@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.77.73 X-Source-L: No X-Exim-ID: 1qzhat-003Y66-15 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-77-73.hlrn.qwest.net ([192.168.0.21]) [97.122.77.73]:51014 X-Source-Auth: tom+tromey.com X-Email-Count: 12 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfLObsXsLepEKDhP91HHrhn6Cu2OgnhTakCg2zrf0mMnUdcpD22whhLiqCxFJ5ZPQzNVV1wCUbkg/Q17vaFFWoZpXeHlQzpHjw7lTbQZwJDGB0v+mkLIj MwKyL7W3fQqFe35ZkWxjoWk0TX5fvZE6HGpHAP6c7OwF2oJo/xnkd973l7a5eJKCWueM5GCxDJqEjhhMD/g5VHYnCuq+vtWOz0Q= X-Spam-Status: No, score=-3024.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This changes ada-lang.c to use block_symbol::address. --- gdb/ada-lang.c | 98 ++++++++++++++++++++++++++-------------------------------- 1 file changed, 43 insertions(+), 55 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 3391aaeccb3..03f405778e6 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -108,8 +108,7 @@ static void ada_add_all_symbols (std::vector &, static int is_nonfunction (const std::vector &); static void add_defn_to_vec (std::vector &, - struct symbol *, - const struct block *); + block_symbol); static int possible_user_operator_p (enum exp_opcode, struct value **); @@ -160,8 +159,6 @@ static struct value *value_subscript_packed (struct value *, int, static struct value *coerce_unspec_val_to_type (struct value *, struct type *); -static int lesseq_defined_than (struct symbol *, struct symbol *); - static int equiv_types (struct type *, struct type *); static int is_name_suffix (const char *); @@ -336,12 +333,9 @@ struct cache_entry std::string name; /* The namespace used during the lookup. */ domain_enum domain = UNDEF_DOMAIN; - /* The symbol returned by the lookup, or NULL if no matching symbol - was found. */ - struct symbol *sym = nullptr; - /* The block where the symbol was found, or NULL if no matching - symbol was found. */ - const struct block *block = nullptr; + /* The symbol returned by the lookup. The 'symbol' field will be + NULL if no matching symbol was found. */ + block_symbol sym = {}; }; /* The symbol cache uses this type when searching. */ @@ -4685,8 +4679,7 @@ ada_clear_symbol_cache (program_space *pspace) SYM. Same principle for BLOCK if not NULL. */ static int -lookup_cached_symbol (const char *name, domain_enum domain, - struct symbol **sym, const struct block **block) +lookup_cached_symbol (const char *name, domain_enum domain, block_symbol *sym) { htab_t tab = get_ada_pspace_data (current_program_space); cache_entry_search search; @@ -4699,18 +4692,17 @@ lookup_cached_symbol (const char *name, domain_enum domain, return 0; if (sym != nullptr) *sym = e->sym; - if (block != nullptr) - *block = e->block; return 1; } -/* Assuming that (SYM, BLOCK) is the result of the lookup of NAME +/* Assuming that SYM is the result of the lookup of NAME in domain DOMAIN, save this result in our symbol cache. */ static void -cache_symbol (const char *name, domain_enum domain, struct symbol *sym, - const struct block *block) +cache_symbol (const char *name, domain_enum domain, block_symbol bsym) { + symbol *sym = bsym.symbol; + /* Symbols for builtin types don't have a block. For now don't cache such symbols. */ if (sym != NULL && !sym->is_objfile_owned ()) @@ -4724,7 +4716,7 @@ cache_symbol (const char *name, domain_enum domain, struct symbol *sym, { const blockvector &bv = *sym->symtab ()->compunit ()->blockvector (); - if (bv.global_block () != block && bv.static_block () != block) + if (bv.global_block () != bsym.block && bv.static_block () != bsym.block) return; } @@ -4739,8 +4731,7 @@ cache_symbol (const char *name, domain_enum domain, struct symbol *sym, cache_entry *e = new cache_entry; e->name = name; e->domain = domain; - e->sym = sym; - e->block = block; + e->sym = bsym; *slot = e; } @@ -4768,13 +4759,12 @@ static struct symbol * standard_lookup (const char *name, const struct block *block, domain_enum domain) { - /* Initialize it just to avoid a GCC false warning. */ - struct block_symbol sym = {}; + struct block_symbol sym; - if (lookup_cached_symbol (name, domain, &sym.symbol, NULL)) + if (lookup_cached_symbol (name, domain, &sym)) return sym.symbol; ada_lookup_encoded_symbol (name, block, domain, &sym); - cache_symbol (name, domain, sym.symbol, sym.block); + cache_symbol (name, domain, sym); return sym.symbol; } @@ -4814,12 +4804,15 @@ equiv_types (struct type *type0, struct type *type1) return 0; } -/* True iff SYM0 represents the same entity as SYM1, or one that is - no more defined than that of SYM1. */ +/* True iff BSYM0 represents the same entity as BSYM1, or one that is + no more defined than that of BSYM1. */ static int -lesseq_defined_than (struct symbol *sym0, struct symbol *sym1) +lesseq_defined_than (block_symbol bsym0, block_symbol bsym1) { + symbol *sym0 = bsym0.symbol; + symbol *sym1 = bsym1.symbol; + if (sym0 == sym1) return 1; if (sym0->domain () != sym1->domain () @@ -4853,7 +4846,7 @@ lesseq_defined_than (struct symbol *sym0, struct symbol *sym1) const char *name0 = sym0->linkage_name (); const char *name1 = sym1->linkage_name (); return (strcmp (name0, name1) == 0 - && sym0->value_address () == sym1->value_address ()); + && bsym0.address () == bsym1.address ()); } default: @@ -4866,8 +4859,7 @@ lesseq_defined_than (struct symbol *sym0, struct symbol *sym1) static void add_defn_to_vec (std::vector &result, - struct symbol *sym, - const struct block *block) + block_symbol info) { /* Do not try to complete stub types, as the debugger is probably already scanning all symbols matching a certain name at the @@ -4880,19 +4872,15 @@ add_defn_to_vec (std::vector &result, for (int i = result.size () - 1; i >= 0; i -= 1) { - if (lesseq_defined_than (sym, result[i].symbol)) + if (lesseq_defined_than (info, result[i])) return; - else if (lesseq_defined_than (result[i].symbol, sym)) + else if (lesseq_defined_than (result[i], info)) { - result[i].symbol = sym; - result[i].block = block; + result[i] = info; return; } } - struct block_symbol info; - info.symbol = sym; - info.block = block; result.push_back (info); } @@ -5382,13 +5370,12 @@ struct match_data bool match_data::operator() (struct block_symbol *bsym) { - const struct block *block = bsym->block; struct symbol *sym = bsym->symbol; if (sym == NULL) { if (!found_sym && arg_sym != NULL) - add_defn_to_vec (*resultp, arg_sym, block); + add_defn_to_vec (*resultp, { arg_sym, bsym->block }); found_sym = false; arg_sym = NULL; } @@ -5401,7 +5388,7 @@ match_data::operator() (struct block_symbol *bsym) else { found_sym = true; - add_defn_to_vec (*resultp, sym, block); + add_defn_to_vec (*resultp, *bsym); } } return true; @@ -5651,8 +5638,6 @@ ada_add_all_symbols (std::vector &result, int full_search, int *made_global_lookup_p) { - struct symbol *sym; - if (made_global_lookup_p) *made_global_lookup_p = 0; @@ -5687,11 +5672,11 @@ ada_add_all_symbols (std::vector &result, already performed this search before. If we have, then return the same result. */ - if (lookup_cached_symbol (ada_lookup_name (lookup_name), - domain, &sym, &block)) + block_symbol sym; + if (lookup_cached_symbol (ada_lookup_name (lookup_name), domain, &sym)) { - if (sym != NULL) - add_defn_to_vec (result, sym, block); + if (sym.symbol != nullptr) + add_defn_to_vec (result, sym); return; } @@ -5739,11 +5724,10 @@ ada_lookup_symbol_list_worker (const lookup_name_info &lookup_name, remove_extra_symbols (results); if (results.empty () && full_search && syms_from_global_search) - cache_symbol (ada_lookup_name (lookup_name), domain, NULL, NULL); + cache_symbol (ada_lookup_name (lookup_name), domain, {}); if (results.size () == 1 && full_search && syms_from_global_search) - cache_symbol (ada_lookup_name (lookup_name), domain, - results[0].symbol, results[0].block); + cache_symbol (ada_lookup_name (lookup_name), domain, results[0]); remove_irrelevant_renamings (&results, block); return results; @@ -6087,7 +6071,7 @@ ada_add_block_symbols (std::vector &result, else { found_sym = true; - add_defn_to_vec (result, sym, block); + add_defn_to_vec (result, { sym, block }); } } } @@ -6100,7 +6084,7 @@ ada_add_block_symbols (std::vector &result, if (!found_sym && arg_sym != NULL) { - add_defn_to_vec (result, arg_sym, block); + add_defn_to_vec (result, { arg_sym, block }); } if (!lookup_name.ada ().wild_match_p ()) @@ -6136,7 +6120,7 @@ ada_add_block_symbols (std::vector &result, else { found_sym = true; - add_defn_to_vec (result, sym, block); + add_defn_to_vec (result, { sym, block }); } } } @@ -6147,7 +6131,7 @@ ada_add_block_symbols (std::vector &result, They aren't parameters, right? */ if (!found_sym && arg_sym != NULL) { - add_defn_to_vec (result, arg_sym, block); + add_defn_to_vec (result, { arg_sym, block }); } } } @@ -12999,8 +12983,10 @@ ada_add_exceptions_from_frame (compiled_regex *preg, default: if (ada_is_exception_sym (sym)) { + block_symbol bsym { sym, block }; + struct ada_exc_info info = {sym->print_name (), - sym->value_address ()}; + bsym.address ()}; exceptions->push_back (info); } @@ -13075,8 +13061,10 @@ ada_add_global_exceptions (compiled_regex *preg, if (ada_is_non_standard_exception_sym (sym) && name_matches_regex (sym->natural_name (), preg)) { + block_symbol bsym { sym, b }; + struct ada_exc_info info - = {sym->print_name (), sym->value_address ()}; + = {sym->print_name (), bsym.address ()}; exceptions->push_back (info); } -- 2.41.0