[lldb-dev] Thead-local storage support

Ignacio Laguna lagunaperalt1 at llnl.gov
Sat Jan 3 21:51:05 PST 2015


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!

-- 
Ignacio




More information about the lldb-dev mailing list