-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[lldb/aarch64] Fix unwinding when signal interrupts a leaf function #91321
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
Merged
Merged
Changes from all commits
Commits
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 |
---|---|---|
|
@@ -1555,12 +1555,12 @@ RegisterContextUnwind::SavedLocationForRegister( | |
} | ||
|
||
if (unwindplan_regloc.IsSame()) { | ||
if (!IsFrameZero() && | ||
if (!m_all_registers_available && | ||
(regnum.GetAsKind(eRegisterKindGeneric) == LLDB_REGNUM_GENERIC_PC || | ||
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.
.. or drop the lr check entirely, since some non-ABI-respecting functions could actually preserve the value of lr even if they are not leaf functions. |
||
regnum.GetAsKind(eRegisterKindGeneric) == LLDB_REGNUM_GENERIC_RA)) { | ||
UnwindLogMsg("register %s (%d) is marked as 'IsSame' - it is a pc or " | ||
"return address reg on a non-zero frame -- treat as if we " | ||
"have no information", | ||
"return address reg on a frame which does not have all " | ||
"registers available -- treat as if we have no information", | ||
regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB)); | ||
return UnwindLLDB::RegisterSearchResult::eRegisterNotFound; | ||
} else { | ||
|
15 changes: 15 additions & 0 deletions
15
lldb/test/Shell/Unwind/Inputs/signal-in-leaf-function-aarch64.c
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include <signal.h> | ||
#include <unistd.h> | ||
|
||
int __attribute__((naked)) signal_generating_add(int a, int b) { | ||
asm("add w0, w1, w0\n\t" | ||
"udf #0xdead\n\t" | ||
"ret"); | ||
} | ||
|
||
void sigill_handler(int) { _exit(0); } | ||
|
||
int main() { | ||
signal(SIGILL, sigill_handler); | ||
return signal_generating_add(42, 47); | ||
} |
24 changes: 24 additions & 0 deletions
24
lldb/test/Shell/Unwind/signal-in-leaf-function-aarch64.test
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# REQUIRES: target-aarch64 && native | ||
# UNSUPPORTED: system-windows | ||
|
||
# RUN: %clang_host %S/Inputs/signal-in-leaf-function-aarch64.c -o %t | ||
# RUN: %lldb -s %s -o exit %t | FileCheck %s | ||
|
||
breakpoint set -n sigill_handler | ||
# CHECK: Breakpoint 1: where = {{.*}}`sigill_handler | ||
|
||
run | ||
# CHECK: thread #1, {{.*}} stop reason = signal SIGILL | ||
|
||
thread backtrace | ||
# CHECK: frame #0: [[ADD:0x[0-9a-fA-F]*]] {{.*}}`signal_generating_add | ||
# CHECK: frame #1: [[MAIN:0x[0-9a-fA-F]*]] {{.*}}`main | ||
|
||
continue | ||
# CHECK: thread #1, {{.*}} stop reason = breakpoint 1 | ||
|
||
thread backtrace | ||
# CHECK: frame #0: {{.*}}`sigill_handler | ||
# Unknown number of signal trampoline frames | ||
# CHECK: frame #{{[0-9]+}}: [[ADD]] {{.*}}`signal_generating_add | ||
# CHECK: frame #{{[0-9]+}}: [[MAIN]] {{.*}}`main |
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
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.
This could be narrowed down so that it only overwrites the
<same>
rules, but I'm not sure it's necessary given that lines 464&465 ensure that the register can get pushed only once.