[IRMemoryMap] Test host-side allocations

r333583 introduced testing for IRMemoryMap's process-side allocations
(eAllocationPolicyProcessOnly). This adds support for the host-side
variety (eAllocationPolicyHostOnly).

llvm-svn: 333698
This commit is contained in:
Vedant Kumar 2018-05-31 22:09:00 +00:00
parent 5b71e75ed3
commit f616b9db7d
2 changed files with 11 additions and 3 deletions

View File

@ -1,3 +1,5 @@
# RUN: %cxx %p/Inputs/call-function.cpp -g -o %t
# RUN: lldb-test ir-memory-map %t %S/Inputs/ir-memory-map-basic.test
# RUN: lldb-test ir-memory-map -host-only %t %S/Inputs/ir-memory-map-basic.test
# RUN: lldb-test ir-memory-map %t %S/Inputs/ir-memory-map-overlap1.test
# RUN: lldb-test ir-memory-map -host-only %t %S/Inputs/ir-memory-map-overlap1.test

View File

@ -159,6 +159,10 @@ static cl::opt<std::string> CommandFile(cl::Positional,
cl::desc("<command-file>"),
cl::init("-"),
cl::sub(IRMemoryMapSubcommand));
static cl::opt<bool> UseHostOnlyAllocationPolicy(
"host-only", cl::desc("Use the host-only allocation policy"),
cl::init(false), cl::sub(IRMemoryMapSubcommand));
using AllocationT = std::pair<addr_t, addr_t>;
bool areAllocationsOverlapping(const AllocationT &L, const AllocationT &R);
using AddrIntervalMap =
@ -521,14 +525,16 @@ bool opts::irmemorymap::evalMalloc(IRMemoryMap &IRMemMap, StringRef Line,
exit(1);
}
IRMemoryMap::AllocationPolicy AP =
UseHostOnlyAllocationPolicy ? IRMemoryMap::eAllocationPolicyHostOnly
: IRMemoryMap::eAllocationPolicyProcessOnly;
// Issue the malloc in the target process with "-rw" permissions.
const uint32_t Permissions = 0x3;
const bool ZeroMemory = false;
IRMemoryMap::AllocationPolicy Policy =
IRMemoryMap::eAllocationPolicyProcessOnly;
Status ST;
addr_t Addr =
IRMemMap.Malloc(Size, Alignment, Permissions, Policy, ZeroMemory, ST);
IRMemMap.Malloc(Size, Alignment, Permissions, AP, ZeroMemory, ST);
if (ST.Fail()) {
outs() << formatv("Malloc error: {0}\n", ST);
return true;