ChildTarget.cpp revision 36b56886974eae4f9c5ebc96befd3e7bfe5de338
10ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor#include "llvm/Config/config.h" 236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#include "../RPCChannel.h" 336b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#include "../RemoteTarget.h" 40ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor#include "../RemoteTargetMessage.h" 536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#include "llvm/Support/Memory.h" 60ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor#include <assert.h> 70ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor#include <map> 80ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor#include <stdint.h> 90ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor#include <string> 100ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor#include <vector> 110ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 120ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylorusing namespace llvm; 130ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 140ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylorclass LLIChildTarget { 150ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylorpublic: 160ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor void initialize(); 170ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor LLIMessageType waitForIncomingMessage(); 180ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor void handleMessage(LLIMessageType messageType); 1936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines RemoteTarget *RT; 2036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines RPCChannel RPC; 210ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 220ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylorprivate: 230ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Incoming message handlers 240ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor void handleAllocateSpace(); 250ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor void handleLoadSection(bool IsCode); 260ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor void handleExecute(); 270ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 280ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Outgoing message handlers 290ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor void sendChildActive(); 300ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor void sendAllocationResult(uint64_t Addr); 3136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines void sendLoadStatus(uint32_t Status); 3236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines void sendExecutionComplete(int Result); 330ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 340ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // OS-specific functions 350ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor void initializeConnection(); 3636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines int WriteBytes(const void *Data, size_t Size) { 3736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines return RPC.WriteBytes(Data, Size) ? Size : -1; 3836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines } 3936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines int ReadBytes(void *Data, size_t Size) { 4036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines return RPC.ReadBytes(Data, Size) ? Size : -1; 4136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines } 420ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 430ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Communication handles (OS-specific) 440ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor void *ConnectionData; 450ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor}; 460ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 470ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylorint main() { 480ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor LLIChildTarget ThisChild; 4936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines ThisChild.RT = new RemoteTarget(); 500ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor ThisChild.initialize(); 510ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor LLIMessageType MsgType; 520ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor do { 530ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor MsgType = ThisChild.waitForIncomingMessage(); 540ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor ThisChild.handleMessage(MsgType); 550ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor } while (MsgType != LLI_Terminate && 560ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor MsgType != LLI_Error); 5736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines delete ThisChild.RT; 580ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor return 0; 590ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor} 600ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 610ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor// Public methods 620ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylorvoid LLIChildTarget::initialize() { 6336b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines RPC.createClient(); 640ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor sendChildActive(); 650ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor} 660ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 670ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew KaylorLLIMessageType LLIChildTarget::waitForIncomingMessage() { 680ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor int32_t MsgType = -1; 690ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor if (ReadBytes(&MsgType, 4) > 0) 700ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor return (LLIMessageType)MsgType; 710ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor return LLI_Error; 720ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor} 730ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 740ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylorvoid LLIChildTarget::handleMessage(LLIMessageType messageType) { 750ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor switch (messageType) { 760ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor case LLI_AllocateSpace: 770ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor handleAllocateSpace(); 780ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor break; 790ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor case LLI_LoadCodeSection: 800ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor handleLoadSection(true); 810ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor break; 820ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor case LLI_LoadDataSection: 830ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor handleLoadSection(false); 840ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor break; 850ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor case LLI_Execute: 860ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor handleExecute(); 870ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor break; 880ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor case LLI_Terminate: 8936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines RT->stop(); 900ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor break; 910ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor default: 920ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // FIXME: Handle error! 930ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor break; 940ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor } 950ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor} 960ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 970ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor// Incoming message handlers 980ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylorvoid LLIChildTarget::handleAllocateSpace() { 990ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Read and verify the message data size. 1000ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor uint32_t DataSize; 1010ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor int rc = ReadBytes(&DataSize, 4); 10236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines (void)rc; 1030ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor assert(rc == 4); 1040ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor assert(DataSize == 8); 1050ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 1060ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Read the message arguments. 1070ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor uint32_t Alignment; 1080ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor uint32_t AllocSize; 1090ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor rc = ReadBytes(&Alignment, 4); 1100ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor assert(rc == 4); 1110ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor rc = ReadBytes(&AllocSize, 4); 1120ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor assert(rc == 4); 1130ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 1140ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Allocate the memory. 11536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines uint64_t Addr; 11636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines RT->allocateSpace(AllocSize, Alignment, Addr); 1170ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 1180ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Send AllocationResult message. 1190ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor sendAllocationResult(Addr); 1200ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor} 1210ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 1220ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylorvoid LLIChildTarget::handleLoadSection(bool IsCode) { 1230ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Read the message data size. 1240ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor uint32_t DataSize; 1250ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor int rc = ReadBytes(&DataSize, 4); 12636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines (void)rc; 1270ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor assert(rc == 4); 1280ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 1290ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Read the target load address. 1300ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor uint64_t Addr; 1310ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor rc = ReadBytes(&Addr, 8); 1320ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor assert(rc == 8); 1330ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor size_t BufferSize = DataSize - 8; 1340ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 13536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines if (!RT->isAllocatedMemory(Addr, BufferSize)) 13636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines return sendLoadStatus(LLI_Status_NotAllocated); 1370ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 1380ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Read section data into previously allocated buffer 13936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines rc = ReadBytes((void*)Addr, BufferSize); 14036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines if (rc != (int)(BufferSize)) 14136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines return sendLoadStatus(LLI_Status_IncompleteMsg); 1420ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 1430ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // If IsCode, mark memory executable 1440ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor if (IsCode) 14536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines sys::Memory::InvalidateInstructionCache((void *)Addr, BufferSize); 1460ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 1470ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Send MarkLoadComplete message. 14836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines sendLoadStatus(LLI_Status_Success); 1490ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor} 1500ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 1510ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylorvoid LLIChildTarget::handleExecute() { 1520ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Read the message data size. 1530ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor uint32_t DataSize; 1540ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor int rc = ReadBytes(&DataSize, 4); 15536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines (void)rc; 1560ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor assert(rc == 4); 1570ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor assert(DataSize == 8); 1580ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 1590ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Read the target address. 1600ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor uint64_t Addr; 1610ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor rc = ReadBytes(&Addr, 8); 1620ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor assert(rc == 8); 1630ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 1640ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Call function 16536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines int32_t Result = -1; 16636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines RT->executeCode(Addr, Result); 1670ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 1680ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Send ExecutionResult message. 16936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines sendExecutionComplete(Result); 1700ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor} 1710ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 1720ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor// Outgoing message handlers 1730ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylorvoid LLIChildTarget::sendChildActive() { 1740ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Write the message type. 1750ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor uint32_t MsgType = (uint32_t)LLI_ChildActive; 1760ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor int rc = WriteBytes(&MsgType, 4); 17736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines (void)rc; 1780ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor assert(rc == 4); 1790ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 1800ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Write the data size. 1810ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor uint32_t DataSize = 0; 1820ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor rc = WriteBytes(&DataSize, 4); 1830ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor assert(rc == 4); 1840ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor} 1850ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 1860ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylorvoid LLIChildTarget::sendAllocationResult(uint64_t Addr) { 1870ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Write the message type. 1880ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor uint32_t MsgType = (uint32_t)LLI_AllocationResult; 1890ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor int rc = WriteBytes(&MsgType, 4); 19036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines (void)rc; 1910ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor assert(rc == 4); 1920ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 1930ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Write the data size. 1940ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor uint32_t DataSize = 8; 1950ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor rc = WriteBytes(&DataSize, 4); 1960ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor assert(rc == 4); 1970ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 1980ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Write the allocated address. 1990ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor rc = WriteBytes(&Addr, 8); 2000ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor assert(rc == 8); 2010ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor} 2020ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 20336b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hinesvoid LLIChildTarget::sendLoadStatus(uint32_t Status) { 2040ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Write the message type. 20536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines uint32_t MsgType = (uint32_t)LLI_LoadResult; 2060ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor int rc = WriteBytes(&MsgType, 4); 20736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines (void)rc; 2080ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor assert(rc == 4); 2090ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 2100ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Write the data size. 21136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines uint32_t DataSize = 4; 2120ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor rc = WriteBytes(&DataSize, 4); 2130ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor assert(rc == 4); 21436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines 21536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines // Write the result. 21636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines rc = WriteBytes(&Status, 4); 21736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines assert(rc == 4); 2180ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor} 2190ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 22036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hinesvoid LLIChildTarget::sendExecutionComplete(int Result) { 2210ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Write the message type. 2220ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor uint32_t MsgType = (uint32_t)LLI_ExecutionResult; 2230ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor int rc = WriteBytes(&MsgType, 4); 22436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines (void)rc; 2250ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor assert(rc == 4); 2260ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 2270ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 2280ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Write the data size. 22936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines uint32_t DataSize = 4; 2300ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor rc = WriteBytes(&DataSize, 4); 2310ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor assert(rc == 4); 2320ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 2330ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor // Write the result. 23436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines rc = WriteBytes(&Result, 4); 23536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines assert(rc == 4); 2360ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor} 2370ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 2380ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor#ifdef LLVM_ON_UNIX 23936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#include "../Unix/RPCChannel.inc" 2400ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor#endif 2410ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor 2420ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor#ifdef LLVM_ON_WIN32 24336b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#include "../Windows/RPCChannel.inc" 2440ab5c6c16b1b09d76c3ba2d70443b10bcc26169cAndrew Kaylor#endif 245