diff options
Diffstat (limited to 'include/lldb/Target')
67 files changed, 1161 insertions, 3016 deletions
diff --git a/include/lldb/Target/ABI.h b/include/lldb/Target/ABI.h index 24fff1caf6c48..f254839fc975a 100644 --- a/include/lldb/Target/ABI.h +++ b/include/lldb/Target/ABI.h @@ -1,9 +1,8 @@ //===-- ABI.h ---------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -35,7 +34,7 @@ public: size_t size; /* size in bytes of this argument */ lldb::addr_t value; /* literal value */ - std::unique_ptr<uint8_t[]> data_ap; /* host data pointer */ + std::unique_ptr<uint8_t[]> data_up; /* host data pointer */ }; ~ABI() override; @@ -87,14 +86,12 @@ protected: virtual lldb::ValueObjectSP GetReturnValueObjectImpl(Thread &thread, llvm::Type &ir_type) const; - //------------------------------------------------------------------ /// Request to get a Process shared pointer. /// /// This ABI object may not have been created with a Process object, /// or the Process object may no longer be alive. Be sure to handle /// the case where the shared pointer returned does not have an /// object inside it. - //------------------------------------------------------------------ lldb::ProcessSP GetProcessSP() const { return m_process_wp.lock(); } public: @@ -129,7 +126,7 @@ public: virtual const RegisterInfo *GetRegisterInfoArray(uint32_t &count) = 0; - bool GetRegisterInfoByName(const ConstString &name, RegisterInfo &info); + bool GetRegisterInfoByName(ConstString name, RegisterInfo &info); bool GetRegisterInfoByKind(lldb::RegisterKind reg_kind, uint32_t reg_num, RegisterInfo &info); @@ -139,9 +136,7 @@ public: static lldb::ABISP FindPlugin(lldb::ProcessSP process_sp, const ArchSpec &arch); protected: - //------------------------------------------------------------------ // Classes that inherit from ABI can see and modify these - //------------------------------------------------------------------ ABI(lldb::ProcessSP process_sp) { if (process_sp.get()) m_process_wp = process_sp; diff --git a/include/lldb/Target/CPPLanguageRuntime.h b/include/lldb/Target/CPPLanguageRuntime.h deleted file mode 100644 index e96ee168389b9..0000000000000 --- a/include/lldb/Target/CPPLanguageRuntime.h +++ /dev/null @@ -1,80 +0,0 @@ -//===-- CPPLanguageRuntime.h -//---------------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_CPPLanguageRuntime_h_ -#define liblldb_CPPLanguageRuntime_h_ - -#include <vector> -#include "lldb/Core/PluginInterface.h" -#include "lldb/Target/LanguageRuntime.h" -#include "lldb/lldb-private.h" - -namespace lldb_private { - -class CPPLanguageRuntime : public LanguageRuntime { -public: - enum class LibCppStdFunctionCallableCase { - Lambda = 0, - CallableObject, - FreeOrMemberFunction, - Invalid - }; - - struct LibCppStdFunctionCallableInfo { - Symbol callable_symbol; - Address callable_address; - LineEntry callable_line_entry; - lldb::addr_t member__f_pointer_value = 0u; - LibCppStdFunctionCallableCase callable_case = - LibCppStdFunctionCallableCase::Invalid; - }; - - LibCppStdFunctionCallableInfo - FindLibCppStdFunctionCallableInfo(lldb::ValueObjectSP &valobj_sp); - - ~CPPLanguageRuntime() override; - - lldb::LanguageType GetLanguageType() const override { - return lldb::eLanguageTypeC_plus_plus; - } - - virtual bool IsVTableName(const char *name) = 0; - - bool GetObjectDescription(Stream &str, ValueObject &object) override; - - bool GetObjectDescription(Stream &str, Value &value, - ExecutionContextScope *exe_scope) override; - - /// Obtain a ThreadPlan to get us into C++ constructs such as std::function. - /// - /// @param[in] thread - /// Curent thrad of execution. - /// - /// @param[in] stop_others - /// True if other threads should pause during execution. - /// - /// @return - /// A ThreadPlan Shared pointer - lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, - bool stop_others); - -protected: - //------------------------------------------------------------------ - // Classes that inherit from CPPLanguageRuntime can see and modify these - //------------------------------------------------------------------ - CPPLanguageRuntime(Process *process); - -private: - DISALLOW_COPY_AND_ASSIGN(CPPLanguageRuntime); -}; - -} // namespace lldb_private - -#endif // liblldb_CPPLanguageRuntime_h_ diff --git a/include/lldb/Target/DynamicLoader.h b/include/lldb/Target/DynamicLoader.h index fe04f94aa31be..2bf3f32b5eef2 100644 --- a/include/lldb/Target/DynamicLoader.h +++ b/include/lldb/Target/DynamicLoader.h @@ -1,9 +1,8 @@ //===-- DynamicLoader.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,30 +22,17 @@ #include <stdint.h> namespace lldb_private { class ModuleList; -} -namespace lldb_private { class Process; -} -namespace lldb_private { class SectionList; -} -namespace lldb_private { class Symbol; -} -namespace lldb_private { class SymbolContext; -} -namespace lldb_private { class SymbolContextList; -} -namespace lldb_private { class Thread; } namespace lldb_private { -//---------------------------------------------------------------------- -/// @class DynamicLoader DynamicLoader.h "lldb/Target/DynamicLoader.h" +/// \class DynamicLoader DynamicLoader.h "lldb/Target/DynamicLoader.h" /// A plug-in interface definition class for dynamic loaders. /// /// Dynamic loader plug-ins track image (shared library) loading and @@ -63,64 +49,50 @@ namespace lldb_private { /// boolean value that indicates if the process should continue or halt and /// should return the global setting for this using: /// DynamicLoader::StopWhenImagesChange() const. -//---------------------------------------------------------------------- class DynamicLoader : public PluginInterface { public: - //------------------------------------------------------------------ /// Find a dynamic loader plugin for a given process. /// /// Scans the installed DynamicLoader plug-ins and tries to find an instance /// that can be used to track image changes in \a process. /// - /// @param[in] process + /// \param[in] process /// The process for which to try and locate a dynamic loader /// plug-in instance. /// - /// @param[in] plugin_name + /// \param[in] plugin_name /// An optional name of a specific dynamic loader plug-in that /// should be used. If NULL, pick the best plug-in. - //------------------------------------------------------------------ static DynamicLoader *FindPlugin(Process *process, const char *plugin_name); - //------------------------------------------------------------------ /// Construct with a process. - //------------------------------------------------------------------ DynamicLoader(Process *process); - //------------------------------------------------------------------ /// Destructor. /// /// The destructor is virtual since this class is designed to be inherited /// from by the plug-in instance. - //------------------------------------------------------------------ - virtual ~DynamicLoader() override; + ~DynamicLoader() override; - //------------------------------------------------------------------ /// Called after attaching a process. /// /// Allow DynamicLoader plug-ins to execute some code after attaching to a /// process. - //------------------------------------------------------------------ virtual void DidAttach() = 0; - //------------------------------------------------------------------ /// Called after launching a process. /// /// Allow DynamicLoader plug-ins to execute some code after the process has /// stopped for the first time on launch. - //------------------------------------------------------------------ virtual void DidLaunch() = 0; - //------------------------------------------------------------------ /// Helper function that can be used to detect when a process has called /// exec and is now a new and different process. This can be called when /// necessary to try and detect the exec. The process might be able to /// answer this question, but sometimes it might not be able and the dynamic /// loader often knows what the program entry point is. So the process and /// the dynamic loader can work together to detect this. - //------------------------------------------------------------------ virtual bool ProcessDidExec() { return false; } - //------------------------------------------------------------------ /// Get whether the process should stop when images change. /// /// When images (executables and shared libraries) get loaded or unloaded, @@ -129,13 +101,11 @@ public: /// DynamicLoader plug-in instances should return this value to ensure /// consistent debug session behaviour. /// - /// @return + /// \return /// Returns \b true if the process should stop when images /// change, \b false if the process should resume. - //------------------------------------------------------------------ bool GetStopWhenImagesChange() const; - //------------------------------------------------------------------ /// Set whether the process should stop when images change. /// /// When images (executables and shared libraries) get loaded or unloaded, @@ -144,54 +114,48 @@ public: /// process stops when images change, but this can be overridden using this /// function callback. /// - /// @param[in] stop + /// \param[in] stop /// Boolean value that indicates whether the process should stop /// when images change. - //------------------------------------------------------------------ void SetStopWhenImagesChange(bool stop); - //------------------------------------------------------------------ /// Provides a plan to step through the dynamic loader trampoline for the /// current state of \a thread. /// /// - /// @param[in] stop_others + /// \param[in] stop_others /// Whether the plan should be set to stop other threads. /// - /// @return + /// \return /// A pointer to the plan (caller owned) or NULL if we are not at such /// a trampoline. - //------------------------------------------------------------------ virtual lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, bool stop_others) = 0; - //------------------------------------------------------------------ /// Some dynamic loaders provide features where there are a group of symbols /// "equivalent to" a given symbol one of which will be chosen when the /// symbol is bound. If you want to set a breakpoint on one of these /// symbols, you really need to set it on all the equivalent symbols. /// /// - /// @param[in] original_symbol + /// \param[in] original_symbol /// The symbol for which we are finding equivalences. /// - /// @param[in] module_list + /// \param[in] module_list /// The set of modules in which to search. /// - /// @param[out] equivalent_symbols + /// \param[out] equivalent_symbols /// The equivalent symbol list - any equivalent symbols found are appended /// to this list. /// - /// @return + /// \return /// Number of equivalent symbols found. - //------------------------------------------------------------------ virtual size_t FindEquivalentSymbols(Symbol *original_symbol, ModuleList &module_list, SymbolContextList &equivalent_symbols) { return 0; } - //------------------------------------------------------------------ /// Ask if it is ok to try and load or unload an shared library (image). /// /// The dynamic loader often knows when it would be ok to try and load or @@ -199,13 +163,11 @@ public: /// plug-ins to check any current dyld state to make sure it is an ok time /// to load a shared library. /// - /// @return + /// \return /// \b true if it is currently ok to try and load a shared /// library into the process, \b false otherwise. - //------------------------------------------------------------------ virtual Status CanLoadImage() = 0; - //------------------------------------------------------------------ /// Ask if the eh_frame information for the given SymbolContext should be /// relied on even when it's the first frame in a stack unwind. /// @@ -221,44 +183,40 @@ public: /// not reliable enough -- we need to consult those function's hand-written /// eh_frame information. /// - /// @return + /// \return /// \b True if the symbol context should use eh_frame instructions /// unconditionally when unwinding from this frame. Else \b false, /// the normal lldb unwind behavior of only using eh_frame when the /// function appears in the middle of the stack. - //------------------------------------------------------------------ virtual bool AlwaysRelyOnEHUnwindInfo(SymbolContext &sym_ctx) { return false; } - //------------------------------------------------------------------ /// Retrieves the per-module TLS block for a given thread. /// - /// @param[in] module + /// \param[in] module /// The module to query TLS data for. /// - /// @param[in] thread + /// \param[in] thread /// The specific thread to query TLS data for. /// - /// @return + /// \return /// If the given 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, 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. + /// 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); - //------------------------------------------------------------------ /// Get information about the shared cache for a process, if possible. /// /// On some systems (e.g. Darwin based systems), a set of libraries that are @@ -273,27 +231,26 @@ public: /// of the cache - or it may be able to return additional information about /// the cache. /// - /// @param[out] base_address + /// \param[out] base_address /// The base address (load address) of the shared cache. /// LLDB_INVALID_ADDRESS if it cannot be determined. /// - /// @param[out] uuid + /// \param[out] uuid /// The UUID of the shared cache, if it can be determined. /// If the UUID cannot be fetched, IsValid() will be false. /// - /// @param[out] using_shared_cache + /// \param[out] using_shared_cache /// If this process is using a shared cache. /// If unknown, eLazyBoolCalculate is returned. /// - /// @param[out] private_shared_cache + /// \param[out] private_shared_cache /// A LazyBool indicating whether this process is using a /// private shared cache. /// If this information cannot be fetched, eLazyBoolCalculate. /// - /// @return + /// \return /// Returns false if this DynamicLoader cannot gather information /// about the shared cache / has no concept of a shared cache. - //------------------------------------------------------------------ virtual bool GetSharedCacheInformation(lldb::addr_t &base_address, UUID &uuid, LazyBool &using_shared_cache, LazyBool &private_shared_cache) { @@ -305,22 +262,20 @@ public: } protected: - //------------------------------------------------------------------ // Utility methods for derived classes - //------------------------------------------------------------------ /// Checks to see if the target module has changed, updates the target /// accordingly and returns the target executable module. lldb::ModuleSP GetTargetExecutable(); - /// Updates the load address of every allocatable section in @p module. + /// Updates the load address of every allocatable section in \p module. /// - /// @param module The module to traverse. + /// \param module The module to traverse. /// - /// @param link_map_addr The virtual address of the link map for the @p + /// \param link_map_addr The virtual address of the link map for the @p /// module. /// - /// @param base_addr The virtual base address @p module is loaded at. + /// \param base_addr The virtual base address \p module is loaded at. virtual void UpdateLoadedSections(lldb::ModuleSP module, lldb::addr_t link_map_addr, lldb::addr_t base_addr, @@ -331,9 +286,9 @@ protected: void UpdateLoadedSectionsCommon(lldb::ModuleSP module, lldb::addr_t base_addr, bool base_addr_is_offset); - /// Removes the loaded sections from the target in @p module. + /// Removes the loaded sections from the target in \p module. /// - /// @param module The module to traverse. + /// \param module The module to traverse. virtual void UnloadSections(const lldb::ModuleSP module); // Utility method so base classes can share implementation of UnloadSections @@ -354,9 +309,7 @@ protected: void LoadOperatingSystemPlugin(bool flush); - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ Process *m_process; ///< The process that this dynamic loader plug-in is tracking. diff --git a/include/lldb/Target/ExecutionContext.h b/include/lldb/Target/ExecutionContext.h index 167189c3a8375..0819357fab32d 100644 --- a/include/lldb/Target/ExecutionContext.h +++ b/include/lldb/Target/ExecutionContext.h @@ -1,9 +1,8 @@ //===-- ExecutionContext.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -41,8 +40,7 @@ namespace lldb_private { /// a wide variety of functions that require execution contexts. //===----------------------------------------------------------------------===// -//---------------------------------------------------------------------- -/// @class ExecutionContextRef ExecutionContext.h +/// \class ExecutionContextRef ExecutionContext.h /// "lldb/Target/ExecutionContext.h" /// A class that holds a weak reference to an execution context. /// @@ -71,44 +69,32 @@ namespace lldb_private { /// exist during a function that requires the objects. ExecutionContext /// objects should NOT be used for long term storage since they will keep /// objects alive with extra shared pointer references to these objects. -//---------------------------------------------------------------------- class ExecutionContextRef { public: - //------------------------------------------------------------------ /// Default Constructor. - //------------------------------------------------------------------ ExecutionContextRef(); - //------------------------------------------------------------------ /// Copy Constructor. - //------------------------------------------------------------------ ExecutionContextRef(const ExecutionContextRef &rhs); - //------------------------------------------------------------------ /// Construct using an ExecutionContext object that might be nullptr. /// /// If \a exe_ctx_ptr is valid, then make weak references to any valid /// objects in the ExecutionContext, otherwise no weak references to any /// execution context objects will be made. - //------------------------------------------------------------------ ExecutionContextRef(const ExecutionContext *exe_ctx_ptr); - //------------------------------------------------------------------ /// Construct using an ExecutionContext object. /// /// Make weak references to any valid objects in the ExecutionContext. - //------------------------------------------------------------------ ExecutionContextRef(const ExecutionContext &exe_ctx); - //------------------------------------------------------------------ /// Construct using the target and all the selected items inside of it (the /// process and its selected thread, and the thread's selected frame). If /// there is no selected thread, default to the first thread If there is no /// selected frame, default to the first frame. - //------------------------------------------------------------------ ExecutionContextRef(Target *target, bool adopt_selected); - //------------------------------------------------------------------ /// Construct using an execution context scope. /// /// If the ExecutionContextScope object is valid and refers to a frame, make @@ -119,10 +105,8 @@ public: /// references too the process and target. If the ExecutionContextScope /// object is valid and refers to a target, make weak references too the /// target. - //------------------------------------------------------------------ ExecutionContextRef(ExecutionContextScope *exe_scope); - //------------------------------------------------------------------ /// Construct using an execution context scope. /// /// If the ExecutionContextScope object refers to a frame, make weak @@ -132,34 +116,26 @@ public: /// refers to a process, make weak references too the process and target. If /// the ExecutionContextScope object refers to a target, make weak /// references too the target. - //------------------------------------------------------------------ ExecutionContextRef(ExecutionContextScope &exe_scope); ~ExecutionContextRef(); - //------------------------------------------------------------------ /// Assignment operator /// /// Copy all weak references in \a rhs. - //------------------------------------------------------------------ ExecutionContextRef &operator=(const ExecutionContextRef &rhs); - //------------------------------------------------------------------ /// Assignment operator from a ExecutionContext /// /// Make weak references to any strongly referenced objects in \a exe_ctx. - //------------------------------------------------------------------ ExecutionContextRef &operator=(const ExecutionContext &exe_ctx); - //------------------------------------------------------------------ /// Clear the object's state. /// /// Sets the process and thread to nullptr, and the frame index to an /// invalid value. - //------------------------------------------------------------------ void Clear(); - //------------------------------------------------------------------ /// Set accessor that creates a weak reference to the target referenced in /// \a target_sp. /// @@ -172,11 +148,9 @@ public: /// a weak reference to the target's process, use the /// ExecutionContextRef::SetContext() functions. /// - /// @see ExecutionContextRef::SetContext(const lldb::TargetSP &, bool) - //------------------------------------------------------------------ + /// \see ExecutionContextRef::SetContext(const lldb::TargetSP &, bool) void SetTargetSP(const lldb::TargetSP &target_sp); - //------------------------------------------------------------------ /// Set accessor that creates a weak reference to the process referenced in /// \a process_sp. /// @@ -189,11 +163,9 @@ public: /// a weak reference to the target, use the /// ExecutionContextRef::SetContext() functions. /// - /// @see ExecutionContextRef::SetContext(const lldb::ProcessSP &) - //------------------------------------------------------------------ + /// \see ExecutionContextRef::SetContext(const lldb::ProcessSP &) void SetProcessSP(const lldb::ProcessSP &process_sp); - //------------------------------------------------------------------ /// Set accessor that creates a weak reference to the thread referenced in /// \a thread_sp. /// @@ -206,11 +178,9 @@ public: /// a weak reference to the thread's process and target, use the /// ExecutionContextRef::SetContext() functions. /// - /// @see ExecutionContextRef::SetContext(const lldb::ThreadSP &) - //------------------------------------------------------------------ + /// \see ExecutionContextRef::SetContext(const lldb::ThreadSP &) void SetThreadSP(const lldb::ThreadSP &thread_sp); - //------------------------------------------------------------------ /// Set accessor that creates a weak reference to the frame referenced in \a /// frame_sp. /// @@ -223,8 +193,7 @@ public: /// a weak reference to the frame's thread, process and target, use the /// ExecutionContextRef::SetContext() functions. /// - /// @see ExecutionContextRef::SetContext(const lldb::StackFrameSP &) - //------------------------------------------------------------------ + /// \see ExecutionContextRef::SetContext(const lldb::StackFrameSP &) void SetFrameSP(const lldb::StackFrameSP &frame_sp); void SetTargetPtr(Target *target, bool adopt_selected); @@ -235,65 +204,51 @@ public: void SetFramePtr(StackFrame *frame); - //------------------------------------------------------------------ /// Get accessor that creates a strong reference from the weak target /// reference contained in this object. /// - /// @returns + /// \returns /// A shared pointer to a target that is not guaranteed to be valid. - //------------------------------------------------------------------ lldb::TargetSP GetTargetSP() const; - //------------------------------------------------------------------ /// Get accessor that creates a strong reference from the weak process /// reference contained in this object. /// - /// @returns + /// \returns /// A shared pointer to a process that is not guaranteed to be valid. - //------------------------------------------------------------------ lldb::ProcessSP GetProcessSP() const; - //------------------------------------------------------------------ /// Get accessor that creates a strong reference from the weak thread /// reference contained in this object. /// - /// @returns + /// \returns /// A shared pointer to a thread that is not guaranteed to be valid. - //------------------------------------------------------------------ lldb::ThreadSP GetThreadSP() const; - //------------------------------------------------------------------ /// Get accessor that creates a strong reference from the weak frame /// reference contained in this object. /// - /// @returns + /// \returns /// A shared pointer to a frame that is not guaranteed to be valid. - //------------------------------------------------------------------ lldb::StackFrameSP GetFrameSP() const; - //------------------------------------------------------------------ /// Create an ExecutionContext object from this object. /// /// Create strong references to any execution context objects that are still /// valid. Any of the returned shared pointers in the ExecutionContext - /// objects is not guaranteed to be valid. @returns + /// objects is not guaranteed to be valid. \returns /// An execution context object that has strong references to /// any valid weak references in this object. - //------------------------------------------------------------------ ExecutionContext Lock(bool thread_and_frame_only_if_stopped) const; - //------------------------------------------------------------------ /// Returns true if this object has a weak reference to a thread. The return /// value is only an indication of whether this object has a weak reference /// and does not indicate whether the weak reference is valid or not. - //------------------------------------------------------------------ bool HasThreadRef() const { return m_tid != LLDB_INVALID_THREAD_ID; } - //------------------------------------------------------------------ /// Returns true if this object has a weak reference to a frame. The return /// value is only an indication of whether this object has a weak reference /// and does not indicate whether the weak reference is valid or not. - //------------------------------------------------------------------ bool HasFrameRef() const { return m_stack_id.IsValid(); } void ClearThread() { @@ -304,9 +259,7 @@ public: void ClearFrame() { m_stack_id.Clear(); } protected: - //------------------------------------------------------------------ // Member variables - //------------------------------------------------------------------ lldb::TargetWP m_target_wp; ///< A weak reference to a target lldb::ProcessWP m_process_wp; ///< A weak reference to a process mutable lldb::ThreadWP m_thread_wp; ///< A weak reference to a thread @@ -316,8 +269,7 @@ protected: ///backing object changes }; -//---------------------------------------------------------------------- -/// @class ExecutionContext ExecutionContext.h +/// \class ExecutionContext ExecutionContext.h /// "lldb/Target/ExecutionContext.h" /// A class that contains an execution context. /// @@ -336,35 +288,24 @@ protected: /// for passing down to other functions that also require specific contexts. /// They should NOT be used for long term storage, for long term storage use /// ExecutionContextRef objects. -//---------------------------------------------------------------------- class ExecutionContext { public: - //------------------------------------------------------------------ /// Default Constructor. - //------------------------------------------------------------------ ExecutionContext(); - //------------------------------------------------------------------ // Copy constructor - //------------------------------------------------------------------ ExecutionContext(const ExecutionContext &rhs); - //------------------------------------------------------------------ // Adopt the target and optionally its current context. - //------------------------------------------------------------------ ExecutionContext(Target *t, bool fill_current_process_thread_frame = true); - //------------------------------------------------------------------ // Create execution contexts from shared pointers - //------------------------------------------------------------------ ExecutionContext(const lldb::TargetSP &target_sp, bool get_process); ExecutionContext(const lldb::ProcessSP &process_sp); ExecutionContext(const lldb::ThreadSP &thread_sp); ExecutionContext(const lldb::StackFrameSP &frame_sp); - //------------------------------------------------------------------ // Create execution contexts from weak pointers - //------------------------------------------------------------------ ExecutionContext(const lldb::TargetWP &target_wp, bool get_process); ExecutionContext(const lldb::ProcessWP &process_wp); ExecutionContext(const lldb::ThreadWP &thread_wp); @@ -379,26 +320,22 @@ public: 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 - //------------------------------------------------------------------ ExecutionContext(ExecutionContextScope *exe_scope); ExecutionContext(ExecutionContextScope &exe_scope); - //------------------------------------------------------------------ /// Construct with process, thread, and frame index. /// /// Initialize with process \a p, thread \a t, and frame index \a f. /// - /// @param[in] process + /// \param[in] process /// The process for this execution context. /// - /// @param[in] thread + /// \param[in] thread /// The thread for this execution context. /// - /// @param[in] frame + /// \param[in] frame /// The frame index for this execution context. - //------------------------------------------------------------------ ExecutionContext(Process *process, Thread *thread = nullptr, StackFrame *frame = nullptr); @@ -410,12 +347,10 @@ public: bool operator!=(const ExecutionContext &rhs) const; - //------------------------------------------------------------------ /// Clear the object's state. /// /// Sets the process and thread to nullptr, and the frame index to an /// invalid value. - //------------------------------------------------------------------ void Clear(); RegisterContext *GetRegisterContext() const; @@ -426,7 +361,6 @@ public: lldb::ByteOrder GetByteOrder() const; - //------------------------------------------------------------------ /// Returns a pointer to the target object. /// /// The returned pointer might be nullptr. Calling HasTargetScope(), @@ -434,14 +368,12 @@ public: /// validate this pointer so that this accessor can freely be used without /// having to check for nullptr each time. /// - /// @see ExecutionContext::HasTargetScope() const @see + /// \see ExecutionContext::HasTargetScope() const @see /// ExecutionContext::HasProcessScope() const @see /// ExecutionContext::HasThreadScope() const @see /// ExecutionContext::HasFrameScope() const - //------------------------------------------------------------------ Target *GetTargetPtr() const; - //------------------------------------------------------------------ /// Returns a pointer to the process object. /// /// The returned pointer might be nullptr. Calling HasProcessScope(), @@ -449,13 +381,11 @@ public: /// pointer so that this accessor can freely be used without having to check /// for nullptr each time. /// - /// @see ExecutionContext::HasProcessScope() const @see + /// \see ExecutionContext::HasProcessScope() const @see /// ExecutionContext::HasThreadScope() const @see /// ExecutionContext::HasFrameScope() const - //------------------------------------------------------------------ Process *GetProcessPtr() const; - //------------------------------------------------------------------ /// Returns a pointer to the thread object. /// /// The returned pointer might be nullptr. Calling HasThreadScope() or @@ -463,187 +393,141 @@ public: /// accessor can freely be used without having to check for nullptr each /// time. /// - /// @see ExecutionContext::HasThreadScope() const @see + /// \see ExecutionContext::HasThreadScope() const @see /// ExecutionContext::HasFrameScope() const - //------------------------------------------------------------------ Thread *GetThreadPtr() const { return m_thread_sp.get(); } - //------------------------------------------------------------------ /// Returns a pointer to the frame object. /// /// The returned pointer might be nullptr. Calling HasFrameScope(), can help /// to pre-validate this pointer so that this accessor can freely be used /// without having to check for nullptr each time. /// - /// @see ExecutionContext::HasFrameScope() const - //------------------------------------------------------------------ + /// \see ExecutionContext::HasFrameScope() const StackFrame *GetFramePtr() const { return m_frame_sp.get(); } - //------------------------------------------------------------------ /// Returns a reference to the target object. /// /// Clients should call HasTargetScope(), HasProcessScope(), /// HasThreadScope(), or HasFrameScope() prior to calling this function to /// ensure that this ExecutionContext object contains a valid target. /// - /// @see ExecutionContext::HasTargetScope() const @see + /// \see ExecutionContext::HasTargetScope() const @see /// ExecutionContext::HasProcessScope() const @see /// ExecutionContext::HasThreadScope() const @see /// ExecutionContext::HasFrameScope() const - //------------------------------------------------------------------ Target &GetTargetRef() const; - //------------------------------------------------------------------ /// Returns a reference to the process object. /// /// Clients should call HasProcessScope(), HasThreadScope(), or /// HasFrameScope() prior to calling this function to ensure that this /// ExecutionContext object contains a valid target. /// - /// @see ExecutionContext::HasProcessScope() const @see + /// \see ExecutionContext::HasProcessScope() const @see /// ExecutionContext::HasThreadScope() const @see /// ExecutionContext::HasFrameScope() const - //------------------------------------------------------------------ Process &GetProcessRef() const; - //------------------------------------------------------------------ /// Returns a reference to the thread object. /// /// Clients should call HasThreadScope(), or HasFrameScope() prior to /// calling this function to ensure that this ExecutionContext object /// contains a valid target. /// - /// @see ExecutionContext::HasThreadScope() const @see + /// \see ExecutionContext::HasThreadScope() const @see /// ExecutionContext::HasFrameScope() const - //------------------------------------------------------------------ Thread &GetThreadRef() const; - //------------------------------------------------------------------ /// Returns a reference to the thread object. /// /// Clients should call HasFrameScope() prior to calling this function to /// ensure that this ExecutionContext object contains a valid target. /// - /// @see ExecutionContext::HasFrameScope() const - //------------------------------------------------------------------ + /// \see ExecutionContext::HasFrameScope() const StackFrame &GetFrameRef() const; - //------------------------------------------------------------------ /// Get accessor to get the target shared pointer. /// /// The returned shared pointer is not guaranteed to be valid. - //------------------------------------------------------------------ const lldb::TargetSP &GetTargetSP() const { return m_target_sp; } - //------------------------------------------------------------------ /// Get accessor to get the process shared pointer. /// /// The returned shared pointer is not guaranteed to be valid. - //------------------------------------------------------------------ const lldb::ProcessSP &GetProcessSP() const { return m_process_sp; } - //------------------------------------------------------------------ /// Get accessor to get the thread shared pointer. /// /// The returned shared pointer is not guaranteed to be valid. - //------------------------------------------------------------------ const lldb::ThreadSP &GetThreadSP() const { return m_thread_sp; } - //------------------------------------------------------------------ /// Get accessor to get the frame shared pointer. /// /// The returned shared pointer is not guaranteed to be valid. - //------------------------------------------------------------------ const lldb::StackFrameSP &GetFrameSP() const { return m_frame_sp; } - //------------------------------------------------------------------ /// Set accessor to set only the target shared pointer. - //------------------------------------------------------------------ void SetTargetSP(const lldb::TargetSP &target_sp); - //------------------------------------------------------------------ /// Set accessor to set only the process shared pointer. - //------------------------------------------------------------------ void SetProcessSP(const lldb::ProcessSP &process_sp); - //------------------------------------------------------------------ /// Set accessor to set only the thread shared pointer. - //------------------------------------------------------------------ void SetThreadSP(const lldb::ThreadSP &thread_sp); - //------------------------------------------------------------------ /// Set accessor to set only the frame shared pointer. - //------------------------------------------------------------------ void SetFrameSP(const lldb::StackFrameSP &frame_sp); - //------------------------------------------------------------------ /// Set accessor to set only the target shared pointer from a target /// pointer. - //------------------------------------------------------------------ void SetTargetPtr(Target *target); - //------------------------------------------------------------------ /// Set accessor to set only the process shared pointer from a process /// pointer. - //------------------------------------------------------------------ void SetProcessPtr(Process *process); - //------------------------------------------------------------------ /// Set accessor to set only the thread shared pointer from a thread /// pointer. - //------------------------------------------------------------------ void SetThreadPtr(Thread *thread); - //------------------------------------------------------------------ /// Set accessor to set only the frame shared pointer from a frame pointer. - //------------------------------------------------------------------ void SetFramePtr(StackFrame *frame); - //------------------------------------------------------------------ // Set the execution context using a target shared pointer. // // If "target_sp" is valid, sets the target context to match and if // "get_process" is true, sets the process shared pointer if the target // currently has a process. - //------------------------------------------------------------------ void SetContext(const lldb::TargetSP &target_sp, bool get_process); - //------------------------------------------------------------------ // Set the execution context using a process shared pointer. // // If "process_sp" is valid, then set the process and target in this context. // Thread and frame contexts will be cleared. If "process_sp" is not valid, // all shared pointers are reset. - //------------------------------------------------------------------ void SetContext(const lldb::ProcessSP &process_sp); - //------------------------------------------------------------------ // Set the execution context using a thread shared pointer. // // If "thread_sp" is valid, then set the thread, process and target in this // context. The frame context will be cleared. If "thread_sp" is not valid, // all shared pointers are reset. - //------------------------------------------------------------------ void SetContext(const lldb::ThreadSP &thread_sp); - //------------------------------------------------------------------ // Set the execution context using a frame shared pointer. // // If "frame_sp" is valid, then set the frame, thread, process and target in // this context If "frame_sp" is not valid, all shared pointers are reset. - //------------------------------------------------------------------ void SetContext(const lldb::StackFrameSP &frame_sp); - //------------------------------------------------------------------ /// Returns true the ExecutionContext object contains a valid target. /// /// This function can be called after initializing an ExecutionContext /// object, and if it returns true, calls to GetTargetPtr() and /// GetTargetRef() do not need to be checked for validity. - //------------------------------------------------------------------ bool HasTargetScope() const; - //------------------------------------------------------------------ /// Returns true the ExecutionContext object contains a valid target and /// process. /// @@ -651,10 +535,8 @@ public: /// object, and if it returns true, calls to GetTargetPtr() and /// GetTargetRef(), GetProcessPtr(), and GetProcessRef(), do not need to be /// checked for validity. - //------------------------------------------------------------------ bool HasProcessScope() const; - //------------------------------------------------------------------ /// Returns true the ExecutionContext object contains a valid target, /// process, and thread. /// @@ -662,10 +544,8 @@ public: /// object, and if it returns true, calls to GetTargetPtr(), GetTargetRef(), /// GetProcessPtr(), GetProcessRef(), GetThreadPtr(), and GetThreadRef() do /// not need to be checked for validity. - //------------------------------------------------------------------ bool HasThreadScope() const; - //------------------------------------------------------------------ /// Returns true the ExecutionContext object contains a valid target, /// process, thread and frame. /// @@ -673,13 +553,10 @@ public: /// object, and if it returns true, calls to GetTargetPtr(), GetTargetRef(), /// GetProcessPtr(), GetProcessRef(), GetThreadPtr(), GetThreadRef(), /// GetFramePtr(), and GetFrameRef() do not need to be checked for validity. - //------------------------------------------------------------------ bool HasFrameScope() const; protected: - //------------------------------------------------------------------ // Member variables - //------------------------------------------------------------------ lldb::TargetSP m_target_sp; ///< The target that owns the process/thread/frame lldb::ProcessSP m_process_sp; ///< The process that owns the thread/frame lldb::ThreadSP m_thread_sp; ///< The thread that owns the frame diff --git a/include/lldb/Target/ExecutionContextScope.h b/include/lldb/Target/ExecutionContextScope.h index 3e787584be0b0..0121ce61a1d77 100644 --- a/include/lldb/Target/ExecutionContextScope.h +++ b/include/lldb/Target/ExecutionContextScope.h @@ -1,9 +1,8 @@ //===-- ExecutionContextScope.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -14,9 +13,8 @@ namespace lldb_private { -//---------------------------------------------------------------------- /// @class ExecutionContextScope ExecutionContextScope.h -/// "lldb/Symbol/ExecutionContextScope.h" Inherit from this if your object can +/// "lldb/Target/ExecutionContextScope.h" Inherit from this if your object can /// reconstruct its /// execution context. /// @@ -31,7 +29,6 @@ namespace lldb_private { /// /// Objects that adhere to this protocol can reconstruct enough of a execution /// context to allow functions that take a execution contexts to be called. -//---------------------------------------------------------------------- class ExecutionContextScope { public: virtual ~ExecutionContextScope() {} @@ -44,17 +41,15 @@ public: virtual lldb::StackFrameSP CalculateStackFrame() = 0; - //------------------------------------------------------------------ /// Reconstruct the object's execution context into \a sc. /// /// The object should fill in as much of the ExecutionContextScope as it can /// so function calls that require a execution context can be made for the /// given object. /// - /// @param[out] exe_ctx + /// \param[out] exe_ctx /// A reference to an execution context object that gets filled /// in. - //------------------------------------------------------------------ virtual void CalculateExecutionContext(ExecutionContext &exe_ctx) = 0; }; diff --git a/include/lldb/Target/FileAction.h b/include/lldb/Target/FileAction.h deleted file mode 100644 index f80f57ac588b5..0000000000000 --- a/include/lldb/Target/FileAction.h +++ /dev/null @@ -1,59 +0,0 @@ -//===-- FileAction.h --------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_Target_FileAction_h -#define liblldb_Target_FileAction_h - -#include "lldb/Utility/FileSpec.h" -#include <string> - -namespace lldb_private { - -class FileAction { -public: - enum Action { - eFileActionNone, - eFileActionClose, - eFileActionDuplicate, - eFileActionOpen - }; - - FileAction(); - - void Clear(); - - bool Close(int fd); - - bool Duplicate(int fd, int dup_fd); - - bool Open(int fd, const FileSpec &file_spec, bool read, bool write); - - int GetFD() const { return m_fd; } - - Action GetAction() const { return m_action; } - - int GetActionArgument() const { return m_arg; } - - llvm::StringRef GetPath() const; - - const FileSpec &GetFileSpec() const; - - void Dump(Stream &stream) const; - -protected: - Action m_action; // The action for this file - int m_fd; // An existing file descriptor - int m_arg; // oflag for eFileActionOpen*, dup_fd for eFileActionDuplicate - FileSpec - m_file_spec; // A file spec to use for opening after fork or posix_spawn -}; - -} // namespace lldb_private - -#endif diff --git a/include/lldb/Target/InstrumentationRuntime.h b/include/lldb/Target/InstrumentationRuntime.h index ba905cb8535df..4cee76d657bb8 100644 --- a/include/lldb/Target/InstrumentationRuntime.h +++ b/include/lldb/Target/InstrumentationRuntime.h @@ -1,9 +1,8 @@ //===-- InstrumentationRuntime.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/InstrumentationRuntimeStopInfo.h b/include/lldb/Target/InstrumentationRuntimeStopInfo.h index 7c72c9524ecac..6c2a8ad87418a 100644 --- a/include/lldb/Target/InstrumentationRuntimeStopInfo.h +++ b/include/lldb/Target/InstrumentationRuntimeStopInfo.h @@ -1,9 +1,8 @@ //===-- InstrumentationRuntimeStopInfo.h ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/JITLoader.h b/include/lldb/Target/JITLoader.h index 56f1417eddb0e..1bafd828f78e4 100644 --- a/include/lldb/Target/JITLoader.h +++ b/include/lldb/Target/JITLoader.h @@ -1,9 +1,8 @@ //===-- JITLoader.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -17,8 +16,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class JITLoader JITLoader.h "lldb/Target/JITLoader.h" +/// \class JITLoader JITLoader.h "lldb/Target/JITLoader.h" /// A plug-in interface definition class for JIT loaders. /// /// Plugins of this kind listen for code generated at runtime in the target. @@ -26,55 +24,42 @@ namespace lldb_private { /// not have information about the target's dyld and that there may be /// multiple JITLoader plugins per process, while there is at most one /// DynamicLoader. -//---------------------------------------------------------------------- class JITLoader : public PluginInterface { public: - //------------------------------------------------------------------ /// Find a JIT loader plugin for a given process. /// /// Scans the installed DynamicLoader plug-ins and tries to find all /// applicable instances for the current process. /// - /// @param[in] process + /// \param[in] process /// The process for which to try and locate a JIT loader /// plug-in instance. /// - //------------------------------------------------------------------ static void LoadPlugins(Process *process, lldb_private::JITLoaderList &list); - //------------------------------------------------------------------ /// Construct with a process. - //------------------------------------------------------------------ JITLoader(Process *process); ~JITLoader() override; - //------------------------------------------------------------------ /// Called after attaching a process. /// /// Allow JITLoader plug-ins to execute some code after attaching to a /// process. - //------------------------------------------------------------------ virtual void DidAttach() = 0; - //------------------------------------------------------------------ /// Called after launching a process. /// /// Allow JITLoader plug-ins to execute some code after the process has /// stopped for the first time on launch. - //------------------------------------------------------------------ virtual void DidLaunch() = 0; - //------------------------------------------------------------------ /// Called after a new shared object has been loaded so that it can be /// probed for JIT entry point hooks. - //------------------------------------------------------------------ virtual void ModulesDidLoad(lldb_private::ModuleList &module_list) = 0; protected: - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ Process *m_process; }; diff --git a/include/lldb/Target/JITLoaderList.h b/include/lldb/Target/JITLoaderList.h index 4b9d79bbfcabb..4cc3a9ecb91d1 100644 --- a/include/lldb/Target/JITLoaderList.h +++ b/include/lldb/Target/JITLoaderList.h @@ -1,9 +1,8 @@ //===-- JITLoaderList.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -17,11 +16,9 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class JITLoaderList JITLoaderList.h "lldb/Target/JITLoaderList.h" +/// \class JITLoaderList JITLoaderList.h "lldb/Target/JITLoaderList.h" /// /// Class used by the Process to hold a list of its JITLoaders. -//---------------------------------------------------------------------- class JITLoaderList { public: JITLoaderList(); diff --git a/include/lldb/Target/Language.h b/include/lldb/Target/Language.h index 27f40fd1ba837..6ea6029bdace0 100644 --- a/include/lldb/Target/Language.h +++ b/include/lldb/Target/Language.h @@ -1,10 +1,9 @@ //===-- Language.h ---------------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -191,6 +190,14 @@ public: virtual const char *GetLanguageSpecificTypeLookupHelp(); + // If a language can have more than one possible name for a method, this + // function can be used to enumerate them. This is useful when doing name + // lookups. + virtual std::vector<ConstString> + GetMethodNameVariants(ConstString method_name) const { + return std::vector<ConstString>(); + }; + // 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 @@ -248,12 +255,17 @@ public: static bool LanguageIsC(lldb::LanguageType language); + /// Equivalent to \c LanguageIsC||LanguageIsObjC||LanguageIsCPlusPlus. + static bool LanguageIsCFamily(lldb::LanguageType language); + static bool LanguageIsPascal(lldb::LanguageType language); // return the primary language, so if LanguageIsC(l), return eLanguageTypeC, // etc. static lldb::LanguageType GetPrimaryLanguage(lldb::LanguageType language); + static std::set<lldb::LanguageType> GetSupportedLanguages(); + static void GetLanguagesSupportingTypeSystems( std::set<lldb::LanguageType> &languages, std::set<lldb::LanguageType> &languages_for_expressions); @@ -262,9 +274,7 @@ public: GetLanguagesSupportingREPLs(std::set<lldb::LanguageType> &languages); protected: - //------------------------------------------------------------------ // Classes that inherit from Language can see and modify these - //------------------------------------------------------------------ Language(); diff --git a/include/lldb/Target/LanguageRuntime.h b/include/lldb/Target/LanguageRuntime.h index 2a2f47b853591..73c8dfa3874db 100644 --- a/include/lldb/Target/LanguageRuntime.h +++ b/include/lldb/Target/LanguageRuntime.h @@ -1,10 +1,9 @@ //===-- LanguageRuntime.h ---------------------------------------------------*- // C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -17,6 +16,7 @@ #include "lldb/Core/Value.h" #include "lldb/Core/ValueObject.h" #include "lldb/Expression/LLVMUserExpression.h" +#include "lldb/Symbol/DeclVendor.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/lldb-private.h" #include "lldb/lldb-public.h" @@ -116,9 +116,8 @@ public: bool catch_bp, bool throw_bp, bool is_internal = false); - static Breakpoint::BreakpointPreconditionSP - CreateExceptionPrecondition(lldb::LanguageType language, bool catch_bp, - bool throw_bp); + static lldb::BreakpointPreconditionSP + GetExceptionPrecondition(lldb::LanguageType language, bool throw_bp); virtual lldb::ValueObjectSP GetExceptionObjectForThread( lldb::ThreadSP thread_sp) { @@ -134,17 +133,32 @@ public: Target &GetTargetRef() { return m_process->GetTarget(); } + virtual DeclVendor *GetDeclVendor() { return nullptr; } + virtual lldb::BreakpointResolverSP CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp, bool throw_bp) = 0; - virtual lldb::SearchFilterSP CreateExceptionSearchFilter(); + virtual lldb::SearchFilterSP CreateExceptionSearchFilter() { + return m_process->GetTarget().GetSearchFilterForModule(nullptr); + } virtual bool GetTypeBitSize(const CompilerType &compiler_type, uint64_t &size) { return false; } - virtual bool IsRuntimeSupportValue(ValueObject &valobj) { return false; } + virtual void SymbolsDidLoad(const ModuleList &module_list) { return; } + + virtual lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, + bool stop_others) = 0; + + /// Identify whether a name is a runtime value that should not be hidden by + /// from the user interface. + virtual bool IsWhitelistedRuntimeValue(ConstString name) { return false; } + + virtual llvm::Optional<CompilerType> GetRuntimeType(CompilerType base_type) { + return llvm::None; + } virtual void ModulesDidLoad(const ModuleList &module_list) {} @@ -162,10 +176,18 @@ public: return false; } + // Given the name of a runtime symbol (e.g. in Objective-C, an ivar offset + // symbol), try to determine from the runtime what the value of that symbol + // would be. Useful when the underlying binary is stripped. + virtual lldb::addr_t LookupRuntimeSymbol(ConstString name) { + return LLDB_INVALID_ADDRESS; + } + + virtual bool isA(const void *ClassID) const { return ClassID == &ID; } + static char ID; + protected: - //------------------------------------------------------------------ // Classes that inherit from LanguageRuntime can see and modify these - //------------------------------------------------------------------ LanguageRuntime(Process *process); Process *m_process; diff --git a/include/lldb/Target/Memory.h b/include/lldb/Target/Memory.h index d5e6c105f76d3..e62b8ef9c773e 100644 --- a/include/lldb/Target/Memory.h +++ b/include/lldb/Target/Memory.h @@ -1,33 +1,26 @@ //===-- Memory.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef liblldb_Memory_h_ #define liblldb_Memory_h_ +#include "lldb/Utility/RangeMap.h" +#include "lldb/lldb-private.h" #include <map> #include <mutex> #include <vector> - -#include "lldb/Core/RangeMap.h" -#include "lldb/lldb-private.h" - namespace lldb_private { -//---------------------------------------------------------------------- // A class to track memory that was read from a live process between // runs. -//---------------------------------------------------------------------- class MemoryCache { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ MemoryCache(Process &process); ~MemoryCache(); @@ -54,9 +47,7 @@ protected: typedef std::map<lldb::addr_t, lldb::DataBufferSP> BlockMap; typedef RangeArray<lldb::addr_t, lldb::addr_t, 4> InvalidRanges; typedef Range<lldb::addr_t, lldb::addr_t> AddrRange; - //------------------------------------------------------------------ // Classes that inherit from MemoryCache can see and modify these - //------------------------------------------------------------------ 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 @@ -114,16 +105,12 @@ protected: RangeVector<lldb::addr_t, uint32_t> m_reserved_blocks; }; -//---------------------------------------------------------------------- // A class that can track allocated memory and give out allocated memory // without us having to make an allocate/deallocate call every time we need // some memory in a process that is being debugged. -//---------------------------------------------------------------------- class AllocatedMemoryCache { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ AllocatedMemoryCache(Process &process); ~AllocatedMemoryCache(); @@ -141,9 +128,7 @@ protected: AllocatedBlockSP AllocatePage(uint32_t byte_size, uint32_t permissions, uint32_t chunk_size, Status &error); - //------------------------------------------------------------------ // Classes that inherit from MemoryCache can see and modify these - //------------------------------------------------------------------ Process &m_process; std::recursive_mutex m_mutex; typedef std::multimap<uint32_t, AllocatedBlockSP> PermissionsToBlockMap; diff --git a/include/lldb/Target/MemoryHistory.h b/include/lldb/Target/MemoryHistory.h index cb3e900533576..501751c55e80a 100644 --- a/include/lldb/Target/MemoryHistory.h +++ b/include/lldb/Target/MemoryHistory.h @@ -1,10 +1,9 @@ //===-- MemoryHistory.h ---------------------------------------------------*- //C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/MemoryRegionInfo.h b/include/lldb/Target/MemoryRegionInfo.h index a57c4678bb370..5cab2efea77c9 100644 --- a/include/lldb/Target/MemoryRegionInfo.h +++ b/include/lldb/Target/MemoryRegionInfo.h @@ -1,19 +1,18 @@ //===-- MemoryRegionInfo.h ---------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef lldb_MemoryRegionInfo_h #define lldb_MemoryRegionInfo_h -#include "lldb/Core/RangeMap.h" -#include "llvm/Support/FormatProviders.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/RangeMap.h" +#include "llvm/Support/FormatProviders.h" namespace lldb_private { class MemoryRegionInfo { @@ -45,7 +44,7 @@ public: OptionalBool GetMapped() const { return m_mapped; } - const ConstString &GetName() const { return m_name; } + ConstString GetName() const { return m_name; } void SetReadable(OptionalBool val) { m_read = val; } @@ -65,10 +64,8 @@ public: void SetBlocksize(lldb::offset_t blocksize) { m_blocksize = blocksize; } - //---------------------------------------------------------------------- // 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) @@ -80,10 +77,8 @@ public: 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; diff --git a/include/lldb/Target/ModuleCache.h b/include/lldb/Target/ModuleCache.h index a060937e0614a..1196169113936 100644 --- a/include/lldb/Target/ModuleCache.h +++ b/include/lldb/Target/ModuleCache.h @@ -1,9 +1,8 @@ //===-- ModuleCache.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -26,8 +25,7 @@ namespace lldb_private { class Module; class UUID; -//---------------------------------------------------------------------- -/// @class ModuleCache ModuleCache.h "lldb/Target/ModuleCache.h" +/// \class ModuleCache ModuleCache.h "lldb/Target/ModuleCache.h" /// A module cache class. /// /// Caches locally modules that are downloaded from remote targets. Each @@ -45,7 +43,6 @@ class UUID; /// /tmp/lldb/remote- /// linux/.cache/30C94DC6-6A1F-E951-80C3-D68D2B89E576-D5AE213C/libc.so.6 /// Sysroot view: /tmp/lldb/remote-linux/ubuntu/lib/x86_64-linux-gnu/libc.so.6 -//---------------------------------------------------------------------- class ModuleCache { public: diff --git a/include/lldb/Target/ObjCLanguageRuntime.h b/include/lldb/Target/ObjCLanguageRuntime.h deleted file mode 100644 index 9eebf94630432..0000000000000 --- a/include/lldb/Target/ObjCLanguageRuntime.h +++ /dev/null @@ -1,419 +0,0 @@ -//===-- ObjCLanguageRuntime.h -----------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_ObjCLanguageRuntime_h_ -#define liblldb_ObjCLanguageRuntime_h_ - -#include <functional> -#include <map> -#include <memory> -#include <unordered_set> - -#include "llvm/Support/Casting.h" - -#include "lldb/Core/PluginInterface.h" -#include "lldb/Core/ThreadSafeDenseMap.h" -#include "lldb/Symbol/CompilerType.h" -#include "lldb/Symbol/DeclVendor.h" -#include "lldb/Symbol/Type.h" -#include "lldb/Target/LanguageRuntime.h" -#include "lldb/lldb-private.h" - -class CommandObjectObjC_ClassTable_Dump; - -namespace lldb_private { - -class UtilityFunction; - -class ObjCLanguageRuntime : public LanguageRuntime { -public: - enum class ObjCRuntimeVersions { - eObjC_VersionUnknown = 0, - eAppleObjC_V1 = 1, - eAppleObjC_V2 = 2 - }; - - typedef lldb::addr_t ObjCISA; - - class ClassDescriptor; - typedef std::shared_ptr<ClassDescriptor> ClassDescriptorSP; - - // the information that we want to support retrieving from an ObjC class this - // needs to be pure virtual since there are at least 2 different - // implementations of the runtime, and more might come - class ClassDescriptor { - public: - ClassDescriptor() - : m_is_kvo(eLazyBoolCalculate), m_is_cf(eLazyBoolCalculate), - m_type_wp() {} - - virtual ~ClassDescriptor() = default; - - virtual ConstString GetClassName() = 0; - - virtual ClassDescriptorSP GetSuperclass() = 0; - - virtual ClassDescriptorSP GetMetaclass() const = 0; - - // virtual if any implementation has some other version-specific rules but - // for the known v1/v2 this is all that needs to be done - virtual bool IsKVO() { - if (m_is_kvo == eLazyBoolCalculate) { - const char *class_name = GetClassName().AsCString(); - if (class_name && *class_name) - m_is_kvo = - (LazyBool)(strstr(class_name, "NSKVONotifying_") == class_name); - } - return (m_is_kvo == eLazyBoolYes); - } - - // virtual if any implementation has some other version-specific rules but - // for the known v1/v2 this is all that needs to be done - virtual bool IsCFType() { - if (m_is_cf == eLazyBoolCalculate) { - const char *class_name = GetClassName().AsCString(); - if (class_name && *class_name) - m_is_cf = (LazyBool)(strcmp(class_name, "__NSCFType") == 0 || - strcmp(class_name, "NSCFType") == 0); - } - return (m_is_cf == eLazyBoolYes); - } - - virtual bool IsValid() = 0; - - virtual bool GetTaggedPointerInfo(uint64_t *info_bits = nullptr, - uint64_t *value_bits = nullptr, - uint64_t *payload = nullptr) = 0; - - virtual uint64_t GetInstanceSize() = 0; - - // use to implement version-specific additional constraints on pointers - virtual bool CheckPointer(lldb::addr_t value, uint32_t ptr_size) const { - return true; - } - - virtual ObjCISA GetISA() = 0; - - // This should return true iff the interface could be completed - virtual bool - Describe(std::function<void(ObjCISA)> const &superclass_func, - std::function<bool(const char *, const char *)> const - &instance_method_func, - std::function<bool(const char *, const char *)> const - &class_method_func, - std::function<bool(const char *, const char *, lldb::addr_t, - uint64_t)> const &ivar_func) const { - return false; - } - - lldb::TypeSP GetType() { return m_type_wp.lock(); } - - void SetType(const lldb::TypeSP &type_sp) { m_type_wp = type_sp; } - - struct iVarDescriptor { - ConstString m_name; - CompilerType m_type; - uint64_t m_size; - int32_t m_offset; - }; - - virtual size_t GetNumIVars() { return 0; } - - virtual iVarDescriptor GetIVarAtIndex(size_t idx) { - return iVarDescriptor(); - } - - protected: - bool IsPointerValid(lldb::addr_t value, uint32_t ptr_size, - bool allow_NULLs = false, bool allow_tagged = false, - bool check_version_specific = false) const; - - private: - LazyBool m_is_kvo; - LazyBool m_is_cf; - lldb::TypeWP m_type_wp; - }; - - class EncodingToType { - public: - virtual ~EncodingToType(); - - virtual CompilerType RealizeType(ClangASTContext &ast_ctx, const char *name, - bool for_expression); - virtual CompilerType RealizeType(const char *name, bool for_expression); - - virtual CompilerType RealizeType(clang::ASTContext &ast_ctx, - const char *name, bool for_expression) = 0; - - protected: - std::unique_ptr<ClangASTContext> m_scratch_ast_ctx_ap; - }; - - class ObjCExceptionPrecondition : public Breakpoint::BreakpointPrecondition { - public: - ObjCExceptionPrecondition(); - - ~ObjCExceptionPrecondition() override = default; - - bool EvaluatePrecondition(StoppointCallbackContext &context) override; - void GetDescription(Stream &stream, lldb::DescriptionLevel level) override; - Status ConfigurePrecondition(Args &args) override; - - protected: - void AddClassName(const char *class_name); - - private: - std::unordered_set<std::string> m_class_names; - }; - - class TaggedPointerVendor { - public: - virtual ~TaggedPointerVendor() = default; - - virtual bool IsPossibleTaggedPointer(lldb::addr_t ptr) = 0; - - virtual ObjCLanguageRuntime::ClassDescriptorSP - GetClassDescriptor(lldb::addr_t ptr) = 0; - - protected: - TaggedPointerVendor() = default; - - private: - DISALLOW_COPY_AND_ASSIGN(TaggedPointerVendor); - }; - - ~ObjCLanguageRuntime() override; - - virtual TaggedPointerVendor *GetTaggedPointerVendor() { return nullptr; } - - typedef std::shared_ptr<EncodingToType> EncodingToTypeSP; - - virtual EncodingToTypeSP GetEncodingToType(); - - virtual ClassDescriptorSP GetClassDescriptor(ValueObject &in_value); - - ClassDescriptorSP GetNonKVOClassDescriptor(ValueObject &in_value); - - virtual ClassDescriptorSP - GetClassDescriptorFromClassName(const ConstString &class_name); - - virtual ClassDescriptorSP GetClassDescriptorFromISA(ObjCISA isa); - - ClassDescriptorSP GetNonKVOClassDescriptor(ObjCISA isa); - - lldb::LanguageType GetLanguageType() const override { - return lldb::eLanguageTypeObjC; - } - - virtual bool IsModuleObjCLibrary(const lldb::ModuleSP &module_sp) = 0; - - virtual bool ReadObjCLibrary(const lldb::ModuleSP &module_sp) = 0; - - virtual bool HasReadObjCLibrary() = 0; - - virtual lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, - bool stop_others) = 0; - - lldb::addr_t LookupInMethodCache(lldb::addr_t class_addr, lldb::addr_t sel); - - void AddToMethodCache(lldb::addr_t class_addr, lldb::addr_t sel, - lldb::addr_t impl_addr); - - TypeAndOrName LookupInClassNameCache(lldb::addr_t class_addr); - - void AddToClassNameCache(lldb::addr_t class_addr, const char *name, - lldb::TypeSP type_sp); - - void AddToClassNameCache(lldb::addr_t class_addr, - const TypeAndOrName &class_or_type_name); - - lldb::TypeSP LookupInCompleteClassCache(ConstString &name); - - virtual UtilityFunction *CreateObjectChecker(const char *) = 0; - - virtual ObjCRuntimeVersions GetRuntimeVersion() const { - return ObjCRuntimeVersions::eObjC_VersionUnknown; - } - - bool IsValidISA(ObjCISA isa) { - UpdateISAToDescriptorMap(); - return m_isa_to_descriptor.count(isa) > 0; - } - - virtual void UpdateISAToDescriptorMapIfNeeded() = 0; - - void UpdateISAToDescriptorMap() { - if (m_process && m_process->GetStopID() != m_isa_to_descriptor_stop_id) { - UpdateISAToDescriptorMapIfNeeded(); - } - } - - virtual ObjCISA GetISA(const ConstString &name); - - virtual ConstString GetActualTypeName(ObjCISA isa); - - virtual ObjCISA GetParentClass(ObjCISA isa); - - virtual DeclVendor *GetDeclVendor() { return nullptr; } - - // Finds the byte offset of the child_type ivar in parent_type. If it can't - // find the offset, returns LLDB_INVALID_IVAR_OFFSET. - - virtual size_t GetByteOffsetForIvar(CompilerType &parent_qual_type, - const char *ivar_name); - - // Given the name of an Objective-C runtime symbol (e.g., ivar offset - // symbol), try to determine from the runtime what the value of that symbol - // would be. Useful when the underlying binary is stripped. - virtual lldb::addr_t LookupRuntimeSymbol(const ConstString &name) { - return LLDB_INVALID_ADDRESS; - } - - bool HasNewLiteralsAndIndexing() { - if (m_has_new_literals_and_indexing == eLazyBoolCalculate) { - if (CalculateHasNewLiteralsAndIndexing()) - m_has_new_literals_and_indexing = eLazyBoolYes; - else - m_has_new_literals_and_indexing = eLazyBoolNo; - } - - return (m_has_new_literals_and_indexing == eLazyBoolYes); - } - - virtual void SymbolsDidLoad(const ModuleList &module_list) { - m_negative_complete_class_cache.clear(); - } - - bool GetTypeBitSize(const CompilerType &compiler_type, - uint64_t &size) override; - -protected: - //------------------------------------------------------------------ - // Classes that inherit from ObjCLanguageRuntime can see and modify these - //------------------------------------------------------------------ - ObjCLanguageRuntime(Process *process); - - virtual bool CalculateHasNewLiteralsAndIndexing() { return false; } - - bool ISAIsCached(ObjCISA isa) const { - return m_isa_to_descriptor.find(isa) != m_isa_to_descriptor.end(); - } - - bool AddClass(ObjCISA isa, const ClassDescriptorSP &descriptor_sp) { - if (isa != 0) { - m_isa_to_descriptor[isa] = descriptor_sp; - return true; - } - return false; - } - - bool AddClass(ObjCISA isa, const ClassDescriptorSP &descriptor_sp, - const char *class_name); - - bool AddClass(ObjCISA isa, const ClassDescriptorSP &descriptor_sp, - uint32_t class_name_hash) { - if (isa != 0) { - m_isa_to_descriptor[isa] = descriptor_sp; - m_hash_to_isa_map.insert(std::make_pair(class_name_hash, isa)); - return true; - } - return false; - } - -private: - // We keep a map of <Class,Selector>->Implementation so we don't have to call - // the resolver function over and over. - - // FIXME: We need to watch for the loading of Protocols, and flush the cache - // for any - // class that we see so changed. - - struct ClassAndSel { - ClassAndSel() { - sel_addr = LLDB_INVALID_ADDRESS; - class_addr = LLDB_INVALID_ADDRESS; - } - - ClassAndSel(lldb::addr_t in_sel_addr, lldb::addr_t in_class_addr) - : class_addr(in_class_addr), sel_addr(in_sel_addr) {} - - bool operator==(const ClassAndSel &rhs) { - if (class_addr == rhs.class_addr && sel_addr == rhs.sel_addr) - return true; - else - return false; - } - - bool operator<(const ClassAndSel &rhs) const { - if (class_addr < rhs.class_addr) - return true; - else if (class_addr > rhs.class_addr) - return false; - else { - if (sel_addr < rhs.sel_addr) - return true; - else - return false; - } - } - - lldb::addr_t class_addr; - lldb::addr_t sel_addr; - }; - - typedef std::map<ClassAndSel, lldb::addr_t> MsgImplMap; - typedef std::map<ObjCISA, ClassDescriptorSP> ISAToDescriptorMap; - typedef std::multimap<uint32_t, ObjCISA> HashToISAMap; - typedef ISAToDescriptorMap::iterator ISAToDescriptorIterator; - typedef HashToISAMap::iterator HashToISAIterator; - typedef ThreadSafeDenseMap<void *, uint64_t> TypeSizeCache; - - MsgImplMap m_impl_cache; - LazyBool m_has_new_literals_and_indexing; - ISAToDescriptorMap m_isa_to_descriptor; - HashToISAMap m_hash_to_isa_map; - TypeSizeCache m_type_size_cache; - -protected: - uint32_t m_isa_to_descriptor_stop_id; - - typedef std::map<ConstString, lldb::TypeWP> CompleteClassMap; - CompleteClassMap m_complete_class_cache; - - struct ConstStringSetHelpers { - size_t operator()(const ConstString &arg) const // for hashing - { - return (size_t)arg.GetCString(); - } - bool operator()(const ConstString &arg1, - const ConstString &arg2) const // for equality - { - return arg1.operator==(arg2); - } - }; - typedef std::unordered_set<ConstString, ConstStringSetHelpers, - ConstStringSetHelpers> - CompleteClassSet; - CompleteClassSet m_negative_complete_class_cache; - - ISAToDescriptorIterator GetDescriptorIterator(const ConstString &name); - - friend class ::CommandObjectObjC_ClassTable_Dump; - - std::pair<ISAToDescriptorIterator, ISAToDescriptorIterator> - GetDescriptorIteratorPair(bool update_if_needed = true); - - void ReadObjCLibraryIfNeeded(const ModuleList &module_list); - - DISALLOW_COPY_AND_ASSIGN(ObjCLanguageRuntime); -}; - -} // namespace lldb_private - -#endif // liblldb_ObjCLanguageRuntime_h_ diff --git a/include/lldb/Target/OperatingSystem.h b/include/lldb/Target/OperatingSystem.h index 4d73bb3906ee6..c75d1ca2e5f48 100644 --- a/include/lldb/Target/OperatingSystem.h +++ b/include/lldb/Target/OperatingSystem.h @@ -1,10 +1,9 @@ //===-- OperatingSystem.h ----------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -17,8 +16,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class OperatingSystem OperatingSystem.h "lldb/Target/OperatingSystem.h" +/// \class OperatingSystem OperatingSystem.h "lldb/Target/OperatingSystem.h" /// A plug-in interface definition class for halted OS helpers. /// /// Halted OS plug-ins can be used by any process to locate and create @@ -26,36 +24,29 @@ namespace lldb_private { /// This is commonly used when attaching to an operating system that is /// halted, such as when debugging over JTAG or connecting to low level kernel /// debug services. -//---------------------------------------------------------------------- class OperatingSystem : public PluginInterface { public: - //------------------------------------------------------------------ /// Find a halted OS plugin for a given process. /// /// Scans the installed OperatingSystem plug-ins and tries to find an /// instance that matches the current target triple and executable. /// - /// @param[in] process + /// \param[in] process /// The process for which to try and locate a halted OS /// plug-in instance. /// - /// @param[in] plugin_name + /// \param[in] plugin_name /// An optional name of a specific halted OS plug-in that /// should be used. If NULL, pick the best plug-in. - //------------------------------------------------------------------ static OperatingSystem *FindPlugin(Process *process, const char *plugin_name); - //------------------------------------------------------------------ // Class Methods - //------------------------------------------------------------------ OperatingSystem(Process *process); ~OperatingSystem() override; - //------------------------------------------------------------------ // Plug-in Methods - //------------------------------------------------------------------ virtual bool UpdateThreadList(ThreadList &old_thread_list, ThreadList &real_thread_list, ThreadList &new_thread_list) = 0; @@ -75,9 +66,7 @@ public: virtual bool IsOperatingSystemPluginThread(const lldb::ThreadSP &thread_sp); protected: - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ Process *m_process; ///< The process that this dynamic loader plug-in is tracking. private: diff --git a/include/lldb/Target/PathMappingList.h b/include/lldb/Target/PathMappingList.h index 29e6ef191e275..d1759667f1f5d 100644 --- a/include/lldb/Target/PathMappingList.h +++ b/include/lldb/Target/PathMappingList.h @@ -1,9 +1,8 @@ //===-- PathMappingList.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,9 +21,7 @@ public: typedef void (*ChangedCallback)(const PathMappingList &path_list, void *baton); - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ PathMappingList(); PathMappingList(ChangedCallback callback, void *callback_baton); @@ -35,7 +32,7 @@ public: const PathMappingList &operator=(const PathMappingList &rhs); - void Append(const ConstString &path, const ConstString &replacement, + void Append(ConstString path, ConstString replacement, bool notify); void Append(const PathMappingList &rhs, bool notify); @@ -52,43 +49,40 @@ public: bool GetPathsAtIndex(uint32_t idx, ConstString &path, ConstString &new_path) const; - void Insert(const ConstString &path, const ConstString &replacement, + void Insert(ConstString path, ConstString replacement, uint32_t insert_idx, bool notify); bool Remove(size_t index, bool notify); - bool Remove(const ConstString &path, bool notify); + bool Remove(ConstString path, bool notify); - bool Replace(const ConstString &path, const ConstString &replacement, + bool Replace(ConstString path, ConstString replacement, bool notify); - bool Replace(const ConstString &path, const ConstString &replacement, + bool Replace(ConstString path, ConstString replacement, uint32_t index, bool notify); - bool RemapPath(const ConstString &path, ConstString &new_path) const; + bool RemapPath(ConstString path, ConstString &new_path) const; - //------------------------------------------------------------------ /// Remaps a source file given \a path into \a new_path. /// /// Remaps \a path if any source remappings match. This function /// does NOT stat the file system so it can be used in tight loops /// where debug info is being parsed. /// - /// @param[in] path + /// \param[in] path /// The original source file path to try and remap. /// - /// @param[out] new_path + /// \param[out] new_path /// The newly remapped filespec that is may or may not exist. /// - /// @return + /// \return /// /b true if \a path was successfully located and \a new_path /// is filled in with a new source path, \b false otherwise. - //------------------------------------------------------------------ bool RemapPath(llvm::StringRef path, std::string &new_path) const; bool RemapPath(const char *, std::string &) const = delete; bool ReverseRemapPath(const FileSpec &file, FileSpec &fixed) const; - //------------------------------------------------------------------ /// Finds a source file given a file spec using the path remappings. /// /// Tries to resolve \a orig_spec by checking the path remappings. @@ -97,20 +91,19 @@ public: /// or are even on the local file system, so use this function /// sparingly (not in a tight debug info parsing loop). /// - /// @param[in] orig_spec + /// \param[in] orig_spec /// The original source file path to try and remap. /// - /// @param[out] new_spec + /// \param[out] new_spec /// The newly remapped filespec that is guaranteed to exist. /// - /// @return + /// \return /// /b true if \a orig_spec was successfully located and /// \a new_spec is filled in with an existing file spec, /// \b false otherwise. - //------------------------------------------------------------------ bool FindFile(const FileSpec &orig_spec, FileSpec &new_spec) const; - uint32_t FindIndexForPath(const ConstString &path) const; + uint32_t FindIndexForPath(ConstString path) const; uint32_t GetModificationID() const { return m_mod_id; } @@ -120,9 +113,9 @@ protected: typedef collection::iterator iterator; typedef collection::const_iterator const_iterator; - iterator FindIteratorForPath(const ConstString &path); + iterator FindIteratorForPath(ConstString path); - const_iterator FindIteratorForPath(const ConstString &path) const; + const_iterator FindIteratorForPath(ConstString path) const; collection m_pairs; ChangedCallback m_callback; diff --git a/include/lldb/Target/Platform.h b/include/lldb/Target/Platform.h index 3dbeef73f0aba..3ba58c0ec741e 100644 --- a/include/lldb/Target/Platform.h +++ b/include/lldb/Target/Platform.h @@ -1,9 +1,8 @@ //===-- Platform.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,12 +23,17 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Timeout.h" +#include "lldb/Utility/UserIDResolver.h" #include "lldb/lldb-private-forward.h" #include "lldb/lldb-public.h" #include "llvm/Support/VersionTuple.h" namespace lldb_private { +class ProcessInstanceInfo; +class ProcessInstanceInfoList; +class ProcessInstanceInfoMatch; + class ModuleCache; enum MmapFlags { eMmapFlagsPrivate = 1, eMmapFlagsAnon = 2 }; @@ -49,32 +53,26 @@ public: typedef std::shared_ptr<PlatformProperties> PlatformPropertiesSP; typedef llvm::SmallVector<lldb::addr_t, 6> MmapArgList; -//---------------------------------------------------------------------- -/// @class Platform Platform.h "lldb/Target/Platform.h" +/// \class Platform Platform.h "lldb/Target/Platform.h" /// A plug-in interface definition class for debug platform that /// includes many platform abilities such as: -/// @li getting platform information such as supported architectures, +/// \li getting platform information such as supported architectures, /// supported binary file formats and more -/// @li launching new processes -/// @li attaching to existing processes -/// @li download/upload files -/// @li execute shell commands -/// @li listing and getting info for existing processes -/// @li attaching and possibly debugging the platform's kernel -//---------------------------------------------------------------------- +/// \li launching new processes +/// \li attaching to existing processes +/// \li download/upload files +/// \li execute shell commands +/// \li listing and getting info for existing processes +/// \li attaching and possibly debugging the platform's kernel class Platform : public PluginInterface { public: - //------------------------------------------------------------------ /// Default Constructor - //------------------------------------------------------------------ Platform(bool is_host_platform); - //------------------------------------------------------------------ /// Destructor. /// /// The destructor is virtual since this class is designed to be inherited /// from by the plug-in instance. - //------------------------------------------------------------------ ~Platform() override; static void Initialize(); @@ -83,7 +81,6 @@ public: static const PlatformPropertiesSP &GetGlobalPlatformProperties(); - //------------------------------------------------------------------ /// Get the native host platform plug-in. /// /// There should only be one of these for each host that LLDB runs upon that @@ -93,7 +90,6 @@ public: /// /// This platform will be used as the default platform when launching or /// attaching to processes unless another platform is specified. - //------------------------------------------------------------------ static lldb::PlatformSP GetHostPlatform(); static lldb::PlatformSP @@ -104,38 +100,33 @@ public: static void SetHostPlatform(const lldb::PlatformSP &platform_sp); // Find an existing platform plug-in by name - static lldb::PlatformSP Find(const ConstString &name); + static lldb::PlatformSP Find(ConstString name); - static lldb::PlatformSP Create(const ConstString &name, Status &error); + static lldb::PlatformSP Create(ConstString name, Status &error); static lldb::PlatformSP Create(const ArchSpec &arch, ArchSpec *platform_arch_ptr, Status &error); - //------------------------------------------------------------------------ /// Augments the triple either with information from platform or the host /// system (if platform is null). - //------------------------------------------------------------------------ static ArchSpec GetAugmentedArchSpec(Platform *platform, llvm::StringRef triple); - //------------------------------------------------------------------ /// Find a platform plugin for a given process. /// /// Scans the installed Platform plug-ins and tries to find an instance that /// can be used for \a process /// - /// @param[in] process + /// \param[in] process /// The process for which to try and locate a platform /// plug-in instance. /// - /// @param[in] plugin_name + /// \param[in] plugin_name /// An optional name of a specific platform plug-in that /// should be used. If nullptr, pick the best plug-in. - //------------------------------------------------------------------ // static lldb::PlatformSP - // FindPlugin (Process *process, const ConstString &plugin_name); + // FindPlugin (Process *process, ConstString plugin_name); - //------------------------------------------------------------------ /// Set the target's executable based off of the existing architecture /// information in \a target given a path to an executable \a exe_file. /// @@ -148,15 +139,13 @@ public: /// application bundles or executable wrappers can also be inspected for the /// actual application binary within the bundle that should be used. /// - /// @return + /// \return /// Returns \b true if this Platform plug-in was able to find /// a suitable executable, \b false otherwise. - //------------------------------------------------------------------ virtual Status ResolveExecutable(const ModuleSpec &module_spec, lldb::ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr); - //------------------------------------------------------------------ /// Find a symbol file given a symbol file module specification. /// /// Each platform might have tricks to find symbol files for an executable @@ -164,7 +153,7 @@ public: /// support symbol files that are bundles and know how to extract the right /// symbol file given a bundle. /// - /// @param[in] target + /// \param[in] target /// The target in which we are trying to resolve the symbol file. /// The target has a list of modules that we might be able to /// use in order to help find the right symbol file. If the @@ -177,7 +166,7 @@ public: /// is specified, we can use a variety of tricks to locate the /// symbols in an SDK, PDK, or other development kit location. /// - /// @param[in] sym_spec + /// \param[in] sym_spec /// A module spec that describes some information about the /// symbol file we are trying to resolve. The ModuleSpec might /// contain the following: @@ -196,24 +185,20 @@ public: /// a symbol file, or resolve an symbol file in a /// symbol file bundle. /// - /// @param[out] sym_file + /// \param[out] sym_file /// The resolved symbol file spec if the returned error /// indicates success. /// - /// @return + /// \return /// Returns an error that describes success or failure. - //------------------------------------------------------------------ virtual Status ResolveSymbolFile(Target &target, const ModuleSpec &sym_spec, FileSpec &sym_file); - //------------------------------------------------------------------ /// Resolves the FileSpec to a (possibly) remote path. Remote platforms must /// override this to resolve to a path on the remote side. - //------------------------------------------------------------------ virtual bool ResolveRemotePath(const FileSpec &platform_path, FileSpec &resolved_platform_path); - //------------------------------------------------------------------ /// Get the OS version from a connected platform. /// /// Some platforms might not be connected to a remote platform, but can @@ -221,7 +206,6 @@ public: /// platforms that will run native programs on the current host, but the /// simulator might be simulating a different OS. The \a process parameter /// might be specified to help to determine the OS version. - //------------------------------------------------------------------ virtual llvm::VersionTuple GetOSVersion(Process *process = nullptr); bool SetOSVersion(llvm::VersionTuple os_version); @@ -239,23 +223,19 @@ public: virtual const char *GetDescription() = 0; - //------------------------------------------------------------------ /// Report the current status for this platform. /// /// The returned string usually involves returning the OS version (if /// available), and any SDK directory that might be being used for local /// file caching, and if connected a quick blurb about what this platform is /// connected to. - //------------------------------------------------------------------ virtual void GetStatus(Stream &strm); - //------------------------------------------------------------------ // Subclasses must be able to fetch the current OS version // // Remote classes must be connected for this to succeed. Local subclasses // don't need to override this function as it will just call the // HostInfo::GetOSVersion(). - //------------------------------------------------------------------ virtual bool GetRemoteOSVersion() { return false; } virtual bool GetRemoteOSBuildString(std::string &s) { @@ -277,20 +257,30 @@ public: virtual bool SetRemoteWorkingDirectory(const FileSpec &working_dir); - virtual const char *GetUserName(uint32_t uid); + /// Retrieve the system include directories on this platform for the + /// given language. + /// + /// \param[in] lang + /// The language for which the include directories should be queried. + /// + /// \param[out] directories + /// The include directories for this system. + virtual std::vector<std::string> + GetSystemIncludeDirectories(lldb::LanguageType lang) { + return {}; + } - virtual const char *GetGroupName(uint32_t gid); + virtual UserIDResolver &GetUserIDResolver() = 0; - //------------------------------------------------------------------ /// Locate a file for a platform. /// /// The default implementation of this function will return the same file /// patch in \a local_file as was in \a platform_file. /// - /// @param[in] platform_file + /// \param[in] platform_file /// The platform file path to locate and cache locally. /// - /// @param[in] uuid_ptr + /// \param[in] uuid_ptr /// If we know the exact UUID of the file we are looking for, it /// can be specified. If it is not specified, we might now know /// the exact file. The UUID is usually some sort of MD5 checksum @@ -299,25 +289,22 @@ public: /// file queries to ensure we are finding the correct file, not /// just a file at the correct path. /// - /// @param[out] local_file + /// \param[out] local_file /// A locally cached version of the platform file. For platforms /// that describe the current host computer, this will just be /// the same file. For remote platforms, this file might come from /// and SDK directory, or might need to be sync'ed over to the /// current machine for efficient debugging access. /// - /// @return + /// \return /// An error object. - //------------------------------------------------------------------ virtual Status GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid_ptr, FileSpec &local_file); - //---------------------------------------------------------------------- // Locate the scripting resource given a module specification. // // Locating the file should happen only on the local computer or using the // current computers global settings. - //---------------------------------------------------------------------- virtual FileSpecList LocateExecutableScriptingResources(Target *target, Module &module, Stream *feedback_stream); @@ -335,70 +322,56 @@ public: virtual Status DisconnectRemote(); - //------------------------------------------------------------------ /// Get the platform's supported architectures in the order in which they /// should be searched. /// - /// @param[in] idx + /// \param[in] idx /// A zero based architecture index /// - /// @param[out] arch + /// \param[out] arch /// A copy of the architecture at index if the return value is /// \b true. /// - /// @return + /// \return /// \b true if \a arch was filled in and is valid, \b false /// otherwise. - //------------------------------------------------------------------ virtual bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) = 0; virtual size_t GetSoftwareBreakpointTrapOpcode(Target &target, BreakpointSite *bp_site); - //------------------------------------------------------------------ /// Launch a new process on a platform, not necessarily for debugging, it /// could be just for running the process. - //------------------------------------------------------------------ virtual Status LaunchProcess(ProcessLaunchInfo &launch_info); - //------------------------------------------------------------------ /// Perform expansion of the command-line for this launch info This can /// potentially involve wildcard expansion - // environment variable replacement, and whatever other - // argument magic the platform defines as part of its typical - // user experience - //------------------------------------------------------------------ + /// environment variable replacement, and whatever other + /// argument magic the platform defines as part of its typical + /// user experience virtual Status ShellExpandArguments(ProcessLaunchInfo &launch_info); - //------------------------------------------------------------------ /// Kill process on a platform. - //------------------------------------------------------------------ virtual Status KillProcess(const lldb::pid_t pid); - //------------------------------------------------------------------ /// Lets a platform answer if it is compatible with a given architecture and /// the target triple contained within. - //------------------------------------------------------------------ virtual bool IsCompatibleArchitecture(const ArchSpec &arch, bool exact_arch_match, ArchSpec *compatible_arch_ptr); - //------------------------------------------------------------------ /// Not all platforms will support debugging a process by spawning somehow /// halted for a debugger (specified using the "eLaunchFlagDebug" launch /// flag) and then attaching. If your platform doesn't support this, /// override this function and return false. - //------------------------------------------------------------------ virtual bool CanDebugProcess() { return true; } - //------------------------------------------------------------------ /// Subclasses do not need to implement this function as it uses the /// Platform::LaunchProcess() followed by Platform::Attach (). Remote /// platforms will want to subclass this function in order to be able to /// intercept STDIO and possibly launch a separate process that will debug /// the debuggee. - //------------------------------------------------------------------ virtual lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, Target *target, // Can be nullptr, if nullptr create a new @@ -411,7 +384,6 @@ public: lldb_private::Target *target, lldb_private::Status &error); - //------------------------------------------------------------------ /// Attach to an existing process using a process ID. /// /// Each platform subclass needs to implement this function and attempt to @@ -420,15 +392,14 @@ public: /// attached to the process, or an empty shared pointer with an appropriate /// error. /// - /// @param[in] pid + /// \param[in] pid /// The process ID that we should attempt to attach to. /// - /// @return + /// \return /// An appropriate ProcessSP containing a valid shared pointer /// to the default Process subclass for the platform that is /// attached to the process, or an empty shared pointer with an /// appropriate error fill into the \a error object. - //------------------------------------------------------------------ virtual lldb::ProcessSP Attach(ProcessAttachInfo &attach_info, Debugger &debugger, Target *target, // Can be nullptr, if nullptr @@ -436,7 +407,6 @@ public: // use existing one Status &error) = 0; - //------------------------------------------------------------------ /// Attach to an existing process by process name. /// /// This function is not meant to be overridden by Process subclasses. It @@ -445,38 +415,31 @@ public: /// the attach. If DoAttach returns \b true, then Process::DidAttach() will /// be called. /// - /// @param[in] process_name + /// \param[in] process_name /// A process name to match against the current process list. /// - /// @return + /// \return /// Returns \a pid if attaching was successful, or /// LLDB_INVALID_PROCESS_ID if attaching fails. - //------------------------------------------------------------------ // virtual lldb::ProcessSP // Attach (const char *process_name, // bool wait_for_launch, // Status &error) = 0; - //------------------------------------------------------------------ // The base class Platform will take care of the host platform. Subclasses // will need to fill in the remote case. - //------------------------------------------------------------------ virtual uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &proc_infos); virtual bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info); - //------------------------------------------------------------------ // Set a breakpoint on all functions that can end up creating a thread for // this platform. This is needed when running expressions and also for // process control. - //------------------------------------------------------------------ virtual lldb::BreakpointSP SetThreadCreationBreakpoint(Target &target); - //------------------------------------------------------------------ // Given a target, find the local SDK directory if one exists on the current // host. - //------------------------------------------------------------------ virtual lldb_private::ConstString GetSDKDirectory(lldb_private::Target &target) { return lldb_private::ConstString(); @@ -503,11 +466,9 @@ public: m_os_version_set_while_connected = m_system_arch.IsValid(); } - //--------------------------------------------------------------------------- /// If the triple contains not specify the vendor, os, and environment /// parts, we "augment" these using information from the platform and return /// the resulting ArchSpec object. - //--------------------------------------------------------------------------- ArchSpec GetAugmentedArchSpec(llvm::StringRef triple); // Used for column widths @@ -516,13 +477,13 @@ public: // Used for column widths size_t GetMaxGroupIDNameLength() const { return m_max_gid_name_len; } - const ConstString &GetSDKRootDirectory() const { return m_sdk_sysroot; } + ConstString GetSDKRootDirectory() const { return m_sdk_sysroot; } - void SetSDKRootDirectory(const ConstString &dir) { m_sdk_sysroot = dir; } + void SetSDKRootDirectory(ConstString dir) { m_sdk_sysroot = dir; } - const ConstString &GetSDKBuild() const { return m_sdk_build; } + ConstString GetSDKBuild() const { return m_sdk_build; } - void SetSDKBuild(const ConstString &sdk_build) { m_sdk_build = sdk_build; } + void SetSDKBuild(ConstString sdk_build) { m_sdk_build = sdk_build; } // Override this to return true if your platform supports Clang modules. You // may also need to override AddClangModuleCompilationOptions to pass the @@ -579,7 +540,7 @@ public: virtual uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, uint64_t src_len, Status &error) { error.SetErrorStringWithFormat( - "Platform::ReadFile() is not supported in the %s platform", + "Platform::WriteFile() is not supported in the %s platform", GetName().GetCString()); return -1; } @@ -593,7 +554,6 @@ public: CreateSymlink(const FileSpec &src, // The name of the link is in src const FileSpec &dst); // The symlink points to dst - //---------------------------------------------------------------------- /// Install a file or directory to the remote system. /// /// Install is similar to Platform::PutFile(), but it differs in that if an @@ -602,10 +562,10 @@ public: /// application/framework/shared library, then this extra registration can /// be done. /// - /// @param[in] src + /// \param[in] src /// The source file/directory to install on the remote system. /// - /// @param[in] dst + /// \param[in] dst /// The destination file/directory where \a src will be installed. /// If \a dst has no filename specified, then its filename will /// be set from \a src. It \a dst has no directory specified, it @@ -614,9 +574,8 @@ public: /// platform working directory will be prepended to the relative /// directory. /// - /// @return + /// \return /// An error object that describes anything that went wrong. - //---------------------------------------------------------------------- virtual Status Install(const FileSpec &src, const FileSpec &dst); virtual Environment GetEnvironment(); @@ -690,9 +649,8 @@ public: virtual const lldb::UnixSignalsSP &GetRemoteUnixSignals(); - const lldb::UnixSignalsSP &GetUnixSignals(); + lldb::UnixSignalsSP GetUnixSignals(); - //------------------------------------------------------------------ /// Locate a queue name given a thread's qaddr /// /// On a system using libdispatch ("Grand Central Dispatch") style queues, a @@ -702,23 +660,21 @@ public: /// dispatch_qaddr this Platform method will locate the queue name and /// provide that. /// - /// @param[in] process + /// \param[in] process /// A process is required for reading memory. /// - /// @param[in] dispatch_qaddr + /// \param[in] dispatch_qaddr /// The dispatch_qaddr for this thread. /// - /// @return + /// \return /// The name of the queue, if there is one. An empty string /// means that this thread is not associated with a dispatch /// queue. - //------------------------------------------------------------------ virtual std::string GetQueueNameForThreadQAddress(Process *process, lldb::addr_t dispatch_qaddr) { return ""; } - //------------------------------------------------------------------ /// Locate a queue ID given a thread's qaddr /// /// On a system using libdispatch ("Grand Central Dispatch") style queues, a @@ -728,22 +684,20 @@ public: /// dispatch_qaddr this Platform method will locate the queue ID and provide /// that. /// - /// @param[in] process + /// \param[in] process /// A process is required for reading memory. /// - /// @param[in] dispatch_qaddr + /// \param[in] dispatch_qaddr /// The dispatch_qaddr for this thread. /// - /// @return + /// \return /// The queue_id for this thread, if this thread is associated /// with a dispatch queue. Else LLDB_INVALID_QUEUE_ID is returned. - //------------------------------------------------------------------ virtual lldb::queue_id_t GetQueueIDForThreadQAddress(Process *process, lldb::addr_t dispatch_qaddr) { return LLDB_INVALID_QUEUE_ID; } - //------------------------------------------------------------------ /// Provide a list of trap handler function names for this platform /// /// The unwinder needs to treat trap handlers specially -- the stack frame @@ -761,105 +715,96 @@ public: /// signal handler routines as needed. For most Unix platforms, add /// _sigtramp. /// - /// @return + /// \return /// A list of symbol names. The list may be empty. - //------------------------------------------------------------------ virtual const std::vector<ConstString> &GetTrapHandlerSymbolNames(); - //------------------------------------------------------------------ /// Find a support executable that may not live within in the standard /// locations related to LLDB. /// /// Executable might exist within the Platform SDK directories, or in /// standard tool directories within the current IDE that is running LLDB. /// - /// @param[in] basename + /// \param[in] basename /// The basename of the executable to locate in the current /// platform. /// - /// @return + /// \return /// A FileSpec pointing to the executable on disk, or an invalid /// FileSpec if the executable cannot be found. - //------------------------------------------------------------------ virtual FileSpec LocateExecutable(const char *basename) { return FileSpec(); } - //------------------------------------------------------------------ /// Allow the platform to set preferred memory cache line size. If non-zero /// (and the user has not set cache line size explicitly), this value will /// be used as the cache line size for memory reads. - //------------------------------------------------------------------ virtual uint32_t GetDefaultMemoryCacheLineSize() { return 0; } - //------------------------------------------------------------------ /// Load a shared library into this process. /// /// Try and load a shared library into the current process. This call might /// fail in the dynamic loader plug-in says it isn't safe to try and load /// shared libraries at the moment. /// - /// @param[in] process + /// \param[in] process /// The process to load the image. /// - /// @param[in] local_file + /// \param[in] local_file /// The file spec that points to the shared library that you want /// to load if the library is located on the host. The library will /// be copied over to the location specified by remote_file or into /// the current working directory with the same filename if the /// remote_file isn't specified. /// - /// @param[in] remote_file + /// \param[in] remote_file /// If local_file is specified then the location where the library /// should be copied over from the host. If local_file isn't /// specified, then the path for the shared library on the target /// what you want to load. /// - /// @param[out] error + /// \param[out] error /// An error object that gets filled in with any errors that /// might occur when trying to load the shared library. /// - /// @return + /// \return /// A token that represents the shared library that can be /// later used to unload the shared library. A value of /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared /// library can't be opened. - //------------------------------------------------------------------ uint32_t LoadImage(lldb_private::Process *process, const lldb_private::FileSpec &local_file, const lldb_private::FileSpec &remote_file, lldb_private::Status &error); - //------------------------------------------------------------------ /// Load a shared library specified by base name into this process, /// looking by hand along a set of paths. /// - /// @param[in] process + /// \param[in] process /// The process to load the image. /// - /// @param[in] library_name + /// \param[in] library_name /// The name of the library to look for. If library_name is an /// absolute path, the basename will be extracted and searched for /// along the paths. This emulates the behavior of the loader when /// given an install name and a set (e.g. DYLD_LIBRARY_PATH provided) of /// alternate paths. /// - /// @param[in] path_list + /// \param[in] path_list /// The list of paths to use to search for the library. First /// match wins. /// - /// @param[out] error + /// \param[out] error /// An error object that gets filled in with any errors that /// might occur when trying to load the shared library. /// - /// @param[out] loaded_path + /// \param[out] loaded_path /// If non-null, the path to the dylib that was successfully loaded /// is stored in this path. /// - /// @return + /// \return /// A token that represents the shared library which can be /// passed to UnloadImage. A value of /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared /// library can't be opened. - //------------------------------------------------------------------ uint32_t LoadImageUsingPaths(lldb_private::Process *process, const lldb_private::FileSpec &library_name, const std::vector<std::string> &paths, @@ -875,22 +820,20 @@ public: virtual Status UnloadImage(lldb_private::Process *process, uint32_t image_token); - //------------------------------------------------------------------ /// Connect to all processes waiting for a debugger to attach /// /// If the platform have a list of processes waiting for a debugger to /// connect to them then connect to all of these pending processes. /// - /// @param[in] debugger + /// \param[in] debugger /// The debugger used for the connect. /// - /// @param[out] error + /// \param[out] error /// If an error occurred during the connect then this object will /// contain the error message. /// - /// @return + /// \return /// The number of processes we are successfully connected to. - //------------------------------------------------------------------ virtual size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger, lldb_private::Status &error); @@ -917,8 +860,6 @@ protected: // 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; size_t m_max_gid_name_len; bool m_supports_rsync; @@ -932,7 +873,6 @@ protected: bool m_calculated_trap_handlers; const std::unique_ptr<ModuleCache> m_module_cache; - //------------------------------------------------------------------ /// Ask the Platform subclass to fill in the list of trap handler names /// /// For most Unix user process environments, this will be a single function @@ -944,71 +884,8 @@ protected: /// The base class Platform ivar m_trap_handlers should be updated by the /// Platform subclass when this method is called. If there are no /// predefined trap handlers, this method may be a no-op. - //------------------------------------------------------------------ virtual void CalculateTrapHandlerSymbolNames() = 0; - const char *GetCachedUserName(uint32_t uid) { - 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 - // trying) - const auto pos = m_uid_map.find(uid); - return ((pos != m_uid_map.end()) ? pos->second.AsCString("") : nullptr); - } - - const char *SetCachedUserName(uint32_t uid, const char *name, - size_t name_len) { - 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(); - } - - void SetUserNameNotFound(uint32_t uid) { - std::lock_guard<std::mutex> guard(m_mutex); - m_uid_map[uid] = ConstString(); - } - - void ClearCachedUserNames() { - std::lock_guard<std::mutex> guard(m_mutex); - m_uid_map.clear(); - } - - const char *GetCachedGroupName(uint32_t gid) { - 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 - // trying) - const auto pos = m_gid_map.find(gid); - return ((pos != m_gid_map.end()) ? pos->second.AsCString("") : nullptr); - } - - const char *SetCachedGroupName(uint32_t gid, const char *name, - size_t name_len) { - 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(); - } - - void SetGroupNameNotFound(uint32_t gid) { - std::lock_guard<std::mutex> guard(m_mutex); - m_gid_map[gid] = ConstString(); - } - - void ClearCachedGroupNames() { - std::lock_guard<std::mutex> guard(m_mutex); - m_gid_map.clear(); - } - Status GetCachedExecutable(ModuleSpec &module_spec, lldb::ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, Platform &remote_platform); @@ -1072,14 +949,12 @@ public: return platform_sp; } - //------------------------------------------------------------------ /// Select the active platform. /// /// In order to debug remotely, other platform's can be remotely connected /// to and set as the selected platform for any subsequent debugging. This /// allows connection to remote targets and allows the ability to discover /// process info, launch and attach to remote processes. - //------------------------------------------------------------------ lldb::PlatformSP GetSelectedPlatform() { std::lock_guard<std::recursive_mutex> guard(m_mutex); if (!m_selected_platform_sp && !m_platforms.empty()) diff --git a/include/lldb/Target/Process.h b/include/lldb/Target/Process.h index be72b9a9c747a..f85069ea09067 100644 --- a/include/lldb/Target/Process.h +++ b/include/lldb/Target/Process.h @@ -1,9 +1,8 @@ //===-- Process.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -29,14 +28,13 @@ #include "lldb/Core/ThreadSafeValue.h" #include "lldb/Core/UserSettingsController.h" #include "lldb/Host/HostThread.h" +#include "lldb/Host/ProcessLaunchInfo.h" #include "lldb/Host/ProcessRunLock.h" #include "lldb/Interpreter/Options.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/InstrumentationRuntime.h" #include "lldb/Target/Memory.h" -#include "lldb/Target/ProcessInfo.h" -#include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Target/QueueList.h" #include "lldb/Target/ThreadList.h" #include "lldb/Utility/ArchSpec.h" @@ -44,9 +42,11 @@ #include "lldb/Utility/Event.h" #include "lldb/Utility/Listener.h" #include "lldb/Utility/NameMatches.h" +#include "lldb/Utility/ProcessInfo.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StructuredData.h" #include "lldb/Utility/TraceOptions.h" +#include "lldb/Utility/UserIDResolver.h" #include "lldb/lldb-private.h" #include "llvm/ADT/ArrayRef.h" @@ -56,9 +56,7 @@ namespace lldb_private { template <typename B, typename S> struct Range; -//---------------------------------------------------------------------- // ProcessProperties -//---------------------------------------------------------------------- class ProcessProperties : public Properties { public: // Pass nullptr for "process" if the ProcessProperties are to be the global @@ -68,36 +66,22 @@ public: ~ProcessProperties() override; bool GetDisableMemoryCache() const; - uint64_t GetMemoryCacheLineSize() const; - Args GetExtraStartupCommands() const; - void SetExtraStartupCommands(const Args &args); - FileSpec GetPythonOSPluginPath() const; - void SetPythonOSPluginPath(const FileSpec &file); - bool GetIgnoreBreakpointsInExpressions() const; - void SetIgnoreBreakpointsInExpressions(bool ignore); - bool GetUnwindOnErrorInExpressions() const; - void SetUnwindOnErrorInExpressions(bool ignore); - bool GetStopOnSharedLibraryEvents() const; - void SetStopOnSharedLibraryEvents(bool stop); - bool GetDetachKeepsStopped() const; - void SetDetachKeepsStopped(bool keep_stopped); - bool GetWarningsOptimization() const; - bool GetStopOnExec() const; + std::chrono::seconds GetUtilityExpressionTimeout() const; protected: static void OptionValueChangedCallback(void *baton, @@ -108,68 +92,9 @@ protected: typedef std::shared_ptr<ProcessProperties> ProcessPropertiesSP; -//---------------------------------------------------------------------- -// ProcessInstanceInfo -// -// Describes an existing process and any discoverable information that pertains -// to that process. -//---------------------------------------------------------------------- -class ProcessInstanceInfo : public ProcessInfo { -public: - ProcessInstanceInfo() - : ProcessInfo(), m_euid(UINT32_MAX), m_egid(UINT32_MAX), - m_parent_pid(LLDB_INVALID_PROCESS_ID) {} - - ProcessInstanceInfo(const char *name, const ArchSpec &arch, lldb::pid_t pid) - : ProcessInfo(name, arch, pid), m_euid(UINT32_MAX), m_egid(UINT32_MAX), - m_parent_pid(LLDB_INVALID_PROCESS_ID) {} - - void Clear() { - ProcessInfo::Clear(); - m_euid = UINT32_MAX; - m_egid = UINT32_MAX; - m_parent_pid = LLDB_INVALID_PROCESS_ID; - } - - uint32_t GetEffectiveUserID() const { return m_euid; } - - uint32_t GetEffectiveGroupID() const { return m_egid; } - - bool EffectiveUserIDIsValid() const { return m_euid != UINT32_MAX; } - - bool EffectiveGroupIDIsValid() const { return m_egid != UINT32_MAX; } - - void SetEffectiveUserID(uint32_t uid) { m_euid = uid; } - - void SetEffectiveGroupID(uint32_t gid) { m_egid = gid; } - - lldb::pid_t GetParentProcessID() const { return m_parent_pid; } - - void SetParentProcessID(lldb::pid_t pid) { m_parent_pid = pid; } - - bool ParentProcessIDIsValid() const { - return m_parent_pid != LLDB_INVALID_PROCESS_ID; - } - - void Dump(Stream &s, Platform *platform) const; - - static void DumpTableHeader(Stream &s, Platform *platform, bool show_args, - bool verbose); - - void DumpAsTableRow(Stream &s, Platform *platform, bool show_args, - bool verbose) const; - -protected: - uint32_t m_euid; - uint32_t m_egid; - lldb::pid_t m_parent_pid; -}; - -//---------------------------------------------------------------------- // ProcessAttachInfo // // Describes any information that is required to attach to a process. -//---------------------------------------------------------------------- class ProcessAttachInfo : public ProcessInstanceInfo { public: @@ -299,94 +224,6 @@ public: lldb_private::LazyBool disable_aslr; }; -//---------------------------------------------------------------------- -// ProcessInstanceInfoMatch -// -// A class to help matching one ProcessInstanceInfo to another. -//---------------------------------------------------------------------- - -class ProcessInstanceInfoMatch { -public: - ProcessInstanceInfoMatch() - : m_match_info(), m_name_match_type(NameMatch::Ignore), - m_match_all_users(false) {} - - ProcessInstanceInfoMatch(const char *process_name, - NameMatch process_name_match_type) - : m_match_info(), m_name_match_type(process_name_match_type), - m_match_all_users(false) { - m_match_info.GetExecutableFile().SetFile(process_name, - FileSpec::Style::native); - } - - ProcessInstanceInfo &GetProcessInfo() { return m_match_info; } - - const ProcessInstanceInfo &GetProcessInfo() const { return m_match_info; } - - bool GetMatchAllUsers() const { return m_match_all_users; } - - void SetMatchAllUsers(bool b) { m_match_all_users = b; } - - NameMatch GetNameMatchType() const { return m_name_match_type; } - - void SetNameMatchType(NameMatch name_match_type) { - m_name_match_type = name_match_type; - } - - bool NameMatches(const char *process_name) const; - - bool Matches(const ProcessInstanceInfo &proc_info) const; - - bool MatchAllProcesses() const; - void Clear(); - -protected: - ProcessInstanceInfo m_match_info; - NameMatch m_name_match_type; - bool m_match_all_users; -}; - -class ProcessInstanceInfoList { -public: - ProcessInstanceInfoList() = default; - - void Clear() { m_infos.clear(); } - - size_t GetSize() { return m_infos.size(); } - - void Append(const ProcessInstanceInfo &info) { m_infos.push_back(info); } - - const char *GetProcessNameAtIndex(size_t idx) { - return ((idx < m_infos.size()) ? m_infos[idx].GetName() : nullptr); - } - - size_t GetProcessNameLengthAtIndex(size_t idx) { - return ((idx < m_infos.size()) ? m_infos[idx].GetNameLength() : 0); - } - - lldb::pid_t GetProcessIDAtIndex(size_t idx) { - return ((idx < m_infos.size()) ? m_infos[idx].GetProcessID() : 0); - } - - bool GetInfoAtIndex(size_t idx, ProcessInstanceInfo &info) { - if (idx < m_infos.size()) { - info = m_infos[idx]; - return true; - } - return false; - } - - // You must ensure "idx" is valid before calling this function - const ProcessInstanceInfo &GetProcessInfoAtIndex(size_t idx) const { - assert(idx < m_infos.size()); - return m_infos[idx]; - } - -protected: - typedef std::vector<ProcessInstanceInfo> collection; - collection m_infos; -}; - // This class tracks the Modification state of the process. Things that can // currently modify the program are running the program (which will up the // StopID) and writing memory (which will up the MemoryID.) @@ -511,10 +348,8 @@ inline bool operator!=(const ProcessModID &lhs, const ProcessModID &rhs) { return (!lhs.StopIDEqual(rhs) || !lhs.MemoryIDEqual(rhs)); } -//---------------------------------------------------------------------- -/// @class Process Process.h "lldb/Target/Process.h" +/// \class Process Process.h "lldb/Target/Process.h" /// A plug-in interface definition class for debugging a process. -//---------------------------------------------------------------------- class Process : public std::enable_shared_from_this<Process>, public ProcessProperties, public UserID, @@ -530,9 +365,7 @@ class Process : public std::enable_shared_from_this<Process>, friend class ThreadList; public: - //------------------------------------------------------------------ /// Broadcaster event bits definitions. - //------------------------------------------------------------------ enum { eBroadcastBitStateChanged = (1 << 0), eBroadcastBitInterrupt = (1 << 1), @@ -548,9 +381,7 @@ public: eBroadcastInternalStateControlResume = (1 << 2) }; - //------------------------------------------------------------------ /// Process warning types. - //------------------------------------------------------------------ enum Warnings { eWarningsOptimization = 1 }; typedef Range<lldb::addr_t, lldb::addr_t> LoadRange; @@ -570,14 +401,11 @@ public: return GetStaticBroadcasterClass(); } -//------------------------------------------------------------------ /// A notification structure that can be used by clients to listen /// for changes in a process's lifetime. /// -/// @see RegisterNotificationCallbacks (const Notifications&) @see +/// \see RegisterNotificationCallbacks (const Notifications&) @see /// UnregisterNotificationCallbacks (const Notifications&) -//------------------------------------------------------------------ -#ifndef SWIG typedef struct { void *baton; void (*initialize)(void *baton, Process *process); @@ -594,9 +422,9 @@ public: ~ProcessEventData() override; - static const ConstString &GetFlavorString(); + static ConstString GetFlavorString(); - const ConstString &GetFlavor() const override; + ConstString GetFlavor() const override; lldb::ProcessSP GetProcessSP() const { return m_process_wp.lock(); } @@ -662,27 +490,20 @@ public: DISALLOW_COPY_AND_ASSIGN(ProcessEventData); }; -#endif // SWIG - //------------------------------------------------------------------ /// Construct with a shared pointer to a target, and the Process listener. /// Uses the Host UnixSignalsSP by default. - //------------------------------------------------------------------ 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, lldb::ListenerSP listener_sp, const lldb::UnixSignalsSP &unix_signals_sp); - //------------------------------------------------------------------ /// Destructor. /// /// The destructor is virtual since this class is designed to be inherited /// from by the plug-in instance. - //------------------------------------------------------------------ ~Process() override; static void SettingsInitialize(); @@ -691,7 +512,6 @@ public: static const ProcessPropertiesSP &GetGlobalProperties(); - //------------------------------------------------------------------ /// Find a Process plug-in that can debug \a module using the currently /// selected architecture. /// @@ -699,22 +519,20 @@ public: /// Process plug-in interface and returns the first instance that can debug /// the file. /// - /// @param[in] module_sp + /// \param[in] module_sp /// The module shared pointer that this process will debug. /// - /// @param[in] plugin_name + /// \param[in] plugin_name /// If nullptr, select the best plug-in for the binary. If non-nullptr /// then look for a plugin whose PluginInfo's name matches /// this string. /// - /// @see Process::CanDebug () - //------------------------------------------------------------------ + /// \see Process::CanDebug () static lldb::ProcessSP FindPlugin(lldb::TargetSP target_sp, llvm::StringRef plugin_name, lldb::ListenerSP listener_sp, const FileSpec *crash_file_path); - //------------------------------------------------------------------ /// Static function that can be used with the \b host function /// Host::StartMonitoringChildProcess (). /// @@ -725,7 +543,6 @@ public: /// callback = Process::SetHostProcessExitStatus /// pid = Process::GetID() /// monitor_signals = false - //------------------------------------------------------------------ static bool SetProcessExitStatus(lldb::pid_t pid, // The process ID we want to monitor bool exited, @@ -738,38 +555,31 @@ public: uint32_t GetUniqueID() const { return m_process_unique_id; } - //------------------------------------------------------------------ /// Check if a plug-in instance can debug the file in \a module. /// /// Each plug-in is given a chance to say whether it can debug the file in /// \a module. If the Process plug-in instance can debug a file on the /// current system, it should return \b true. /// - /// @return + /// \return /// Returns \b true if this Process plug-in instance can /// debug the executable, \b false otherwise. - //------------------------------------------------------------------ virtual bool CanDebug(lldb::TargetSP target, bool plugin_specified_by_name) = 0; - //------------------------------------------------------------------ /// This object is about to be destroyed, do any necessary cleanup. /// /// Subclasses that override this method should always call this superclass /// method. - //------------------------------------------------------------------ virtual void Finalize(); - //------------------------------------------------------------------ /// Return whether this object is valid (i.e. has not been finalized.) /// - /// @return + /// \return /// Returns \b true if this Process has not been finalized /// and \b false otherwise. - //------------------------------------------------------------------ bool IsValid() const { return !m_finalize_called; } - //------------------------------------------------------------------ /// Return a multi-word command object that can be used to expose plug-in /// specific commands. /// @@ -778,14 +588,12 @@ public: /// /// (lldb) process command <args> /// - /// @return + /// \return /// A CommandObject which can be one of the concrete subclasses /// of CommandObject like CommandObjectRaw, CommandObjectParsed, /// or CommandObjectMultiword. - //------------------------------------------------------------------ virtual CommandObject *GetPluginCommandObject() { return nullptr; } - //------------------------------------------------------------------ /// Launch a new process. /// /// Launch a new process by spawning a new process using the target object's @@ -798,14 +606,13 @@ public: /// launching. If DoLaunch returns \b true, then Process::DidLaunch() will /// be called. /// - /// @param[in] launch_info + /// \param[in] launch_info /// Details regarding the environment, STDIN/STDOUT/STDERR /// redirection, working path, etc. related to the requested launch. /// - /// @return + /// \return /// An error object. Call GetID() to get the process ID if /// the error object is success. - //------------------------------------------------------------------ virtual Status Launch(ProcessLaunchInfo &launch_info); virtual Status LoadCore(); @@ -818,7 +625,6 @@ public: return error; } - //------------------------------------------------------------------ // FUTURE WORK: GetLoadImageUtilityFunction are the first use we've // had of having other plugins cache data in the Process. This is handy for // long-living plugins - like the Platform - which manage interactions whose @@ -833,27 +639,23 @@ public: // whether the registree should be notified of the Process' demise. // // We are postponing designing this till we have at least a second use case. - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// Get the cached UtilityFunction that assists in loading binary images /// into the process. /// - /// @param[in] platform + /// \param[in] platform /// The platform fetching the UtilityFunction. - /// @param[in] factory + /// \param[in] factory /// A function that will be called only once per-process in a /// thread-safe way to create the UtilityFunction if it has not /// been initialized yet. /// - /// @return + /// \return /// The cached utility function or null if the platform is not the /// same as the target's platform. - //------------------------------------------------------------------ UtilityFunction *GetLoadImageUtilityFunction( Platform *platform, llvm::function_ref<std::unique_ptr<UtilityFunction>()> factory); - //------------------------------------------------------------------ /// Get the dynamic loader plug-in for this process. /// /// The default action is to let the DynamicLoader plug-ins check the main @@ -861,29 +663,24 @@ public: /// Subclasses can override this if inspecting the executable is not /// desired, or if Process subclasses can only use a specific DynamicLoader /// plug-in. - //------------------------------------------------------------------ virtual DynamicLoader *GetDynamicLoader(); - //------------------------------------------------------------------ // Returns AUXV structure found in many ELF-based environments. // // The default action is to return an empty data buffer. // - // @return - // A data buffer containing the contents of the AUXV data. - //------------------------------------------------------------------ - virtual const lldb::DataBufferSP GetAuxvData(); + // \return + // A data extractor containing the contents of the AUXV data. + virtual DataExtractor GetAuxvData(); - //------------------------------------------------------------------ /// Sometimes processes know how to retrieve and load shared libraries. This /// is normally done by DynamicLoader plug-ins, but sometimes the connection /// to the process allows retrieving this information. The dynamic loader /// plug-ins can use this function if they can't determine the current /// shared library load state. /// - /// @return + /// \return /// The number of shared libraries that were loaded - //------------------------------------------------------------------ virtual size_t LoadModules() { return 0; } virtual size_t LoadModules(LoadedModuleInfoList &) { return 0; } @@ -892,16 +689,13 @@ protected: virtual JITLoaderList &GetJITLoaders(); public: - //------------------------------------------------------------------ /// Get the system runtime plug-in for this process. /// - /// @return + /// \return /// Returns a pointer to the SystemRuntime plugin for this Process /// if one is available. Else returns nullptr. - //------------------------------------------------------------------ virtual SystemRuntime *GetSystemRuntime(); - //------------------------------------------------------------------ /// Attach to an existing process using the process attach info. /// /// This function is not meant to be overridden by Process subclasses. It @@ -910,36 +704,32 @@ public: /// char *) will be called to actually do the attach. If DoAttach returns \b /// true, then Process::DidAttach() will be called. /// - /// @param[in] pid + /// \param[in] pid /// The process ID that we should attempt to attach to. /// - /// @return + /// \return /// Returns \a pid if attaching was successful, or /// LLDB_INVALID_PROCESS_ID if attaching fails. - //------------------------------------------------------------------ virtual Status Attach(ProcessAttachInfo &attach_info); - //------------------------------------------------------------------ /// Attach to a remote system via a URL /// - /// @param[in] strm + /// \param[in] strm /// A stream where output intended for the user /// (if the driver has a way to display that) generated during /// the connection. This may be nullptr if no output is needed.A /// - /// @param[in] remote_url + /// \param[in] remote_url /// The URL format that we are connecting to. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ virtual Status ConnectRemote(Stream *strm, llvm::StringRef remote_url); bool GetShouldDetach() const { return m_should_detach; } void SetShouldDetach(bool b) { m_should_detach = b; } - //------------------------------------------------------------------ /// Get the image information address for the current process. /// /// Some runtimes have system functions that can help dynamic loaders locate @@ -948,14 +738,12 @@ public: /// opposed to the DynamicLoader interface) to ensure that remote debugging /// can take advantage of this functionality. /// - /// @return + /// \return /// The address of the dynamic loader information, or /// LLDB_INVALID_ADDRESS if this is not supported by this /// interface. - //------------------------------------------------------------------ virtual lldb::addr_t GetImageInfoAddress(); - //------------------------------------------------------------------ /// Called when the process is about to broadcast a public stop. /// /// There are public and private stops. Private stops are when the process @@ -968,49 +756,39 @@ public: /// more). This function can be overriden and allows process subclasses to /// do something before the eBroadcastBitStateChanged event is sent to /// public clients. - //------------------------------------------------------------------ virtual void WillPublicStop() {} -//------------------------------------------------------------------ /// Register for process and thread notifications. /// /// Clients can register notification callbacks by filling out a /// Process::Notifications structure and calling this function. /// -/// @param[in] callbacks +/// \param[in] callbacks /// A structure that contains the notification baton and /// callback functions. /// -/// @see Process::Notifications -//------------------------------------------------------------------ -#ifndef SWIG +/// \see Process::Notifications void RegisterNotificationCallbacks(const Process::Notifications &callbacks); -#endif -//------------------------------------------------------------------ /// Unregister for process and thread notifications. /// /// Clients can unregister notification callbacks by passing a copy of the /// original baton and callbacks in \a callbacks. /// -/// @param[in] callbacks +/// \param[in] callbacks /// A structure that contains the notification baton and /// callback functions. /// -/// @return +/// \return /// Returns \b true if the notification callbacks were /// successfully removed from the process, \b false otherwise. /// -/// @see Process::Notifications -//------------------------------------------------------------------ -#ifndef SWIG +/// \see Process::Notifications bool UnregisterNotificationCallbacks(const Process::Notifications &callbacks); -#endif //================================================================== // Built in Process Control functions //================================================================== - //------------------------------------------------------------------ /// Resumes all of a process's threads as configured using the Thread run /// control functions. /// @@ -1030,18 +808,16 @@ public: /// use PrivateResume (though you should only do that from inside the /// Process class. /// - /// @return + /// \return /// Returns an error object. /// - /// @see Thread:Resume() - /// @see Thread:Step() - /// @see Thread:Suspend() - //------------------------------------------------------------------ + /// \see Thread:Resume() + /// \see Thread:Step() + /// \see Thread:Suspend() Status Resume(); Status ResumeSynchronous(Stream *stream); - //------------------------------------------------------------------ /// Halts a running process. /// /// This function is not meant to be overridden by Process subclasses. If @@ -1049,39 +825,35 @@ public: /// GetInterrupted will be broadcast. If false, we will halt the process /// with no events generated by the halt. /// - /// @param[in] clear_thread_plans + /// \param[in] clear_thread_plans /// If true, when the process stops, clear all thread plans. /// - /// @param[in] use_run_lock + /// \param[in] use_run_lock /// Whether to release the run lock after the stop. /// - /// @return + /// \return /// Returns an error object. If the error is empty, the process is /// halted. /// otherwise the halt has failed. - //------------------------------------------------------------------ Status Halt(bool clear_thread_plans = false, bool use_run_lock = true); - //------------------------------------------------------------------ /// Detaches from a running or stopped process. /// /// This function is not meant to be overridden by Process subclasses. /// - /// @param[in] keep_stopped + /// \param[in] keep_stopped /// If true, don't resume the process on detach. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ Status Detach(bool keep_stopped); - //------------------------------------------------------------------ /// Kills the process and shuts down all threads that were spawned to track /// and monitor the process. /// /// This function is not meant to be overridden by Process subclasses. /// - /// @param[in] force_kill + /// \param[in] force_kill /// Whether lldb should force a kill (instead of a detach) from /// the inferior process. Normally if lldb launched a binary and /// Destory is called, lldb kills it. If lldb attached to a @@ -1089,19 +861,16 @@ public: /// this behavior needs to be over-ridden, this is the bool that /// can be used. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ Status Destroy(bool force_kill); - //------------------------------------------------------------------ /// Sends a process a UNIX signal \a signal. /// /// This function is not meant to be overridden by Process subclasses. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ Status Signal(int signal); void SetUnixSignals(lldb::UnixSignalsSP &&signals_sp); @@ -1112,65 +881,57 @@ public: // Plug-in Process Control Overrides //================================================================== - //------------------------------------------------------------------ /// Called before attaching to a process. /// /// Allow Process plug-ins to execute some code before attaching a process. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ virtual Status WillAttachToProcessWithID(lldb::pid_t pid) { return Status(); } - //------------------------------------------------------------------ /// Called before attaching to a process. /// /// Allow Process plug-ins to execute some code before attaching a process. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ virtual Status WillAttachToProcessWithName(const char *process_name, bool wait_for_launch) { return Status(); } - //------------------------------------------------------------------ /// Attach to a remote system via a URL /// - /// @param[in] strm + /// \param[in] strm /// A stream where output intended for the user /// (if the driver has a way to display that) generated during /// the connection. This may be nullptr if no output is needed.A /// - /// @param[in] remote_url + /// \param[in] remote_url /// The URL format that we are connecting to. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ virtual Status DoConnectRemote(Stream *strm, llvm::StringRef remote_url) { Status error; error.SetErrorString("remote connections are not supported"); return error; } - //------------------------------------------------------------------ /// Attach to an existing process using a process ID. /// - /// @param[in] pid + /// \param[in] pid /// The process ID that we should attempt to attach to. /// - /// @param[in] attach_info + /// \param[in] attach_info /// Information on how to do the attach. For example, GetUserID() /// will return the uid to attach as. /// - /// @return + /// \return /// Returns a successful Status attaching was successful, or /// an appropriate (possibly platform-specific) error code if /// attaching fails. /// hanming : need flag - //------------------------------------------------------------------ virtual Status DoAttachToProcessWithID(lldb::pid_t pid, const ProcessAttachInfo &attach_info) { Status error; @@ -1180,21 +941,19 @@ public: return error; } - //------------------------------------------------------------------ /// Attach to an existing process using a partial process name. /// - /// @param[in] process_name + /// \param[in] process_name /// The name of the process to attach to. /// - /// @param[in] attach_info + /// \param[in] attach_info /// Information on how to do the attach. For example, GetUserID() /// will return the uid to attach as. /// - /// @return + /// \return /// Returns a successful Status attaching was successful, or /// an appropriate (possibly platform-specific) error code if /// attaching fails. - //------------------------------------------------------------------ virtual Status DoAttachToProcessWithName(const char *process_name, const ProcessAttachInfo &attach_info) { @@ -1203,63 +962,53 @@ public: return error; } - //------------------------------------------------------------------ /// Called after attaching a process. /// - /// @param[in] process_arch + /// \param[in] process_arch /// If you can figure out the process architecture after attach, fill it /// in here. /// /// Allow Process plug-ins to execute some code after attaching to a /// process. - //------------------------------------------------------------------ virtual void DidAttach(ArchSpec &process_arch) { process_arch.Clear(); } - //------------------------------------------------------------------ /// Called after a process re-execs itself. /// /// Allow Process plug-ins to execute some code after a process has exec'ed /// itself. Subclasses typically should override DoDidExec() as the /// lldb_private::Process class needs to remove its dynamic loader, runtime, /// ABI and other plug-ins, as well as unload all shared libraries. - //------------------------------------------------------------------ virtual void DidExec(); - //------------------------------------------------------------------ /// Subclasses of Process should implement this function if they need to do /// anything after a process exec's itself. - //------------------------------------------------------------------ virtual void DoDidExec() {} - //------------------------------------------------------------------ /// Called before launching to a process. /// /// Allow Process plug-ins to execute some code before launching a process. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ virtual Status WillLaunch(Module *module) { return Status(); } - //------------------------------------------------------------------ /// Launch a new process. /// /// Launch a new process by spawning a new process using \a exe_module's /// file as the file to launch. Launch details are provided in \a /// launch_info. /// - /// @param[in] exe_module + /// \param[in] exe_module /// The module from which to extract the file specification and /// launch. /// - /// @param[in] launch_info + /// \param[in] launch_info /// Details (e.g. arguments, stdio redirection, etc.) for the /// requested launch. /// - /// @return + /// \return /// An Status instance indicating success or failure of the /// operation. - //------------------------------------------------------------------ virtual Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) { Status error; error.SetErrorStringWithFormat( @@ -1268,24 +1017,19 @@ public: return error; } - //------------------------------------------------------------------ /// Called after launching a process. /// /// Allow Process plug-ins to execute some code after launching a process. - //------------------------------------------------------------------ virtual void DidLaunch() {} - //------------------------------------------------------------------ /// Called before resuming to a process. /// /// Allow Process plug-ins to execute some code before resuming a process. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ virtual Status WillResume() { return Status(); } - //------------------------------------------------------------------ /// Resumes all of a process's threads as configured using the Thread run /// control functions. /// @@ -1294,14 +1038,13 @@ public: /// process is resumed. If no run control action is given to a thread it /// will be resumed by default. /// - /// @return + /// \return /// Returns \b true if the process successfully resumes using /// the thread run control actions, \b false otherwise. /// - /// @see Thread:Resume() - /// @see Thread:Step() - /// @see Thread:Suspend() - //------------------------------------------------------------------ + /// \see Thread:Resume() + /// \see Thread:Step() + /// \see Thread:Suspend() virtual Status DoResume() { Status error; error.SetErrorStringWithFormat( @@ -1310,24 +1053,19 @@ public: return error; } - //------------------------------------------------------------------ /// Called after resuming a process. /// /// Allow Process plug-ins to execute some code after resuming a process. - //------------------------------------------------------------------ virtual void DidResume() {} - //------------------------------------------------------------------ /// Called before halting to a process. /// /// Allow Process plug-ins to execute some code before halting a process. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ virtual Status WillHalt() { return Status(); } - //------------------------------------------------------------------ /// Halts a running process. /// /// DoHalt must produce one and only one stop StateChanged event if it @@ -1336,14 +1074,13 @@ public: /// Otherwise, you must generate the event manually. This function is called /// from the context of the private state thread. /// - /// @param[out] caused_stop + /// \param[out] caused_stop /// If true, then this Halt caused the stop, otherwise, the /// process was already stopped. /// - /// @return + /// \return /// Returns \b true if the process successfully halts, \b false /// otherwise. - //------------------------------------------------------------------ virtual Status DoHalt(bool &caused_stop) { Status error; error.SetErrorStringWithFormat( @@ -1352,31 +1089,25 @@ public: return error; } - //------------------------------------------------------------------ /// Called after halting a process. /// /// Allow Process plug-ins to execute some code after halting a process. - //------------------------------------------------------------------ virtual void DidHalt() {} - //------------------------------------------------------------------ /// Called before detaching from a process. /// /// Allow Process plug-ins to execute some code before detaching from a /// process. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ virtual Status WillDetach() { return Status(); } - //------------------------------------------------------------------ /// Detaches from a running or stopped process. /// - /// @return + /// \return /// Returns \b true if the process successfully detaches, \b /// false otherwise. - //------------------------------------------------------------------ virtual Status DoDetach(bool keep_stopped) { Status error; error.SetErrorStringWithFormat( @@ -1385,35 +1116,29 @@ public: return error; } - //------------------------------------------------------------------ /// Called after detaching from a process. /// /// Allow Process plug-ins to execute some code after detaching from a /// process. - //------------------------------------------------------------------ virtual void DidDetach() {} virtual bool DetachRequiresHalt() { return false; } - //------------------------------------------------------------------ /// Called before sending a signal to a process. /// /// Allow Process plug-ins to execute some code before sending a signal to a /// process. /// - /// @return + /// \return /// Returns no error if it is safe to proceed with a call to /// Process::DoSignal(int), otherwise an error describing what /// prevents the signal from being sent. - //------------------------------------------------------------------ virtual Status WillSignal() { return Status(); } - //------------------------------------------------------------------ /// Sends a process a UNIX signal \a signal. /// - /// @return + /// \return /// Returns an error object. - //------------------------------------------------------------------ virtual Status DoSignal(int signal) { Status error; error.SetErrorStringWithFormat( @@ -1430,15 +1155,12 @@ public: virtual bool DestroyRequiresHalt() { return true; } - //------------------------------------------------------------------ /// Called after sending a signal to a process. /// /// Allow Process plug-ins to execute some code after sending a signal to a /// process. - //------------------------------------------------------------------ virtual void DidSignal() {} - //------------------------------------------------------------------ /// Currently called as part of ShouldStop. /// FIXME: Should really happen when the target stops before the /// event is taken from the queue... @@ -1449,10 +1171,8 @@ public: /// operations include updating the thread list, invalidating any thread /// state (registers, stack, etc) prior to letting the notification go out. /// - //------------------------------------------------------------------ virtual void RefreshStateAfterStop() = 0; - //------------------------------------------------------------------ /// Sometimes the connection to a process can detect the host OS version /// that the process is running on. The current platform should be checked /// first in case the platform is connected, but clients can fall back onto @@ -1461,31 +1181,25 @@ public: /// platform that might itself be running natively, but have different /// heuristics for figuring out which OS is is emulating. /// - /// @return + /// \return /// Returns the version tuple of the host OS. In case of failure an empty /// VersionTuple is returner. - //------------------------------------------------------------------ virtual llvm::VersionTuple GetHostOSVersion() { return llvm::VersionTuple(); } - //------------------------------------------------------------------ /// Get the target object pointer for this module. /// - /// @return + /// \return /// A Target object pointer to the target that owns this /// module. - //------------------------------------------------------------------ Target &GetTarget() { return *m_target_wp.lock(); } - //------------------------------------------------------------------ /// Get the const target object pointer for this module. /// - /// @return + /// \return /// A const Target object pointer to the target that owns this /// module. - //------------------------------------------------------------------ const Target &GetTarget() const { return *m_target_wp.lock(); } - //------------------------------------------------------------------ /// Flush all data in the process. /// /// Flush the memory caches, all threads, and any other cached data in the @@ -1494,17 +1208,14 @@ public: /// This function can be called after a world changing event like adding a /// new symbol file, or after the process makes a large context switch (from /// boot ROM to booted into an OS). - //------------------------------------------------------------------ void Flush(); - //------------------------------------------------------------------ /// Get accessor for the current process state. /// - /// @return + /// \return /// The current state of the process. /// - /// @see lldb::StateType - //------------------------------------------------------------------ + /// \see lldb::StateType lldb::StateType GetState(); lldb::ExpressionResults @@ -1523,15 +1234,12 @@ public: void SendAsyncInterrupt(); - //------------------------------------------------------------------ // Notify this process class that modules got loaded. // // If subclasses override this method, they must call this version before // doing anything in the subclass version of the function. - //------------------------------------------------------------------ virtual void ModulesDidLoad(ModuleList &module_list); - //------------------------------------------------------------------ /// Retrieve the list of shared libraries that are loaded for this process /// This method is used on pre-macOS 10.12, pre-iOS 10, pre-tvOS 10, pre- /// watchOS 3 systems. The following two methods are for newer versions of @@ -1544,21 +1252,20 @@ public: /// memory and return a concise summary sufficient for the DynamicLoader /// plugin. /// - /// @param [in] image_list_address + /// \param [in] image_list_address /// The address where the table of shared libraries is stored in memory, /// if that is appropriate for this platform. Else this may be /// passed as LLDB_INVALID_ADDRESS. /// - /// @param [in] image_count + /// \param [in] image_count /// The number of shared libraries that are present in this process, if /// that is appropriate for this platofrm Else this may be passed as /// LLDB_INVALID_ADDRESS. /// - /// @return + /// \return /// A StructureDataSP object which, if non-empty, will contain the /// information the DynamicLoader needs to get the initial scan of /// solibs resolved. - //------------------------------------------------------------------ virtual lldb_private::StructuredData::ObjectSP GetLoadedDynamicLibrariesInfos(lldb::addr_t image_list_address, lldb::addr_t image_count) { @@ -1579,60 +1286,50 @@ public: return StructuredData::ObjectSP(); } - //------------------------------------------------------------------ // Get information about the library shared cache, if that exists // // On macOS 10.12, tvOS 10, iOS 10, watchOS 3 and newer, debugserver can // return information about the library shared cache (a set of standard // libraries that are loaded at the same location for all processes on a // system) in use. - //------------------------------------------------------------------ virtual lldb_private::StructuredData::ObjectSP GetSharedCacheInfo() { return StructuredData::ObjectSP(); } - //------------------------------------------------------------------ /// Print a user-visible warning about a module being built with /// optimization /// /// Prints a async warning message to the user one time per Module where a /// function is found that was compiled with optimization, per Process. /// - /// @param [in] sc + /// \param [in] sc /// A SymbolContext with eSymbolContextFunction and eSymbolContextModule /// pre-computed. - //------------------------------------------------------------------ void PrintWarningOptimization(const SymbolContext &sc); virtual bool GetProcessInfo(ProcessInstanceInfo &info); public: - //------------------------------------------------------------------ /// Get the exit status for a process. /// - /// @return + /// \return /// The process's return code, or -1 if the current process /// state is not eStateExited. - //------------------------------------------------------------------ int GetExitStatus(); - //------------------------------------------------------------------ /// Get a textual description of what the process exited. /// - /// @return + /// \return /// The textual description of why the process exited, or nullptr /// if there is no description available. - //------------------------------------------------------------------ const char *GetExitDescription(); virtual void DidExit() {} - //------------------------------------------------------------------ /// Get the Modification ID of the process. /// - /// @return + /// \return /// The modification ID of the process. - //------------------------------------------------------------------ ProcessModID GetModID() const { return m_mod_id; } const ProcessModID &GetModIDRef() const { return m_mod_id; } @@ -1653,7 +1350,6 @@ public: return m_mod_id.GetStopEventForStopID(stop_id); } - //------------------------------------------------------------------ /// Set accessor for the process exit status (return code). /// /// Sometimes a child exits and the exit can be detected by global functions @@ -1663,66 +1359,58 @@ public: /// Setting this will cause a eStateExited event to be posted to the process /// event queue. /// - /// @param[in] exit_status + /// \param[in] exit_status /// The value for the process's return code. /// - /// @see lldb::StateType - //------------------------------------------------------------------ + /// \see lldb::StateType virtual bool SetExitStatus(int exit_status, const char *cstr); - //------------------------------------------------------------------ /// Check if a process is still alive. /// - /// @return + /// \return /// Returns \b true if the process is still valid, \b false /// otherwise. - //------------------------------------------------------------------ virtual bool IsAlive(); - //------------------------------------------------------------------ /// Before lldb detaches from a process, it warns the user that they are /// about to lose their debug session. In some cases, this warning doesn't /// need to be emitted -- for instance, with core file debugging where the /// user can reconstruct the "state" by simply re-running the debugger on /// the core file. /// - /// @return + /// \return // true if the user should be warned about detaching from this process. - //------------------------------------------------------------------ virtual bool WarnBeforeDetach() const { return true; } - //------------------------------------------------------------------ /// Actually do the reading of memory from a process. /// /// Subclasses must override this function and can return fewer bytes than /// requested when memory requests are too large. This class will break up /// the memory requests and keep advancing the arguments along as needed. /// - /// @param[in] vm_addr + /// \param[in] vm_addr /// A virtual load address that indicates where to start reading /// memory from. /// - /// @param[in] size + /// \param[in] size /// The number of bytes to read. /// - /// @param[out] buf + /// \param[out] buf /// A byte buffer that is at least \a size bytes long that /// will receive the memory bytes. /// - /// @param[out] error + /// \param[out] error /// An error that indicates the success or failure of this /// operation. If error indicates success (error.Success()), /// then the value returned can be trusted, otherwise zero /// will be returned. /// - /// @return + /// \return /// The number of bytes that were actually read into \a buf. /// Zero is returned in the case of an error. - //------------------------------------------------------------------ virtual size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error) = 0; - //------------------------------------------------------------------ /// Read of memory from a process. /// /// This function will read memory from the current process's address space @@ -1732,34 +1420,63 @@ public: /// subclasses should implement Process::DoReadMemory (lldb::addr_t, size_t, /// void *). /// - /// @param[in] vm_addr + /// \param[in] vm_addr /// A virtual load address that indicates where to start reading /// memory from. /// - /// @param[out] buf + /// \param[out] buf /// A byte buffer that is at least \a size bytes long that /// will receive the memory bytes. /// - /// @param[in] size + /// \param[in] size /// The number of bytes to read. /// - /// @param[out] error + /// \param[out] error /// An error that indicates the success or failure of this /// operation. If error indicates success (error.Success()), /// then the value returned can be trusted, otherwise zero /// will be returned. /// - /// @return + /// \return /// The number of bytes that were actually read into \a buf. If /// the returned number is greater than zero, yet less than \a /// size, then this function will get called again with \a /// vm_addr, \a buf, and \a size updated appropriately. Zero is /// returned in the case of an error. - //------------------------------------------------------------------ virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error); - //------------------------------------------------------------------ + /// Read of memory from a process. + /// + /// This function has the same semantics of ReadMemory except that it + /// bypasses caching. + /// + /// \param[in] vm_addr + /// A virtual load address that indicates where to start reading + /// memory from. + /// + /// \param[out] buf + /// A byte buffer that is at least \a size bytes long that + /// will receive the memory bytes. + /// + /// \param[in] size + /// The number of bytes to read. + /// + /// \param[out] error + /// An error that indicates the success or failure of this + /// operation. If error indicates success (error.Success()), + /// then the value returned can be trusted, otherwise zero + /// will be returned. + /// + /// \return + /// The number of bytes that were actually read into \a buf. If + /// the returned number is greater than zero, yet less than \a + /// size, then this function will get called again with \a + /// vm_addr, \a buf, and \a size updated appropriately. Zero is + /// returned in the case of an error. + size_t ReadMemoryFromInferior(lldb::addr_t vm_addr, void *buf, size_t size, + Status &error); + /// Read a NULL terminated string from memory /// /// This function will read a cache page at a time until a NULL string @@ -1769,29 +1486,27 @@ public: /// terminated, and that no more than (max_bytes - type_width) bytes will be /// read. /// - /// @param[in] vm_addr + /// \param[in] vm_addr /// The virtual load address to start the memory read. /// - /// @param[in] str + /// \param[in] str /// A character buffer containing at least max_bytes. /// - /// @param[in] max_bytes + /// \param[in] max_bytes /// The maximum number of bytes to read. /// - /// @param[in] error + /// \param[in] error /// The error status of the read operation. /// - /// @param[in] type_width + /// \param[in] type_width /// The size of the null terminator (1 to 4 bytes per /// character). Defaults to 1. /// - /// @return + /// \return /// The error status or the number of bytes prior to the null terminator. - //------------------------------------------------------------------ size_t ReadStringFromMemory(lldb::addr_t vm_addr, char *str, size_t max_bytes, Status &error, size_t type_width = 1); - //------------------------------------------------------------------ /// Read a NULL terminated C string from memory /// /// This function will read a cache page at a time until the NULL @@ -1799,43 +1514,37 @@ public: /// termination byte isn't found before reading \a cstr_max_len bytes, and /// the results are always guaranteed to be NULL terminated (at most /// cstr_max_len - 1 bytes will be read). - //------------------------------------------------------------------ size_t ReadCStringFromMemory(lldb::addr_t vm_addr, char *cstr, size_t cstr_max_len, Status &error); size_t ReadCStringFromMemory(lldb::addr_t vm_addr, std::string &out_str, Status &error); - size_t ReadMemoryFromInferior(lldb::addr_t vm_addr, void *buf, size_t size, - Status &error); - - //------------------------------------------------------------------ /// Reads an unsigned integer of the specified byte size from process /// memory. /// - /// @param[in] load_addr + /// \param[in] load_addr /// A load address of the integer to read. /// - /// @param[in] byte_size + /// \param[in] byte_size /// The size in byte of the integer to read. /// - /// @param[in] fail_value + /// \param[in] fail_value /// The value to return if we fail to read an integer. /// - /// @param[out] error + /// \param[out] error /// An error that indicates the success or failure of this /// operation. If error indicates success (error.Success()), /// then the value returned can be trusted, otherwise zero /// will be returned. /// - /// @return + /// \return /// The unsigned integer that was read from the process memory /// space. If the integer was smaller than a uint64_t, any /// unused upper bytes will be zero filled. If the process /// byte order differs from the host byte order, the integer /// value will be appropriately byte swapped into host byte /// order. - //------------------------------------------------------------------ uint64_t ReadUnsignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, uint64_t fail_value, Status &error); @@ -1848,26 +1557,24 @@ public: bool WritePointerToMemory(lldb::addr_t vm_addr, lldb::addr_t ptr_value, Status &error); - //------------------------------------------------------------------ /// Actually do the writing of memory to a process. /// - /// @param[in] vm_addr + /// \param[in] vm_addr /// A virtual load address that indicates where to start writing /// memory to. /// - /// @param[in] buf + /// \param[in] buf /// A byte buffer that is at least \a size bytes long that /// contains the data to write. /// - /// @param[in] size + /// \param[in] size /// The number of bytes to write. /// - /// @param[out] error + /// \param[out] error /// An error value in case the memory write fails. /// - /// @return + /// \return /// The number of bytes that were actually written. - //------------------------------------------------------------------ virtual size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Status &error) { error.SetErrorStringWithFormat( @@ -1876,7 +1583,6 @@ public: return 0; } - //------------------------------------------------------------------ /// Write all or part of a scalar value to memory. /// /// The value contained in \a scalar will be swapped to match the byte order @@ -1886,14 +1592,14 @@ public: /// extra space will be padded with zeros and the scalar value will be /// placed in the least significant bytes in memory. /// - /// @param[in] vm_addr + /// \param[in] vm_addr /// A virtual load address that indicates where to start writing /// memory to. /// - /// @param[in] scalar + /// \param[in] scalar /// The scalar to write to the debugged process. /// - /// @param[in] size + /// \param[in] size /// This value can be smaller or larger than the scalar value /// itself. If \a size is smaller than the size of \a scalar, /// the least significant bytes in \a scalar will be used. If @@ -1901,12 +1607,11 @@ public: /// the extra space will be padded with zeros. If \a size is /// set to UINT32_MAX, then the size of \a scalar will be used. /// - /// @param[out] error + /// \param[out] error /// An error value in case the memory write fails. /// - /// @return + /// \return /// The number of bytes that were actually written. - //------------------------------------------------------------------ size_t WriteScalarToMemory(lldb::addr_t vm_addr, const Scalar &scalar, size_t size, Status &error); @@ -1914,7 +1619,6 @@ public: bool is_signed, Scalar &scalar, Status &error); - //------------------------------------------------------------------ /// Write memory to a process. /// /// This function will write memory to the current process's address space @@ -1925,38 +1629,35 @@ public: /// subclasses should implement Process::DoWriteMemory (lldb::addr_t, /// size_t, void *). /// - /// @param[in] vm_addr + /// \param[in] vm_addr /// A virtual load address that indicates where to start writing /// memory to. /// - /// @param[in] buf + /// \param[in] buf /// A byte buffer that is at least \a size bytes long that /// contains the data to write. /// - /// @param[in] size + /// \param[in] size /// The number of bytes to write. /// - /// @return + /// \return /// The number of bytes that were actually written. - //------------------------------------------------------------------ // TODO: change this to take an ArrayRef<uint8_t> size_t WriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Status &error); - //------------------------------------------------------------------ /// Actually allocate memory in the process. /// /// This function will allocate memory in the process's address space. This /// can't rely on the generic function calling mechanism, since that /// requires this function. /// - /// @param[in] size + /// \param[in] size /// The size of the allocation requested. /// - /// @return + /// \return /// The address of the allocated buffer in the process, or /// LLDB_INVALID_ADDRESS if the allocation failed. - //------------------------------------------------------------------ virtual lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions, Status &error) { @@ -1968,32 +1669,29 @@ public: virtual Status WriteObjectFile(std::vector<ObjectFile::LoadableData> entries); - //------------------------------------------------------------------ /// The public interface to allocating memory in the process. /// /// This function will allocate memory in the process's address space. This /// can't rely on the generic function calling mechanism, since that /// requires this function. /// - /// @param[in] size + /// \param[in] size /// The size of the allocation requested. /// - /// @param[in] permissions + /// \param[in] permissions /// Or together any of the lldb::Permissions bits. The permissions on /// a given memory allocation can't be changed after allocation. Note /// that a block that isn't set writable can still be written on from /// lldb, /// just not by the process itself. /// - /// @param[in,out] error + /// \param[in,out] error /// An error object to fill in if things go wrong. - /// @return + /// \return /// The address of the allocated buffer in the process, or /// LLDB_INVALID_ADDRESS if the allocation failed. - //------------------------------------------------------------------ lldb::addr_t AllocateMemory(size_t size, uint32_t permissions, Status &error); - //------------------------------------------------------------------ /// The public interface to allocating memory in the process, this also /// clears the allocated memory. /// @@ -2001,43 +1699,39 @@ public: /// can't rely on the generic function calling mechanism, since that /// requires this function. /// - /// @param[in] size + /// \param[in] size /// The size of the allocation requested. /// - /// @param[in] permissions + /// \param[in] permissions /// Or together any of the lldb::Permissions bits. The permissions on /// a given memory allocation can't be changed after allocation. Note /// that a block that isn't set writable can still be written on from /// lldb, /// just not by the process itself. /// - /// @param[in/out] error + /// \param[in/out] error /// An error object to fill in if things go wrong. - /// @return + /// \return /// The address of the allocated buffer in the process, or /// LLDB_INVALID_ADDRESS if the allocation failed. - //------------------------------------------------------------------ lldb::addr_t CallocateMemory(size_t size, uint32_t permissions, Status &error); - //------------------------------------------------------------------ /// Resolve dynamically loaded indirect functions. /// - /// @param[in] address + /// \param[in] address /// The load address of the indirect function to resolve. /// - /// @param[out] error + /// \param[out] error /// An error value in case the resolve fails. /// - /// @return + /// \return /// The address of the resolved function. /// LLDB_INVALID_ADDRESS if the resolution failed. - //------------------------------------------------------------------ virtual lldb::addr_t ResolveIndirectFunction(const Address *address, Status &error); - //------------------------------------------------------------------ /// Locate the memory region that contains load_addr. /// /// If load_addr is within the address space the process has mapped @@ -2054,15 +1748,14 @@ public: /// GetMemoryRegionInfo will only return an error if it is unimplemented for /// the current process. /// - /// @param[in] load_addr + /// \param[in] load_addr /// The load address to query the range_info for. /// - /// @param[out] range_info + /// \param[out] range_info /// An range_info value containing the details of the range. /// - /// @return + /// \return /// An error value. - //------------------------------------------------------------------ virtual Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info) { Status error; @@ -2070,16 +1763,14 @@ public: return error; } - //------------------------------------------------------------------ /// Obtain all the mapped memory regions within this process. /// - /// @param[out] region_list + /// \param[out] region_list /// A vector to contain MemoryRegionInfo objects for all mapped /// ranges. /// - /// @return + /// \return /// An error value. - //------------------------------------------------------------------ virtual Status GetMemoryRegions(lldb_private::MemoryRegionInfos ®ion_list); @@ -2102,7 +1793,6 @@ public: lldb::addr_t header_addr, size_t size_to_read = 512); - //------------------------------------------------------------------ /// Attempt to get the attributes for a region of memory in the process. /// /// It may be possible for the remote debug server to inspect attributes for @@ -2110,81 +1800,68 @@ public: /// of memory at a given address or whether that page is /// readable/writable/executable by the process. /// - /// @param[in] load_addr + /// \param[in] load_addr /// The address of interest in the process. /// - /// @param[out] permissions + /// \param[out] permissions /// If this call returns successfully, this bitmask will have /// its Permissions bits set to indicate whether the region is /// readable/writable/executable. If this call fails, the /// bitmask values are undefined. /// - /// @return + /// \return /// Returns true if it was able to determine the attributes of the /// memory region. False if not. - //------------------------------------------------------------------ virtual bool GetLoadAddressPermissions(lldb::addr_t load_addr, uint32_t &permissions); - //------------------------------------------------------------------ /// Determines whether executing JIT-compiled code in this process is /// possible. /// - /// @return + /// \return /// True if execution of JIT code is possible; false otherwise. - //------------------------------------------------------------------ bool CanJIT(); - //------------------------------------------------------------------ /// Sets whether executing JIT-compiled code in this process is possible. /// - /// @param[in] can_jit + /// \param[in] can_jit /// True if execution of JIT code is possible; false otherwise. - //------------------------------------------------------------------ void SetCanJIT(bool can_jit); - //------------------------------------------------------------------ /// Determines whether executing function calls using the interpreter is /// possible for this process. /// - /// @return + /// \return /// True if possible; false otherwise. - //------------------------------------------------------------------ bool CanInterpretFunctionCalls() { return m_can_interpret_function_calls; } - //------------------------------------------------------------------ /// Sets whether executing function calls using the interpreter is possible /// for this process. /// - /// @param[in] can_interpret_function_calls + /// \param[in] can_interpret_function_calls /// True if possible; false otherwise. - //------------------------------------------------------------------ void SetCanInterpretFunctionCalls(bool can_interpret_function_calls) { m_can_interpret_function_calls = can_interpret_function_calls; } - //------------------------------------------------------------------ /// Sets whether executing code in this process is possible. This could be /// either through JIT or interpreting. /// - /// @param[in] can_run_code + /// \param[in] can_run_code /// True if execution of code is possible; false otherwise. - //------------------------------------------------------------------ void SetCanRunCode(bool can_run_code); - //------------------------------------------------------------------ /// Actually deallocate memory in the process. /// /// This function will deallocate memory in the process's address space that /// was allocated with AllocateMemory. /// - /// @param[in] ptr + /// \param[in] ptr /// A return value from AllocateMemory, pointing to the memory you /// want to deallocate. /// - /// @return + /// \return /// \btrue if the memory was deallocated, \bfalse otherwise. - //------------------------------------------------------------------ virtual Status DoDeallocateMemory(lldb::addr_t ptr) { Status error; error.SetErrorStringWithFormat( @@ -2193,22 +1870,19 @@ public: return error; } - //------------------------------------------------------------------ /// The public interface to deallocating memory in the process. /// /// This function will deallocate memory in the process's address space that /// was allocated with AllocateMemory. /// - /// @param[in] ptr + /// \param[in] ptr /// A return value from AllocateMemory, pointing to the memory you /// want to deallocate. /// - /// @return + /// \return /// \btrue if the memory was deallocated, \bfalse otherwise. - //------------------------------------------------------------------ Status DeallocateMemory(lldb::addr_t ptr); - //------------------------------------------------------------------ /// Get any available STDOUT. /// /// Calling this method is a valid operation only if all of the following @@ -2225,21 +1899,19 @@ public: /// Events will be queued indicating that there is STDOUT available that can /// be retrieved using this function. /// - /// @param[out] buf + /// \param[out] buf /// A buffer that will receive any STDOUT bytes that are /// currently available. /// - /// @param[in] buf_size + /// \param[in] buf_size /// The size in bytes for the buffer \a buf. /// - /// @return + /// \return /// The number of bytes written into \a buf. If this value is /// equal to \a buf_size, another call to this function should /// be made to retrieve more STDOUT data. - //------------------------------------------------------------------ virtual size_t GetSTDOUT(char *buf, size_t buf_size, Status &error); - //------------------------------------------------------------------ /// Get any available STDERR. /// /// Calling this method is a valid operation only if all of the following @@ -2256,21 +1928,19 @@ public: /// Events will be queued indicating that there is STDERR available that can /// be retrieved using this function. /// - /// @param[in] buf + /// \param[in] buf /// A buffer that will receive any STDERR bytes that are /// currently available. /// - /// @param[out] buf_size + /// \param[out] buf_size /// The size in bytes for the buffer \a buf. /// - /// @return + /// \return /// The number of bytes written into \a buf. If this value is /// equal to \a buf_size, another call to this function should /// be made to retrieve more STDERR data. - //------------------------------------------------------------------ virtual size_t GetSTDERR(char *buf, size_t buf_size, Status &error); - //------------------------------------------------------------------ /// Puts data into this process's STDIN. /// /// Calling this method is a valid operation only if all of the following @@ -2279,42 +1949,37 @@ public: /// process was launched without supplying a valid file path /// for STDIN. /// - /// @param[in] buf + /// \param[in] buf /// A buffer that contains the data to write to the process's STDIN. /// - /// @param[in] buf_size + /// \param[in] buf_size /// The size in bytes for the buffer \a buf. /// - /// @return + /// \return /// The number of bytes written into \a buf. If this value is /// less than \a buf_size, another call to this function should /// be made to write the rest of the data. - //------------------------------------------------------------------ virtual size_t PutSTDIN(const char *buf, size_t buf_size, Status &error) { error.SetErrorString("stdin unsupported"); return 0; } - //------------------------------------------------------------------ /// Get any available profile data. /// - /// @param[out] buf + /// \param[out] buf /// A buffer that will receive any profile data bytes that are /// currently available. /// - /// @param[out] buf_size + /// \param[out] buf_size /// The size in bytes for the buffer \a buf. /// - /// @return + /// \return /// The number of bytes written into \a buf. If this value is /// equal to \a buf_size, another call to this function should /// be made to retrieve more profile data. - //------------------------------------------------------------------ virtual size_t GetAsyncProfileData(char *buf, size_t buf_size, Status &error); - //---------------------------------------------------------------------- // Process Breakpoints - //---------------------------------------------------------------------- size_t GetSoftwareBreakpointTrapOpcode(BreakpointSite *bp_site); virtual Status EnableBreakpointSite(BreakpointSite *bp_site) { @@ -2366,16 +2031,12 @@ public: lldb::user_id_t owner_loc_id, lldb::BreakpointSiteSP &bp_site_sp); - //---------------------------------------------------------------------- // Process Watchpoints (optional) - //---------------------------------------------------------------------- virtual Status EnableWatchpoint(Watchpoint *wp, bool notify = true); virtual Status DisableWatchpoint(Watchpoint *wp, bool notify = true); - //------------------------------------------------------------------ // Thread Queries - //------------------------------------------------------------------ virtual bool UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) = 0; @@ -2403,9 +2064,7 @@ public: // id will be used. uint32_t AssignIndexIDToThread(uint64_t thread_id); - //------------------------------------------------------------------ // Queue Queries - //------------------------------------------------------------------ void UpdateQueueListIfNeeded(); @@ -2419,9 +2078,7 @@ public: return m_queue_list.Queues(); } - //------------------------------------------------------------------ // Event Handling - //------------------------------------------------------------------ lldb::StateType GetNextEvent(lldb::EventSP &event_sp); // Returns the process state when it is stopped. If specified, event_sp_ptr @@ -2439,16 +2096,14 @@ public: uint32_t GetIOHandlerID() const { return m_iohandler_sync.GetValue(); } - //-------------------------------------------------------------------------------------- /// Waits for the process state to be running within a given msec timeout. /// /// The main purpose of this is to implement an interlock waiting for /// HandlePrivateEvent to push an IOHandler. /// - /// @param[in] timeout + /// \param[in] timeout /// The maximum time length to wait for the process to transition to the /// eStateRunning state. - //-------------------------------------------------------------------------------------- void SyncIOHandler(uint32_t iohandler_id, const Timeout<std::micro> &timeout); lldb::StateType GetStateChangedEvents( @@ -2456,27 +2111,25 @@ public: lldb::ListenerSP hijack_listener); // Pass an empty ListenerSP to use builtin listener - //-------------------------------------------------------------------------------------- /// Centralize the code that handles and prints descriptions for process /// state changes. /// - /// @param[in] event_sp + /// \param[in] event_sp /// The process state changed event /// - /// @param[in] stream + /// \param[in] stream /// The output stream to get the state change description /// - /// @param[in,out] pop_process_io_handler + /// \param[in,out] pop_process_io_handler /// If this value comes in set to \b true, then pop the Process IOHandler /// if needed. /// Else this variable will be set to \b true or \b false to indicate if /// the process /// needs to have its process IOHandler popped. /// - /// @return + /// \return /// \b true if the event describes a process state changed event, \b false /// otherwise. - //-------------------------------------------------------------------------------------- static bool HandleProcessStateChangedEvent(const lldb::EventSP &event_sp, Stream *stream, bool &pop_process_io_handler); @@ -2498,7 +2151,6 @@ public: friend class ProcessEventHijacker; friend class ProcessProperties; - //------------------------------------------------------------------ /// If you need to ensure that you and only you will hear about some public /// event, then make a new listener, set to listen to process events, and /// then call this with that listener. Then you will have to wait on that @@ -2506,44 +2158,42 @@ public: /// WaitFor* calls above. Be sure to call RestoreProcessEvents when you are /// done. /// - /// @param[in] listener + /// \param[in] listener /// This is the new listener to whom all process events will be delivered. /// - /// @return + /// \return /// Returns \b true if the new listener could be installed, /// \b false otherwise. - //------------------------------------------------------------------ bool HijackProcessEvents(lldb::ListenerSP listener_sp); - //------------------------------------------------------------------ /// Restores the process event broadcasting to its normal state. /// - //------------------------------------------------------------------ void RestoreProcessEvents(); - const lldb::ABISP &GetABI(); + bool StateChangedIsHijackedForSynchronousResume(); - OperatingSystem *GetOperatingSystem() { return m_os_ap.get(); } + bool StateChangedIsExternallyHijacked(); - virtual LanguageRuntime *GetLanguageRuntime(lldb::LanguageType language, - bool retry_if_null = true); + const lldb::ABISP &GetABI(); - virtual CPPLanguageRuntime *GetCPPLanguageRuntime(bool retry_if_null = true); + OperatingSystem *GetOperatingSystem() { return m_os_up.get(); } - virtual ObjCLanguageRuntime * - GetObjCLanguageRuntime(bool retry_if_null = true); + std::vector<LanguageRuntime *> + GetLanguageRuntimes(bool retry_if_null = true); + + LanguageRuntime *GetLanguageRuntime(lldb::LanguageType language, + bool retry_if_null = true); bool IsPossibleDynamicValue(ValueObject &in_value); bool IsRunning() const; DynamicCheckerFunctions *GetDynamicCheckers() { - return m_dynamic_checkers_ap.get(); + return m_dynamic_checkers_up.get(); } void SetDynamicCheckers(DynamicCheckerFunctions *dynamic_checkers); - //------------------------------------------------------------------ /// Call this to set the lldb in the mode where it breaks on new thread /// creations, and then auto-restarts. This is useful when you are trying /// to run only one thread, but either that thread or the kernel is creating @@ -2551,27 +2201,22 @@ public: /// can immediately suspend it, and keep executing only the one thread you /// intend. /// - /// @return + /// \return /// Returns \b true if we were able to start up the notification /// \b false otherwise. - //------------------------------------------------------------------ virtual bool StartNoticingNewThreads() { return true; } - //------------------------------------------------------------------ /// Call this to turn off the stop & notice new threads mode. /// - /// @return + /// \return /// Returns \b true if we were able to start up the notification /// \b false otherwise. - //------------------------------------------------------------------ virtual bool StopNoticingNewThreads() { return true; } void SetRunningUserExpression(bool on); void SetRunningUtilityFunction(bool on); - //------------------------------------------------------------------ // lldb::ExecutionContextScope pure virtual functions - //------------------------------------------------------------------ lldb::TargetSP CalculateTarget() override; lldb::ProcessSP CalculateProcess() override { return shared_from_this(); } @@ -2586,28 +2231,22 @@ public: void SetSTDIOFileDescriptor(int file_descriptor); - //------------------------------------------------------------------ // Add a permanent region of memory that should never be read or written to. // This can be used to ensure that memory reads or writes to certain areas of // memory never end up being sent to the DoReadMemory or DoWriteMemory // functions which can improve performance. - //------------------------------------------------------------------ void AddInvalidMemoryRegion(const LoadRange ®ion); - //------------------------------------------------------------------ // Remove a permanent region of memory that should never be read or written // to that was previously added with AddInvalidMemoryRegion. - //------------------------------------------------------------------ bool RemoveInvalidMemoryRange(const LoadRange ®ion); - //------------------------------------------------------------------ // If the setup code of a thread plan needs to do work that might involve // calling a function in the target, it should not do that work directly in // one of the thread plan functions (DidPush/WillResume) because such work // needs to be handled carefully. Instead, put that work in a // PreResumeAction callback, and register it with the process. It will get // done before the actual "DoResume" gets called. - //------------------------------------------------------------------ typedef bool(PreResumeActionCallback)(void *); @@ -2631,48 +2270,44 @@ public: lldb::InstrumentationRuntimeSP GetInstrumentationRuntime(lldb::InstrumentationRuntimeType type); - //------------------------------------------------------------------ /// Try to fetch the module specification for a module with the given file /// name and architecture. Process sub-classes have to override this method /// if they support platforms where the Platform object can't get the module /// spec for all module. /// - /// @param[in] module_file_spec + /// \param[in] module_file_spec /// The file name of the module to get specification for. /// - /// @param[in] arch + /// \param[in] arch /// The architecture of the module to get specification for. /// - /// @param[out] module_spec + /// \param[out] module_spec /// The fetched module specification if the return value is /// \b true, unchanged otherwise. /// - /// @return + /// \return /// Returns \b true if the module spec fetched successfully, /// \b false otherwise. - //------------------------------------------------------------------ virtual bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch, ModuleSpec &module_spec); virtual void PrefetchModuleSpecs(llvm::ArrayRef<FileSpec> module_file_specs, const llvm::Triple &triple) {} - //------------------------------------------------------------------ /// Try to find the load address of a file. /// The load address is defined as the address of the first memory region /// what contains data mapped from the specified file. /// - /// @param[in] file + /// \param[in] file /// The name of the file whose load address we are looking for /// - /// @param[out] is_loaded + /// \param[out] is_loaded /// \b True if the file is loaded into the memory and false /// otherwise. /// - /// @param[out] load_addr + /// \param[out] load_addr /// The load address of the file if it is loaded into the /// processes address space, LLDB_INVALID_ADDRESS otherwise. - //------------------------------------------------------------------ virtual Status GetFileLoadAddress(const FileSpec &file, bool &is_loaded, lldb::addr_t &load_addr) { return Status("Not supported"); @@ -2684,7 +2319,6 @@ public: void ResetImageToken(size_t token); - //------------------------------------------------------------------ /// Find the next branch instruction to set a breakpoint on /// /// When instruction stepping through a source line, instead of stepping @@ -2693,24 +2327,22 @@ public: /// and continue the process to there, yielding significant performance /// benefits over instruction stepping. /// - /// @param[in] default_stop_addr + /// \param[in] default_stop_addr /// The address of the instruction where lldb would put a /// breakpoint normally. /// - /// @param[in] range_bounds + /// \param[in] range_bounds /// The range which the breakpoint must be contained within. /// Typically a source line. /// - /// @return + /// \return /// The address of the next branch instruction, or the end of /// the range provided in range_bounds. If there are any /// problems with the disassembly or getting the instructions, /// the original default_stop_addr will be returned. - //------------------------------------------------------------------ Address AdvanceAddressToNextBranchInstruction(Address default_stop_addr, AddressRange range_bounds); - //------------------------------------------------------------------ /// Configure asynchronous structured data feature. /// /// Each Process type that supports using an asynchronous StructuredData @@ -2721,11 +2353,11 @@ public: /// StructuredDataPlugin implementations will call this to configure a /// feature that has been reported as being supported. /// - /// @param[in] type_name + /// \param[in] type_name /// The StructuredData type name as previously discovered by /// the Process-derived instance. /// - /// @param[in] config + /// \param[in] config /// Configuration data for the feature being enabled. This config /// data, which may be null, will be passed along to the feature /// to process. The feature will dictate whether this is a dictionary, @@ -2733,14 +2365,12 @@ public: /// set up properly before it can be enabled, then the config should /// also take an enable/disable flag. /// - /// @return + /// \return /// Returns the result of attempting to configure the feature. - //------------------------------------------------------------------ virtual Status - ConfigureStructuredData(const ConstString &type_name, + ConfigureStructuredData(ConstString type_name, const StructuredData::ObjectSP &config_sp); - //------------------------------------------------------------------ /// Broadcasts the given structured data object from the given plugin. /// /// StructuredDataPlugin instances can use this to optionally broadcast any @@ -2748,17 +2378,15 @@ public: /// will come in on the structured data event bit /// (eBroadcastBitStructuredData). /// - /// @param[in] object_sp + /// \param[in] object_sp /// The structured data object to broadcast. /// - /// @param[in] plugin_sp + /// \param[in] plugin_sp /// The plugin that will be reported in the event's plugin /// parameter. - //------------------------------------------------------------------ void BroadcastStructuredData(const StructuredData::ObjectSP &object_sp, const lldb::StructuredDataPluginSP &plugin_sp); - //------------------------------------------------------------------ /// Returns the StructuredDataPlugin associated with a given type name, if /// there is one. /// @@ -2766,14 +2394,12 @@ public: /// debugged process monitor claims that the feature is supported. This is /// one way to tell whether a feature is available. /// - /// @return + /// \return /// The plugin if one is available for the specified feature; /// otherwise, returns an empty shared pointer. - //------------------------------------------------------------------ lldb::StructuredDataPluginSP - GetStructuredDataPlugin(const ConstString &type_name) const; + GetStructuredDataPlugin(ConstString type_name) const; - //------------------------------------------------------------------ /// Starts tracing with the configuration provided in options. To enable /// tracing on the complete process the thread_id in the options should be /// set to LLDB_INVALID_THREAD_ID. The API returns a user_id which is needed @@ -2782,48 +2408,40 @@ public: /// implementations in the server, as they could be returned as an error, or /// rounded to a valid configuration to start tracing. In the later case the /// GetTraceConfig should supply the actual used trace configuration. - //------------------------------------------------------------------ virtual lldb::user_id_t StartTrace(const TraceOptions &options, Status &error) { error.SetErrorString("Not implemented"); return LLDB_INVALID_UID; } - //------------------------------------------------------------------ /// Stops the tracing instance leading to deletion of the trace data. The /// tracing instance is identified by the user_id which is obtained when /// tracing was started from the StartTrace. In case tracing of the complete /// process needs to be stopped the thread_id should be set to /// LLDB_INVALID_THREAD_ID. In the other case that tracing on an individual /// thread needs to be stopped a thread_id can be supplied. - //------------------------------------------------------------------ virtual Status StopTrace(lldb::user_id_t uid, lldb::tid_t thread_id) { return Status("Not implemented"); } - //------------------------------------------------------------------ /// Provides the trace data as raw bytes. A buffer needs to be supplied to /// copy the trace data. The exact behavior of this API may vary across /// trace technology, as some may support partial reading of the trace data /// from a specified offset while some may not. The thread_id should be used /// to select a particular thread for trace extraction. - //------------------------------------------------------------------ virtual Status GetData(lldb::user_id_t uid, lldb::tid_t thread_id, llvm::MutableArrayRef<uint8_t> &buffer, size_t offset = 0) { return Status("Not implemented"); } - //------------------------------------------------------------------ /// Similar API as above except for obtaining meta data - //------------------------------------------------------------------ virtual Status GetMetaData(lldb::user_id_t uid, lldb::tid_t thread_id, llvm::MutableArrayRef<uint8_t> &buffer, size_t offset = 0) { return Status("Not implemented"); } - //------------------------------------------------------------------ /// API to obtain the trace configuration used by a trace instance. /// Configurations that may be specific to some trace technology should be /// stored in the custom parameters. The options are transported to the @@ -2831,7 +2449,6 @@ public: /// specified in the options to obtain the configuration used by a specific /// thread. The thread_id specified should also match the uid otherwise an /// error will be returned. - //------------------------------------------------------------------ virtual Status GetTraceConfig(lldb::user_id_t uid, TraceOptions &options) { return Status("Not implemented"); } @@ -2841,21 +2458,16 @@ protected: lldb::StateType GetPrivateState(); - //------------------------------------------------------------------ /// The "private" side of resuming a process. This doesn't alter the state /// of m_run_lock, but just causes the process to resume. /// - /// @return + /// \return /// An Status object describing the success or failure of the resume. - //------------------------------------------------------------------ Status PrivateResume(); - //------------------------------------------------------------------ // Called internally - //------------------------------------------------------------------ void CompleteAttach(); - //------------------------------------------------------------------ /// Print a user-visible warning one time per Process /// /// A facility for printing a warning to the user once per repeat_key. @@ -2872,21 +2484,19 @@ protected: /// that the warning strings are all centralized in Process, instead of /// calling PrintWarning() directly. /// - /// @param [in] warning_type + /// \param [in] warning_type /// One of the types defined in Process::Warnings. /// - /// @param [in] repeat_key + /// \param [in] repeat_key /// A pointer value used to ensure that the warning is only printed once. /// May be nullptr, indicating that the warning is printed unconditionally /// every time. /// - /// @param [in] fmt + /// \param [in] fmt /// printf style format string - //------------------------------------------------------------------ void PrintWarning(uint64_t warning_type, const void *repeat_key, const char *fmt, ...) __attribute__((format(printf, 4, 5))); - //------------------------------------------------------------------ // NextEventAction provides a way to register an action on the next event // that is delivered to this process. There is currently only one next event // action allowed in the process at one time. If a new "NextEventAction" is @@ -2895,14 +2505,13 @@ protected: // // If you want to resume the process as a result of a resume action, call // RequestResume, don't call Resume directly. - //------------------------------------------------------------------ class NextEventAction { public: - typedef enum EventActionResult { + enum EventActionResult { eEventActionSuccess, eEventActionRetry, eEventActionExit - } EventActionResult; + }; NextEventAction(Process *process) : m_process(process) {} @@ -2919,10 +2528,10 @@ protected: }; void SetNextEventAction(Process::NextEventAction *next_event_action) { - if (m_next_event_action_ap.get()) - m_next_event_action_ap->HandleBeingUnshipped(); + if (m_next_event_action_up.get()) + m_next_event_action_up->HandleBeingUnshipped(); - m_next_event_action_ap.reset(next_event_action); + m_next_event_action_up.reset(next_event_action); } // This is the completer for Attaching: @@ -2949,7 +2558,6 @@ protected: void ForceNextEventDelivery() { m_force_next_event_delivery = true; } - //------------------------------------------------------------------ /// Loads any plugins associated with asynchronous structured data and maps /// the relevant supported type name to the plugin. /// @@ -2962,22 +2570,20 @@ protected: /// named 'type', with a value that equals the relevant type name string /// (one of the values in \b supported_type_names). /// - /// @param[in] supported_type_names + /// \param[in] supported_type_names /// An array of zero or more type names. Each must be unique. /// For each entry in the list, a StructuredDataPlugin will be /// searched for that supports the structured data type name. - //------------------------------------------------------------------ void MapSupportedStructuredDataPlugins( const StructuredData::Array &supported_type_names); - //------------------------------------------------------------------ /// Route the incoming structured data dictionary to the right plugin. /// /// The incoming structured data must be a dictionary, and it must have a /// key named 'type' that stores a string value. The string value must be /// the name of the structured data feature that knows how to handle it. /// - /// @param[in] object_sp + /// \param[in] object_sp /// When non-null and pointing to a dictionary, the 'type' /// key's string value is used to look up the plugin that /// was registered for that structured data type. It then @@ -2986,19 +2592,16 @@ protected: /// /// virtual void /// HandleArrivalOfStructuredData(Process &process, - /// const ConstString &type_name, + /// ConstString type_name, /// const StructuredData::ObjectSP /// &object_sp) /// - /// @return + /// \return /// True if the structured data was routed to a plugin; otherwise, /// false. - //------------------------------------------------------------------ bool RouteAsyncStructuredData(const StructuredData::ObjectSP object_sp); - //------------------------------------------------------------------ // Type definitions - //------------------------------------------------------------------ typedef std::map<lldb::LanguageType, lldb::LanguageRuntimeSP> LanguageRuntimeCollection; typedef std::unordered_set<const void *> WarningsPointerSet; @@ -3018,9 +2621,7 @@ protected: using StructuredDataPluginMap = std::map<ConstString, lldb::StructuredDataPluginSP>; - //------------------------------------------------------------------ // Member variables - //------------------------------------------------------------------ std::weak_ptr<Target> m_target_wp; ///< The target that owns this process. ThreadSafeValue<lldb::StateType> m_public_state; ThreadSafeValue<lldb::StateType> @@ -3071,15 +2672,15 @@ protected: 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; - lldb::DynamicCheckerFunctionsUP m_dynamic_checkers_ap; ///< The functions used - ///by the expression - ///parser to validate - ///data that - ///expressions use. - lldb::OperatingSystemUP m_os_ap; - lldb::SystemRuntimeUP m_system_runtime_ap; + lldb::DynamicLoaderUP m_dyld_up; + lldb::JITLoaderListUP m_jit_loaders_up; + lldb::DynamicCheckerFunctionsUP m_dynamic_checkers_up; ///< The functions used + /// by the expression + /// parser to validate + /// data that + /// expressions use. + lldb::OperatingSystemUP m_os_up; + lldb::SystemRuntimeUP m_system_runtime_up; lldb::UnixSignalsSP m_unix_signals_sp; /// This is the current signal set for this process. lldb::ABISP m_abi_sp; @@ -3098,8 +2699,9 @@ protected: bool m_should_detach; /// Should we detach if the process object goes away /// with an explicit call to Kill or Detach? LanguageRuntimeCollection m_language_runtimes; + std::recursive_mutex m_language_runtimes_mutex; InstrumentationRuntimeCollection m_instrumentation_runtimes; - std::unique_ptr<NextEventAction> m_next_event_action_ap; + std::unique_ptr<NextEventAction> m_next_event_action_up; std::vector<PreResumeCallbackAndBaton> m_pre_resume_actions; ProcessRunLock m_public_run_lock; ProcessRunLock m_private_run_lock; @@ -3212,12 +2814,9 @@ protected: virtual Status UpdateAutomaticSignalFiltering(); - bool StateChangedIsExternallyHijacked(); - void LoadOperatingSystemPlugin(bool flush); private: - //------------------------------------------------------------------ /// This is the part of the event handling that for a process event. It /// decides what to do with the event and returns true if the event needs to /// be propagated to the user, and false otherwise. If the event is not @@ -3225,13 +2824,12 @@ private: /// again. There is only one place where this call should be called, /// HandlePrivateEvent. Don't call it from anywhere else... /// - /// @param[in] event_ptr + /// \param[in] event_ptr /// This is the event we are handling. /// - /// @return + /// \return /// Returns \b true if the event should be reported to the /// user, \b false otherwise. - //------------------------------------------------------------------ bool ShouldBroadcastEvent(Event *event_ptr); void ControlPrivateStateThread(uint32_t signal); @@ -3239,10 +2837,8 @@ private: DISALLOW_COPY_AND_ASSIGN(Process); }; -//------------------------------------------------------------------ /// RAII guard that should be aquired when an utility function is called within /// a given process. -//------------------------------------------------------------------ class UtilityFunctionScope { Process *m_process; diff --git a/include/lldb/Target/ProcessInfo.h b/include/lldb/Target/ProcessInfo.h deleted file mode 100644 index 0e0d8548feb6f..0000000000000 --- a/include/lldb/Target/ProcessInfo.h +++ /dev/null @@ -1,102 +0,0 @@ -//===-- ProcessInfo.h -------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_ProcessInfo_h_ -#define liblldb_ProcessInfo_h_ - -// LLDB headers -#include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/Args.h" -#include "lldb/Utility/Environment.h" -#include "lldb/Utility/FileSpec.h" - -namespace lldb_private { -//---------------------------------------------------------------------- -// ProcessInfo -// -// A base class for information for a process. This can be used to fill -// out information for a process prior to launching it, or it can be used for -// an instance of a process and can be filled in with the existing values for -// that process. -//---------------------------------------------------------------------- -class ProcessInfo { -public: - ProcessInfo(); - - ProcessInfo(const char *name, const ArchSpec &arch, lldb::pid_t pid); - - void Clear(); - - const char *GetName() const; - - size_t GetNameLength() const; - - FileSpec &GetExecutableFile() { return m_executable; } - - void SetExecutableFile(const FileSpec &exe_file, - bool add_exe_file_as_first_arg); - - const FileSpec &GetExecutableFile() const { return m_executable; } - - uint32_t GetUserID() const { return m_uid; } - - uint32_t GetGroupID() const { return m_gid; } - - bool UserIDIsValid() const { return m_uid != UINT32_MAX; } - - bool GroupIDIsValid() const { return m_gid != UINT32_MAX; } - - void SetUserID(uint32_t uid) { m_uid = uid; } - - void SetGroupID(uint32_t gid) { m_gid = gid; } - - ArchSpec &GetArchitecture() { return m_arch; } - - const ArchSpec &GetArchitecture() const { return m_arch; } - - void SetArchitecture(const ArchSpec &arch) { m_arch = arch; } - - lldb::pid_t GetProcessID() const { return m_pid; } - - void SetProcessID(lldb::pid_t pid) { m_pid = pid; } - - bool ProcessIDIsValid() const { return m_pid != LLDB_INVALID_PROCESS_ID; } - - void Dump(Stream &s, Platform *platform) const; - - Args &GetArguments() { return m_arguments; } - - const Args &GetArguments() const { return m_arguments; } - - llvm::StringRef GetArg0() const; - - void SetArg0(llvm::StringRef arg); - - void SetArguments(const Args &args, bool first_arg_is_executable); - - void SetArguments(char const **argv, bool first_arg_is_executable); - - Environment &GetEnvironment() { return m_environment; } - const Environment &GetEnvironment() const { return m_environment; } - -protected: - FileSpec m_executable; - std::string m_arg0; // argv[0] if supported. If empty, then use m_executable. - // Not all process plug-ins support specifying an argv[0] that differs from - // the resolved platform executable (which is in m_executable) - Args m_arguments; // All program arguments except argv[0] - Environment m_environment; - uint32_t m_uid; - uint32_t m_gid; - ArchSpec m_arch; - lldb::pid_t m_pid; -}; -} - -#endif // #ifndef liblldb_ProcessInfo_h_ diff --git a/include/lldb/Target/ProcessLaunchInfo.h b/include/lldb/Target/ProcessLaunchInfo.h deleted file mode 100644 index ef1d63035b18c..0000000000000 --- a/include/lldb/Target/ProcessLaunchInfo.h +++ /dev/null @@ -1,171 +0,0 @@ -//===-- ProcessLaunchInfo.h -------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_ProcessLaunch_Info_h -#define liblldb_ProcessLaunch_Info_h - -// C++ Headers -#include <string> - -// LLDB Headers -#include "lldb/Utility/Flags.h" - -#include "lldb/Host/Host.h" -#include "lldb/Host/PseudoTerminal.h" -#include "lldb/Target/FileAction.h" -#include "lldb/Target/ProcessInfo.h" -#include "lldb/Utility/FileSpec.h" - -namespace lldb_private { - -//---------------------------------------------------------------------- -// ProcessLaunchInfo -// -// Describes any information that is required to launch a process. -//---------------------------------------------------------------------- - -class ProcessLaunchInfo : public ProcessInfo { -public: - ProcessLaunchInfo(); - - ProcessLaunchInfo(const FileSpec &stdin_file_spec, - const FileSpec &stdout_file_spec, - const FileSpec &stderr_file_spec, - const FileSpec &working_dir, uint32_t launch_flags); - - void AppendFileAction(const FileAction &info) { - m_file_actions.push_back(info); - } - - bool AppendCloseFileAction(int fd); - - bool AppendDuplicateFileAction(int fd, int dup_fd); - - bool AppendOpenFileAction(int fd, const FileSpec &file_spec, bool read, - bool write); - - bool AppendSuppressFileAction(int fd, bool read, bool write); - - // Redirect stdin/stdout/stderr to a pty, if no action for the respective file - // descriptor is specified. (So if stdin and stdout already have file actions, - // but stderr doesn't, then only stderr will be redirected to a pty.) - llvm::Error SetUpPtyRedirection(); - - size_t GetNumFileActions() const { return m_file_actions.size(); } - - const FileAction *GetFileActionAtIndex(size_t idx) const; - - const FileAction *GetFileActionForFD(int fd) const; - - Flags &GetFlags() { return m_flags; } - - const Flags &GetFlags() const { return m_flags; } - - const FileSpec &GetWorkingDirectory() const; - - void SetWorkingDirectory(const FileSpec &working_dir); - - const char *GetProcessPluginName() const; - - void SetProcessPluginName(llvm::StringRef plugin); - - const FileSpec &GetShell() const; - - void SetShell(const FileSpec &shell); - - uint32_t GetResumeCount() const { return m_resume_count; } - - void SetResumeCount(uint32_t c) { m_resume_count = c; } - - bool GetLaunchInSeparateProcessGroup() const { - return m_flags.Test(lldb::eLaunchFlagLaunchInSeparateProcessGroup); - } - - void SetLaunchInSeparateProcessGroup(bool separate); - - bool GetShellExpandArguments() const { - return m_flags.Test(lldb::eLaunchFlagShellExpandArguments); - } - - void SetShellExpandArguments(bool expand); - - void Clear(); - - bool ConvertArgumentsForLaunchingInShell(Status &error, bool localhost, - bool will_debug, - bool first_arg_is_full_shell_command, - int32_t num_resumes); - - void - SetMonitorProcessCallback(const Host::MonitorChildProcessCallback &callback, - bool monitor_signals); - - Host::MonitorChildProcessCallback GetMonitorProcessCallback() const { - return m_monitor_callback; - } - - /// A Monitor callback which does not take any action on process events. Use - /// this if you don't need to take any particular action when the process - /// terminates, but you still need to reap it. - static bool NoOpMonitorCallback(lldb::pid_t pid, bool exited, int signal, - int status); - - bool GetMonitorSignals() const { return m_monitor_signals; } - - // If the LaunchInfo has a monitor callback, then arrange to monitor the - // process. Return true if the LaunchInfo has taken care of monitoring the - // process, and false if the caller might want to monitor the process - // themselves. - - bool MonitorProcess() const; - - PseudoTerminal &GetPTY() { return *m_pty; } - - // Get and set the actual listener that will be used for the process events - lldb::ListenerSP GetListener() const { return m_listener_sp; } - - void SetListener(const lldb::ListenerSP &listener_sp) { - m_listener_sp = listener_sp; - } - - lldb::ListenerSP GetHijackListener() const { return m_hijack_listener_sp; } - - void SetHijackListener(const lldb::ListenerSP &listener_sp) { - m_hijack_listener_sp = listener_sp; - } - - void SetLaunchEventData(const char *data) { m_event_data.assign(data); } - - const char *GetLaunchEventData() const { return m_event_data.c_str(); } - - void SetDetachOnError(bool enable); - - bool GetDetachOnError() const { - return m_flags.Test(lldb::eLaunchFlagDetachOnError); - } - -protected: - FileSpec m_working_dir; - std::string m_plugin_name; - FileSpec m_shell; - Flags m_flags; // Bitwise OR of bits from lldb::LaunchFlags - std::vector<FileAction> m_file_actions; // File actions for any other files - std::shared_ptr<PseudoTerminal> m_pty; - uint32_t m_resume_count; // How many times do we resume after launching - Host::MonitorChildProcessCallback m_monitor_callback; - void *m_monitor_callback_baton; - bool m_monitor_signals; - std::string m_event_data; // A string passed to the plugin launch, having no - // meaning to the upper levels of lldb. - lldb::ListenerSP m_listener_sp; - lldb::ListenerSP m_hijack_listener_sp; -}; -} - -#endif // liblldb_ProcessLaunch_Info_h diff --git a/include/lldb/Target/ProcessStructReader.h b/include/lldb/Target/ProcessStructReader.h index 79f0b4cccd455..ade29c0a7cf7f 100644 --- a/include/lldb/Target/ProcessStructReader.h +++ b/include/lldb/Target/ProcessStructReader.h @@ -1,9 +1,8 @@ //===---------------------ProcessStructReader.h ------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/Queue.h b/include/lldb/Target/Queue.h index 62cc3ccf2e2fc..01e8994f24418 100644 --- a/include/lldb/Target/Queue.h +++ b/include/lldb/Target/Queue.h @@ -1,9 +1,8 @@ //===-- Queue.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,7 +19,6 @@ namespace lldb_private { -//------------------------------------------------------------------ // Queue: // This class represents a libdispatch aka Grand Central Dispatch queue in the // process. @@ -30,7 +28,6 @@ namespace lldb_private { // pthreads to execute the work items for the queues. A serial queue will be // associated with a single thread (or possibly no thread, if it is not doing // any work). A concurrent queue may be associated with multiple threads. -//------------------------------------------------------------------ class Queue : public std::enable_shared_from_this<Queue> { public: @@ -39,7 +36,6 @@ public: ~Queue(); - //------------------------------------------------------------------ /// Get the QueueID for this Queue /// /// A 64-bit ID number that uniquely identifies a queue at this particular @@ -48,21 +44,17 @@ public: /// each queue. A serialnum is not reused for a different queue in the /// lifetime of that process execution. /// - /// @return + /// \return /// The QueueID for this Queue. - //------------------------------------------------------------------ lldb::queue_id_t GetID(); - //------------------------------------------------------------------ /// Get the name of this Queue /// - /// @return + /// \return /// The name of the queue, if one is available. /// A NULL pointer is returned if none is available. - //------------------------------------------------------------------ const char *GetName(); - //------------------------------------------------------------------ /// Get the IndexID for this Queue /// /// This is currently the same as GetID(). If it changes in the future, @@ -73,66 +65,55 @@ public: /// maintain similar API to the Thread class, and allow for the /// possibility of GetID changing to a different source in the future. /// - /// @return + /// \return /// The IndexID for this queue. - //------------------------------------------------------------------ uint32_t GetIndexID(); - //------------------------------------------------------------------ /// Return the threads currently associated with this queue /// /// Zero, one, or many threads may be executing code for a queue at /// a given point in time. This call returns the list of threads /// that are currently executing work for this queue. /// - /// @return + /// \return /// The threads currently performing work for this queue - //------------------------------------------------------------------ std::vector<lldb::ThreadSP> GetThreads(); - //------------------------------------------------------------------ /// Return the items that are currently enqueued /// /// "Enqueued" means that the item has been added to the queue to /// be done, but has not yet been done. When the item is going to /// be processed it is "dequeued". /// - /// @return + /// \return /// The vector of enqueued items for this queue - //------------------------------------------------------------------ const std::vector<lldb::QueueItemSP> &GetPendingItems(); lldb::ProcessSP GetProcess() const { return m_process_wp.lock(); } - //------------------------------------------------------------------ /// Get the number of work items that this queue is currently running /// - /// @return + /// \return /// The number of work items currently executing. For a serial /// queue, this will be 0 or 1. For a concurrent queue, this /// may be any number. - //------------------------------------------------------------------ uint32_t GetNumRunningWorkItems() const; - //------------------------------------------------------------------ /// Get the number of work items enqueued on this queue /// - /// @return + /// \return /// The number of work items currently enqueued, waiting to /// execute. - //------------------------------------------------------------------ uint32_t GetNumPendingWorkItems() const; - //------------------------------------------------------------------ /// Get the dispatch_queue_t structure address for this Queue /// /// Get the address in the inferior process' memory of this Queue's /// dispatch_queue_t structure. /// - /// @return + /// \return /// The address of the dispatch_queue_t structure, if known. /// LLDB_INVALID_ADDRESS will be returned if it is unavailable. - //------------------------------------------------------------------ lldb::addr_t GetLibdispatchQueueAddress() const; void SetNumRunningWorkItems(uint32_t count); @@ -145,20 +126,16 @@ public: m_pending_items.push_back(item); } - //------------------------------------------------------------------ /// Return the kind (serial, concurrent) of this queue /// - /// @return + /// \return // Whether this is a serial or a concurrent queue - //------------------------------------------------------------------ lldb::QueueKind GetKind(); void SetKind(lldb::QueueKind kind); private: - //------------------------------------------------------------------ // For Queue only - //------------------------------------------------------------------ lldb::ProcessWP m_process_wp; lldb::queue_id_t m_queue_id; diff --git a/include/lldb/Target/QueueItem.h b/include/lldb/Target/QueueItem.h index 3fd331ca525af..dfae3b8472633 100644 --- a/include/lldb/Target/QueueItem.h +++ b/include/lldb/Target/QueueItem.h @@ -1,9 +1,8 @@ //===-- QueueItem.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,14 +22,12 @@ namespace lldb_private { -//------------------------------------------------------------------ // QueueItem: // This class represents a work item enqueued on a libdispatch aka Grand // Central Dispatch (GCD) queue. Most often, this will be a function or block. // "enqueued" here means that the work item has been added to a queue but it // has not yet started executing. When it is "dequeued", execution of the item // begins. -//------------------------------------------------------------------ class QueueItem : public std::enable_shared_from_this<QueueItem> { public: @@ -39,71 +36,59 @@ public: ~QueueItem(); - //------------------------------------------------------------------ /// Get the kind of work item this is /// - /// @return + /// \return /// The type of work item that this QueueItem object /// represents. eQueueItemKindUnknown may be returned. - //------------------------------------------------------------------ lldb::QueueItemKind GetKind(); - //------------------------------------------------------------------ /// Set the type of work item this is /// - /// @param [in] item_kind + /// \param [in] item_kind /// Set the kind of this work item object. - //------------------------------------------------------------------ void SetKind(lldb::QueueItemKind item_kind); - //------------------------------------------------------------------ /// Get the code address that will be executed when this work item /// is executed. /// - /// @return + /// \return /// The address that will be invoked when this work item is /// executed. Not all types of QueueItems will have an /// address associated with them; check that the returned /// Address is valid, or check that the WorkItemKind is a /// kind that involves an address, such as eQueueItemKindFunction /// or eQueueItemKindBlock. - //------------------------------------------------------------------ lldb_private::Address &GetAddress(); - //------------------------------------------------------------------ /// Set the work item address for this object /// - /// @param [in] addr + /// \param [in] addr /// The address that will be invoked when this work item /// is executed. - //------------------------------------------------------------------ void SetAddress(lldb_private::Address addr); - //------------------------------------------------------------------ /// Check if this QueueItem object is valid /// /// If the weak pointer to the parent Queue cannot be revivified, /// it is invalid. /// - /// @return + /// \return /// True if this object is valid. - //------------------------------------------------------------------ bool IsValid() { return m_queue_wp.lock() != nullptr; } - //------------------------------------------------------------------ /// Get an extended backtrace thread for this queue item, if available /// /// If the backtrace/thread information was collected when this item /// was enqueued, this call will provide it. /// - /// @param [in] type + /// \param [in] type /// The type of extended backtrace being requested, e.g. "libdispatch" /// or "pthread". /// - /// @return + /// \return /// A thread shared pointer which will have a reference to an extended /// thread if one was available. - //------------------------------------------------------------------ lldb::ThreadSP GetExtendedBacktraceThread(ConstString type); void SetItemThatEnqueuedThis(lldb::addr_t address_of_item) { diff --git a/include/lldb/Target/QueueList.h b/include/lldb/Target/QueueList.h index b35de13aa1e54..761107e41def6 100644 --- a/include/lldb/Target/QueueList.h +++ b/include/lldb/Target/QueueList.h @@ -1,9 +1,8 @@ //===-- QueueList.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -19,14 +18,12 @@ namespace lldb_private { -//------------------------------------------------------------------ // QueueList: // This is the container for libdispatch aka Grand Central Dispatch Queue // objects. // // Each Process will have a QueueList. When the process execution is paused, // the QueueList may be populated with Queues by the SystemRuntime. -//------------------------------------------------------------------ class QueueList { friend class Process; @@ -36,22 +33,18 @@ public: ~QueueList(); - //------------------------------------------------------------------ /// Get the number of libdispatch queues that are available /// - /// @return + /// \return /// The number of queues that are stored in the QueueList. - //------------------------------------------------------------------ uint32_t GetSize(); - //------------------------------------------------------------------ /// Get the Queue at a given index number /// - /// @param [in] idx + /// \param [in] idx /// The index number (0-based) of the queue. - /// @return + /// \return /// The Queue at that index number. - //------------------------------------------------------------------ lldb::QueueSP GetQueueAtIndex(uint32_t idx); typedef std::vector<lldb::QueueSP> collection; @@ -59,61 +52,49 @@ public: std::mutex> QueueIterable; - //------------------------------------------------------------------ /// Iterate over the list of queues /// - /// @return + /// \return /// An Iterable object which can be used to loop over the queues /// that exist. - //------------------------------------------------------------------ QueueIterable Queues() { return QueueIterable(m_queues, m_mutex); } - //------------------------------------------------------------------ /// Clear out the list of queues from the QueueList - //------------------------------------------------------------------ void Clear(); - //------------------------------------------------------------------ /// Add a Queue to the QueueList /// - /// @param [in] queue + /// \param [in] queue /// Used by the SystemRuntime to populate the QueueList - //------------------------------------------------------------------ void AddQueue(lldb::QueueSP queue); - //------------------------------------------------------------------ /// Find a queue in the QueueList by QueueID /// - /// @param [in] qid + /// \param [in] qid /// The QueueID (same as returned by Thread::GetQueueID()) to find. /// - /// @return + /// \return /// A QueueSP to the queue requested, if it is present in the QueueList. /// An empty QueueSP will be returned if this queue was not found. - //------------------------------------------------------------------ lldb::QueueSP FindQueueByID(lldb::queue_id_t qid); - //------------------------------------------------------------------ /// Find a queue in the QueueList by IndexID /// - /// @param [in] index_id + /// \param [in] index_id /// Find a queue by IndexID. This is an integer associated with each /// unique queue seen during a debug session and will not be reused /// for a different queue. Unlike the QueueID, a 64-bit value, this /// will tend to be an integral value like 1 or 7. /// - /// @return + /// \return /// A QueueSP to the queue requested, if it is present in the QueueList. /// An empty QueueSP will be returned if this queue was not found. - //------------------------------------------------------------------ lldb::QueueSP FindQueueByIndexID(uint32_t index_id); std::mutex &GetMutex(); protected: - //------------------------------------------------------------------ // Classes that inherit from Process can see and modify these - //------------------------------------------------------------------ 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. @@ -121,7 +102,7 @@ protected: std::mutex m_mutex; private: - QueueList(); + QueueList() = delete; }; } // namespace lldb_private diff --git a/include/lldb/Target/RegisterCheckpoint.h b/include/lldb/Target/RegisterCheckpoint.h index e4b407124c9fc..4f9654f763437 100644 --- a/include/lldb/Target/RegisterCheckpoint.h +++ b/include/lldb/Target/RegisterCheckpoint.h @@ -1,9 +1,8 @@ //===-- RegisterCheckpoint.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/RegisterContext.h b/include/lldb/Target/RegisterContext.h index a24c270a1e5e9..d6212dd49dd6b 100644 --- a/include/lldb/Target/RegisterContext.h +++ b/include/lldb/Target/RegisterContext.h @@ -1,9 +1,8 @@ //===-- RegisterContext.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -18,18 +17,14 @@ namespace lldb_private { class RegisterContext : public std::enable_shared_from_this<RegisterContext>, public ExecutionContextScope { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ RegisterContext(Thread &thread, uint32_t concrete_frame_idx); ~RegisterContext() override; void InvalidateIfNeeded(bool force); - //------------------------------------------------------------------ // Subclasses must override these functions - //------------------------------------------------------------------ virtual void InvalidateAllRegisters() = 0; virtual size_t GetRegisterCount() = 0; @@ -76,7 +71,6 @@ public: bool CopyFromRegisterContext(lldb::RegisterContextSP context); - //------------------------------------------------------------------ /// Convert from a given register numbering scheme to the lldb register /// numbering scheme /// @@ -100,23 +94,20 @@ public: /// This method translates a given register kind + register number into /// the eRegisterKindLLDB register numbering. /// - /// @param [in] kind + /// \param [in] kind /// The register numbering scheme (RegisterKind) that the following /// register number is in. /// - /// @param [in] num + /// \param [in] num /// A register number in the 'kind' register numbering scheme. /// - /// @return + /// \return /// The equivalent register number in the eRegisterKindLLDB /// numbering scheme, if possible, else LLDB_INVALID_REGNUM. - //------------------------------------------------------------------ virtual uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) = 0; - //------------------------------------------------------------------ // Subclasses can override these functions if desired - //------------------------------------------------------------------ virtual uint32_t NumSupportedHardwareBreakpoints(); virtual uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size); @@ -142,9 +133,7 @@ public: lldb::addr_t dst_addr, uint32_t dst_len, const RegisterValue ®_value); - //------------------------------------------------------------------ // Subclasses should not override these - //------------------------------------------------------------------ virtual lldb::tid_t GetThreadID() const; virtual Thread &GetThread() { return m_thread; } @@ -189,9 +178,7 @@ public: lldb::RegisterKind target_rk, uint32_t &target_regnum); - //------------------------------------------------------------------ // lldb::ExecutionContextScope pure virtual functions - //------------------------------------------------------------------ lldb::TargetSP CalculateTarget() override; lldb::ProcessSP CalculateProcess() override; @@ -207,17 +194,13 @@ public: void SetStopID(uint32_t stop_id) { m_stop_id = stop_id; } protected: - //------------------------------------------------------------------ // Classes that inherit from RegisterContext can see and modify these - //------------------------------------------------------------------ Thread &m_thread; // The thread that this register context belongs to. uint32_t m_concrete_frame_idx; // The concrete frame index for this register // context uint32_t m_stop_id; // The stop ID that any data in this context is valid for private: - //------------------------------------------------------------------ // For RegisterContext only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(RegisterContext); }; diff --git a/include/lldb/Target/RegisterNumber.h b/include/lldb/Target/RegisterNumber.h index 1a0ab49bdce39..0bef0c13f3785 100644 --- a/include/lldb/Target/RegisterNumber.h +++ b/include/lldb/Target/RegisterNumber.h @@ -1,9 +1,8 @@ //===-- RegisterNumber.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -13,11 +12,9 @@ #include "lldb/lldb-private.h" #include <map> -//-------------------------------------------------------------------- /// A class to represent register numbers, and able to convert between /// different register numbering schemes that may be used in a single /// debug session. -//-------------------------------------------------------------------- class RegisterNumber { public: diff --git a/include/lldb/Target/RemoteAwarePlatform.h b/include/lldb/Target/RemoteAwarePlatform.h new file mode 100644 index 0000000000000..524332f948a54 --- /dev/null +++ b/include/lldb/Target/RemoteAwarePlatform.h @@ -0,0 +1,97 @@ +//===-- RemoteAwarePlatform.h -----------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_TARGET_REMOTEAWAREPLATFORM_H +#define LLDB_TARGET_REMOTEAWAREPLATFORM_H + +#include "lldb/Target/Platform.h" + +namespace lldb_private { + +/// A base class for platforms which automatically want to be able to forward +/// operations to a remote platform instance (such as PlatformRemoteGDBServer). +class RemoteAwarePlatform : public Platform { +public: + using Platform::Platform; + + bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch, + ModuleSpec &module_spec) override; + + lldb::user_id_t OpenFile(const FileSpec &file_spec, uint32_t flags, + uint32_t mode, Status &error) override; + + bool CloseFile(lldb::user_id_t fd, Status &error) override; + + uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, + uint64_t dst_len, Status &error) override; + + uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, + uint64_t src_len, Status &error) override; + + lldb::user_id_t GetFileSize(const FileSpec &file_spec) override; + + Status CreateSymlink(const FileSpec &src, const FileSpec &dst) override; + + bool GetFileExists(const FileSpec &file_spec) override; + + Status Unlink(const FileSpec &file_spec) override; + + FileSpec GetRemoteWorkingDirectory() override; + + bool SetRemoteWorkingDirectory(const FileSpec &working_dir) override; + + Status MakeDirectory(const FileSpec &file_spec, uint32_t mode) override; + + Status GetFilePermissions(const FileSpec &file_spec, + uint32_t &file_permissions) override; + + Status SetFilePermissions(const FileSpec &file_spec, + uint32_t file_permissions) override; + + bool CalculateMD5(const FileSpec &file_spec, uint64_t &low, + uint64_t &high) override; + + Status GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid, + FileSpec &local_file) override; + + bool GetRemoteOSVersion() override; + bool GetRemoteOSBuildString(std::string &s) override; + bool GetRemoteOSKernelDescription(std::string &s) override; + ArchSpec GetRemoteSystemArchitecture() override; + + Status RunShellCommand(const char *command, const FileSpec &working_dir, + int *status_ptr, int *signo_ptr, + std::string *command_output, + const Timeout<std::micro> &timeout) override; + + const char *GetHostname() override; + UserIDResolver &GetUserIDResolver() override; + lldb_private::Environment GetEnvironment() override; + + bool IsConnected() const override; + + bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info) override; + uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info, + ProcessInstanceInfoList &process_infos) override; + + lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url, + llvm::StringRef plugin_name, + Debugger &debugger, Target *target, + Status &error) override; + + Status LaunchProcess(ProcessLaunchInfo &launch_info) override; + + Status KillProcess(const lldb::pid_t pid) override; + +protected: + lldb::PlatformSP m_remote_platform_sp; +}; + +} // namespace lldb_private + +#endif // LLDB_TARGET_REMOTEAWAREPLATFORM_H diff --git a/include/lldb/Target/SectionLoadHistory.h b/include/lldb/Target/SectionLoadHistory.h index 0a14fc05c458f..71b5d0c427463 100644 --- a/include/lldb/Target/SectionLoadHistory.h +++ b/include/lldb/Target/SectionLoadHistory.h @@ -1,9 +1,8 @@ //===-- SectionLoadHistory.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,9 +23,7 @@ public: // value. eStopIDNow = UINT32_MAX }; - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ SectionLoadHistory() : m_stop_id_to_section_load_list(), m_mutex() {} ~SectionLoadHistory() { diff --git a/include/lldb/Target/SectionLoadList.h b/include/lldb/Target/SectionLoadList.h index 2a321e7a25454..caefa00ec1daa 100644 --- a/include/lldb/Target/SectionLoadList.h +++ b/include/lldb/Target/SectionLoadList.h @@ -1,10 +1,9 @@ //===-- SectionLoadList.h -----------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,9 +21,7 @@ namespace lldb_private { class SectionLoadList { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ SectionLoadList() : m_addr_to_sect(), m_sect_to_addr(), m_mutex() {} SectionLoadList(const SectionLoadList &rhs); diff --git a/include/lldb/Target/StackFrame.h b/include/lldb/Target/StackFrame.h index a4e31a567440a..4e6e79befc6ab 100644 --- a/include/lldb/Target/StackFrame.h +++ b/include/lldb/Target/StackFrame.h @@ -1,9 +1,8 @@ //===-- StackFrame.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -26,7 +25,7 @@ namespace lldb_private { -/// @class StackFrame StackFrame.h "lldb/Target/StackFrame.h" +/// \class StackFrame StackFrame.h "lldb/Target/StackFrame.h" /// /// This base class provides an interface to stack frames. /// @@ -64,7 +63,6 @@ public: Artificial }; - //------------------------------------------------------------------ /// Construct a StackFrame object without supplying a RegisterContextSP. /// /// This is the one constructor that doesn't take a RegisterContext @@ -73,19 +71,19 @@ public: /// point in the past. We may only have pc values. We may have a CFA, /// or more likely, we won't. /// - /// @param [in] thread_sp + /// \param [in] thread_sp /// The Thread that this frame belongs to. /// - /// @param [in] frame_idx + /// \param [in] frame_idx /// This StackFrame's frame index number in the Thread. If inlined stack /// frames are being created, this may differ from the concrete_frame_idx /// which is the frame index without any inlined stack frames. /// - /// @param [in] concrete_frame_idx + /// \param [in] concrete_frame_idx /// The StackFrame's frame index number in the Thread without any inlined /// stack frames being included in the index. /// - /// @param [in] cfa + /// \param [in] cfa /// The Canonical Frame Address (this terminology from DWARF) for this /// stack frame. The CFA for a stack frame does not change over the /// span of the stack frame's existence. It is often the value of the @@ -93,21 +91,20 @@ public: /// function. It is usually not the same as the frame pointer register's /// value. /// - /// @param [in] cfa_is_valid + /// \param [in] cfa_is_valid /// A history stack frame may not have a CFA value collected. We want to /// distinguish between "no CFA available" and a CFA of /// LLDB_INVALID_ADDRESS. /// - /// @param [in] pc + /// \param [in] pc /// The current pc value of this stack frame. /// - /// @param [in] frame_kind + /// \param [in] frame_kind /// - /// @param [in] sc_ptr + /// \param [in] sc_ptr /// Optionally seed the StackFrame with the SymbolContext information that /// has /// already been discovered. - //------------------------------------------------------------------ StackFrame(const lldb::ThreadSP &thread_sp, lldb::user_id_t frame_idx, lldb::user_id_t concrete_frame_idx, lldb::addr_t cfa, bool cfa_is_valid, lldb::addr_t pc, Kind frame_kind, @@ -129,31 +126,26 @@ public: StackID &GetStackID(); - //------------------------------------------------------------------ /// Get an Address for the current pc value in this StackFrame. /// /// May not be the same as the actual PC value for inlined stack frames. /// - /// @return + /// \return /// The Address object set to the current PC value. - //------------------------------------------------------------------ const Address &GetFrameCodeAddress(); - //------------------------------------------------------------------ /// Change the pc value for a given thread. /// /// Change the current pc value for the frame on this thread. /// - /// @param[in] pc + /// \param[in] pc /// The load address that the pc will be set to. /// - /// @return + /// \return /// true if the pc was changed. false if this failed -- possibly /// because this frame is not a live StackFrame. - //------------------------------------------------------------------ bool ChangePC(lldb::addr_t pc); - //------------------------------------------------------------------ /// Provide a SymbolContext for this StackFrame's current pc value. /// /// The StackFrame maintains this SymbolContext and adds additional @@ -161,17 +153,15 @@ public: /// functions looking up symbolic information for a given pc value multiple /// times. /// - /// @params [in] resolve_scope + /// \params [in] resolve_scope /// Flags from the SymbolContextItem enumerated type which specify what /// type of symbol context is needed by this caller. /// - /// @return + /// \return /// A SymbolContext reference which includes the types of information /// requested by resolve_scope, if they are available. - //------------------------------------------------------------------ const SymbolContext &GetSymbolContext(lldb::SymbolContextItem resolve_scope); - //------------------------------------------------------------------ /// Return the Canonical Frame Address (DWARF term) for this frame. /// /// The CFA is typically the value of the stack pointer register before the @@ -182,46 +172,40 @@ public: /// Live StackFrames will always have a CFA but other types of frames may /// not be able to supply one. /// - /// @param [out] value + /// \param [out] value /// The address of the CFA for this frame, if available. /// - /// @param [out] error_ptr + /// \param [out] error_ptr /// If there is an error determining the CFA address, this may contain a /// string explaining the failure. /// - /// @return + /// \return /// Returns true if the CFA value was successfully set in value. Some /// frames may be unable to provide this value; they will return false. - //------------------------------------------------------------------ bool GetFrameBaseValue(Scalar &value, Status *error_ptr); - //------------------------------------------------------------------ /// Get the DWARFExpression corresponding to the Canonical Frame Address. /// /// Often a register (bp), but sometimes a register + offset. /// - /// @param [out] error_ptr + /// \param [out] error_ptr /// If there is an error determining the CFA address, this may contain a /// string explaining the failure. /// - /// @return + /// \return /// Returns the corresponding DWARF expression, or NULL. - //------------------------------------------------------------------ DWARFExpression *GetFrameBaseExpression(Status *error_ptr); - //------------------------------------------------------------------ /// Get the current lexical scope block for this StackFrame, if possible. /// /// If debug information is available for this stack frame, return a pointer /// to the innermost lexical Block that the frame is currently executing. /// - /// @return + /// \return /// A pointer to the current Block. nullptr is returned if this can /// not be provided. - //------------------------------------------------------------------ Block *GetFrameBlock(); - //------------------------------------------------------------------ /// Get the RegisterContext for this frame, if possible. /// /// Returns a shared pointer to the RegisterContext for this stack frame. @@ -232,16 +216,14 @@ public: /// registers. Only the currently executing frame (frame 0) can reliably /// provide every register in the register context. /// - /// @return + /// \return /// The RegisterContext shared point for this frame. - //------------------------------------------------------------------ lldb::RegisterContextSP GetRegisterContext(); const lldb::RegisterContextSP &GetRegisterContextSP() const { return m_reg_context_sp; } - //------------------------------------------------------------------ /// Retrieve the list of variables that are in scope at this StackFrame's /// pc. /// @@ -249,17 +231,15 @@ public: /// pc value even though variables would be available at this point if it /// were a live stack frame. /// - /// @param[in] get_file_globals + /// \param[in] get_file_globals /// Whether to also retrieve compilation-unit scoped variables /// that are visible to the entire compilation unit (e.g. file /// static in C, globals that are homed in this CU). /// - /// @return + /// \return /// A pointer to a list of variables. - //------------------------------------------------------------------ VariableList *GetVariableList(bool get_file_globals); - //------------------------------------------------------------------ /// Retrieve the list of variables that are in scope at this StackFrame's /// pc. /// @@ -267,269 +247,230 @@ public: /// given pc value even though variables would be available at this point if /// it were a live stack frame. /// - /// @param[in] get_file_globals + /// \param[in] get_file_globals /// Whether to also retrieve compilation-unit scoped variables /// that are visible to the entire compilation unit (e.g. file /// static in C, globals that are homed in this CU). /// - /// @return + /// \return /// A pointer to a list of variables. - //------------------------------------------------------------------ lldb::VariableListSP GetInScopeVariableList(bool get_file_globals, bool must_have_valid_location = false); - //------------------------------------------------------------------ /// Create a ValueObject for a variable name / pathname, possibly including /// simple dereference/child selection syntax. /// - /// @param[in] var_expr + /// \param[in] var_expr /// The string specifying a variable to base the VariableObject off /// of. /// - /// @param[in] use_dynamic + /// \param[in] use_dynamic /// Whether the correct dynamic type of an object pointer should be /// determined before creating the object, or if the static type is /// sufficient. One of the DynamicValueType enumerated values. /// - /// @param[in] options + /// \param[in] options /// An unsigned integer of flags, values from /// StackFrame::ExpressionPathOption /// enum. - /// @param[in] var_sp + /// \param[in] var_sp /// A VariableSP that will be set to the variable described in the /// var_expr path. /// - /// @param[in] error + /// \param[in] error /// Record any errors encountered while evaluating var_expr. /// - /// @return + /// \return /// A shared pointer to the ValueObject described by var_expr. - //------------------------------------------------------------------ lldb::ValueObjectSP GetValueForVariableExpressionPath( llvm::StringRef var_expr, lldb::DynamicValueType use_dynamic, uint32_t options, lldb::VariableSP &var_sp, Status &error); - //------------------------------------------------------------------ /// Determine whether this StackFrame has debug information available or not /// - /// @return + /// \return // true if debug information is available for this frame (function, // compilation unit, block, etc.) - //------------------------------------------------------------------ bool HasDebugInformation(); - //------------------------------------------------------------------ /// Return the disassembly for the instructions of this StackFrame's /// function as a single C string. /// - /// @return + /// \return // C string with the assembly instructions for this function. - //------------------------------------------------------------------ const char *Disassemble(); - //------------------------------------------------------------------ /// Print a description for this frame using the frame-format formatter /// settings. /// - /// @param [in] strm + /// \param [in] strm /// The Stream to print the description to. /// - /// @param [in] show_unique + /// \param [in] show_unique /// Whether to print the function arguments or not for backtrace unique. /// - /// @param [in] frame_marker + /// \param [in] frame_marker /// Optional string that will be prepended to the frame output description. - //------------------------------------------------------------------ void DumpUsingSettingsFormat(Stream *strm, bool show_unique = false, const char *frame_marker = nullptr); - //------------------------------------------------------------------ /// Print a description for this frame using a default format. /// - /// @param [in] strm + /// \param [in] strm /// The Stream to print the description to. /// - /// @param [in] show_frame_index + /// \param [in] show_frame_index /// Whether to print the frame number or not. /// - /// @param [in] show_fullpaths + /// \param [in] show_fullpaths /// Whether to print the full source paths or just the file base name. - //------------------------------------------------------------------ void Dump(Stream *strm, bool show_frame_index, bool show_fullpaths); - //------------------------------------------------------------------ /// Print a description of this stack frame and/or the source /// context/assembly for this stack frame. /// - /// @param[in] strm + /// \param[in] strm /// The Stream to send the output to. /// - /// @param[in] show_frame_info + /// \param[in] show_frame_info /// If true, print the frame info by calling DumpUsingSettingsFormat(). /// - /// @param[in] show_source + /// \param[in] show_source /// If true, print source or disassembly as per the user's settings. /// - /// @param[in] show_unique + /// \param[in] show_unique /// If true, print using backtrace unique style, without function /// arguments as per the user's settings. /// - /// @param[in] frame_marker + /// \param[in] frame_marker /// Passed to DumpUsingSettingsFormat() for the frame info printing. /// - /// @return + /// \return /// Returns true if successful. - //------------------------------------------------------------------ bool GetStatus(Stream &strm, bool show_frame_info, bool show_source, bool show_unique = false, const char *frame_marker = nullptr); - //------------------------------------------------------------------ /// Query whether this frame is a concrete frame on the call stack, or if it /// is an inlined frame derived from the debug information and presented by /// the debugger. /// - /// @return + /// \return /// true if this is an inlined frame. - //------------------------------------------------------------------ bool IsInlined(); - //------------------------------------------------------------------ /// Query whether this frame is part of a historical backtrace. - //------------------------------------------------------------------ bool IsHistorical() const; - //------------------------------------------------------------------ /// Query whether this frame is artificial (e.g a synthesized result of /// inferring missing tail call frames from a backtrace). Artificial frames /// may have limited support for inspecting variables. - //------------------------------------------------------------------ bool IsArtificial() const; - //------------------------------------------------------------------ /// Query this frame to find what frame it is in this Thread's /// StackFrameList. /// - /// @return + /// \return /// StackFrame index 0 indicates the currently-executing function. Inline /// frames are included in this frame index count. - //------------------------------------------------------------------ uint32_t GetFrameIndex() const; - //------------------------------------------------------------------ /// Set this frame's synthetic frame index. - //------------------------------------------------------------------ void SetFrameIndex(uint32_t index) { m_frame_index = index; } - //------------------------------------------------------------------ /// Query this frame to find what frame it is in this Thread's /// StackFrameList, not counting inlined frames. /// - /// @return + /// \return /// StackFrame index 0 indicates the currently-executing function. Inline /// frames are not included in this frame index count; their concrete /// frame index will be the same as the concrete frame that they are /// derived from. - //------------------------------------------------------------------ uint32_t GetConcreteFrameIndex() const { return m_concrete_frame_index; } - //------------------------------------------------------------------ /// Create a ValueObject for a given Variable in this StackFrame. /// - /// @params [in] variable_sp + /// \params [in] variable_sp /// The Variable to base this ValueObject on /// - /// @params [in] use_dynamic + /// \params [in] use_dynamic /// Whether the correct dynamic type of the variable should be /// determined before creating the ValueObject, or if the static type /// is sufficient. One of the DynamicValueType enumerated values. /// - /// @return + /// \return // A ValueObject for this variable. - //------------------------------------------------------------------ lldb::ValueObjectSP GetValueObjectForFrameVariable(const lldb::VariableSP &variable_sp, lldb::DynamicValueType use_dynamic); - //------------------------------------------------------------------ /// Add an arbitrary Variable object (e.g. one that specifics a global or /// static) to a StackFrame's list of ValueObjects. /// - /// @params [in] variable_sp + /// \params [in] variable_sp /// The Variable to base this ValueObject on /// - /// @params [in] use_dynamic + /// \params [in] use_dynamic /// Whether the correct dynamic type of the variable should be /// determined before creating the ValueObject, or if the static type /// is sufficient. One of the DynamicValueType enumerated values. /// - /// @return + /// \return // A ValueObject for this variable. - //------------------------------------------------------------------ lldb::ValueObjectSP TrackGlobalVariable(const lldb::VariableSP &variable_sp, lldb::DynamicValueType use_dynamic); - //------------------------------------------------------------------ /// Query this frame to determine what the default language should be when /// parsing expressions given the execution context. /// - /// @return + /// \return /// The language of the frame if known, else lldb::eLanguageTypeUnknown. - //------------------------------------------------------------------ lldb::LanguageType GetLanguage(); // similar to GetLanguage(), but is allowed to take a potentially incorrect // guess if exact information is not available lldb::LanguageType GuessLanguage(); - //------------------------------------------------------------------ /// Attempt to econstruct the ValueObject for a given raw address touched by /// the current instruction. The ExpressionPath should indicate how to get /// to this value using "frame variable." /// - /// @params [in] addr + /// \params [in] addr /// The raw address. /// - /// @return + /// \return /// The ValueObject if found. If valid, it has a valid ExpressionPath. - //------------------------------------------------------------------ lldb::ValueObjectSP GuessValueForAddress(lldb::addr_t addr); - //------------------------------------------------------------------ /// Attempt to reconstruct the ValueObject for the address contained in a /// given register plus an offset. The ExpressionPath should indicate how /// to get to this value using "frame variable." /// - /// @params [in] reg + /// \params [in] reg /// The name of the register. /// - /// @params [in] offset + /// \params [in] offset /// The offset from the register. Particularly important for sp... /// - /// @return + /// \return /// The ValueObject if found. If valid, it has a valid ExpressionPath. - //------------------------------------------------------------------ lldb::ValueObjectSP GuessValueForRegisterAndOffset(ConstString reg, int64_t offset); - //------------------------------------------------------------------ /// Attempt to reconstruct the ValueObject for a variable with a given \a name /// from within the current StackFrame, within the current block. The search /// for the variable starts in the deepest block corresponding to the current /// PC in the stack frame and traverse through all parent blocks stopping at /// inlined function boundaries. /// - /// @params [in] name + /// \params [in] name /// The name of the variable. /// - /// @return + /// \return /// The ValueObject if found. - //------------------------------------------------------------------ lldb::ValueObjectSP FindVariable(ConstString name); - //------------------------------------------------------------------ // lldb::ExecutionContextScope pure virtual functions - //------------------------------------------------------------------ lldb::TargetSP CalculateTarget() override; lldb::ProcessSP CalculateProcess() override; @@ -554,9 +495,7 @@ protected: bool HasCachedData() const; private: - //------------------------------------------------------------------ // For StackFrame only - //------------------------------------------------------------------ lldb::ThreadWP m_thread_wp; uint32_t m_frame_index; uint32_t m_concrete_frame_index; diff --git a/include/lldb/Target/StackFrameList.h b/include/lldb/Target/StackFrameList.h index 0de90b3ba4acb..5eb7919501722 100644 --- a/include/lldb/Target/StackFrameList.h +++ b/include/lldb/Target/StackFrameList.h @@ -1,9 +1,8 @@ //===-- StackFrameList.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,9 +19,7 @@ namespace lldb_private { class StackFrameList { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ StackFrameList(Thread &thread, const lldb::StackFrameListSP &prev_frames_sp, bool show_inline_frames); @@ -92,7 +89,7 @@ protected: bool SetFrameAtIndex(uint32_t idx, lldb::StackFrameSP &frame_sp); - static void Merge(std::unique_ptr<StackFrameList> &curr_ap, + static void Merge(std::unique_ptr<StackFrameList> &curr_up, lldb::StackFrameListSP &prev_sp); void GetFramesUpTo(uint32_t end_idx); diff --git a/include/lldb/Target/StackFrameRecognizer.h b/include/lldb/Target/StackFrameRecognizer.h index 35ec23b754f3a..2021ac5215f38 100644 --- a/include/lldb/Target/StackFrameRecognizer.h +++ b/include/lldb/Target/StackFrameRecognizer.h @@ -1,15 +1,15 @@ //===-- StackFrameRecognizer.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef liblldb_StackFrameRecognizer_h_ #define liblldb_StackFrameRecognizer_h_ +#include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectList.h" #include "lldb/Symbol/VariableList.h" #include "lldb/Utility/StructuredData.h" @@ -18,7 +18,7 @@ namespace lldb_private { -/// @class RecognizedStackFrame +/// \class RecognizedStackFrame /// /// This class provides extra information about a stack frame that was /// provided by a specific stack frame recognizer. Right now, this class only @@ -39,7 +39,7 @@ protected: lldb::ValueObjectListSP m_arguments; }; -/// @class StackFrameRecognizer +/// \class StackFrameRecognizer /// /// A base class for frame recognizers. Subclasses (actual frame recognizers) /// should implement RecognizeFrame to provide a RecognizedStackFrame for a @@ -59,9 +59,7 @@ public: virtual ~StackFrameRecognizer(){}; }; -#ifndef LLDB_DISABLE_PYTHON - -/// @class ScriptedStackFrameRecognizer +/// \class ScriptedStackFrameRecognizer /// /// Python implementation for frame recognizers. An instance of this class /// tracks a particular Python classobject, which will be asked to recognize @@ -75,7 +73,7 @@ class ScriptedStackFrameRecognizer : public StackFrameRecognizer { public: ScriptedStackFrameRecognizer(lldb_private::ScriptInterpreter *interpreter, const char *pclass); - ~ScriptedStackFrameRecognizer() {} + ~ScriptedStackFrameRecognizer() override {} std::string GetName() override { return GetPythonClassName(); @@ -90,9 +88,7 @@ private: DISALLOW_COPY_AND_ASSIGN(ScriptedStackFrameRecognizer); }; -#endif - -/// @class StackFrameRecognizerManager +/// \class StackFrameRecognizerManager /// /// Static class that provides a registry of known stack frame recognizers. /// Has static methods to add, enumerate, remove, query and invoke recognizers. @@ -100,8 +96,8 @@ private: class StackFrameRecognizerManager { public: static void AddRecognizer(lldb::StackFrameRecognizerSP recognizer, - const ConstString &module, - const ConstString &symbol, + ConstString module, + ConstString symbol, bool first_instruction_only = true); static void AddRecognizer(lldb::StackFrameRecognizerSP recognizer, @@ -124,6 +120,42 @@ public: static lldb::RecognizedStackFrameSP RecognizeFrame(lldb::StackFrameSP frame); }; +/// \class ValueObjectRecognizerSynthesizedValue +/// +/// ValueObject subclass that presents the passed ValueObject as a recognized +/// value with the specified ValueType. Frame recognizers should return +/// instances of this class as the returned objects in GetRecognizedArguments(). + +class ValueObjectRecognizerSynthesizedValue : public ValueObject { + public: + static lldb::ValueObjectSP Create(ValueObject &parent, lldb::ValueType type) { + return (new ValueObjectRecognizerSynthesizedValue(parent, type))->GetSP(); + } + ValueObjectRecognizerSynthesizedValue(ValueObject &parent, + lldb::ValueType type) + : ValueObject(parent), m_type(type) { + SetName(parent.GetName()); + } + + uint64_t GetByteSize() override { return m_parent->GetByteSize(); } + lldb::ValueType GetValueType() const override { return m_type; } + bool UpdateValue() override { + if (!m_parent->UpdateValueIfNeeded()) return false; + m_value = m_parent->GetValue(); + return true; + } + size_t CalculateNumChildren(uint32_t max = UINT32_MAX) override { + return m_parent->GetNumChildren(max); + } + CompilerType GetCompilerTypeImpl() override { + return m_parent->GetCompilerType(); + } + bool IsSynthetic() override { return true; } + + private: + lldb::ValueType m_type; +}; + } // namespace lldb_private #endif // liblldb_StackFrameRecognizer_h_ diff --git a/include/lldb/Target/StackID.h b/include/lldb/Target/StackID.h index 871f39c463a95..a649a4faa9391 100644 --- a/include/lldb/Target/StackID.h +++ b/include/lldb/Target/StackID.h @@ -1,9 +1,8 @@ //===-- StackID.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -17,9 +16,7 @@ namespace lldb_private { class StackID { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ StackID() : m_pc(LLDB_INVALID_ADDRESS), m_cfa(LLDB_INVALID_ADDRESS), m_symbol_scope(nullptr) {} @@ -55,9 +52,7 @@ public: void Dump(Stream *s); - //------------------------------------------------------------------ // Operators - //------------------------------------------------------------------ const StackID &operator=(const StackID &rhs) { if (this != &rhs) { m_pc = rhs.m_pc; diff --git a/include/lldb/Target/StopInfo.h b/include/lldb/Target/StopInfo.h index 1a9f5b8480dbd..59033b1b64416 100644 --- a/include/lldb/Target/StopInfo.h +++ b/include/lldb/Target/StopInfo.h @@ -1,9 +1,8 @@ //===-- StopInfo.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,9 +22,7 @@ class StopInfo { friend class ThreadPlanBase; public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ StopInfo(Thread &thread, uint64_t value); virtual ~StopInfo() {} @@ -157,9 +154,7 @@ protected: // to consult this later on. virtual bool ShouldStop(Event *event_ptr) { return true; } - //------------------------------------------------------------------ // Classes that inherit from StackID can see and modify these - //------------------------------------------------------------------ lldb::ThreadWP m_thread_wp; // The thread corresponding to the stop reason. uint32_t m_stop_id; // The process stop ID for which this stop info is valid uint32_t m_resume_id; // This is the resume ID when we made this stop ID. diff --git a/include/lldb/Target/StructuredDataPlugin.h b/include/lldb/Target/StructuredDataPlugin.h index 5ea265b054205..b20bdb3b263a3 100644 --- a/include/lldb/Target/StructuredDataPlugin.h +++ b/include/lldb/Target/StructuredDataPlugin.h @@ -1,9 +1,8 @@ //===-- StructuredDataPlugin.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -17,7 +16,6 @@ namespace lldb_private { class CommandObjectMultiword; -// ----------------------------------------------------------------------------- /// Plugin that supports process-related structured data sent asynchronously /// from the debug monitor (e.g. debugserver, lldb-server, etc.) /// @@ -38,21 +36,17 @@ class CommandObjectMultiword; /// and error streams such that the plugin can display something about the /// event, at a time when the debugger ensures it is safe to write to the /// output or error streams. -// ----------------------------------------------------------------------------- class StructuredDataPlugin : public PluginInterface, public std::enable_shared_from_this<StructuredDataPlugin> { public: - virtual ~StructuredDataPlugin(); + ~StructuredDataPlugin() override; lldb::ProcessSP GetProcess() const; - // ------------------------------------------------------------------------- // Public instance API - // ------------------------------------------------------------------------- - // ------------------------------------------------------------------------- /// Return whether this plugin supports the given StructuredData feature. /// /// When Process is informed of a list of process-monitor-supported @@ -64,16 +58,14 @@ public: /// features, and if that happens, there is a single plugin instance /// created covering all of the mapped features for a given process. /// - /// @param[in] type_name + /// \param[in] type_name /// The name of the feature tag supported by a process. /// e.g. "darwin-log". /// - /// @return + /// \return /// true if the plugin supports the feature; otherwise, false. - // ------------------------------------------------------------------------- - virtual bool SupportsStructuredDataType(const ConstString &type_name) = 0; + virtual bool SupportsStructuredDataType(ConstString type_name) = 0; - // ------------------------------------------------------------------------- /// Handle the arrival of asynchronous structured data from the process. /// /// When asynchronous structured data arrives from the process monitor, @@ -84,27 +76,25 @@ public: /// value. This is the manner in which the data is routed to the proper /// plugin instance. /// - /// @param[in] process + /// \param[in] process /// The process instance that just received the structured data. /// This will always be the same process for a given instance of /// a plugin. /// - /// @param[in] type_name + /// \param[in] type_name /// The name of the feature tag for the asynchronous structured data. /// Note this data will also be present in the \b object_sp dictionary /// under the string value with key "type". /// - /// @param[in] object_sp + /// \param[in] object_sp /// A shared pointer to the structured data that arrived. This must /// be a dictionary. The only key required is the aforementioned /// key named "type" that must be a string value containing the /// structured data type name. - // ------------------------------------------------------------------------- virtual void - HandleArrivalOfStructuredData(Process &process, const ConstString &type_name, + HandleArrivalOfStructuredData(Process &process, ConstString type_name, const StructuredData::ObjectSP &object_sp) = 0; - // ------------------------------------------------------------------------- /// Get a human-readable description of the contents of the data. /// /// In command-line LLDB, this method will be called by the Debugger @@ -113,33 +103,29 @@ public: /// nothing will be printed; otherwise, a newline will be added to the end /// when displayed. /// - /// @param[in] object_sp + /// \param[in] object_sp /// A shared pointer to the structured data to format. /// - /// @param[in] stream + /// \param[in] stream /// The stream where the structured data should be pretty printed. /// - /// @return + /// \return /// The error if formatting the object contents failed; otherwise, /// success. - // ------------------------------------------------------------------------- virtual Status GetDescription(const StructuredData::ObjectSP &object_sp, lldb_private::Stream &stream) = 0; - // ------------------------------------------------------------------------- /// Returns whether the plugin's features are enabled. /// /// This is a convenience method for plugins that can enable or disable /// their functionality. It allows retrieval of this state without /// requiring a cast. /// - /// @param[in] type_name + /// \param[in] type_name /// The name of the feature tag for the asynchronous structured data. /// This is needed for plugins that support more than one feature. - // ------------------------------------------------------------------------- - virtual bool GetEnabled(const ConstString &type_name) const; + virtual bool GetEnabled(ConstString type_name) const; - // ------------------------------------------------------------------------- /// Allow the plugin to do work related to modules that loaded in the /// the corresponding process. /// @@ -147,24 +133,20 @@ public: /// if they have any behavior they want to enable/modify based on loaded /// modules. /// - /// @param[in] process + /// \param[in] process /// The process that just was notified of modules having been loaded. /// This will always be the same process for a given instance of /// a plugin. /// - /// @param[in] module_list + /// \param[in] module_list /// The list of modules that the process registered as having just /// loaded. See \b Process::ModulesDidLoad(...). - // ------------------------------------------------------------------------- virtual void ModulesDidLoad(Process &process, ModuleList &module_list); protected: - // ------------------------------------------------------------------------- // Derived-class API - // ------------------------------------------------------------------------- StructuredDataPlugin(const lldb::ProcessWP &process_wp); - // ------------------------------------------------------------------------- /// Derived classes must call this before attempting to hook up commands /// to the 'plugin structured-data' tree. /// @@ -172,10 +154,9 @@ protected: /// StructuredDataPlugin derived classes are available for this debugger. /// If this has already happened, this call is a no-op. /// - /// @param[in] debugger + /// \param[in] debugger /// The Debugger instance for which we're creating the required shared /// components for the StructuredDataPlugin derived classes. - // ------------------------------------------------------------------------- static void InitializeBasePluginForDebugger(Debugger &debugger); private: diff --git a/include/lldb/Target/SystemRuntime.h b/include/lldb/Target/SystemRuntime.h index 328dbe2310783..b45f882d36b0e 100644 --- a/include/lldb/Target/SystemRuntime.h +++ b/include/lldb/Target/SystemRuntime.h @@ -1,9 +1,8 @@ //===-- SystemRuntime.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,8 +22,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class SystemRuntime SystemRuntime.h "lldb/Target/SystemRuntime.h" +/// \class SystemRuntime SystemRuntime.h "lldb/Target/SystemRuntime.h" /// A plug-in interface definition class for system runtimes. /// /// The system runtime plugins can collect information from the system @@ -40,68 +38,52 @@ namespace lldb_private { /// collecting information. Later when it comes time to augment a Thread, it /// can be asked to provide that information. /// -//---------------------------------------------------------------------- class SystemRuntime : public PluginInterface { public: - //------------------------------------------------------------------ /// Find a system runtime plugin for a given process. /// /// Scans the installed SystemRuntime plugins and tries to find an instance /// that can be used to track image changes in \a process. /// - /// @param[in] process + /// \param[in] process /// The process for which to try and locate a system runtime /// plugin instance. - //------------------------------------------------------------------ static SystemRuntime *FindPlugin(Process *process); - //------------------------------------------------------------------ /// Construct with a process. - // ----------------------------------------------------------------- SystemRuntime(lldb_private::Process *process); - //------------------------------------------------------------------ /// Destructor. /// /// The destructor is virtual since this class is designed to be inherited /// by the plug-in instance. - //------------------------------------------------------------------ ~SystemRuntime() override; - //------------------------------------------------------------------ /// Called after attaching to a process. /// /// Allow the SystemRuntime plugin to execute some code after attaching to a /// process. - //------------------------------------------------------------------ virtual void DidAttach(); - //------------------------------------------------------------------ /// Called after launching a process. /// /// Allow the SystemRuntime plugin to execute some code after launching a /// process. - //------------------------------------------------------------------ virtual void DidLaunch(); - //------------------------------------------------------------------ /// Called when modules have been loaded in the process. /// /// Allow the SystemRuntime plugin to enable logging features in the system /// runtime libraries. - //------------------------------------------------------------------ virtual void ModulesDidLoad(lldb_private::ModuleList &module_list); - //------------------------------------------------------------------ /// Called before detaching from a process. /// /// This will give a SystemRuntime plugin a chance to free any resources in /// the inferior process before we detach. - //------------------------------------------------------------------ virtual void Detach(); - //------------------------------------------------------------------ /// Return a list of thread origin extended backtraces that may be /// available. /// @@ -119,14 +101,12 @@ public: /// libdispatch queue origin. If there is none, then request the pthread /// origin. /// - /// @return + /// \return /// A vector of ConstStrings with names like "pthread" or "libdispatch". /// An empty vector may be returned if no thread origin extended /// backtrace capabilities are available. - //------------------------------------------------------------------ virtual const std::vector<ConstString> &GetExtendedBacktraceTypes(); - //------------------------------------------------------------------ /// Return a Thread which shows the origin of this thread's creation. /// /// This likely returns a HistoryThread which shows how thread was @@ -137,25 +117,23 @@ public: /// There may be a chain of thread-origins; it may be informative to the end /// user to query the returned ThreadSP for its origins as well. /// - /// @param [in] thread + /// \param [in] thread /// The thread to examine. /// - /// @param [in] type + /// \param [in] type /// The type of thread origin being requested. The types supported /// are returned from SystemRuntime::GetExtendedBacktraceTypes. /// - /// @return + /// \return /// A ThreadSP which will have a StackList of frames. This Thread will /// not appear in the Process' list of current threads. Normal thread /// operations like stepping will not be available. This is a historical /// view thread and may be only useful for showing a backtrace. /// /// An empty ThreadSP will be returned if no thread origin is available. - //------------------------------------------------------------------ virtual lldb::ThreadSP GetExtendedBacktraceThread(lldb::ThreadSP thread, ConstString type); - //------------------------------------------------------------------ /// Get the extended backtrace thread for a QueueItem /// /// A QueueItem represents a function/block that will be executed on @@ -165,38 +143,34 @@ public: /// This method will report a thread backtrace of the function that enqueued /// it originally, if possible. /// - /// @param [in] queue_item_sp + /// \param [in] queue_item_sp /// The QueueItem that we are getting an extended backtrace for. /// - /// @param [in] type + /// \param [in] type /// The type of extended backtrace to fetch. The types supported /// are returned from SystemRuntime::GetExtendedBacktraceTypes. /// - /// @return + /// \return /// If an extended backtrace is available, it is returned. Else /// an empty ThreadSP is returned. - //------------------------------------------------------------------ virtual lldb::ThreadSP GetExtendedBacktraceForQueueItem(lldb::QueueItemSP queue_item_sp, ConstString type) { return lldb::ThreadSP(); } - //------------------------------------------------------------------ /// Populate the Process' QueueList with libdispatch / GCD queues that /// exist. /// /// When process execution is paused, the SystemRuntime may be called to /// fill in the list of Queues that currently exist. /// - /// @param [out] queue_list + /// \param [out] queue_list /// This QueueList will be cleared, and any queues that currently exist /// will be added. An empty QueueList will be returned if no queues /// exist or if this Systemruntime does not support libdispatch queues. - //------------------------------------------------------------------ virtual void PopulateQueueList(lldb_private::QueueList &queue_list) {} - //------------------------------------------------------------------ /// Get the queue name for a thread given a thread's dispatch_qaddr. /// /// On systems using libdispatch queues, a thread may be associated with a @@ -205,19 +179,17 @@ public: /// dispatch_queue_t structure. Given the address of the dispatch_queue_t /// structure for a thread, get the queue name and return it. /// - /// @param [in] dispatch_qaddr + /// \param [in] dispatch_qaddr /// The address of the dispatch_qaddr pointer for this thread. /// - /// @return + /// \return /// The string of this queue's name. An empty string is returned if the /// name could not be found. - //------------------------------------------------------------------ virtual std::string GetQueueNameFromThreadQAddress(lldb::addr_t dispatch_qaddr) { return ""; } - //------------------------------------------------------------------ /// Get the QueueID for the libdispatch queue given the thread's /// dispatch_qaddr. /// @@ -227,18 +199,16 @@ public: /// dispatch_queue_t structure. Given the address of the dispatch_queue_t /// structure for a thread, get the queue ID and return it. /// - /// @param [in] dispatch_qaddr + /// \param [in] dispatch_qaddr /// The address of the dispatch_qaddr pointer for this thread. /// - /// @return + /// \return /// The queue ID, or if it could not be retrieved, LLDB_INVALID_QUEUE_ID. - //------------------------------------------------------------------ virtual lldb::queue_id_t GetQueueIDFromThreadQAddress(lldb::addr_t dispatch_qaddr) { return LLDB_INVALID_QUEUE_ID; } - //------------------------------------------------------------------ /// Get the libdispatch_queue_t address for the queue given the thread's /// dispatch_qaddr. /// @@ -247,71 +217,62 @@ public: /// the thread's dispatch_qaddr, find the libdispatch_queue_t address and /// return it. /// - /// @param [in] dispatch_qaddr + /// \param [in] dispatch_qaddr /// The address of the dispatch_qaddr pointer for this thread. /// - /// @return + /// \return /// The libdispatch_queue_t address, or LLDB_INVALID_ADDRESS if /// unavailable/not found. - //------------------------------------------------------------------ virtual lldb::addr_t GetLibdispatchQueueAddressFromThreadQAddress(lldb::addr_t dispatch_qaddr) { return LLDB_INVALID_ADDRESS; } - //------------------------------------------------------------------ /// Retrieve the Queue kind for the queue at a thread's dispatch_qaddr. /// /// Retrieve the Queue kind - either eQueueKindSerial or /// eQueueKindConcurrent, indicating that this queue processes work items /// serially or concurrently. /// - /// @return + /// \return /// The Queue kind, if it could be read, else eQueueKindUnknown. - //------------------------------------------------------------------ virtual lldb::QueueKind GetQueueKind(lldb::addr_t dispatch_qaddr) { return lldb::eQueueKindUnknown; } - //------------------------------------------------------------------ /// Get the pending work items for a libdispatch Queue /// /// If this system/process is using libdispatch and the runtime can do so, /// retrieve the list of pending work items for the specified Queue and add /// it to the Queue. /// - /// @param [in] queue + /// \param [in] queue /// The queue of interest. - //------------------------------------------------------------------ virtual void PopulatePendingItemsForQueue(lldb_private::Queue *queue) {} - //------------------------------------------------------------------ /// Complete the fields in a QueueItem /// /// PopulatePendingItemsForQueue() may not fill in all of the QueueItem /// details; when the remaining fields are needed, they will be fetched by /// call this method. /// - /// @param [in] queue_item + /// \param [in] queue_item /// The QueueItem that we will be completing. /// - /// @param [in] item_ref + /// \param [in] item_ref /// The item_ref token that is needed to retrieve the rest of the /// information about the QueueItem. - //------------------------------------------------------------------ virtual void CompleteQueueItem(lldb_private::QueueItem *queue_item, lldb::addr_t item_ref) {} - //------------------------------------------------------------------ /// Add key-value pairs to the StructuredData dictionary object with /// information debugserver may need when constructing the /// jThreadExtendedInfo packet. /// - /// @param [out] dict + /// \param [out] dict /// Dictionary to which key-value pairs should be added; they will /// be sent to the remote gdb server stub as arguments in the /// jThreadExtendedInfo request. - //------------------------------------------------------------------ virtual void AddThreadExtendedInfoPacketHints( lldb_private::StructuredData::ObjectSP dict) {} @@ -321,22 +282,19 @@ public: /// this method gives a way for it to flag that the expression should not be /// run. /// - /// @param [in] thread_sp + /// \param [in] thread_sp /// The thread we want to run the expression on. /// - /// @return + /// \return /// True will be returned if there are no known problems with running an /// expression on this thread. False means that the inferior function /// call should not be made on this thread. - //------------------------------------------------------------------ virtual bool SafeToCallFunctionsOnThisThread(lldb::ThreadSP thread_sp) { return true; } protected: - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ Process *m_process; std::vector<ConstString> m_types; diff --git a/include/lldb/Target/Target.h b/include/lldb/Target/Target.h index 90df1f4929b77..4ed11afc31ba6 100644 --- a/include/lldb/Target/Target.h +++ b/include/lldb/Target/Target.h @@ -1,9 +1,8 @@ //===-- Target.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,10 +23,10 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/UserSettingsController.h" #include "lldb/Expression/Expression.h" +#include "lldb/Host/ProcessLaunchInfo.h" #include "lldb/Symbol/TypeSystem.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/PathMappingList.h" -#include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Target/SectionLoadHistory.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/Broadcaster.h" @@ -39,33 +38,31 @@ namespace lldb_private { OptionEnumValues GetDynamicValueTypes(); -typedef enum InlineStrategy { +enum InlineStrategy { eInlineBreakpointsNever = 0, eInlineBreakpointsHeaders, eInlineBreakpointsAlways -} InlineStrategy; +}; -typedef enum LoadScriptFromSymFile { +enum LoadScriptFromSymFile { eLoadScriptFromSymFileTrue, eLoadScriptFromSymFileFalse, eLoadScriptFromSymFileWarn -} LoadScriptFromSymFile; +}; -typedef enum LoadCWDlldbinitFile { +enum LoadCWDlldbinitFile { eLoadCWDlldbinitTrue, eLoadCWDlldbinitFalse, eLoadCWDlldbinitWarn -} LoadCWDlldbinitFile; +}; -typedef enum LoadDependentFiles { +enum LoadDependentFiles { eLoadDependentsDefault, eLoadDependentsYes, eLoadDependentsNo, -} LoadDependentFiles; +}; -//---------------------------------------------------------------------- // TargetProperties -//---------------------------------------------------------------------- class TargetExperimentalProperties : public Properties { public: TargetExperimentalProperties(); @@ -122,14 +119,18 @@ public: PathMappingList &GetSourcePathMap() const; - FileSpecList &GetExecutableSearchPaths(); + FileSpecList GetExecutableSearchPaths(); - FileSpecList &GetDebugFileSearchPaths(); + void AppendExecutableSearchPaths(const FileSpec&); - FileSpecList &GetClangModuleSearchPaths(); + FileSpecList GetDebugFileSearchPaths(); + + FileSpecList GetClangModuleSearchPaths(); bool GetEnableAutoImportClangModules() const; + bool GetEnableImportStdModule() const; + bool GetEnableAutoApplyFixIts() const; bool GetEnableNotifyAboutFixIts() const; @@ -207,9 +208,7 @@ public: bool GetRequireHardwareBreakpoints() const; private: - //------------------------------------------------------------------ // Callbacks for m_launch_info. - //------------------------------------------------------------------ static void Arg0ValueChangedCallback(void *target_property_ptr, OptionValue *); static void RunArgsValueChangedCallback(void *target_property_ptr, @@ -231,9 +230,7 @@ private: static void DisableSTDIOValueChangedCallback(void *target_property_ptr, OptionValue *); - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ ProcessLaunchInfo m_launch_info; std::unique_ptr<TargetExperimentalProperties> m_experimental_properties_up; }; @@ -422,9 +419,7 @@ private: mutable uint32_t m_pound_line_line; }; -//---------------------------------------------------------------------- // Target -//---------------------------------------------------------------------- class Target : public std::enable_shared_from_this<Target>, public TargetProperties, public Broadcaster, @@ -433,9 +428,7 @@ class Target : public std::enable_shared_from_this<Target>, public: friend class TargetList; - //------------------------------------------------------------------ /// Broadcaster event bits definitions. - //------------------------------------------------------------------ enum { eBroadcastBitBreakpointChanged = (1 << 0), eBroadcastBitModulesLoaded = (1 << 1), @@ -463,9 +456,9 @@ public: ~TargetEventData() override; - static const ConstString &GetFlavorString(); + static ConstString GetFlavorString(); - const ConstString &GetFlavor() const override { + ConstString GetFlavor() const override { return TargetEventData::GetFlavorString(); } @@ -498,18 +491,46 @@ public: static FileSpecList GetDefaultDebugFileSearchPaths(); - static FileSpecList GetDefaultClangModuleSearchPaths(); - static ArchSpec GetDefaultArchitecture(); static void SetDefaultArchitecture(const ArchSpec &arch); - lldb::ModuleSP GetSharedModule(const ModuleSpec &module_spec, - Status *error_ptr = nullptr); + /// Find a binary on the system and return its Module, + /// or return an existing Module that is already in the Target. + /// + /// Given a ModuleSpec, find a binary satisifying that specification, + /// or identify a matching Module already present in the Target, + /// and return a shared pointer to it. + /// + /// \param[in] module_spec + /// The criteria that must be matched for the binary being loaded. + /// e.g. UUID, architecture, file path. + /// + /// \param[in] notify + /// If notify is true, and the Module is new to this Target, + /// Target::ModulesDidLoad will be called. + /// If notify is false, it is assumed that the caller is adding + /// multiple Modules and will call ModulesDidLoad with the + /// full list at the end. + /// ModulesDidLoad must be called when a Module/Modules have + /// been added to the target, one way or the other. + /// + /// \param[out] error_ptr + /// Optional argument, pointing to a Status object to fill in + /// with any results / messages while attempting to find/load + /// this binary. Many callers will be internal functions that + /// will handle / summarize the failures in a custom way and + /// don't use these messages. + /// + /// \return + /// An empty ModuleSP will be returned if no matching file + /// was found. If error_ptr was non-nullptr, an error message + /// will likely be provided. + lldb::ModuleSP GetOrCreateModule(const ModuleSpec &module_spec, + bool notify, + Status *error_ptr = nullptr); - //---------------------------------------------------------------------- // Settings accessors - //---------------------------------------------------------------------- static const lldb::TargetPropertiesSP &GetGlobalProperties(); @@ -519,7 +540,6 @@ public: void CleanupProcess(); - //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// /// Dump a description of the contents of this object to the @@ -528,9 +548,8 @@ public: /// is called, so this is a good way to see what has been parsed /// in a target. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. - //------------------------------------------------------------------ void Dump(Stream *s, lldb::DescriptionLevel description_level); // If listener_sp is null, the listener of the owning Debugger object will be @@ -551,9 +570,7 @@ public: Status Attach(ProcessAttachInfo &attach_info, Stream *stream); // Optional stream to receive first stop info - //------------------------------------------------------------------ // This part handles the breakpoints. - //------------------------------------------------------------------ BreakpointList &GetBreakpointList(bool internal = false); @@ -681,12 +698,12 @@ public: Status &error); void RemoveNameFromBreakpoint(lldb::BreakpointSP &bp_sp, - const ConstString &name); + ConstString name); - BreakpointName *FindBreakpointName(const ConstString &name, bool can_create, + BreakpointName *FindBreakpointName(ConstString name, bool can_create, Status &error); - void DeleteBreakpointName(const ConstString &name); + void DeleteBreakpointName(ConstString name); void ConfigureBreakpointName(BreakpointName &bp_name, const BreakpointOptions &options, @@ -752,7 +769,6 @@ public: std::vector<std::string> &names, BreakpointIDList &new_bps); - //------------------------------------------------------------------ /// Get \a load_addr as a callable code load address for this target /// /// Take \a load_addr and potentially add any address bits that are @@ -762,12 +778,10 @@ public: /// adjustment will always happen. If it is set to an address class /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be /// returned. - //------------------------------------------------------------------ lldb::addr_t GetCallableLoadAddress( lldb::addr_t load_addr, AddressClass addr_class = AddressClass::eInvalid) const; - //------------------------------------------------------------------ /// Get \a load_addr as an opcode for this target. /// /// Take \a load_addr and potentially strip any address bits that are @@ -778,7 +792,6 @@ public: /// adjustment will always happen. If it is set to an address class /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be /// returned. - //------------------------------------------------------------------ lldb::addr_t GetOpcodeLoadAddress(lldb::addr_t load_addr, AddressClass addr_class = AddressClass::eInvalid) const; @@ -798,7 +811,6 @@ public: void ClearModules(bool delete_locations); - //------------------------------------------------------------------ /// Called as the last function in Process::DidExec(). /// /// Process::DidExec() will clear a lot of state in the process, @@ -808,10 +820,8 @@ public: /// has been figured out. It can remove breakpoints that no longer /// make sense as the exec might have changed the target /// architecture, and unloaded some modules that might get deleted. - //------------------------------------------------------------------ void DidExec(); - //------------------------------------------------------------------ /// Gets the module for the main executable. /// /// Each process has a notion of a main executable that is the file @@ -819,20 +829,18 @@ public: /// dependent modules that are discovered from the object files, or /// discovered at runtime as things are dynamically loaded. /// - /// @return + /// \return /// The shared pointer to the executable module which can /// contains a nullptr Module object if no executable has been /// set. /// - /// @see DynamicLoader - /// @see ObjectFile::GetDependentModules (FileSpecList&) - /// @see Process::SetExecutableModule(lldb::ModuleSP&) - //------------------------------------------------------------------ + /// \see DynamicLoader + /// \see ObjectFile::GetDependentModules (FileSpecList&) + /// \see Process::SetExecutableModule(lldb::ModuleSP&) lldb::ModuleSP GetExecutableModule(); Module *GetExecutableModulePointer(); - //------------------------------------------------------------------ /// Set the main executable module. /// /// Each process has a notion of a main executable that is the file @@ -848,17 +856,16 @@ public: /// Process::GetImages() will return the newly found images that /// were obtained from all of the object files. /// - /// @param[in] module_sp + /// \param[in] module_sp /// A shared pointer reference to the module that will become /// the main executable for this process. /// - /// @param[in] load_dependent_files + /// \param[in] load_dependent_files /// If \b true then ask the object files to track down any /// known dependent files. /// - /// @see ObjectFile::GetDependentModules (FileSpecList&) - /// @see Process::GetImages() - //------------------------------------------------------------------ + /// \see ObjectFile::GetDependentModules (FileSpecList&) + /// \see Process::GetImages() void SetExecutableModule( lldb::ModuleSP &module_sp, LoadDependentFiles load_dependent_files = eLoadDependentsDefault); @@ -870,7 +877,6 @@ public: this, errors, feedback_stream, continue_on_error); } - //------------------------------------------------------------------ /// Get accessor for the images for this process. /// /// Each process has a notion of a main executable that is the file @@ -886,14 +892,12 @@ public: /// addresses is each image, and also in images that are loaded by /// code. /// - /// @return + /// \return /// A list of Module objects in a module list. - //------------------------------------------------------------------ const ModuleList &GetImages() const { return m_images; } ModuleList &GetImages() { return m_images; } - //------------------------------------------------------------------ /// Return whether this FileSpec corresponds to a module that should be /// considered for general searches. /// @@ -905,14 +909,12 @@ public: /// The target call at present just consults the Platform's call of the /// same name. /// - /// @param[in] module_sp + /// \param[in] module_sp /// A shared pointer reference to the module that checked. /// - /// @return \b true if the module should be excluded, \b false otherwise. - //------------------------------------------------------------------ + /// \return \b true if the module should be excluded, \b false otherwise. bool ModuleIsExcludedForUnconstrainedSearches(const FileSpec &module_spec); - //------------------------------------------------------------------ /// Return whether this module should be considered for general searches. /// /// This API will be consulted by the SearchFilterForUnconstrainedSearches @@ -927,17 +929,15 @@ public: /// that they /// don't want searched, in addition to or instead of the platform ones. /// - /// @param[in] module_sp + /// \param[in] module_sp /// A shared pointer reference to the module that checked. /// - /// @return \b true if the module should be excluded, \b false otherwise. - //------------------------------------------------------------------ + /// \return \b true if the module should be excluded, \b false otherwise. bool ModuleIsExcludedForUnconstrainedSearches(const lldb::ModuleSP &module_sp); const ArchSpec &GetArchitecture() const { return m_arch.GetSpec(); } - //------------------------------------------------------------------ /// Set the architecture for this target. /// /// If the current target has no Images read in, then this just sets the @@ -951,19 +951,18 @@ public: /// won't be changed. If the input arch_spec is the same as the already set /// architecture, this is a no-op. /// - /// @param[in] arch_spec + /// \param[in] arch_spec /// The new architecture. /// - /// @param[in] set_platform + /// \param[in] set_platform /// If \b true, then the platform will be adjusted if the currently /// selected platform is not compatible with the archicture being set. /// If \b false, then just the architecture will be set even if the /// currently selected platform isn't compatible (in case it might be /// manually set following this function call). /// - /// @return + /// \return /// \b true if the architecture was successfully set, \bfalse otherwise. - //------------------------------------------------------------------ bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform = false); bool MergeArchitecture(const ArchSpec &arch_spec); @@ -1015,9 +1014,7 @@ public: static Target *GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr, const SymbolContext *sc_ptr); - //------------------------------------------------------------------ // lldb::ExecutionContextScope pure virtual functions - //------------------------------------------------------------------ lldb::TargetSP CalculateTarget() override; lldb::ProcessSP CalculateProcess() override; @@ -1044,7 +1041,8 @@ public: UserExpression *GetUserExpressionForLanguage( llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language, Expression::ResultType desired_type, - const EvaluateExpressionOptions &options, Status &error); + const EvaluateExpressionOptions &options, + ValueObject *ctx_obj, Status &error); // Creates a FunctionCaller for the given language, the rest of the // parameters have the same meaning as for the FunctionCaller constructor. @@ -1073,10 +1071,8 @@ public: lldb::ClangASTImporterSP GetClangASTImporter(); - //---------------------------------------------------------------------- // Install any files through the platform that need be to installed prior to // launching or attaching. - //---------------------------------------------------------------------- Status Install(ProcessLaunchInfo *launch_info); bool ResolveFileAddress(lldb::addr_t load_addr, Address &so_addr); @@ -1103,25 +1099,24 @@ public: // and the const expression results are available after a process is gone, we // provide a way for expressions to be evaluated from the Target itself. If // an expression is going to be run, then it should have a frame filled in in - // th execution context. + // the execution context. lldb::ExpressionResults EvaluateExpression( llvm::StringRef expression, ExecutionContextScope *exe_scope, lldb::ValueObjectSP &result_valobj_sp, const EvaluateExpressionOptions &options = EvaluateExpressionOptions(), - std::string *fixed_expression = nullptr); + std::string *fixed_expression = nullptr, + ValueObject *ctx_obj = nullptr); - lldb::ExpressionVariableSP GetPersistentVariable(const ConstString &name); + lldb::ExpressionVariableSP GetPersistentVariable(ConstString name); /// Return the next available number for numbered persistent variables. unsigned GetNextPersistentVariableIndex() { return m_next_persistent_variable_index++; } - lldb::addr_t GetPersistentSymbol(const ConstString &name); + lldb::addr_t GetPersistentSymbol(ConstString name); - //------------------------------------------------------------------ // Target Stop Hooks - //------------------------------------------------------------------ class StopHook : public UserID { public: StopHook(const StopHook &rhs); @@ -1146,20 +1141,25 @@ public: // and is responsible for deleting it when we're done. void SetThreadSpecifier(ThreadSpec *specifier); - ThreadSpec *GetThreadSpecifier() { return m_thread_spec_ap.get(); } + ThreadSpec *GetThreadSpecifier() { return m_thread_spec_up.get(); } bool IsActive() { return m_active; } void SetIsActive(bool is_active) { m_active = is_active; } + void SetAutoContinue(bool auto_continue) {m_auto_continue = auto_continue;} + + bool GetAutoContinue() const { return m_auto_continue; } + void GetDescription(Stream *s, lldb::DescriptionLevel level) const; private: lldb::TargetSP m_target_sp; StringList m_commands; lldb::SymbolContextSpecifierSP m_specifier_sp; - std::unique_ptr<ThreadSpec> m_thread_spec_ap; - bool m_active; + std::unique_ptr<ThreadSpec> m_thread_spec_up; + bool m_active = true; + bool m_auto_continue = false; // Use CreateStopHook to make a new empty stop hook. The GetCommandPointer // and fill it with commands, and SetSpecifier to set the specifier shared @@ -1219,9 +1219,7 @@ public: ClangModulesDeclVendor *GetClangModulesDeclVendor(); - //------------------------------------------------------------------ // Methods. - //------------------------------------------------------------------ lldb::SearchFilterSP GetSearchFilterForModule(const FileSpec *containingModule); @@ -1238,20 +1236,21 @@ public: void SetREPL(lldb::LanguageType language, lldb::REPLSP repl_sp); protected: - //------------------------------------------------------------------ /// Implementing of ModuleList::Notifier. - //------------------------------------------------------------------ - void ModuleAdded(const ModuleList &module_list, - const lldb::ModuleSP &module_sp) override; + void NotifyModuleAdded(const ModuleList &module_list, + const lldb::ModuleSP &module_sp) override; + + void NotifyModuleRemoved(const ModuleList &module_list, + const lldb::ModuleSP &module_sp) override; + + void NotifyModuleUpdated(const ModuleList &module_list, + const lldb::ModuleSP &old_module_sp, + const lldb::ModuleSP &new_module_sp) override; - void ModuleRemoved(const ModuleList &module_list, - const lldb::ModuleSP &module_sp) override; + void NotifyWillClearList(const ModuleList &module_list) override; - void ModuleUpdated(const ModuleList &module_list, - const lldb::ModuleSP &old_module_sp, - const lldb::ModuleSP &new_module_sp) override; - void WillClearList(const ModuleList &module_list) override; + void NotifyModulesRemoved(lldb_private::ModuleList &module_list) override; class Arch { public: @@ -1265,9 +1264,7 @@ protected: ArchSpec m_spec; std::unique_ptr<Architecture> m_plugin_up; }; - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ Debugger &m_debugger; lldb::PlatformSP m_platform_sp; ///< The platform for this target. std::recursive_mutex m_mutex; ///< An API mutex that is used by the lldb::SB* @@ -1296,9 +1293,9 @@ protected: REPLMap m_repl_map; lldb::ClangASTImporterSP m_ast_importer_sp; - lldb::ClangModulesDeclVendorUP m_clang_modules_decl_vendor_ap; + lldb::ClangModulesDeclVendorUP m_clang_modules_decl_vendor_up; - lldb::SourceManagerUP m_source_manager_ap; + lldb::SourceManagerUP m_source_manager_up; typedef std::map<lldb::user_id_t, StopHookSP> StopHookCollection; StopHookCollection m_stop_hooks; @@ -1311,9 +1308,7 @@ protected: static void ImageSearchPathsChanged(const PathMappingList &path_list, void *baton); - //------------------------------------------------------------------ // Utilities for `statistics` command. - //------------------------------------------------------------------ private: std::vector<uint32_t> m_stats_storage; bool m_collecting_stats = false; @@ -1334,15 +1329,13 @@ public: std::vector<uint32_t> GetStatistics() { return m_stats_storage; } private: - //------------------------------------------------------------------ /// Construct with optional file and arch. /// /// This member is private. Clients must use /// TargetList::CreateTarget(const FileSpec*, const ArchSpec*) /// so all targets can be tracked from the central target list. /// - /// @see TargetList::CreateTarget(const FileSpec*, const ArchSpec*) - //------------------------------------------------------------------ + /// \see TargetList::CreateTarget(const FileSpec*, const ArchSpec*) Target(Debugger &debugger, const ArchSpec &target_arch, const lldb::PlatformSP &platform_sp, bool is_dummy_target); diff --git a/include/lldb/Target/TargetList.h b/include/lldb/Target/TargetList.h index 90c480745a0cb..ece0705ae71c0 100644 --- a/include/lldb/Target/TargetList.h +++ b/include/lldb/Target/TargetList.h @@ -1,9 +1,8 @@ //===-- TargetList.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,21 +21,17 @@ class TargetList : public Broadcaster { private: friend class Debugger; - //------------------------------------------------------------------ /// Constructor /// /// The constructor for the target list is private. Clients can /// get ahold of of the one and only target list through the /// lldb_private::Debugger::GetSharedInstance().GetTargetList(). /// - /// @see static TargetList& lldb_private::Debugger::GetTargetList(). - //------------------------------------------------------------------ + /// \see static TargetList& lldb_private::Debugger::GetTargetList(). TargetList(Debugger &debugger); public: - //------------------------------------------------------------------ /// Broadcaster event bits definitions. - //------------------------------------------------------------------ enum { eBroadcastBitInterrupt = (1 << 0) }; // These two functions fill out the Broadcaster interface: @@ -49,7 +44,6 @@ public: ~TargetList() override; - //------------------------------------------------------------------ /// Create a new Target. /// /// Clients must use this function to create a Target. This allows @@ -58,68 +52,63 @@ public: /// locate an appropriate target to deliver asynchronous information /// to. /// - /// @param[in] debugger + /// \param[in] debugger /// The debugger to associate this target with /// - /// @param[in] file_spec + /// \param[in] file_spec /// The main executable file for a debug target. This value /// can be nullptr and the file can be set later using: /// Target::SetExecutableModule (ModuleSP&) /// - /// @param[in] triple_cstr + /// \param[in] triple_cstr /// A target triple string to be used for the target. This can /// be nullptr if the triple is not known or when attaching to a /// process. /// - /// @param[in] get_dependent_modules + /// \param[in] get_dependent_modules /// Track down the dependent modules for an executable and /// load those into the module list. /// - /// @param[in] platform_options + /// \param[in] platform_options /// A pointer to the platform options to use when creating this /// target. If this value is nullptr, then the currently selected /// platform will be used. /// - /// @param[out] target_sp + /// \param[out] target_sp /// A shared pointer to a target that will be filled in if /// this call is successful. /// - /// @return + /// \return /// An error object that indicates success or failure - //------------------------------------------------------------------ Status CreateTarget(Debugger &debugger, llvm::StringRef user_exe_path, llvm::StringRef triple_str, LoadDependentFiles get_dependent_modules, const OptionGroupPlatform *platform_options, lldb::TargetSP &target_sp); - //------------------------------------------------------------------ /// Create a new Target. /// /// Same as the function above, but used when you already know the /// platform you will be using - //------------------------------------------------------------------ Status CreateTarget(Debugger &debugger, llvm::StringRef user_exe_path, const ArchSpec &arch, LoadDependentFiles get_dependent_modules, lldb::PlatformSP &platform_sp, lldb::TargetSP &target_sp); - //------------------------------------------------------------------ /// Delete a Target object from the list. /// /// When clients are done with the Target objects, this function /// should be called to release the memory associated with a target /// object. /// - /// @param[in] target_sp + /// \param[in] target_sp /// The shared pointer to a target. /// - /// @return + /// \return /// Returns \b true if the target was successfully removed from /// from this target list, \b false otherwise. The client will /// be left with the last remaining shared pointer to the target /// in \a target_sp which can then be properly released. - //------------------------------------------------------------------ bool DeleteTarget(lldb::TargetSP &target_sp); int GetNumTargets() const; @@ -128,12 +117,11 @@ public: uint32_t GetIndexOfTarget(lldb::TargetSP target_sp) const; - //------------------------------------------------------------------ /// Find the target that contains has an executable whose path /// matches \a exe_file_spec, and whose architecture matches /// \a arch_ptr if arch_ptr is not nullptr. /// - /// @param[in] exe_file_spec + /// \param[in] exe_file_spec /// A file spec containing a basename, or a full path (directory /// and basename). If \a exe_file_spec contains only a filename /// (empty GetDirectory() value) then matching will be done @@ -141,53 +129,48 @@ public: /// compared. If \a exe_file_spec contains a filename and a /// directory, then both must match. /// - /// @param[in] exe_arch_ptr + /// \param[in] exe_arch_ptr /// If not nullptr then the architecture also needs to match, else /// the architectures will be compared. /// - /// @return + /// \return /// A shared pointer to a target object. The returned shared /// pointer will contain nullptr if no target objects have a /// executable whose full or partial path matches /// with a matching process ID. - //------------------------------------------------------------------ lldb::TargetSP FindTargetWithExecutableAndArchitecture( const FileSpec &exe_file_spec, const ArchSpec *exe_arch_ptr = nullptr) const; - //------------------------------------------------------------------ /// Find the target that contains a process with process ID \a /// pid. /// - /// @param[in] pid + /// \param[in] pid /// The process ID to search our target list for. /// - /// @return + /// \return /// A shared pointer to a target object. The returned shared /// pointer will contain nullptr if no target objects own a process /// with a matching process ID. - //------------------------------------------------------------------ lldb::TargetSP FindTargetWithProcessID(lldb::pid_t pid) const; lldb::TargetSP FindTargetWithProcess(lldb_private::Process *process) const; lldb::TargetSP GetTargetSP(Target *target) const; - //------------------------------------------------------------------ /// Send an async interrupt to one or all processes. /// /// Find the target that contains the process with process ID \a /// pid and send a LLDB_EVENT_ASYNC_INTERRUPT event to the process's /// event queue. /// - /// @param[in] pid + /// \param[in] pid /// The process ID to search our target list for, if \a pid is /// LLDB_INVALID_PROCESS_ID, then the interrupt will be sent to /// all processes. /// - /// @return + /// \return /// The number of async interrupts sent. - //------------------------------------------------------------------ uint32_t SendAsyncInterrupt(lldb::pid_t pid = LLDB_INVALID_PROCESS_ID); uint32_t SignalIfRunning(lldb::pid_t pid, int signo); @@ -198,9 +181,7 @@ public: protected: typedef std::vector<lldb::TargetSP> collection; - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ collection m_target_list; lldb::TargetSP m_dummy_target_sp; mutable std::recursive_mutex m_target_list_mutex; diff --git a/include/lldb/Target/Thread.h b/include/lldb/Target/Thread.h index 0d14b10c651f1..7aeaece5b5d51 100644 --- a/include/lldb/Target/Thread.h +++ b/include/lldb/Target/Thread.h @@ -1,9 +1,8 @@ //===-- Thread.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -35,18 +34,16 @@ public: ~ThreadProperties() override; - //------------------------------------------------------------------ /// The regular expression returned determines symbols that this /// thread won't stop in during "step-in" operations. /// - /// @return + /// \return /// A pointer to a regular expression to compare against symbols, /// or nullptr if all symbols are allowed. /// - //------------------------------------------------------------------ const RegularExpression *GetSymbolsToAvoidRegexp(); - FileSpecList &GetLibrariesToAvoid() const; + FileSpecList GetLibrariesToAvoid() const; bool GetTraceEnabledState() const; @@ -65,9 +62,7 @@ class Thread : public std::enable_shared_from_this<Thread>, public ExecutionContextScope, public Broadcaster { public: - //------------------------------------------------------------------ /// Broadcaster event bits definitions. - //------------------------------------------------------------------ enum { eBroadcastBitStackChanged = (1 << 0), eBroadcastBitThreadSuspended = (1 << 1), @@ -92,9 +87,9 @@ public: ~ThreadEventData() override; - static const ConstString &GetFlavorString(); + static ConstString GetFlavorString(); - const ConstString &GetFlavor() const override { + ConstString GetFlavor() const override { return ThreadEventData::GetFlavorString(); } @@ -131,14 +126,13 @@ public: lldb::addr_t current_inlined_pc; }; - //------------------------------------------------------------------ /// Constructor /// - /// @param [in] process + /// \param [in] process /// - /// @param [in] tid + /// \param [in] tid /// - /// @param [in] use_invalid_index_id + /// \param [in] use_invalid_index_id /// Optional parameter, defaults to false. The only subclass that /// is likely to set use_invalid_index_id == true is the HistoryThread /// class. In that case, the Thread we are constructing represents @@ -147,7 +141,6 @@ public: /// to reuse the IndexID of that thread, or create a new one. If a /// client wants to know the original thread's IndexID, they should use /// Thread::GetExtendedBacktraceOriginatingIndexID(). - //------------------------------------------------------------------ Thread(Process &process, lldb::tid_t tid, bool use_invalid_index_id = false); ~Thread() override; @@ -168,7 +161,6 @@ public: void SetState(lldb::StateType state); - //------------------------------------------------------------------ /// Sets the USER resume state for this thread. If you set a thread to /// suspended with /// this API, it won't take part in any of the arbitration for ShouldResume, @@ -189,25 +181,22 @@ public: /// to force the thread to run (e.g. the "thread continue" command, or are /// resetting the state /// (e.g. in SBThread::Resume()), then pass true to override_suspend. - /// @return + /// \return /// The User resume state for this thread. - //------------------------------------------------------------------ void SetResumeState(lldb::StateType state, bool override_suspend = false) { if (m_resume_state == lldb::eStateSuspended && !override_suspend) return; m_resume_state = state; } - //------------------------------------------------------------------ /// Gets the USER resume state for this thread. This is not the same as what /// this thread is going to do for any particular step, however if this thread /// returns eStateSuspended, then the process control logic will never allow /// this /// thread to run. /// - /// @return + /// \return /// The User resume state for this thread. - //------------------------------------------------------------------ lldb::StateType GetResumeState() const { return m_resume_state; } // This function is called on all the threads before "ShouldResume" and @@ -267,7 +256,6 @@ public: virtual const char *GetInfo() { return nullptr; } - //------------------------------------------------------------------ /// Retrieve a dictionary of information about this thread /// /// On Mac OS X systems there may be voucher information. @@ -278,7 +266,6 @@ public: /// array /// being a dictionary (keys include "message" with the text of the trace /// message). - //------------------------------------------------------------------ StructuredData::ObjectSP GetExtendedInfo() { if (!m_extended_info_fetched) { m_extended_info = FetchThreadExtendedInfo(); @@ -291,7 +278,6 @@ public: virtual void SetName(const char *name) {} - //------------------------------------------------------------------ /// Whether this thread can be associated with a libdispatch queue /// /// The Thread may know if it is associated with a libdispatch queue, @@ -299,7 +285,7 @@ public: /// queue, or it may be unknown whether it is associated with a libdispatch /// queue. /// - /// @return + /// \return /// eLazyBoolNo if this thread is definitely not associated with a /// libdispatch queue (e.g. on a non-Darwin system where GCD aka /// libdispatch is not available). @@ -308,7 +294,6 @@ public: /// /// eLazyBoolCalculate this thread may be associated with a libdispatch /// queue but the thread doesn't know one way or the other. - //------------------------------------------------------------------ virtual lldb_private::LazyBool GetAssociatedWithLibdispatchQueue() { return eLazyBoolNo; } @@ -316,7 +301,6 @@ public: virtual void SetAssociatedWithLibdispatchQueue( lldb_private::LazyBool associated_with_libdispatch_queue) {} - //------------------------------------------------------------------ /// Retrieve the Queue ID for the queue currently using this Thread /// /// If this Thread is doing work on behalf of a libdispatch/GCD queue, @@ -327,29 +311,25 @@ public: /// queues and incrementing, a QueueID will not be reused for a /// different queue during the lifetime of a process. /// - /// @return + /// \return /// A QueueID if the Thread subclass implements this, else /// LLDB_INVALID_QUEUE_ID. - //------------------------------------------------------------------ virtual lldb::queue_id_t GetQueueID() { return LLDB_INVALID_QUEUE_ID; } virtual void SetQueueID(lldb::queue_id_t new_val) {} - //------------------------------------------------------------------ /// Retrieve the Queue name for the queue currently using this Thread /// /// If this Thread is doing work on behalf of a libdispatch/GCD queue, /// retrieve the Queue name. /// - /// @return + /// \return /// The Queue name, if the Thread subclass implements this, else /// nullptr. - //------------------------------------------------------------------ virtual const char *GetQueueName() { return nullptr; } virtual void SetQueueName(const char *name) {} - //------------------------------------------------------------------ /// Retrieve the Queue kind for the queue currently using this Thread /// /// If this Thread is doing work on behalf of a libdispatch/GCD queue, @@ -357,27 +337,23 @@ public: /// eQueueKindConcurrent, indicating that this queue processes work /// items serially or concurrently. /// - /// @return + /// \return /// The Queue kind, if the Thread subclass implements this, else /// eQueueKindUnknown. - //------------------------------------------------------------------ virtual lldb::QueueKind GetQueueKind() { return lldb::eQueueKindUnknown; } virtual void SetQueueKind(lldb::QueueKind kind) {} - //------------------------------------------------------------------ /// Retrieve the Queue for this thread, if any. /// - /// @return + /// \return /// A QueueSP for the queue that is currently associated with this /// thread. /// An empty shared pointer indicates that this thread is not /// associated with a queue, or libdispatch queues are not /// supported on this target. - //------------------------------------------------------------------ virtual lldb::QueueSP GetQueue() { return lldb::QueueSP(); } - //------------------------------------------------------------------ /// Retrieve the address of the libdispatch_queue_t struct for queue /// currently using this Thread /// @@ -389,17 +365,15 @@ public: /// lifetime and should not be used to identify a queue uniquely. Use /// the GetQueueID() call for that. /// - /// @return + /// \return /// The Queue's libdispatch_queue_t address if the Thread subclass /// implements this, else LLDB_INVALID_ADDRESS. - //------------------------------------------------------------------ virtual lldb::addr_t GetQueueLibdispatchQueueAddress() { return LLDB_INVALID_ADDRESS; } virtual void SetQueueLibdispatchQueueAddress(lldb::addr_t dispatch_queue_t) {} - //------------------------------------------------------------------ /// Whether this Thread already has all the Queue information cached or not /// /// A Thread may be associated with a libdispatch work Queue at a given @@ -412,7 +386,6 @@ public: /// This method allows the SystemRuntime to discover if a thread has this /// information already, instead of calling the thread to get the information /// and having the thread call the SystemRuntime again. - //------------------------------------------------------------------ virtual bool ThreadHasQueueInformation() const { return false; } virtual uint32_t GetStackFrameCount() { @@ -500,102 +473,89 @@ public: bool GetDescription(Stream &s, lldb::DescriptionLevel level, bool print_json_thread, bool print_json_stopinfo); - //------------------------------------------------------------------ /// Default implementation for stepping into. /// /// This function is designed to be used by commands where the /// process is publicly stopped. /// - /// @param[in] source_step + /// \param[in] source_step /// If true and the frame has debug info, then do a source level /// step in, else do a single instruction step in. /// - /// @param[in] step_in_avoids_code_without_debug_info + /// \param[in] step_in_avoids_code_without_debug_info /// If \a true, then avoid stepping into code that doesn't have /// debug info, else step into any code regardless of whether it /// has debug info. /// - /// @param[in] step_out_avoids_code_without_debug_info + /// \param[in] step_out_avoids_code_without_debug_info /// If \a true, then if you step out to code with no debug info, keep /// stepping out till you get to code with debug info. /// - /// @return + /// \return /// An error that describes anything that went wrong - //------------------------------------------------------------------ virtual Status StepIn(bool source_step, LazyBool step_in_avoids_code_without_debug_info = eLazyBoolCalculate, LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate); - //------------------------------------------------------------------ /// Default implementation for stepping over. /// /// This function is designed to be used by commands where the /// process is publicly stopped. /// - /// @param[in] source_step + /// \param[in] source_step /// If true and the frame has debug info, then do a source level /// step over, else do a single instruction step over. /// - /// @return + /// \return /// An error that describes anything that went wrong - //------------------------------------------------------------------ virtual Status StepOver( bool source_step, LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate); - //------------------------------------------------------------------ /// Default implementation for stepping out. /// /// This function is designed to be used by commands where the /// process is publicly stopped. /// - /// @return + /// \return /// An error that describes anything that went wrong - //------------------------------------------------------------------ virtual Status StepOut(); - //------------------------------------------------------------------ /// Retrieves the per-thread data area. /// Most OSs maintain a per-thread pointer (e.g. the FS register on /// x64), which we return the value of here. /// - /// @return + /// \return /// LLDB_INVALID_ADDRESS if not supported, otherwise the thread /// pointer value. - //------------------------------------------------------------------ virtual lldb::addr_t GetThreadPointer(); - //------------------------------------------------------------------ /// Retrieves the per-module TLS block for a thread. /// - /// @param[in] module + /// \param[in] module /// The module to query TLS data for. /// - /// @param[in] tls_file_addr + /// \param[in] tls_file_addr /// The thread local address in module - /// @return + /// \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, lldb::addr_t tls_file_addr); - //------------------------------------------------------------------ /// Check whether this thread is safe to run functions /// /// The SystemRuntime may know of certain thread states (functions in /// process of execution, for instance) which can make it unsafe for /// functions to be called. /// - /// @return + /// \return /// True if it is safe to call functions on this thread. /// False if function calls should be avoided on this thread. - //------------------------------------------------------------------ virtual bool SafeToCallFunctions(); - //------------------------------------------------------------------ // Thread Plan Providers: // This section provides the basic thread plans that the Process control // machinery uses to run the target. ThreadPlan.h provides more details on @@ -618,69 +578,63 @@ public: // annoying to do because there's no elegant way to friend a method to all // sub-classes of a given class. // - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// Queues the base plan for a thread. /// The version returned by Process does some things that are useful, /// like handle breakpoints and signals, so if you return a plugin specific /// one you probably want to call through to the Process one for anything /// your plugin doesn't explicitly handle. /// - /// @param[in] abort_other_plans + /// \param[in] abort_other_plans /// \b true if we discard the currently queued plans and replace them with /// this one. /// Otherwise this plan will go on the end of the plan stack. /// - /// @return + /// \return /// A shared pointer to the newly queued thread plan, or nullptr if the /// plan could not be queued. - //------------------------------------------------------------------ virtual lldb::ThreadPlanSP QueueFundamentalPlan(bool abort_other_plans); - //------------------------------------------------------------------ /// Queues the plan used to step one instruction from the current PC of \a /// thread. /// - /// @param[in] step_over + /// \param[in] step_over /// \b true if we step over calls to functions, false if we step in. /// - /// @param[in] abort_other_plans + /// \param[in] abort_other_plans /// \b true if we discard the currently queued plans and replace them with /// this one. /// Otherwise this plan will go on the end of the plan stack. /// - /// @param[in] stop_other_threads + /// \param[in] stop_other_threads /// \b true if we will stop other threads while we single step this one. /// - /// @param[out] status + /// \param[out] status /// A status with an error if queuing failed. /// - /// @return + /// \return /// A shared pointer to the newly queued thread plan, or nullptr if the /// plan could not be queued. - //------------------------------------------------------------------ virtual lldb::ThreadPlanSP QueueThreadPlanForStepSingleInstruction( bool step_over, bool abort_other_plans, bool stop_other_threads, Status &status); - //------------------------------------------------------------------ /// Queues the plan used to step through an address range, stepping over /// function calls. /// - /// @param[in] abort_other_plans + /// \param[in] abort_other_plans /// \b true if we discard the currently queued plans and replace them with /// this one. /// Otherwise this plan will go on the end of the plan stack. /// - /// @param[in] type + /// \param[in] type /// Type of step to do, only eStepTypeInto and eStepTypeOver are supported /// by this plan. /// - /// @param[in] range + /// \param[in] range /// The address range to step through. /// - /// @param[in] addr_context + /// \param[in] addr_context /// When dealing with stepping through inlined functions the current PC is /// not enough information to know /// what "step" means. For instance a series of nested inline functions @@ -689,21 +643,20 @@ public: /// is supposed to be out of. // FIXME: Currently unused. /// - /// @param[in] stop_other_threads + /// \param[in] stop_other_threads /// \b true if we will stop other threads while we single step this one. /// - /// @param[out] status + /// \param[out] status /// A status with an error if queuing failed. /// - /// @param[in] step_out_avoids_code_without_debug_info + /// \param[in] step_out_avoids_code_without_debug_info /// If eLazyBoolYes, if the step over steps out it will continue to step /// out till it comes to a frame with debug info. /// If eLazyBoolCalculate, we will consult the default set in the thread. /// - /// @return + /// \return /// A shared pointer to the newly queued thread plan, or nullptr if the /// plan could not be queued. - //------------------------------------------------------------------ virtual lldb::ThreadPlanSP QueueThreadPlanForStepOverRange( bool abort_other_plans, const AddressRange &range, const SymbolContext &addr_context, lldb::RunMode stop_other_threads, @@ -719,23 +672,22 @@ public: Status &status, LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate); - //------------------------------------------------------------------ /// Queues the plan used to step through an address range, stepping into /// functions. /// - /// @param[in] abort_other_plans + /// \param[in] abort_other_plans /// \b true if we discard the currently queued plans and replace them with /// this one. /// Otherwise this plan will go on the end of the plan stack. /// - /// @param[in] type + /// \param[in] type /// Type of step to do, only eStepTypeInto and eStepTypeOver are supported /// by this plan. /// - /// @param[in] range + /// \param[in] range /// The address range to step through. /// - /// @param[in] addr_context + /// \param[in] addr_context /// When dealing with stepping through inlined functions the current PC is /// not enough information to know /// what "step" means. For instance a series of nested inline functions @@ -744,30 +696,29 @@ public: /// is supposed to be out of. // FIXME: Currently unused. /// - /// @param[in] step_in_target + /// \param[in] step_in_target /// Name if function we are trying to step into. We will step out if we /// don't land in that function. /// - /// @param[in] stop_other_threads + /// \param[in] stop_other_threads /// \b true if we will stop other threads while we single step this one. /// - /// @param[out] status + /// \param[out] status /// A status with an error if queuing failed. /// - /// @param[in] step_in_avoids_code_without_debug_info + /// \param[in] step_in_avoids_code_without_debug_info /// If eLazyBoolYes we will step out if we step into code with no debug /// info. /// If eLazyBoolCalculate we will consult the default set in the thread. /// - /// @param[in] step_out_avoids_code_without_debug_info + /// \param[in] step_out_avoids_code_without_debug_info /// If eLazyBoolYes, if the step over steps out it will continue to step /// out till it comes to a frame with debug info. /// If eLazyBoolCalculate, it will consult the default set in the thread. /// - /// @return + /// \return /// A shared pointer to the newly queued thread plan, or nullptr if the /// plan could not be queued. - //------------------------------------------------------------------ virtual lldb::ThreadPlanSP QueueThreadPlanForStepInRange( bool abort_other_plans, const AddressRange &range, const SymbolContext &addr_context, const char *step_in_target, @@ -785,16 +736,15 @@ public: LazyBool step_in_avoids_code_without_debug_info = eLazyBoolCalculate, LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate); - //------------------------------------------------------------------ /// Queue the plan used to step out of the function at the current PC of /// \a thread. /// - /// @param[in] abort_other_plans + /// \param[in] abort_other_plans /// \b true if we discard the currently queued plans and replace them with /// this one. /// Otherwise this plan will go on the end of the plan stack. /// - /// @param[in] addr_context + /// \param[in] addr_context /// When dealing with stepping through inlined functions the current PC is /// not enough information to know /// what "step" means. For instance a series of nested inline functions @@ -803,47 +753,45 @@ public: /// is supposed to be out of. // FIXME: Currently unused. /// - /// @param[in] first_insn + /// \param[in] first_insn /// \b true if this is the first instruction of a function. /// - /// @param[in] stop_other_threads + /// \param[in] stop_other_threads /// \b true if we will stop other threads while we single step this one. /// - /// @param[in] stop_vote - /// @param[in] run_vote + /// \param[in] stop_vote + /// \param[in] run_vote /// See standard meanings for the stop & run votes in ThreadPlan.h. /// - /// @param[out] status + /// \param[out] status /// A status with an error if queuing failed. /// - /// @param[in] step_out_avoids_code_without_debug_info + /// \param[in] step_out_avoids_code_without_debug_info /// If eLazyBoolYes, if the step over steps out it will continue to step /// out till it comes to a frame with debug info. /// If eLazyBoolCalculate, it will consult the default set in the thread. /// - /// @return + /// \return /// A shared pointer to the newly queued thread plan, or nullptr if the /// plan could not be queued. - //------------------------------------------------------------------ virtual lldb::ThreadPlanSP QueueThreadPlanForStepOut( bool abort_other_plans, SymbolContext *addr_context, bool first_insn, bool stop_other_threads, Vote stop_vote, Vote run_vote, uint32_t frame_idx, Status &status, LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate); - //------------------------------------------------------------------ /// Queue the plan used to step out of the function at the current PC of /// a thread. This version does not consult the should stop here callback, /// and should only /// be used by other thread plans when they need to retain control of the step /// out. /// - /// @param[in] abort_other_plans + /// \param[in] abort_other_plans /// \b true if we discard the currently queued plans and replace them with /// this one. /// Otherwise this plan will go on the end of the plan stack. /// - /// @param[in] addr_context + /// \param[in] addr_context /// When dealing with stepping through inlined functions the current PC is /// not enough information to know /// what "step" means. For instance a series of nested inline functions @@ -852,23 +800,23 @@ public: /// is supposed to be out of. // FIXME: Currently unused. /// - /// @param[in] first_insn + /// \param[in] first_insn /// \b true if this is the first instruction of a function. /// - /// @param[in] stop_other_threads + /// \param[in] stop_other_threads /// \b true if we will stop other threads while we single step this one. /// - /// @param[in] stop_vote + /// \param[in] stop_vote /// - /// @param[in] run_vote + /// \param[in] run_vote /// See standard meanings for the stop & run votes in ThreadPlan.h. /// - /// @param[in] frame_idx + /// \param[in] frame_idx /// - /// @param[out] status + /// \param[out] status /// A status with an error if queuing failed. /// - /// @param[in] continue_to_next_branch + /// \param[in] continue_to_next_branch /// Normally this will enqueue a plan that will put a breakpoint on the /// return address and continue /// to there. If continue_to_next_branch is true, this is an operation not @@ -885,67 +833,62 @@ public: /// registers which are overwritten /// before the next branch instruction. /// - /// @return + /// \return /// A shared pointer to the newly queued thread plan, or nullptr if the /// plan could not be queued. - //------------------------------------------------------------------ virtual lldb::ThreadPlanSP QueueThreadPlanForStepOutNoShouldStop( bool abort_other_plans, SymbolContext *addr_context, bool first_insn, bool stop_other_threads, Vote stop_vote, Vote run_vote, uint32_t frame_idx, Status &status, bool continue_to_next_branch = false); - //------------------------------------------------------------------ /// Gets the plan used to step through the code that steps from a function /// call site at the current PC into the actual function call. /// - /// @param[in] return_stack_id + /// \param[in] return_stack_id /// The stack id that we will return to (by setting backstop breakpoints on /// the return /// address to that frame) if we fail to step through. /// - /// @param[in] abort_other_plans + /// \param[in] abort_other_plans /// \b true if we discard the currently queued plans and replace them with /// this one. /// Otherwise this plan will go on the end of the plan stack. /// - /// @param[in] stop_other_threads + /// \param[in] stop_other_threads /// \b true if we will stop other threads while we single step this one. /// - /// @param[out] status + /// \param[out] status /// A status with an error if queuing failed. /// - /// @return + /// \return /// A shared pointer to the newly queued thread plan, or nullptr if the /// plan could not be queued. - //------------------------------------------------------------------ virtual lldb::ThreadPlanSP QueueThreadPlanForStepThrough(StackID &return_stack_id, bool abort_other_plans, bool stop_other_threads, Status &status); - //------------------------------------------------------------------ /// Gets the plan used to continue from the current PC. /// This is a simple plan, mostly useful as a backstop when you are continuing /// for some particular purpose. /// - /// @param[in] abort_other_plans + /// \param[in] abort_other_plans /// \b true if we discard the currently queued plans and replace them with /// this one. /// Otherwise this plan will go on the end of the plan stack. /// - /// @param[in] target_addr + /// \param[in] target_addr /// The address to which we're running. /// - /// @param[in] stop_other_threads + /// \param[in] stop_other_threads /// \b true if we will stop other threads while we single step this one. /// - /// @param[out] status + /// \param[out] status /// A status with an error if queuing failed. /// - /// @return + /// \return /// A shared pointer to the newly queued thread plan, or nullptr if the /// plan could not be queued. - //------------------------------------------------------------------ virtual lldb::ThreadPlanSP QueueThreadPlanForRunToAddress(bool abort_other_plans, Address &target_addr, bool stop_other_threads, Status &status); @@ -958,150 +901,122 @@ public: QueueThreadPlanForStepScripted(bool abort_other_plans, const char *class_name, bool stop_other_threads, Status &status); - //------------------------------------------------------------------ // Thread Plan accessors: - //------------------------------------------------------------------ - //------------------------------------------------------------------ /// Gets the plan which will execute next on the plan stack. /// - /// @return + /// \return /// A pointer to the next executed plan. - //------------------------------------------------------------------ ThreadPlan *GetCurrentPlan(); - //------------------------------------------------------------------ /// Unwinds the thread stack for the innermost expression plan currently /// on the thread plan stack. /// - /// @return + /// \return /// An error if the thread plan could not be unwound. - //------------------------------------------------------------------ Status UnwindInnermostExpression(); - //------------------------------------------------------------------ /// Gets the outer-most plan that was popped off the plan stack in the /// most recent stop. Useful for printing the stop reason accurately. /// - /// @return + /// \return /// A pointer to the last completed plan. - //------------------------------------------------------------------ lldb::ThreadPlanSP GetCompletedPlan(); - //------------------------------------------------------------------ /// Gets the outer-most return value from the completed plans /// - /// @return + /// \return /// A ValueObjectSP, either empty if there is no return value, /// or containing the return value. - //------------------------------------------------------------------ lldb::ValueObjectSP GetReturnValueObject(); - //------------------------------------------------------------------ /// Gets the outer-most expression variable from the completed plans /// - /// @return + /// \return /// A ExpressionVariableSP, either empty if there is no /// plan completed an expression during the current stop /// or the expression variable that was made for the completed expression. - //------------------------------------------------------------------ lldb::ExpressionVariableSP GetExpressionVariable(); - //------------------------------------------------------------------ /// Checks whether the given plan is in the completed plans for this /// stop. /// - /// @param[in] plan + /// \param[in] plan /// Pointer to the plan you're checking. /// - /// @return + /// \return /// Returns true if the input plan is in the completed plan stack, /// false otherwise. - //------------------------------------------------------------------ bool IsThreadPlanDone(ThreadPlan *plan); - //------------------------------------------------------------------ /// Checks whether the given plan is in the discarded plans for this /// stop. /// - /// @param[in] plan + /// \param[in] plan /// Pointer to the plan you're checking. /// - /// @return + /// \return /// Returns true if the input plan is in the discarded plan stack, /// false otherwise. - //------------------------------------------------------------------ bool WasThreadPlanDiscarded(ThreadPlan *plan); - //------------------------------------------------------------------ /// Check if we have completed plan to override breakpoint stop reason /// - /// @return + /// \return /// Returns true if completed plan stack is not empty /// false otherwise. - //------------------------------------------------------------------ bool CompletedPlanOverridesBreakpoint(); - //------------------------------------------------------------------ /// Queues a generic thread plan. /// - /// @param[in] plan_sp + /// \param[in] plan_sp /// The plan to queue. /// - /// @param[in] abort_other_plans + /// \param[in] abort_other_plans /// \b true if we discard the currently queued plans and replace them with /// this one. /// Otherwise this plan will go on the end of the plan stack. /// - /// @return + /// \return /// A pointer to the last completed plan. - //------------------------------------------------------------------ Status QueueThreadPlan(lldb::ThreadPlanSP &plan_sp, bool abort_other_plans); - //------------------------------------------------------------------ /// Discards the plans queued on the plan stack of the current thread. This /// is /// arbitrated by the "Master" ThreadPlans, using the "OkayToDiscard" call. // But if \a force is true, all thread plans are discarded. - //------------------------------------------------------------------ void DiscardThreadPlans(bool force); - //------------------------------------------------------------------ /// Discards the plans queued on the plan stack of the current thread up to /// and /// including up_to_plan_sp. // - // @param[in] up_to_plan_sp + // \param[in] up_to_plan_sp // Discard all plans up to and including this one. - //------------------------------------------------------------------ void DiscardThreadPlansUpToPlan(lldb::ThreadPlanSP &up_to_plan_sp); void DiscardThreadPlansUpToPlan(ThreadPlan *up_to_plan_ptr); - //------------------------------------------------------------------ /// Discards the plans queued on the plan stack of the current thread up to /// and /// including the plan in that matches \a thread_index counting only /// the non-Private plans. /// - /// @param[in] up_to_plan_sp + /// \param[in] up_to_plan_sp /// Discard all plans up to and including this user plan given by this /// index. /// - /// @return + /// \return /// \b true if there was a thread plan with that user index, \b false /// otherwise. - //------------------------------------------------------------------ bool DiscardUserThreadPlansUpToIndex(uint32_t thread_index); - //------------------------------------------------------------------ /// Prints the current plan stack. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the plan stack info. /// - //------------------------------------------------------------------ void DumpThreadPlans( Stream *s, lldb::DescriptionLevel desc_level = lldb::eDescriptionLevelVerbose, @@ -1119,15 +1034,12 @@ public: void SetTracer(lldb::ThreadPlanTracerSP &tracer_sp); - //------------------------------------------------------------------ // Get the thread index ID. The index ID that is guaranteed to not be re-used // by a process. They start at 1 and increase with each new thread. This // allows easy command line access by a unique ID that is easier to type than // the actual system thread ID. - //------------------------------------------------------------------ uint32_t GetIndexID() const; - //------------------------------------------------------------------ // Get the originating thread's index ID. // In the case of an "extended" thread -- a thread which represents the stack // that enqueued/spawned work that is currently executing -- we need to @@ -1137,22 +1049,17 @@ public: // is iterating over extended threads may ask for the OriginatingThreadID to // display that information to the user. // Normal threads will return the same thing as GetIndexID(); - //------------------------------------------------------------------ virtual uint32_t GetExtendedBacktraceOriginatingIndexID() { return GetIndexID(); } - //------------------------------------------------------------------ // The API ID is often the same as the Thread::GetID(), but not in all cases. // Thread::GetID() is the user visible thread ID that clients would want to // see. The API thread ID is the thread ID that is used when sending data // to/from the debugging protocol. - //------------------------------------------------------------------ virtual lldb::user_id_t GetProtocolID() const { return GetID(); } - //------------------------------------------------------------------ // lldb::ExecutionContextScope pure virtual functions - //------------------------------------------------------------------ lldb::TargetSP CalculateTarget() override; lldb::ProcessSP CalculateProcess() override; @@ -1195,18 +1102,15 @@ public: // with what you might have calculated. virtual lldb::StopInfoSP GetPrivateStopInfo(); - //---------------------------------------------------------------------- // Ask the thread subclass to set its stop info. // // Thread subclasses should call Thread::SetStopInfo(...) with the reason the // thread stopped. // - // @return + // \return // True if Thread::SetStopInfo(...) was called, false otherwise. - //---------------------------------------------------------------------- virtual bool CalculateStopInfo() = 0; - //---------------------------------------------------------------------- // Gets the temporary resume state for a thread. // // This value gets set in each thread by complex debugger logic in @@ -1220,7 +1124,6 @@ public: // is resumed // eStateSuspended - thread should not execute any instructions when // process is resumed - //---------------------------------------------------------------------- lldb::StateType GetTemporaryResumeState() const { return m_temporary_resume_state; } @@ -1231,26 +1134,22 @@ public: void SetShouldReportStop(Vote vote); - //---------------------------------------------------------------------- /// Sets the extended backtrace token for this thread /// /// Some Thread subclasses may maintain a token to help with providing /// an extended backtrace. The SystemRuntime plugin will set/request this. /// - /// @param [in] token - //---------------------------------------------------------------------- + /// \param [in] token virtual void SetExtendedBacktraceToken(uint64_t token) {} - //---------------------------------------------------------------------- /// Gets the extended backtrace token for this thread /// /// Some Thread subclasses may maintain a token to help with providing /// an extended backtrace. The SystemRuntime plugin will set/request this. /// - /// @return + /// \return /// The token needed by the SystemRuntime to create an extended backtrace. /// LLDB_INVALID_ADDRESS is returned if no token is available. - //---------------------------------------------------------------------- virtual uint64_t GetExtendedBacktraceToken() { return LLDB_INVALID_ADDRESS; } lldb::ValueObjectSP GetCurrentException(); @@ -1306,9 +1205,7 @@ protected: void FunctionOptimizationWarning(lldb_private::StackFrame *frame); - //------------------------------------------------------------------ // Classes that inherit from Process can see and modify these - //------------------------------------------------------------------ lldb::ProcessWP m_process_wp; ///< The process that owns this thread. lldb::StopInfoSP m_stop_info_sp; ///< The private stop reason for this thread uint32_t m_stop_info_stop_id; // This is the stop id for which the StopInfo is @@ -1348,7 +1245,7 @@ protected: ///thread plan logic for the current ///resume. /// It gets set in Thread::ShouldResume. - std::unique_ptr<lldb_private::Unwind> m_unwinder_ap; + std::unique_ptr<lldb_private::Unwind> m_unwinder_up; bool m_destroy_called; // This is used internally to make sure derived Thread // classes call DestroyThread. LazyBool m_override_should_notify; diff --git a/include/lldb/Target/ThreadCollection.h b/include/lldb/Target/ThreadCollection.h index dd5e81c1af480..29ea827203e5e 100644 --- a/include/lldb/Target/ThreadCollection.h +++ b/include/lldb/Target/ThreadCollection.h @@ -1,9 +1,8 @@ //===-- ThreadCollection.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadList.h b/include/lldb/Target/ThreadList.h index 6285cb1e0fb46..64ddf5aea504a 100644 --- a/include/lldb/Target/ThreadList.h +++ b/include/lldb/Target/ThreadList.h @@ -1,9 +1,8 @@ //===-- ThreadList.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -111,19 +110,17 @@ public: void RefreshStateAfterStop(); - //------------------------------------------------------------------ /// The thread list asks tells all the threads it is about to resume. /// If a thread can "resume" without having to resume the target, it /// will return false for WillResume, and then the process will not be /// restarted. /// - /// @return + /// \return /// \b true instructs the process to resume normally, /// \b false means start & stopped events will be generated, but /// the process will not actually run. The thread must then return /// the correct StopInfo when asked. /// - //------------------------------------------------------------------ bool WillResume(); void DidResume(); @@ -145,9 +142,7 @@ protected: void NotifySelectedThreadChanged(lldb::tid_t tid); - //------------------------------------------------------------------ // Classes that inherit from Process can see and modify these - //------------------------------------------------------------------ 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. @@ -156,7 +151,7 @@ protected: std::vector<lldb::tid_t> m_expression_tid_stack; private: - ThreadList(); + ThreadList() = delete; }; } // namespace lldb_private diff --git a/include/lldb/Target/ThreadPlan.h b/include/lldb/Target/ThreadPlan.h index 15bc4c7656c38..ff87ed23cda54 100644 --- a/include/lldb/Target/ThreadPlan.h +++ b/include/lldb/Target/ThreadPlan.h @@ -1,9 +1,8 @@ //===-- ThreadPlan.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,7 +22,6 @@ namespace lldb_private { -//------------------------------------------------------------------ // ThreadPlan: // This is the pure virtual base class for thread plans. // @@ -329,16 +327,15 @@ namespace lldb_private { // for a plan to instruct a sub-plan // on how to respond to ShouldReportStop. // -//------------------------------------------------------------------ class ThreadPlan : public std::enable_shared_from_this<ThreadPlan>, public UserID { public: - typedef enum { eAllThreads, eSomeThreads, eThisThread } ThreadScope; + enum ThreadScope { eAllThreads, eSomeThreads, eThisThread }; // We use these enums so that we can cast a base thread plan to it's real // type without having to resort to dynamic casting. - typedef enum { + enum ThreadPlanKind { eKindGeneric, eKindNull, eKindBase, @@ -354,30 +351,24 @@ public: eKindStepUntil, eKindTestCondition - } ThreadPlanKind; + }; - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread, Vote stop_vote, Vote run_vote); virtual ~ThreadPlan(); - //------------------------------------------------------------------ /// Returns the name of this thread plan. /// - /// @return + /// \return /// A const char * pointer to the thread plan's name. - //------------------------------------------------------------------ const char *GetName() const { return m_name.c_str(); } - //------------------------------------------------------------------ /// Returns the Thread that is using this thread plan. /// - /// @return + /// \return /// A pointer to the thread plan's owning thread. - //------------------------------------------------------------------ Thread &GetThread() { return m_thread; } const Thread &GetThread() const { return m_thread; } @@ -386,30 +377,26 @@ public: const Target &GetTarget() const { return m_thread.GetProcess()->GetTarget(); } - //------------------------------------------------------------------ /// Print a description of this thread to the stream \a s. /// \a thread. /// - /// @param[in] s + /// \param[in] s /// The stream to which to print the description. /// - /// @param[in] level + /// \param[in] level /// The level of description desired. Note that eDescriptionLevelBrief /// will be used in the stop message printed when the plan is complete. - //------------------------------------------------------------------ virtual void GetDescription(Stream *s, lldb::DescriptionLevel level) = 0; - //------------------------------------------------------------------ /// Returns whether this plan could be successfully created. /// - /// @param[in] error + /// \param[in] error /// A stream to which to print some reason why the plan could not be /// created. /// Can be NULL. /// - /// @return + /// \return /// \b true if the plan should be queued, \b false otherwise. - //------------------------------------------------------------------ virtual bool ValidatePlan(Stream *error) = 0; bool TracerExplainsStop() { @@ -557,9 +544,7 @@ public: } protected: - //------------------------------------------------------------------ // Classes that inherit from ThreadPlan can see and modify these - //------------------------------------------------------------------ virtual bool DoWillResume(lldb::StateType resume_state, bool current_plan) { return true; @@ -605,9 +590,7 @@ protected: int32_t m_iteration_count = 1; private: - //------------------------------------------------------------------ // For ThreadPlan only - //------------------------------------------------------------------ static lldb::user_id_t GetNextID(); ThreadPlanKind m_kind; @@ -626,13 +609,11 @@ private: DISALLOW_COPY_AND_ASSIGN(ThreadPlan); }; -//---------------------------------------------------------------------- // ThreadPlanNull: // Threads are assumed to always have at least one plan on the plan stack. This // is put on the plan stack when a thread is destroyed so that if you // accidentally access a thread after it is destroyed you won't crash. But // asking questions of the ThreadPlanNull is definitely an error. -//---------------------------------------------------------------------- class ThreadPlanNull : public ThreadPlan { public: diff --git a/include/lldb/Target/ThreadPlanBase.h b/include/lldb/Target/ThreadPlanBase.h index bcf20c5544bc4..bc92a06229a76 100644 --- a/include/lldb/Target/ThreadPlanBase.h +++ b/include/lldb/Target/ThreadPlanBase.h @@ -1,9 +1,8 @@ //===-- ThreadPlanBase.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -16,12 +15,10 @@ namespace lldb_private { -//------------------------------------------------------------------ // Base thread plans: // This is the generic version of the bottom most plan on the plan stack. It // should // be able to handle generic breakpoint hitting, and signals and exceptions. -//------------------------------------------------------------------ class ThreadPlanBase : public ThreadPlan { friend class Process; // RunThreadPlan manages "stopper" base plans. diff --git a/include/lldb/Target/ThreadPlanCallFunction.h b/include/lldb/Target/ThreadPlanCallFunction.h index 3bec86e370d18..685160a5678ae 100644 --- a/include/lldb/Target/ThreadPlanCallFunction.h +++ b/include/lldb/Target/ThreadPlanCallFunction.h @@ -1,9 +1,8 @@ //===-- ThreadPlanCallFunction.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h b/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h index 9b75da5fd2f88..c21e4d3cf3f76 100644 --- a/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h +++ b/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h @@ -1,10 +1,9 @@ //===-- ThreadPlanCallFunctionUsingABI.h --------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlanCallOnFunctionExit.h b/include/lldb/Target/ThreadPlanCallOnFunctionExit.h index c7ea368cca6ae..ad3ee6e0e8f9c 100644 --- a/include/lldb/Target/ThreadPlanCallOnFunctionExit.h +++ b/include/lldb/Target/ThreadPlanCallOnFunctionExit.h @@ -1,9 +1,8 @@ //===-- ThreadPlanCallOnFunctionExit.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -30,9 +29,7 @@ public: void DidPush() override; - // ------------------------------------------------------------------------- // ThreadPlan API - // ------------------------------------------------------------------------- void GetDescription(Stream *s, lldb::DescriptionLevel level) override; diff --git a/include/lldb/Target/ThreadPlanCallUserExpression.h b/include/lldb/Target/ThreadPlanCallUserExpression.h index ba1001ce5e916..6372155824104 100644 --- a/include/lldb/Target/ThreadPlanCallUserExpression.h +++ b/include/lldb/Target/ThreadPlanCallUserExpression.h @@ -1,10 +1,9 @@ //===-- ThreadPlanCallUserExpression.h --------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlanPython.h b/include/lldb/Target/ThreadPlanPython.h index fc4cfb3bf0b42..3825bf6ee4f31 100644 --- a/include/lldb/Target/ThreadPlanPython.h +++ b/include/lldb/Target/ThreadPlanPython.h @@ -1,10 +1,9 @@ //===-- ThreadPlanPython.h --------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -25,10 +24,8 @@ namespace lldb_private { -//------------------------------------------------------------------ // ThreadPlanPython: // -//------------------------------------------------------------------ class ThreadPlanPython : public ThreadPlan { public: diff --git a/include/lldb/Target/ThreadPlanRunToAddress.h b/include/lldb/Target/ThreadPlanRunToAddress.h index 58608864d4632..d82a9fad548a5 100644 --- a/include/lldb/Target/ThreadPlanRunToAddress.h +++ b/include/lldb/Target/ThreadPlanRunToAddress.h @@ -1,9 +1,8 @@ //===-- ThreadPlanRunToAddress.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlanShouldStopHere.h b/include/lldb/Target/ThreadPlanShouldStopHere.h index d3aca3e6f5c06..dfcbbb355c548 100644 --- a/include/lldb/Target/ThreadPlanShouldStopHere.h +++ b/include/lldb/Target/ThreadPlanShouldStopHere.h @@ -1,9 +1,8 @@ //===-- ThreadPlanShouldStopHere.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -63,9 +62,7 @@ public: eStepOutAvoidNoDebug = (1 << 2) }; - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ ThreadPlanShouldStopHere(ThreadPlan *owner); ThreadPlanShouldStopHere(ThreadPlan *owner, diff --git a/include/lldb/Target/ThreadPlanStepInRange.h b/include/lldb/Target/ThreadPlanStepInRange.h index c13b3533af1c9..a120c98fb36e1 100644 --- a/include/lldb/Target/ThreadPlanStepInRange.h +++ b/include/lldb/Target/ThreadPlanStepInRange.h @@ -1,9 +1,8 @@ //===-- ThreadPlanStepInRange.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -93,7 +92,7 @@ private: // for the ThreadPlanStepThrough. lldb::ThreadPlanSP m_sub_plan_sp; // Keep track of the last plan we were // running. If it fails, we should stop. - std::unique_ptr<RegularExpression> m_avoid_regexp_ap; + std::unique_ptr<RegularExpression> m_avoid_regexp_up; bool m_step_past_prologue; // FIXME: For now hard-coded to true, we could put // a switch in for this if there's // demand for that. diff --git a/include/lldb/Target/ThreadPlanStepInstruction.h b/include/lldb/Target/ThreadPlanStepInstruction.h index ea5d93fa4944d..127de417f6eb9 100644 --- a/include/lldb/Target/ThreadPlanStepInstruction.h +++ b/include/lldb/Target/ThreadPlanStepInstruction.h @@ -1,9 +1,8 @@ //===-- ThreadPlanStepInstruction.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlanStepOut.h b/include/lldb/Target/ThreadPlanStepOut.h index 8ef9f95d4f967..00984db2dca97 100644 --- a/include/lldb/Target/ThreadPlanStepOut.h +++ b/include/lldb/Target/ThreadPlanStepOut.h @@ -1,9 +1,8 @@ //===-- ThreadPlanStepOut.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlanStepOverBreakpoint.h b/include/lldb/Target/ThreadPlanStepOverBreakpoint.h index 7aaf56ed7c0b2..7df7049b568a4 100644 --- a/include/lldb/Target/ThreadPlanStepOverBreakpoint.h +++ b/include/lldb/Target/ThreadPlanStepOverBreakpoint.h @@ -1,9 +1,8 @@ //===-- ThreadPlanStepOverBreakpoint.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlanStepOverRange.h b/include/lldb/Target/ThreadPlanStepOverRange.h index 2eeb2bb96022c..30763e3861fa1 100644 --- a/include/lldb/Target/ThreadPlanStepOverRange.h +++ b/include/lldb/Target/ThreadPlanStepOverRange.h @@ -1,9 +1,8 @@ //===-- ThreadPlanStepOverRange.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlanStepRange.h b/include/lldb/Target/ThreadPlanStepRange.h index b3e267a0827b4..93d54ad7dfd5a 100644 --- a/include/lldb/Target/ThreadPlanStepRange.h +++ b/include/lldb/Target/ThreadPlanStepRange.h @@ -1,9 +1,8 @@ //===-- ThreadPlanStepRange.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlanStepThrough.h b/include/lldb/Target/ThreadPlanStepThrough.h index 1bff541e7df63..0d0621227b535 100644 --- a/include/lldb/Target/ThreadPlanStepThrough.h +++ b/include/lldb/Target/ThreadPlanStepThrough.h @@ -1,9 +1,8 @@ //===-- ThreadPlanStepThrough.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlanStepUntil.h b/include/lldb/Target/ThreadPlanStepUntil.h index 33ccc0fa0d54e..9a5934a36d7d4 100644 --- a/include/lldb/Target/ThreadPlanStepUntil.h +++ b/include/lldb/Target/ThreadPlanStepUntil.h @@ -1,9 +1,8 @@ //===-- ThreadPlanStepUntil.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlanTracer.h b/include/lldb/Target/ThreadPlanTracer.h index 21f9023f8d578..80b08078e975e 100644 --- a/include/lldb/Target/ThreadPlanTracer.h +++ b/include/lldb/Target/ThreadPlanTracer.h @@ -1,10 +1,9 @@ //===-- ThreadPlanTracer.h --------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,12 +21,12 @@ class ThreadPlanTracer { friend class ThreadPlan; public: - typedef enum ThreadPlanTracerStyle { + enum ThreadPlanTracerStyle { eLocation = 0, eStateChange, eCheckFrames, ePython - } ThreadPlanTracerStyle; + }; ThreadPlanTracer(Thread &thread, lldb::StreamSP &stream_sp); ThreadPlanTracer(Thread &thread); diff --git a/include/lldb/Target/ThreadSpec.h b/include/lldb/Target/ThreadSpec.h index 34baf80462618..05e7dcdb38d3c 100644 --- a/include/lldb/Target/ThreadSpec.h +++ b/include/lldb/Target/ThreadSpec.h @@ -1,9 +1,8 @@ //===-- ThreadSpec.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -35,10 +34,6 @@ class ThreadSpec { public: ThreadSpec(); - ThreadSpec(const ThreadSpec &rhs); - - const ThreadSpec &operator=(const ThreadSpec &rhs); - static std::unique_ptr<ThreadSpec> CreateFromStructuredData(const StructuredData::Dictionary &data_dict, Status &error); diff --git a/include/lldb/Target/UnixSignals.h b/include/lldb/Target/UnixSignals.h index 8774139371f01..120ffdd7ae254 100644 --- a/include/lldb/Target/UnixSignals.h +++ b/include/lldb/Target/UnixSignals.h @@ -1,9 +1,8 @@ //===-- UnixSignals.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,10 +22,9 @@ namespace lldb_private { class UnixSignals { public: static lldb::UnixSignalsSP Create(const ArchSpec &arch); + static lldb::UnixSignalsSP CreateForHost(); - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ UnixSignals(); virtual ~UnixSignals(); @@ -95,9 +93,7 @@ public: llvm::Optional<bool> should_notify); protected: - //------------------------------------------------------------------ // Classes that inherit from UnixSignals can see and modify these - //------------------------------------------------------------------ struct Signal { ConstString m_name; diff --git a/include/lldb/Target/Unwind.h b/include/lldb/Target/Unwind.h index 9e0da9ed553b5..a648e063e34b2 100644 --- a/include/lldb/Target/Unwind.h +++ b/include/lldb/Target/Unwind.h @@ -1,9 +1,8 @@ //===-- Unwind.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -18,9 +17,7 @@ namespace lldb_private { class Unwind { protected: - //------------------------------------------------------------------ // Classes that inherit from Unwind can see and modify these - //------------------------------------------------------------------ Unwind(Thread &thread) : m_thread(thread), m_unwind_mutex() {} public: @@ -63,9 +60,7 @@ public: Thread &GetThread() { return m_thread; } protected: - //------------------------------------------------------------------ // Classes that inherit from Unwind can see and modify these - //------------------------------------------------------------------ virtual void DoClear() = 0; virtual uint32_t DoGetFrameCount() = 0; diff --git a/include/lldb/Target/UnwindAssembly.h b/include/lldb/Target/UnwindAssembly.h index 3028ffeaa51d3..a70aef6e93c52 100644 --- a/include/lldb/Target/UnwindAssembly.h +++ b/include/lldb/Target/UnwindAssembly.h @@ -1,9 +1,8 @@ //===-- UnwindAssembly.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -45,7 +44,7 @@ protected: ArchSpec m_arch; private: - UnwindAssembly(); // Outlaw default constructor + UnwindAssembly() = delete; DISALLOW_COPY_AND_ASSIGN(UnwindAssembly); }; |