diff options
author | Jim Grosbach <grosbach@apple.com> | 2012-09-05 16:50:34 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2012-09-05 16:50:34 +0000 |
commit | 706f03a35db7029b2dbd2925552eb0d0472dcbb4 (patch) | |
tree | bc8714e6adb6b8c664c4e48dbf8a04f7133d4632 /tools/lli/RecordingMemoryManager.cpp | |
parent | 998d3cca2937393d91b04d4d6105d9e67dd3b1b6 (diff) |
MCJIT: Add faux remote target execution to lli for the MCJIT.
Simulate a remote target address space by allocating a seperate chunk of
memory for the target and re-mapping section addresses to that prior to
execution. Later we'll want to have a truly remote process, but for now
this gets us closer to being able to test the remote target
functionality outside LLDB.
rdar://12157052
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163216 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lli/RecordingMemoryManager.cpp')
-rw-r--r-- | tools/lli/RecordingMemoryManager.cpp | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/tools/lli/RecordingMemoryManager.cpp b/tools/lli/RecordingMemoryManager.cpp new file mode 100644 index 0000000000..9e1cff5527 --- /dev/null +++ b/tools/lli/RecordingMemoryManager.cpp @@ -0,0 +1,87 @@ +//===- RecordingMemoryManager.cpp - Recording memory manager --------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This memory manager allocates local storage and keeps a record of each +// allocation. Iterators are provided for all data and code allocations. +// +//===----------------------------------------------------------------------===// + +#include "RecordingMemoryManager.h" +using namespace llvm; + +uint8_t *RecordingMemoryManager:: +allocateCodeSection(uintptr_t Size, unsigned Alignment, unsigned SectionID) { + // The recording memory manager is just a local copy of the remote target. + // The alignment requirement is just stored here for later use. Regular + // heap storage is sufficient here. + void *Addr = malloc(Size); + assert(Addr && "malloc() failure!"); + sys::MemoryBlock Block(Addr, Size); + AllocatedCodeMem.push_back(Allocation(Block, Alignment)); + return (uint8_t*)Addr; +} + +uint8_t *RecordingMemoryManager:: +allocateDataSection(uintptr_t Size, unsigned Alignment, unsigned SectionID) { + // The recording memory manager is just a local copy of the remote target. + // The alignment requirement is just stored here for later use. Regular + // heap storage is sufficient here. + void *Addr = malloc(Size); + assert(Addr && "malloc() failure!"); + sys::MemoryBlock Block(Addr, Size); + AllocatedDataMem.push_back(Allocation(Block, Alignment)); + return (uint8_t*)Addr; +} +void RecordingMemoryManager::setMemoryWritable() { llvm_unreachable("Unexpected!"); } +void RecordingMemoryManager::setMemoryExecutable() { llvm_unreachable("Unexpected!"); } +void RecordingMemoryManager::setPoisonMemory(bool poison) { llvm_unreachable("Unexpected!"); } +void RecordingMemoryManager::AllocateGOT() { llvm_unreachable("Unexpected!"); } +uint8_t *RecordingMemoryManager::getGOTBase() const { + llvm_unreachable("Unexpected!"); + return 0; +} +uint8_t *RecordingMemoryManager::startFunctionBody(const Function *F, uintptr_t &ActualSize){ + llvm_unreachable("Unexpected!"); + return 0; +} +uint8_t *RecordingMemoryManager::allocateStub(const GlobalValue* F, unsigned StubSize, + unsigned Alignment) { + llvm_unreachable("Unexpected!"); + return 0; +} +void RecordingMemoryManager::endFunctionBody(const Function *F, uint8_t *FunctionStart, + uint8_t *FunctionEnd) { + llvm_unreachable("Unexpected!"); +} +uint8_t *RecordingMemoryManager::allocateSpace(intptr_t Size, unsigned Alignment) { + llvm_unreachable("Unexpected!"); + return 0; +} +uint8_t *RecordingMemoryManager::allocateGlobal(uintptr_t Size, unsigned Alignment) { + llvm_unreachable("Unexpected!"); + return 0; +} +void RecordingMemoryManager::deallocateFunctionBody(void *Body) { + llvm_unreachable("Unexpected!"); +} +uint8_t* RecordingMemoryManager::startExceptionTable(const Function* F, uintptr_t &ActualSize) { + llvm_unreachable("Unexpected!"); + return 0; +} +void RecordingMemoryManager::endExceptionTable(const Function *F, uint8_t *TableStart, + uint8_t *TableEnd, uint8_t* FrameRegister) { + llvm_unreachable("Unexpected!"); +} +void RecordingMemoryManager::deallocateExceptionTable(void *ET) { + llvm_unreachable("Unexpected!"); +} +void *RecordingMemoryManager::getPointerToNamedFunction(const std::string &Name, + bool AbortOnFailure) { + return NULL; +} |