[lldb] [llvm] [lldb] Extended if conditions to support alias names for registers (PR #124475)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 2 23:04:08 PST 2025
https://github.com/kper updated https://github.com/llvm/llvm-project/pull/124475
>From 096eb85718d70721cec1e539cfa4b05a96475c7a Mon Sep 17 00:00:00 2001
From: Kevin Per <kevin.per at protonmail.com>
Date: Sun, 26 Jan 2025 17:34:17 +0000
Subject: [PATCH 1/9] lldb: Extended if conditions to support alias names for
registers
---
.../Plugins/ABI/RISCV/ABISysV_riscv.cpp | 54 +++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
index 8412991933d277b..c463bd006b3db4c 100644
--- a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
+++ b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
@@ -850,8 +850,62 @@ void ABISysV_riscv::AugmentRegisterInfo(
it.value().alt_name.SetCString("x3");
else if (it.value().name == "fp")
it.value().alt_name.SetCString("s0");
+ else if (it.value().name == "tp")
+ it.value().alt_name.SetCString("x4");
else if (it.value().name == "s0")
it.value().alt_name.SetCString("x8");
+ else if (it.value().name == "s1")
+ it.value().alt_name.SetCString("x9");
+ else if (it.value().name == "t0")
+ it.value().alt_name.SetCString("x5");
+ else if (it.value().name == "t1")
+ it.value().alt_name.SetCString("x6");
+ else if (it.value().name == "t2")
+ it.value().alt_name.SetCString("x7");
+ else if (it.value().name == "a0")
+ it.value().alt_name.SetCString("x10");
+ else if (it.value().name == "a1")
+ it.value().alt_name.SetCString("x11");
+ else if (it.value().name == "a2")
+ it.value().alt_name.SetCString("x12");
+ else if (it.value().name == "a3")
+ it.value().alt_name.SetCString("x13");
+ else if (it.value().name == "a4")
+ it.value().alt_name.SetCString("x14");
+ else if (it.value().name == "a5")
+ it.value().alt_name.SetCString("x15");
+ else if (it.value().name == "a6")
+ it.value().alt_name.SetCString("x16");
+ else if (it.value().name == "a7")
+ it.value().alt_name.SetCString("x17");
+ else if (it.value().name == "s2")
+ it.value().alt_name.SetCString("x18");
+ else if (it.value().name == "s3")
+ it.value().alt_name.SetCString("x19");
+ else if (it.value().name == "s4")
+ it.value().alt_name.SetCString("x20");
+ else if (it.value().name == "s5")
+ it.value().alt_name.SetCString("x21");
+ else if (it.value().name == "s6")
+ it.value().alt_name.SetCString("x22");
+ else if (it.value().name == "s7")
+ it.value().alt_name.SetCString("x23");
+ else if (it.value().name == "s8")
+ it.value().alt_name.SetCString("x24");
+ else if (it.value().name == "s9")
+ it.value().alt_name.SetCString("x25");
+ else if (it.value().name == "s10")
+ it.value().alt_name.SetCString("x26");
+ else if (it.value().name == "s11")
+ it.value().alt_name.SetCString("x27");
+ else if (it.value().name == "t3")
+ it.value().alt_name.SetCString("x28");
+ else if (it.value().name == "t4")
+ it.value().alt_name.SetCString("x29");
+ else if (it.value().name == "t5")
+ it.value().alt_name.SetCString("x30");
+ else if (it.value().name == "t6")
+ it.value().alt_name.SetCString("x31");
// Set generic regnum so lldb knows what the PC, etc is
it.value().regnum_generic = GetGenericNum(it.value().name.GetStringRef());
>From ad3dfa270953a04f755773c402941fd10165a098 Mon Sep 17 00:00:00 2001
From: Kevin Per <kevin.per at protonmail.com>
Date: Tue, 28 Jan 2025 15:23:54 +0000
Subject: [PATCH 2/9] Added RISCV reg test for the ServerTargetXML
---
.../TestGDBServerTargetXML.py | 149 ++++++++++++++++++
1 file changed, 149 insertions(+)
diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
index 22f5553e40802d1..c74726a88aa6ff4 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -652,6 +652,155 @@ def haltReason(self):
)
self.match("register read s31", ["s31 = 128"])
+ @skipIfXmlSupportMissing
+ @skipIfRemote
+ @skipIfLLVMTargetMissing("RISCV")
+ def test_riscv64_regs(self):
+ """Test grabbing various riscv64 registers from gdbserver."""
+
+ class MyResponder(MockGDBServerResponder):
+ reg_data = (
+ (
+ "0102030405060708" # zero
+ "0102030405060708" # ra
+ "0102030405060708" # sp
+ "0102030405060708" # gp
+ "0102030405060708" # tp
+ "0102030405060708" # t0
+ "0102030405060708" # t1
+ "0102030405060708" # t2
+ "0102030405060708" # fp
+ "0102030405060708" # s1
+ "0102030405060708" # a0
+ "0102030405060708" # a1
+ "0102030405060708" # a2
+ "0102030405060708" # a3
+ "0102030405060708" # a4
+ "0102030405060708" # a5
+ "0102030405060708" # a6
+ "0102030405060708" # a7
+ "0102030405060708" # s2
+ "0102030405060708" # s3
+ "0102030405060708" # s4
+ "0102030405060708" # s5
+ "0102030405060708" # s6
+ "0102030405060708" # s7
+ "0102030405060708" # s8
+ "0102030405060708" # s9
+ "0102030405060708" # s10
+ "0102030405060708" # s11
+ "0102030405060708" # t3
+ "0102030405060708" # t4
+ "0102030405060708" # t5
+ "0102030405060708" # t6
+ )
+ )
+
+ def qXferRead(self, obj, annex, offset, length):
+ if annex == "target.xml":
+ return (
+ """<?xml version="1.0"?>
+ <!DOCTYPE feature SYSTEM "gdb-target.dtd">
+ <target>
+ <architecture>riscv</architecture>
+ <feature name="org.gnu.gdb.riscv.cpu">
+ <reg name="zero" bitsize="64" type="int"/>
+ <reg name="ra" bitsize="64" type="code_ptr"/>
+ <reg name="sp" bitsize="64" type="data_ptr"/>
+ <reg name="gp" bitsize="64" type="data_ptr"/>
+ <reg name="tp" bitsize="64" type="data_ptr"/>
+ <reg name="t0" bitsize="64" type="int"/>
+ <reg name="t1" bitsize="64" type="int"/>
+ <reg name="t2" bitsize="64" type="int"/>
+ <reg name="fp" bitsize="64" type="data_ptr"/>
+ <reg name="s1" bitsize="64" type="int"/>
+ <reg name="a0" bitsize="64" type="int"/>
+ <reg name="a1" bitsize="64" type="int"/>
+ <reg name="a2" bitsize="64" type="int"/>
+ <reg name="a3" bitsize="64" type="int"/>
+ <reg name="a4" bitsize="64" type="int"/>
+ <reg name="a5" bitsize="64" type="int"/>
+ <reg name="a6" bitsize="64" type="int"/>
+ <reg name="a7" bitsize="64" type="int"/>
+ <reg name="s2" bitsize="64" type="int"/>
+ <reg name="s3" bitsize="64" type="int"/>
+ <reg name="s4" bitsize="64" type="int"/>
+ <reg name="s5" bitsize="64" type="int"/>
+ <reg name="s6" bitsize="64" type="int"/>
+ <reg name="s7" bitsize="64" type="int"/>
+ <reg name="s8" bitsize="64" type="int"/>
+ <reg name="s9" bitsize="64" type="int"/>
+ <reg name="s10" bitsize="64" type="int"/>
+ <reg name="s11" bitsize="64" type="int"/>
+ <reg name="t3" bitsize="64" type="int"/>
+ <reg name="t4" bitsize="64" type="int"/>
+ <reg name="t5" bitsize="64" type="int"/>
+ <reg name="t6" bitsize="64" type="int"/>
+ <reg name="pc" bitsize="64" type="code_ptr"/>
+ </feature>
+ </target>""",
+ False,
+ )
+ else:
+ return None, False
+
+ def readRegister(self, regnum):
+ return ""
+
+ def readRegisters(self):
+ return self.reg_data
+
+ def writeRegisters(self, reg_hex):
+ self.reg_data = reg_hex
+ return "OK"
+
+ def haltReason(self):
+ return "T02thread:1ff0d;threads:1ff0d;thread-pcs:000000010001bc00;07:0102030405060708;10:1112131415161718;"
+
+ self.server.responder = MyResponder()
+
+ target = self.createTarget("basic_eh_frame-riscv64.yaml")
+ process = self.connect(target)
+ lldbutil.expect_state_changes(
+ self, self.dbg.GetListener(), process, [lldb.eStateStopped]
+ )
+
+ # test generic aliases
+ self.match("register read x0", ["zero = 0x0807060504030201"])
+ self.match("register read x1", ["ra = 0x0807060504030201"])
+ self.match("register read x2", ["sp = 0x0807060504030201"])
+ self.match("register read x3", ["gp = 0x0807060504030201"])
+ self.match("register read x4", ["tp = 0x0807060504030201"])
+ self.match("register read x5", ["t0 = 0x0807060504030201"])
+ self.match("register read x6", ["t1 = 0x0807060504030201"])
+ self.match("register read x7", ["t2 = 0x0807060504030201"])
+ # Register x8 is probably not working because it has two aliases fp, s0
+ # self.match("register read x8", ["fp = 0x0807060504030201"])
+ self.match("register read x9", ["s1 = 0x0807060504030201"])
+ self.match("register read x10", ["a0 = 0x0807060504030201"])
+ self.match("register read x11", ["a1 = 0x0807060504030201"])
+ self.match("register read x12", ["a2 = 0x0807060504030201"])
+ self.match("register read x13", ["a3 = 0x0807060504030201"])
+ self.match("register read x14", ["a4 = 0x0807060504030201"])
+ self.match("register read x15", ["a5 = 0x0807060504030201"])
+ self.match("register read x16", ["a6 = 0x0807060504030201"])
+ self.match("register read x17", ["a7 = 0x0807060504030201"])
+ self.match("register read x18", ["s2 = 0x0807060504030201"])
+ self.match("register read x19", ["s3 = 0x0807060504030201"])
+ self.match("register read x20", ["s4 = 0x0807060504030201"])
+ self.match("register read x21", ["s5 = 0x0807060504030201"])
+ self.match("register read x22", ["s6 = 0x0807060504030201"])
+ self.match("register read x23", ["s7 = 0x0807060504030201"])
+ self.match("register read x24", ["s8 = 0x0807060504030201"])
+ self.match("register read x25", ["s9 = 0x0807060504030201"])
+ self.match("register read x26", ["s10 = 0x0807060504030201"])
+ self.match("register read x27", ["s11 = 0x0807060504030201"])
+ self.match("register read x28", ["t3 = 0x0807060504030201"])
+ self.match("register read x29", ["t4 = 0x0807060504030201"])
+ self.match("register read x30", ["t5 = 0x0807060504030201"])
+ self.match("register read x31", ["t6 = 0x0807060504030201"])
+
+
@skipIfXmlSupportMissing
@skipIfRemote
@skipIfLLVMTargetMissing("X86")
>From be1c2a0b1b2014b66fe0f4418230395a25016cc8 Mon Sep 17 00:00:00 2001
From: Kevin Per <kevin.per at protonmail.com>
Date: Tue, 28 Jan 2025 16:28:52 +0000
Subject: [PATCH 3/9] Extended tests to check the aliases
---
.../postmortem/elf-core/TestLinuxCore.py | 145 ++++++++++++++++++
1 file changed, 145 insertions(+)
diff --git a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
index 376d6492d83b604..4c3391565277a39 100644
--- a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
+++ b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
@@ -704,39 +704,105 @@ def test_riscv64_regs_gpr_fpr(self):
process = target.LoadCore("linux-riscv64.gpr_fpr.core")
values = {}
+ alias = {}
values["pc"] = "0x000000000001016e"
+
values["ra"] = "0x00000000000101a4"
+ alias["x1"] = "ra"
+
values["sp"] = "0x0000003fffc1d2d0"
+ alias["x2"] = "sp"
+
values["gp"] = "0x0000002ae6eccf50"
+ alias["x3"] = "gp"
+
values["tp"] = "0x0000003ff3cb5400"
+ alias["x4"] = "tp"
+
values["t0"] = "0x7f7f7f7fffffffff"
+ alias["x5"] = "t0"
+
values["t1"] = "0x0000002ae6eb9b1c"
+ alias["x6"] = "t1"
+
values["t2"] = "0xffffffffffffffff"
+ alias["x7"] = "t2"
+
values["fp"] = "0x0000003fffc1d300"
+ alias["x8"] = "fp"
+
values["s1"] = "0x0000002ae6eced98"
+ alias["x9"] = "s1"
+
values["a0"] = "0x0"
+ alias["x10"] = "a0"
+
values["a1"] = "0x0000000000010144"
+ alias["x11"] = "a1"
+
values["a2"] = "0x0000002ae6ecedb0"
+ alias["x12"] = "a2"
+
values["a3"] = "0xafdbdbff81cf7f81"
+ alias["x13"] = "a3"
+
values["a4"] = "0x00000000000101e4"
+ alias["x14"] = "a4"
+
values["a5"] = "0x0"
+ alias["x15"] = "a5"
+
values["a6"] = "0x2f5b5a40014e0001"
+ alias["x16"] = "a6"
+
values["a7"] = "0x00000000000000dd"
+ alias["x17"] = "a7"
+
values["s2"] = "0x0000002ae6ec8860"
+ alias["x18"] = "s2"
+
values["s3"] = "0x0000002ae6ecedb0"
+ alias["x19"] = "s3"
+
values["s4"] = "0x0000003fff886c18"
+ alias["x20"] = "s4"
+
values["s5"] = "0x0000002ae6eceb78"
+ alias["x21"] = "s5"
+
values["s6"] = "0x0000002ae6ec8860"
+ alias["x22"] = "s6"
+
values["s7"] = "0x0000002ae6ec8860"
+ alias["x23"] = "s7"
+
values["s8"] = "0x0"
+ alias["x24"] = "s8"
+
values["s9"] = "0x000000000000000f"
+ alias["x25"] = "s9"
+
values["s10"] = "0x0000002ae6ecc8d0"
+ alias["x26"] = "s10"
+
values["s11"] = "0x0000000000000008"
+ alias["x27"] = "s11"
+
values["t3"] = "0x0000003ff3be3728"
+ alias["x28"] = "t3"
+
values["t4"] = "0x0"
+ alias["x29"] = "t4"
+
values["t5"] = "0x0000000000000002"
+ alias["x30"] = "t5"
+
values["t6"] = "0x0000002ae6ed08b9"
+ alias["x31"] = "t6"
+
values["zero"] = "0x0"
+ alias["x0"] = "zero"
+
values["fa5"] = "0xffffffff423c0000"
values["fcsr"] = "0x00000000"
@@ -788,6 +854,13 @@ def test_riscv64_regs_gpr_fpr(self):
substrs=["{} = {}".format(regname, fpr_value)],
)
+ for aliasname, regname in alias.items():
+ value = values[regname]
+ self.expect(
+ "register read {}".format(aliasname),
+ substrs=["{} = {}".format(regname, value)],
+ )
+
self.expect("register read --all")
@skipIfLLVMTargetMissing("RISCV")
@@ -798,39 +871,104 @@ def test_riscv64_regs_gpr_only(self):
process = target.LoadCore("linux-riscv64.gpr_only.core")
values = {}
+ alias = {}
values["pc"] = "0x0000000000010164"
+
values["ra"] = "0x0000000000010194"
+ alias["x1"] = "ra"
+
values["sp"] = "0x00fffffff4d5fcc0"
+ alias["x2"] = "sp"
+
values["gp"] = "0x0000000000157678"
+ alias["x3"] = "gp"
+
values["tp"] = "0x00ffffff99c43400"
+ alias["x4"] = "tp"
+
values["t0"] = "0x00ffffff99c6b260"
+ alias["x5"] = "t0"
+
values["t1"] = "0x00ffffff99b7bd54"
+ alias["x6"] = "t1"
+
values["t2"] = "0x0000000003f0b27f"
+ alias["x7"] = "t2"
+
values["fp"] = "0x00fffffff4d5fcf0"
+ alias["x8"] = "fp"
+
values["s1"] = "0x0000000000000003"
+ alias["x9"] = "s1"
+
values["a0"] = "0x0"
+ alias["x10"] = "a0"
+
values["a1"] = "0x0000000000010144"
+ alias["x11"] = "a1"
+
values["a2"] = "0x0000000000176460"
+ alias["x12"] = "a2"
+
values["a3"] = "0x000000000015ee38"
+ alias["x13"] = "a3"
+
values["a4"] = "0x00000000423c0000"
+ alias["x14"] = "a4"
+
values["a5"] = "0x0"
+ alias["x15"] = "a5"
+
values["a6"] = "0x0"
+ alias["x16"] = "a6"
+
values["a7"] = "0x00000000000000dd"
+ alias["x17"] = "a7"
+
values["s2"] = "0x0"
+ alias["x18"] = "s2"
+
values["s3"] = "0x000000000014ddf8"
+ alias["x19"] = "s3"
+
values["s4"] = "0x000000000003651c"
+ alias["x20"] = "s4"
+
values["s5"] = "0x00fffffffccd8d28"
+ alias["x21"] = "s5"
+
values["s6"] = "0x000000000014ddf8"
+ alias["x22"] = "s6"
+
values["s7"] = "0x00ffffff99c69d48"
+ alias["x23"] = "s7"
+
values["s8"] = "0x00ffffff99c6a008"
+ alias["x24"] = "s8"
+
values["s9"] = "0x0"
+ alias["x25"] = "s9"
+
values["s10"] = "0x0"
+ alias["x26"] = "s10"
+
values["s11"] = "0x0"
+ alias["x27"] = "s11"
+
values["t3"] = "0x00ffffff99c42000"
+ alias["x28"] = "t3"
+
values["t4"] = "0x00ffffff99af8e20"
+ alias["x29"] = "t4"
+
values["t5"] = "0x0000000000000005"
+ alias["x30"] = "t5"
+
values["t6"] = "0x44760bdd8d5f6381"
+ alias["x31"] = "t6"
+
values["zero"] = "0x0"
+ alias["x0"] = "zero"
for regname, value in values.items():
self.expect(
@@ -838,6 +976,13 @@ def test_riscv64_regs_gpr_only(self):
substrs=["{} = {}".format(regname, value)],
)
+ for aliasname, regname in alias.items():
+ value = values[regname]
+ self.expect(
+ "register read {}".format(aliasname),
+ substrs=["{} = {}".format(regname, value)],
+ )
+
# Check that LLDB does not try to read other registers from core file
self.expect(
"register read --all",
>From 580da5b763a6722d63ea9e43fc039c9b6b44fbce Mon Sep 17 00:00:00 2001
From: Kevin Per <kevin.per at protonmail.com>
Date: Wed, 29 Jan 2025 07:36:47 +0000
Subject: [PATCH 4/9] Fixed formatting
---
.../TestGDBServerTargetXML.py | 66 +++++++++----------
1 file changed, 32 insertions(+), 34 deletions(-)
diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
index c74726a88aa6ff4..a27db7584e6c5ff 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -660,40 +660,38 @@ def test_riscv64_regs(self):
class MyResponder(MockGDBServerResponder):
reg_data = (
- (
- "0102030405060708" # zero
- "0102030405060708" # ra
- "0102030405060708" # sp
- "0102030405060708" # gp
- "0102030405060708" # tp
- "0102030405060708" # t0
- "0102030405060708" # t1
- "0102030405060708" # t2
- "0102030405060708" # fp
- "0102030405060708" # s1
- "0102030405060708" # a0
- "0102030405060708" # a1
- "0102030405060708" # a2
- "0102030405060708" # a3
- "0102030405060708" # a4
- "0102030405060708" # a5
- "0102030405060708" # a6
- "0102030405060708" # a7
- "0102030405060708" # s2
- "0102030405060708" # s3
- "0102030405060708" # s4
- "0102030405060708" # s5
- "0102030405060708" # s6
- "0102030405060708" # s7
- "0102030405060708" # s8
- "0102030405060708" # s9
- "0102030405060708" # s10
- "0102030405060708" # s11
- "0102030405060708" # t3
- "0102030405060708" # t4
- "0102030405060708" # t5
- "0102030405060708" # t6
- )
+ "0102030405060708" # zero
+ "0102030405060708" # ra
+ "0102030405060708" # sp
+ "0102030405060708" # gp
+ "0102030405060708" # tp
+ "0102030405060708" # t0
+ "0102030405060708" # t1
+ "0102030405060708" # t2
+ "0102030405060708" # fp
+ "0102030405060708" # s1
+ "0102030405060708" # a0
+ "0102030405060708" # a1
+ "0102030405060708" # a2
+ "0102030405060708" # a3
+ "0102030405060708" # a4
+ "0102030405060708" # a5
+ "0102030405060708" # a6
+ "0102030405060708" # a7
+ "0102030405060708" # s2
+ "0102030405060708" # s3
+ "0102030405060708" # s4
+ "0102030405060708" # s5
+ "0102030405060708" # s6
+ "0102030405060708" # s7
+ "0102030405060708" # s8
+ "0102030405060708" # s9
+ "0102030405060708" # s10
+ "0102030405060708" # s11
+ "0102030405060708" # t3
+ "0102030405060708" # t4
+ "0102030405060708" # t5
+ "0102030405060708" # t6
)
def qXferRead(self, obj, annex, offset, length):
>From 460094ec2a286bf57116b8aa80352d1ccc418d1d Mon Sep 17 00:00:00 2001
From: Kevin Per <kevin.per at protonmail.com>
Date: Wed, 29 Jan 2025 07:55:26 +0000
Subject: [PATCH 5/9] Removed empty spaces
---
.../gdb_remote_client/TestGDBServerTargetXML.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
index a27db7584e6c5ff..4a1a13096be652e 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -665,10 +665,10 @@ class MyResponder(MockGDBServerResponder):
"0102030405060708" # sp
"0102030405060708" # gp
"0102030405060708" # tp
- "0102030405060708" # t0
+ "0102030405060708" # t0
"0102030405060708" # t1
"0102030405060708" # t2
- "0102030405060708" # fp
+ "0102030405060708" # fp
"0102030405060708" # s1
"0102030405060708" # a0
"0102030405060708" # a1
>From 4affdd33a67b6a18a9370b0e5f6897d6bb864cf9 Mon Sep 17 00:00:00 2001
From: Kevin Per <kevin.per at protonmail.com>
Date: Wed, 29 Jan 2025 08:01:33 +0000
Subject: [PATCH 6/9] Removed empty line
---
.../functionalities/gdb_remote_client/TestGDBServerTargetXML.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
index 4a1a13096be652e..983a310ff3934f7 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -798,7 +798,6 @@ def haltReason(self):
self.match("register read x30", ["t5 = 0x0807060504030201"])
self.match("register read x31", ["t6 = 0x0807060504030201"])
-
@skipIfXmlSupportMissing
@skipIfRemote
@skipIfLLVMTargetMissing("X86")
>From 5e8fe4dce6eaa68a28da0580f08eda311959b98e Mon Sep 17 00:00:00 2001
From: Kevin Per <kevin.per at protonmail.com>
Date: Wed, 29 Jan 2025 08:43:49 +0000
Subject: [PATCH 7/9] Added riscv64 eh_frame
---
.../basic_eh_frame-riscv64.yaml | 20 +++++++++++++++++++
1 file changed, 20 insertions(+)
create mode 100644 lldb/test/API/functionalities/gdb_remote_client/basic_eh_frame-riscv64.yaml
diff --git a/lldb/test/API/functionalities/gdb_remote_client/basic_eh_frame-riscv64.yaml b/lldb/test/API/functionalities/gdb_remote_client/basic_eh_frame-riscv64.yaml
new file mode 100644
index 000000000000000..50cdd23f42667ce
--- /dev/null
+++ b/lldb/test/API/functionalities/gdb_remote_client/basic_eh_frame-riscv64.yaml
@@ -0,0 +1,20 @@
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_RISCV
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ Address: 0x0000000000000570
+ AddressAlign: 0x0000000000000004
+ Content: DEADBEEF
+ - Name: .eh_frame
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC ]
+ Address: 0x0000000000000688
+ AddressAlign: 0x0000000000000008
+ Content: 000006881000000000000000037a5200017c0101000006981b0d02001000000018000000ccfeffff000006a82200000000070100200000002c000000000006b89cffffff1000000000420e1042880242000006c80c080046c80c0210420e000000000000
+...
>From 918fe26686a6c57ba3e5e20f890b0851a977e439 Mon Sep 17 00:00:00 2001
From: Kevin Per <kevin.per at protonmail.com>
Date: Thu, 30 Jan 2025 08:14:35 +0000
Subject: [PATCH 8/9] Addressed feedback
---
.../TestGDBServerTargetXML.py | 1 +
.../postmortem/elf-core/TestLinuxCore.py | 303 +++++-------------
2 files changed, 87 insertions(+), 217 deletions(-)
diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
index 983a310ff3934f7..cf82f7f168c2062 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -696,6 +696,7 @@ class MyResponder(MockGDBServerResponder):
def qXferRead(self, obj, annex, offset, length):
if annex == "target.xml":
+ # Note that this XML does not include any aliases, LLDB must generate them itself.
return (
"""<?xml version="1.0"?>
<!DOCTYPE feature SYSTEM "gdb-target.dtd">
diff --git a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
index 4c3391565277a39..eacbabc55e9dfeb 100644
--- a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
+++ b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
@@ -703,108 +703,43 @@ def test_riscv64_regs_gpr_fpr(self):
self.assertTrue(target, VALID_TARGET)
process = target.LoadCore("linux-riscv64.gpr_fpr.core")
- values = {}
- alias = {}
- values["pc"] = "0x000000000001016e"
-
- values["ra"] = "0x00000000000101a4"
- alias["x1"] = "ra"
-
- values["sp"] = "0x0000003fffc1d2d0"
- alias["x2"] = "sp"
-
- values["gp"] = "0x0000002ae6eccf50"
- alias["x3"] = "gp"
-
- values["tp"] = "0x0000003ff3cb5400"
- alias["x4"] = "tp"
-
- values["t0"] = "0x7f7f7f7fffffffff"
- alias["x5"] = "t0"
-
- values["t1"] = "0x0000002ae6eb9b1c"
- alias["x6"] = "t1"
-
- values["t2"] = "0xffffffffffffffff"
- alias["x7"] = "t2"
-
- values["fp"] = "0x0000003fffc1d300"
- alias["x8"] = "fp"
-
- values["s1"] = "0x0000002ae6eced98"
- alias["x9"] = "s1"
-
- values["a0"] = "0x0"
- alias["x10"] = "a0"
-
- values["a1"] = "0x0000000000010144"
- alias["x11"] = "a1"
-
- values["a2"] = "0x0000002ae6ecedb0"
- alias["x12"] = "a2"
-
- values["a3"] = "0xafdbdbff81cf7f81"
- alias["x13"] = "a3"
-
- values["a4"] = "0x00000000000101e4"
- alias["x14"] = "a4"
-
- values["a5"] = "0x0"
- alias["x15"] = "a5"
-
- values["a6"] = "0x2f5b5a40014e0001"
- alias["x16"] = "a6"
-
- values["a7"] = "0x00000000000000dd"
- alias["x17"] = "a7"
-
- values["s2"] = "0x0000002ae6ec8860"
- alias["x18"] = "s2"
-
- values["s3"] = "0x0000002ae6ecedb0"
- alias["x19"] = "s3"
-
- values["s4"] = "0x0000003fff886c18"
- alias["x20"] = "s4"
-
- values["s5"] = "0x0000002ae6eceb78"
- alias["x21"] = "s5"
-
- values["s6"] = "0x0000002ae6ec8860"
- alias["x22"] = "s6"
-
- values["s7"] = "0x0000002ae6ec8860"
- alias["x23"] = "s7"
-
- values["s8"] = "0x0"
- alias["x24"] = "s8"
-
- values["s9"] = "0x000000000000000f"
- alias["x25"] = "s9"
-
- values["s10"] = "0x0000002ae6ecc8d0"
- alias["x26"] = "s10"
-
- values["s11"] = "0x0000000000000008"
- alias["x27"] = "s11"
-
- values["t3"] = "0x0000003ff3be3728"
- alias["x28"] = "t3"
-
- values["t4"] = "0x0"
- alias["x29"] = "t4"
-
- values["t5"] = "0x0000000000000002"
- alias["x30"] = "t5"
-
- values["t6"] = "0x0000002ae6ed08b9"
- alias["x31"] = "t6"
-
- values["zero"] = "0x0"
- alias["x0"] = "zero"
-
- values["fa5"] = "0xffffffff423c0000"
- values["fcsr"] = "0x00000000"
+ values = {
+ "pc": ( "0x000000000001016e", None ),
+ "zero": ( "0x0", "x0" ),
+ "ra": ( "0x00000000000101a4", "x1" ),
+ "sp": ( "0x0000003fffc1d2d0", "x2" ),
+ "gp": ( "0x0000002ae6eccf50", "x3" ),
+ "tp": ( "0x0000003ff3cb5400", "x4" ),
+ "t0": ( "0x7f7f7f7fffffffff", "x5" ),
+ "t1": ( "0x0000002ae6eb9b1c", "x6" ),
+ "t2": ( "0xffffffffffffffff", "x7" ),
+ "fp": ( "0x0000003fffc1d300", "x8" ),
+ "s1": ( "0x0000002ae6eced98", "x9" ),
+ "a0": ( "0x0000000000000000", "x10" ),
+ "a1": ( "0x0000000000010144", "x11" ),
+ "a2": ( "0x0000002ae6ecedb0", "x12" ),
+ "a3": ( "0xafdbdbff81cf7f81", "x13" ),
+ "a4": ( "0x00000000000101e4", "x14" ),
+ "a5": ( "0x0000000000000000", "x15" ),
+ "a6": ( "0x2f5b5a40014e0001", "x16" ),
+ "a7": ( "0x00000000000000dd", "x17" ),
+ "s2": ( "0x0000002ae6ec8860", "x18" ),
+ "s3": ( "0x0000002ae6ecedb0", "x19" ),
+ "s4": ( "0x0000003fff886c18", "x20" ),
+ "s5": ( "0x0000002ae6eceb78", "x21" ),
+ "s6": ( "0x0000002ae6ec8860", "x22" ),
+ "s7": ( "0x0000002ae6ec8860", "x23" ),
+ "s8": ( "0x0000000000000000", "x24" ),
+ "s9": ( "0x000000000000000f", "x25" ),
+ "s10": ( "0x0000002ae6ecc8d0", "x26" ),
+ "s11": ( "0x0000000000000008", "x27" ),
+ "t3": ( "0x0000003ff3be3728", "x28" ),
+ "t4": ( "0x0000000000000000", "x29" ),
+ "t5": ( "0x0000000000000002", "x30" ),
+ "t6": ( "0x0000002ae6ed08b9", "x31" ),
+ "fa5": ( "0xffffffff423c0000", None),
+ "fcsr": ( "0x00000000", None)
+ }
fpr_names = {
"ft0",
@@ -842,11 +777,17 @@ def test_riscv64_regs_gpr_fpr(self):
}
fpr_value = "0x0000000000000000"
- for regname, value in values.items():
+ for regname in values:
+ value, alias = values[regname]
self.expect(
"register read {}".format(regname),
substrs=["{} = {}".format(regname, value)],
)
+ if alias:
+ self.expect(
+ "register read {}".format(alias),
+ substrs=["{} = {}".format(regname, value)],
+ )
for regname in fpr_names:
self.expect(
@@ -854,13 +795,6 @@ def test_riscv64_regs_gpr_fpr(self):
substrs=["{} = {}".format(regname, fpr_value)],
)
- for aliasname, regname in alias.items():
- value = values[regname]
- self.expect(
- "register read {}".format(aliasname),
- substrs=["{} = {}".format(regname, value)],
- )
-
self.expect("register read --all")
@skipIfLLVMTargetMissing("RISCV")
@@ -870,118 +804,53 @@ def test_riscv64_regs_gpr_only(self):
self.assertTrue(target, VALID_TARGET)
process = target.LoadCore("linux-riscv64.gpr_only.core")
- values = {}
- alias = {}
- values["pc"] = "0x0000000000010164"
-
- values["ra"] = "0x0000000000010194"
- alias["x1"] = "ra"
-
- values["sp"] = "0x00fffffff4d5fcc0"
- alias["x2"] = "sp"
-
- values["gp"] = "0x0000000000157678"
- alias["x3"] = "gp"
-
- values["tp"] = "0x00ffffff99c43400"
- alias["x4"] = "tp"
-
- values["t0"] = "0x00ffffff99c6b260"
- alias["x5"] = "t0"
-
- values["t1"] = "0x00ffffff99b7bd54"
- alias["x6"] = "t1"
-
- values["t2"] = "0x0000000003f0b27f"
- alias["x7"] = "t2"
-
- values["fp"] = "0x00fffffff4d5fcf0"
- alias["x8"] = "fp"
-
- values["s1"] = "0x0000000000000003"
- alias["x9"] = "s1"
-
- values["a0"] = "0x0"
- alias["x10"] = "a0"
-
- values["a1"] = "0x0000000000010144"
- alias["x11"] = "a1"
-
- values["a2"] = "0x0000000000176460"
- alias["x12"] = "a2"
-
- values["a3"] = "0x000000000015ee38"
- alias["x13"] = "a3"
-
- values["a4"] = "0x00000000423c0000"
- alias["x14"] = "a4"
-
- values["a5"] = "0x0"
- alias["x15"] = "a5"
-
- values["a6"] = "0x0"
- alias["x16"] = "a6"
-
- values["a7"] = "0x00000000000000dd"
- alias["x17"] = "a7"
-
- values["s2"] = "0x0"
- alias["x18"] = "s2"
-
- values["s3"] = "0x000000000014ddf8"
- alias["x19"] = "s3"
-
- values["s4"] = "0x000000000003651c"
- alias["x20"] = "s4"
-
- values["s5"] = "0x00fffffffccd8d28"
- alias["x21"] = "s5"
-
- values["s6"] = "0x000000000014ddf8"
- alias["x22"] = "s6"
-
- values["s7"] = "0x00ffffff99c69d48"
- alias["x23"] = "s7"
-
- values["s8"] = "0x00ffffff99c6a008"
- alias["x24"] = "s8"
-
- values["s9"] = "0x0"
- alias["x25"] = "s9"
-
- values["s10"] = "0x0"
- alias["x26"] = "s10"
-
- values["s11"] = "0x0"
- alias["x27"] = "s11"
-
- values["t3"] = "0x00ffffff99c42000"
- alias["x28"] = "t3"
-
- values["t4"] = "0x00ffffff99af8e20"
- alias["x29"] = "t4"
-
- values["t5"] = "0x0000000000000005"
- alias["x30"] = "t5"
-
- values["t6"] = "0x44760bdd8d5f6381"
- alias["x31"] = "t6"
-
- values["zero"] = "0x0"
- alias["x0"] = "zero"
+ values = {
+ "pc": ( "0x0000000000010164", None ),
+ "zero": ( "0x0", "x0" ),
+ "ra": ( "0x0000000000010194", "x1" ),
+ "sp": ( "0x00fffffff4d5fcc0", "x2" ),
+ "gp": ( "0x0000000000157678", "x3" ),
+ "tp": ( "0x00ffffff99c43400", "x4" ),
+ "t0": ( "0x00ffffff99c6b260", "x5" ),
+ "t1": ( "0x00ffffff99b7bd54", "x6" ),
+ "t2": ( "0x0000000003f0b27f", "x7" ),
+ "fp": ( "0x00fffffff4d5fcf0", "x8" ),
+ "s1": ( "0x0000000000000003", "x9" ),
+ "a0": ( "0x0", "x10" ),
+ "a1": ( "0x0000000000010144", "x11" ),
+ "a2": ( "0x0000000000176460", "x12" ),
+ "a3": ( "0x000000000015ee38", "x13" ),
+ "a4": ( "0x00000000423c0000", "x14" ),
+ "a5": ( "0x0", "x15" ),
+ "a6": ( "0x0", "x16" ),
+ "a7": ( "0x00000000000000dd", "x17" ),
+ "s2": ( "0x0", "x18" ),
+ "s3": ( "0x000000000014ddf8", "x19" ),
+ "s4": ( "0x000000000003651c", "x20" ),
+ "s5": ( "0x00fffffffccd8d28", "x21" ),
+ "s6": ( "0x000000000014ddf8", "x22" ),
+ "s7": ( "0x00ffffff99c69d48", "x23" ),
+ "s8": ( "0x00ffffff99c6a008", "x24" ),
+ "s9": ( "0x0", "x25" ),
+ "s10": ( "0x0", "x26" ),
+ "s11": ( "0x0", "x27" ),
+ "t3": ( "0x00ffffff99c42000", "x28" ),
+ "t4": ( "0x00ffffff99af8e20", "x29" ),
+ "t5": ( "0x0000000000000005", "x30" ),
+ "t6": ( "0x44760bdd8d5f6381", "x31" ),
+ }
- for regname, value in values.items():
+ for regname in values:
+ value, alias = values[regname]
self.expect(
"register read {}".format(regname),
substrs=["{} = {}".format(regname, value)],
)
-
- for aliasname, regname in alias.items():
- value = values[regname]
- self.expect(
- "register read {}".format(aliasname),
- substrs=["{} = {}".format(regname, value)],
- )
+ if alias:
+ self.expect(
+ "register read {}".format(alias),
+ substrs=["{} = {}".format(regname, value)],
+ )
# Check that LLDB does not try to read other registers from core file
self.expect(
>From eae031960c096ac00acf194e477ed6cba35bb63c Mon Sep 17 00:00:00 2001
From: Kevin Per <kevin.per at protonmail.com>
Date: Mon, 3 Feb 2025 07:02:22 +0000
Subject: [PATCH 9/9] Created live process test
---
.../Shell/Register/Inputs/riscv64-gp-read.cpp | 38 +++++++++++++++++++
lldb/test/Shell/Register/riscv64-gp-read.test | 38 +++++++++++++++++++
llvm/utils/lit/lit/llvm/config.py | 7 +++-
3 files changed, 82 insertions(+), 1 deletion(-)
create mode 100644 lldb/test/Shell/Register/Inputs/riscv64-gp-read.cpp
create mode 100644 lldb/test/Shell/Register/riscv64-gp-read.test
diff --git a/lldb/test/Shell/Register/Inputs/riscv64-gp-read.cpp b/lldb/test/Shell/Register/Inputs/riscv64-gp-read.cpp
new file mode 100644
index 000000000000000..ecc441a1231ca6c
--- /dev/null
+++ b/lldb/test/Shell/Register/Inputs/riscv64-gp-read.cpp
@@ -0,0 +1,38 @@
+int main() {
+ asm volatile(
+ "li x0, 0\n\t"
+ "li x1, 1\n\t"
+ "li x2, 2\n\t"
+ "li x3, 3\n\t"
+ "li x4, 4\n\t"
+ "li x5, 5\n\t"
+ "li x6, 6\n\t"
+ "li x7, 7\n\t"
+ "li x8, 8\n\t"
+ "li x9, 9\n\t"
+ "li x10, 10\n\t"
+ "li x11, 11\n\t"
+ "li x12, 12\n\t"
+ "li x13, 13\n\t"
+ "li x14, 14\n\t"
+ "li x15, 15\n\t"
+ "li x16, 16\n\t"
+ "li x17, 17\n\t"
+ "li x18, 18\n\t"
+ "li x19, 19\n\t"
+ "li x20, 20\n\t"
+ "li x21, 21\n\t"
+ "li x22, 22\n\t"
+ "li x23, 23\n\t"
+ "li x24, 24\n\t"
+ "li x25, 25\n\t"
+ "li x26, 26\n\t"
+ "li x27, 27\n\t"
+ "li x28, 28\n\t"
+ "li x29, 29\n\t"
+ "li x30, 30\n\t"
+ "li x31, 31\n\t"
+ );
+
+ return 0;
+}
diff --git a/lldb/test/Shell/Register/riscv64-gp-read.test b/lldb/test/Shell/Register/riscv64-gp-read.test
new file mode 100644
index 000000000000000..b013aab6355594c
--- /dev/null
+++ b/lldb/test/Shell/Register/riscv64-gp-read.test
@@ -0,0 +1,38 @@
+# REQUIRES: native && target-riscv64
+# RUN: %clangxx_host -fomit-frame-pointer %p/Inputs/riscv64-gp-read.cpp -o %t
+# RUN: %lldb -b -s %s %t | FileCheck %s
+process launch
+
+register read --all
+# CHECK-DAG: x0 = 0x0
+# CHECK-DAG: x1 = 0x1
+# CHECK-DAG: x2 = 0x2
+# CHECK-DAG: x3 = 0x3
+# CHECK-DAG: x4 = 0x4
+# CHECK-DAG: x5 = 0x5
+# CHECK-DAG: x6 = 0x6
+# CHECK-DAG: x7 = 0x7
+# CHECK-DAG: x8 = 0x8
+# CHECK-DAG: x9 = 0x9
+# CHECK-DAG: x10 = 0xa
+# CHECK-DAG: x11 = 0xb
+# CHECK-DAG: x12 = 0xc
+# CHECK-DAG: x13 = 0xd
+# CHECK-DAG: x14 = 0x8
+# CHECK-DAG: x15 = 0x8
+# CHECK-DAG: x16 = 0x8
+# CHECK-DAG: x17 = 0x8
+# CHECK-DAG: x18 = 0x8
+# CHECK-DAG: x19 = 0x8
+# CHECK-DAG: x20 = 0x8
+# CHECK-DAG: x21 = 0x8
+# CHECK-DAG: x22 = 0x8
+# CHECK-DAG: x23 = 0x8
+# CHECK-DAG: x24 = 0x8
+# CHECK-DAG: x25 = 0x8
+# CHECK-DAG: x26 = 0x8
+# CHECK-DAG: x27 = 0x8
+# CHECK-DAG: x28 = 0x8
+# CHECK-DAG: x29 = 0x8
+# CHECK-DAG: x30 = 0x8
+# CHECK-DAG: x31 = 0x8
\ No newline at end of file
diff --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py
index 5f762ec7f3514ab..87e8879f5610bc0 100644
--- a/llvm/utils/lit/lit/llvm/config.py
+++ b/llvm/utils/lit/lit/llvm/config.py
@@ -148,6 +148,7 @@ def __init__(self, lit_config, config):
features.add("long_tests")
if target_triple:
+ print(target_triple)
if re.match(r"^x86_64.*-apple", target_triple):
features.add("x86_64-apple")
host_cxx = getattr(config, "host_cxx", None)
@@ -169,8 +170,12 @@ def __init__(self, lit_config, config):
features.add("target-aarch64")
elif re.match(r"^arm.*", target_triple):
features.add("target-arm")
- if re.match(r'^ppc64le.*-linux', target_triple):
+ elif re.match(r'^ppc64le.*-linux', target_triple):
features.add('target=powerpc64le-linux')
+ elif re.match(r'^riscv64-.*-elf', target_triple):
+ features.add('target-riscv64')
+ elif re.match(r'^riscv32-.*-elf.', target_triple):
+ features.add('target-riscv32')
if not user_is_root():
features.add("non-root-user")
More information about the llvm-commits
mailing list