public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/26917] New: Printing a thread_local throws an error
@ 2020-11-18 20:18 jengelh at inai dot de
  2020-11-18 21:02 ` [Bug gdb/26917] " vries at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: jengelh at inai dot de @ 2020-11-18 20:18 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 26917
           Summary: Printing a thread_local throws an error
           Product: gdb
           Version: HEAD
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: jengelh at inai dot de
                CC: vries at gcc dot gnu.org
  Target Milestone: ---

Given this program:

#include <thread>
#include <cstdio>
struct C { int x = 42; };
thread_local C c;
int main()
{
        printf("%d\n", c.x);
}


Given this gdb:

» git log -1
commit 632de67bdb7b77e7ef9916b2698a7eada2420dc1
Author: GDB Administrator <gdbadmin@sourceware.org>
Date:   Wed Nov 18 00:00:14 2020 +0000

    Automatic date update in version.in

In other words, I have bug #25807 's commit
de82891ce5b6d2c8109f512cd0732325f4cd0557 present.


The output/gdb session is (still) as follows:

» ./gdb a.out
Python Exception <type 'exceptions.ImportError'> No module named gdb: 
./gdb: warning: 
Could not load the Python gdb module from `/usr/local/share/gdb/python'.
Limited Python support is available from the _gdb module.
Suggest passing --data-directory=/path/to/gdb/data-directory.
GNU gdb (GDB) 11.0.50.20201118-git
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.out...
(gdb) b main
Breakpoint 1 at 0x40111a: file /dev/shm/y.cpp, line 7.
(gdb) r
Starting program: /home/jengelh/repos/binutils-gdb/gdb/a.out 

Breakpoint 1, Python Exception <type 'exceptions.NameError'> Installation
error: gdb._execute_unwinders function is missing: 
main () at /dev/shm/y.cpp:7
7               printf("%d\n", c.x);
(gdb) p c
Cannot find thread-local storage for process 11067, executable file
/home/jengelh/repos/binutils-gdb/gdb/a.out:
Cannot find thread-local variables on this target
(gdb)


What I expected to see instead:

(gdb) p c.x
$1 = 42

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

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

* [Bug gdb/26917] Printing a thread_local throws an error
  2020-11-18 20:18 [Bug gdb/26917] New: Printing a thread_local throws an error jengelh at inai dot de
@ 2020-11-18 21:02 ` vries at gcc dot gnu.org
  2020-11-18 21:06 ` vries at gcc dot gnu.org
  2020-11-18 22:14 ` jengelh at inai dot de
  2 siblings, 0 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2020-11-18 21:02 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
If I compile like this:
...
$ g++ -g test.cc 
...
I can reproduce:
...
$ gdb -batch a.out -ex start -ex "p c.x"
Temporary breakpoint 1 at 0x40056b: file test.cc, line 7.

Temporary breakpoint 1, main () at test.cc:7
7               printf("%d\n", c.x);
Cannot find thread-local storage for process 484, executable file a.out:
Cannot find thread-local variables on this target
...

But if I compile like this instead:
...
$ g++ -g test.cc -pthread
...
I get:
...
$ gdb -batch a.out -ex start -ex "p c.x"
Temporary breakpoint 1 at 0x40057b: file test.cc, line 7.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Temporary breakpoint 1, main () at test.cc:7
7               printf("%d\n", c.x);
$1 = 42
...

Gdb's tls support is enabled by a dependency on libpthread.so.0, which in the
first case, isn't there.

There are gdb test-cases (f.i. gdb.threads/tls-shared.c) which add an
unnecessary call to a libpthread function:
...
   /* Ensure we link against pthreads even with --as-needed.  */
  pthread_testcancel();
...
to make sure that the exec has a dependency on libpthread, such that tls works,
so I'm assuming this behavior is known.

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

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

* [Bug gdb/26917] Printing a thread_local throws an error
  2020-11-18 20:18 [Bug gdb/26917] New: Printing a thread_local throws an error jengelh at inai dot de
  2020-11-18 21:02 ` [Bug gdb/26917] " vries at gcc dot gnu.org
@ 2020-11-18 21:06 ` vries at gcc dot gnu.org
  2020-11-18 22:14 ` jengelh at inai dot de
  2 siblings, 0 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2020-11-18 21:06 UTC (permalink / raw)
  To: gdb-prs

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

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #1)
> There are gdb test-cases (f.i. gdb.threads/tls-shared.c) which add an
> unnecessary call to a libpthread function:
> ...
>    /* Ensure we link against pthreads even with --as-needed.  */
>   pthread_testcancel();
> ...
> to make sure that the exec has a dependency on libpthread, such that tls
> works, so I'm assuming this behavior is known.

Indeed, marking duplicate of PR24548 - "gdb: TLS variables inaccessible when
not linking with libpthread".

*** This bug has been marked as a duplicate of bug 24548 ***

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

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

* [Bug gdb/26917] Printing a thread_local throws an error
  2020-11-18 20:18 [Bug gdb/26917] New: Printing a thread_local throws an error jengelh at inai dot de
  2020-11-18 21:02 ` [Bug gdb/26917] " vries at gcc dot gnu.org
  2020-11-18 21:06 ` vries at gcc dot gnu.org
@ 2020-11-18 22:14 ` jengelh at inai dot de
  2 siblings, 0 replies; 4+ messages in thread
From: jengelh at inai dot de @ 2020-11-18 22:14 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #3 from Jan Engelhardt <jengelh at inai dot de> ---
So, could we improve the error message and remind the developer that perhaps
-lpthread may be absent?

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

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

end of thread, other threads:[~2020-11-18 22:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-18 20:18 [Bug gdb/26917] New: Printing a thread_local throws an error jengelh at inai dot de
2020-11-18 21:02 ` [Bug gdb/26917] " vries at gcc dot gnu.org
2020-11-18 21:06 ` vries at gcc dot gnu.org
2020-11-18 22:14 ` jengelh at inai dot de

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