Issue 55658
Summary [lldb] No TLS data currently exists for this thread
Labels new issue
Assignees
Reporter dodoga93
    I have a small `C` program that uses `pthread` and `thread local storage`.
```c
static __thread long z = 0xdeadbeef;
static __thread long x = 0xdeadbeef;

// create the function to be executed as a thread
void *thread(void *ptr)
{
    …
}

int main(int argc, char **argv)
{
    …
    pthread_create(&thread1, NULL, *thread, (void *) thr);
    pthread_create(&thread2, NULL, *thread, (void *) thr2);
    …
}
```
- I compile with the following options `-g -O0 -pthread`
- when I try to debug it with `lldb` and print the variables I get the following error:
```sh
[amin@lzvmr5 c_example]$ lldb main
(lldb) target create "main"
Current executable set to '/home/amin/bugs/.../c_example/main' (x86_64).
(lldb) b thread
Breakpoint 1: where = main`thread + 12 at main.c:11:22, address = 0x000000000040074c
(lldb) run
Process 3366142 launched: '/home/amin/bugs/.../c_example/main' (x86_64)
Process 3366142 stopped
* thread #2, name = 'main', stop reason = breakpoint 1.1
    frame #0: 0x000000000040074c main`thread(ptr=0x0000000000000001) at main.c:11:22
   8    // create the function to be executed as a thread
   9    void *thread(void *ptr)
   10   {
-> 11       int type = (int) ptr;
   12       printf("%p\n", &z);
   13       printf("%p\n", &x);
   14       fprintf(stderr,"Thread - %d\n",type);
(lldb) p z
error: Couldn't materialize: couldn't get the value of variable z: No TLS data currently exists for this thread.
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
(lldb) p x
error: Couldn't materialize: couldn't get the value of variable x: No TLS data currently exists for this thread.
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
```
I can print the variables if I use `gdb`.
Attached you can find the complete reproducer.

[c_example.zip](https://github.com/llvm/llvm-project/files/8755345/c_example.zip)



_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to