summaryrefslogtreecommitdiff
path: root/include/lldb/Host/common
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-12-30 11:55:28 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-12-30 11:55:28 +0000
commite81d9d49145e432d917eea3a70d2ae74dcad1d89 (patch)
tree9ed5e1a91f242e2cb5911577356e487a55c01b78 /include/lldb/Host/common
parent85d8ef8f1f0e0e063a8571944302be2d2026f823 (diff)
Notes
Diffstat (limited to 'include/lldb/Host/common')
-rw-r--r--include/lldb/Host/common/GetOptInc.h65
-rw-r--r--include/lldb/Host/common/NativeProcessProtocol.h17
-rw-r--r--include/lldb/Host/common/TCPSocket.h46
-rw-r--r--include/lldb/Host/common/UDPSocket.h35
4 files changed, 159 insertions, 4 deletions
diff --git a/include/lldb/Host/common/GetOptInc.h b/include/lldb/Host/common/GetOptInc.h
new file mode 100644
index 0000000000000..f79644017ca54
--- /dev/null
+++ b/include/lldb/Host/common/GetOptInc.h
@@ -0,0 +1,65 @@
+#pragma once
+
+#include "lldb/lldb-defines.h"
+
+#if defined(_MSC_VER)
+#define REPLACE_GETOPT
+#define REPLACE_GETOPT_LONG
+#endif
+#if defined(_MSC_VER) || defined(__NetBSD__)
+#define REPLACE_GETOPT_LONG_ONLY
+#endif
+
+#if defined(REPLACE_GETOPT)
+// from getopt.h
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
+
+// option structure
+struct option
+{
+ const char *name;
+ // has_arg can't be an enum because some compilers complain about
+ // type mismatches in all the code that assumes it is an int.
+ int has_arg;
+ int *flag;
+ int val;
+};
+
+int getopt( int argc, char * const argv[], const char *optstring );
+
+// from getopt.h
+extern char * optarg;
+extern int optind;
+extern int opterr;
+extern int optopt;
+
+// defined in unistd.h
+extern int optreset;
+#else
+# include <unistd.h>
+# include <getopt.h>
+#endif
+
+#if defined(REPLACE_GETOPT_LONG)
+int getopt_long
+(
+ int argc,
+ char * const *argv,
+ const char *optstring,
+ const struct option *longopts,
+ int *longindex
+);
+#endif
+
+#if defined(REPLACE_GETOPT_LONG_ONLY)
+int getopt_long_only
+(
+ int argc,
+ char * const *argv,
+ const char *optstring,
+ const struct option *longopts,
+ int *longindex
+);
+#endif
diff --git a/include/lldb/Host/common/NativeProcessProtocol.h b/include/lldb/Host/common/NativeProcessProtocol.h
index 4f0f3a962d321..7236bf6590428 100644
--- a/include/lldb/Host/common/NativeProcessProtocol.h
+++ b/include/lldb/Host/common/NativeProcessProtocol.h
@@ -16,6 +16,7 @@
#include "lldb/lldb-types.h"
#include "lldb/Core/Error.h"
#include "lldb/Host/Mutex.h"
+#include "lldb/Host/MainLoop.h"
#include "llvm/ADT/StringRef.h"
#include "NativeBreakpointList.h"
@@ -284,10 +285,6 @@ namespace lldb_private
bool
UnregisterNativeDelegate (NativeDelegate &native_delegate);
- // Called before termination of NativeProcessProtocol's instance.
- virtual void
- Terminate ();
-
virtual Error
GetLoadedModuleFileSpec(const char* module_path, FileSpec& file_spec) = 0;
@@ -307,6 +304,11 @@ namespace lldb_private
/// inferior. Must outlive the NativeProcessProtocol
/// instance.
///
+ /// @param[in] mainloop
+ /// The mainloop instance with which the process can register
+ /// callbacks. Must outlive the NativeProcessProtocol
+ /// instance.
+ ///
/// @param[out] process_sp
/// On successful return from the method, this parameter
/// contains the shared pointer to the
@@ -320,6 +322,7 @@ namespace lldb_private
static Error
Launch (ProcessLaunchInfo &launch_info,
NativeDelegate &native_delegate,
+ MainLoop &mainloop,
NativeProcessProtocolSP &process_sp);
//------------------------------------------------------------------
@@ -335,6 +338,11 @@ namespace lldb_private
/// inferior. Must outlive the NativeProcessProtocol
/// instance.
///
+ /// @param[in] mainloop
+ /// The mainloop instance with which the process can register
+ /// callbacks. Must outlive the NativeProcessProtocol
+ /// instance.
+ ///
/// @param[out] process_sp
/// On successful return from the method, this parameter
/// contains the shared pointer to the
@@ -348,6 +356,7 @@ namespace lldb_private
static Error
Attach (lldb::pid_t pid,
NativeDelegate &native_delegate,
+ MainLoop &mainloop,
NativeProcessProtocolSP &process_sp);
protected:
diff --git a/include/lldb/Host/common/TCPSocket.h b/include/lldb/Host/common/TCPSocket.h
new file mode 100644
index 0000000000000..0ffe9c87bfa40
--- /dev/null
+++ b/include/lldb/Host/common/TCPSocket.h
@@ -0,0 +1,46 @@
+//===-- TCPSocket.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_TCPSocket_h_
+#define liblldb_TCPSocket_h_
+
+#include "lldb/Host/Socket.h"
+
+namespace lldb_private
+{
+ class TCPSocket: public Socket
+ {
+ public:
+ TCPSocket(NativeSocket socket, bool should_close);
+ TCPSocket(bool child_processes_inherit, Error &error);
+
+ // returns port number or 0 if error
+ uint16_t GetLocalPortNumber () const;
+
+ // returns ip address string or empty string if error
+ std::string GetLocalIPAddress () const;
+
+ // must be connected
+ // returns port number or 0 if error
+ uint16_t GetRemotePortNumber () const;
+
+ // must be connected
+ // returns ip address string or empty string if error
+ std::string GetRemoteIPAddress () const;
+
+ int SetOptionNoDelay();
+ int SetOptionReuseAddress();
+
+ Error Connect(llvm::StringRef name) override;
+ Error Listen(llvm::StringRef name, int backlog) override;
+ Error Accept(llvm::StringRef name, bool child_processes_inherit, Socket *&conn_socket) override;
+ };
+}
+
+#endif // ifndef liblldb_TCPSocket_h_
diff --git a/include/lldb/Host/common/UDPSocket.h b/include/lldb/Host/common/UDPSocket.h
new file mode 100644
index 0000000000000..afc1ec7196269
--- /dev/null
+++ b/include/lldb/Host/common/UDPSocket.h
@@ -0,0 +1,35 @@
+//===-- UDPSocket.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_UDPSocket_h_
+#define liblldb_UDPSocket_h_
+
+#include "lldb/Host/Socket.h"
+
+namespace lldb_private
+{
+ class UDPSocket: public Socket
+ {
+ public:
+ UDPSocket(bool child_processes_inherit, Error &error);
+
+ static Error Connect(llvm::StringRef name, bool child_processes_inherit, Socket *&send_socket, Socket *&recv_socket);
+ private:
+ UDPSocket(NativeSocket socket);
+
+ size_t Send(const void *buf, const size_t num_bytes) override;
+ Error Connect(llvm::StringRef name) override;
+ Error Listen(llvm::StringRef name, int backlog) override;
+ Error Accept(llvm::StringRef name, bool child_processes_inherit, Socket *&socket) override;
+
+ SocketAddress m_send_sockaddr;
+ };
+}
+
+#endif // ifndef liblldb_UDPSocket_h_