[Lldb-commits] [lldb] [lldb][AArch64] Read fpmr register from core files (PR #110104)
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Thu Sep 26 03:46:00 PDT 2024
https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/110104
None
>From 58911927a59557aab167792f62f2c9ba9a86fa0d Mon Sep 17 00:00:00 2001
From: David Spickett <david.spickett at linaro.org>
Date: Thu, 29 Aug 2024 16:18:56 +0100
Subject: [PATCH] [lldb][AArch64] Read fpmr register from core files
---
.../RegisterContextPOSIXCore_arm64.cpp | 13 +++++++
.../elf-core/RegisterContextPOSIXCore_arm64.h | 1 +
.../Process/elf-core/RegisterUtilities.h | 4 +++
.../aarch64/fpmr/TestAArch64LinuxFPMR.py | 32 ++++++++++++++----
lldb/test/API/linux/aarch64/fpmr/corefile | Bin 0 -> 20480 bytes
lldb/test/API/linux/aarch64/fpmr/main.c | 5 ++-
6 files changed, 48 insertions(+), 7 deletions(-)
create mode 100644 lldb/test/API/linux/aarch64/fpmr/corefile
diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
index 413bf1bbdb2a58..2ddf8440aeb035 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
@@ -64,6 +64,11 @@ RegisterContextCorePOSIX_arm64::Create(Thread &thread, const ArchSpec &arch,
if (zt_data.GetByteSize() >= 64)
opt_regsets.Set(RegisterInfoPOSIX_arm64::eRegsetMaskZT);
+ DataExtractor fpmr_data =
+ getRegset(notes, arch.GetTriple(), AARCH64_FPMR_Desc);
+ if (fpmr_data.GetByteSize() >= sizeof(uint64_t))
+ opt_regsets.Set(RegisterInfoPOSIX_arm64::eRegsetMaskFPMR);
+
auto register_info_up =
std::make_unique<RegisterInfoPOSIX_arm64>(arch, opt_regsets);
return std::unique_ptr<RegisterContextCorePOSIX_arm64>(
@@ -128,6 +133,9 @@ RegisterContextCorePOSIX_arm64::RegisterContextCorePOSIX_arm64(
if (m_register_info_up->IsZTPresent())
m_zt_data = getRegset(notes, target_triple, AARCH64_ZT_Desc);
+ if (m_register_info_up->IsFPMRPresent())
+ m_fpmr_data = getRegset(notes, target_triple, AARCH64_FPMR_Desc);
+
ConfigureRegisterContext();
}
@@ -370,6 +378,11 @@ bool RegisterContextCorePOSIX_arm64::ReadRegister(const RegisterInfo *reg_info,
*reg_info, reinterpret_cast<uint8_t *>(&m_sme_pseudo_regs) + offset,
reg_info->byte_size, lldb_private::endian::InlHostByteOrder(), error);
}
+ } else if (IsFPMR(reg)) {
+ offset = reg_info->byte_offset - m_register_info_up->GetFPMROffset();
+ assert(offset < m_fpmr_data.GetByteSize());
+ value.SetFromMemoryData(*reg_info, m_fpmr_data.GetDataStart() + offset,
+ reg_info->byte_size, lldb::eByteOrderLittle, error);
} else
return false;
diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
index ff94845e58d602..35588c40c2eb1a 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
@@ -62,6 +62,7 @@ class RegisterContextCorePOSIX_arm64 : public RegisterContextPOSIX_arm64 {
lldb_private::DataExtractor m_za_data;
lldb_private::DataExtractor m_mte_data;
lldb_private::DataExtractor m_zt_data;
+ lldb_private::DataExtractor m_fpmr_data;
SVEState m_sve_state = SVEState::Unknown;
uint16_t m_sve_vector_length = 0;
diff --git a/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h b/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
index 12aa5f72371c51..b97279b0d735b8 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
+++ b/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
@@ -144,6 +144,10 @@ constexpr RegsetDesc AARCH64_MTE_Desc[] = {
llvm::ELF::NT_ARM_TAGGED_ADDR_CTRL},
};
+constexpr RegsetDesc AARCH64_FPMR_Desc[] = {
+ {llvm::Triple::Linux, llvm::Triple::aarch64, llvm::ELF::NT_ARM_FPMR},
+};
+
constexpr RegsetDesc PPC_VMX_Desc[] = {
{llvm::Triple::FreeBSD, llvm::Triple::UnknownArch, llvm::ELF::NT_PPC_VMX},
{llvm::Triple::Linux, llvm::Triple::UnknownArch, llvm::ELF::NT_PPC_VMX},
diff --git a/lldb/test/API/linux/aarch64/fpmr/TestAArch64LinuxFPMR.py b/lldb/test/API/linux/aarch64/fpmr/TestAArch64LinuxFPMR.py
index d022c8eb3d6cc4..7f8dc811c5df36 100644
--- a/lldb/test/API/linux/aarch64/fpmr/TestAArch64LinuxFPMR.py
+++ b/lldb/test/API/linux/aarch64/fpmr/TestAArch64LinuxFPMR.py
@@ -11,9 +11,13 @@
class AArch64LinuxFPMR(TestBase):
NO_DEBUG_INFO_TESTCASE = True
+ # The value set by the inferior.
+ EXPECTED_FPMR = (0b101010 << 32) | 0b101
+ EXPECTED_FPMR_FIELDS = ["LSCALE2 = 42", "F8S1 = FP8_E4M3 | 0x4"]
+
@skipUnlessArch("aarch64")
@skipUnlessPlatform(["linux"])
- def test_fpmr_register(self):
+ def test_fpmr_register_live(self):
if not self.isAArch64FPMR():
self.skipTest("FPMR must be present.")
@@ -39,16 +43,16 @@ def test_fpmr_register(self):
)
# This has been set by the program.
- expected_fpmr = (0b101010 << 32) | 0b101
self.expect(
"register read --all",
- substrs=["Floating Point Mode Register", f"fpmr = {expected_fpmr:#018x}"],
+ substrs=[
+ "Floating Point Mode Register",
+ f"fpmr = {self.EXPECTED_FPMR:#018x}",
+ ],
)
if self.hasXMLSupport():
- self.expect(
- "register read fpmr", substrs=["LSCALE2 = 42", "F8S1 = FP8_E4M3 | 0x4"]
- )
+ self.expect("register read fpmr", substrs=self.EXPECTED_FPMR_FIELDS)
# Write a value for the program to find. Same fields but with bit values
# inverted.
@@ -61,3 +65,19 @@ def test_fpmr_register(self):
# 0 means the program found the new value in the sysreg as expected.
self.expect("continue", substrs=["exited with status = 0"])
+
+ @skipIfLLVMTargetMissing("AArch64")
+ def test_fpmr_register_core(self):
+ if not self.isAArch64FPMR():
+ self.skipTest("FPMR must be present.")
+
+ self.runCmd("target create --core corefile")
+
+ self.expect(
+ "register read --all",
+ substrs=[
+ "Floating Point Mode Register",
+ f"fpmr = {self.EXPECTED_FPMR:#018x}",
+ ],
+ )
+ self.expect("register read fpmr", substrs=self.EXPECTED_FPMR_FIELDS)
diff --git a/lldb/test/API/linux/aarch64/fpmr/corefile b/lldb/test/API/linux/aarch64/fpmr/corefile
new file mode 100644
index 0000000000000000000000000000000000000000..8496b6a774df95ab24c4792ab41f78049430f606
GIT binary patch
literal 20480
zcmeHPZ){Y at 5g*?_+hCIiO_Y$N^@9-CP&gZcXlUB<e8zxPlOki<C~9)H&xdXNkKCOp
zNT?VKgNZ>v>4y-$xM?79)en3iX`M>Ng+K|W5{1%IDN@}00Y_8~p=ugP;@6pdGro7{
zbJH}9gv9P~Z+2#9c4mJ&yL*Scx23#tnI|g?r1;>MkmLX?X>d^s9tMMXAJajvOTkqg
z5ydop^5G|$Ne?QPdX9UDJyWt%K26aql}akjU>6__lhus>-YzxHzx>*^xeqtldym7p
z;#2~YmG-`$+3p&*yX;cN*Lgj&oi*MrWqgAZ*qNVVH#~ve;CQ<fTn7J<InE;<$Ivyt
zlsJulWwtZN`%A&4B+X9rg}VHyI4$mPRhk{^jU}|pPWfBKb~R~sEKcT=BgjIc#wT{2
z|D#>a?i(5N%t*zP#@2&Q$#2<rtI8<~HD0P<an~IQz)D=JA0Z=D<mq(XSJEY!d5Y*R
ze3P#^_|AE9kBU7nU?G<*H(y@*?f~pQyZ3b`$11*8T1^4}nN?&eYF13J#-yvg4yH9h
zhxV<$qH-vQ*EAypA3ov4LD*2amS3u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BQHKWca}=DL-((T($b47|<TFbBGZt$~>U16^+;^}#?gfAX3KagJ!rzr!&X
z-IdJcvhUai<;_W7GH*Qg1bKtwZuy1Pzm~_{h;{`yPqgMRS2$-TtDNaJL;WgWin7(%
zLzq{mFmEU?{5TewH~0EG<jR|q)`Pvj;d#1*RP7%gs6KIW)Cl0%X&;G}+eQP9U+pE+
zwpQ7=b|OYM;k<4J;!JDOLh3QMo_{X8?>b|6bP4BT-H0{trq?s)CicI=wZ01wC)#g_
z(%Q+yH%@ghtpCWi&*A;VFX0LMlaFm1*S)Hr{=~LVbN%S3ZNJKO`5gk;lgF<5^Ij?Y
z>j?Az9JSl2dJk?sROCDzW}fzBDyx{E<goBVrg9yZ&NC_)qUx`a&n*m7 at p6pGPmu_J
zjoTj+fz!<w_LR>j6FFF3R`w0EXiZ&5TcX2U99$SInK!>far1w)pd?tbFt}j0Bgf01
z at y2)}mZ+_RApQtIu(3AY2*LVIZShU54o$?ImJQKZys5n{g$dU~u&q52g<vAOF#*Ba
zmPAt<cGnR}plV!oP}|xRfncn?zBW+{!AN^+YqTvfQRJUZPWQTKt_60<2cdJhJ36na
z<TwPkUZ>E!e}Ho*_L4tBA7;IDdlswTnV~+!Uh+%mURET3lzQS{^6bkfqrSyn@>Qth
zC#tBz=_ at Qeh&5a?WARJ=36)<Ekod)q&;@8uxh=fpyHFWF#ZNjCKUP&K#V37K6#G7|
z2*m?Br3mgKT#gkQldMnqyeRZinnAk%m25BmFY)JAp(WyoX*zySvTwmh)|F6`4I~Wl
zFZ)pg`)9XM#NRK3n(SAI*bAjig<Pb^Dc?`NCWcHUem9la-KuepW20M$b+JnmYgQw0
HOCa!Xfmm<-
literal 0
HcmV?d00001
diff --git a/lldb/test/API/linux/aarch64/fpmr/main.c b/lldb/test/API/linux/aarch64/fpmr/main.c
index bdb7d8f40b64dd..518609035ec845 100644
--- a/lldb/test/API/linux/aarch64/fpmr/main.c
+++ b/lldb/test/API/linux/aarch64/fpmr/main.c
@@ -37,5 +37,8 @@ int main(int argc, char *argv[]) {
uint64_t new_fpmr = get_fpmr(); // Set break point at this line.
uint64_t expected_fpmr = ((uint64_t)0b010101 << 32) | (uint64_t)0b010;
- return new_fpmr == expected_fpmr ? 0 : 1;
+ if (new_fpmr != expected_fpmr)
+ __builtin_trap();
+
+ return 0;
}
More information about the lldb-commits
mailing list