[Lldb-commits] [lldb] [lldb] Add amd64 ArchSpec (PR #122533)
https://github.com/brad0 updated https://github.com/llvm/llvm-project/pull/122533 >From 92c341b44c43a0d6f2442ec968ad56e494b8e785 Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Thu, 9 Jan 2025 19:18:27 -0500 Subject: [PATCH] [lldb] Add amd64 ArchSpec amd64 is used on OpenBSD. --- lldb/include/lldb/Utility/ArchSpec.h| 2 ++ lldb/source/Utility/ArchSpec.cpp| 4 lldb/unittests/Utility/ArchSpecTest.cpp | 6 ++ 3 files changed, 12 insertions(+) diff --git a/lldb/include/lldb/Utility/ArchSpec.h b/lldb/include/lldb/Utility/ArchSpec.h index 2a74058673bae5..7e9bc23a75acbb 100644 --- a/lldb/include/lldb/Utility/ArchSpec.h +++ b/lldb/include/lldb/Utility/ArchSpec.h @@ -215,6 +215,8 @@ class ArchSpec { eCore_x86_64_x86_64, eCore_x86_64_x86_64h, // Haswell enabled x86_64 +eCore_x86_64_amd64, + eCore_hexagon_generic, eCore_hexagon_hexagonv4, eCore_hexagon_hexagonv5, diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp index 85bb85044ec156..b13e8ff1ec373d 100644 --- a/lldb/source/Utility/ArchSpec.cpp +++ b/lldb/source/Utility/ArchSpec.cpp @@ -218,6 +218,9 @@ static const CoreDefinition g_core_definitions[] = { ArchSpec::eCore_x86_64_x86_64, "x86_64"}, {eByteOrderLittle, 8, 1, 15, llvm::Triple::x86_64, ArchSpec::eCore_x86_64_x86_64h, "x86_64h"}, +{eByteOrderLittle, 8, 1, 15, llvm::Triple::x86_64, + ArchSpec::eCore_x86_64_amd64, "amd64"}, + {eByteOrderLittle, 4, 4, 4, llvm::Triple::hexagon, ArchSpec::eCore_hexagon_generic, "hexagon"}, {eByteOrderLittle, 4, 4, 4, llvm::Triple::hexagon, @@ -1227,6 +1230,7 @@ static bool cores_match(const ArchSpec::Core core1, const ArchSpec::Core core2, break; case ArchSpec::eCore_x86_64_x86_64h: + case ArchSpec::eCore_x86_64_amd64: if (!enforce_exact_match) { try_inverse = false; if (core2 == ArchSpec::eCore_x86_64_x86_64) diff --git a/lldb/unittests/Utility/ArchSpecTest.cpp b/lldb/unittests/Utility/ArchSpecTest.cpp index de3590b73bbaa4..74a4b48456b016 100644 --- a/lldb/unittests/Utility/ArchSpecTest.cpp +++ b/lldb/unittests/Utility/ArchSpecTest.cpp @@ -129,6 +129,12 @@ TEST(ArchSpecTest, TestSetTriple) { EXPECT_STREQ("msp430", AS.GetArchitectureName()); EXPECT_EQ(ArchSpec::eCore_msp430, AS.GetCore()); + AS = ArchSpec(); + EXPECT_TRUE(AS.SetTriple("amd64-unknown-openbsd")); + EXPECT_EQ(llvm::Triple::x86_64, AS.GetTriple().getArch()); + EXPECT_STREQ("amd64", AS.GetArchitectureName()); + EXPECT_EQ(ArchSpec::eCore_x86_64_amd64, AS.GetCore()); + // Various flavors of invalid triples. AS = ArchSpec(); EXPECT_FALSE(AS.SetTriple("unknown-unknown-unknown")); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] Added PlatformAIX plugin (PR #121273)
@@ -0,0 +1,370 @@ +//===-- PlatformAIX.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 "PlatformAIX.h" +#include "lldb/Host/Config.h" +#include +#if LLDB_ENABLE_POSIX +#include +#endif +#include "Utility/ARM64_DWARF_Registers.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Symbol/UnwindPlan.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" +#include "lldb/Utility/Status.h" +#include "lldb/Utility/StreamString.h" + +// Use defined constants from AIX mman.h for use when targeting remote aix +// systems even when host has different values. + +#if defined(_AIX) +#include +#endif + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::platform_aix; + +LLDB_PLUGIN_DEFINE(PlatformAIX) + +static uint32_t g_initialize_count = 0; + +PlatformSP PlatformAIX::CreateInstance(bool force, const ArchSpec *arch) { + Log *log = GetLog(LLDBLog::Platform); + LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force, + arch ? arch->GetArchitectureName() : "", + arch ? arch->GetTriple().getTriple() : ""); + + bool create = force; + if (!create && arch && arch->IsValid()) { +const llvm::Triple &triple = arch->GetTriple(); +switch (triple.getOS()) { +case llvm::Triple::AIX: + create = true; + break; + +default: + break; +} + } + + LLDB_LOG(log, "create = {0}", create); + if (create) { +return PlatformSP(new PlatformAIX(false)); + } + return PlatformSP(); +} + +llvm::StringRef PlatformAIX::GetPluginDescriptionStatic(bool is_host) { + if (is_host) +return "Local AIX user platform plug-in."; + return "Remote AIX user platform plug-in."; +} + +void PlatformAIX::Initialize() { + PlatformPOSIX::Initialize(); + + if (g_initialize_count++ == 0) { +#ifdef _AIX +PlatformSP default_platform_sp(new PlatformAIX(true)); +default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture()); +Platform::SetHostPlatform(default_platform_sp); +#endif +PluginManager::RegisterPlugin( +PlatformAIX::GetPluginNameStatic(false), +PlatformAIX::GetPluginDescriptionStatic(false), +PlatformAIX::CreateInstance, nullptr); + } +} + +void PlatformAIX::Terminate() { + if (g_initialize_count > 0) { +if (--g_initialize_count == 0) { + PluginManager::UnregisterPlugin(PlatformAIX::CreateInstance); +} + } + + PlatformPOSIX::Terminate(); +} + +/// Default Constructor +PlatformAIX::PlatformAIX(bool is_host) +: PlatformPOSIX(is_host) // This is the local host platform +{ + if (is_host) { +ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault); +m_supported_architectures.push_back(hostArch); +if (hostArch.GetTriple().isArch64Bit()) { + m_supported_architectures.push_back( + HostInfo::GetArchitecture(HostInfo::eArchKind32)); +} + } else { +m_supported_architectures = +CreateArchList({llvm::Triple::ppc64}, llvm::Triple::AIX); + } +} + +std::vector +PlatformAIX::GetSupportedArchitectures(const ArchSpec &process_host_arch) { + if (m_remote_platform_sp) +return m_remote_platform_sp->GetSupportedArchitectures(process_host_arch); + return m_supported_architectures; +} + +void PlatformAIX::GetStatus(Stream &strm) { + Platform::GetStatus(strm); + +#if LLDB_ENABLE_POSIX + // Display local kernel information only when we are running in host mode. + // Otherwise, we would end up printing non-AIX information (when running on + // Mac OS for example). + if (IsHost()) { +struct utsname un; + +if (uname(&un)) + return; + +strm.Printf("Kernel: %s\n", un.sysname); +strm.Printf(" Release: %s\n", un.release); +strm.Printf(" Version: %s\n", un.version); + } +#endif +} + +uint32_t +PlatformAIX::GetResumeCountForLaunchInfo(ProcessLaunchInfo &launch_info) { DhruvSrivastavaX wrote: Okay sure. Thanks! https://github.com/llvm/llvm-project/pull/121273 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][AIX] Added PlatformAIX plugin (PR #121273)
@@ -0,0 +1,370 @@ +//===-- PlatformAIX.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 "PlatformAIX.h" +#include "lldb/Host/Config.h" +#include +#if LLDB_ENABLE_POSIX +#include +#endif +#include "Utility/ARM64_DWARF_Registers.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Symbol/UnwindPlan.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" +#include "lldb/Utility/Status.h" +#include "lldb/Utility/StreamString.h" + +// Use defined constants from AIX mman.h for use when targeting remote aix +// systems even when host has different values. + +#if defined(_AIX) +#include +#endif + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::platform_aix; + +LLDB_PLUGIN_DEFINE(PlatformAIX) + +static uint32_t g_initialize_count = 0; + +PlatformSP PlatformAIX::CreateInstance(bool force, const ArchSpec *arch) { + Log *log = GetLog(LLDBLog::Platform); + LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force, + arch ? arch->GetArchitectureName() : "", + arch ? arch->GetTriple().getTriple() : ""); + + bool create = force; + if (!create && arch && arch->IsValid()) { +const llvm::Triple &triple = arch->GetTriple(); +switch (triple.getOS()) { +case llvm::Triple::AIX: + create = true; + break; + +default: + break; +} + } + + LLDB_LOG(log, "create = {0}", create); + if (create) { +return PlatformSP(new PlatformAIX(false)); + } + return PlatformSP(); +} + +llvm::StringRef PlatformAIX::GetPluginDescriptionStatic(bool is_host) { + if (is_host) +return "Local AIX user platform plug-in."; + return "Remote AIX user platform plug-in."; +} + +void PlatformAIX::Initialize() { + PlatformPOSIX::Initialize(); + + if (g_initialize_count++ == 0) { +#ifdef _AIX +PlatformSP default_platform_sp(new PlatformAIX(true)); +default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture()); +Platform::SetHostPlatform(default_platform_sp); +#endif +PluginManager::RegisterPlugin( +PlatformAIX::GetPluginNameStatic(false), +PlatformAIX::GetPluginDescriptionStatic(false), +PlatformAIX::CreateInstance, nullptr); + } +} + +void PlatformAIX::Terminate() { + if (g_initialize_count > 0) { +if (--g_initialize_count == 0) { + PluginManager::UnregisterPlugin(PlatformAIX::CreateInstance); +} + } + + PlatformPOSIX::Terminate(); +} + +/// Default Constructor +PlatformAIX::PlatformAIX(bool is_host) +: PlatformPOSIX(is_host) // This is the local host platform +{ + if (is_host) { +ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault); +m_supported_architectures.push_back(hostArch); +if (hostArch.GetTriple().isArch64Bit()) { + m_supported_architectures.push_back( + HostInfo::GetArchitecture(HostInfo::eArchKind32)); +} + } else { +m_supported_architectures = +CreateArchList({llvm::Triple::ppc64}, llvm::Triple::AIX); + } +} + +std::vector +PlatformAIX::GetSupportedArchitectures(const ArchSpec &process_host_arch) { + if (m_remote_platform_sp) +return m_remote_platform_sp->GetSupportedArchitectures(process_host_arch); + return m_supported_architectures; +} + +void PlatformAIX::GetStatus(Stream &strm) { + Platform::GetStatus(strm); + +#if LLDB_ENABLE_POSIX + // Display local kernel information only when we are running in host mode. + // Otherwise, we would end up printing non-AIX information (when running on + // Mac OS for example). + if (IsHost()) { +struct utsname un; + +if (uname(&un)) + return; + +strm.Printf("Kernel: %s\n", un.sysname); +strm.Printf(" Release: %s\n", un.release); +strm.Printf(" Version: %s\n", un.version); + } +#endif +} + +uint32_t +PlatformAIX::GetResumeCountForLaunchInfo(ProcessLaunchInfo &launch_info) { + uint32_t resume_count = 0; + + // Always resume past the initial stop when we use eLaunchFlagDebug + if (launch_info.GetFlags().Test(eLaunchFlagDebug)) { +// Resume past the stop for the final exec into the true inferior. +++resume_count; + } + + // If we're not launching a shell, we're done. + const FileSpec &shell = launch_info.GetShell(); + if (!shell) +return resume_count; + + std::string shell_string = shell.GetPath(); + // We're in a shell, so for sure we have to resume past the shell exec. + ++resume_count; + + // Figure out what shell we're planning on using. + const char *shell_name