[PATCH v5 0/2] Enhancing LD_DEBUG with TLS logging and category exclusion support

Frédéric Bérat fberat@redhat.com
Tue Feb 24 10:24:08 GMT 2026


Hi,

This patch series improves the debugging capabilities of the dynamic
linker by introducing detailed logging for Thread-Local Storage (TLS)
operations and providing a mechanism to exclude specific categories from
the LD_DEBUG output.

The first patch adds comprehensive logging for TLS events, which are
often difficult to trace in multithreaded environments. This includes
module ID assignments, DTV resizing, and lazy allocation events. To aid
in identifying the context of these operations, logs include the TCB
address where applicable.

The second patch introduces the ability to prefix LD_DEBUG categories
with a dash (-) to exclude them. This is particularly useful when
combined with the all category, allowing users to suppress verbose
output from specific subsystems that are not relevant to their current
debugging task (e.g., LD_DEBUG=all,-tls).

Tested on x86_64-linux-gnu.

Best regards,

Fred

---
Changes since v4:
- Increase TLS size in tst-tls-debug-mod.c to 32KB to force dynamic
  allocation and ensure the expected debug messages are logged on all
  architectures.
Changes since v3:
- Standardized TLS debug logs to use a "tls: " prefix and improved
  message clarity (e.g., "TLS initialized").
- Restricted TCB address logging to thread-specific events, removing it
  from global events (module assignment/release).
- Corrected Lmid_t (namespace ID) printing to use %ld (signed long).
- Added missing glibc headers and detailed intent descriptions to new
  test scripts.
- Refactored LD_DEBUG parsing to a single-pass sequential loop to ensure
  proper handling of option ordering (e.g., 'all,-tls,tls' now leaves
  tls enabled).
- Expanded verification tests to cover sequential processing and
  ordering.
Frédéric Bérat (2):
  elf(tls): Add debug logging for TLS operations
  feat(rtld): Allow LD_DEBUG category exclusion

 elf/Makefile                   | 26 ++++++++++
 elf/dl-close.c                 |  5 ++
 elf/dl-tls.c                   | 83 +++++++++++++++++++++++++++-----
 elf/rtld.c                     | 21 ++++++--
 elf/tst-dl-debug-exclude.sh    | 87 ++++++++++++++++++++++++++++++++++
 elf/tst-tls-debug-recursive.sh | 83 ++++++++++++++++++++++++++++++++
 nptl/Makefile                  |  5 +-
 nptl/allocatestack.c           | 10 ++--
 nptl/nptl-stack.c              |  6 +--
 nptl/pthread_create.c          |  2 +-
 nptl/tst-dl-debug-tid.c        | 13 +++++
 nptl/tst-dl-debug-tid.sh       | 33 ++++++++++---
 nptl/tst-tls-debug-mod.c       | 26 ++++++++++
 sysdeps/x86_64/dl-tls.c        | 33 +++++++++++--
 14 files changed, 398 insertions(+), 35 deletions(-)
 create mode 100644 elf/tst-dl-debug-exclude.sh
 create mode 100755 elf/tst-tls-debug-recursive.sh
 create mode 100644 nptl/tst-tls-debug-mod.c


base-commit: b657f72fa34192b9afdd4cfab7fcf8e039d8888c
-- 
2.53.0



More information about the Libc-alpha mailing list