From owner-svn-src-all@freebsd.org Wed Aug 9 19:09:25 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8FDE8DD3A3D; Wed, 9 Aug 2017 19:09:25 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4543781879; Wed, 9 Aug 2017 19:09:25 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v79J9Owt053567; Wed, 9 Aug 2017 19:09:24 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v79J9N0U053557; Wed, 9 Aug 2017 19:09:23 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201708091909.v79J9N0U053557@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 9 Aug 2017 19:09:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322326 - in head/contrib/llvm/tools/lldb: include/lldb/Target source/Plugins/ABI/SysV-i386 source/Plugins/Platform/FreeBSD source/Plugins/Platform/NetBSD source/Plugins/Platform/OpenBS... X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: in head/contrib/llvm/tools/lldb: include/lldb/Target source/Plugins/ABI/SysV-i386 source/Plugins/Platform/FreeBSD source/Plugins/Platform/NetBSD source/Plugins/Platform/OpenBSD source/Plugins/Process/... X-SVN-Commit-Revision: 322326 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Aug 2017 19:09:25 -0000 Author: emaste Date: Wed Aug 9 19:09:23 2017 New Revision: 322326 URL: https://svnweb.freebsd.org/changeset/base/322326 Log: lldb: Make i386-*-freebsd expression work on JIT path * Enable i386 ABI creation for freebsd * Added an extra argument in ABISysV_i386::PrepareTrivialCall for mmap syscall * Unlike linux, the last argument of mmap is actually 64-bit(off_t). This requires us to push an additional word for the higher order bits. * Prior to this change, ktrace dump will show mmap failures due to invalid argument coming from the 6th mmap argument. Submitted by: Karnajit Wangkhem Differential Revision: https://reviews.llvm.org/D34776 Modified: head/contrib/llvm/tools/lldb/include/lldb/Target/Platform.h head/contrib/llvm/tools/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp head/contrib/llvm/tools/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp head/contrib/llvm/tools/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h head/contrib/llvm/tools/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp head/contrib/llvm/tools/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h head/contrib/llvm/tools/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp head/contrib/llvm/tools/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h head/contrib/llvm/tools/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp head/contrib/llvm/tools/lldb/source/Target/Platform.cpp Modified: head/contrib/llvm/tools/lldb/include/lldb/Target/Platform.h ============================================================================== --- head/contrib/llvm/tools/lldb/include/lldb/Target/Platform.h Wed Aug 9 18:23:46 2017 (r322325) +++ head/contrib/llvm/tools/lldb/include/lldb/Target/Platform.h Wed Aug 9 19:09:23 2017 (r322326) @@ -53,6 +53,7 @@ class PlatformProperties : public Properties { (public }; typedef std::shared_ptr PlatformPropertiesSP; +typedef llvm::SmallVector MmapArgList; //---------------------------------------------------------------------- /// @class Platform Platform.h "lldb/Target/Platform.h" @@ -628,8 +629,11 @@ class Platform : public PluginInterface { (public) virtual Status Unlink(const FileSpec &file_spec); - virtual uint64_t ConvertMmapFlagsToPlatform(const ArchSpec &arch, - unsigned flags); + virtual MmapArgList GetMmapArgumentList(const ArchSpec &arch, + lldb::addr_t addr, + lldb::addr_t length, + unsigned prot, unsigned flags, + lldb::addr_t fd, lldb::addr_t offset); virtual bool GetSupportsRSync() { return m_supports_rsync; } Modified: head/contrib/llvm/tools/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp ============================================================================== --- head/contrib/llvm/tools/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp Wed Aug 9 18:23:46 2017 (r322325) +++ head/contrib/llvm/tools/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp Wed Aug 9 19:09:23 2017 (r322326) @@ -206,7 +206,7 @@ ABISP ABISysV_i386::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) { static ABISP g_abi_sp; if ((arch.GetTriple().getArch() == llvm::Triple::x86) && - arch.GetTriple().isOSLinux()) { + (arch.GetTriple().isOSLinux() || arch.GetTriple().isOSFreeBSD())) { if (!g_abi_sp) g_abi_sp.reset(new ABISysV_i386(process_sp)); return g_abi_sp; Modified: head/contrib/llvm/tools/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp ============================================================================== --- head/contrib/llvm/tools/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp Wed Aug 9 18:23:46 2017 (r322325) +++ head/contrib/llvm/tools/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp Wed Aug 9 19:09:23 2017 (r322326) @@ -314,13 +314,19 @@ void PlatformFreeBSD::CalculateTrapHandlerSymbolNames( m_trap_handlers.push_back(ConstString("_sigtramp")); } -uint64_t PlatformFreeBSD::ConvertMmapFlagsToPlatform(const ArchSpec &arch, - unsigned flags) { +MmapArgList PlatformFreeBSD::GetMmapArgumentList(const ArchSpec &arch, + addr_t addr, addr_t length, + unsigned prot, unsigned flags, + addr_t fd, addr_t offset) { uint64_t flags_platform = 0; if (flags & eMmapFlagsPrivate) flags_platform |= MAP_PRIVATE; if (flags & eMmapFlagsAnon) flags_platform |= MAP_ANON; - return flags_platform; + + MmapArgList args({addr, length, prot, flags_platform, fd, offset}); + if (arch.GetTriple().getArch() == llvm::Triple::x86) + args.push_back(0); + return args; } Modified: head/contrib/llvm/tools/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h ============================================================================== --- head/contrib/llvm/tools/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h Wed Aug 9 18:23:46 2017 (r322325) +++ head/contrib/llvm/tools/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h Wed Aug 9 19:09:23 2017 (r322326) @@ -61,8 +61,10 @@ class PlatformFreeBSD : public PlatformPOSIX { (public void CalculateTrapHandlerSymbolNames() override; - uint64_t ConvertMmapFlagsToPlatform(const ArchSpec &arch, - unsigned flags) override; + MmapArgList GetMmapArgumentList(const ArchSpec &arch, lldb::addr_t addr, + lldb::addr_t length, unsigned prot, + unsigned flags, lldb::addr_t fd, + lldb::addr_t offset) override; private: DISALLOW_COPY_AND_ASSIGN(PlatformFreeBSD); Modified: head/contrib/llvm/tools/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp ============================================================================== --- head/contrib/llvm/tools/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp Wed Aug 9 18:23:46 2017 (r322325) +++ head/contrib/llvm/tools/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp Wed Aug 9 19:09:23 2017 (r322326) @@ -420,13 +420,17 @@ void PlatformNetBSD::CalculateTrapHandlerSymbolNames() m_trap_handlers.push_back(ConstString("_sigtramp")); } -uint64_t PlatformNetBSD::ConvertMmapFlagsToPlatform(const ArchSpec &arch, - unsigned flags) { +MmapArgList PlatformNetBSD::GetMmapArgumentList(const ArchSpec &arch, + addr_t addr, addr_t length, + unsigned prot, unsigned flags, + addr_t fd, addr_t offset) { uint64_t flags_platform = 0; if (flags & eMmapFlagsPrivate) flags_platform |= MAP_PRIVATE; if (flags & eMmapFlagsAnon) flags_platform |= MAP_ANON; - return flags_platform; + + MmapArgList args({addr, length, prot, flags_platform, fd, offset}); + return args; } Modified: head/contrib/llvm/tools/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h ============================================================================== --- head/contrib/llvm/tools/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h Wed Aug 9 18:23:46 2017 (r322325) +++ head/contrib/llvm/tools/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h Wed Aug 9 19:09:23 2017 (r322326) @@ -59,8 +59,10 @@ class PlatformNetBSD : public PlatformPOSIX { (public) void CalculateTrapHandlerSymbolNames() override; - uint64_t ConvertMmapFlagsToPlatform(const ArchSpec &arch, - unsigned flags) override; + MmapArgList GetMmapArgumentList(const ArchSpec &arch, lldb::addr_t addr, + lldb::addr_t length, unsigned prot, + unsigned flags, lldb::addr_t fd, + lldb::addr_t offset) override; private: DISALLOW_COPY_AND_ASSIGN(PlatformNetBSD); Modified: head/contrib/llvm/tools/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp ============================================================================== --- head/contrib/llvm/tools/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp Wed Aug 9 18:23:46 2017 (r322325) +++ head/contrib/llvm/tools/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp Wed Aug 9 19:09:23 2017 (r322326) @@ -219,5 +219,7 @@ uint64_t PlatformOpenBSD::ConvertMmapFlagsToPlatform(c flags_platform |= MAP_PRIVATE; if (flags & eMmapFlagsAnon) flags_platform |= MAP_ANON; - return flags_platform; + + MmapArgList args({addr, length, prot, flags_platform, fd, offset}); + return args; } Modified: head/contrib/llvm/tools/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h ============================================================================== --- head/contrib/llvm/tools/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h Wed Aug 9 18:23:46 2017 (r322325) +++ head/contrib/llvm/tools/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h Wed Aug 9 19:09:23 2017 (r322326) @@ -53,8 +53,10 @@ class PlatformOpenBSD : public PlatformPOSIX { (public void CalculateTrapHandlerSymbolNames() override; - uint64_t ConvertMmapFlagsToPlatform(const ArchSpec &arch, - unsigned flags) override; + MmapArgList GetMmapArgumentList(const ArchSpec &arch, lldb::addr_t addr, + lldb::addr_t length, unsigned prot, + unsigned flags, lldb::addr_t fd, + lldb::addr_t offset) override; private: DISALLOW_COPY_AND_ASSIGN(PlatformOpenBSD); Modified: head/contrib/llvm/tools/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp ============================================================================== --- head/contrib/llvm/tools/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp Wed Aug 9 18:23:46 2017 (r322325) +++ head/contrib/llvm/tools/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp Wed Aug 9 19:09:23 2017 (r322326) @@ -64,7 +64,7 @@ bool lldb_private::InferiorCallMmap(Process *process, options.SetTimeout(std::chrono::milliseconds(500)); options.SetTrapExceptions(false); - addr_t prot_arg, flags_arg = 0; + addr_t prot_arg; if (prot == eMmapProtNone) prot_arg = PROT_NONE; else { @@ -77,11 +77,6 @@ bool lldb_private::InferiorCallMmap(Process *process, prot_arg |= PROT_WRITE; } - const ArchSpec arch = process->GetTarget().GetArchitecture(); - flags_arg = - process->GetTarget().GetPlatform()->ConvertMmapFlagsToPlatform(arch, - flags); - AddressRange mmap_range; if (sc.GetAddressRange(range_scope, 0, use_inline_block_range, mmap_range)) { @@ -89,7 +84,10 @@ bool lldb_private::InferiorCallMmap(Process *process, process->GetTarget().GetScratchClangASTContext(); CompilerType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); - lldb::addr_t args[] = {addr, length, prot_arg, flags_arg, fd, offset}; + const ArchSpec arch = process->GetTarget().GetArchitecture(); + MmapArgList args = + process->GetTarget().GetPlatform()->GetMmapArgumentList( + arch, addr, length, prot_arg, flags, fd, offset); lldb::ThreadPlanSP call_plan_sp( new ThreadPlanCallFunction(*thread, mmap_range.GetBaseAddress(), clang_void_ptr_type, args, options)); Modified: head/contrib/llvm/tools/lldb/source/Target/Platform.cpp ============================================================================== --- head/contrib/llvm/tools/lldb/source/Target/Platform.cpp Wed Aug 9 18:23:46 2017 (r322325) +++ head/contrib/llvm/tools/lldb/source/Target/Platform.cpp Wed Aug 9 19:09:23 2017 (r322326) @@ -1316,14 +1316,18 @@ Status Platform::Unlink(const FileSpec &path) { return error; } -uint64_t Platform::ConvertMmapFlagsToPlatform(const ArchSpec &arch, - unsigned flags) { +MmapArgList Platform::GetMmapArgumentList(const ArchSpec &arch, addr_t addr, + addr_t length, unsigned prot, + unsigned flags, addr_t fd, + addr_t offset) { uint64_t flags_platform = 0; if (flags & eMmapFlagsPrivate) flags_platform |= MAP_PRIVATE; if (flags & eMmapFlagsAnon) flags_platform |= MAP_ANON; - return flags_platform; + + MmapArgList args({addr, length, prot, flags_platform, fd, offset}); + return args; } lldb_private::Status Platform::RunShellCommand(