diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:50:09 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:50:09 +0000 |
commit | f3fbd1c0586ff6ec7895991e6c28f61a503c36a8 (patch) | |
tree | 48d008fd3df8c0e73271a4b18474e0aac6dbfe33 /include/lldb/Target | |
parent | 2fc5d2d1dfaf623ce4e24cd8590565902f8c557c (diff) | |
download | src-f3fbd1c0586ff6ec7895991e6c28f61a503c36a8.tar.gz src-f3fbd1c0586ff6ec7895991e6c28f61a503c36a8.zip |
Vendor import of lldb release_39 branch r276489:vendor/lldb/lldb-release_39-r276489
Notes
Notes:
svn path=/vendor/lldb/dist/; revision=303241
svn path=/vendor/lldb/lldb-release_39-r276489/; revision=303242; tag=vendor/lldb/lldb-release_39-r276489
Diffstat (limited to 'include/lldb/Target')
27 files changed, 418 insertions, 198 deletions
diff --git a/include/lldb/Target/ABI.h b/include/lldb/Target/ABI.h index 94826d173500..cd0b57e61ff8 100644 --- a/include/lldb/Target/ABI.h +++ b/include/lldb/Target/ABI.h @@ -16,6 +16,7 @@ // Project includes #include "lldb/Core/Error.h" #include "lldb/Core/PluginInterface.h" +#include "lldb/Symbol/UnwindPlan.h" #include "lldb/lldb-private.h" #include "llvm/ADT/ArrayRef.h" @@ -110,6 +111,10 @@ public: virtual bool RegisterIsVolatile (const RegisterInfo *reg_info) = 0; + virtual bool + GetFallbackRegisterLocation (const RegisterInfo *reg_info, + UnwindPlan::Row::RegisterLocation &unwind_regloc); + // Should take a look at a call frame address (CFA) which is just the stack // pointer value upon entry to a function. ABIs usually impose alignment // restrictions (4, 8 or 16 byte aligned), and zero is usually not allowed. diff --git a/include/lldb/Target/DynamicLoader.h b/include/lldb/Target/DynamicLoader.h index 5eada0342a21..2c4956829b29 100644 --- a/include/lldb/Target/DynamicLoader.h +++ b/include/lldb/Target/DynamicLoader.h @@ -71,7 +71,7 @@ public: /// The destructor is virtual since this class is designed to be /// inherited from by the plug-in instance. //------------------------------------------------------------------ - ~DynamicLoader() override; + virtual ~DynamicLoader() override; //------------------------------------------------------------------ /// Called after attaching a process. @@ -238,11 +238,19 @@ public: /// LLDB_INVALID_ADDRESS is returned. //------------------------------------------------------------------ virtual lldb::addr_t - GetThreadLocalData (const lldb::ModuleSP module, const lldb::ThreadSP thread) + GetThreadLocalData(const lldb::ModuleSP module, const lldb::ThreadSP thread, lldb::addr_t tls_file_addr) { return LLDB_INVALID_ADDRESS; } + /// Locates or creates a module given by @p file and updates/loads the + /// resulting module at the virtual base address @p base_addr. + virtual lldb::ModuleSP + LoadModuleAtAddress(const lldb_private::FileSpec &file, + lldb::addr_t link_map_addr, + lldb::addr_t base_addr, + bool base_addr_is_offset); + protected: //------------------------------------------------------------------ // Utility methods for derived classes @@ -282,14 +290,6 @@ protected: void UnloadSectionsCommon(const lldb::ModuleSP module); - /// Locates or creates a module given by @p file and updates/loads the - /// resulting module at the virtual base address @p base_addr. - virtual lldb::ModuleSP - LoadModuleAtAddress(const lldb_private::FileSpec &file, - lldb::addr_t link_map_addr, - lldb::addr_t base_addr, - bool base_addr_is_offset); - const lldb_private::SectionList * GetSectionListFromModule(const lldb::ModuleSP module) const; diff --git a/include/lldb/Target/ExecutionContext.h b/include/lldb/Target/ExecutionContext.h index cdf55e3b744c..da585e4c9dad 100644 --- a/include/lldb/Target/ExecutionContext.h +++ b/include/lldb/Target/ExecutionContext.h @@ -12,11 +12,12 @@ // C Includes // C++ Includes +#include <mutex> + // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" #include "lldb/Target/StackID.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -412,8 +413,8 @@ public: // These two variants take in a locker, and grab the target, lock the API mutex into locker, then // fill in the rest of the shared pointers. - ExecutionContext (const ExecutionContextRef &exe_ctx_ref, Mutex::Locker &locker); - ExecutionContext (const ExecutionContextRef *exe_ctx_ref, Mutex::Locker &locker); + ExecutionContext(const ExecutionContextRef &exe_ctx_ref, std::unique_lock<std::recursive_mutex> &locker); + ExecutionContext(const ExecutionContextRef *exe_ctx_ref, std::unique_lock<std::recursive_mutex> &locker); //------------------------------------------------------------------ // Create execution contexts from execution context scopes //------------------------------------------------------------------ diff --git a/include/lldb/Target/InstrumentationRuntime.h b/include/lldb/Target/InstrumentationRuntime.h index 70aa62908406..a5dc853ab55b 100644 --- a/include/lldb/Target/InstrumentationRuntime.h +++ b/include/lldb/Target/InstrumentationRuntime.h @@ -20,6 +20,7 @@ #include "lldb/lldb-private.h" #include "lldb/lldb-types.h" #include "lldb/Core/PluginInterface.h" +#include "lldb/Core/StructuredData.h" namespace lldb_private { @@ -39,6 +40,9 @@ public: virtual bool IsActive(); + + virtual lldb::ThreadCollectionSP + GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info); }; diff --git a/include/lldb/Target/JITLoaderList.h b/include/lldb/Target/JITLoaderList.h index f933a61e9952..c86043c5cf1f 100644 --- a/include/lldb/Target/JITLoaderList.h +++ b/include/lldb/Target/JITLoaderList.h @@ -10,10 +10,10 @@ #ifndef liblldb_JITLoaderList_h_ #define liblldb_JITLoaderList_h_ +#include <mutex> #include <vector> #include "lldb/lldb-forward.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -52,7 +52,7 @@ public: private: std::vector<lldb::JITLoaderSP> m_jit_loaders_vec; - lldb_private::Mutex m_jit_loaders_mutex; + std::recursive_mutex m_jit_loaders_mutex; }; } // namespace lldb_private diff --git a/include/lldb/Target/Language.h b/include/lldb/Target/Language.h index 492425ec088b..d1a3ff8e6747 100644 --- a/include/lldb/Target/Language.h +++ b/include/lldb/Target/Language.h @@ -113,6 +113,9 @@ public: virtual std::unique_ptr<TypeScavenger> GetTypeScavenger (); + virtual const char* + GetLanguageSpecificTypeLookupHelp (); + // if an individual data formatter can apply to several types and cross a language boundary // it makes sense for individual languages to want to customize the printing of values of that // type by appending proper prefix/suffix information in language-specific ways diff --git a/include/lldb/Target/LanguageRuntime.h b/include/lldb/Target/LanguageRuntime.h index 686ec5ea3479..beb7a9e74876 100644 --- a/include/lldb/Target/LanguageRuntime.h +++ b/include/lldb/Target/LanguageRuntime.h @@ -22,6 +22,9 @@ #include "lldb/Core/ValueObject.h" #include "lldb/Core/Value.h" #include "lldb/Target/ExecutionContextScope.h" +#include "lldb/Expression/LLVMUserExpression.h" + +#include "clang/Basic/TargetOptions.h" namespace lldb_private { @@ -147,6 +150,22 @@ public: { } + // Called by the Clang expression evaluation engine to allow runtimes to alter the set of target options provided to + // the compiler. + // If the options prototype is modified, runtimes must return true, false otherwise. + virtual bool + GetOverrideExprOptions(clang::TargetOptions &prototype) + { + return false; + } + + // Called by ClangExpressionParser::PrepareForExecution to query for any custom LLVM IR passes + // that need to be run before an expression is assembled and run. + virtual bool + GetIRPasses(LLVMUserExpression::IRPasses &custom_passes) + { + return false; + } protected: //------------------------------------------------------------------ // Classes that inherit from LanguageRuntime can see and modify these diff --git a/include/lldb/Target/Memory.h b/include/lldb/Target/Memory.h index bf1cc1878784..f4d776a43c99 100644 --- a/include/lldb/Target/Memory.h +++ b/include/lldb/Target/Memory.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include <map> +#include <mutex> #include <vector> // Other libraries and framework includes @@ -20,7 +21,6 @@ // Project includes #include "lldb/lldb-private.h" #include "lldb/Core/RangeMap.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { //---------------------------------------------------------------------- @@ -75,7 +75,7 @@ namespace lldb_private { //------------------------------------------------------------------ // Classes that inherit from MemoryCache can see and modify these //------------------------------------------------------------------ - Mutex m_mutex; + std::recursive_mutex m_mutex; BlockMap m_L1_cache; // A first level memory cache whose chunk sizes vary that will be used only if the memory read fits entirely in a chunk BlockMap m_L2_cache; // A memory cache of fixed size chinks (m_L2_cache_line_byte_size bytes in size each) InvalidRanges m_invalid_ranges; @@ -192,7 +192,7 @@ namespace lldb_private { // Classes that inherit from MemoryCache can see and modify these //------------------------------------------------------------------ Process &m_process; - Mutex m_mutex; + std::recursive_mutex m_mutex; typedef std::multimap<uint32_t, AllocatedBlockSP> PermissionsToBlockMap; PermissionsToBlockMap m_memory_map; diff --git a/include/lldb/Target/MemoryRegionInfo.h b/include/lldb/Target/MemoryRegionInfo.h index 0726ad15e876..5c82a1f294dd 100644 --- a/include/lldb/Target/MemoryRegionInfo.h +++ b/include/lldb/Target/MemoryRegionInfo.h @@ -30,7 +30,8 @@ namespace lldb_private m_range (), m_read (eDontKnow), m_write (eDontKnow), - m_execute (eDontKnow) + m_execute (eDontKnow), + m_mapped (eDontKnow) { } @@ -75,6 +76,12 @@ namespace lldb_private return m_execute; } + OptionalBool + GetMapped () const + { + return m_mapped; + } + void SetReadable (OptionalBool val) { @@ -93,11 +100,63 @@ namespace lldb_private m_execute = val; } + void + SetMapped (OptionalBool val) + { + m_mapped = val; + } + + //---------------------------------------------------------------------- + // Get permissions as a uint32_t that is a mask of one or more bits from + // the lldb::Permissions + //---------------------------------------------------------------------- + uint32_t + GetLLDBPermissions() const + { + uint32_t permissions = 0; + if (m_read) + permissions |= lldb::ePermissionsReadable; + if (m_write) + permissions |= lldb::ePermissionsWritable; + if (m_execute) + permissions |= lldb::ePermissionsExecutable; + return permissions; + } + + //---------------------------------------------------------------------- + // Set permissions from a uint32_t that contains one or more bits from + // the lldb::Permissions + //---------------------------------------------------------------------- + void + SetLLDBPermissions(uint32_t permissions) + { + m_read = (permissions & lldb::ePermissionsReadable) ? eYes : eNo; + m_write = (permissions & lldb::ePermissionsWritable) ? eYes : eNo; + m_execute = (permissions & lldb::ePermissionsExecutable) ? eYes : eNo; + } + + bool + operator == (const MemoryRegionInfo &rhs) const + { + return m_range == rhs.m_range && + m_read == rhs.m_read && + m_write == rhs.m_write && + m_execute == rhs.m_execute && + m_mapped == rhs.m_mapped; + } + + bool + operator != (const MemoryRegionInfo &rhs) const + { + return !(*this == rhs); + } + protected: RangeType m_range; OptionalBool m_read; OptionalBool m_write; OptionalBool m_execute; + OptionalBool m_mapped; }; } diff --git a/include/lldb/Target/PathMappingList.h b/include/lldb/Target/PathMappingList.h index 17185cb68495..1a486c4642dc 100644 --- a/include/lldb/Target/PathMappingList.h +++ b/include/lldb/Target/PathMappingList.h @@ -116,7 +116,9 @@ public: bool RemapPath (const char *path, std::string &new_path) const; - + bool + ReverseRemapPath (const ConstString &path, ConstString &new_path) const; + //------------------------------------------------------------------ /// Finds a source file given a file spec using the path remappings. /// diff --git a/include/lldb/Target/Platform.h b/include/lldb/Target/Platform.h index 53c17a6a66cf..6fdd92db5680 100644 --- a/include/lldb/Target/Platform.h +++ b/include/lldb/Target/Platform.h @@ -15,6 +15,7 @@ #include <functional> #include <map> #include <memory> +#include <mutex> #include <string> #include <vector> @@ -28,7 +29,6 @@ #include "lldb/Core/UserSettingsController.h" #include "lldb/Interpreter/Options.h" #include "lldb/Host/FileSpec.h" -#include "lldb/Host/Mutex.h" // TODO pull NativeDelegate class out of NativeProcessProtocol so we // can just forward ref the NativeDelegate rather than include it here. @@ -427,7 +427,7 @@ class ModuleCache; virtual size_t GetSoftwareBreakpointTrapOpcode (Target &target, - BreakpointSite *bp_site) = 0; + BreakpointSite *bp_site); //------------------------------------------------------------------ /// Launch a new process on a platform, not necessarily for @@ -1079,7 +1079,8 @@ class ModuleCache; uint32_t m_update_os_version; ArchSpec m_system_arch; // The architecture of the kernel or the remote platform typedef std::map<uint32_t, ConstString> IDToNameMap; - Mutex m_mutex; // Mutex for modifying Platform data structures that should only be used for non-reentrant code + // Mutex for modifying Platform data structures that should only be used for non-reentrant code + std::mutex m_mutex; IDToNameMap m_uid_map; IDToNameMap m_gid_map; size_t m_max_uid_name_len; @@ -1112,9 +1113,9 @@ class ModuleCache; CalculateTrapHandlerSymbolNames () = 0; const char * - GetCachedUserName (uint32_t uid) + GetCachedUserName(uint32_t uid) { - Mutex::Locker locker (m_mutex); + std::lock_guard<std::mutex> guard(m_mutex); // return the empty string if our string is NULL // so we can tell when things were in the negative // cached (didn't find a valid user name, don't keep @@ -1124,35 +1125,35 @@ class ModuleCache; } const char * - SetCachedUserName (uint32_t uid, const char *name, size_t name_len) + SetCachedUserName(uint32_t uid, const char *name, size_t name_len) { - Mutex::Locker locker (m_mutex); - ConstString const_name (name); + std::lock_guard<std::mutex> guard(m_mutex); + ConstString const_name(name); m_uid_map[uid] = const_name; if (m_max_uid_name_len < name_len) m_max_uid_name_len = name_len; // Const strings lives forever in our const string pool, so we can return the const char * - return const_name.GetCString(); + return const_name.GetCString(); } void - SetUserNameNotFound (uint32_t uid) + SetUserNameNotFound(uint32_t uid) { - Mutex::Locker locker (m_mutex); + std::lock_guard<std::mutex> guard(m_mutex); m_uid_map[uid] = ConstString(); } void - ClearCachedUserNames () + ClearCachedUserNames() { - Mutex::Locker locker (m_mutex); + std::lock_guard<std::mutex> guard(m_mutex); m_uid_map.clear(); } - + const char * - GetCachedGroupName (uint32_t gid) + GetCachedGroupName(uint32_t gid) { - Mutex::Locker locker (m_mutex); + std::lock_guard<std::mutex> guard(m_mutex); // return the empty string if our string is NULL // so we can tell when things were in the negative // cached (didn't find a valid group name, don't keep @@ -1162,28 +1163,28 @@ class ModuleCache; } const char * - SetCachedGroupName (uint32_t gid, const char *name, size_t name_len) + SetCachedGroupName(uint32_t gid, const char *name, size_t name_len) { - Mutex::Locker locker (m_mutex); - ConstString const_name (name); + std::lock_guard<std::mutex> guard(m_mutex); + ConstString const_name(name); m_gid_map[gid] = const_name; if (m_max_gid_name_len < name_len) m_max_gid_name_len = name_len; // Const strings lives forever in our const string pool, so we can return the const char * - return const_name.GetCString(); + return const_name.GetCString(); } void - SetGroupNameNotFound (uint32_t gid) + SetGroupNameNotFound(uint32_t gid) { - Mutex::Locker locker (m_mutex); + std::lock_guard<std::mutex> guard(m_mutex); m_gid_map[gid] = ConstString(); } void - ClearCachedGroupNames () + ClearCachedGroupNames() { - Mutex::Locker locker (m_mutex); + std::lock_guard<std::mutex> guard(m_mutex); m_gid_map.clear(); } @@ -1236,20 +1237,15 @@ class ModuleCache; class PlatformList { public: - PlatformList() : - m_mutex (Mutex::eMutexTypeRecursive), - m_platforms (), - m_selected_platform_sp() - { - } + PlatformList() : m_mutex(), m_platforms(), m_selected_platform_sp() {} ~PlatformList() = default; void - Append (const lldb::PlatformSP &platform_sp, bool set_selected) + Append(const lldb::PlatformSP &platform_sp, bool set_selected) { - Mutex::Locker locker (m_mutex); - m_platforms.push_back (platform_sp); + std::lock_guard<std::recursive_mutex> guard(m_mutex); + m_platforms.push_back(platform_sp); if (set_selected) m_selected_platform_sp = m_platforms.back(); } @@ -1257,16 +1253,16 @@ class ModuleCache; size_t GetSize() { - Mutex::Locker locker (m_mutex); + std::lock_guard<std::recursive_mutex> guard(m_mutex); return m_platforms.size(); } lldb::PlatformSP - GetAtIndex (uint32_t idx) + GetAtIndex(uint32_t idx) { lldb::PlatformSP platform_sp; { - Mutex::Locker locker (m_mutex); + std::lock_guard<std::recursive_mutex> guard(m_mutex); if (idx < m_platforms.size()) platform_sp = m_platforms[idx]; } @@ -1283,23 +1279,23 @@ class ModuleCache; /// processes. //------------------------------------------------------------------ lldb::PlatformSP - GetSelectedPlatform () + GetSelectedPlatform() { - Mutex::Locker locker (m_mutex); + std::lock_guard<std::recursive_mutex> guard(m_mutex); if (!m_selected_platform_sp && !m_platforms.empty()) m_selected_platform_sp = m_platforms.front(); - + return m_selected_platform_sp; } void - SetSelectedPlatform (const lldb::PlatformSP &platform_sp) + SetSelectedPlatform(const lldb::PlatformSP &platform_sp) { if (platform_sp) { - Mutex::Locker locker (m_mutex); + std::lock_guard<std::recursive_mutex> guard(m_mutex); const size_t num_platforms = m_platforms.size(); - for (size_t idx=0; idx<num_platforms; ++idx) + for (size_t idx = 0; idx < num_platforms; ++idx) { if (m_platforms[idx].get() == platform_sp.get()) { @@ -1307,28 +1303,28 @@ class ModuleCache; return; } } - m_platforms.push_back (platform_sp); + m_platforms.push_back(platform_sp); m_selected_platform_sp = m_platforms.back(); } } protected: typedef std::vector<lldb::PlatformSP> collection; - mutable Mutex m_mutex; + mutable std::recursive_mutex m_mutex; collection m_platforms; lldb::PlatformSP m_selected_platform_sp; private: DISALLOW_COPY_AND_ASSIGN (PlatformList); }; - + class OptionGroupPlatformRSync : public lldb_private::OptionGroup { public: - OptionGroupPlatformRSync (); - - ~OptionGroupPlatformRSync() override; - + OptionGroupPlatformRSync() = default; + + ~OptionGroupPlatformRSync() override = default; + lldb_private::Error SetOptionValue(CommandInterpreter &interpreter, uint32_t option_idx, @@ -1353,6 +1349,7 @@ class ModuleCache; std::string m_rsync_opts; std::string m_rsync_prefix; bool m_ignores_remote_hostname; + private: DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformRSync); }; @@ -1360,10 +1357,10 @@ class ModuleCache; class OptionGroupPlatformSSH : public lldb_private::OptionGroup { public: - OptionGroupPlatformSSH (); - - ~OptionGroupPlatformSSH() override; - + OptionGroupPlatformSSH() = default; + + ~OptionGroupPlatformSSH() override = default; + lldb_private::Error SetOptionValue(CommandInterpreter &interpreter, uint32_t option_idx, @@ -1394,10 +1391,10 @@ class ModuleCache; class OptionGroupPlatformCaching : public lldb_private::OptionGroup { public: - OptionGroupPlatformCaching (); - - ~OptionGroupPlatformCaching() override; - + OptionGroupPlatformCaching() = default; + + ~OptionGroupPlatformCaching() override = default; + lldb_private::Error SetOptionValue(CommandInterpreter &interpreter, uint32_t option_idx, diff --git a/include/lldb/Target/Process.h b/include/lldb/Target/Process.h index 6bb7a3d783de..57787f2f8f39 100644 --- a/include/lldb/Target/Process.h +++ b/include/lldb/Target/Process.h @@ -18,6 +18,7 @@ // C++ Includes #include <list> #include <memory> +#include <mutex> #include <string> #include <vector> #include <unordered_set> @@ -30,6 +31,7 @@ #include "lldb/Core/Communication.h" #include "lldb/Core/Error.h" #include "lldb/Core/Event.h" +#include "lldb/Core/Listener.h" #include "lldb/Core/LoadedModuleInfoList.h" #include "lldb/Core/ThreadSafeValue.h" #include "lldb/Core/PluginInterface.h" @@ -400,7 +402,7 @@ public: m_listener_sp = listener_sp; } - Listener & + lldb::ListenerSP GetListenerForProcess (Debugger &debugger); protected: @@ -939,13 +941,13 @@ public: /// Construct with a shared pointer to a target, and the Process listener. /// Uses the Host UnixSignalsSP by default. //------------------------------------------------------------------ - Process(lldb::TargetSP target_sp, Listener &listener); + Process(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp); //------------------------------------------------------------------ /// Construct with a shared pointer to a target, the Process listener, /// and the appropriate UnixSignalsSP for the process. //------------------------------------------------------------------ - Process(lldb::TargetSP target_sp, Listener &listener, const lldb::UnixSignalsSP &unix_signals_sp); + Process(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const lldb::UnixSignalsSP &unix_signals_sp); //------------------------------------------------------------------ /// Destructor. @@ -985,7 +987,7 @@ public: static lldb::ProcessSP FindPlugin (lldb::TargetSP target_sp, const char *plugin_name, - Listener &listener, + lldb::ListenerSP listener_sp, const FileSpec *crash_file_path); //------------------------------------------------------------------ @@ -998,16 +1000,14 @@ public: /// Subclasses should call Host::StartMonitoringChildProcess () /// with: /// callback = Process::SetHostProcessExitStatus - /// callback_baton = nullptr /// pid = Process::GetID() /// monitor_signals = false //------------------------------------------------------------------ static bool - SetProcessExitStatus(void *callback_baton, // The callback baton which should be set to nullptr - lldb::pid_t pid, // The process ID we want to monitor + SetProcessExitStatus(lldb::pid_t pid, // The process ID we want to monitor bool exited, - int signo, // Zero for no signal - int status); // Exit value of process if signal is zero + int signo, // Zero for no signal + int status); // Exit value of process if signal is zero lldb::ByteOrder GetByteOrder () const; @@ -1886,15 +1886,13 @@ public: //------------------------------------------------------------------ lldb::StateType GetState (); - + lldb::ExpressionResults - RunThreadPlan (ExecutionContext &exe_ctx, - lldb::ThreadPlanSP &thread_plan_sp, - const EvaluateExpressionOptions &options, - Stream &errors); + RunThreadPlan(ExecutionContext &exe_ctx, lldb::ThreadPlanSP &thread_plan_sp, + const EvaluateExpressionOptions &options, DiagnosticManager &diagnostic_manager); static const char * - ExecutionResultAsCString (lldb::ExpressionResults result); + ExecutionResultAsCString(lldb::ExpressionResults result); void GetStatus (Stream &ostrm); @@ -1962,6 +1960,9 @@ public: void PrintWarningOptimization (const SymbolContext &sc); + virtual bool + GetProcessInfo(ProcessInstanceInfo &info); + public: //------------------------------------------------------------------ /// Get the exit status for a process. @@ -2232,11 +2233,11 @@ public: /// order. //------------------------------------------------------------------ uint64_t - ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr, - size_t byte_size, - uint64_t fail_value, - Error &error); - + ReadUnsignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, uint64_t fail_value, Error &error); + + int64_t + ReadSignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, int64_t fail_value, Error &error); + lldb::addr_t ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error); @@ -2436,6 +2437,32 @@ public: virtual lldb::addr_t ResolveIndirectFunction(const Address *address, Error &error); + //------------------------------------------------------------------ + /// Locate the memory region that contains load_addr. + /// + /// If load_addr is within the address space the process has mapped + /// range_info will be filled in with the start and end of that range + /// as well as the permissions for that range and range_info.GetMapped + /// will return true. + /// + /// If load_addr is outside any mapped region then range_info will + /// have its start address set to load_addr and the end of the + /// range will indicate the start of the next mapped range or be + /// set to LLDB_INVALID_ADDRESS if there are no valid mapped ranges + /// between load_addr and the end of the process address space. + /// + /// GetMemoryRegionInfo will only return an error if it is + /// unimplemented for the current process. + /// + /// @param[in] load_addr + /// The load address to query the range_info for. + /// + /// @param[out] range_info + /// An range_info value containing the details of the range. + /// + /// @return + /// An error value. + //------------------------------------------------------------------ virtual Error GetMemoryRegionInfo (lldb::addr_t load_addr, MemoryRegionInfo &range_info) @@ -2445,6 +2472,19 @@ public: return error; } + //------------------------------------------------------------------ + /// Obtain all the mapped memory regions within this process. + /// + /// @param[out] region_list + /// A vector to contain MemoryRegionInfo objects for all mapped + /// ranges. + /// + /// @return + /// An error value. + //------------------------------------------------------------------ + virtual Error + GetMemoryRegions (std::vector<lldb::MemoryRegionInfoSP>& region_list); + virtual Error GetWatchpointSupportInfo (uint32_t &num) { @@ -2851,7 +2891,7 @@ public: WaitForProcessToStop(const TimeValue *timeout, lldb::EventSP *event_sp_ptr = nullptr, bool wait_always = true, - Listener *hijack_listener = nullptr, + lldb::ListenerSP hijack_listener = lldb::ListenerSP(), Stream *stream = nullptr, bool use_run_lock = true); @@ -2877,7 +2917,7 @@ public: lldb::StateType WaitForStateChangedEvents(const TimeValue *timeout, lldb::EventSP &event_sp, - Listener *hijack_listener); // Pass nullptr to use builtin listener + lldb::ListenerSP hijack_listener); // Pass an empty ListenerSP to use builtin listener //-------------------------------------------------------------------------------------- /// Centralize the code that handles and prints descriptions for process state changes. @@ -2908,10 +2948,10 @@ public: ProcessEventHijacker { public: - ProcessEventHijacker (Process &process, Listener *listener) : + ProcessEventHijacker (Process &process, lldb::ListenerSP listener_sp) : m_process (process) { - m_process.HijackProcessEvents (listener); + m_process.HijackProcessEvents (listener_sp); } ~ProcessEventHijacker () @@ -2940,7 +2980,7 @@ public: /// \b false otherwise. //------------------------------------------------------------------ bool - HijackProcessEvents (Listener *listener); + HijackProcessEvents (lldb::ListenerSP listener_sp); //------------------------------------------------------------------ /// Restores the process event broadcasting to its normal state. @@ -3308,9 +3348,13 @@ protected: bool PrivateStateThreadIsValid () const { - return m_private_state_thread.IsJoinable(); + lldb::StateType state = m_private_state.GetValue(); + return state != lldb::eStateInvalid && + state != lldb::eStateDetached && + state != lldb::eStateExited && + m_private_state_thread.IsJoinable(); } - + void ForceNextEventDelivery() { @@ -3343,8 +3387,7 @@ protected: ThreadSafeValue<lldb::StateType> m_private_state; // The actual state of our process Broadcaster m_private_state_broadcaster; // This broadcaster feeds state changed events into the private state thread's listener. Broadcaster m_private_state_control_broadcaster; // This is the control broadcaster, used to pause, resume & stop the private state thread. - Listener m_private_state_listener; // This is the listener for the private state thread. - Predicate<bool> m_private_state_control_wait; /// This Predicate is used to signal that a control operation is complete. + lldb::ListenerSP m_private_state_listener_sp; // This is the listener for the private state thread. HostThread m_private_state_thread; ///< Thread ID for the thread that watches internal state events ProcessModID m_mod_id; ///< Tracks the state of the process over stops and other alterations. uint32_t m_process_unique_id; ///< Each lldb_private::Process class that is created gets a unique integer ID that increments with each new instance @@ -3352,8 +3395,9 @@ protected: std::map<uint64_t, uint32_t> m_thread_id_to_index_id_map; int m_exit_status; ///< The exit status of the process, or -1 if not set. std::string m_exit_string; ///< A textual description of why a process exited. - Mutex m_exit_status_mutex; ///< Mutex so m_exit_status m_exit_string can be safely accessed from multiple threads - Mutex m_thread_mutex; + std::mutex + m_exit_status_mutex; ///< Mutex so m_exit_status m_exit_string can be safely accessed from multiple threads + std::recursive_mutex m_thread_mutex; ThreadList m_thread_list_real; ///< The threads for this process as are known to the protocol we are debugging with ThreadList m_thread_list; ///< The threads for this process as the user will see them. This is usually the same as ///< m_thread_list_real, but might be different if there is an OS plug-in creating memory threads @@ -3363,7 +3407,7 @@ protected: uint32_t m_queue_list_stop_id; ///< The natural stop id when queue list was last fetched std::vector<Notifications> m_notifications; ///< The list of notifications that this process can deliver. std::vector<lldb::addr_t> m_image_tokens; - Listener &m_listener; + lldb::ListenerSP m_listener_sp; ///< Shared pointer to the listener used for public events. Can not be empty. BreakpointSiteList m_breakpoint_site_list; ///< This is the list of breakpoint locations we intend to insert in the target. lldb::DynamicLoaderUP m_dyld_ap; lldb::JITLoaderListUP m_jit_loaders_ap; @@ -3374,11 +3418,11 @@ protected: lldb::ABISP m_abi_sp; lldb::IOHandlerSP m_process_input_reader; Communication m_stdio_communication; - Mutex m_stdio_communication_mutex; + std::recursive_mutex m_stdio_communication_mutex; bool m_stdin_forward; /// Remember if stdin must be forwarded to remote debug server std::string m_stdout_data; std::string m_stderr_data; - Mutex m_profile_data_comm_mutex; + std::recursive_mutex m_profile_data_comm_mutex; std::vector<std::string> m_profile_data; Predicate<uint32_t> m_iohandler_sync; MemoryCache m_memory_cache; @@ -3402,6 +3446,7 @@ protected: bool m_destroy_in_process; bool m_can_interpret_function_calls; // Some targets, e.g the OSX kernel, don't support the ability to modify the stack. WarningsCollection m_warnings_issued; // A set of object pointers which have already had warnings printed + std::mutex m_run_thread_plan_lock; enum { eCanJITDontKnow= 0, @@ -3433,12 +3478,15 @@ protected: void ResumePrivateStateThread (); +private: struct PrivateStateThreadArgs { + PrivateStateThreadArgs(Process *p, bool s) : process(p), is_secondary_thread(s) {}; Process *process; bool is_secondary_thread; }; - + + // arg is a pointer to a new'ed PrivateStateThreadArgs structure. PrivateStateThread will free it for you. static lldb::thread_result_t PrivateStateThread (void *arg); @@ -3450,6 +3498,7 @@ protected: lldb::thread_result_t RunPrivateStateThread (bool is_secondary_thread); +protected: void HandlePrivateEvent (lldb::EventSP &event_sp); diff --git a/include/lldb/Target/ProcessLaunchInfo.h b/include/lldb/Target/ProcessLaunchInfo.h index 92a3ed40736d..d1a45794b551 100644 --- a/include/lldb/Target/ProcessLaunchInfo.h +++ b/include/lldb/Target/ProcessLaunchInfo.h @@ -148,9 +148,7 @@ namespace lldb_private int32_t num_resumes); void - SetMonitorProcessCallback (Host::MonitorChildProcessCallback callback, - void *baton, - bool monitor_signals); + SetMonitorProcessCallback(const Host::MonitorChildProcessCallback &callback, bool monitor_signals); Host::MonitorChildProcessCallback GetMonitorProcessCallback() const @@ -158,12 +156,6 @@ namespace lldb_private return m_monitor_callback; } - void * - GetMonitorProcessBaton() const - { - return m_monitor_callback_baton; - } - bool GetMonitorSignals() const { @@ -196,7 +188,7 @@ namespace lldb_private m_listener_sp = listener_sp; } - Listener & + lldb::ListenerSP GetListenerForProcess (Debugger &debugger); lldb::ListenerSP diff --git a/include/lldb/Target/QueueList.h b/include/lldb/Target/QueueList.h index 12a0ea52d7f4..265145db2696 100644 --- a/include/lldb/Target/QueueList.h +++ b/include/lldb/Target/QueueList.h @@ -10,6 +10,7 @@ #ifndef liblldb_QueueList_h_ #define liblldb_QueueList_h_ +#include <mutex> #include <vector> #include "lldb/lldb-private.h" @@ -60,7 +61,7 @@ public: GetQueueAtIndex (uint32_t idx); typedef std::vector<lldb::QueueSP> collection; - typedef LockingAdaptedIterable<collection, lldb::QueueSP, vector_adapter> QueueIterable; + typedef LockingAdaptedIterable<collection, lldb::QueueSP, vector_adapter, std::mutex> QueueIterable; //------------------------------------------------------------------ /// Iterate over the list of queues @@ -119,8 +120,8 @@ public: lldb::QueueSP FindQueueByIndexID (uint32_t index_id); - lldb_private::Mutex & - GetMutex (); + std::mutex & + GetMutex(); protected: @@ -130,7 +131,7 @@ protected: Process *m_process; ///< The process that manages this queue list. uint32_t m_stop_id; ///< The process stop ID that this queue list is valid for. collection m_queues; ///< The queues for this process. - Mutex m_mutex; + std::mutex m_mutex; private: QueueList (); diff --git a/include/lldb/Target/SectionLoadHistory.h b/include/lldb/Target/SectionLoadHistory.h index ddf46a1861ca..2494b7fd2779 100644 --- a/include/lldb/Target/SectionLoadHistory.h +++ b/include/lldb/Target/SectionLoadHistory.h @@ -13,10 +13,10 @@ // C Includes // C++ Includes #include <map> +#include <mutex> // Project includes #include "lldb/lldb-public.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -31,11 +31,7 @@ public: //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - SectionLoadHistory () : - m_stop_id_to_section_load_list(), - m_mutex (Mutex::eMutexTypeRecursive) - { - } + SectionLoadHistory() : m_stop_id_to_section_load_list(), m_mutex() {} ~SectionLoadHistory() { @@ -98,7 +94,7 @@ protected: typedef std::map<uint32_t, lldb::SectionLoadListSP> StopIDToSectionLoadList; StopIDToSectionLoadList m_stop_id_to_section_load_list; - mutable Mutex m_mutex; + mutable std::recursive_mutex m_mutex; private: DISALLOW_COPY_AND_ASSIGN (SectionLoadHistory); diff --git a/include/lldb/Target/SectionLoadList.h b/include/lldb/Target/SectionLoadList.h index 5f5d39e2b24b..1326d6007f2d 100644 --- a/include/lldb/Target/SectionLoadList.h +++ b/include/lldb/Target/SectionLoadList.h @@ -13,13 +13,13 @@ // C Includes // C++ Includes #include <map> +#include <mutex> // Other libraries and framework includes #include "llvm/ADT/DenseMap.h" // Project includes #include "lldb/lldb-public.h" #include "lldb/Core/Section.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -29,13 +29,7 @@ public: //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - SectionLoadList () : - m_addr_to_sect (), - m_sect_to_addr (), - m_mutex (Mutex::eMutexTypeRecursive) - - { - } + SectionLoadList() : m_addr_to_sect(), m_sect_to_addr(), m_mutex() {} SectionLoadList (const SectionLoadList& rhs); @@ -84,7 +78,7 @@ protected: typedef llvm::DenseMap<const Section *, lldb::addr_t> sect_to_addr_collection; addr_to_sect_collection m_addr_to_sect; sect_to_addr_collection m_sect_to_addr; - mutable Mutex m_mutex; + mutable std::recursive_mutex m_mutex; }; } // namespace lldb_private diff --git a/include/lldb/Target/StackFrame.h b/include/lldb/Target/StackFrame.h index b65b01810176..b3cc57f176ca 100644 --- a/include/lldb/Target/StackFrame.h +++ b/include/lldb/Target/StackFrame.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include <memory> +#include <mutex> // Other libraries and framework includes // Project includes @@ -289,7 +290,7 @@ public: /// A pointer to a list of variables. //------------------------------------------------------------------ lldb::VariableListSP - GetInScopeVariableList (bool get_file_globals); + GetInScopeVariableList (bool get_file_globals, bool must_have_valid_location = false); //------------------------------------------------------------------ /// Create a ValueObject for a variable name / pathname, possibly @@ -478,6 +479,11 @@ public: lldb::LanguageType GetLanguage (); + // similar to GetLanguage(), but is allowed to take a potentially incorrect guess + // if exact information is not available + lldb::LanguageType + GuessLanguage (); + //------------------------------------------------------------------ // lldb::ExecutionContextScope pure virtual functions //------------------------------------------------------------------ @@ -532,7 +538,7 @@ private: lldb::VariableListSP m_variable_list_sp; ValueObjectList m_variable_list_value_objects; // Value objects for each variable in m_variable_list_sp StreamString m_disassembly; - Mutex m_mutex; + std::recursive_mutex m_mutex; DISALLOW_COPY_AND_ASSIGN (StackFrame); }; diff --git a/include/lldb/Target/StackFrameList.h b/include/lldb/Target/StackFrameList.h index 50a656de9e69..8b6bea3193c5 100644 --- a/include/lldb/Target/StackFrameList.h +++ b/include/lldb/Target/StackFrameList.h @@ -13,11 +13,11 @@ // C Includes // C++ Includes #include <memory> +#include <mutex> #include <vector> // Other libraries and framework includes // Project includes -#include "lldb/Host/Mutex.h" #include "lldb/Target/StackFrame.h" namespace lldb_private { @@ -135,7 +135,7 @@ protected: Thread &m_thread; lldb::StackFrameListSP m_prev_frames_sp; - mutable Mutex m_mutex; + mutable std::recursive_mutex m_mutex; collection m_frames; uint32_t m_selected_frame_idx; uint32_t m_concrete_frames_fetched; diff --git a/include/lldb/Target/Target.h b/include/lldb/Target/Target.h index 0cdb248a9b44..7124b2e83467 100644 --- a/include/lldb/Target/Target.h +++ b/include/lldb/Target/Target.h @@ -53,9 +53,22 @@ typedef enum LoadScriptFromSymFile eLoadScriptFromSymFileWarn } LoadScriptFromSymFile; +typedef enum LoadCWDlldbinitFile +{ + eLoadCWDlldbinitTrue, + eLoadCWDlldbinitFalse, + eLoadCWDlldbinitWarn +} LoadCWDlldbinitFile; + //---------------------------------------------------------------------- // TargetProperties //---------------------------------------------------------------------- +class TargetExperimentalProperties : public Properties +{ +public: + TargetExperimentalProperties(); +}; + class TargetProperties : public Properties { public: @@ -142,6 +155,12 @@ public: GetEnableAutoImportClangModules () const; bool + GetEnableAutoApplyFixIts () const; + + bool + GetEnableNotifyAboutFixIts () const; + + bool GetEnableSyntheticValue () const; uint32_t @@ -192,6 +211,9 @@ public: LoadScriptFromSymFile GetLoadScriptFromSymbolFile() const; + LoadCWDlldbinitFile + GetLoadCWDlldbinitFile () const; + Disassembler::HexImmediateStyle GetHexImmediateStyle() const; @@ -221,6 +243,12 @@ public: void SetProcessLaunchInfo(const ProcessLaunchInfo &launch_info); + + bool + GetInjectLocalVariables(ExecutionContext *exe_ctx) const; + + void + SetInjectLocalVariables(ExecutionContext *exe_ctx, bool b); private: //------------------------------------------------------------------ @@ -241,14 +269,17 @@ private: // Member variables. //------------------------------------------------------------------ ProcessLaunchInfo m_launch_info; + std::unique_ptr<TargetExperimentalProperties> m_experimental_properties_up; }; class EvaluateExpressionOptions { public: static const uint32_t default_timeout = 500000; + static const ExecutionPolicy default_execution_policy = eExecutionPolicyOnlyWhenNeeded; + EvaluateExpressionOptions() : - m_execution_policy(eExecutionPolicyOnlyWhenNeeded), + m_execution_policy(default_execution_policy), m_language (lldb::eLanguageTypeUnknown), m_prefix (), // A prefix specific to this expression that is added after the prefix from the settings (if any) m_coerce_to_id (false), @@ -261,6 +292,7 @@ public: m_trap_exceptions (true), m_generate_debug_info (false), m_result_is_internal (false), + m_auto_apply_fixits (true), m_use_dynamic (lldb::eNoDynamicValues), m_timeout_usec (default_timeout), m_one_thread_timeout_usec (0), @@ -531,6 +563,18 @@ public: { return m_result_is_internal; } + + void + SetAutoApplyFixIts(bool b) + { + m_auto_apply_fixits = b; + } + + bool + GetAutoApplyFixIts() const + { + return m_auto_apply_fixits; + } private: ExecutionPolicy m_execution_policy; @@ -548,6 +592,7 @@ private: bool m_generate_debug_info; bool m_ansi_color_errors; bool m_result_is_internal; + bool m_auto_apply_fixits; lldb::DynamicValueType m_use_dynamic; uint32_t m_timeout_usec; uint32_t m_one_thread_timeout_usec; @@ -681,8 +726,8 @@ public: static const lldb::TargetPropertiesSP & GetGlobalProperties(); - Mutex & - GetAPIMutex () + std::recursive_mutex & + GetAPIMutex() { return m_mutex; } @@ -709,7 +754,7 @@ public: Dump (Stream *s, lldb::DescriptionLevel description_level); const lldb::ProcessSP & - CreateProcess (Listener &listener, + CreateProcess (lldb::ListenerSP listener, const char *plugin_name, const FileSpec *crash_file); @@ -757,6 +802,7 @@ public: CreateBreakpoint (const FileSpecList *containingModules, const FileSpec &file, uint32_t line_no, + lldb::addr_t offset, LazyBool check_inlines, LazyBool skip_prologue, bool internal, @@ -764,9 +810,11 @@ public: LazyBool move_to_nearest_code); // Use this to create breakpoint that matches regex against the source lines in files given in source_file_list: + // If function_names is non-empty, also filter by function after the matches are made. lldb::BreakpointSP CreateSourceRegexBreakpoint (const FileSpecList *containingModules, const FileSpecList *source_file_list, + const std::unordered_set<std::string> &function_names, RegularExpression &source_regex, bool internal, bool request_hardware, @@ -813,6 +861,7 @@ public: const char *func_name, uint32_t func_name_type_mask, lldb::LanguageType language, + lldb::addr_t offset, LazyBool skip_prologue, bool internal, bool request_hardware); @@ -834,8 +883,9 @@ public: const FileSpecList *containingSourceFiles, const char *func_names[], size_t num_names, - uint32_t func_name_type_mask, + uint32_t func_name_type_mask, lldb::LanguageType language, + lldb::addr_t offset, LazyBool skip_prologue, bool internal, bool request_hardware); @@ -846,6 +896,7 @@ public: const std::vector<std::string> &func_names, uint32_t func_name_type_mask, lldb::LanguageType language, + lldb::addr_t m_offset, LazyBool skip_prologue, bool internal, bool request_hardware); @@ -1342,7 +1393,8 @@ public: EvaluateExpression (const char *expression, ExecutionContextScope *exe_scope, lldb::ValueObjectSP &result_valobj_sp, - const EvaluateExpressionOptions& options = EvaluateExpressionOptions()); + const EvaluateExpressionOptions& options = EvaluateExpressionOptions(), + std::string *fixed_expression = nullptr); lldb::ExpressionVariableSP GetPersistentVariable(const ConstString &name); @@ -1555,7 +1607,8 @@ protected: //------------------------------------------------------------------ Debugger & m_debugger; lldb::PlatformSP m_platform_sp; ///< The platform for this target. - Mutex m_mutex; ///< An API mutex that is used by the lldb::SB* classes make the SB interface thread safe + std::recursive_mutex + m_mutex; ///< An API mutex that is used by the lldb::SB* classes make the SB interface thread safe ArchSpec m_arch; ModuleList m_images; ///< The list of images for this process (shared libraries and anything dynamically loaded). SectionLoadHistory m_section_load_history; diff --git a/include/lldb/Target/TargetList.h b/include/lldb/Target/TargetList.h index fddb715b46f3..d96d2f1b0e7a 100644 --- a/include/lldb/Target/TargetList.h +++ b/include/lldb/Target/TargetList.h @@ -12,12 +12,12 @@ // C Includes // C++ Includes +#include <mutex> #include <vector> // Other libraries and framework includes // Project includes #include "lldb/Core/Broadcaster.h" -#include "lldb/Host/Mutex.h" #include "lldb/Target/Target.h" namespace lldb_private { @@ -229,7 +229,7 @@ protected: //------------------------------------------------------------------ collection m_target_list; lldb::TargetSP m_dummy_target_sp; - mutable Mutex m_target_list_mutex; + mutable std::recursive_mutex m_target_list_mutex; uint32_t m_selected_target_idx; private: diff --git a/include/lldb/Target/Thread.h b/include/lldb/Target/Thread.h index ba73e0b49da8..f3cf97325e16 100644 --- a/include/lldb/Target/Thread.h +++ b/include/lldb/Target/Thread.h @@ -13,13 +13,13 @@ // C Includes // C++ Includes #include <memory> +#include <mutex> #include <string> #include <vector> // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" -#include "lldb/Host/Mutex.h" #include "lldb/Core/Broadcaster.h" #include "lldb/Core/Event.h" #include "lldb/Core/StructuredData.h" @@ -708,13 +708,15 @@ public: /// @param[in] module /// The module to query TLS data for. /// + /// @param[in] tls_file_addr + /// The thread local address in module /// @return /// If the thread has TLS data allocated for the /// module, the address of the TLS block. Otherwise /// LLDB_INVALID_ADDRESS is returned. //------------------------------------------------------------------ virtual lldb::addr_t - GetThreadLocalData (const lldb::ModuleSP module); + GetThreadLocalData(const lldb::ModuleSP module, lldb::addr_t tls_file_addr); //------------------------------------------------------------------ /// Check whether this thread is safe to run functions @@ -1446,11 +1448,11 @@ protected: const uint32_t m_index_id; ///< A unique 1 based index assigned to each thread for easy UI/command line access. lldb::RegisterContextSP m_reg_context_sp; ///< The register context for this thread's current register state. lldb::StateType m_state; ///< The state of our process. - mutable Mutex m_state_mutex; ///< Multithreaded protection for m_state. + mutable std::recursive_mutex m_state_mutex; ///< Multithreaded protection for m_state. plan_stack m_plan_stack; ///< The stack of plans this thread is executing. plan_stack m_completed_plan_stack; ///< Plans that have been completed by this stop. They get deleted when the thread resumes. plan_stack m_discarded_plan_stack; ///< Plans that have been discarded by this stop. They get deleted when the thread resumes. - mutable Mutex m_frame_mutex; ///< Multithreaded protection for m_state. + mutable std::recursive_mutex m_frame_mutex; ///< Multithreaded protection for m_state. lldb::StackFrameListSP m_curr_frames_sp; ///< The stack frames that get lazily populated after a thread stops. lldb::StackFrameListSP m_prev_frames_sp; ///< The previous stack frames from the last time this thread stopped. int m_resume_signal; ///< The signal that should be used when continuing this thread. diff --git a/include/lldb/Target/ThreadCollection.h b/include/lldb/Target/ThreadCollection.h index 0c2b41cc0ca4..f24167f120a8 100644 --- a/include/lldb/Target/ThreadCollection.h +++ b/include/lldb/Target/ThreadCollection.h @@ -10,10 +10,10 @@ #ifndef liblldb_ThreadCollection_h_ #define liblldb_ThreadCollection_h_ +#include <mutex> #include <vector> #include "lldb/lldb-private.h" -#include "lldb/Host/Mutex.h" #include "lldb/Utility/Iterable.h" namespace lldb_private { @@ -22,8 +22,8 @@ class ThreadCollection { public: typedef std::vector<lldb::ThreadSP> collection; - typedef LockingAdaptedIterable<collection, lldb::ThreadSP, vector_adapter> ThreadIterable; - + typedef LockingAdaptedIterable<collection, lldb::ThreadSP, vector_adapter, std::recursive_mutex> ThreadIterable; + ThreadCollection(); ThreadCollection(collection threads); @@ -38,7 +38,10 @@ public: void AddThread (const lldb::ThreadSP &thread_sp); - + + void + AddThreadSortedByIndexID (const lldb::ThreadSP &thread_sp); + void InsertThread (const lldb::ThreadSP &thread_sp, uint32_t idx); @@ -53,16 +56,16 @@ public: { return ThreadIterable(m_threads, GetMutex()); } - - virtual Mutex & + + virtual std::recursive_mutex & GetMutex() { return m_mutex; } - + protected: collection m_threads; - Mutex m_mutex; + std::recursive_mutex m_mutex; }; } // namespace lldb_private diff --git a/include/lldb/Target/ThreadList.h b/include/lldb/Target/ThreadList.h index e6489b25e558..140fdaa444d0 100644 --- a/include/lldb/Target/ThreadList.h +++ b/include/lldb/Target/ThreadList.h @@ -10,12 +10,14 @@ #ifndef liblldb_ThreadList_h_ #define liblldb_ThreadList_h_ +#include <mutex> #include <vector> #include "lldb/lldb-private.h" #include "lldb/Core/UserID.h" #include "lldb/Utility/Iterable.h" #include "lldb/Target/ThreadCollection.h" +#include "lldb/Target/Thread.h" namespace lldb_private { @@ -44,7 +46,43 @@ public: // selected at index 0. lldb::ThreadSP GetSelectedThread (); + + // Manage the thread to use for running expressions. This is usually the Selected thread, + // but sometimes (e.g. when evaluating breakpoint conditions & stop hooks) it isn't. + class ExpressionExecutionThreadPusher + { + public: + ExpressionExecutionThreadPusher(ThreadList &thread_list, lldb::tid_t tid) : + m_thread_list(&thread_list), + m_tid(tid) + { + m_thread_list->PushExpressionExecutionThread(m_tid); + } + + ExpressionExecutionThreadPusher(lldb::ThreadSP thread_sp); + + ~ExpressionExecutionThreadPusher() + { + if (m_thread_list && m_tid != LLDB_INVALID_THREAD_ID) + m_thread_list->PopExpressionExecutionThread(m_tid); + } + + private: + ThreadList *m_thread_list; + lldb::tid_t m_tid; + }; + lldb::ThreadSP + GetExpressionExecutionThread(); + +protected: + void + PushExpressionExecutionThread(lldb::tid_t tid); + + void + PopExpressionExecutionThread(lldb::tid_t tid); + +public: bool SetSelectedThreadByID (lldb::tid_t tid, bool notify = false); @@ -127,9 +165,9 @@ public: void SetStopID (uint32_t stop_id); - Mutex & + std::recursive_mutex & GetMutex() override; - + void Update (ThreadList &rhs); @@ -147,6 +185,7 @@ protected: Process *m_process; ///< The process that manages this thread list. uint32_t m_stop_id; ///< The process stop ID that this thread list is valid for. lldb::tid_t m_selected_tid; ///< For targets that need the notion of a current thread. + std::vector<lldb::tid_t> m_expression_tid_stack; private: diff --git a/include/lldb/Target/ThreadPlan.h b/include/lldb/Target/ThreadPlan.h index e6f9aeb78dd6..6dac4a299e52 100644 --- a/include/lldb/Target/ThreadPlan.h +++ b/include/lldb/Target/ThreadPlan.h @@ -12,13 +12,13 @@ // C Includes // C++ Includes +#include <mutex> #include <string> // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" #include "lldb/Core/UserID.h" -#include "lldb/Host/Mutex.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" @@ -632,7 +632,7 @@ private: ThreadPlanKind m_kind; std::string m_name; - Mutex m_plan_complete_mutex; + std::recursive_mutex m_plan_complete_mutex; LazyBool m_cached_plan_explains_stop; bool m_plan_complete; bool m_plan_private; diff --git a/include/lldb/Target/ThreadPlanPython.h b/include/lldb/Target/ThreadPlanPython.h index ab3fbbdf6fb5..8d5b217226f1 100644 --- a/include/lldb/Target/ThreadPlanPython.h +++ b/include/lldb/Target/ThreadPlanPython.h @@ -19,7 +19,6 @@ #include "lldb/lldb-private.h" #include "lldb/Core/StructuredData.h" #include "lldb/Core/UserID.h" -#include "lldb/Host/Mutex.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" diff --git a/include/lldb/Target/ThreadPlanStepInstruction.h b/include/lldb/Target/ThreadPlanStepInstruction.h index da83ecadcae6..27b9bf1133fe 100644 --- a/include/lldb/Target/ThreadPlanStepInstruction.h +++ b/include/lldb/Target/ThreadPlanStepInstruction.h @@ -23,6 +23,12 @@ namespace lldb_private { class ThreadPlanStepInstruction : public ThreadPlan { public: + ThreadPlanStepInstruction (Thread &thread, + bool step_over, + bool stop_others, + Vote stop_vote, + Vote run_vote); + ~ThreadPlanStepInstruction() override; void GetDescription(Stream *s, lldb::DescriptionLevel level) override; @@ -37,11 +43,6 @@ public: protected: bool DoPlanExplainsStop(Event *event_ptr) override; - ThreadPlanStepInstruction (Thread &thread, - bool step_over, - bool stop_others, - Vote stop_vote, - Vote run_vote); void SetUpState (); private: diff --git a/include/lldb/Target/Unwind.h b/include/lldb/Target/Unwind.h index 17c6c0df8207..09ba87a42bbe 100644 --- a/include/lldb/Target/Unwind.h +++ b/include/lldb/Target/Unwind.h @@ -12,10 +12,11 @@ // C Includes // C++ Includes +#include <mutex> + // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -25,11 +26,7 @@ protected: //------------------------------------------------------------------ // Classes that inherit from Unwind can see and modify these //------------------------------------------------------------------ - Unwind(Thread &thread) : - m_thread (thread), - m_unwind_mutex(Mutex::eMutexTypeRecursive) - { - } + Unwind(Thread &thread) : m_thread(thread), m_unwind_mutex() {} public: virtual @@ -40,18 +37,17 @@ public: void Clear() { - Mutex::Locker locker(m_unwind_mutex); + std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex); DoClear(); - } uint32_t GetFrameCount() { - Mutex::Locker locker(m_unwind_mutex); + std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex); return DoGetFrameCount(); } - + uint32_t GetFramesUpTo (uint32_t end_idx) { @@ -70,21 +66,19 @@ public: } bool - GetFrameInfoAtIndex (uint32_t frame_idx, - lldb::addr_t& cfa, - lldb::addr_t& pc) + GetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa, lldb::addr_t &pc) { - Mutex::Locker locker(m_unwind_mutex); - return DoGetFrameInfoAtIndex (frame_idx, cfa, pc); + std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex); + return DoGetFrameInfoAtIndex(frame_idx, cfa, pc); } - + lldb::RegisterContextSP - CreateRegisterContextForFrame (StackFrame *frame) + CreateRegisterContextForFrame(StackFrame *frame) { - Mutex::Locker locker(m_unwind_mutex); - return DoCreateRegisterContextForFrame (frame); + std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex); + return DoCreateRegisterContextForFrame(frame); } - + Thread & GetThread() { @@ -110,7 +104,8 @@ protected: DoCreateRegisterContextForFrame (StackFrame *frame) = 0; Thread &m_thread; - Mutex m_unwind_mutex; + std::recursive_mutex m_unwind_mutex; + private: DISALLOW_COPY_AND_ASSIGN (Unwind); }; |