https://github.com/xgupta created 
https://github.com/llvm/llvm-project/pull/94852

This commit adds a test for lea_rsp_pattern_p which was previously due as FIXME.

>From 1ca5f7e7edefedd12de0745de5afe720f41456b1 Mon Sep 17 00:00:00 2001
From: Shivam Gupta <shivam98....@gmail.com>
Date: Sat, 8 Jun 2024 17:43:55 +0530
Subject: [PATCH] [lldb] Add a test for lea_rsp_pattern_p to x86 unwinder (NFC)

This commit adds a test for lea_rsp_pattern_p which was previously due as FIXME.
---
 .../x86/Testx86AssemblyInspectionEngine.cpp   | 24 ++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

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;

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to