#include "SubprocessMemory.h"
#include "Error.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FormatVariadic.h"
#include <cerrno>
#ifdef __linux__
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <unistd.h>
#endif
namespace llvm {
namespace exegesis {
#if defined(__linux__)
#ifndef SYS_gettid
#define SYS_gettid …
#endif
long SubprocessMemory::getCurrentTID() { … }
#if !defined(__ANDROID__)
Error SubprocessMemory::initializeSubprocessMemory(pid_t ProcessID) { … }
Error SubprocessMemory::addMemoryDefinition(
std::unordered_map<std::string, MemoryValue> MemoryDefinitions,
pid_t ProcessPID) { … }
Expected<int> SubprocessMemory::setupAuxiliaryMemoryInSubprocess(
std::unordered_map<std::string, MemoryValue> MemoryDefinitions,
pid_t ParentPID, long ParentTID, int CounterFileDescriptor) { … }
SubprocessMemory::~SubprocessMemory() { … }
#else
Error SubprocessMemory::initializeSubprocessMemory(pid_t ProcessPID) {
return make_error<Failure>(
"initializeSubprocessMemory is only supported on Linux");
}
Error SubprocessMemory::addMemoryDefinition(
std::unordered_map<std::string, MemoryValue> MemoryDefinitions,
pid_t ProcessPID) {
return make_error<Failure>("addMemoryDefinitions is only supported on Linux");
}
Expected<int> SubprocessMemory::setupAuxiliaryMemoryInSubprocess(
std::unordered_map<std::string, MemoryValue> MemoryDefinitions,
pid_t ParentPID, long ParentTID, int CounterFileDescriptor) {
return make_error<Failure>(
"setupAuxiliaryMemoryInSubprocess is only supported on Linux");
}
SubprocessMemory::~SubprocessMemory() {}
#endif
#endif
}
}