Remove unused function parameter (NFC)
[oota-llvm.git] / tools / lli / RemoteTargetExternal.h
index 5ef67100e360f4f7cddab69d5a991385d79540a1..afe8570ff49fbf90c279f070ef3aa1681061eb96 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLI_REMOTETARGETEXTERNAL_H
-#define LLI_REMOTETARGETEXTERNAL_H
+#ifndef LLVM_TOOLS_LLI_REMOTETARGETEXTERNAL_H
+#define LLVM_TOOLS_LLI_REMOTETARGETEXTERNAL_H
 
+#include "RPCChannel.h"
 #include "RemoteTarget.h"
 #include "RemoteTargetMessage.h"
 #include "llvm/ADT/SmallVector.h"
 namespace llvm {
 
 class RemoteTargetExternal : public RemoteTarget {
+  RPCChannel RPC;
+
+  bool WriteBytes(const void *Data, size_t Size) {
+    return RPC.WriteBytes(Data, Size);
+  }
+
+  bool ReadBytes(void *Data, size_t Size) { return RPC.ReadBytes(Data, Size); }
+
 public:
   /// Allocate space in the remote target address space.
   ///
@@ -37,9 +46,8 @@ public:
   ///
   /// @returns True on success. On failure, ErrorMsg is updated with
   ///          descriptive text of the encountered error.
-  virtual bool allocateSpace(size_t Size,
-                             unsigned Alignment,
-                             uint64_t &Address);
+  bool allocateSpace(size_t Size, unsigned Alignment,
+                     uint64_t &Address) override;
 
   /// Load data into the target address space.
   ///
@@ -49,7 +57,7 @@ public:
   ///
   /// @returns True on success. On failure, ErrorMsg is updated with
   ///          descriptive text of the encountered error.
-  virtual bool loadData(uint64_t Address, const void *Data, size_t Size);
+  bool loadData(uint64_t Address, const void *Data, size_t Size) override;
 
   /// Load code into the target address space and prepare it for execution.
   ///
@@ -59,7 +67,7 @@ public:
   ///
   /// @returns True on success. On failure, ErrorMsg is updated with
   ///          descriptive text of the encountered error.
-  virtual bool loadCode(uint64_t Address, const void *Data, size_t Size);
+  bool loadCode(uint64_t Address, const void *Data, size_t Size) override;
 
   /// Execute code in the target process. The called function is required
   /// to be of signature int "(*)(void)".
@@ -70,26 +78,35 @@ public:
   ///
   /// @returns True on success. On failure, ErrorMsg is updated with
   ///          descriptive text of the encountered error.
-  virtual bool executeCode(uint64_t Address, int &RetVal);
+  bool executeCode(uint64_t Address, int &RetVal) override;
 
-  /// Minimum alignment for memory permissions. Used to seperate code and
+  /// Minimum alignment for memory permissions. Used to separate code and
   /// data regions to make sure data doesn't get marked as code or vice
   /// versa.
   ///
   /// @returns Page alignment return value. Default of 4k.
-  virtual unsigned getPageAlignment() { return 4096; }
+  unsigned getPageAlignment() override { 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();
+  bool create() override {
+    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();
+  void stop() override;
 
   RemoteTargetExternal(std::string &Name) : RemoteTarget(), ChildName(Name) {}
-  virtual ~RemoteTargetExternal();
+  ~RemoteTargetExternal() override {}
 
 private:
   std::string ChildName;
@@ -119,15 +136,8 @@ 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
 
-#endif // LLI_REMOTETARGETEXTERNAL_H
+#endif