-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[lldb] Add a test for lea_rsp_pattern_p to x86 unwinder (NFC) #94852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit adds a test for lea_rsp_pattern_p which was previously due as FIXME.
@llvm/pr-subscribers-lldb Author: Shivam Gupta (xgupta) ChangesThis commit adds a test for lea_rsp_pattern_p which was previously due as FIXME. Full diff: https://github.com/llvm/llvm-project/pull/94852.diff 1 Files Affected:
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;
|
Hi, thanks for the PR. I wrote the x86 unwinder but I don't work with the ISA very often any more, I'm a little confused. Shouldn't the sp offset after this instruction executes be 16? The test is testing for 8. I'm sure I've misunderstood the effects of the instruction. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah wait, it's because x86_64 functions on entry have the CFA == $rsp+8, right. So you add 16 to rsp and now the CFA is $rsp-8. This is good to merge. Do you have access to do that yourself?
Thanks @jasonmolenda for the review. I do have commit access to merge it. |
…4852) This commit adds a test for lea_rsp_pattern_p which was previously due as FIXME.
This commit adds a test for lea_rsp_pattern_p which was previously due as FIXME.