llvm-project/lldb/source/Target
Greg Clayton 63a27afae3 Added support for thread local variables on all Apple OS variants.
We had support that assumed that thread local data for a variable could be determined solely from the module in which the variable exists. While this work for linux, it doesn't work for Apple OSs. The DWARF for thread local variables consists of location opcodes that do something like:

DW_OP_const8u (x)
DW_OP_form_tls_address

or 

DW_OP_const8u (x)
DW_OP_GNU_push_tls_address

The "x" is allowed to be anything that is needed to determine the location of the variable. For Linux "x" is the offset within the TLS data for a given executable (ModuleSP in LLDB). For Apple OS variants, it is the file address of the data structure that contains a pthread key that can be used with pthread_getspecific() and the offset needed. 

This fix passes the "x" along to the thread:

virtual lldb::addr_t
lldb_private::Thread::GetThreadLocalData(const lldb::ModuleSP module, lldb::addr_t tls_file_addr);

Then this is passed along to the DynamicLoader::GetThreadLocalData():

virtual lldb::addr_t
lldb_private::DynamicLoader::GetThreadLocalData(const lldb::ModuleSP module, const lldb::ThreadSP thread, lldb::addr_t tls_file_addr);

This allows each DynamicLoader plug-in do the right thing for the current OS.

The DynamicLoaderMacOSXDYLD was modified to be able to grab the pthread key from the data structure that is in memory and call "void *pthread_getspecific(pthread_key_t key)" to get the value of the thread local storage and it caches it per thread since it never changes.

I had to update the test case to access the thread local data before trying to print it as on Apple OS variants, thread locals are not available unless they have been accessed at least one by the current thread.

I also added a new lldb::ValueType named "eValueTypeVariableThreadLocal" so that we can ask SBValue objects for their ValueType and be able to tell when we have a thread local variable.

<rdar://problem/23308080>

llvm-svn: 274366
2016-07-01 17:17:23 +00:00
..
ABI.cpp Add new ABI callback to provide fallback unwind register locations 2016-04-14 14:25:20 +00:00
CMakeLists.txt [cmake] Remove LLVM_NO_RTTI. 2015-09-03 08:46:55 +00:00
CPPLanguageRuntime.cpp Move more functionality from the LanguageRuntimes to the Languages. 2015-09-02 01:59:14 +00:00
ExecutionContext.cpp second pass over removal of Mutex and Condition 2016-05-19 05:13:57 +00:00
FileAction.cpp Refactor many file functions to use FileSpec over strings. 2015-05-29 19:52:29 +00:00
InstrumentationRuntime.cpp Provide more information in ThreadSanitizer's JSON data. Move remaining TSan logic from SBThread to InstrumentationRuntime plugin. 2016-04-10 18:57:38 +00:00
InstrumentationRuntimeStopInfo.cpp LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction 2014-10-10 23:43:03 +00:00
JITLoader.cpp Fix Clang-tidy modernize-use-nullptr warnings; other minor fixes. 2016-02-18 00:10:17 +00:00
JITLoaderList.cpp remove use of Mutex in favour of std::{,recursive_}mutex 2016-05-18 01:59:10 +00:00
Language.cpp second pass over removal of Mutex and Condition 2016-05-19 05:13:57 +00:00
LanguageRuntime.cpp Fix Clang-tidy modernize-use-nullptr warnings; other minor fixes. 2016-02-18 00:10:17 +00:00
Memory.cpp second pass over removal of Mutex and Condition 2016-05-19 05:13:57 +00:00
MemoryHistory.cpp Fix Clang-tidy modernize-use-nullptr warnings; other minor fixes. 2016-02-18 00:10:17 +00:00
ObjCLanguageRuntime.cpp Now that SymbolFileDWARF supports having types in completely separate .pcm file with "-fmodules -gmodules", each SymbolFileDWARF can reference module DWARF info by looking in other DWARF files. Then if you have 1000 .o files that each reference one or more .pcm files in their debug info, a simple Module::FindTypes(...) call can end up searching the same .pcm file over and over and over. Now all internal FindTypes methods in classes (ModuleList, Module, SymbolFile) now take an extra argument: 2016-02-10 21:28:13 +00:00
OperatingSystem.cpp Fix Clang-tidy modernize-use-nullptr warnings; other minor fixes. 2016-02-18 00:10:17 +00:00
PathMappingList.cpp Add reverse file remapping for breakpoint set 2016-03-04 11:26:44 +00:00
Platform.cpp Fix typo in eOpenOptionDontFollowSymlinks 2016-06-21 00:03:57 +00:00
Process.cpp Process::StopForDetachOrDestroy should actually return an error if it can't stop the 2016-06-28 16:35:58 +00:00
ProcessInfo.cpp Implement ProcessInfo::Dump(), log gdb-remote stub launch 2016-05-31 18:32:20 +00:00
ProcessLaunchInfo.cpp Generalize child process monitoring functions 2016-05-11 16:59:04 +00:00
Queue.cpp Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Target; other minor fixes. 2016-02-18 18:52:47 +00:00
QueueItem.cpp Correctly add the QueueID to a pending block's extended thread backtrace thread. 2014-03-10 08:42:03 +00:00
QueueList.cpp second pass over removal of Mutex and Condition 2016-05-19 05:13:57 +00:00
RegisterContext.cpp Fix Clang-tidy modernize-use-nullptr warnings; other minor fixes. 2016-02-18 00:10:17 +00:00
SectionLoadHistory.cpp remove use of Mutex in favour of std::{,recursive_}mutex 2016-05-18 01:59:10 +00:00
SectionLoadList.cpp remove use of Mutex in favour of std::{,recursive_}mutex 2016-05-18 01:59:10 +00:00
StackFrame.cpp second pass over removal of Mutex and Condition 2016-05-19 05:13:57 +00:00
StackFrameList.cpp second pass over removal of Mutex and Condition 2016-05-19 05:13:57 +00:00
StackID.cpp Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Target; other minor fixes. 2016-02-18 18:52:47 +00:00
StopInfo.cpp This change introduces a "ExpressionExecutionThread" to the ThreadList. 2016-03-12 02:45:34 +00:00
SystemRuntime.cpp Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Target; other minor fixes. 2016-02-18 18:52:47 +00:00
Target.cpp fixits are apparently called fix-its. 2016-06-28 01:33:03 +00:00
TargetList.cpp remove use of Mutex in favour of std::{,recursive_}mutex 2016-05-18 01:59:10 +00:00
Thread.cpp Added support for thread local variables on all Apple OS variants. 2016-07-01 17:17:23 +00:00
ThreadCollection.cpp Add missing #include for linux. 2016-06-10 23:53:06 +00:00
ThreadList.cpp second pass over removal of Mutex and Condition 2016-05-19 05:13:57 +00:00
ThreadPlan.cpp remove use of Mutex in favour of std::{,recursive_}mutex 2016-05-18 01:59:10 +00:00
ThreadPlanBase.cpp Improve logging a bit by printing the exception or signal type description. 2014-02-27 19:35:12 +00:00
ThreadPlanCallFunction.cpp Fix Clang-tidy modernize-use-nullptr and readability-simplify-boolean-expr warnings in some files in source/Target/. 2015-12-15 01:33:19 +00:00
ThreadPlanCallFunctionUsingABI.cpp Fix Clang-tidy modernize-use-nullptr and readability-simplify-boolean-expr warnings in some files in source/Target/. 2015-12-15 01:33:19 +00:00
ThreadPlanCallUserExpression.cpp Add a DiagnosticManager replace error streams in the expression parser. 2016-03-19 00:03:59 +00:00
ThreadPlanPython.cpp Don't #include "lldb-python.h" from anywhere. 2015-05-29 17:41:47 +00:00
ThreadPlanRunToAddress.cpp Fix Clang-tidy modernize-use-nullptr and readability-simplify-boolean-expr warnings in some files in source/Target/. 2015-12-15 01:33:19 +00:00
ThreadPlanShouldStopHere.cpp Remove a should have been deleted extra assignment to a variable. 2016-05-19 22:22:57 +00:00
ThreadPlanStepInRange.cpp Fix Clang-tidy modernize-use-nullptr and readability-simplify-boolean-expr warnings in some files in source/Target/. 2015-12-15 01:33:19 +00:00
ThreadPlanStepInstruction.cpp The SetStopInfo from a Mach Exception was setting the stop 2016-02-03 19:45:31 +00:00
ThreadPlanStepOut.cpp Re-apply r257117 (reverted in r257138 temporarily), 2016-01-08 21:40:11 +00:00
ThreadPlanStepOverBreakpoint.cpp Move lldb-log.cpp to core/Logging.cpp 2015-03-18 18:20:42 +00:00
ThreadPlanStepOverRange.cpp Keep original source path and mapped path in LineEntry 2016-05-11 22:46:53 +00:00
ThreadPlanStepRange.cpp Now that there are no cycles that cause leaks in the disassembler/instruction classes, we can get rid of the FIXME lines that were working around this issue. 2016-06-07 23:19:00 +00:00
ThreadPlanStepThrough.cpp Fix Clang-tidy modernize-use-nullptr and readability-simplify-boolean-expr warnings in some files in source/Target/. 2015-12-15 01:33:19 +00:00
ThreadPlanStepUntil.cpp Fix Clang-tidy modernize-use-nullptr and readability-simplify-boolean-expr warnings in some files in source/Target/. 2015-12-15 01:33:19 +00:00
ThreadPlanTracer.cpp Fix Clang-tidy modernize-use-nullptr and readability-simplify-boolean-expr warnings in some files in source/Target/. 2015-12-15 01:33:19 +00:00
ThreadSpec.cpp Fix Clang-tidy modernize-use-nullptr and readability-simplify-boolean-expr warnings in some files in source/Target/. 2015-12-15 01:33:19 +00:00
UnixSignals.cpp Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Target; other minor fixes. 2016-02-18 18:52:47 +00:00
UnwindAssembly.cpp Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Target; other minor fixes. 2016-02-18 18:52:47 +00:00