Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Hannes Domani <ssbssa@yahoo.de>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC PATCH] Implement native TLS support on Windows
Date: Fri, 08 May 2026 13:09:07 -0600	[thread overview]
Message-ID: <87tsshn2gc.fsf@tromey.com> (raw)
In-Reply-To: <20260508144232.940078-1-ssbssa@yahoo.de> (Hannes Domani's message of "Fri, 8 May 2026 16:42:28 +0200")

>>>>> "Hannes" == Hannes Domani <ssbssa@yahoo.de> writes:

Hannes> I've used the fetch_tls_load_module_address gdbarch method to get the
Hannes> address of _tls_index of the OBJFILE, which is then forwarded as LM_ADDR
Hannes> to windows_get_thread_local_address, but I'm not really sure if this is
Hannes> allowed.

I think it is fine, or at most would need a small update to the comment
string explaining that the values are opaque and intended to be
target-specific.

Hannes> +/* Get the address of variable "_tls_index" of OBJFILE.  */
Hannes> +
Hannes> +static CORE_ADDR
Hannes> +windows_tls_index_address (struct objfile *objfile)
Hannes> +{
Hannes> +  bound_minimal_symbol minsym
Hannes> +    = lookup_minimal_symbol_linkage("_tls_index", objfile, false);

Missing space.

Hannes> +  gdb_byte buf[8];
Hannes> +  if (target_read_memory (lm_addr, buf, 4))
Hannes> +    throw_error (TLS_GENERIC_ERROR, _("Cannot read _tls_index"));
Hannes> +
Hannes> +  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
Hannes> +  uint32_t tls_index = extract_unsigned_integer (buf, 4, byte_order);
Hannes> +  CORE_ADDR tlb, tls_ptr, slot_ptr;
Hannes> +  if (target_get_tib_address (ptid, &tlb)
Hannes> +      && !target_read_memory (tlb + tls_offset, buf, ptr_bytes)
Hannes> +      && (tls_ptr = extract_unsigned_integer (buf, ptr_bytes,
Hannes> +					      byte_order)) != 0
Hannes> +      && !target_read_memory (tls_ptr + tls_index * ptr_bytes,
Hannes> +			      buf, ptr_bytes)
Hannes> +      && (slot_ptr = extract_unsigned_integer (buf, ptr_bytes,
Hannes> +					       byte_order)) != 0)

Instead of multiple assignments in an 'if' I think it'd be better to
have separate 'if's and early returns.

Tom

      parent reply	other threads:[~2026-05-08 19:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260508144232.940078-1-ssbssa.ref@yahoo.de>
2026-05-08 14:42 ` Hannes Domani
2026-05-08 14:56   ` Eli Zaretskii
2026-05-08 19:09   ` Tom Tromey [this message]

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=87tsshn2gc.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=ssbssa@yahoo.de \
    /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