Skip to content

Commit baad1b8

Browse files
authored
[lldb] Add a test for lea_rsp_pattern_p to x86 unwinder (NFC) (#94852)
This commit adds a test for lea_rsp_pattern_p which was previously due as FIXME.
1 parent b64cf38 commit baad1b8

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

lldb/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1731,7 +1731,29 @@ TEST_F(Testx86AssemblyInspectionEngine, TestAddESP) {
17311731
EXPECT_EQ(4 - 16, row_sp->GetCFAValue().GetOffset());
17321732
}
17331733

1734-
// FIXME add test for lea_rsp_pattern_p
1734+
TEST_F(Testx86AssemblyInspectionEngine, TestLEA_RSP_Pattern) {
1735+
UnwindPlan::Row::RegisterLocation regloc;
1736+
UnwindPlan::RowSP row_sp;
1737+
AddressRange sample_range;
1738+
UnwindPlan unwind_plan(eRegisterKindLLDB);
1739+
std::unique_ptr<x86AssemblyInspectionEngine> engine = Getx86_64Inspector();
1740+
1741+
uint8_t data[] = {
1742+
0x8d, 0x64, 0x24, 0x10, // lea rsp, [rsp + 0x10]
1743+
0x90 // nop
1744+
};
1745+
1746+
sample_range = AddressRange(0x1000, sizeof(data));
1747+
1748+
EXPECT_TRUE(engine->GetNonCallSiteUnwindPlanFromAssembly(
1749+
data, sizeof(data), sample_range, unwind_plan));
1750+
1751+
row_sp = unwind_plan.GetRowForFunctionOffset(0);
1752+
EXPECT_EQ(0ull, row_sp->GetOffset());
1753+
EXPECT_TRUE(row_sp->GetCFAValue().GetRegisterNumber() == k_rsp);
1754+
EXPECT_TRUE(row_sp->GetCFAValue().IsRegisterPlusOffset() == true);
1755+
EXPECT_EQ(8, row_sp->GetCFAValue().GetOffset());
1756+
}
17351757

17361758
TEST_F(Testx86AssemblyInspectionEngine, TestPopRBX) {
17371759
UnwindPlan::Row::RegisterLocation regloc;

0 commit comments

Comments
 (0)