summaryrefslogtreecommitdiff
path: root/tools/lli/RemoteTargetExternal.h
diff options
context:
space:
mode:
authorRenato Golin <renato.golin@linaro.org>2014-01-14 22:43:43 +0000
committerRenato Golin <renato.golin@linaro.org>2014-01-14 22:43:43 +0000
commit83ece7a4993edb295e71841bd51b298219186c4c (patch)
tree396a100a569c18057afe5c1ed288cabf65a2c0c0 /tools/lli/RemoteTargetExternal.h
parent0445dc203b0e4001a153d9af4bd75f5242401d06 (diff)
downloadllvm-83ece7a4993edb295e71841bd51b298219186c4c.tar.gz
llvm-83ece7a4993edb295e71841bd51b298219186c4c.tar.bz2
llvm-83ece7a4993edb295e71841bd51b298219186c4c.tar.xz
Sanitize MCJIT remote execution
MCJIT remote execution (ChildTarget+RemoteTargetExternal) protocol was in dire need of refactoring. It was fail-prone, had no error reporting and implemented the same message logic on every single function. This patch rectifies it, and makes it work on ARM, where it was randomly failing. Other architectures shall profit from this change as well, making their buildbots and releases more reliable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199261 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lli/RemoteTargetExternal.h')
-rw-r--r--tools/lli/RemoteTargetExternal.h51
1 files changed, 34 insertions, 17 deletions
diff --git a/tools/lli/RemoteTargetExternal.h b/tools/lli/RemoteTargetExternal.h
index 63548eb52d..5ef67100e3 100644
--- a/tools/lli/RemoteTargetExternal.h
+++ b/tools/lli/RemoteTargetExternal.h
@@ -35,7 +35,7 @@ public:
/// @param Alignment Required minimum alignment for allocated space.
/// @param[out] Address Remote address of the allocated memory.
///
- /// @returns False on success. On failure, ErrorMsg is updated with
+ /// @returns True on success. On failure, ErrorMsg is updated with
/// descriptive text of the encountered error.
virtual bool allocateSpace(size_t Size,
unsigned Alignment,
@@ -47,7 +47,7 @@ public:
/// @param Data Source address in the host process.
/// @param Size Number of bytes to copy.
///
- /// @returns False on success. On failure, ErrorMsg is updated with
+ /// @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);
@@ -57,7 +57,7 @@ public:
/// @param Data Source address in the host process.
/// @param Size Number of bytes to copy.
///
- /// @returns False on success. On failure, ErrorMsg is updated with
+ /// @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);
@@ -68,7 +68,7 @@ public:
/// process.
/// @param[out] RetVal The integer return value of the called function.
///
- /// @returns False on success. On failure, ErrorMsg is updated with
+ /// @returns True on success. On failure, ErrorMsg is updated with
/// descriptive text of the encountered error.
virtual bool executeCode(uint64_t Address, int &RetVal);
@@ -80,7 +80,10 @@ public:
virtual unsigned getPageAlignment() { return 4096; }
/// Start the remote process.
- virtual void create();
+ ///
+ /// @returns True on success. On failure, ErrorMsg is updated with
+ /// descriptive text of the encountered error.
+ virtual bool create();
/// Terminate the remote process.
virtual void stop();
@@ -91,23 +94,37 @@ public:
private:
std::string ChildName;
- // This will get filled in as a point to an OS-specific structure.
- void *ConnectionData;
-
- void SendAllocateSpace(uint32_t Alignment, uint32_t Size);
- void SendLoadSection(uint64_t Addr,
+ bool SendAllocateSpace(uint32_t Alignment, uint32_t Size);
+ bool SendLoadSection(uint64_t Addr,
const void *Data,
uint32_t Size,
bool IsCode);
- void SendExecute(uint64_t Addr);
- void SendTerminate();
+ bool SendExecute(uint64_t Addr);
+ bool SendTerminate();
+
+ // High-level wrappers for receiving data
+ bool Receive(LLIMessageType Msg);
+ bool Receive(LLIMessageType Msg, int32_t &Data);
+ bool Receive(LLIMessageType Msg, uint64_t &Data);
+
+ // Lower level target-independent read/write to deal with errors
+ bool ReceiveHeader(LLIMessageType Msg);
+ bool ReceivePayload();
+ bool SendHeader(LLIMessageType Msg);
+ bool SendPayload();
+
+ // Functions to append/retrieve data from the payload
+ SmallVector<const void *, 2> SendData;
+ SmallVector<void *, 1> ReceiveData; // Future proof
+ SmallVector<int, 2> Sizes;
+ void AppendWrite(const void *Data, uint32_t Size);
+ void AppendRead(void *Data, uint32_t Size);
- void Receive(LLIMessageType Msg);
- void Receive(LLIMessageType Msg, int &Data);
- void Receive(LLIMessageType Msg, uint64_t &Data);
+ // This will get filled in as a point to an OS-specific structure.
+ void *ConnectionData;
- int WriteBytes(const void *Data, size_t Size);
- int ReadBytes(void *Data, size_t Size);
+ bool WriteBytes(const void *Data, size_t Size);
+ bool ReadBytes(void *Data, size_t Size);
void Wait();
};