diff options
Diffstat (limited to 'contrib/llvm-project/lldb/include/lldb/Host')
9 files changed, 116 insertions, 59 deletions
diff --git a/contrib/llvm-project/lldb/include/lldb/Host/Config.h.cmake b/contrib/llvm-project/lldb/include/lldb/Host/Config.h.cmake index 42f4ca1a26c6..c667708a90a6 100644 --- a/contrib/llvm-project/lldb/include/lldb/Host/Config.h.cmake +++ b/contrib/llvm-project/lldb/include/lldb/Host/Config.h.cmake @@ -20,6 +20,8 @@ #cmakedefine01 HAVE_PPOLL +#cmakedefine01 HAVE_PTSNAME_R + #cmakedefine01 HAVE_SIGACTION #cmakedefine01 HAVE_PROCESS_VM_READV @@ -38,6 +40,8 @@ #cmakedefine01 LLDB_ENABLE_CURSES +#cmakedefine01 CURSES_HAVE_NCURSES_CURSES_H + #cmakedefine01 LLDB_ENABLE_LIBEDIT #cmakedefine01 LLDB_ENABLE_LIBXML2 @@ -48,7 +52,7 @@ #cmakedefine01 LLDB_EMBED_PYTHON_HOME -#cmakedefine LLDB_PYTHON_HOME "${LLDB_PYTHON_HOME}" +#cmakedefine LLDB_PYTHON_HOME R"(${LLDB_PYTHON_HOME})" #define LLDB_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" diff --git a/contrib/llvm-project/lldb/include/lldb/Host/Editline.h b/contrib/llvm-project/lldb/include/lldb/Host/Editline.h index 356e8f734732..a37ad1b9d106 100644 --- a/contrib/llvm-project/lldb/include/lldb/Host/Editline.h +++ b/contrib/llvm-project/lldb/include/lldb/Host/Editline.h @@ -98,6 +98,9 @@ typedef int (*FixIndentationCallbackType)(Editline *editline, const StringList &lines, int cursor_position, void *baton); +typedef llvm::Optional<std::string> (*SuggestionCallbackType)( + llvm::StringRef line, void *baton); + typedef void (*CompleteCallbackType)(CompletionRequest &request, void *baton); /// Status used to decide when and how to start editing another line in @@ -184,6 +187,9 @@ public: /// Cancel this edit and oblitarate all trace of it bool Cancel(); + /// Register a callback for autosuggestion. + void SetSuggestionCallback(SuggestionCallbackType callback, void *baton); + /// Register a callback for the tab key void SetAutoCompleteCallback(CompleteCallbackType callback, void *baton); @@ -312,6 +318,12 @@ private: /// tab key is typed. unsigned char TabCommand(int ch); + /// Apply autosuggestion part in gray as editline. + unsigned char ApplyAutosuggestCommand(int ch); + + /// Command used when a character is typed. + unsigned char TypedCharacter(int ch); + /// Respond to normal character insertion by fixing line indentation unsigned char FixIndentationCommand(int ch); @@ -360,7 +372,9 @@ private: const char *m_fix_indentation_callback_chars = nullptr; CompleteCallbackType m_completion_callback = nullptr; void *m_completion_callback_baton = nullptr; - + SuggestionCallbackType m_suggestion_callback = nullptr; + void *m_suggestion_callback_baton = nullptr; + std::size_t m_previous_autosuggestion_size = 0; std::mutex m_output_mutex; }; } diff --git a/contrib/llvm-project/lldb/include/lldb/Host/FileSystem.h b/contrib/llvm-project/lldb/include/lldb/Host/FileSystem.h index 8dcff3402592..02ff5f301336 100644 --- a/contrib/llvm-project/lldb/include/lldb/Host/FileSystem.h +++ b/contrib/llvm-project/lldb/include/lldb/Host/FileSystem.h @@ -33,13 +33,14 @@ public: FileSystem() : m_fs(llvm::vfs::getRealFileSystem()), m_collector(nullptr), - m_mapped(false) {} - FileSystem(std::shared_ptr<llvm::FileCollector> collector) - : m_fs(llvm::vfs::getRealFileSystem()), m_collector(collector), - m_mapped(false) {} + m_home_directory(), m_mapped(false) {} + FileSystem(std::shared_ptr<llvm::FileCollectorBase> collector) + : m_fs(llvm::vfs::getRealFileSystem()), m_collector(std::move(collector)), + m_home_directory(), m_mapped(false) {} FileSystem(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs, bool mapped = false) - : m_fs(fs), m_collector(nullptr), m_mapped(mapped) {} + : m_fs(std::move(fs)), m_collector(nullptr), m_home_directory(), + m_mapped(mapped) {} FileSystem(const FileSystem &fs) = delete; FileSystem &operator=(const FileSystem &fs) = delete; @@ -47,7 +48,7 @@ public: static FileSystem &Instance(); static void Initialize(); - static void Initialize(std::shared_ptr<llvm::FileCollector> collector); + static void Initialize(std::shared_ptr<llvm::FileCollectorBase> collector); static llvm::Error Initialize(const FileSpec &mapping); static void Initialize(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs); static void Terminate(); @@ -154,6 +155,10 @@ public: /// Call into the Host to see if it can help find the file. bool ResolveExecutableLocation(FileSpec &file_spec); + /// Get the user home directory. + bool GetHomeDirectory(llvm::SmallVectorImpl<char> &path) const; + bool GetHomeDirectory(FileSpec &file_spec) const; + enum EnumerateDirectoryResult { /// Enumerate next entry in the current directory. eEnumerateDirectoryResultNext, @@ -189,10 +194,13 @@ public: void Collect(const FileSpec &file_spec); void Collect(const llvm::Twine &file); + void SetHomeDirectory(std::string home_directory); + private: static llvm::Optional<FileSystem> &InstanceImpl(); llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> m_fs; - std::shared_ptr<llvm::FileCollector> m_collector; + std::shared_ptr<llvm::FileCollectorBase> m_collector; + std::string m_home_directory; bool m_mapped; }; } // namespace lldb_private diff --git a/contrib/llvm-project/lldb/include/lldb/Host/Host.h b/contrib/llvm-project/lldb/include/lldb/Host/Host.h index f19cb85d2329..76792cc6eab5 100644 --- a/contrib/llvm-project/lldb/include/lldb/Host/Host.h +++ b/contrib/llvm-project/lldb/include/lldb/Host/Host.h @@ -196,19 +196,34 @@ public: static Status ShellExpandArguments(ProcessLaunchInfo &launch_info); /// Run a shell command. - /// \arg command shouldn't be NULL + /// \arg command shouldn't be empty /// \arg working_dir Pass empty FileSpec to use the current working directory /// \arg status_ptr Pass NULL if you don't want the process exit status /// \arg signo_ptr Pass NULL if you don't want the signal that caused the /// process to exit /// \arg command_output Pass NULL if you don't want the command output /// \arg hide_stderr if this is false, redirect stderr to stdout - /// TODO: Convert this function to take a StringRef. - static Status RunShellCommand(const char *command, + static Status RunShellCommand(llvm::StringRef command, const FileSpec &working_dir, int *status_ptr, int *signo_ptr, std::string *command_output, const Timeout<std::micro> &timeout, - bool run_in_default_shell = true, + bool run_in_shell = true, + bool hide_stderr = false); + + /// Run a shell command. + /// \arg shell Pass an empty string if you want to use the default shell + /// interpreter \arg command \arg working_dir Pass empty FileSpec to use the + /// current working directory \arg status_ptr Pass NULL if you don't want + /// the process exit status \arg signo_ptr Pass NULL if you don't want the + /// signal that caused + /// the process to exit + /// \arg command_output Pass NULL if you don't want the command output + /// \arg hide_stderr If this is \b false, redirect stderr to stdout + static Status RunShellCommand(llvm::StringRef shell, llvm::StringRef command, + const FileSpec &working_dir, int *status_ptr, + int *signo_ptr, std::string *command_output, + const Timeout<std::micro> &timeout, + bool run_in_shell = true, bool hide_stderr = false); /// Run a shell command. @@ -222,7 +237,23 @@ public: int *status_ptr, int *signo_ptr, std::string *command_output, const Timeout<std::micro> &timeout, - bool run_in_default_shell = true, + bool run_in_shell = true, + bool hide_stderr = false); + + /// Run a shell command. + /// \arg shell Pass an empty string if you want to use the default + /// shell interpreter \arg command \arg working_dir Pass empty FileSpec to use + /// the current working directory \arg status_ptr Pass NULL if you don't + /// want the process exit status \arg signo_ptr Pass NULL if you don't + /// want the signal that caused the + /// process to exit + /// \arg command_output Pass NULL if you don't want the command output + /// \arg hide_stderr If this is \b false, redirect stderr to stdout + static Status RunShellCommand(llvm::StringRef shell, const Args &args, + const FileSpec &working_dir, int *status_ptr, + int *signo_ptr, std::string *command_output, + const Timeout<std::micro> &timeout, + bool run_in_shell = true, bool hide_stderr = false); static bool OpenFileInExternalEditor(const FileSpec &file_spec, diff --git a/contrib/llvm-project/lldb/include/lldb/Host/HostInfoBase.h b/contrib/llvm-project/lldb/include/lldb/Host/HostInfoBase.h index 70682c9b685e..15bb168aad97 100644 --- a/contrib/llvm-project/lldb/include/lldb/Host/HostInfoBase.h +++ b/contrib/llvm-project/lldb/include/lldb/Host/HostInfoBase.h @@ -11,6 +11,7 @@ #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/UUID.h" #include "lldb/Utility/UserIDResolver.h" #include "lldb/Utility/XcodeSDK.h" #include "lldb/lldb-enumerations.h" @@ -24,6 +25,11 @@ namespace lldb_private { class FileSpec; +struct SharedCacheImageInfo { + UUID uuid; + lldb::DataBufferSP data_sp; +}; + class HostInfoBase { private: // Static class, unconstructable. @@ -98,6 +104,13 @@ public: /// Return the directory containing a specific Xcode SDK. static llvm::StringRef GetXcodeSDKPath(XcodeSDK sdk) { return {}; } + /// Return information about module \p image_name if it is loaded in + /// the current process's address space. + static SharedCacheImageInfo + GetSharedCacheImageInfo(llvm::StringRef image_name) { + return {}; + } + protected: static bool ComputeSharedLibraryDirectory(FileSpec &file_spec); static bool ComputeSupportExeDirectory(FileSpec &file_spec); diff --git a/contrib/llvm-project/lldb/include/lldb/Host/ProcessLaunchInfo.h b/contrib/llvm-project/lldb/include/lldb/Host/ProcessLaunchInfo.h index e83d8396e9f2..ee9755580825 100644 --- a/contrib/llvm-project/lldb/include/lldb/Host/ProcessLaunchInfo.h +++ b/contrib/llvm-project/lldb/include/lldb/Host/ProcessLaunchInfo.h @@ -94,10 +94,9 @@ public: void Clear(); - bool ConvertArgumentsForLaunchingInShell(Status &error, bool localhost, - bool will_debug, + bool ConvertArgumentsForLaunchingInShell(Status &error, bool will_debug, bool first_arg_is_full_shell_command, - int32_t num_resumes); + uint32_t num_resumes); void SetMonitorProcessCallback(const Host::MonitorChildProcessCallback &callback, diff --git a/contrib/llvm-project/lldb/include/lldb/Host/PseudoTerminal.h b/contrib/llvm-project/lldb/include/lldb/Host/PseudoTerminal.h index 8a5a233e7748..350f926dcac1 100644 --- a/contrib/llvm-project/lldb/include/lldb/Host/PseudoTerminal.h +++ b/contrib/llvm-project/lldb/include/lldb/Host/PseudoTerminal.h @@ -9,11 +9,11 @@ #ifndef LLDB_HOST_PSEUDOTERMINAL_H #define LLDB_HOST_PSEUDOTERMINAL_H +#include "lldb/lldb-defines.h" +#include "llvm/Support/Error.h" #include <fcntl.h> #include <string> -#include "lldb/lldb-defines.h" - namespace lldb_private { /// \class PseudoTerminal PseudoTerminal.h "lldb/Host/PseudoTerminal.h" @@ -62,15 +62,11 @@ public: /// @li PseudoTerminal::ReleasePrimaryFileDescriptor() @li /// PseudoTerminal::ReleaseSaveFileDescriptor() /// - /// \param[out] error_str - /// An pointer to an error that can describe any errors that - /// occur. This can be NULL if no error status is desired. - /// /// \return /// \b Parent process: a child process ID that is greater - /// than zero, or -1 if the fork fails. + /// than zero, or an error if the fork fails. /// \b Child process: zero. - lldb::pid_t Fork(char *error_str, size_t error_len); + llvm::Expected<lldb::pid_t> Fork(); /// The primary file descriptor accessor. /// @@ -105,20 +101,11 @@ public: /// A primary pseudo terminal should already be valid prior to /// calling this function. /// - /// \param[out] error_str - /// An pointer to an error that can describe any errors that - /// occur. This can be NULL if no error status is desired. - /// /// \return - /// The name of the secondary pseudo terminal as a NULL terminated - /// C. This string that comes from static memory, so a copy of - /// the string should be made as subsequent calls can change - /// this value. NULL is returned if this object doesn't have - /// a valid primary pseudo terminal opened or if the call to - /// \c ptsname() fails. + /// The name of the secondary pseudo terminal. /// /// \see PseudoTerminal::OpenFirstAvailablePrimary() - const char *GetSecondaryName(char *error_str, size_t error_len) const; + std::string GetSecondaryName() const; /// Open the first available pseudo terminal. /// @@ -137,18 +124,9 @@ public: /// Flags to use when calling \c posix_openpt(\a oflag). /// A value of "O_RDWR|O_NOCTTY" is suggested. /// - /// \param[out] error_str - /// An pointer to an error that can describe any errors that - /// occur. This can be NULL if no error status is desired. - /// - /// \return - /// \b true when the primary files descriptor is - /// successfully opened. - /// \b false if anything goes wrong. - /// /// \see PseudoTerminal::GetPrimaryFileDescriptor() @see /// PseudoTerminal::ReleasePrimaryFileDescriptor() - bool OpenFirstAvailablePrimary(int oflag, char *error_str, size_t error_len); + llvm::Error OpenFirstAvailablePrimary(int oflag); /// Open the secondary for the current primary pseudo terminal. /// @@ -166,19 +144,10 @@ public: /// \param[in] oflag /// Flags to use when calling \c open(\a oflag). /// - /// \param[out] error_str - /// An pointer to an error that can describe any errors that - /// occur. This can be NULL if no error status is desired. - /// - /// \return - /// \b true when the primary files descriptor is - /// successfully opened. - /// \b false if anything goes wrong. - /// /// \see PseudoTerminal::OpenFirstAvailablePrimary() @see /// PseudoTerminal::GetSecondaryFileDescriptor() @see /// PseudoTerminal::ReleaseSecondaryFileDescriptor() - bool OpenSecondary(int oflag, char *error_str, size_t error_len); + llvm::Error OpenSecondary(int oflag); /// Release the primary file descriptor. /// diff --git a/contrib/llvm-project/lldb/include/lldb/Host/common/NativeProcessProtocol.h b/contrib/llvm-project/lldb/include/lldb/Host/common/NativeProcessProtocol.h index 2faab6f587cd..5be9cb657382 100644 --- a/contrib/llvm-project/lldb/include/lldb/Host/common/NativeProcessProtocol.h +++ b/contrib/llvm-project/lldb/include/lldb/Host/common/NativeProcessProtocol.h @@ -17,6 +17,7 @@ #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/TraceOptions.h" +#include "lldb/Utility/UnimplementedError.h" #include "lldb/lldb-private-forward.h" #include "lldb/lldb-types.h" #include "llvm/ADT/ArrayRef.h" @@ -112,10 +113,14 @@ public: virtual Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written) = 0; - virtual Status AllocateMemory(size_t size, uint32_t permissions, - lldb::addr_t &addr) = 0; + virtual llvm::Expected<lldb::addr_t> AllocateMemory(size_t size, + uint32_t permissions) { + return llvm::make_error<UnimplementedError>(); + } - virtual Status DeallocateMemory(lldb::addr_t addr) = 0; + virtual llvm::Error DeallocateMemory(lldb::addr_t addr) { + return llvm::make_error<UnimplementedError>(); + } virtual lldb::addr_t GetSharedLibraryInfoAddress() = 0; @@ -387,6 +392,11 @@ public: return Status("Not implemented"); } + /// \copydoc Process::GetSupportedTraceType() + virtual llvm::Expected<TraceTypeInfo> GetSupportedTraceType() { + return llvm::make_error<UnimplementedError>(); + } + protected: struct SoftwareBreakpoint { uint32_t ref_count; diff --git a/contrib/llvm-project/lldb/include/lldb/Host/common/NativeRegisterContext.h b/contrib/llvm-project/lldb/include/lldb/Host/common/NativeRegisterContext.h index 3b54d4ae1e05..f7568fe31b80 100644 --- a/contrib/llvm-project/lldb/include/lldb/Host/common/NativeRegisterContext.h +++ b/contrib/llvm-project/lldb/include/lldb/Host/common/NativeRegisterContext.h @@ -16,6 +16,8 @@ namespace lldb_private { class NativeThreadProtocol; +enum class ExpeditedRegs { Minimal, Full }; + class NativeRegisterContext : public std::enable_shared_from_this<NativeRegisterContext> { public: @@ -75,6 +77,8 @@ public: virtual bool ClearHardwareWatchpoint(uint32_t hw_index); + virtual Status ClearWatchpointHit(uint32_t hw_index); + virtual Status ClearAllHardwareWatchpoints(); virtual Status IsWatchpointHit(uint32_t wp_index, bool &is_hit); @@ -114,6 +118,11 @@ public: virtual NativeThreadProtocol &GetThread() { return m_thread; } + virtual std::vector<uint32_t> + GetExpeditedRegisters(ExpeditedRegs expType) const; + + virtual bool RegisterOffsetIsDynamic() const { return false; } + const RegisterInfo *GetRegisterInfoByName(llvm::StringRef reg_name, uint32_t start_idx = 0); |