[Lldb-commits] [lldb] [lldb][AIX] HostInfoAIX Support (PR #117906)
DhruvSrivastavaX wrote: Since the common changes have been moved to HostInfoPosix via this PR: - https://github.com/llvm/llvm-project/pull/119694 I have updated HostInfoAIX accordingly. Still it is a copy of the remaining HostInfoLinux, so please let me know your comments. https://github.com/llvm/llvm-project/pull/117906 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix address to read segment data (PR #120655)
https://github.com/GeorgeHuyubo updated https://github.com/llvm/llvm-project/pull/120655 >From 896ec79db0b59f9a98fcfd06f6e3a5c7f2946a87 Mon Sep 17 00:00:00 2001 From: George Hu Date: Thu, 19 Dec 2024 15:38:12 -0800 Subject: [PATCH] [lldb] Fix address to read segment data --- lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp index b3916cc913f7db..5f85f99ce7bddc 100644 --- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp +++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp @@ -1031,6 +1031,8 @@ UUID ProcessElfCore::FindBuidIdInCoreMemory(lldb::addr_t address) { std::vector ph_bytes; ph_bytes.resize(elf_header.e_phentsize); + lldb::addr_t base_addr = 0; + bool found_first_load_segment = false; for (unsigned int i = 0; i < elf_header.e_phnum; ++i) { byte_read = ReadMemory(ph_addr + i * elf_header.e_phentsize, ph_bytes.data(), elf_header.e_phentsize, error); @@ -1041,6 +1043,11 @@ UUID ProcessElfCore::FindBuidIdInCoreMemory(lldb::addr_t address) { offset = 0; elf::ELFProgramHeader program_header; program_header.Parse(program_header_data, &offset); +if (program_header.p_type == llvm::ELF::PT_LOAD && +!found_first_load_segment) { + base_addr = program_header.p_vaddr; + found_first_load_segment = true; +} if (program_header.p_type != llvm::ELF::PT_NOTE) continue; @@ -1049,7 +1056,7 @@ UUID ProcessElfCore::FindBuidIdInCoreMemory(lldb::addr_t address) { // We need to slide the address of the p_vaddr as these values don't get // relocated in memory. -const lldb::addr_t vaddr = program_header.p_vaddr + address; +const lldb::addr_t vaddr = program_header.p_vaddr + address - base_addr; byte_read = ReadMemory(vaddr, note_bytes.data(), program_header.p_memsz, error); if (byte_read != program_header.p_memsz) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix address to read segment data (PR #120655)
GeorgeHuyubo wrote: > > Updated the commit to address @labath's comment. > > Can you explain how you did that? The new implementation does something > completely different (and wrong on several levels) from the one I pointed you > to. > [Here](https://android.googlesource.com/platform/bionic/+/android-4.2_r1/linker/linker_phdr.c#34) > is a description of elf loading from a linker POV that might be helpful. Hope I got this right this time. Now it's trying to find the p_vaddr of the first PT_LOAD segment as the base_addr. And then subtract this base_addr from the vaddr I am trying to read from. https://github.com/llvm/llvm-project/pull/120655 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] HostInfoAIX Support (PR #117906)
https://github.com/DhruvSrivastavaX updated https://github.com/llvm/llvm-project/pull/117906 >From d05de47c87362b54760f65c294c30c80b2d5bc9b Mon Sep 17 00:00:00 2001 From: Dhruv-Srivastava Date: Wed, 27 Nov 2024 10:10:32 -0600 Subject: [PATCH 1/2] HostInfoAIX --- lldb/include/lldb/Host/aix/HostInfoAIX.h | 43 + lldb/source/Host/CMakeLists.txt | 5 + lldb/source/Host/aix/HostInfoAIX.cpp | 213 +++ 3 files changed, 261 insertions(+) create mode 100644 lldb/include/lldb/Host/aix/HostInfoAIX.h create mode 100644 lldb/source/Host/aix/HostInfoAIX.cpp diff --git a/lldb/include/lldb/Host/aix/HostInfoAIX.h b/lldb/include/lldb/Host/aix/HostInfoAIX.h new file mode 100644 index 00..c797b36f3dcc8d --- /dev/null +++ b/lldb/include/lldb/Host/aix/HostInfoAIX.h @@ -0,0 +1,43 @@ +//===-- HostInfoAIX.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_HOST_AIX_HOSTINFOAIX_H_ +#define LLDB_HOST_AIX_HOSTINFOAIX_H_ + +#include "lldb/Host/posix/HostInfoPosix.h" +#include "lldb/Utility/FileSpec.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/VersionTuple.h" + +#include +#include + +namespace lldb_private { + +class HostInfoAIX : public HostInfoPosix { + friend class HostInfoBase; + +public: + static void Initialize(SharedLibraryDirectoryHelper *helper = nullptr); + static void Terminate(); + + static llvm::VersionTuple GetOSVersion(); + static std::optional GetOSBuildString(); + static llvm::StringRef GetDistributionId(); + static FileSpec GetProgramFileSpec(); + +protected: + static bool ComputeSupportExeDirectory(FileSpec &file_spec); + static bool ComputeSystemPluginsDirectory(FileSpec &file_spec); + static bool ComputeUserPluginsDirectory(FileSpec &file_spec); + static void ComputeHostArchitectureSupport(ArchSpec &arch_32, + ArchSpec &arch_64); +}; +} // namespace lldb_private + +#endif // LLDB_HOST_AIX_HOSTINFOAIX_H_ diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt index c2e091ee8555b7..e0cd8569bf9575 100644 --- a/lldb/source/Host/CMakeLists.txt +++ b/lldb/source/Host/CMakeLists.txt @@ -133,6 +133,11 @@ else() openbsd/Host.cpp openbsd/HostInfoOpenBSD.cpp ) + + elseif (CMAKE_SYSTEM_NAME MATCHES "AIX") +add_host_subdirectory(aix + aix/HostInfoAIX.cpp + ) endif() endif() diff --git a/lldb/source/Host/aix/HostInfoAIX.cpp b/lldb/source/Host/aix/HostInfoAIX.cpp new file mode 100644 index 00..e43ab3afd94657 --- /dev/null +++ b/lldb/source/Host/aix/HostInfoAIX.cpp @@ -0,0 +1,213 @@ +//===-- HostInfoAIX.cpp -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Host/aix/HostInfoAIX.h" +#include "lldb/Host/Config.h" +#include "lldb/Host/FileSystem.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" + +#include "llvm/Support/Threading.h" + +#include +#include +#include +#include +#include + +#include +#include +#include + +using namespace lldb_private; + +namespace { +struct HostInfoAIXFields { + llvm::once_flag m_distribution_once_flag; + std::string m_distribution_id; + llvm::once_flag m_os_version_once_flag; + llvm::VersionTuple m_os_version; +}; +} // namespace + +static HostInfoAIXFields *g_fields = nullptr; + +void HostInfoAIX::Initialize(SharedLibraryDirectoryHelper *helper) { + HostInfoPosix::Initialize(helper); + + g_fields = new HostInfoAIXFields(); +} + +void HostInfoAIX::Terminate() { + assert(g_fields && "Missing call to Initialize?"); + delete g_fields; + g_fields = nullptr; + HostInfoBase::Terminate(); +} + +llvm::VersionTuple HostInfoAIX::GetOSVersion() { + assert(g_fields && "Missing call to Initialize?"); + llvm::call_once(g_fields->m_os_version_once_flag, []() { +struct utsname un; +if (uname(&un) != 0) + return; + +llvm::StringRef release = un.release; +// The kernel release string can include a lot of stuff (e.g. +// 4.9.0-6-amd64). We're only interested in the numbered prefix. +release = release.substr(0, release.find_first_not_of("0123456789.")); +g_fields->m_os_version.tryParse(release); + }); + + return g_fields->m_os_version; +} + +std::optional HostInfoAIX::GetOSBuildString() { + struct utsname un; + ::memset(&un, 0, sizeof(utsname)); + + if (uname(&un) < 0) +return std::nullopt; + + return std::s
[Lldb-commits] [lldb] [lldb][AIX] HostInfoAIX Support (PR #117906)
https://github.com/DhruvSrivastavaX updated https://github.com/llvm/llvm-project/pull/117906 >From d05de47c87362b54760f65c294c30c80b2d5bc9b Mon Sep 17 00:00:00 2001 From: Dhruv-Srivastava Date: Wed, 27 Nov 2024 10:10:32 -0600 Subject: [PATCH] HostInfoAIX --- lldb/include/lldb/Host/aix/HostInfoAIX.h | 43 + lldb/source/Host/CMakeLists.txt | 5 + lldb/source/Host/aix/HostInfoAIX.cpp | 213 +++ 3 files changed, 261 insertions(+) create mode 100644 lldb/include/lldb/Host/aix/HostInfoAIX.h create mode 100644 lldb/source/Host/aix/HostInfoAIX.cpp diff --git a/lldb/include/lldb/Host/aix/HostInfoAIX.h b/lldb/include/lldb/Host/aix/HostInfoAIX.h new file mode 100644 index 00..c797b36f3dcc8d --- /dev/null +++ b/lldb/include/lldb/Host/aix/HostInfoAIX.h @@ -0,0 +1,43 @@ +//===-- HostInfoAIX.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_HOST_AIX_HOSTINFOAIX_H_ +#define LLDB_HOST_AIX_HOSTINFOAIX_H_ + +#include "lldb/Host/posix/HostInfoPosix.h" +#include "lldb/Utility/FileSpec.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/VersionTuple.h" + +#include +#include + +namespace lldb_private { + +class HostInfoAIX : public HostInfoPosix { + friend class HostInfoBase; + +public: + static void Initialize(SharedLibraryDirectoryHelper *helper = nullptr); + static void Terminate(); + + static llvm::VersionTuple GetOSVersion(); + static std::optional GetOSBuildString(); + static llvm::StringRef GetDistributionId(); + static FileSpec GetProgramFileSpec(); + +protected: + static bool ComputeSupportExeDirectory(FileSpec &file_spec); + static bool ComputeSystemPluginsDirectory(FileSpec &file_spec); + static bool ComputeUserPluginsDirectory(FileSpec &file_spec); + static void ComputeHostArchitectureSupport(ArchSpec &arch_32, + ArchSpec &arch_64); +}; +} // namespace lldb_private + +#endif // LLDB_HOST_AIX_HOSTINFOAIX_H_ diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt index c2e091ee8555b7..e0cd8569bf9575 100644 --- a/lldb/source/Host/CMakeLists.txt +++ b/lldb/source/Host/CMakeLists.txt @@ -133,6 +133,11 @@ else() openbsd/Host.cpp openbsd/HostInfoOpenBSD.cpp ) + + elseif (CMAKE_SYSTEM_NAME MATCHES "AIX") +add_host_subdirectory(aix + aix/HostInfoAIX.cpp + ) endif() endif() diff --git a/lldb/source/Host/aix/HostInfoAIX.cpp b/lldb/source/Host/aix/HostInfoAIX.cpp new file mode 100644 index 00..e43ab3afd94657 --- /dev/null +++ b/lldb/source/Host/aix/HostInfoAIX.cpp @@ -0,0 +1,213 @@ +//===-- HostInfoAIX.cpp -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Host/aix/HostInfoAIX.h" +#include "lldb/Host/Config.h" +#include "lldb/Host/FileSystem.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" + +#include "llvm/Support/Threading.h" + +#include +#include +#include +#include +#include + +#include +#include +#include + +using namespace lldb_private; + +namespace { +struct HostInfoAIXFields { + llvm::once_flag m_distribution_once_flag; + std::string m_distribution_id; + llvm::once_flag m_os_version_once_flag; + llvm::VersionTuple m_os_version; +}; +} // namespace + +static HostInfoAIXFields *g_fields = nullptr; + +void HostInfoAIX::Initialize(SharedLibraryDirectoryHelper *helper) { + HostInfoPosix::Initialize(helper); + + g_fields = new HostInfoAIXFields(); +} + +void HostInfoAIX::Terminate() { + assert(g_fields && "Missing call to Initialize?"); + delete g_fields; + g_fields = nullptr; + HostInfoBase::Terminate(); +} + +llvm::VersionTuple HostInfoAIX::GetOSVersion() { + assert(g_fields && "Missing call to Initialize?"); + llvm::call_once(g_fields->m_os_version_once_flag, []() { +struct utsname un; +if (uname(&un) != 0) + return; + +llvm::StringRef release = un.release; +// The kernel release string can include a lot of stuff (e.g. +// 4.9.0-6-amd64). We're only interested in the numbered prefix. +release = release.substr(0, release.find_first_not_of("0123456789.")); +g_fields->m_os_version.tryParse(release); + }); + + return g_fields->m_os_version; +} + +std::optional HostInfoAIX::GetOSBuildString() { + struct utsname un; + ::memset(&un, 0, sizeof(utsname)); + + if (uname(&un) < 0) +return std::nullopt; + + return std::strin
[Lldb-commits] [lldb] [llvm] [LLDB][Process] Add LSX and LASX register definitions and operations on the LoongArch64 (PR #120664)
https://github.com/wangleiat updated https://github.com/llvm/llvm-project/pull/120664 >From 7e56f86ec79865de0c2bc49ffa3f9f2b17a6f36f Mon Sep 17 00:00:00 2001 From: wanglei Date: Fri, 20 Dec 2024 09:10:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5-bogner --- ...NativeRegisterContextLinux_loongarch64.cpp | 168 ++ .../NativeRegisterContextLinux_loongarch64.h | 21 ++- .../RegisterContextPOSIX_loongarch64.cpp | 10 ++ .../RegisterContextPOSIX_loongarch64.h| 8 + .../Utility/RegisterInfoPOSIX_loongarch64.cpp | 63 ++- .../Utility/RegisterInfoPOSIX_loongarch64.h | 12 ++ .../Utility/RegisterInfos_loongarch64.h | 89 ++ .../Utility/lldb-loongarch-register-enums.h | 70 .../RegisterContextPOSIXCore_loongarch64.cpp | 14 ++ .../RegisterContextPOSIXCore_loongarch64.h| 8 + .../Utility/LoongArch_DWARF_Registers.h | 66 +++ 11 files changed, 525 insertions(+), 4 deletions(-) diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp index 9ffc8ada920cb8..2eeea46f7f6836 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp @@ -27,6 +27,14 @@ // struct iovec definition #include +#ifndef NT_LARCH_LSX +#define NT_LARCH_LSX 0xa02 /* LoongArch SIMD eXtension registers */ +#endif + +#ifndef NT_LARCH_LASX +#define NT_LARCH_LASX 0xa03 /* LoongArch Advanced SIMD eXtension registers */ +#endif + #define REG_CONTEXT_SIZE (GetGPRSize() + GetFPRSize()) using namespace lldb; @@ -62,6 +70,8 @@ NativeRegisterContextLinux_loongarch64::NativeRegisterContextLinux_loongarch64( NativeRegisterContextLinux(native_thread) { ::memset(&m_fpr, 0, sizeof(m_fpr)); ::memset(&m_gpr, 0, sizeof(m_gpr)); + ::memset(&m_lsx, 0, sizeof(m_lsx)); + ::memset(&m_lasx, 0, sizeof(m_lasx)); ::memset(&m_hwp_regs, 0, sizeof(m_hwp_regs)); ::memset(&m_hbp_regs, 0, sizeof(m_hbp_regs)); @@ -75,6 +85,8 @@ NativeRegisterContextLinux_loongarch64::NativeRegisterContextLinux_loongarch64( m_gpr_is_valid = false; m_fpu_is_valid = false; + m_lsx_is_valid = false; + m_lasx_is_valid = false; } const RegisterInfoPOSIX_loongarch64 & @@ -135,6 +147,22 @@ Status NativeRegisterContextLinux_loongarch64::ReadRegister( offset = CalculateFprOffset(reg_info); assert(offset < GetFPRSize()); src = (uint8_t *)GetFPRBuffer() + offset; + } else if (IsLSX(reg)) { +error = ReadLSX(); +if (error.Fail()) + return error; + +offset = CalculateLsxOffset(reg_info); +assert(offset < sizeof(m_lsx)); +src = (uint8_t *)&m_lsx + offset; + } else if (IsLASX(reg)) { +error = ReadLASX(); +if (error.Fail()) + return error; + +offset = CalculateLasxOffset(reg_info); +assert(offset < sizeof(m_lasx)); +src = (uint8_t *)&m_lasx + offset; } else return Status::FromErrorString( "failed - register wasn't recognized to be a GPR or an FPR, " @@ -184,6 +212,28 @@ Status NativeRegisterContextLinux_loongarch64::WriteRegister( ::memcpy(dst, reg_value.GetBytes(), reg_info->byte_size); return WriteFPR(); + } else if (IsLSX(reg)) { +error = ReadLSX(); +if (error.Fail()) + return error; + +offset = CalculateLsxOffset(reg_info); +assert(offset < sizeof(m_lsx)); +dst = (uint8_t *)&m_lsx + offset; +::memcpy(dst, reg_value.GetBytes(), reg_info->byte_size); + +return WriteLSX(); + } else if (IsLASX(reg)) { +error = ReadLASX(); +if (error.Fail()) + return error; + +offset = CalculateLasxOffset(reg_info); +assert(offset < sizeof(m_lasx)); +dst = (uint8_t *)&m_lasx + offset; +::memcpy(dst, reg_value.GetBytes(), reg_info->byte_size); + +return WriteLASX(); } return Status::FromErrorString("Failed to write register value"); @@ -203,10 +253,22 @@ Status NativeRegisterContextLinux_loongarch64::ReadAllRegisterValues( if (error.Fail()) return error; + error = ReadLSX(); + if (error.Fail()) +return error; + + error = ReadLASX(); + if (error.Fail()) +return error; + uint8_t *dst = data_sp->GetBytes(); ::memcpy(dst, GetGPRBuffer(), GetGPRSize()); dst += GetGPRSize(); ::memcpy(dst, GetFPRBuffer(), GetFPRSize()); + dst += GetFPRSize(); + ::memcpy(dst, &m_lsx, sizeof(m_lsx)); + dst += sizeof(m_lsx); + ::memcpy(dst, &m_lasx, sizeof(m_lasx)); return error; } @@ -252,6 +314,20 @@ Status NativeRegisterContextLinux_loongarch64::WriteAllRegisterValues( if (error.Fail()) return error; + src += GetFPRSize(); + ::memcpy(&m_lsx, src, sizeof(m_lsx)); + + error = WriteLSX(); + i
[Lldb-commits] [lldb] [llvm] [LLDB][Process] Add LSX and LASX register definitions and operations on the LoongArch64 (PR #120664)
@@ -27,6 +27,14 @@ // struct iovec definition #include +#ifndef NT_LARCH_LSX wangleiat wrote: Sorry, I didn’t find this initially. This definition `NT_LARCH_xxx` was found in GDB. Thanks all, done. https://github.com/llvm/llvm-project/pull/120664 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Process] Add LSX and LASX register definitions and operations on the LoongArch64 (PR #120664)
https://github.com/wangleiat edited https://github.com/llvm/llvm-project/pull/120664 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Process] Add LSX and LASX register definitions and operations on the LoongArch64 (PR #120664)
@@ -48,6 +48,10 @@ bool RegisterContextCorePOSIX_loongarch64::ReadGPR() { return true; } bool RegisterContextCorePOSIX_loongarch64::ReadFPR() { return true; } +bool RegisterContextCorePOSIX_loongarch64::ReadLSX() { return true; } + +bool RegisterContextCorePOSIX_loongarch64::ReadLASX() { return true; } wangleiat wrote: I have verified that it works(surprised too). I have removed the ELF-core-related modifications, and support for adding LSX/LASX registers in ELF-core will be included in a subsequent patch. The modifications are too extensive; it's not just about adding two functions. https://github.com/llvm/llvm-project/pull/120664 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Process] Add LSX and LASX register definitions and operations on the LoongArch64 (PR #120664)
https://github.com/wangleiat updated https://github.com/llvm/llvm-project/pull/120664 >From 7e56f86ec79865de0c2bc49ffa3f9f2b17a6f36f Mon Sep 17 00:00:00 2001 From: wanglei Date: Fri, 20 Dec 2024 09:10:10 +0800 Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5-bogner --- ...NativeRegisterContextLinux_loongarch64.cpp | 168 ++ .../NativeRegisterContextLinux_loongarch64.h | 21 ++- .../RegisterContextPOSIX_loongarch64.cpp | 10 ++ .../RegisterContextPOSIX_loongarch64.h| 8 + .../Utility/RegisterInfoPOSIX_loongarch64.cpp | 63 ++- .../Utility/RegisterInfoPOSIX_loongarch64.h | 12 ++ .../Utility/RegisterInfos_loongarch64.h | 89 ++ .../Utility/lldb-loongarch-register-enums.h | 70 .../RegisterContextPOSIXCore_loongarch64.cpp | 14 ++ .../RegisterContextPOSIXCore_loongarch64.h| 8 + .../Utility/LoongArch_DWARF_Registers.h | 66 +++ 11 files changed, 525 insertions(+), 4 deletions(-) diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp index 9ffc8ada920cb8..2eeea46f7f6836 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp @@ -27,6 +27,14 @@ // struct iovec definition #include +#ifndef NT_LARCH_LSX +#define NT_LARCH_LSX 0xa02 /* LoongArch SIMD eXtension registers */ +#endif + +#ifndef NT_LARCH_LASX +#define NT_LARCH_LASX 0xa03 /* LoongArch Advanced SIMD eXtension registers */ +#endif + #define REG_CONTEXT_SIZE (GetGPRSize() + GetFPRSize()) using namespace lldb; @@ -62,6 +70,8 @@ NativeRegisterContextLinux_loongarch64::NativeRegisterContextLinux_loongarch64( NativeRegisterContextLinux(native_thread) { ::memset(&m_fpr, 0, sizeof(m_fpr)); ::memset(&m_gpr, 0, sizeof(m_gpr)); + ::memset(&m_lsx, 0, sizeof(m_lsx)); + ::memset(&m_lasx, 0, sizeof(m_lasx)); ::memset(&m_hwp_regs, 0, sizeof(m_hwp_regs)); ::memset(&m_hbp_regs, 0, sizeof(m_hbp_regs)); @@ -75,6 +85,8 @@ NativeRegisterContextLinux_loongarch64::NativeRegisterContextLinux_loongarch64( m_gpr_is_valid = false; m_fpu_is_valid = false; + m_lsx_is_valid = false; + m_lasx_is_valid = false; } const RegisterInfoPOSIX_loongarch64 & @@ -135,6 +147,22 @@ Status NativeRegisterContextLinux_loongarch64::ReadRegister( offset = CalculateFprOffset(reg_info); assert(offset < GetFPRSize()); src = (uint8_t *)GetFPRBuffer() + offset; + } else if (IsLSX(reg)) { +error = ReadLSX(); +if (error.Fail()) + return error; + +offset = CalculateLsxOffset(reg_info); +assert(offset < sizeof(m_lsx)); +src = (uint8_t *)&m_lsx + offset; + } else if (IsLASX(reg)) { +error = ReadLASX(); +if (error.Fail()) + return error; + +offset = CalculateLasxOffset(reg_info); +assert(offset < sizeof(m_lasx)); +src = (uint8_t *)&m_lasx + offset; } else return Status::FromErrorString( "failed - register wasn't recognized to be a GPR or an FPR, " @@ -184,6 +212,28 @@ Status NativeRegisterContextLinux_loongarch64::WriteRegister( ::memcpy(dst, reg_value.GetBytes(), reg_info->byte_size); return WriteFPR(); + } else if (IsLSX(reg)) { +error = ReadLSX(); +if (error.Fail()) + return error; + +offset = CalculateLsxOffset(reg_info); +assert(offset < sizeof(m_lsx)); +dst = (uint8_t *)&m_lsx + offset; +::memcpy(dst, reg_value.GetBytes(), reg_info->byte_size); + +return WriteLSX(); + } else if (IsLASX(reg)) { +error = ReadLASX(); +if (error.Fail()) + return error; + +offset = CalculateLasxOffset(reg_info); +assert(offset < sizeof(m_lasx)); +dst = (uint8_t *)&m_lasx + offset; +::memcpy(dst, reg_value.GetBytes(), reg_info->byte_size); + +return WriteLASX(); } return Status::FromErrorString("Failed to write register value"); @@ -203,10 +253,22 @@ Status NativeRegisterContextLinux_loongarch64::ReadAllRegisterValues( if (error.Fail()) return error; + error = ReadLSX(); + if (error.Fail()) +return error; + + error = ReadLASX(); + if (error.Fail()) +return error; + uint8_t *dst = data_sp->GetBytes(); ::memcpy(dst, GetGPRBuffer(), GetGPRSize()); dst += GetGPRSize(); ::memcpy(dst, GetFPRBuffer(), GetFPRSize()); + dst += GetFPRSize(); + ::memcpy(dst, &m_lsx, sizeof(m_lsx)); + dst += sizeof(m_lsx); + ::memcpy(dst, &m_lasx, sizeof(m_lasx)); return error; } @@ -252,6 +314,20 @@ Status NativeRegisterContextLinux_loongarch64::WriteAllRegisterValues( if (error.Fail()) return error; + src += GetFPRSize(); + ::memcpy(&m_lsx, src, sizeof(m_lsx)); + + error = WriteLSX(); + i
[Lldb-commits] [lldb] bca055f - [lldb] AIX Changes for MainLoop polling (#120378)
Author: Dhruv Srivastava Date: 2024-12-27T09:12:26+01:00 New Revision: bca055f2ac075d43f6f316927947b2a493f93bdb URL: https://github.com/llvm/llvm-project/commit/bca055f2ac075d43f6f316927947b2a493f93bdb DIFF: https://github.com/llvm/llvm-project/commit/bca055f2ac075d43f6f316927947b2a493f93bdb.diff LOG: [lldb] AIX Changes for MainLoop polling (#120378) This PR is in reference to porting LLDB on AIX. Link to discussions on llvm discourse and github: 1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640 2. https://github.com/llvm/llvm-project/issues/101657 The complete changes for porting are present in this draft PR: https://github.com/llvm/llvm-project/pull/102601 Dropping changes for MainLoop polling in AIX, as `ppoll` is not supported in AIX currently. This change is part of the couple of minimal changes required to build a minimal `lldb` binary on AIX Added: Modified: lldb/source/Host/posix/MainLoopPosix.cpp Removed: diff --git a/lldb/source/Host/posix/MainLoopPosix.cpp b/lldb/source/Host/posix/MainLoopPosix.cpp index aecdeb9ba5d1c8..ce7caa3041dd06 100644 --- a/lldb/source/Host/posix/MainLoopPosix.cpp +++ b/lldb/source/Host/posix/MainLoopPosix.cpp @@ -99,6 +99,7 @@ class MainLoopPosix::RunImpl { ~RunImpl() = default; Status Poll(); + void ProcessReadEvents(); private: @@ -159,6 +160,22 @@ MainLoopPosix::RunImpl::RunImpl(MainLoopPosix &loop) : loop(loop) { read_fds.reserve(loop.m_read_fds.size()); } +static int StartPoll(llvm::MutableArrayRef fds, + std::optional point) { +#if HAVE_PPOLL + return ppoll(fds.data(), fds.size(), ToTimeSpec(point), + /*sigmask=*/nullptr); +#else + using namespace std::chrono; + int timeout = -1; + if (point) { +nanoseconds dur = std::max(*point - steady_clock::now(), nanoseconds(0)); +timeout = ceil(dur).count(); + } + return poll(fds.data(), fds.size(), timeout); +#endif +} + Status MainLoopPosix::RunImpl::Poll() { read_fds.clear(); @@ -169,11 +186,9 @@ Status MainLoopPosix::RunImpl::Poll() { pfd.revents = 0; read_fds.push_back(pfd); } + int ready = StartPoll(read_fds, loop.GetNextWakeupTime()); - if (ppoll(read_fds.data(), read_fds.size(), -ToTimeSpec(loop.GetNextWakeupTime()), -/*sigmask=*/nullptr) == -1 && - errno != EINTR) + if (ready == -1 && errno != EINTR) return Status(errno, eErrorTypePOSIX); return Status(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] AIX Changes for MainLoop polling (PR #120378)
https://github.com/labath closed https://github.com/llvm/llvm-project/pull/120378 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] clang-format changes for some basic #if _AIX changes (PR #120978)
https://github.com/labath closed https://github.com/llvm/llvm-project/pull/120978 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 1ead155 - [lldb] clang-format changes for some basic #if _AIX changes (#120978)
Author: Dhruv Srivastava Date: 2024-12-27T09:13:43+01:00 New Revision: 1ead15512872b1f9eec0b69a7d8283e752a747e6 URL: https://github.com/llvm/llvm-project/commit/1ead15512872b1f9eec0b69a7d8283e752a747e6 DIFF: https://github.com/llvm/llvm-project/commit/1ead15512872b1f9eec0b69a7d8283e752a747e6.diff LOG: [lldb] clang-format changes for some basic #if _AIX changes (#120978) This PR is in reference to porting LLDB on AIX. Link to discussions on llvm discourse and github: 1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640 2. https://github.com/llvm/llvm-project/issues/101657 The complete changes for porting are present in this draft PR: https://github.com/llvm/llvm-project/pull/102601 Added clang-format changes for changes related to some base #if _AIX changes: - https://github.com/llvm/llvm-project/pull/120979 Added: Modified: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp lldb/source/Host/posix/DomainSocket.cpp lldb/source/Plugins/Language/ObjC/Cocoa.cpp lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp Removed: diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp index 6bdc33f8923281..ab4ddbfe1fb203 100644 --- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -119,8 +119,7 @@ bool ConnectionFileDescriptor::IsConnected() const { ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path, Status *error_ptr) { - return Connect( - path, [](llvm::StringRef) {}, error_ptr); + return Connect(path, [](llvm::StringRef) {}, error_ptr); } ConnectionStatus diff --git a/lldb/source/Host/posix/DomainSocket.cpp b/lldb/source/Host/posix/DomainSocket.cpp index 9a0b385d998bfc..f85e1b9bbdc5c0 100644 --- a/lldb/source/Host/posix/DomainSocket.cpp +++ b/lldb/source/Host/posix/DomainSocket.cpp @@ -86,7 +86,8 @@ Status DomainSocket::Connect(llvm::StringRef name) { if (error.Fail()) return error; if (llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(), -(struct sockaddr *)&saddr_un, saddr_un_len) < 0) + (struct sockaddr *)&saddr_un, + saddr_un_len) < 0) SetLastError(error); return error; diff --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp index bbe5d4c611f870..b35e27ad8123f6 100644 --- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp +++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp @@ -31,7 +31,6 @@ #include "llvm/ADT/APInt.h" #include "llvm/ADT/bit.h" - using namespace lldb; using namespace lldb_private; using namespace lldb_private::formatters; @@ -267,21 +266,21 @@ bool lldb_private::formatters::NSIndexSetSummaryProvider( if (class_name == "NSIndexSet" || class_name == "NSMutableIndexSet") { // Foundation version 2000 added a bitmask if the index set fit in 64 bits // and a Tagged Pointer version if the bitmask is small enough to fit in - // the tagged pointer payload. + // the tagged pointer payload. // It also changed the layout (but not the size) of the set descriptor. // First check whether this is a tagged pointer. The bitmask will be in // the payload of the tagged pointer. uint64_t payload; - if (runtime->GetFoundationVersion() >= 2000 - && descriptor->GetTaggedPointerInfo(nullptr, nullptr, &payload)) { + if (runtime->GetFoundationVersion() >= 2000 && + descriptor->GetTaggedPointerInfo(nullptr, nullptr, &payload)) { count = llvm::popcount(payload); break; } // The first 32 bits describe the index set in all cases: Status error; uint32_t mode = process_sp->ReadUnsignedIntegerFromMemory( -valobj_addr + ptr_size, 4, 0, error); + valobj_addr + ptr_size, 4, 0, error); if (error.Fail()) return false; // Now check if the index is held in a bitmask in the object: @@ -292,7 +291,7 @@ bool lldb_private::formatters::NSIndexSetSummaryProvider( if ((mode & 2) == 2) { // The bitfield is a 64 bit uint at the beginning of the data var. uint64_t bitfield = process_sp->ReadUnsignedIntegerFromMemory( -valobj_addr + 2 * ptr_size, 8, 0, error); + valobj_addr + 2 * ptr_size, 8, 0, error); if (error.Fail()) return false; count = llvm::popcount(bitfield); @@ -309,7 +308,7 @@ bool lldb_private::formatters::NSIndexSetSummaryProvider( count = 0; break; } - + if ((mode & 2) == 2) mode = 1; // this means the set only has one range else diff --git a/lldb/sou
[Lldb-commits] [lldb] [lldb][AIX] Some base #if _AIX changes of a minimal lldb build (PR #120979)
https://github.com/DhruvSrivastavaX updated https://github.com/llvm/llvm-project/pull/120979 >From c8887adb58fc0042c99a66fbc436bc95361e9086 Mon Sep 17 00:00:00 2001 From: Dhruv-Srivastava Date: Mon, 23 Dec 2024 10:22:40 -0600 Subject: [PATCH 1/2] Some base #if _AIX changes --- .../Host/posix/ConnectionFileDescriptorPosix.cpp | 7 +++ lldb/source/Host/posix/DomainSocket.cpp | 6 +- lldb/source/Host/posix/FileSystemPosix.cpp| 2 ++ lldb/source/Plugins/Language/ObjC/Cocoa.cpp | 15 +++ 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp index 6bdc33f8923281..e3d1300cf76eda 100644 --- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -119,8 +119,7 @@ bool ConnectionFileDescriptor::IsConnected() const { ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path, Status *error_ptr) { - return Connect( - path, [](llvm::StringRef) {}, error_ptr); + return Connect(path, [](llvm::StringRef) {}, error_ptr); } ConnectionStatus @@ -716,7 +715,7 @@ ConnectionFileDescriptor::ConnectFD(llvm::StringRef s, ConnectionStatus ConnectionFileDescriptor::ConnectFile( llvm::StringRef s, socket_id_callback_type socket_id_callback, Status *error_ptr) { -#if LLDB_ENABLE_POSIX +#if LLDB_ENABLE_POSIX && !defined(_AIX) std::string addr_str = s.str(); // file:///PATH int fd = FileSystem::Instance().Open(addr_str.c_str(), O_RDWR); @@ -747,7 +746,7 @@ ConnectionStatus ConnectionFileDescriptor::ConnectFile( m_io_sp = std::make_shared(fd, File::eOpenOptionReadWrite, true); return eConnectionStatusSuccess; -#endif // LLDB_ENABLE_POSIX +#endif // LLDB_ENABLE_POSIX && !defined(_AIX) llvm_unreachable("this function should be only called w/ LLDB_ENABLE_POSIX"); } diff --git a/lldb/source/Host/posix/DomainSocket.cpp b/lldb/source/Host/posix/DomainSocket.cpp index 9a0b385d998bfc..9f4f12bb481bd0 100644 --- a/lldb/source/Host/posix/DomainSocket.cpp +++ b/lldb/source/Host/posix/DomainSocket.cpp @@ -16,6 +16,9 @@ #include #include #include +#ifdef _AIX +#include +#endif using namespace lldb; using namespace lldb_private; @@ -86,7 +89,8 @@ Status DomainSocket::Connect(llvm::StringRef name) { if (error.Fail()) return error; if (llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(), -(struct sockaddr *)&saddr_un, saddr_un_len) < 0) + (struct sockaddr *)&saddr_un, + saddr_un_len) < 0) SetLastError(error); return error; diff --git a/lldb/source/Host/posix/FileSystemPosix.cpp b/lldb/source/Host/posix/FileSystemPosix.cpp index 945e2affc83715..1a84f550662d75 100644 --- a/lldb/source/Host/posix/FileSystemPosix.cpp +++ b/lldb/source/Host/posix/FileSystemPosix.cpp @@ -11,7 +11,9 @@ // C includes #include #include +#ifndef _AIX #include +#endif #include #include #include diff --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp index bbe5d4c611f870..1d79edbede5d67 100644 --- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp +++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp @@ -31,7 +31,6 @@ #include "llvm/ADT/APInt.h" #include "llvm/ADT/bit.h" - using namespace lldb; using namespace lldb_private; using namespace lldb_private::formatters; @@ -267,21 +266,21 @@ bool lldb_private::formatters::NSIndexSetSummaryProvider( if (class_name == "NSIndexSet" || class_name == "NSMutableIndexSet") { // Foundation version 2000 added a bitmask if the index set fit in 64 bits // and a Tagged Pointer version if the bitmask is small enough to fit in - // the tagged pointer payload. + // the tagged pointer payload. // It also changed the layout (but not the size) of the set descriptor. // First check whether this is a tagged pointer. The bitmask will be in // the payload of the tagged pointer. uint64_t payload; - if (runtime->GetFoundationVersion() >= 2000 - && descriptor->GetTaggedPointerInfo(nullptr, nullptr, &payload)) { + if (runtime->GetFoundationVersion() >= 2000 && + descriptor->GetTaggedPointerInfo(nullptr, nullptr, &payload)) { count = llvm::popcount(payload); break; } // The first 32 bits describe the index set in all cases: Status error; uint32_t mode = process_sp->ReadUnsignedIntegerFromMemory( -valobj_addr + ptr_size, 4, 0, error); + valobj_addr + ptr_size, 4, 0, error); if (error.Fail()) return false; // Now check if the index is held in a bitmask in the object: @@ -292,7 +291,7 @@ bool lldb_private::formatters::NSIndexSetSummaryProvider( if (
[Lldb-commits] [lldb] [lldb][AIX] Some base #if _AIX changes of a minimal lldb build (PR #120979)
DhruvSrivastavaX wrote: Hi @labath , Please let me know your comments for these changes, I have rebased this for formatting changes. https://github.com/llvm/llvm-project/pull/120979 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] Some base #if _AIX changes of a minimal lldb build (PR #120979)
DhruvSrivastavaX wrote: Hi @labath , Please let me know your comments for these changes. https://github.com/llvm/llvm-project/pull/120979 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Update SBModule (PR #120832)
https://github.com/rchamala closed https://github.com/llvm/llvm-project/pull/120832 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Update SBModule (PR #120832)
https://github.com/rchamala reopened https://github.com/llvm/llvm-project/pull/120832 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits