public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "avi@cloudius-systems.com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug threads/27886] New: static thread_local on aarch64 are broken in gdb
Date: Tue, 18 May 2021 14:36:08 +0000	[thread overview]
Message-ID: <bug-27886-4717@http.sourceware.org/bugzilla/> (raw)

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.

             reply	other threads:[~2021-05-18 14:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-18 14:36 avi@cloudius-systems.com [this message]
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

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=bug-27886-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).