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 E9C88393F85B for ; Wed, 20 May 2020 09:40:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E9C88393F85B 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 B861FACC3; Wed, 20 May 2020 09:40:25 +0000 (UTC) Subject: Re: [PATCH][gdb/symtab] Handle .gdb_index in ada language mode To: Tom Tromey Cc: gdb-patches@sourceware.org, Simon Marchi References: <20200513094147.GA20499@delia> <87tv0b64yd.fsf@tromey.com> From: Tom de Vries Autocrypt: addr=tdevries@suse.de; keydata= xsBNBF0ltCcBCADDhsUnMMdEXiHFfqJdXeRvgqSEUxLCy/pHek88ALuFnPTICTwkf4g7uSR7 HvOFUoUyu8oP5mNb4VZHy3Xy8KRZGaQuaOHNhZAT1xaVo6kxjswUi3vYgGJhFMiLuIHdApoc u5f7UbV+egYVxmkvVLSqsVD4pUgHeSoAcIlm3blZ1sDKviJCwaHxDQkVmSsGXImaAU+ViJ5l CwkvyiiIifWD2SoOuFexZyZ7RUddLosgsO0npVUYbl6dEMq2a5ijGF6/rBs1m3nAoIgpXk6P TCKlSWVW6OCneTaKM5C387972qREtiArTakRQIpvDJuiR2soGfdeJ6igGA1FZjU+IsM5ABEB AAHNH1RvbSBkZSBWcmllcyA8dGRldnJpZXNAc3VzZS5kZT7CwKsEEwEIAD4WIQSsnSe5hKbL MK1mGmjuhV2rbOJEoAUCXSW0JwIbAwUJA8JnAAULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAh CRDuhV2rbOJEoBYhBKydJ7mEpsswrWYaaO6FXats4kSgc48H/Ra2lq5p3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xeTqwxC/1ZtNS DUCSFQjqA6bEGwM22dP8OUY6SC94x1G81A9/xbtm9LQxKm0EiDH8KBMLfQ== Message-ID: <89719b8a-9252-7af5-3ad8-1bcd1ebbc80c@suse.de> Date: Wed, 20 May 2020 11:40:21 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <87tv0b64yd.fsf@tromey.com> Content-Type: multipart/mixed; boundary="------------881001797FB6CA12A876EB12" Content-Language: en-US X-Spam-Status: No, score=-17.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_STOCKGEN, 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: Wed, 20 May 2020 09:40:25 -0000 This is a multi-part message in MIME format. --------------881001797FB6CA12A876EB12 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 19-05-2020 22:32, Tom Tromey wrote: >>>>>> "Tom" == Tom de Vries writes: > > Tom> Fix the inconsistency by completing implementation of > Tom> dw2_map_matching_symbols. > > Thanks for doing this. > > Tom> Tested on x86_64-linux, both with native and target board > Tom> cc-with-debug-index. > > Tom> Any comments? > > This may be the only barrier to supporting Ada in .gdb_index. > So, it seems like the Ada check in dwarf2/index-write.c should probably > be removed as well...? > > I'm not 100% sure whether it will work or not. Using this patch, I managed to get it working. The patch does the following: - enable ada .gdb_index by removing the ada check in write_psymbols - copy some ada-specific code from debug_names::insert to write_psymbols - disable a workaround for gold/15646 in dw2_expand_marked_cus As for the disabled workaround, I ran into trouble in gdb.ada/access_tagged_param.exp, where setting a breakpoint on foo failed. The index shows that there are two entries for foo, one variable, one function: ... [3733] foo: 3 [global, variable] 5 [global, function] ... The workaround skips the function, so disabling the workaround allows the test to pass (my guess atm is that the workaround is not precise enough). FWIW, if I use .debug_names instead, I see the same pattern: ... [445] #0b887389 foo: <6> DW_TAG_subprogram DW_IDX_compile_unit=5 DW_IDX_GNU_external=1 <2> DW_TAG_variable DW_IDX_compile_unit=3 DW_IDX_GNU_external=1 ... Thanks, - Tom --------------881001797FB6CA12A876EB12 Content-Type: text/x-patch; charset=UTF-8; name="0002-try.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="0002-try.patch" try --- gdb/dwarf2/index-write.c | 34 ++++++++++++++++++++++++++++++---- gdb/dwarf2/read.c | 12 ------------ 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index eabfe5d682..3e83e3ae2c 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -543,18 +543,44 @@ write_psymbols (struct mapped_symtab *symtab, for (; count-- > 0; ++psymp) { struct partial_symbol *psym = *psymp; + const char *name = psym->ginfo.search_name (); if (psym->ginfo.language () == language_ada) - error (_("Ada is not currently supported by the index; " - "use the DWARF 5 index instead")); + { + /* We want to ensure that the Ada main function's name appears + verbatim in the index. However, this name will be of the + form "_ada_mumble", and will be rewritten by ada_decode. + So, recognize it specially here and add it to the index by + hand. */ + if (strcmp (main_name (), name) == 0) + { + gdb_index_symbol_kind kind = symbol_kind (psym); + + add_index_entry (symtab, name, is_static, kind, cu_index); + } + + /* In order for the index to work when read back into gdb, it + has to supply a funny form of the name: it should be the + encoded name, with any suffixes stripped. Using the + ordinary encoded name will not work properly with the + searching logic in find_name_components_bounds; nor will + using the decoded name. Furthermore, an Ada "verbatim" + name (of the form "") must be entered without the + angle brackets. Note that the current index is unusual, + see PR symtab/24820 for details. */ + std::string decoded = ada_decode (name); + if (decoded[0] == '<') + name = (char *) strndup (decoded.c_str () + 1, decoded.length () - 2); + else + name = strdup (ada_encode (decoded.c_str ())); + } /* Only add a given psymbol once. */ if (psyms_seen.insert (psym).second) { gdb_index_symbol_kind kind = symbol_kind (psym); - add_index_entry (symtab, psym->ginfo.search_name (), - is_static, kind, cu_index); + add_index_entry (symtab, name, is_static, kind, cu_index); } } } diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index ded71f53b5..d25e8ecb8c 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -4514,7 +4514,6 @@ dw2_expand_marked_cus search_domain kind) { offset_type *vec, vec_len, vec_idx; - bool global_seen = false; mapped_index &index = *dwarf2_per_objfile->index_table; vec = (offset_type *) (index.constant_pool @@ -4523,8 +4522,6 @@ dw2_expand_marked_cus for (vec_idx = 0; vec_idx < vec_len; ++vec_idx) { offset_type cu_index_and_attrs = MAYBE_SWAP (vec[vec_idx + 1]); - /* This value is only valid for index versions >= 7. */ - int is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (cu_index_and_attrs); gdb_index_symbol_kind symbol_kind = GDB_INDEX_SYMBOL_KIND_VALUE (cu_index_and_attrs); int cu_index = GDB_INDEX_CU_VALUE (cu_index_and_attrs); @@ -4536,15 +4533,6 @@ dw2_expand_marked_cus (index.version >= 7 && symbol_kind != GDB_INDEX_SYMBOL_KIND_NONE); - /* Work around gold/15646. */ - if (attrs_valid) - { - if (!is_static && global_seen) - continue; - if (!is_static) - global_seen = true; - } - /* Only check the symbol's kind if it has one. */ if (attrs_valid) { --------------881001797FB6CA12A876EB12--