From: Simon Marchi <simark@simark.ca>
To: John Baldwin <jhb@FreeBSD.org>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2 07/11] Add a helper function to resolve TLS variable addresses for FreeBSD.
Date: Thu, 07 Mar 2019 16:18:00 -0000 [thread overview]
Message-ID: <eddc12ba-1b15-f2ad-1a33-9b413ae28b9a@simark.ca> (raw)
In-Reply-To: <c7e57cc0f4e08580f7f78d5cc5e111b3db7637bf.1549672588.git.jhb@FreeBSD.org>
On 2019-02-08 7:40 p.m., John Baldwin wrote:
> The fbsd_get_thread_local_address function accepts the base address of
> a thread's DTV array and the base address of an object file's link map
> and uses this to compute a TLS variable's address. FreeBSD
> architectures use an architecture-specific method to determine the
> address of the DTV array pointer and call this helper function to
> perform the rest of the address calculation.
I didn't check against FreeBSD's data structures (I trust you for that
:)), but in general this LGTM. Just some formatting nits.
> +/* Per-program-space data for FreeBSD architectures. */
> +static const struct program_space_data *fbsd_pspace_data_handle;
> +
> +struct fbsd_pspace_data
> + {
> + /* Offsets in the runtime linker's 'Obj_Entry' structure. */
> + LONGEST off_linkmap;
> + LONGEST off_tlsindex;
> + bool rtld_offsets_valid;
> + };
Unindent the { } and what's between.
> +/* Lookup offsets of fields in the runtime linker's 'Obj_Entry'
> + structure needed to determine the TLS index of an object file. */
> +
> +static void
> +fbsd_fetch_rtld_offsets (struct gdbarch *gdbarch, struct fbsd_pspace_data *data)
> +{
> + TRY
> + {
> + /* Fetch offsets from debug symbols in rtld. */
> + struct symbol *obj_entry_sym
> + = lookup_symbol_in_language ("Struct_Obj_Entry", NULL, STRUCT_DOMAIN,
> + language_c, NULL).symbol;
> + if (obj_entry_sym == NULL)
> + error (_("Unable to find Struct_Obj_Entry symbol"));
> + data->off_linkmap = lookup_struct_elt (SYMBOL_TYPE(obj_entry_sym),
> + "linkmap", 0).offset / 8;
> + data->off_tlsindex = lookup_struct_elt (SYMBOL_TYPE(obj_entry_sym),
> + "tlsindex", 0).offset / 8;
> + data->rtld_offsets_valid = true;
> + return;
> + }
> + CATCH (e, RETURN_MASK_ERROR)
> + {
> + data->off_linkmap = -1;
> + }
> + END_CATCH
> +
> + TRY
> + {
> + /* Fetch offsets from global variables in libthr. Note that
> + this does not work for single-threaded processes that are not
> + linked against libthr. */
> + data->off_linkmap = fbsd_read_integer_by_name(gdbarch,
> + "_thread_off_linkmap");
> + data->off_tlsindex = fbsd_read_integer_by_name(gdbarch,
> + "_thread_off_tlsindex");
Missing spaces before parentheses.
> +/* Helper function to fetch the address of a thread-local variable.
> + DTV_ADDR is the base address of the thread's dtv array. LM_ADDR is
> + the address of the link_map structure for the associated object
> + file. */
> +
> +extern CORE_ADDR fbsd_get_thread_local_address (struct gdbarch *gdbarch,
> + CORE_ADDR dtv_addr,
> + CORE_ADDR lm_addr,
> + CORE_ADDR offset);
Could you document the offset parameter? I know it's obvious for
somebody who already knows how TLS works, but if somebody is still a
noob, they will appreciate the comment :).
Simon
next prev parent reply other threads:[~2019-03-07 16:18 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-09 0:42 [PATCH v2 00/11] Support for thread-local variables on FreeBSD John Baldwin
2019-02-09 0:42 ` [PATCH v2 06/11] Add a more general version of lookup_struct_elt_type John Baldwin
2019-02-09 1:08 ` John Baldwin
2019-02-11 10:27 ` Philipp Rudo
2019-02-11 17:44 ` John Baldwin
2019-03-07 15:53 ` Simon Marchi
2019-03-08 0:04 ` John Baldwin
2019-03-08 0:32 ` Pedro Alves
2019-03-08 18:39 ` John Baldwin
2019-02-09 0:42 ` [PATCH v2 02/11] Support fs_base and gs_base on FreeBSD/i386 John Baldwin
2019-02-09 0:42 ` [PATCH v2 09/11] Support TLS variables " John Baldwin
2019-02-09 0:42 ` [PATCH v2 03/11] Handle an edge case for minisym TLS variable lookups John Baldwin
2019-02-09 0:42 ` [PATCH v2 11/11] Support TLS variables on FreeBSD/powerpc John Baldwin
2019-03-07 16:26 ` Simon Marchi
2019-02-09 0:42 ` [PATCH v2 07/11] Add a helper function to resolve TLS variable addresses for FreeBSD John Baldwin
2019-03-07 16:18 ` Simon Marchi [this message]
2019-02-09 0:42 ` [PATCH v2 08/11] Support TLS variables on FreeBSD/amd64 John Baldwin
2019-02-09 0:42 ` [PATCH v2 01/11] Support the fs_base and gs_base registers on i386 John Baldwin
2019-02-09 0:50 ` [PATCH v2 10/11] Support TLS variables on FreeBSD/riscv John Baldwin
2019-02-09 0:50 ` [PATCH v2 04/11] Add a new gdbarch method to resolve the address of TLS variables John Baldwin
2019-03-07 16:08 ` Simon Marchi
2019-03-07 23:50 ` John Baldwin
2019-03-08 2:55 ` Simon Marchi
2019-03-08 18:39 ` John Baldwin
2019-02-09 0:50 ` [PATCH v2 05/11] Remove code disabled since at least 1999 from lookup_struct_elt_type John Baldwin
2019-03-07 16:25 ` Simon Marchi
2019-02-22 17:22 ` [PING][PATCH v2 00/11] Support for thread-local variables on FreeBSD John Baldwin
2019-03-12 20:21 ` Simon Marchi
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=eddc12ba-1b15-f2ad-1a33-9b413ae28b9a@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=jhb@FreeBSD.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