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

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).