How to get pthread pointer from lldb?

After a big digging, I found DynamicLoaderPOSIXDYLD::GetThreadLocalData() seems to never work on Linux. lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py fails on Linux. thread_local or __thread variables can’t be examined on Linux. (It is interesting that GDB11 also fails).

This thread (Access to TLS variables on GNU/Linux - #2 by Jan_Kratochvil) seems to imply the the TLS support is only available in FreeBSD (but I can’t find FreeBSDThread::GetThreadPointer() or any concrete platform implementation of it).

It seems $fs_base virtual register is available both from linux Posix and coredump but lldb ignores it for whatever reason. I did a quick prototype by adding fs_base into GPR register list and it seems to work (both from live and coredump debugging). I assume that’s how GDB reports the pthread * pointer in info threads list.