Convert mmap options for target in InferiorCallMmap.

Converts the MAP_PRIVATE and MAP_ANON options to the target platform constants
(on which the call runs) rather than using those of the compiled host.

Test Plan:
Run test suite, the following tests requiring memory allocation / JIT support
begin passing when running mac -> linux:
Test11588.py
TestAnonymous.py
TestBreakpointConditions.py
TestCPPStaticMethods.py
TestCStrings.py
TestCallStdStringFunction.py
TestDataFormatterCpp.py
TestDataFormatterStdList.py
TestExprDoesntBlock.py
TestExprHelpExamples.py
TestFunctionTypes.py
TestPrintfAfterUp.py
TestSBValuePersist.py
TestSetValues.py

Differential Revision: http://reviews.llvm.org/D9511

llvm-svn: 236933
This commit is contained in:
Robert Flack 2015-05-09 15:53:31 +00:00
parent 3e6070ef03
commit 96ad3de54b
6 changed files with 53 additions and 28 deletions

View File

@ -37,6 +37,11 @@ namespace lldb_private {
class ModuleCache;
enum MmapFlags {
eMmapFlagsPrivate = 1,
eMmapFlagsAnon = 2
};
class PlatformProperties : public Properties
{
public:
@ -745,6 +750,9 @@ class ModuleCache;
virtual Error
Unlink (const char *path);
virtual uint64_t
ConvertMmapFlagsToPlatform(unsigned flags);
virtual bool
GetSupportsRSync ()
{

View File

@ -14,6 +14,7 @@
// C Includes
#include <stdio.h>
#include <vector>
#ifndef LLDB_DISABLE_POSIX
#include <sys/utsname.h>
#endif
@ -42,6 +43,11 @@
#include "../../Process/Linux/NativeProcessLinux.h"
#endif
// Define these constants from Linux mman.h for use when targetting
// remote linux systems even when host has different values.
#define MAP_PRIVATE 2
#define MAP_ANON 0x20
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::platform_linux;
@ -492,22 +498,14 @@ PlatformLinux::FindProcesses (const ProcessInstanceInfoMatch &match_info,
bool
PlatformLinux::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
{
if (idx == 0)
{
arch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
return arch.IsValid();
}
else if (idx == 1)
{
// If the default host architecture is 64-bit, look for a 32-bit variant
ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
if (hostArch.IsValid() && hostArch.GetTriple().isArch64Bit())
{
arch = HostInfo::GetArchitecture(HostInfo::eArchKind32);
return arch.IsValid();
}
}
return false;
static std::vector<ArchSpec> architectures = {
ArchSpec("x86_64-unknown-linux-gnu"),
ArchSpec("i386-unknown-linux-gnu"),
};
if (idx >= architectures.size())
return false;
arch = architectures[idx];
return true;
}
void
@ -911,3 +909,14 @@ PlatformLinux::AttachNativeProcess (lldb::pid_t pid,
return process_linux::NativeProcessLinux::AttachToProcess (pid, native_delegate, process_sp);
#endif
}
uint64_t
PlatformLinux::ConvertMmapFlagsToPlatform(unsigned flags)
{
uint64_t flags_platform = 0;
if (flags & eMmapFlagsPrivate)
flags_platform |= MAP_PRIVATE;
if (flags & eMmapFlagsAnon)
flags_platform |= MAP_ANON;
return flags_platform;
}

View File

@ -119,6 +119,9 @@ namespace platform_linux {
NativeProcessProtocol::NativeDelegate &native_delegate,
NativeProcessProtocolSP &process_sp) override;
uint64_t
ConvertMmapFlagsToPlatform(unsigned flags) override;
static bool
UseLlgsForLocalDebugging ();

View File

@ -14,6 +14,7 @@
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadPlanCallFunction.h"
@ -27,8 +28,6 @@
#define PROT_READ 1
#define PROT_WRITE 2
#define PROT_EXEC 4
#define MAP_PRIVATE 2
#define MAP_ANON 0x1000
#endif
using namespace lldb;
@ -87,10 +86,7 @@ lldb_private::InferiorCallMmap (Process *process,
prot_arg |= PROT_WRITE;
}
if (flags & eMmapFlagsPrivate)
flags_arg |= MAP_PRIVATE;
if (flags & eMmapFlagsAnon)
flags_arg |= MAP_ANON;
flags_arg = process->GetTarget().GetPlatform()->ConvertMmapFlagsToPlatform(flags);
AddressRange mmap_range;
if (sc.GetAddressRange(range_scope, 0, use_inline_block_range, mmap_range))

View File

@ -25,11 +25,6 @@ enum MmapProt {
eMmapProtWrite = 4
};
enum MmapFlags {
eMmapFlagsPrivate = 1,
eMmapFlagsAnon = 2
};
bool InferiorCallMmap(Process *proc, lldb::addr_t &allocated_addr,
lldb::addr_t addr, lldb::addr_t length, unsigned prot,
unsigned flags, lldb::addr_t fd, lldb::addr_t offset);

View File

@ -40,6 +40,11 @@
#include "Utility/ModuleCache.h"
// Define these constants from POSIX mman.h rather than include the file
// so that they will be correct even when compiled on Linux.
#define MAP_PRIVATE 2
#define MAP_ANON 0x1000
using namespace lldb;
using namespace lldb_private;
@ -1480,7 +1485,16 @@ Platform::Unlink (const char *path)
return error;
}
uint64_t
Platform::ConvertMmapFlagsToPlatform(unsigned flags)
{
uint64_t flags_platform = 0;
if (flags & eMmapFlagsPrivate)
flags_platform |= MAP_PRIVATE;
if (flags & eMmapFlagsAnon)
flags_platform |= MAP_ANON;
return flags_platform;
}
lldb_private::Error
Platform::RunShellCommand (const char *command, // Shouldn't be NULL