aboutsummaryrefslogtreecommitdiff
path: root/include/lldb/Host/posix
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2015-02-06 21:38:51 +0000
committerEd Maste <emaste@FreeBSD.org>2015-02-06 21:38:51 +0000
commit205afe679855a4ce8149cdaa94d3f0868ce796dc (patch)
tree09bc83f73246ee3c7a779605cd0122093d2a8a19 /include/lldb/Host/posix
parent0cac4ca3916ac24ab6139d03cbfd18db9e715bfe (diff)
downloadsrc-205afe679855a4ce8149cdaa94d3f0868ce796dc.tar.gz
src-205afe679855a4ce8149cdaa94d3f0868ce796dc.zip
Import LLDB as of upstream SVN r225923 (git 2b588ecd)vendor/lldb/lldb-r225923
This corresponds with the branchpoint for the 3.6 release. A number of files not required for the FreeBSD build have been removed. Sponsored by: DARPA, AFRL
Notes
Notes: svn path=/vendor/lldb/dist/; revision=278332 svn path=/vendor/lldb/lldb-r225923/; revision=278333; tag=vendor/lldb/lldb-r225923
Diffstat (limited to 'include/lldb/Host/posix')
-rw-r--r--include/lldb/Host/posix/ConnectionFileDescriptorPosix.h108
-rw-r--r--include/lldb/Host/posix/HostInfoPosix.h3
-rw-r--r--include/lldb/Host/posix/HostProcessPosix.h26
-rw-r--r--include/lldb/Host/posix/HostThreadPosix.h34
-rw-r--r--include/lldb/Host/posix/PipePosix.h81
-rw-r--r--include/lldb/Host/posix/ProcessLauncherPosix.h25
6 files changed, 262 insertions, 15 deletions
diff --git a/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h b/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
new file mode 100644
index 000000000000..4d326d71fa75
--- /dev/null
+++ b/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
@@ -0,0 +1,108 @@
+//===-- ConnectionFileDescriptorPosix.h -------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_Host_posix_ConnectionFileDescriptorPosix_h_
+#define liblldb_Host_posix_ConnectionFileDescriptorPosix_h_
+
+// C++ Includes
+#include <atomic>
+#include <memory>
+
+#include "lldb/lldb-forward.h"
+
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/Connection.h"
+#include "lldb/Host/Mutex.h"
+#include "lldb/Host/Pipe.h"
+#include "lldb/Host/Predicate.h"
+#include "lldb/Host/IOObject.h"
+
+namespace lldb_private
+{
+
+class Error;
+class Socket;
+class SocketAddress;
+
+class ConnectionFileDescriptor : public Connection
+{
+ public:
+ ConnectionFileDescriptor(bool child_processes_inherit = false);
+
+ ConnectionFileDescriptor(int fd, bool owns_fd);
+
+ virtual ~ConnectionFileDescriptor();
+
+ virtual bool IsConnected() const;
+
+ virtual lldb::ConnectionStatus Connect(const char *s, Error *error_ptr);
+
+ virtual lldb::ConnectionStatus Disconnect(Error *error_ptr);
+
+ virtual size_t Read(void *dst, size_t dst_len, uint32_t timeout_usec, lldb::ConnectionStatus &status, Error *error_ptr);
+
+ virtual size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status, Error *error_ptr);
+
+ lldb::ConnectionStatus BytesAvailable(uint32_t timeout_usec, Error *error_ptr);
+
+ bool InterruptRead();
+
+ lldb::IOObjectSP
+ GetReadObject()
+ {
+ return m_read_sp;
+ }
+ const lldb::IOObjectSP
+ GetReadObject() const
+ {
+ return m_read_sp;
+ }
+
+ uint16_t GetListeningPort(uint32_t timeout_sec);
+
+ bool GetChildProcessesInherit() const;
+ void SetChildProcessesInherit(bool child_processes_inherit);
+
+ protected:
+ void OpenCommandPipe();
+
+ void CloseCommandPipe();
+
+ lldb::ConnectionStatus SocketListen(const char *host_and_port, Error *error_ptr);
+
+ lldb::ConnectionStatus ConnectTCP(const char *host_and_port, Error *error_ptr);
+
+ lldb::ConnectionStatus ConnectUDP(const char *args, Error *error_ptr);
+
+ lldb::ConnectionStatus NamedSocketConnect(const char *socket_name, Error *error_ptr);
+
+ lldb::ConnectionStatus NamedSocketAccept(const char *socket_name, Error *error_ptr);
+
+ lldb::IOObjectSP m_read_sp;
+ lldb::IOObjectSP m_write_sp;
+
+ Predicate<uint16_t> m_port_predicate; // Used when binding to port zero to wait for the thread
+ // that creates the socket, binds and listens to resolve
+ // the port number.
+
+ Pipe m_pipe;
+ Mutex m_mutex;
+ std::atomic<bool> m_shutting_down; // This marks that we are shutting down so if we get woken up from
+ // BytesAvailable to disconnect, we won't try to read again.
+ bool m_waiting_for_accept;
+ bool m_child_processes_inherit;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ConnectionFileDescriptor);
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_ConnectionFileDescriptor_h_
diff --git a/include/lldb/Host/posix/HostInfoPosix.h b/include/lldb/Host/posix/HostInfoPosix.h
index 6e0dcbe48021..9524a2a2481d 100644
--- a/include/lldb/Host/posix/HostInfoPosix.h
+++ b/include/lldb/Host/posix/HostInfoPosix.h
@@ -10,6 +10,7 @@
#ifndef lldb_Host_posix_HostInfoPosix_h_
#define lldb_Host_posix_HostInfoPosix_h_
+#include "lldb/Host/FileSpec.h"
#include "lldb/Host/HostInfoBase.h"
namespace lldb_private
@@ -30,6 +31,8 @@ class HostInfoPosix : public HostInfoBase
static uint32_t GetEffectiveUserID();
static uint32_t GetEffectiveGroupID();
+ static FileSpec GetDefaultShell();
+
protected:
static bool ComputeSupportExeDirectory(FileSpec &file_spec);
static bool ComputeHeaderDirectory(FileSpec &file_spec);
diff --git a/include/lldb/Host/posix/HostProcessPosix.h b/include/lldb/Host/posix/HostProcessPosix.h
index aa003ee4845e..8c1b0599e114 100644
--- a/include/lldb/Host/posix/HostProcessPosix.h
+++ b/include/lldb/Host/posix/HostProcessPosix.h
@@ -12,34 +12,30 @@
#include "lldb/lldb-types.h"
#include "lldb/Core/Error.h"
-#include "lldb/Target/ProcessLaunchInfo.h"
+#include "lldb/Host/HostNativeProcessBase.h"
namespace lldb_private
{
class FileSpec;
-class HostProcessPosix
+class HostProcessPosix : public HostNativeProcessBase
{
public:
- static const lldb::pid_t kInvalidProcessId;
-
HostProcessPosix();
- ~HostProcessPosix();
-
- Error Signal(int signo) const;
- static Error Signal(lldb::pid_t pid, int signo);
+ HostProcessPosix(lldb::process_t process);
+ virtual ~HostProcessPosix();
- Error Create(lldb::pid_t pid);
- Error Terminate(int signo);
- Error GetMainModule(FileSpec &file_spec) const;
+ virtual Error Signal(int signo) const;
+ static Error Signal(lldb::process_t process, int signo);
- lldb::pid_t GetProcessId() const;
- bool IsRunning() const;
+ virtual Error Terminate();
+ virtual Error GetMainModule(FileSpec &file_spec) const;
- private:
+ virtual lldb::pid_t GetProcessId() const;
+ virtual bool IsRunning() const;
- lldb::pid_t m_pid;
+ virtual HostThread StartMonitoring(HostProcess::MonitorCallback callback, void *callback_baton, bool monitor_signals);
};
}
diff --git a/include/lldb/Host/posix/HostThreadPosix.h b/include/lldb/Host/posix/HostThreadPosix.h
new file mode 100644
index 000000000000..e0eaedf73be2
--- /dev/null
+++ b/include/lldb/Host/posix/HostThreadPosix.h
@@ -0,0 +1,34 @@
+//===-- HostThreadPosix.h -------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef lldb_Host_posix_HostThreadPosix_h_
+#define lldb_Host_posix_HostThreadPosix_h_
+
+#include "lldb/Host/HostNativeThreadBase.h"
+
+namespace lldb_private
+{
+
+class HostThreadPosix : public HostNativeThreadBase
+{
+ DISALLOW_COPY_AND_ASSIGN(HostThreadPosix);
+
+ public:
+ HostThreadPosix();
+ HostThreadPosix(lldb::thread_t thread);
+ virtual ~HostThreadPosix();
+
+ virtual Error Join(lldb::thread_result_t *result);
+ virtual Error Cancel();
+
+ Error Detach();
+};
+}
+
+#endif
diff --git a/include/lldb/Host/posix/PipePosix.h b/include/lldb/Host/posix/PipePosix.h
new file mode 100644
index 000000000000..0ab3ff7f6775
--- /dev/null
+++ b/include/lldb/Host/posix/PipePosix.h
@@ -0,0 +1,81 @@
+//===-- PipePosix.h ---------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_Host_posix_PipePosix_h_
+#define liblldb_Host_posix_PipePosix_h_
+#if defined(__cplusplus)
+
+#include "lldb/Host/PipeBase.h"
+
+namespace lldb_private {
+
+//----------------------------------------------------------------------
+/// @class PipePosix PipePosix .h "lldb/Host/posix/PipePosix.h"
+/// @brief A posix-based implementation of Pipe, a class that abtracts
+/// unix style pipes.
+///
+/// A class that abstracts the LLDB core from host pipe functionality.
+//----------------------------------------------------------------------
+class PipePosix : public PipeBase
+{
+public:
+ static int kInvalidDescriptor;
+
+ PipePosix();
+
+ ~PipePosix() override;
+
+ Error
+ CreateNew(bool child_process_inherit) override;
+ Error
+ CreateNew(llvm::StringRef name, bool child_process_inherit) override;
+ Error
+ OpenAsReader(llvm::StringRef name, bool child_process_inherit) override;
+ Error
+ OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit, const std::chrono::microseconds &timeout) override;
+
+ bool
+ CanRead() const override;
+ bool
+ CanWrite() const override;
+
+ int
+ GetReadFileDescriptor() const override;
+ int
+ GetWriteFileDescriptor() const override;
+ int
+ ReleaseReadFileDescriptor() override;
+ int
+ ReleaseWriteFileDescriptor() override;
+
+ // Close both descriptors
+ void
+ Close() override;
+
+ Error
+ Delete(llvm::StringRef name) override;
+
+ Error
+ Write(const void *buf, size_t size, size_t &bytes_written) override;
+ Error
+ ReadWithTimeout(void *buf, size_t size, const std::chrono::microseconds &timeout, size_t &bytes_read) override;
+
+private:
+ void
+ CloseReadFileDescriptor();
+ void
+ CloseWriteFileDescriptor();
+
+ int m_fds[2];
+};
+
+} // namespace lldb_private
+
+#endif // #if defined(__cplusplus)
+#endif // liblldb_Host_posix_PipePosix_h_
diff --git a/include/lldb/Host/posix/ProcessLauncherPosix.h b/include/lldb/Host/posix/ProcessLauncherPosix.h
new file mode 100644
index 000000000000..c0e2a36e4e5e
--- /dev/null
+++ b/include/lldb/Host/posix/ProcessLauncherPosix.h
@@ -0,0 +1,25 @@
+//===-- ProcessLauncherPosix.h ----------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef lldb_Host_posix_ProcessLauncherPosix_h_
+#define lldb_Host_posix_ProcessLauncherPosix_h_
+
+#include "lldb/Host/ProcessLauncher.h"
+
+namespace lldb_private
+{
+
+class ProcessLauncherPosix : public ProcessLauncher
+{
+ public:
+ virtual HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info, Error &error);
+};
+}
+
+#endif