Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sourceware.org
Cc: Kevin Buettner <kevinb@redhat.com>
Subject: [PATCH v4 11/11] Add TLS NEWS entry and document 'set force-internal-tls-address-lookup' command
Date: Wed,  6 Nov 2024 12:21:47 -0700	[thread overview]
Message-ID: <20241106192517.206988-12-kevinb@redhat.com> (raw)
In-Reply-To: <20241106192517.206988-1-kevinb@redhat.com>

---
 gdb/NEWS            | 20 ++++++++++++++++++
 gdb/doc/gdb.texinfo | 50 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+)

diff --git a/gdb/NEWS b/gdb/NEWS
index 678d031b02f..5c0502652b8 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -67,6 +67,26 @@
      the return value from the latest "stepOut" command, when
      appropriate.
 
+* GDB-internal Thread Local Storage (TLS) support
+
+  ** Linux targets for the x86_64, aarch64, ppc64, s390x, and riscv
+     architectures now have GDB-internal support for TLS address
+     lookup in addition to that traditionally provided by the
+     libthread_db library.  This internal support works for programs
+     linked against either the GLIBC or MUSL C libraries.  For
+     programs linked against MUSL, this new internal support provides
+     new debug functionality, allowing access to TLS variables, due to
+     the fact that MUSL does not implement the libthread_db library. 
+     Internal TLS support is also useful in cross-debugging
+     situations, debugging statically linked binaries, and debugging
+     programs linked against GLIBC 2.33 and earlier, but which are not
+     linked against libpthread.
+
+  ** The command 'maint set force-internal-tls-address-lookup on' may
+     be used to force the internal TLS lookup mechanisms to be used. 
+     Otherwise, TLS lookup via libthread_db will still be preferred,
+     when available.
+
 * New commands
 
 set style line-number foreground COLOR
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index eb2aff974bb..b5c7a60f162 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -4084,6 +4084,56 @@ When @samp{on} @value{GDBN} will print additional messages when
 threads are created and deleted.
 @end table
 
+@cindex thread local storage
+@cindex @acronym{TLS}
+For some debugging targets, @value{GDBN} has support for accessing
+variables that reside in Thread Local Storage (@acronym{TLS}). 
+@acronym{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, @acronym{TLS} variables can also be used in
+programs without threads.  The C library variable @var{errno} is,
+perhaps, the most prominent example of a @acronym{TLS} variable that
+is frequently used in non-threaded programs.  For targets where
+@value{GDBN} does not have good @acronym{TLS} support, printing or
+changing the value of @var{errno} might not be directly possible.
+
+@sc{gnu}/Linux and FreeBSD targets have support for accessing
+@acronym{TLS} variables.  On @sc{gnu}/Linux, the helper library,
+@code{libthread_db}, is used to help resolve the addresses of
+@acronym{TLS} variables.  Some FreeBSD and some @sc{gnu}/Linux targets
+also have @value{GDBN}-internal @acronym{TLS} resolution code. 
+@sc{gnu}/Linux targets will attempt to use the @acronym{TLS} address
+lookup functionality provided by @code{libthread_db}, but will fall
+back to using its internal @acronym{TLS} support when
+@code{libthread_db} is not available.  This can happen in
+cross-debugging scenarios or when debugging programs that are linked
+in such a way that @code{libthread_db} support is unavailable -- this
+includes statically linked programs, linking against @acronym{GLIBC}
+versions earlier than 2.34, but not with @code{libpthread}, and use of
+other (non-@acronym{GLIBC}) C libraries.
+
+@table @code
+@kindex maint set force-internal-tls-address-lookup
+@kindex maint show force-internal-tls-address-lookup
+@cindex internal @acronym{TLS} address lookup
+@item maint set force-internal-tls-address-lookup
+@itemx maint show force-internal-tls-address-lookup
+Turns on or off forced use of @value{GDBN}-internal @acronym{TLS}
+address lookup code.  Use @code{on} to enable and @code{off} to
+disable.  The default for this setting is @code{off}.
+
+When disabled, @value{GDBN} will attempt to use a helper
+@code{libthread_db} library if possible, but will fall back to use of
+its own internal @acronym{TLS} address lookup mechanisms if necessary.
+
+When enabled, @value{GDBN} will only use @value{GDBN}'s internal
+@acronym{TLS} address lookup mechanisms, if they exist.
+
+This command is only available for @sc{gnu}/Linux targets.  Its
+primary use is for testing -- certain tests in the @value{GDBN} test
+suite use this command to force use of internal TLS address lookup. 
+@end table
+
 @node Forks
 @section Debugging Forks
 
-- 
2.46.2


  parent reply	other threads:[~2024-11-06 19:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-06 19:21 [PATCH v4 00/11] GDB-internal TLS support for Linux targets Kevin Buettner
2024-11-06 19:21 ` [PATCH v4 01/11] Don't attempt to find TLS address when target has no registers Kevin Buettner
2024-12-19 21:36   ` Tom Tromey
2024-11-06 19:21 ` [PATCH v4 02/11] Allow TLS access to work in gdb.server/no-thread-db.exp Kevin Buettner
2024-11-06 19:21 ` [PATCH v4 03/11] Track and fetch TLS module ids for MUSL and GLIBC Kevin Buettner
2024-11-06 19:21 ` [PATCH v4 04/11] Implement internal TLS address lookup for Linux targets Kevin Buettner
2024-11-06 19:21 ` [PATCH v4 05/11] Internal TLS support for aarch64, x86_64, riscv, ppc64, and s390x Kevin Buettner
2024-11-06 19:21 ` [PATCH v4 06/11] Internal, but disabled, TLS support for i386 Kevin Buettner
2024-11-06 19:21 ` [PATCH v4 07/11] Delete disabled i386 internal TLS support Kevin Buettner
2024-11-06 19:21 ` [PATCH v4 08/11] New test - gdb.base/tls-nothreads.exp Kevin Buettner
2024-11-06 19:21 ` [PATCH v4 09/11] New test - gdb.base/tls-multiobj.exp Kevin Buettner
2024-11-06 19:21 ` [PATCH v4 10/11] New test - gdb.base/tls-dlobj.exp Kevin Buettner
2024-11-06 19:21 ` Kevin Buettner [this message]
2024-11-07  5:38   ` [PATCH v4 11/11] Add TLS NEWS entry and document 'set force-internal-tls-address-lookup' command Eli Zaretskii
2024-11-27 17:36 ` [PATCH v4 00/11] GDB-internal TLS support for Linux targets Kevin Buettner
2024-11-27 18:59   ` Eli Zaretskii
2024-11-30 23:11     ` Kevin Buettner
2024-12-12 23:20 ` 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=20241106192517.206988-12-kevinb@redhat.com \
    --to=kevinb@redhat.com \
    --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