Thead-local storage support

Hi,

Does the current version of lldb support thread local storage (TLS) variables via the __thread syntax in OS X? When I print such variables lldb prints a void pointer (to the TLS sections I believe), but it doesn't print the value of the variable like in gdb.

Here is the code I'm using, lldb version and compiler version.

***** Test code *****

$ cat tls.c
#include <stdio.h>
#include <unistd.h>

__thread int tls;

int main()
{
   tls = 123;
   printf("Sleeping...\n");
   sleep(1000);
   return 0;
}

***** LLDB output *****

$ lldb ./tls
(lldb) target create "./tls"
Current executable set to './tls' (x86_64).
(lldb) version
lldb-330.99.0
(lldb) run
Process 41212 launched: './tls' (x86_64)
Sleeping...
Process 41212 stopped
............
(lldb) print tls
(void *) $0 = 0x00007fff8b51e421

***** Compiler *****

$ gcc -g -O0 -o tls tls.c
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix

When I use gcc 4.8 from Mac ports, I get an error from lldb:

$ gcc-mp-4.8 -g -O0 -o tls tls.c
$ lldb ./tls
..................
(lldb) print tls
error: use of undeclared identifier 'tls'
error: 1 errors parsing expression

I'm using OS X Yosemite 10.10.1.

Thank you!

In article <54A8D4C9.8010802@llnl.gov>,

Yeah, we need to implement DynamicLoaderMacOSXDYLD::GetThreadLocalData() for this to work - that's what the radar # listed in that expected-fail is tracking. It also looks like there's a bug in the current dsymutil where tls variables are not copied into the .dSYM bundle, I filed a quick bug report on that. You can do .o file debugging (where the debugger reads the dwarf out of the individual .o files) to work around that - but without a Darwin implementation of GetThreadLocalData(), it's not going to get much further.

J