1//===- RecordingMemoryManager.cpp - Recording memory manager --------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This memory manager allocates local storage and keeps a record of each
11// allocation. Iterators are provided for all data and code allocations.
12//
13//===----------------------------------------------------------------------===//
14
15#include "RecordingMemoryManager.h"
16using namespace llvm;
17
18uint8_t *RecordingMemoryManager::
19allocateCodeSection(uintptr_t Size, unsigned Alignment, unsigned SectionID) {
20  // The recording memory manager is just a local copy of the remote target.
21  // The alignment requirement is just stored here for later use. Regular
22  // heap storage is sufficient here.
23  void *Addr = malloc(Size);
24  assert(Addr && "malloc() failure!");
25  sys::MemoryBlock Block(Addr, Size);
26  AllocatedCodeMem.push_back(Allocation(Block, Alignment));
27  return (uint8_t*)Addr;
28}
29
30uint8_t *RecordingMemoryManager::
31allocateDataSection(uintptr_t Size, unsigned Alignment, unsigned SectionID) {
32  // The recording memory manager is just a local copy of the remote target.
33  // The alignment requirement is just stored here for later use. Regular
34  // heap storage is sufficient here.
35  void *Addr = malloc(Size);
36  assert(Addr && "malloc() failure!");
37  sys::MemoryBlock Block(Addr, Size);
38  AllocatedDataMem.push_back(Allocation(Block, Alignment));
39  return (uint8_t*)Addr;
40}
41void RecordingMemoryManager::setMemoryWritable() { llvm_unreachable("Unexpected!"); }
42void RecordingMemoryManager::setMemoryExecutable() { llvm_unreachable("Unexpected!"); }
43void RecordingMemoryManager::setPoisonMemory(bool poison) { llvm_unreachable("Unexpected!"); }
44void RecordingMemoryManager::AllocateGOT() { llvm_unreachable("Unexpected!"); }
45uint8_t *RecordingMemoryManager::getGOTBase() const {
46  llvm_unreachable("Unexpected!");
47  return 0;
48}
49uint8_t *RecordingMemoryManager::startFunctionBody(const Function *F, uintptr_t &ActualSize){
50  llvm_unreachable("Unexpected!");
51  return 0;
52}
53uint8_t *RecordingMemoryManager::allocateStub(const GlobalValue* F, unsigned StubSize,
54                                              unsigned Alignment) {
55  llvm_unreachable("Unexpected!");
56  return 0;
57}
58void RecordingMemoryManager::endFunctionBody(const Function *F, uint8_t *FunctionStart,
59                                             uint8_t *FunctionEnd) {
60  llvm_unreachable("Unexpected!");
61}
62uint8_t *RecordingMemoryManager::allocateSpace(intptr_t Size, unsigned Alignment) {
63  llvm_unreachable("Unexpected!");
64  return 0;
65}
66uint8_t *RecordingMemoryManager::allocateGlobal(uintptr_t Size, unsigned Alignment) {
67  llvm_unreachable("Unexpected!");
68  return 0;
69}
70void RecordingMemoryManager::deallocateFunctionBody(void *Body) {
71  llvm_unreachable("Unexpected!");
72}
73uint8_t* RecordingMemoryManager::startExceptionTable(const Function* F, uintptr_t &ActualSize) {
74  llvm_unreachable("Unexpected!");
75  return 0;
76}
77void RecordingMemoryManager::endExceptionTable(const Function *F, uint8_t *TableStart,
78                                               uint8_t *TableEnd, uint8_t* FrameRegister) {
79  llvm_unreachable("Unexpected!");
80}
81void RecordingMemoryManager::deallocateExceptionTable(void *ET) {
82  llvm_unreachable("Unexpected!");
83}
84void *RecordingMemoryManager::getPointerToNamedFunction(const std::string &Name,
85                                                        bool AbortOnFailure) {
86  return NULL;
87}
88