summaryrefslogtreecommitdiffstats
path: root/llvm/tools/lli/RemoteTargetExternal.h
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2014-01-23 22:19:45 +0000
committerAlp Toker <alp@nuanti.com>2014-01-23 22:19:45 +0000
commit632c6cd114e6ed06b141fbef4c161b60d41fac1b (patch)
treeb4395ecc0fb3ba68444c34c24c0846d293bca63d /llvm/tools/lli/RemoteTargetExternal.h
parent146b7b123001e185a76e143a8443b93b7c011c4e (diff)
downloadbcm5719-llvm-632c6cd114e6ed06b141fbef4c161b60d41fac1b.tar.gz
bcm5719-llvm-632c6cd114e6ed06b141fbef4c161b60d41fac1b.zip
lli: Factor portable messaging into a new RPCChannel facility
The client and server now use a single unified low-level RPC core built around LLVM's existing cross-platform abstractions. llvm-svn: 199947
Diffstat (limited to 'llvm/tools/lli/RemoteTargetExternal.h')
-rw-r--r--llvm/tools/lli/RemoteTargetExternal.h51
1 files changed, 38 insertions, 13 deletions
diff --git a/llvm/tools/lli/RemoteTargetExternal.h b/llvm/tools/lli/RemoteTargetExternal.h
index 5ef67100e36..b332b19c0b5 100644
--- a/llvm/tools/lli/RemoteTargetExternal.h
+++ b/llvm/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
OpenPOWER on IntegriCloud