summaryrefslogtreecommitdiff
path: root/tools/lli/RemoteTargetExternal.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lli/RemoteTargetExternal.h')
-rw-r--r--tools/lli/RemoteTargetExternal.h51
1 files changed, 38 insertions, 13 deletions
diff --git a/tools/lli/RemoteTargetExternal.h b/tools/lli/RemoteTargetExternal.h
index 5ef67100e3..b332b19c0b 100644
--- a/tools/lli/RemoteTargetExternal.h
+++ b/tools/lli/RemoteTargetExternal.h
@@ -15,6 +15,7 @@
#ifndef LLI_REMOTETARGETEXTERNAL_H
#define LLI_REMOTETARGETEXTERNAL_H
+#include "RPCChannel.h"
#include "RemoteTarget.h"
#include "RemoteTargetMessage.h"
#include "llvm/ADT/SmallVector.h"
@@ -28,6 +29,28 @@
namespace llvm {
class RemoteTargetExternal : public RemoteTarget {
+ RPCChannel RPC;
+
+ bool WriteBytes(const void *Data, size_t Size) {
+ int rc = RPC.WriteBytes(Data, Size);
+ if (rc != -1 && (size_t)rc == Size)
+ return true;
+
+ ErrorMsg = "WriteBytes: ";
+ RPC.ReportError(rc, Size, ErrorMsg);
+ return false;
+ }
+
+ bool ReadBytes(void *Data, size_t Size) {
+ int rc = RPC.ReadBytes(Data, Size);
+ if (rc != -1 && (size_t)rc == Size)
+ return true;
+
+ ErrorMsg = "ReadBytes: ";
+ RPC.ReportError(rc, Size, ErrorMsg);
+ return false;
+ }
+
public:
/// Allocate space in the remote target address space.
///
@@ -79,17 +102,26 @@ public:
/// @returns Page alignment return value. Default of 4k.
virtual unsigned getPageAlignment() { return 4096; }
- /// Start the remote process.
- ///
- /// @returns True on success. On failure, ErrorMsg is updated with
- /// descriptive text of the encountered error.
- virtual bool create();
+ virtual bool create() {
+ RPC.ChildName = ChildName;
+ if (!RPC.createServer())
+ return true;
+
+ // We must get Ack from the client (blocking read)
+ if (!Receive(LLI_ChildActive)) {
+ ErrorMsg += ", (RPCChannel::create) - Stopping process!";
+ stop();
+ return false;
+ }
+
+ return true;
+ }
/// Terminate the remote process.
virtual void stop();
RemoteTargetExternal(std::string &Name) : RemoteTarget(), ChildName(Name) {}
- virtual ~RemoteTargetExternal();
+ virtual ~RemoteTargetExternal() {}
private:
std::string ChildName;
@@ -119,13 +151,6 @@ private:
SmallVector<int, 2> Sizes;
void AppendWrite(const void *Data, uint32_t Size);
void AppendRead(void *Data, uint32_t Size);
-
- // This will get filled in as a point to an OS-specific structure.
- void *ConnectionData;
-
- bool WriteBytes(const void *Data, size_t Size);
- bool ReadBytes(void *Data, size_t Size);
- void Wait();
};
} // end namespace llvm