From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id A499D385B836 for ; Tue, 24 Mar 2020 07:07:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A499D385B836 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B4E8FAC44 for ; Tue, 24 Mar 2020 07:07:52 +0000 (UTC) Date: Tue, 24 Mar 2020 08:07:51 +0100 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH][gdb/ada] Fix -readnow FAILs Message-ID: <20200324070749.GA30240@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-38.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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: Tue, 24 Mar 2020 07:07:55 -0000 Hi, When running test-case gdb.ada/access_to_packed_array we have: ... (gdb) print pack.a^M $1 = (0 => 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)^M ... but with target board readnow.exp, we have instead: ... (gdb) print pack.a^M 'pack.a' has unknown type; cast it to its declared type^M ... The symbol is normally found by the map_matching_symbols call in ada-lang.c:add_nonlocal_symbols: ... for (objfile *objfile : current_program_space->objfiles ()) { data.objfile = objfile; objfile->sf->qf->map_matching_symbols (objfile, lookup_name, domain, global, callback, (is_wild_match ? NULL : compare_names)); ... which maps onto psym_map_matching_symbols. Function psym_map_matching_symbols iterates over all the partial symtabs, and: - if not expanded, searches in the partial symtab: - if not found, continues to the next - if found, expands into full symtab - searches in the full symtab However, with -readnow the call maps onto dw2_map_matching_symbols instead, which is unimplemented, and consequently no symbol is found. Fix this by detecting -readnow in dw2_map_matching_symbols, and handling that appropriately given that partial symtabs are not present, and full symtabs are: iterate over all the symtabs and search them. Tested on x86_64-linux, with native and target board -readnow. This removes 217 FAILs with board -readnow. OK for trunk? Thanks, - Tom [gdb/ada] Fix -readnow FAILs gdb/ChangeLog: 2020-03-24 Tom de Vries PR ada/24671 * dwarf2/read.c (dw2_map_matching_symbols): Handle -readnow. --- gdb/dwarf2/read.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 0e879e08a0..44db6392c8 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -3685,9 +3685,35 @@ dw2_map_matching_symbols gdb::function_view callback, symbol_compare_ftype *ordered_compare) { - /* Currently unimplemented; used for Ada. The function can be called if the - current language is Ada for a non-Ada objfile using GNU index. As Ada - does not look for non-Ada symbols this function should just return. */ + /* Used for Ada. */ + struct dwarf2_per_objfile *dwarf2_per_objfile + = get_dwarf2_per_objfile (objfile); + + if (dwarf2_per_objfile->index_table) + { + /* Ada currently doesn't support .gdb_index (see PR24713). We can get + here though if the current language is Ada for a non-Ada objfile + using GNU index. As Ada does not look for non-Ada symbols this + function should just return. */ + return; + } + + /* We have -readnow: no .gdb_index, but no partial symtabs either. So, + inline psym_map_matching_symbols here, assuming all partial symtabs have + been read in. */ + const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK; + + for (compunit_symtab *cust : objfile->compunits ()) + { + const struct block *block; + + if (cust == NULL) + continue; + block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), block_kind); + if (!iterate_over_symbols_terminated (block, name, + domain, callback)) + return; + } } /* Starting from a search name, return the string that finds the upper