From: Eli Zaretskii <eliz@gnu.org>
To: Kevin Buettner <kevinb@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 11/11] Add TLS NEWS entry and document 'set force-internal-tls-address-lookup' command
Date: Fri, 11 Oct 2024 08:42:33 +0300 [thread overview]
Message-ID: <8634l319h2.fsf@gnu.org> (raw)
In-Reply-To: <20241010162631.6fe74f4b@f40-zbm-amd> (message from Kevin Buettner on Thu, 10 Oct 2024 16:27:50 -0700)
> Date: Thu, 10 Oct 2024 16:27:50 -0700
> From: Kevin Buettner <kevinb@redhat.com>
> Cc: gdb-patches@sourceware.org
>
> I'm trying to figure out where in the doc to add background
> material regarding TLS.
>
> Adding it to the text explaining the new command doesn't really
> fit with the way that other commands are documented. It seems
> to me that it ought to be placed in some prefatory remarks.
>
> If so, should it stay within "Debugging Programs with Multiple
> Threads"? Or would it make sense to make a new section, perhaps named
> "Thread Local Storage"?
We could leave it in the multiple-threads section (as the text is not
too long, and is related to threads), or we could add a new section
under "Data". In the latter case, you'd need to use cross-references
judiciously, both in the new section and in "Threads", to provide the
reader with all the relevant information, since libthread_db and the
commands related to it are only discussed in "Threads", and the new
command will be described there as well.
> Without getting bogged down with texinfo markup yet, here
> is what I propose saying about TLS:
>
> For some debugging targets, GDB has support for accessing
> variables that reside in Thread Local Storage (TLS). TLS
> variables are similar to global variables, except that each thread
> has its own copy of the variable. While often used in
> multi-threaded programs, TLS variables can also be used in
> programs without threads. The C library variable 'errno' is,
> perhaps, the most prominent example of a TLS variable that is
> frequently used in non-threaded programs. For targets where GDB
> does not have good TLS support, printing the value of errno might
> not be directly possible.
>
> Linux and FreeBSD targets have support for printing TLS variables.
> On Linux, the helper library, libthread_db, is used to help
> resolve the addresses of TLS variables. Some FreeBSD and some
> Linux targets also have GDB-internal TLS resolution code. Linux
> targets will attempt to use the TLS address lookup functionality
> provided by libthread_db, but will fall back to using its
> internal TLS support when libthread_db is not available. This can
> happen in cross-debugging scenarios or when debugging programs
> that are linked in such a way that libthread_db support is
> unavailable - this includes statically linked programs, GLIBC
> versions earlier than 2.34, and use of other (non-GLIBC) C libraries.
LGTM.
> There's a lot more that could be said about errno. Earlier this
> year, I wrote an article about it. See:
>
> https://developers.redhat.com/articles/2024/06/05/why-your-errno-value-isnt-printing-gdb-and-what-do-about-it
>
> That article dealt with errno problems on Linux, but some of the same
> tricks, with some tweaks, might apply to other environments too. It
> might make sense to try document some ways to obtain the value of
> errno when "print errno" doesn't just work. But that can be the
> topic of another patch.
We can have a summary of that in this new section.
Btw, the MS-Windows situation is similar to what you describe for
Linux. The MinGW <errno.h> says:
_CRTIMP int *__cdecl _errno(void);
#define errno (*_errno())
So one can display errno by calling this function with an explicit
type-cast. Maybe we should mention that if and when we add this to
the GDB manual.
> With regard to the question of why you might want to force use of
> internal TLS lookup, it's mostly for testing purposes.
If this is for testing, shouldn't it be a maint command?
next prev parent reply other threads:[~2024-10-11 5:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-10 2:16 [PATCH 00/11] GDB-internal TLS support for Linux targets Kevin Buettner
2024-10-10 2:16 ` [PATCH 01/11] Don't attempt to find TLS address when target has no registers Kevin Buettner
2024-10-10 2:16 ` [PATCH 02/11] Allow TLS access to work in gdb.server/no-thread-db.exp Kevin Buettner
2024-10-10 2:16 ` [PATCH 03/11] Track and fetch TLS module ids for MUSL and GLIBC Kevin Buettner
2024-10-10 2:16 ` [PATCH 04/11] Implement internal TLS address lookup for Linux targets Kevin Buettner
2024-10-10 2:16 ` [PATCH 05/11] Internal TLS support for aarch64, x86_64, riscv, ppc64, and s390x Kevin Buettner
2024-10-11 8:12 ` Luis Machado
2024-10-11 19:48 ` Kevin Buettner
2024-10-10 2:16 ` [PATCH 06/11] Internal, but disabled, TLS support for i386 Kevin Buettner
2024-10-10 2:16 ` [PATCH 07/11] Delete disabled i386 internal TLS support Kevin Buettner
2024-10-10 2:16 ` [PATCH 08/11] New test - gdb.base/tls-nothreads.exp Kevin Buettner
2024-10-10 2:16 ` [PATCH 09/11] New test - gdb.base/tls-multiobj.exp Kevin Buettner
2024-10-10 2:16 ` [PATCH 10/11] New test - gdb.base/tls-dlobj.exp Kevin Buettner
2024-10-10 2:16 ` [PATCH 11/11] Add TLS NEWS entry and document 'set force-internal-tls-address-lookup' command Kevin Buettner
2024-10-10 6:01 ` Eli Zaretskii
2024-10-10 23:27 ` Kevin Buettner
2024-10-11 5:42 ` Eli Zaretskii [this message]
2024-10-11 16:15 ` Kevin Buettner
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=8634l319h2.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=kevinb@redhat.com \
/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