Search code examples
cdebugginglldb

lldb cannot print TLS variable


I've decided to use TLS variables on my C project to define some variables that should be valid throughout thread scope.

Here's my declaration : static __thread char log_username[100];

however, for some reason the lldb debugger fail to show them for the following reason :

(lldb) print log_username[2]
error: Couldn't materialize: couldn't get the value of variable log_username: 
No TLS data currently exists for this thread.
Errored out in Execute, couldn't PrepareToExecuteJITExpression

The debugger states that TLS data is currently not available, but if I use simple printf, it works.

Any idea how to resolve this, or just treat it as debugger limitation that I can live with ...


Solution

  • lldb doesn't currently support thread local storage variables on OS X (not sure about Linux.) You can work around this by making accessor functions for your TLS variables, and calling those after selecting the appropriate thread.