Index: source/Plugins/Process/Utility/InferiorCallPOSIX.cpp =================================================================== --- source/Plugins/Process/Utility/InferiorCallPOSIX.cpp +++ source/Plugins/Process/Utility/InferiorCallPOSIX.cpp @@ -9,6 +9,7 @@ #include "InferiorCallPOSIX.h" #include "lldb/Core/Address.h" +#include "lldb/Core/ArchSpec.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/ValueObject.h" #include "lldb/Symbol/ClangASTContext.h" @@ -19,6 +20,8 @@ #include "lldb/Target/ThreadPlanCallFunction.h" #include "lldb/Host/Config.h" +#include "llvm/ADT/Triple.h" + #ifndef LLDB_DISABLE_POSIX #include #else @@ -27,13 +30,33 @@ #define PROT_READ 1 #define PROT_WRITE 2 #define PROT_EXEC 4 -#define MAP_PRIVATE 2 -#define MAP_ANON 0x1000 #endif using namespace lldb; using namespace lldb_private; +uint64_t ConvertMmapFlagsForTarget(unsigned flags, + const Target& target) +{ + uint64_t flags_arg = 0; + llvm::Triple target_triple = target.GetArchitecture().GetTriple(); + if (target_triple.isOSLinux()) + { + if (flags & eMmapFlagsPrivate) + flags_arg |= 2; + if (flags & eMmapFlagsAnon) + flags_arg |= 0x20; + } + else + { + if (flags & eMmapFlagsPrivate) + flags_arg |= 2; + if (flags & eMmapFlagsAnon) + flags_arg |= 0x1000; + } + return flags_arg; +} + bool lldb_private::InferiorCallMmap (Process *process, addr_t &allocated_addr, @@ -87,10 +110,7 @@ prot_arg |= PROT_WRITE; } - if (flags & eMmapFlagsPrivate) - flags_arg |= MAP_PRIVATE; - if (flags & eMmapFlagsAnon) - flags_arg |= MAP_ANON; + flags_arg = ConvertMmapFlagsForTarget(flags, process->GetTarget()); AddressRange mmap_range; if (sc.GetAddressRange(range_scope, 0, use_inline_block_range, mmap_range))