-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[lldb] Handle backwards branches in UnwindAssemblyInstEmulation #169633
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
Open
felipepiovezan
wants to merge
3
commits into
users/felipepiovezan/spr/main.lldb-handle-backwards-branches-in-unwindassemblyinstemulation
Choose a base branch
from
users/felipepiovezan/spr/lldb-handle-backwards-branches-in-unwindassemblyinstemulation
base: users/felipepiovezan/spr/main.lldb-handle-backwards-branches-in-unwindassemblyinstemulation
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+28
−9
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -987,7 +987,7 @@ TEST_F(TestArm64InstEmulation, TestMidFunctionEpilogueAndBackwardsJump) { | |
| 0xfd, 0x7b, 0x42, 0xa9, // <+20>: ldp x29, x30, [sp, #0x20] | ||
| 0xff, 0xc3, 0x00, 0x91, // <+24>: add sp, sp, #0x30 | ||
| 0xc0, 0x03, 0x5f, 0xd6, // <+28>: ret | ||
| // AFTER_EPILOGUE: LLDB computes the next 5 unwind states incorrectly. | ||
| // AFTER_EPILOGUE | ||
| 0x37, 0x00, 0x80, 0xd2, // <+32>: mov x23, #0x1 | ||
| 0xf6, 0x5f, 0x41, 0xa9, // <+36>: ldp x22, x23, [sp, #0x10] | ||
| 0xfd, 0x7b, 0x42, 0xa9, // <+40>: ldp x29, x30, [sp, #0x20] | ||
|
|
@@ -1054,12 +1054,19 @@ TEST_F(TestArm64InstEmulation, TestMidFunctionEpilogueAndBackwardsJump) { | |
| EXPECT_TRUE(row->GetCFAValue().GetRegisterNumber() == gpr_sp_arm64); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need to update the comment above: |
||
| EXPECT_EQ(row->GetCFAValue().GetOffset(), 0); | ||
|
|
||
| // FIXME: Row for offset +32 incorrectly inherits the state of the `ret` | ||
| // instruction, but +32 _never_ executes after the `ret`. | ||
| // Row for offset +32 should not inherit the state of the `ret` instruction | ||
| // in +28. Instead, it should inherit the state of the branch in +64. | ||
| // Check for register x22, which is available in row +64. | ||
| // <+28>: ret | ||
| // <+32>: mov x23, #0x1 | ||
| row = unwind_plan.GetRowForFunctionOffset(32); | ||
| // FIXME: EXPECT_NE(28, row->GetOffset()); | ||
| EXPECT_EQ(32, row->GetOffset()); | ||
| { | ||
| UnwindPlan::Row::AbstractRegisterLocation loc; | ||
| EXPECT_TRUE(row->GetRegisterInfo(gpr_x22_arm64, loc)); | ||
| EXPECT_TRUE(loc.IsAtCFAPlusOffset()); | ||
| EXPECT_EQ(loc.GetOffset(), -32); | ||
| } | ||
|
|
||
| // Check that the state of this branch | ||
| // <+16>: b.ne ; <+52> DO_SOMETHING_AND_GOTO_AFTER_EPILOGUE | ||
|
|
@@ -1070,4 +1077,12 @@ TEST_F(TestArm64InstEmulation, TestMidFunctionEpilogueAndBackwardsJump) { | |
| EXPECT_TRUE(row->GetCFAValue().IsRegisterPlusOffset()); | ||
| EXPECT_EQ(row->GetCFAValue().GetRegisterNumber(), gpr_fp_arm64); | ||
| EXPECT_EQ(row->GetCFAValue().GetOffset(), 16); | ||
|
|
||
| row = unwind_plan.GetRowForFunctionOffset(64); | ||
| { | ||
| UnwindPlan::Row::AbstractRegisterLocation loc; | ||
| EXPECT_TRUE(row->GetRegisterInfo(gpr_x22_arm64, loc)); | ||
| EXPECT_TRUE(loc.IsAtCFAPlusOffset()); | ||
| EXPECT_EQ(loc.GetOffset(), -32); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we know what the range of this is? In theory a very large immediate assigned into an int32_t is going to come out mangled.
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.
Anything with the top bit set would be incorrect.
Uh oh!
There was an error while loading. Please reload this page.
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.
I think we need to make
m_branch_offsetandint64_t.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.
Actually, those are offsets encoded in instructions, so I think it is very unlikely they would ever be 32bits long, but it doesn't hurt to change the underlying type of
m_branch_offsetThere 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.
Istr Arm having some "genius" way of encoding immediates where in some cases the immediate decodes to more than the field it was stored in. But yeah, easier to change the type than go check all the instructions.