aboutsummaryrefslogtreecommitdiffstats
path: root/include/lldb/Host
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-10-23 17:53:01 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-10-23 17:53:01 +0000
commitead246455adf1a215ec2715dad6533073a6beb4e (patch)
treef3f97a47d77053bf96fe74cdbd6fae74380e8a92 /include/lldb/Host
parentfdb00c4408990a0a63ef7f496d809ce59f263bc5 (diff)
downloadsrc-vendor/lldb.tar.gz
src-vendor/lldb.zip
Vendor import of stripped lldb trunk r375505, the last commit before thevendor/lldb/lldb-trunk-r375505vendor/lldb
upstream Subversion repository was made read-only, and the LLVM project migrated to GitHub: https://llvm.org/svn/llvm-project/lldb/trunk@375505
Notes
Notes: svn path=/vendor/lldb/dist/; revision=353952 svn path=/vendor/lldb/lldb-r375505/; revision=353953; tag=vendor/lldb/lldb-trunk-r375505
Diffstat (limited to 'include/lldb/Host')
-rw-r--r--include/lldb/Host/Config.h.cmake4
-rw-r--r--include/lldb/Host/Editline.h7
-rw-r--r--include/lldb/Host/File.h358
-rw-r--r--include/lldb/Host/FileCache.h5
-rw-r--r--include/lldb/Host/FileSystem.h17
-rw-r--r--include/lldb/Host/LZMA.h34
-rw-r--r--include/lldb/Host/Socket.h3
-rw-r--r--include/lldb/Host/common/NativeProcessProtocol.h41
8 files changed, 298 insertions, 171 deletions
diff --git a/include/lldb/Host/Config.h.cmake b/include/lldb/Host/Config.h.cmake
index b8fb9e9de868..662c07668d14 100644
--- a/include/lldb/Host/Config.h.cmake
+++ b/include/lldb/Host/Config.h.cmake
@@ -19,6 +19,8 @@
#define LLDB_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}"
+#cmakedefine01 HAVE_SYS_TYPES_H
+
#cmakedefine01 HAVE_SYS_EVENT_H
#cmakedefine01 HAVE_PPOLL
@@ -33,4 +35,6 @@
#cmakedefine HAVE_LIBCOMPRESSION
#endif
+#cmakedefine01 LLDB_ENABLE_LZMA
+
#endif // #ifndef LLDB_HOST_CONFIG_H
diff --git a/include/lldb/Host/Editline.h b/include/lldb/Host/Editline.h
index a942ede05ce5..65bf15531bc4 100644
--- a/include/lldb/Host/Editline.h
+++ b/include/lldb/Host/Editline.h
@@ -53,6 +53,7 @@
#include <vector>
#include "lldb/Host/ConnectionFileDescriptor.h"
+#include "lldb/Utility/CompletionRequest.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Predicate.h"
@@ -97,11 +98,7 @@ typedef int (*FixIndentationCallbackType)(Editline *editline,
const StringList &lines,
int cursor_position, void *baton);
-typedef int (*CompleteCallbackType)(const char *current_line,
- const char *cursor, const char *last_char,
- int skip_first_n_matches, int max_matches,
- StringList &matches,
- StringList &descriptions, void *baton);
+typedef void (*CompleteCallbackType)(CompletionRequest &request, void *baton);
/// Status used to decide when and how to start editing another line in
/// multi-line sessions
diff --git a/include/lldb/Host/File.h b/include/lldb/Host/File.h
index eb28c4ada0e7..0102beb141ee 100644
--- a/include/lldb/Host/File.h
+++ b/include/lldb/Host/File.h
@@ -13,6 +13,7 @@
#include "lldb/Utility/IOObject.h"
#include "lldb/Utility/Status.h"
#include "lldb/lldb-private.h"
+#include "llvm/ADT/BitmaskEnum.h"
#include <mutex>
#include <stdarg.h>
@@ -21,11 +22,15 @@
namespace lldb_private {
+LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
+
/// \class File File.h "lldb/Host/File.h"
-/// A file class.
+/// An abstract base class for files.
///
-/// A file class that divides abstracts the LLDB core from host file
-/// functionality.
+/// Files will often be NativeFiles, which provides a wrapper
+/// around host OS file functionality. But it
+/// is also possible to subclass file to provide objects that have file
+/// or stream functionality but are not backed by any host OS file.
class File : public IOObject {
public:
static int kInvalidDescriptor;
@@ -33,7 +38,12 @@ public:
// NB this enum is used in the lldb platform gdb-remote packet
// vFile:open: and existing values cannot be modified.
- enum OpenOptions {
+ //
+ // FIXME
+ // These values do not match the values used by GDB
+ // * https://sourceware.org/gdb/onlinedocs/gdb/Open-Flags.html#Open-Flags
+ // * rdar://problem/46788934
+ enum OpenOptions : uint32_t {
eOpenOptionRead = (1u << 0), // Open file for reading
eOpenOptionWrite = (1u << 1), // Open file for writing
eOpenOptionAppend =
@@ -45,128 +55,105 @@ public:
(1u << 6), // Can create file only if it doesn't already exist
eOpenOptionDontFollowSymlinks = (1u << 7),
eOpenOptionCloseOnExec =
- (1u << 8) // Close the file when executing a new process
+ (1u << 8), // Close the file when executing a new process
+ LLVM_MARK_AS_BITMASK_ENUM(/* largest_value= */ eOpenOptionCloseOnExec)
};
- static mode_t ConvertOpenOptionsForPOSIXOpen(uint32_t open_options);
+ static mode_t ConvertOpenOptionsForPOSIXOpen(OpenOptions open_options);
+ static llvm::Expected<OpenOptions> GetOptionsFromMode(llvm::StringRef mode);
+ static bool DescriptorIsValid(int descriptor) { return descriptor >= 0; };
+ static llvm::Expected<const char *>
+ GetStreamOpenModeFromOptions(OpenOptions options);
File()
- : IOObject(eFDTypeFile, false), m_descriptor(kInvalidDescriptor),
- m_stream(kInvalidStream), m_options(0), m_own_stream(false),
- m_is_interactive(eLazyBoolCalculate),
+ : IOObject(eFDTypeFile), m_is_interactive(eLazyBoolCalculate),
m_is_real_terminal(eLazyBoolCalculate),
- m_supports_colors(eLazyBoolCalculate) {}
-
- File(FILE *fh, bool transfer_ownership)
- : IOObject(eFDTypeFile, false), m_descriptor(kInvalidDescriptor),
- m_stream(fh), m_options(0), m_own_stream(transfer_ownership),
- m_is_interactive(eLazyBoolCalculate),
- m_is_real_terminal(eLazyBoolCalculate),
- m_supports_colors(eLazyBoolCalculate) {}
-
- File(int fd, bool transfer_ownership)
- : IOObject(eFDTypeFile, transfer_ownership), m_descriptor(fd),
- m_stream(kInvalidStream), m_options(0), m_own_stream(false),
- m_is_interactive(eLazyBoolCalculate),
- m_is_real_terminal(eLazyBoolCalculate) {}
+ m_supports_colors(eLazyBoolCalculate){};
- /// Destructor.
+ /// Read bytes from a file from the current file position into buf.
///
- /// The destructor is virtual in case this class is subclassed.
- ~File() override;
-
- bool IsValid() const override {
- return DescriptorIsValid() || StreamIsValid();
- }
-
- /// Convert to pointer operator.
+ /// NOTE: This function is NOT thread safe. Use the read function
+ /// that takes an "off_t &offset" to ensure correct operation in multi-
+ /// threaded environments.
///
- /// This allows code to check a File object to see if it contains anything
- /// valid using code such as:
+ /// \param[out] buf
///
- /// \code
- /// File file(...);
- /// if (file)
- /// { ...
- /// \endcode
+ /// \param[in,out] num_bytes.
+ /// Pass in the size of buf. Read will pass out the number
+ /// of bytes read. Zero bytes read with no error indicates
+ /// EOF.
///
/// \return
- /// A pointer to this object if either the directory or filename
- /// is valid, nullptr otherwise.
- operator bool() const { return DescriptorIsValid() || StreamIsValid(); }
+ /// success, ENOTSUP, or another error.
+ Status Read(void *buf, size_t &num_bytes) override;
- /// Logical NOT operator.
+ /// Write bytes from buf to a file at the current file position.
///
- /// This allows code to check a File object to see if it is invalid using
- /// code such as:
+ /// NOTE: This function is NOT thread safe. Use the write function
+ /// that takes an "off_t &offset" to ensure correct operation in multi-
+ /// threaded environments.
+ ///
+ /// \param[in] buf
///
- /// \code
- /// File file(...);
- /// if (!file)
- /// { ...
- /// \endcode
+ /// \param[in,out] num_bytes
+ /// Pass in the size of buf. Write will pass out the number
+ /// of bytes written. Write will attempt write the full number
+ /// of bytes and will not return early except on error.
///
/// \return
- /// Returns \b true if the object has an empty directory and
- /// filename, \b false otherwise.
- bool operator!() const { return !DescriptorIsValid() && !StreamIsValid(); }
+ /// success, ENOTSUP, or another error.
+ Status Write(const void *buf, size_t &num_bytes) override;
- /// Get the file spec for this file.
+ /// IsValid
///
/// \return
- /// A reference to the file specification object.
- Status GetFileSpec(FileSpec &file_spec) const;
+ /// true iff the file is valid.
+ bool IsValid() const override;
+ /// Flush any buffers and release any resources owned by the file.
+ /// After Close() the file will be invalid.
+ ///
+ /// \return
+ /// success or an error.
Status Close() override;
- void Clear();
-
- int GetDescriptor() const;
-
+ /// Get a handle that can be used for OS polling interfaces, such
+ /// as WaitForMultipleObjects, select, or epoll. This may return
+ /// IOObject::kInvalidHandleValue if none is available. This will
+ /// generally be the same as the file descriptor, this function
+ /// is not interchangeable with GetDescriptor(). A WaitableHandle
+ /// must only be used for polling, not actual I/O.
+ ///
+ /// \return
+ /// a valid handle or IOObject::kInvalidHandleValue
WaitableHandle GetWaitableHandle() override;
- void SetDescriptor(int fd, bool transfer_ownership);
-
- FILE *GetStream();
-
- void SetStream(FILE *fh, bool transfer_ownership);
-
- /// Read bytes from a file from the current file position.
- ///
- /// NOTE: This function is NOT thread safe. Use the read function
- /// that takes an "off_t &offset" to ensure correct operation in multi-
- /// threaded environments.
- ///
- /// \param[in] buf
- /// A buffer where to put the bytes that are read.
- ///
- /// \param[in,out] num_bytes
- /// The number of bytes to read form the current file position
- /// which gets modified with the number of bytes that were read.
+ /// Get the file specification for this file, if possible.
///
+ /// \param[out] file_spec
+ /// the file specification.
/// \return
- /// An error object that indicates success or the reason for
- /// failure.
- Status Read(void *buf, size_t &num_bytes) override;
+ /// ENOTSUP, success, or another error.
+ virtual Status GetFileSpec(FileSpec &file_spec) const;
- /// Write bytes to a file at the current file position.
- ///
- /// NOTE: This function is NOT thread safe. Use the write function
- /// that takes an "off_t &offset" to ensure correct operation in multi-
- /// threaded environments.
+ /// Get underlying OS file descriptor for this file, or kInvalidDescriptor.
+ /// If the descriptor is valid, then it may be used directly for I/O
+ /// However, the File may also perform it's own buffering, so avoid using
+ /// this if it is not necessary, or use Flush() appropriately.
///
- /// \param[in] buf
- /// A buffer where to put the bytes that are read.
+ /// \return
+ /// a valid file descriptor for this file or kInvalidDescriptor
+ virtual int GetDescriptor() const;
+
+ /// Get the underlying libc stream for this file, or NULL.
///
- /// \param[in,out] num_bytes
- /// The number of bytes to write to the current file position
- /// which gets modified with the number of bytes that were
- /// written.
+ /// Not all valid files will have a FILE* stream. This should only be
+ /// used if absolutely necessary, such as to interact with 3rd party
+ /// libraries that need FILE* streams.
///
/// \return
- /// An error object that indicates success or the reason for
- /// failure.
- Status Write(const void *buf, size_t &num_bytes) override;
+ /// a valid stream or NULL;
+ virtual FILE *GetStream();
/// Seek to an offset relative to the beginning of the file.
///
@@ -186,7 +173,7 @@ public:
///
/// \return
/// The resulting seek offset, or -1 on error.
- off_t SeekFromStart(off_t offset, Status *error_ptr = nullptr);
+ virtual off_t SeekFromStart(off_t offset, Status *error_ptr = nullptr);
/// Seek to an offset relative to the current file position.
///
@@ -206,7 +193,7 @@ public:
///
/// \return
/// The resulting seek offset, or -1 on error.
- off_t SeekFromCurrent(off_t offset, Status *error_ptr = nullptr);
+ virtual off_t SeekFromCurrent(off_t offset, Status *error_ptr = nullptr);
/// Seek to an offset relative to the end of the file.
///
@@ -227,7 +214,7 @@ public:
///
/// \return
/// The resulting seek offset, or -1 on error.
- off_t SeekFromEnd(off_t offset, Status *error_ptr = nullptr);
+ virtual off_t SeekFromEnd(off_t offset, Status *error_ptr = nullptr);
/// Read bytes from a file from the specified file offset.
///
@@ -250,37 +237,7 @@ public:
/// \return
/// An error object that indicates success or the reason for
/// failure.
- Status Read(void *dst, size_t &num_bytes, off_t &offset);
-
- /// Read bytes from a file from the specified file offset.
- ///
- /// NOTE: This function is thread safe in that clients manager their
- /// own file position markers and reads on other threads won't mess up the
- /// current read.
- ///
- /// \param[in,out] num_bytes
- /// The number of bytes to read form the current file position
- /// which gets modified with the number of bytes that were read.
- ///
- /// \param[in,out] offset
- /// The offset within the file from which to read \a num_bytes
- /// bytes. This offset gets incremented by the number of bytes
- /// that were read.
- ///
- /// \param[in] null_terminate
- /// Ensure that the data that is read is terminated with a NULL
- /// character so that the data can be used as a C string.
- ///
- /// \param[out] data_buffer_sp
- /// A data buffer to create and fill in that will contain any
- /// data that is read from the file. This buffer will be reset
- /// if an error occurs.
- ///
- /// \return
- /// An error object that indicates success or the reason for
- /// failure.
- Status Read(size_t &num_bytes, off_t &offset, bool null_terminate,
- lldb::DataBufferSP &data_buffer_sp);
+ virtual Status Read(void *dst, size_t &num_bytes, off_t &offset);
/// Write bytes to a file at the specified file offset.
///
@@ -305,21 +262,67 @@ public:
/// \return
/// An error object that indicates success or the reason for
/// failure.
- Status Write(const void *src, size_t &num_bytes, off_t &offset);
+ virtual Status Write(const void *src, size_t &num_bytes, off_t &offset);
/// Flush the current stream
///
/// \return
/// An error object that indicates success or the reason for
/// failure.
- Status Flush();
+ virtual Status Flush();
/// Sync to disk.
///
/// \return
/// An error object that indicates success or the reason for
/// failure.
- Status Sync();
+ virtual Status Sync();
+
+ /// Output printf formatted output to the stream.
+ ///
+ /// NOTE: this is not virtual, because it just calls the va_list
+ /// version of the function.
+ ///
+ /// Print some formatted output to the stream.
+ ///
+ /// \param[in] format
+ /// A printf style format string.
+ ///
+ /// \param[in] ...
+ /// Variable arguments that are needed for the printf style
+ /// format string \a format.
+ size_t Printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
+
+ /// Output printf formatted output to the stream.
+ ///
+ /// Print some formatted output to the stream.
+ ///
+ /// \param[in] format
+ /// A printf style format string.
+ ///
+ /// \param[in] args
+ /// Variable arguments that are needed for the printf style
+ /// format string \a format.
+ virtual size_t PrintfVarArg(const char *format, va_list args);
+
+ /// Return the OpenOptions for this file.
+ ///
+ /// Some options like eOpenOptionDontFollowSymlinks only make
+ /// sense when a file is being opened (or not at all)
+ /// and may not be preserved for this method. But any valid
+ /// File should return either or both of eOpenOptionRead and
+ /// eOpenOptionWrite here.
+ ///
+ /// \return
+ /// OpenOptions flags for this file, or an error.
+ virtual llvm::Expected<OpenOptions> GetOptions() const;
+
+ llvm::Expected<const char *> GetOpenMode() const {
+ auto opts = GetOptions();
+ if (!opts)
+ return opts.takeError();
+ return GetStreamOpenModeFromOptions(opts.get());
+ }
/// Get the permissions for a this file.
///
@@ -346,45 +349,90 @@ public:
/// a non-zero width and height, false otherwise.
bool GetIsRealTerminal();
- bool GetIsTerminalWithColors();
-
- /// Output printf formatted output to the stream.
- ///
- /// Print some formatted output to the stream.
+ /// Return true if this file is a terminal which supports colors.
///
- /// \param[in] format
- /// A printf style format string.
- ///
- /// \param[in] ...
- /// Variable arguments that are needed for the printf style
- /// format string \a format.
- size_t Printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
+ /// \return
+ /// True iff this is a terminal and it supports colors.
+ bool GetIsTerminalWithColors();
- size_t PrintfVarArg(const char *format, va_list args);
+ operator bool() const { return IsValid(); };
- void SetOptions(uint32_t options) { m_options = options; }
+ bool operator!() const { return !IsValid(); };
- static bool DescriptorIsValid(int descriptor) { return descriptor >= 0; };
+ static char ID;
+ virtual bool isA(const void *classID) const { return classID == &ID; }
+ static bool classof(const File *file) { return file->isA(&ID); }
protected:
- bool DescriptorIsValid() const { return DescriptorIsValid(m_descriptor); }
-
- bool StreamIsValid() const { return m_stream != kInvalidStream; }
+ LazyBool m_is_interactive;
+ LazyBool m_is_real_terminal;
+ LazyBool m_supports_colors;
void CalculateInteractiveAndTerminal();
+private:
+ DISALLOW_COPY_AND_ASSIGN(File);
+};
+
+class NativeFile : public File {
+public:
+ NativeFile()
+ : m_descriptor(kInvalidDescriptor), m_own_descriptor(false),
+ m_stream(kInvalidStream), m_options(), m_own_stream(false) {}
+
+ NativeFile(FILE *fh, bool transfer_ownership)
+ : m_descriptor(kInvalidDescriptor), m_own_descriptor(false), m_stream(fh),
+ m_options(), m_own_stream(transfer_ownership) {}
+
+ NativeFile(int fd, OpenOptions options, bool transfer_ownership)
+ : m_descriptor(fd), m_own_descriptor(transfer_ownership),
+ m_stream(kInvalidStream), m_options(options), m_own_stream(false) {}
+
+ ~NativeFile() override { Close(); }
+
+ bool IsValid() const override {
+ return DescriptorIsValid() || StreamIsValid();
+ }
+
+ Status Read(void *buf, size_t &num_bytes) override;
+ Status Write(const void *buf, size_t &num_bytes) override;
+ Status Close() override;
+ WaitableHandle GetWaitableHandle() override;
+ Status GetFileSpec(FileSpec &file_spec) const override;
+ int GetDescriptor() const override;
+ FILE *GetStream() override;
+ off_t SeekFromStart(off_t offset, Status *error_ptr = nullptr) override;
+ off_t SeekFromCurrent(off_t offset, Status *error_ptr = nullptr) override;
+ off_t SeekFromEnd(off_t offset, Status *error_ptr = nullptr) override;
+ Status Read(void *dst, size_t &num_bytes, off_t &offset) override;
+ Status Write(const void *src, size_t &num_bytes, off_t &offset) override;
+ Status Flush() override;
+ Status Sync() override;
+ size_t PrintfVarArg(const char *format, va_list args) override;
+ llvm::Expected<OpenOptions> GetOptions() const override;
+
+ static char ID;
+ virtual bool isA(const void *classID) const override {
+ return classID == &ID || File::isA(classID);
+ }
+ static bool classof(const File *file) { return file->isA(&ID); }
+
+protected:
+ bool DescriptorIsValid() const {
+ return File::DescriptorIsValid(m_descriptor);
+ }
+ bool StreamIsValid() const { return m_stream != kInvalidStream; }
+
// Member variables
int m_descriptor;
+ bool m_own_descriptor;
FILE *m_stream;
- uint32_t m_options;
+ OpenOptions m_options;
bool m_own_stream;
- LazyBool m_is_interactive;
- LazyBool m_is_real_terminal;
- LazyBool m_supports_colors;
std::mutex offset_access_mutex;
private:
- DISALLOW_COPY_AND_ASSIGN(File);
+ DISALLOW_COPY_AND_ASSIGN(NativeFile);
};
} // namespace lldb_private
diff --git a/include/lldb/Host/FileCache.h b/include/lldb/Host/FileCache.h
index 0c1ef1961645..c76916701ebb 100644
--- a/include/lldb/Host/FileCache.h
+++ b/include/lldb/Host/FileCache.h
@@ -14,6 +14,7 @@
#include "lldb/lldb-forward.h"
#include "lldb/lldb-types.h"
+#include "lldb/Host/File.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Status.h"
@@ -22,12 +23,12 @@ class FileCache {
private:
FileCache() {}
- typedef std::map<lldb::user_id_t, lldb::FileSP> FDToFileMap;
+ typedef std::map<lldb::user_id_t, lldb::FileUP> FDToFileMap;
public:
static FileCache &GetInstance();
- lldb::user_id_t OpenFile(const FileSpec &file_spec, uint32_t flags,
+ lldb::user_id_t OpenFile(const FileSpec &file_spec, File::OpenOptions flags,
uint32_t mode, Status &error);
bool CloseFile(lldb::user_id_t fd, Status &error);
diff --git a/include/lldb/Host/FileSystem.h b/include/lldb/Host/FileSystem.h
index 865b09b23103..528c43519a32 100644
--- a/include/lldb/Host/FileSystem.h
+++ b/include/lldb/Host/FileSystem.h
@@ -11,12 +11,12 @@
#include "lldb/Host/File.h"
#include "lldb/Utility/DataBufferLLVM.h"
-#include "lldb/Utility/FileCollector.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Status.h"
#include "llvm/ADT/Optional.h"
#include "llvm/Support/Chrono.h"
+#include "llvm/Support/FileCollector.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "lldb/lldb-types.h"
@@ -34,8 +34,8 @@ public:
FileSystem()
: m_fs(llvm::vfs::getRealFileSystem()), m_collector(nullptr),
m_mapped(false) {}
- FileSystem(FileCollector &collector)
- : m_fs(llvm::vfs::getRealFileSystem()), m_collector(&collector),
+ FileSystem(std::shared_ptr<llvm::FileCollector> collector)
+ : m_fs(llvm::vfs::getRealFileSystem()), m_collector(collector),
m_mapped(false) {}
FileSystem(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs,
bool mapped = false)
@@ -47,7 +47,7 @@ public:
static FileSystem &Instance();
static void Initialize();
- static void Initialize(FileCollector &collector);
+ static void Initialize(std::shared_ptr<llvm::FileCollector> collector);
static llvm::Error Initialize(const FileSpec &mapping);
static void Initialize(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs);
static void Terminate();
@@ -63,9 +63,10 @@ public:
/// Wraps ::open in a platform-independent way.
int Open(const char *path, int flags, int mode);
- Status Open(File &File, const FileSpec &file_spec, uint32_t options,
- uint32_t permissions = lldb::eFilePermissionsFileDefault,
- bool should_close_fd = true);
+ llvm::Expected<std::unique_ptr<File>>
+ Open(const FileSpec &file_spec, File::OpenOptions options,
+ uint32_t permissions = lldb::eFilePermissionsFileDefault,
+ bool should_close_fd = true);
/// Get a directory iterator.
/// \{
@@ -188,7 +189,7 @@ public:
private:
static llvm::Optional<FileSystem> &InstanceImpl();
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> m_fs;
- FileCollector *m_collector;
+ std::shared_ptr<llvm::FileCollector> m_collector;
bool m_mapped;
};
} // namespace lldb_private
diff --git a/include/lldb/Host/LZMA.h b/include/lldb/Host/LZMA.h
new file mode 100644
index 000000000000..c741cc3bbde1
--- /dev/null
+++ b/include/lldb/Host/LZMA.h
@@ -0,0 +1,34 @@
+//===-- LZMA.h --------------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_Host_LZMA_h_
+#define liblldb_Host_LZMA_h_
+
+#include "llvm/ADT/ArrayRef.h"
+
+namespace llvm {
+class Error;
+} // End of namespace llvm
+
+namespace lldb_private {
+
+namespace lzma {
+
+bool isAvailable();
+
+llvm::Expected<uint64_t>
+getUncompressedSize(llvm::ArrayRef<uint8_t> InputBuffer);
+
+llvm::Error uncompress(llvm::ArrayRef<uint8_t> InputBuffer,
+ llvm::SmallVectorImpl<uint8_t> &Uncompressed);
+
+} // End of namespace lzma
+
+} // End of namespace lldb_private
+
+#endif // liblldb_Host_LZMA_h_
diff --git a/include/lldb/Host/Socket.h b/include/lldb/Host/Socket.h
index 6f96bd73e753..c6df5634e24e 100644
--- a/include/lldb/Host/Socket.h
+++ b/include/lldb/Host/Socket.h
@@ -31,7 +31,7 @@ class StringRef;
namespace lldb_private {
-#if defined(_MSC_VER)
+#if defined(_WIN32)
typedef SOCKET NativeSocket;
#else
typedef int NativeSocket;
@@ -122,6 +122,7 @@ protected:
SocketProtocol m_protocol;
NativeSocket m_socket;
bool m_child_processes_inherit;
+ bool m_should_close_fd;
};
} // namespace lldb_private
diff --git a/include/lldb/Host/common/NativeProcessProtocol.h b/include/lldb/Host/common/NativeProcessProtocol.h
index f05b8d01a1c9..2d48717c4fbb 100644
--- a/include/lldb/Host/common/NativeProcessProtocol.h
+++ b/include/lldb/Host/common/NativeProcessProtocol.h
@@ -32,6 +32,14 @@ namespace lldb_private {
class MemoryRegionInfo;
class ResumeActionList;
+struct SVR4LibraryInfo {
+ std::string name;
+ lldb::addr_t link_map;
+ lldb::addr_t base_addr;
+ lldb::addr_t ld_addr;
+ lldb::addr_t next;
+};
+
// NativeProcessProtocol
class NativeProcessProtocol {
public:
@@ -76,6 +84,31 @@ public:
Status ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size,
size_t &bytes_read);
+ /// Reads a null terminated string from memory.
+ ///
+ /// Reads up to \p max_size bytes of memory until it finds a '\0'.
+ /// If a '\0' is not found then it reads max_size-1 bytes as a string and a
+ /// '\0' is added as the last character of the \p buffer.
+ ///
+ /// \param[in] addr
+ /// The address in memory to read from.
+ ///
+ /// \param[in] buffer
+ /// An allocated buffer with at least \p max_size size.
+ ///
+ /// \param[in] max_size
+ /// The maximum number of bytes to read from memory until it reads the
+ /// string.
+ ///
+ /// \param[out] total_bytes_read
+ /// The number of bytes read from memory into \p buffer.
+ ///
+ /// \return
+ /// Returns a StringRef backed up by the \p buffer passed in.
+ llvm::Expected<llvm::StringRef>
+ ReadCStringFromMemory(lldb::addr_t addr, char *buffer, size_t max_size,
+ size_t &total_bytes_read);
+
virtual Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size,
size_t &bytes_written) = 0;
@@ -86,6 +119,12 @@ public:
virtual lldb::addr_t GetSharedLibraryInfoAddress() = 0;
+ virtual llvm::Expected<std::vector<SVR4LibraryInfo>>
+ GetLoadedSVR4Libraries() {
+ return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Not implemented");
+ }
+
virtual bool IsAlive() const;
virtual size_t UpdateThreads() = 0;
@@ -391,6 +430,8 @@ protected:
NativeProcessProtocol(lldb::pid_t pid, int terminal_fd,
NativeDelegate &delegate);
+ void SetID(lldb::pid_t pid) { m_pid = pid; }
+
// interface for state handling
void SetState(lldb::StateType state, bool notify_delegates = true);