public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug threads/27886] New: static thread_local on aarch64 are broken in gdb
@ 2021-05-18 14:36 avi@cloudius-systems.com
  2021-09-19  2:41 ` [Bug threads/27886] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: avi@cloudius-systems.com @ 2021-05-18 14:36 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27886

            Bug ID: 27886
           Summary: static thread_local on aarch64 are broken in gdb
           Product: gdb
           Version: 10.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: threads
          Assignee: unassigned at sourceware dot org
          Reporter: avi@cloudius-systems.com
  Target Milestone: ---

Consider this small C++ program:

=== begin ===


struct kk {
  kk() = default;
  int x = 1, y = 2, z = 3;
  ~kk() {}
};

namespace a {

  static thread_local kk v1;
  thread_local kk v2;

  void f(int x) {
    v1.x = v2.y = x;
  }

  int g() {
    return v1.x + v2.y;
  }


}


int main() {
  return 0;
}


=== end ===

Compiling and linking it with -pthread -O3 -g, gcc and clang, I can examine
both a::v1 and a::v2 on x86_64 with these commands:

(gdb) start
(gdb) p a::v1
(gdb) p a::v2

However, on aarch64, I get

(gdb) p a::v1
$1 = <optimized out>
(gdb) p a::v2
$2 = {x = 1, y = 2, z = 3}


a::v1 is not optimized out, and the problem remains when I add a function that
returns a reference to a::v1 (thus forcing the compiler to retain the structure
in memory).

In a more complicated project, I get a different error for static thread-locals
- the type is lost though the address is still visible to gdb.


Since both g++ and clang++ yield the same result, I assume the problem is with
gdb.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug threads/27886] static thread_local on aarch64 are broken in gdb
  2021-05-18 14:36 [Bug threads/27886] New: static thread_local on aarch64 are broken in gdb avi@cloudius-systems.com
@ 2021-09-19  2:41 ` pinskia at gcc dot gnu.org
  2024-02-29  5:38 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-19  2:41 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27886

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=97344,
                   |                            |https://sourceware.org/bugz
                   |                            |illa/show_bug.cgi?id=28351
                 CC|                            |pinskia at gcc dot gnu.org

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I suspect this due to GCC bug 97344 (which in turn needs binutils support PR
28351).

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug threads/27886] static thread_local on aarch64 are broken in gdb
  2021-05-18 14:36 [Bug threads/27886] New: static thread_local on aarch64 are broken in gdb avi@cloudius-systems.com
  2021-09-19  2:41 ` [Bug threads/27886] " pinskia at gcc dot gnu.org
@ 2024-02-29  5:38 ` pinskia at gcc dot gnu.org
  2024-02-29 18:03 ` tromey at sourceware dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-29  5:38 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27886

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-02-29
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug threads/27886] static thread_local on aarch64 are broken in gdb
  2021-05-18 14:36 [Bug threads/27886] New: static thread_local on aarch64 are broken in gdb avi@cloudius-systems.com
  2021-09-19  2:41 ` [Bug threads/27886] " pinskia at gcc dot gnu.org
  2024-02-29  5:38 ` pinskia at gcc dot gnu.org
@ 2024-02-29 18:03 ` tromey at sourceware dot org
  2024-02-29 19:07 ` pinskia at gcc dot gnu.org
  2024-02-29 19:14 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: tromey at sourceware dot org @ 2024-02-29 18:03 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27886

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org

--- Comment #3 from Tom Tromey <tromey at sourceware dot org> ---
It would be interesting to see the DWARF DIE for 'v1'.
Normally these end up with DW_OP_form_tls_address -- which
on Linux ends up just calling into libthread_db.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug threads/27886] static thread_local on aarch64 are broken in gdb
  2021-05-18 14:36 [Bug threads/27886] New: static thread_local on aarch64 are broken in gdb avi@cloudius-systems.com
                   ` (2 preceding siblings ...)
  2024-02-29 18:03 ` tromey at sourceware dot org
@ 2024-02-29 19:07 ` pinskia at gcc dot gnu.org
  2024-02-29 19:14 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-29 19:07 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27886

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Tom Tromey from comment #3)
> It would be interesting to see the DWARF DIE for 'v1'.
> Normally these end up with DW_OP_form_tls_address -- which
> on Linux ends up just calling into libthread_db.

Right and DW_OP_form_tls_address requires dtprel relocation support which is
not currently there for aarch64, see bug 28351 for the binutils support and
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97344 for the GCC side support.

it looks like clang/LLVM will need similar support added too.

The ABI does define a dtprel relocation even.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug threads/27886] static thread_local on aarch64 are broken in gdb
  2021-05-18 14:36 [Bug threads/27886] New: static thread_local on aarch64 are broken in gdb avi@cloudius-systems.com
                   ` (3 preceding siblings ...)
  2024-02-29 19:07 ` pinskia at gcc dot gnu.org
@ 2024-02-29 19:14 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-29 19:14 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27886

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://github.com/llvm/llv
                   |                            |m-project/issues/83466

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-02-29 19:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-18 14:36 [Bug threads/27886] New: static thread_local on aarch64 are broken in gdb avi@cloudius-systems.com
2021-09-19  2:41 ` [Bug threads/27886] " pinskia at gcc dot gnu.org
2024-02-29  5:38 ` pinskia at gcc dot gnu.org
2024-02-29 18:03 ` tromey at sourceware dot org
2024-02-29 19:07 ` pinskia at gcc dot gnu.org
2024-02-29 19:14 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).