[Lldb-commits] [lldb] baad1b8 - [lldb] Add a test for lea_rsp_pattern_p to x86 unwinder (NFC) (#94852)

via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 11 00:22:35 PDT 2024


Author: Shivam Gupta
Date: 2024-06-11T12:52:32+05:30
New Revision: baad1b85b93c0b5ce0341668259ae21911bed8b1

URL: https://github.com/llvm/llvm-project/commit/baad1b85b93c0b5ce0341668259ae21911bed8b1
DIFF: https://github.com/llvm/llvm-project/commit/baad1b85b93c0b5ce0341668259ae21911bed8b1.diff

LOG: [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.

Added: 
    

Modified: 
    lldb/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp b/lldb/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
index 277cc14ce50c9..597e5b2e40d5e 100644
--- a/lldb/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
+++ b/lldb/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
@@ -1731,7 +1731,29 @@ TEST_F(Testx86AssemblyInspectionEngine, TestAddESP) {
   EXPECT_EQ(4 - 16, row_sp->GetCFAValue().GetOffset());
 }
 
-// FIXME add test for lea_rsp_pattern_p
+TEST_F(Testx86AssemblyInspectionEngine, TestLEA_RSP_Pattern) {
+  UnwindPlan::Row::RegisterLocation regloc;
+  UnwindPlan::RowSP row_sp;
+  AddressRange sample_range;
+  UnwindPlan unwind_plan(eRegisterKindLLDB);
+  std::unique_ptr<x86AssemblyInspectionEngine> engine = Getx86_64Inspector();
+
+  uint8_t data[] = {
+      0x8d, 0x64, 0x24, 0x10, // lea rsp, [rsp + 0x10]
+      0x90                    // nop
+  };
+
+  sample_range = AddressRange(0x1000, sizeof(data));
+
+  EXPECT_TRUE(engine->GetNonCallSiteUnwindPlanFromAssembly(
+      data, sizeof(data), sample_range, unwind_plan));
+
+  row_sp = unwind_plan.GetRowForFunctionOffset(0);
+  EXPECT_EQ(0ull, row_sp->GetOffset());
+  EXPECT_TRUE(row_sp->GetCFAValue().GetRegisterNumber() == k_rsp);
+  EXPECT_TRUE(row_sp->GetCFAValue().IsRegisterPlusOffset() == true);
+  EXPECT_EQ(8, row_sp->GetCFAValue().GetOffset());
+}
 
 TEST_F(Testx86AssemblyInspectionEngine, TestPopRBX) {
   UnwindPlan::Row::RegisterLocation regloc;


        


More information about the lldb-commits mailing list