From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id kPZDF+u6O2J/OAAAWB0awg (envelope-from ) for ; Wed, 23 Mar 2022 20:27:23 -0400 Received: by simark.ca (Postfix, from userid 112) id 5D2CF1F3E2; Wed, 23 Mar 2022 20:27:23 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 92C861F3B9 for ; Wed, 23 Mar 2022 20:27:22 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E9BC2386549C for ; Thu, 24 Mar 2022 00:27:21 +0000 (GMT) Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2610:1c1:1:606c::19:2]) by sourceware.org (Postfix) with ESMTPS id 47D7F3858C2C for ; Thu, 24 Mar 2022 00:27:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 47D7F3858C2C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 9D0A092436; Thu, 24 Mar 2022 00:26:51 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KP5d73kJ7z3t7Y; Thu, 24 Mar 2022 00:26:51 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648081611; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IWjWqshd955bFG6xMGVs9vdPdxjRuAo0Y+XUYOVay5Y=; b=ptLyrbJaMZVAE4okrVMu8tlZE1uyVzrDQJm7wYb8/tZBlUxlMNzmen1vfYjNZLspD3WvMS 6OYzVV8rgmb3aCshj6m+fc3tJ18sMmBGQaA1YO/j3Gwq0OpYkP4TL+mVueq/o+kdtdwIBx TkksDbZFSblwRNOA/ZqUbHmsOsQ+MzNBAkCp0FU9fM/+eSybK7OqU7Z6KCaP5kNhqlcjYp wF1el4zfHdm7r/0aGtpAXs45prL0VMNlAWzpAZ9m/xblzygHbjZ3p1pPNYUznh4Ou3awoX z3R6R5U6+QPLxQzrYU9ihRQ4NqEL2uWA/WPp/SwRDEqgJKpIXPS/1tf1GZl2hg== Received: from [10.0.1.4] (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 0300D29BC0; Thu, 24 Mar 2022 00:26:50 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: Date: Wed, 23 Mar 2022 17:26:50 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Content-Language: en-US From: John Baldwin To: gdb-patches@sourceware.org References: <20220323210048.25525-1-jhb@FreeBSD.org> <20220323210048.25525-2-jhb@FreeBSD.org> Subject: Re: [PATCH 01/12] Handle another edge case for TLS variable lookups. In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648081611; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IWjWqshd955bFG6xMGVs9vdPdxjRuAo0Y+XUYOVay5Y=; b=GpZie+ULm6DJHhsy2FpQUJ2F9nJhD3N2uUj3UKcPKx2y3nL/x0l/wRZDPPHdDuyyEd/4sh rMnMKrNUaC4eGGZNPUC0KiCuKAp+gxLFi1kmaxKDyLRYg+ZRiYWacfoMcHOwZHPfDIjQck lc2VMliP2zOvH6OAwpeLfW+7mdxeEX6AXUIMyepyNky9nyRnmFFhzYwd9Zj6GYT0Zkk3DO isS9uLw7DlIduzaaxTT2J1MEkdbL3D8J8w7e3HXgTOLHCiIueGyH6LbGMj3O84WOQ1OqNA PxWkqw2qLI/Ps/RzCOV6R9nMKP240OJGTRbT0voMA0OKyqWR0Ar8jShQiwnZqg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648081611; a=rsa-sha256; cv=none; b=HkpJkOHoQA1aHR3gSG68Nepzi4blU6gHh6ldk4/hsswsaBxB7nka9lFGfFcIbRBdKxyHaU xima0oMZyyGsCA5Q1icDzNQ/nmTyJIraW8WSNUcA+/UEzL5w/b5tDRz+1ooamhot1Z97mw OdXEH9Qdds3n2N9m4mONXymAeCqY0rIdBL8D8lPp4iOjORXrkkp7aYgaDvT1jZGoxh46+v 9UoHZLX9E7isfBCE/NK4a+q/O2NvdYSvQTJPsLn5yf174E98R/J+qIHXuLyRUgjMMed+2K BXe2X6Tsef7Nwa3vFcQODuC1Tq6StXtI7SAhJG4E5eW4AJ8Nze9PWi29Oj+dpw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 3/23/22 4:55 PM, John Baldwin wrote: > On 3/23/22 2:00 PM, John Baldwin wrote: >> This is similar to the change in >> df22c1e5d53c38f38bce6072bb46de240f9e0e2b but applies to the main >> object file. The original change I encountered when testing TLS on >> RISC-V for which I was unable to test TLS variables in the main >> executable due to issues with compiler-generated debug info, so I only >> checked for a backlink before walking the list of shared library >> object files. >> >> However, I ran into this issue again (of a separate debug object file >> being passed to svr4_fetch_objfile_link_map) when testing TLS >> variables on 32-bit arm. To fix, move the check for a backlink >> earlier before the check for the main object file. > > I now see this when using a separate debug file on FreeBSD/amd64 as > well FWIW. This definitely used to work but now needs this fix for > me. Curiously, 'info address' shows the variable belonging to the > separate debug file, e.g.: > > % gdb tls tls.core > ... > (gdb) info address id > Symbol "id" is a thread-local variable at offset 0x0 in the thread-local storage for `/usr/home/john/work/johnsvn/test/tls/tls.debug'. > > Arguably this is a recent bug somewhere in the DWARF parsing that > is longer following the backlink when choosing the object file > for a TLS variable? I think fixing svr4_fetch_objfile_link_map to > be resilient against this is still ok, but it might be worth > tracking down the other bug as well. I'll see if I can find it. So the change in behavior was introduced by this commit: commit 9f47c7071654d8cee82ff91ec1e65d57bd78e77f Author: Simon Marchi Date: Wed May 27 11:14:04 2020 -0400 Remove dwarf2_per_cu_data::objfile () Since dwarf2_per_cu_data objects are going to become objfile-independent, the backlink from dwarf2_per_cu_data to one particular objfile must be removed. Instead, users of dwarf2_per_cu_data that need an objfile must know from somewhere else in the context of which objfile they are using this CU. This also helps remove a dwarf2_per_cu_data::dwarf2_per_objfile reference (from where the objfile was obtained). Note that the dwarf2_per_cu_data::objfile method has a special case to make sure to return the main objfile, if the objfile associated to the dwarf2_per_cu_data is a separate debug objfile. I don't really know if this is necessary: I ignored that, and didn't see any regression when testing with the various Dejagnu boards with separate debug info, so I presume it wasn't needed. If it turns out this was needed, then we can have a helper method on the objfile type for that. gdb/ChangeLog: * dwarf2/read.h (struct dwarf2_per_cu_data) : Remove. * dwarf2/read.c (dwarf2_compute_name): Pass per_objfile down. (read_call_site_scope): Assign per_objfile. (dwarf2_per_cu_data::objfile): Remove. * gdbtypes.h (struct call_site) : New member. * dwarf2/loc.h (dwarf2_evaluate_loc_desc): Add dwarf2_per_objfile parameter. * dwarf2/loc.c (dwarf2_evaluate_loc_desc_full): Add dwarf2_per_objfile parameter. (dwarf_expr_reg_to_entry_parameter): Add output dwarf2_per_objfile parameter. (locexpr_get_frame_base): Update. (class dwarf_evaluate_loc_desc) : Update. : Update. : Update. (dwarf_entry_parameter_to_value): Add dwarf2_per_objfile parameter. (value_of_dwarf_reg_entry): Update. (rw_pieced_value): Update. (indirect_synthetic_pointer): Update. (dwarf2_evaluate_property): Update. (dwarf2_loc_desc_get_symbol_read_needs): Add dwarf2_per_objfile parameter. (locexpr_read_variable): Update. (locexpr_get_symbol_read_needs): Update. (loclist_read_variable): Update. In particular, this appears to be fallout from removing the special case to return the main objfile described in the last paragraph (and this means it is also likely a regression in GDB 12?). I did find that 'info address' also prints the name of the separate debug file in GDB 11, so that behavior is not new. -- John Baldwin