Skip to content

Commit 73386d9

Browse files
Optimize flags initialization
Add RISC-V 64 testcases to TestLinuxCore.py
1 parent 7239f62 commit 73386d9

File tree

4 files changed

+58
-3
lines changed

4 files changed

+58
-3
lines changed

lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ std::unique_ptr<RegisterContextCorePOSIX_riscv64>
1616
RegisterContextCorePOSIX_riscv64::Create(Thread &thread, const ArchSpec &arch,
1717
const DataExtractor &gpregset,
1818
llvm::ArrayRef<CoreNote> notes) {
19-
Flags flags = 0;
20-
2119
return std::unique_ptr<RegisterContextCorePOSIX_riscv64>(
2220
new RegisterContextCorePOSIX_riscv64(
23-
thread, std::make_unique<RegisterInfoPOSIX_riscv64>(arch, flags),
21+
thread, std::make_unique<RegisterInfoPOSIX_riscv64>(arch, Flags()),
2422
gpregset, notes));
2523
}
2624

lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ class LinuxCoreTestCase(TestBase):
2121
_x86_64_pid = 32259
2222
_s390x_pid = 1045
2323
_ppc64le_pid = 28147
24+
_riscv64_pid = 89328
2425

2526
_aarch64_regions = 4
2627
_i386_regions = 4
2728
_x86_64_regions = 5
2829
_s390x_regions = 2
2930
_ppc64le_regions = 2
31+
_riscv64_regions = 4
3032

3133
@skipIfLLVMTargetMissing("AArch64")
3234
def test_aarch64(self):
@@ -58,6 +60,11 @@ def test_s390x(self):
5860
"""Test that lldb can read the process information from an s390x linux core file."""
5961
self.do_test("linux-s390x", self._s390x_pid, self._s390x_regions, "a.out")
6062

63+
@skipIfLLVMTargetMissing("RISCV")
64+
def test_riscv64(self):
65+
"""Test that lldb can read the process information from an riscv64 linux core file."""
66+
self.do_test("linux-riscv64", self._riscv64_pid, self._riscv64_regions, "a.out")
67+
6168
@skipIfLLVMTargetMissing("X86")
6269
def test_same_pid_running(self):
6370
"""Test that we read the information from the core correctly even if we have a running
@@ -629,6 +636,56 @@ def test_arm_core(self):
629636

630637
self.expect("register read --all")
631638

639+
@skipIfLLVMTargetMissing("RISCV")
640+
def test_riscv64_regs(self):
641+
# check basic registers using 64 bit RISC-V core file
642+
target = self.dbg.CreateTarget(None)
643+
self.assertTrue(target, VALID_TARGET)
644+
process = target.LoadCore("linux-riscv64.core")
645+
646+
values = {}
647+
values["pc"] = "0x000000000001015e"
648+
values["ra"] = "0x000000000001018c"
649+
values["sp"] = "0x0000003fffd132a0"
650+
values["gp"] = "0x0000002ae919af50"
651+
values["tp"] = "0x0000003fdceae3e0"
652+
values["t0"] = "0x0"
653+
values["t1"] = "0x0000002ae9187b1c"
654+
values["t2"] = "0x0000000000000021"
655+
values["fp"] = "0x0000003fffd132d0"
656+
values["s1"] = "0x0000002ae919cd98"
657+
values["a0"] = "0x0"
658+
values["a1"] = "0x0000000000010144"
659+
values["a2"] = "0x0000002ae919cdb0"
660+
values["a3"] = "0x000000000000002f"
661+
values["a4"] = "0x000000000000002f"
662+
values["a5"] = "0x0"
663+
values["a6"] = "0x7efefefefefefeff"
664+
values["a7"] = "0x00000000000000dd"
665+
values["s2"] = "0x0000002ae9196860"
666+
values["s3"] = "0x0000002ae919cdb0"
667+
values["s4"] = "0x0000003fffc63be8"
668+
values["s5"] = "0x0000002ae919cb78"
669+
values["s6"] = "0x0000002ae9196860"
670+
values["s7"] = "0x0000002ae9196860"
671+
values["s8"] = "0x0"
672+
values["s9"] = "0x000000000000000f"
673+
values["s10"] = "0x0000002ae919a8d0"
674+
values["s11"] = "0x0000000000000008"
675+
values["t3"] = "0x0000003fdce07df4"
676+
values["t4"] = "0x0"
677+
values["t5"] = "0x0000000000000020"
678+
values["t6"] = "0x0000002ae919f1b0"
679+
values["zero"] = "0x0"
680+
681+
for regname, value in values.items():
682+
self.expect(
683+
"register read {}".format(regname),
684+
substrs=["{} = {}".format(regname, value)],
685+
)
686+
687+
self.expect("register read --all")
688+
632689
def test_get_core_file_api(self):
633690
"""
634691
Test SBProcess::GetCoreFile() API can successfully get the core file.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)