[Lldb-commits] [lldb] [lldb][aix] 2. Updating XCOFF, PPC entry in LLDB ArchSpec (PR #105523)
Dhruv Srivastava via lldb-commits
lldb-commits at lists.llvm.org
Wed Aug 21 06:21:31 PDT 2024
https://github.com/DhruvSrivastavaX created https://github.com/llvm/llvm-project/pull/105523
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. #101657
The complete changes for porting are present in this draft PR:
#102601
The changes in this PR are intended to update the Architecture entry for LLDB with XCOFF,PPC.
1. Added new ArchitectureType `eArchTypeXCOFF`
2. Added a new `ArchDefinitionEntry g_xcoff_arch_entries[]`
3. Added a new case for `XCOFF in ArchSpec::SetArchitecture(..)`
4. Updated `ArchDefinition *g_arch_definitions[]`
>From 53e2a7bffaad8a6813fdc5422805d332fdee86fa Mon Sep 17 00:00:00 2001
From: Dhruv-Srivastava <dhruv.srivastava at ibm.com>
Date: Wed, 21 Aug 2024 06:37:30 -0500
Subject: [PATCH 1/3] Updating XCOFF architecture lookup in LLDB
---
lldb/source/Utility/ArchSpec.cpp | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp
index 07ef435ef451d2..38b403408e38fd 100644
--- a/lldb/source/Utility/ArchSpec.cpp
+++ b/lldb/source/Utility/ArchSpec.cpp
@@ -14,6 +14,7 @@
#include "lldb/lldb-defines.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/BinaryFormat/COFF.h"
+#include "llvm/BinaryFormat/XCOFF.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/Support/Compiler.h"
@@ -459,10 +460,24 @@ static const ArchDefinition g_coff_arch_def = {
"pe-coff",
};
+
+static const ArchDefinitionEntry g_xcoff_arch_entries[] = {
+ {ArchSpec::eCore_ppc_generic, llvm::XCOFF::TCPU_COM, LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu},
+ {ArchSpec::eCore_ppc64_generic, llvm::XCOFF::TCPU_PPC64, LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu}
+};
+
+static const ArchDefinition g_xcoff_arch_def = {
+ eArchTypeXCOFF,
+ std::size(g_xcoff_arch_entries),
+ g_xcoff_arch_entries,
+ "xcoff",
+};
+
+
//===----------------------------------------------------------------------===//
// Table of all ArchDefinitions
static const ArchDefinition *g_arch_definitions[] = {
- &g_macho_arch_def, &g_elf_arch_def, &g_coff_arch_def};
+ &g_macho_arch_def, &g_elf_arch_def, &g_coff_arch_def, &g_xcoff_arch_def};
//===----------------------------------------------------------------------===//
// Static helper functions.
@@ -903,6 +918,9 @@ bool ArchSpec::SetArchitecture(ArchitectureType arch_type, uint32_t cpu,
} else if (arch_type == eArchTypeCOFF && os == llvm::Triple::Win32) {
m_triple.setVendor(llvm::Triple::PC);
m_triple.setOS(llvm::Triple::Win32);
+ } else if (arch_type == eArchTypeXCOFF && os == llvm::Triple::AIX) {
+ m_triple.setVendor(llvm::Triple::IBM);
+ m_triple.setOS(llvm::Triple::AIX);
} else {
m_triple.setVendor(llvm::Triple::UnknownVendor);
m_triple.setOS(llvm::Triple::UnknownOS);
>From f9b94258b175fe24b3f7612d785155566ed5d270 Mon Sep 17 00:00:00 2001
From: Dhruv-Srivastava <dhruv.srivastava at ibm.com>
Date: Wed, 21 Aug 2024 06:46:36 -0500
Subject: [PATCH 2/3] clang-format modifications
---
lldb/source/Utility/ArchSpec.cpp | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp
index 38b403408e38fd..4fd1a800023ce3 100644
--- a/lldb/source/Utility/ArchSpec.cpp
+++ b/lldb/source/Utility/ArchSpec.cpp
@@ -14,9 +14,9 @@
#include "lldb/lldb-defines.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/BinaryFormat/COFF.h"
-#include "llvm/BinaryFormat/XCOFF.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/BinaryFormat/MachO.h"
+#include "llvm/BinaryFormat/XCOFF.h"
#include "llvm/Support/Compiler.h"
#include "llvm/TargetParser/ARMTargetParser.h"
@@ -460,11 +460,11 @@ static const ArchDefinition g_coff_arch_def = {
"pe-coff",
};
-
static const ArchDefinitionEntry g_xcoff_arch_entries[] = {
- {ArchSpec::eCore_ppc_generic, llvm::XCOFF::TCPU_COM, LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu},
- {ArchSpec::eCore_ppc64_generic, llvm::XCOFF::TCPU_PPC64, LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu}
-};
+ {ArchSpec::eCore_ppc_generic, llvm::XCOFF::TCPU_COM, LLDB_INVALID_CPUTYPE,
+ 0xFFFFFFFFu, 0xFFFFFFFFu},
+ {ArchSpec::eCore_ppc64_generic, llvm::XCOFF::TCPU_PPC64,
+ LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu}};
static const ArchDefinition g_xcoff_arch_def = {
eArchTypeXCOFF,
@@ -473,7 +473,6 @@ static const ArchDefinition g_xcoff_arch_def = {
"xcoff",
};
-
//===----------------------------------------------------------------------===//
// Table of all ArchDefinitions
static const ArchDefinition *g_arch_definitions[] = {
@@ -919,8 +918,8 @@ bool ArchSpec::SetArchitecture(ArchitectureType arch_type, uint32_t cpu,
m_triple.setVendor(llvm::Triple::PC);
m_triple.setOS(llvm::Triple::Win32);
} else if (arch_type == eArchTypeXCOFF && os == llvm::Triple::AIX) {
- m_triple.setVendor(llvm::Triple::IBM);
- m_triple.setOS(llvm::Triple::AIX);
+ m_triple.setVendor(llvm::Triple::IBM);
+ m_triple.setOS(llvm::Triple::AIX);
} else {
m_triple.setVendor(llvm::Triple::UnknownVendor);
m_triple.setOS(llvm::Triple::UnknownOS);
>From fb6beb5a67b5a01586a8a782a31db6048eb6803d Mon Sep 17 00:00:00 2001
From: Dhruv-Srivastava <dhruv.srivastava at ibm.com>
Date: Wed, 21 Aug 2024 08:14:41 -0500
Subject: [PATCH 3/3] Added eArchTypeXCOFF
---
lldb/include/lldb/lldb-private-enumerations.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/lldb/include/lldb/lldb-private-enumerations.h b/lldb/include/lldb/lldb-private-enumerations.h
index c24a3538f58dac..98c1e956bf8f7b 100644
--- a/lldb/include/lldb/lldb-private-enumerations.h
+++ b/lldb/include/lldb/lldb-private-enumerations.h
@@ -65,6 +65,7 @@ enum ArchitectureType {
eArchTypeMachO,
eArchTypeELF,
eArchTypeCOFF,
+ eArchTypeXCOFF,
kNumArchTypes
};
More information about the lldb-commits
mailing list