llvm-project/lldb/source/API
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
..
CMakeLists.txt Add MemoryRegionInfo to SB API 2016-06-23 08:35:37 +00:00
SBAddress.cpp second pass over removal of Mutex and Condition 2016-05-19 05:13:57 +00:00
SBAttachInfo.cpp SBTarget::Attach(SBAttachInfo &) was changed to not be asynchronous back in February and this affected Xcode's abililty to cancel an attach to process by name. 2015-10-05 22:58:37 +00:00
SBBlock.cpp Added support for thread local variables on all Apple OS variants. 2016-07-01 17:17:23 +00:00
SBBreakpoint.cpp second pass over removal of Mutex and Condition 2016-05-19 05:13:57 +00:00
SBBreakpointLocation.cpp second pass over removal of Mutex and Condition 2016-05-19 05:13:57 +00:00
SBBroadcaster.cpp Change over the broadcaster/listener process to hold shared or weak pointers 2016-03-07 21:50:25 +00:00
SBCommandInterpreter.cpp second pass over removal of Mutex and Condition 2016-05-19 05:13:57 +00:00
SBCommandReturnObject.cpp Fix FILE * leak in Python API 2016-03-25 23:40:32 +00:00
SBCommunication.cpp Create a ConnectionGenericFile class for Windows. 2014-10-06 21:23:09 +00:00
SBCompileUnit.cpp Add APIs on SBFunction and SBCompileUnit to inquire about the language type that the function/compile unit is defined in 2014-11-17 23:06:20 +00:00
SBData.cpp Included <inttypes.h> in a few headers that were 2014-04-19 03:09:28 +00:00
SBDebugger.cpp second pass over removal of Mutex and Condition 2016-05-19 05:13:57 +00:00
SBDeclaration.cpp sweep up -Wformat warnings from gcc 2014-04-04 04:06:10 +00:00
SBError.cpp sweep up -Wformat warnings from gcc 2014-04-04 04:06:10 +00:00
SBEvent.cpp Don't #include "lldb-python.h" from anywhere. 2015-05-29 17:41:47 +00:00
SBExecutionContext.cpp This adds a "batch mode" to lldb kinda like the gdb batch mode. It will quit the debugger 2014-10-14 01:20:07 +00:00
SBExpressionOptions.cpp Expose top-level Clang expressions via the command line and the API. 2016-03-28 21:20:05 +00:00
SBFileSpec.cpp This patch stops lldb from loading a .lldbinit file from the current 2016-02-19 00:05:17 +00:00
SBFileSpecList.cpp sweep up -Wformat warnings from gcc 2014-04-04 04:06:10 +00:00
SBFrame.cpp Added support for thread local variables on all Apple OS variants. 2016-07-01 17:17:23 +00:00
SBFunction.cpp second pass over removal of Mutex and Condition 2016-05-19 05:13:57 +00:00
SBHostOS.cpp Attempt to fix darwin build after header refactor in llvm (r266595) 2016-04-18 12:18:35 +00:00
SBInstruction.cpp Fix a memory leak in InstructionLLVMC where it held onto a strong reference to the DisassemblerLLVMC which in turn had a vector of InstructionSP causing the strong cycle. This is fixed now. 2016-06-07 22:56:40 +00:00
SBInstructionList.cpp Fix a memory leak in InstructionLLVMC where it held onto a strong reference to the DisassemblerLLVMC which in turn had a vector of InstructionSP causing the strong cycle. This is fixed now. 2016-06-07 22:56:40 +00:00
SBLanguageRuntime.cpp Move things from the LanguageRuntime that obviously belong in the new Language plugin instead. 2015-09-02 01:06:46 +00:00
SBLaunchInfo.cpp Refactor many file functions to use FileSpec over strings. 2015-05-29 19:52:29 +00:00
SBLineEntry.cpp sweep up -Wformat warnings from gcc 2014-04-04 04:06:10 +00:00
SBListener.cpp Change over the broadcaster/listener process to hold shared or weak pointers 2016-03-07 21:50:25 +00:00
SBMemoryRegionInfo.cpp Add MemoryRegionInfo to SB API 2016-06-23 08:35:37 +00:00
SBMemoryRegionInfoList.cpp Add MemoryRegionInfo to SB API 2016-06-23 08:35:37 +00:00
SBModule.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
SBModuleSpec.cpp
SBPlatform.cpp Fix warnings detected by -Wpessimizing-move 2015-07-28 09:18:32 +00:00
SBProcess.cpp Add MemoryRegionInfo to SB API 2016-06-23 08:35:37 +00:00
SBQueue.cpp Don't #include "lldb-python.h" from anywhere. 2015-05-29 17:41:47 +00:00
SBQueueItem.cpp Don't #include "lldb-python.h" from anywhere. 2015-05-29 17:41:47 +00:00
SBSection.cpp Added functions to the C++ API, for the benefit of non-8-bit byte architectures. 2014-10-22 07:22:56 +00:00
SBSourceManager.cpp Don't #include "lldb-python.h" from anywhere. 2015-05-29 17:41:47 +00:00
SBStream.cpp First pass at LLDBRPC.framework 2015-12-15 23:03:22 +00:00
SBStringList.cpp Add the ability to limit "source regexp" breakpoints to a particular function 2016-04-28 01:40:57 +00:00
SBSymbol.cpp second pass over removal of Mutex and Condition 2016-05-19 05:13:57 +00:00
SBSymbolContext.cpp sweep up -Wformat warnings from gcc 2014-04-04 04:06:10 +00:00
SBSymbolContextList.cpp
SBTarget.cpp second pass over removal of Mutex and Condition 2016-05-19 05:13:57 +00:00
SBThread.cpp SBThread also had some places where it got the ExecutionContext w/o 2016-06-10 17:22:26 +00:00
SBThreadCollection.cpp Expose ThreadCollection in SB API 2014-09-06 01:21:19 +00:00
SBThreadPlan.cpp Don't #include "lldb-python.h" from anywhere. 2015-05-29 17:41:47 +00:00
SBType.cpp Fixed TypeMemberFunctionImpl to not use clang types directly but use the new CompilerDecl class to do the job in an abstract way. 2015-11-10 17:47:04 +00:00
SBTypeCategory.cpp Reapply r253423 and r253424 (which cleanup the data formatters iteration model, as well as the type X list commands), along with a change by Zachary Turner to bypass a MSVC bug with SFINAE 2015-11-18 19:42:44 +00:00
SBTypeEnumMember.cpp Reduce inclusion of clang headers. 2015-09-18 17:02:48 +00:00
SBTypeFilter.cpp Don't #include "lldb-python.h" from anywhere. 2015-05-29 17:41:47 +00:00
SBTypeFormat.cpp Don't #include "lldb-python.h" from anywhere. 2015-05-29 17:41:47 +00:00
SBTypeNameSpecifier.cpp ClangASTType is now CompilerType. 2015-08-11 22:53:00 +00:00
SBTypeSummary.cpp Add an 'internal' kind of summary to support one-off subclasses of TypeSummaryImpl 2015-10-29 18:58:13 +00:00
SBTypeSynthetic.cpp Don't #include "lldb-python.h" from anywhere. 2015-05-29 17:41:47 +00:00
SBUnixSignals.cpp Refactor Unix signals. 2015-07-14 01:09:28 +00:00
SBValue.cpp Added support for thread local variables on all Apple OS variants. 2016-07-01 17:17:23 +00:00
SBValueList.cpp Fix warnings found by -Wextra-semi 2015-07-22 08:12:01 +00:00
SBVariablesOptions.cpp Revert "Revert "I had recently added a new SBFrame::GetVariables() overload with yet another bool argument"" 2015-02-17 17:55:50 +00:00
SBWatchpoint.cpp second pass over removal of Mutex and Condition 2016-05-19 05:13:57 +00:00
SystemInitializerFull.cpp Remove platform plugins from lldb-server 2016-06-29 13:58:27 +00:00
liblldb.exports Fix OSX cmake build 2016-02-18 17:01:40 +00:00
liblldb.xcode.exports Only export public symbols with the cmake build. 2015-09-04 00:00:41 +00:00