diff options
Diffstat (limited to 'include/lldb/Target/Process.h')
-rw-r--r-- | include/lldb/Target/Process.h | 934 |
1 files changed, 265 insertions, 669 deletions
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; |