From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sourceware.org
Cc: Kevin Buettner <kevinb@redhat.com>
Subject: [PATCH v4 01/11] Don't attempt to find TLS address when target has no registers
Date: Wed, 6 Nov 2024 12:21:37 -0700 [thread overview]
Message-ID: <20241106192517.206988-2-kevinb@redhat.com> (raw)
In-Reply-To: <20241106192517.206988-1-kevinb@redhat.com>
This commit fixes two bugs, one of which is Bug 25807 - that one is
fixed by the change in findvar.c. I found it while testing on aarch64;
it turned a KFAIL for gdb.threads/tls.exp: print a_thread_local
into a FAIL due to a GDB internal error. In addition to the existing
test just noted, I've also added a test to the new test case
gdb.base/tls-nothreads.exp. It'll be tested, using different
scenarios, up to 8 times:
PASS: gdb.base/tls-nothreads.exp: default: force_internal_tls=false: after exit: print tls_tbss_1
PASS: gdb.base/tls-nothreads.exp: default: force_internal_tls=true: after exit: print tls_tbss_1
PASS: gdb.base/tls-nothreads.exp: static: force_internal_tls=false: after exit: print tls_tbss_1
PASS: gdb.base/tls-nothreads.exp: static: force_internal_tls=true: after exit: print tls_tbss_1
PASS: gdb.base/tls-nothreads.exp: pthreads: force_internal_tls=false: after exit: print tls_tbss_1
PASS: gdb.base/tls-nothreads.exp: pthreads: force_internal_tls=true: after exit: print tls_tbss_1
PASS: gdb.base/tls-nothreads.exp: pthreads-static: force_internal_tls=false: after exit: print tls_tbss_1
PASS: gdb.base/tls-nothreads.exp: pthreads-static: force_internal_tls=true: after exit: print tls_tbss_1
There is a related problem that's fixed by the minsyms.c change. It
can be observed when debugging a program without debugging symbols
when the program is not executing. I've written a new test for this,
but it's included in the new test case gdb.base/tls-nothreads.exp,
found later in this series. Depending on the target, it'll be run
up to 8 times for different targets. E.g., on aarch64, I'm seeing
these PASSes, all of which test this change:
PASS: gdb.base/tls-nothreads.exp: default: force_internal_tls=false: stripped: after exit: print (int) tls_tbss_1
PASS: gdb.base/tls-nothreads.exp: default: force_internal_tls=true: stripped: after exit: print (int) tls_tbss_1
PASS: gdb.base/tls-nothreads.exp: static: force_internal_tls=false: stripped: after exit: print (int) tls_tbss_1
PASS: gdb.base/tls-nothreads.exp: static: force_internal_tls=true: stripped: after exit: print (int) tls_tbss_1
PASS: gdb.base/tls-nothreads.exp: pthreads: force_internal_tls=false: stripped: after exit: print (int) tls_tbss_1
PASS: gdb.base/tls-nothreads.exp: pthreads: force_internal_tls=true: stripped: after exit: print (int) tls_tbss_1
PASS: gdb.base/tls-nothreads.exp: pthreads-static: force_internal_tls=false: stripped: after exit: print (int) tls_tbss_1
PASS: gdb.base/tls-nothreads.exp: pthreads-static: force_internal_tls=true: stripped: after exit: print (int) tls_tbss_1
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=25807
---
gdb/findvar.c | 7 ++++++-
gdb/minsyms.c | 8 +++++++-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/gdb/findvar.c b/gdb/findvar.c
index f7760aa61ca..a530e679c8a 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -485,7 +485,12 @@ language_defn::read_var_value (struct symbol *var,
/* Determine address of TLS variable. */
if (obj_section
&& (obj_section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0)
- addr = target_translate_tls_address (obj_section->objfile, addr);
+ {
+ if (!target_has_registers ())
+ error (_("Cannot read `%s' without registers"),
+ var->print_name ());
+ addr = target_translate_tls_address (obj_section->objfile, addr);
+ }
}
break;
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 33eb9072e5f..a904bd96045 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -1684,7 +1684,13 @@ find_minsym_type_and_address (minimal_symbol *msymbol,
{
/* Skip translation if caller does not need the address. */
if (address_p != NULL)
- *address_p = target_translate_tls_address (objfile, addr);
+ {
+ if (!target_has_registers ())
+ error (_(
+ "Cannot determine address of TLS symbol `%s' without registers"),
+ bound_msym.minsym->print_name ());
+ *address_p = target_translate_tls_address (objfile, addr);
+ }
return builtin_type (objfile)->nodebug_tls_symbol;
}
--
2.46.2
next prev parent reply other threads:[~2024-11-06 19:26 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 ` Kevin Buettner [this message]
2024-12-19 21:36 ` [PATCH v4 01/11] Don't attempt to find TLS address when target has no registers 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 ` [PATCH v4 11/11] Add TLS NEWS entry and document 'set force-internal-tls-address-lookup' command Kevin Buettner
2024-11-07 5:38 ` 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-2-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