-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[lldb][FrameRecognizer] Display the first non-std frame on verbose_trap #108825
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
Michael137
merged 3 commits into
llvm:main
from
Michael137:bugfix/lldb-verbose-trap-stl-ux
Sep 19, 2024
Merged
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
22 changes: 22 additions & 0 deletions
22
lldb/test/Shell/Recognizer/Inputs/verbose_trap-in-stl-callback-user-leaf.cpp
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,22 @@ | ||
void definitely_aborts() { __builtin_verbose_trap("User", "Invariant violated"); } | ||
|
||
namespace std { | ||
void aborts_soon() { definitely_aborts(); } | ||
} // namespace std | ||
|
||
void g() { std::aborts_soon(); } | ||
|
||
namespace std { | ||
namespace detail { | ||
void eventually_aborts() { g(); } | ||
} // namespace detail | ||
|
||
inline namespace __1 { | ||
void eventually_aborts() { detail::eventually_aborts(); } | ||
} // namespace __1 | ||
} // namespace std | ||
|
||
int main() { | ||
std::eventually_aborts(); | ||
return 0; | ||
} |
22 changes: 22 additions & 0 deletions
22
lldb/test/Shell/Recognizer/Inputs/verbose_trap-in-stl-callback.cpp
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,22 @@ | ||
namespace std { | ||
void definitely_aborts() { __builtin_verbose_trap("Failed", "Invariant violated"); } | ||
|
||
void aborts_soon() { definitely_aborts(); } | ||
} // namespace std | ||
|
||
void g() { std::aborts_soon(); } | ||
|
||
namespace std { | ||
namespace detail { | ||
void eventually_aborts() { g(); } | ||
} // namespace detail | ||
|
||
inline namespace __1 { | ||
void eventually_aborts() { detail::eventually_aborts(); } | ||
} // namespace __1 | ||
} // namespace std | ||
|
||
int main() { | ||
std::eventually_aborts(); | ||
return 0; | ||
} |
13 changes: 13 additions & 0 deletions
13
lldb/test/Shell/Recognizer/Inputs/verbose_trap-in-stl-max-depth.cpp
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,13 @@ | ||
namespace std { | ||
void recursively_aborts(int depth) { | ||
if (depth == 0) | ||
__builtin_verbose_trap("Error", "max depth"); | ||
|
||
recursively_aborts(--depth); | ||
} | ||
} // namespace std | ||
|
||
int main() { | ||
std::recursively_aborts(256); | ||
return 0; | ||
} |
21 changes: 21 additions & 0 deletions
21
lldb/test/Shell/Recognizer/Inputs/verbose_trap-in-stl-nested.cpp
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,21 @@ | ||
namespace std { | ||
namespace detail { | ||
void function_that_aborts() { __builtin_verbose_trap("Bounds error", "out-of-bounds access"); } | ||
} // namespace detail | ||
|
||
inline namespace __1 { | ||
template <typename T> struct vector { | ||
void operator[](unsigned) { detail::function_that_aborts(); } | ||
}; | ||
} // namespace __1 | ||
} // namespace std | ||
|
||
void g() { | ||
std::vector<int> v; | ||
v[10]; | ||
} | ||
|
||
int main() { | ||
g(); | ||
return 0; | ||
} |
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,17 @@ | ||
namespace std { | ||
inline namespace __1 { | ||
template <typename T> struct vector { | ||
void operator[](unsigned) { __builtin_verbose_trap("Bounds error", "out-of-bounds access"); } | ||
}; | ||
} // namespace __1 | ||
} // namespace std | ||
|
||
void g() { | ||
std::vector<int> v; | ||
v[10]; | ||
} | ||
|
||
int main() { | ||
g(); | ||
return 0; | ||
} |
22 changes: 22 additions & 0 deletions
22
lldb/test/Shell/Recognizer/verbose_trap-in-stl-callback-user-leaf.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,22 @@ | ||
# Tests that we show the first non-STL frame when | ||
# a verbose_trap triggers from within the STL. | ||
# | ||
# Specifically tests that we correctly handle backtraces | ||
# of the form: | ||
# #0 __builtin_verbose_trap | ||
# #1 user-code | ||
# #2 STL | ||
# #3 user-code | ||
# #4 STL | ||
# #5 user-code | ||
|
||
# UNSUPPORTED: system-windows | ||
# | ||
# RUN: %clang_host -g -O0 %S/Inputs/verbose_trap-in-stl-callback-user-leaf.cpp -o %t.out | ||
# RUN: %lldb -b -s %s %t.out | FileCheck %s --check-prefixes=CHECK | ||
|
||
run | ||
# CHECK: thread #{{.*}}stop reason = User: Invariant violated | ||
frame info | ||
# CHECK: frame #{{.*}}`definitely_aborts() at verbose_trap-in-stl-callback-user-leaf.cpp | ||
q |
21 changes: 21 additions & 0 deletions
21
lldb/test/Shell/Recognizer/verbose_trap-in-stl-callback.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,21 @@ | ||
# Tests that we show the first non-STL frame when | ||
# a verbose_trap triggers from within the STL. | ||
# | ||
# Specifically tests that we correctly handle backtraces | ||
# of the form: | ||
# #0 __builtin_verbose_trap | ||
# #1 STL | ||
# #2 user-code | ||
# #3 STL | ||
# #4 user-code | ||
|
||
# UNSUPPORTED: system-windows | ||
# | ||
# RUN: %clang_host -g -O0 %S/Inputs/verbose_trap-in-stl-callback.cpp -o %t.out | ||
# RUN: %lldb -b -s %s %t.out | FileCheck %s --check-prefixes=CHECK | ||
|
||
run | ||
# CHECK: thread #{{.*}}stop reason = Failed: Invariant violated | ||
frame info | ||
# CHECK: frame #{{.*}}`g() at verbose_trap-in-stl-callback.cpp | ||
q |
16 changes: 16 additions & 0 deletions
16
lldb/test/Shell/Recognizer/verbose_trap-in-stl-max-depth.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,16 @@ | ||
# Tests that the VerboseTrapFrameRecognizer stops | ||
# walking the stack once a certain implementation-defined | ||
# threshold is reached. | ||
|
||
# UNSUPPORTED: system-windows | ||
# | ||
# RUN: %clang_host -g -O0 %S/Inputs/verbose_trap-in-stl-max-depth.cpp -o %t.out | ||
# RUN: %lldb -b -s %s %t.out | FileCheck %s --check-prefixes=CHECK | ||
|
||
run | ||
# CHECK: thread #{{.*}}stop reason = | ||
frame recognizer info 0 | ||
# CHECK: frame 0 is recognized by Verbose Trap StackFrame Recognizer | ||
frame info | ||
# CHECK: frame #0: {{.*}}`std::recursively_aborts(int) {{.*}} at verbose_trap-in-stl-max-depth.cpp | ||
q |
13 changes: 13 additions & 0 deletions
13
lldb/test/Shell/Recognizer/verbose_trap-in-stl-nested.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,13 @@ | ||
# Tests that we show the first non-STL frame when | ||
# a verbose_trap triggers from within the STL. | ||
|
||
# UNSUPPORTED: system-windows | ||
# | ||
# RUN: %clang_host -g -O0 %S/Inputs/verbose_trap-in-stl-nested.cpp -o %t.out | ||
# RUN: %lldb -b -s %s %t.out | FileCheck %s --check-prefixes=CHECK | ||
|
||
run | ||
# CHECK: thread #{{.*}}stop reason = Bounds error: out-of-bounds access | ||
frame info | ||
# CHECK: frame #{{.*}}`g() at verbose_trap-in-stl-nested.cpp | ||
q |
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,13 @@ | ||
# Tests that we show the first non-STL frame when | ||
# a verbose_trap triggers from within the STL. | ||
|
||
# UNSUPPORTED: system-windows | ||
# | ||
# RUN: %clang_host -g -O0 %S/Inputs/verbose_trap-in-stl.cpp -o %t.out | ||
# RUN: %lldb -b -s %s %t.out | FileCheck %s --check-prefixes=CHECK | ||
|
||
run | ||
# CHECK: thread #{{.*}}stop reason = Bounds error: out-of-bounds access | ||
frame info | ||
# CHECK: frame #{{.*}}`g() at verbose_trap-in-stl.cpp | ||
q |
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.
Is there a good reason why this isn't an API test?
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 find it much easier to understand what the test is trying to check when it's done as a
Shell
test. Especially for when we just want to inspect the format of the frame. (FWIW, all the other frame format tests are alsoShell
tests).From the Testing FAQ:
And later:
IMO these tests fit into the latter category.
But I'm happy to change these to API tests if that is more appropriate.