Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: John Baldwin <jhb@FreeBSD.org>
To: gdb-patches@sourceware.org
Subject: Re: [PATCH 01/12] Handle another edge case for TLS variable lookups.
Date: Wed, 23 Mar 2022 17:26:50 -0700	[thread overview]
Message-ID: <e06dd263-54d7-16e4-634b-32eff3a22b0c@FreeBSD.org> (raw)
In-Reply-To: <db43f5d2-543d-d90f-7c8f-fff09524891f@FreeBSD.org>

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 <simon.marchi@efficios.com>
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) <objfile>: 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) <per_objfile>: 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) <get_tls_address>: Update.
             <push_dwarf_reg_entry_value>: Update.
             <call_site_to_target_addr>: 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

  reply	other threads:[~2022-03-24  0:27 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-23 21:00 [PATCH 00/12] * Support for Thread Local Storage (TLS) variables on FreeBSD arm and aarch64 architectures John Baldwin
2022-03-23 21:00 ` [PATCH 01/12] Handle another edge case for TLS variable lookups John Baldwin
2022-03-23 23:55   ` John Baldwin
2022-03-24  0:26     ` John Baldwin [this message]
2022-03-23 21:00 ` [PATCH 02/12] fbsd-nat: Add helper routines for register sets using PT_[G]SETREGSET John Baldwin
2022-03-24  8:51   ` Luis Machado via Gdb-patches
2022-03-24 17:45     ` John Baldwin
2022-03-23 21:00 ` [PATCH 03/12] Create pseudo sections for NT_ARM_TLS notes on FreeBSD John Baldwin
2022-03-23 21:00 ` [PATCH 04/12] Add an arm-tls feature which includes the tpidruro register from CP15 John Baldwin
2022-04-04  8:01   ` Luis Machado via Gdb-patches
2022-04-12 23:36     ` John Baldwin
2022-04-14 10:23       ` Luis Machado via Gdb-patches
2022-04-19 16:18         ` John Baldwin
2022-04-20  6:59           ` Luis Machado via Gdb-patches
2022-03-23 21:00 ` [PATCH 05/12] Read the tpidruro register from NT_ARM_TLS core dump notes on FreeBSD/arm John Baldwin
2022-03-23 21:00 ` [PATCH 06/12] Support TLS variables " John Baldwin
2022-03-23 21:00 ` [PATCH 07/12] Fetch the NT_ARM_TLS register set for native FreeBSD/arm processes John Baldwin
2022-03-23 21:00 ` [PATCH 08/12] Add an aarch64-tls feature which includes the tpidr register John Baldwin
2022-03-28 10:16   ` Luis Machado via Gdb-patches
2022-04-01 23:30     ` John Baldwin
2022-04-04  8:06       ` Luis Machado via Gdb-patches
2022-04-04 12:18         ` Luis Machado via Gdb-patches
2022-05-03 21:14   ` Luis Machado via Gdb-patches
2022-05-03 21:30     ` John Baldwin
2022-05-03 21:34       ` Luis Machado via Gdb-patches
2022-03-23 21:00 ` [PATCH 09/12] Read the tpidr register from NT_ARM_TLS core dump notes on FreeBSD/Aarch64 John Baldwin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e06dd263-54d7-16e4-634b-32eff3a22b0c@FreeBSD.org \
    --to=jhb@freebsd.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox