-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[lldb]Make list command work with headers when possible.
#139002
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 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5746e99
[lldb]Make `list` command work with headers when possible.
oontvoo b0af06e
formatting
oontvoo 0e82340
update test
oontvoo 692a387
rework the logic to be more general
oontvoo 11ef887
address review comments
oontvoo 240b59e
updated comment
oontvoo 923b9b4
addressed review comments
oontvoo 7a2ab92
use line=1 while searching
oontvoo 3bd78d5
use inline-strategy
oontvoo 85daeff
remove space
oontvoo 93a1a64
cleanup code
oontvoo 83e5879
Merge branch 'main' into list_header
oontvoo 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 |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| ## Test that `list header.h:<line>` works correctly when header is available. | ||
| ## | ||
| # RUN: split-file %s %t | ||
|
|
||
| # RUN: %clang_host -g %t/main_with_inlined.cc %t/foo.cc -o %t/main_with_inlined.out | ||
| # RUN: %clang_host -g %t/main_no_inlined.cc %t/foo.cc -o %t/main_no_inlined.out | ||
|
|
||
| # RUN: %lldb %t/main_with_inlined.out -o "list foo.h:2" -o "exit" 2>&1 \ | ||
| # RUN: | FileCheck %s --check-prefix=CHECK-INLINED | ||
|
|
||
| ## Would be nice if this listed the header too - but probably not something | ||
| ## we want to support right now. | ||
| # RUN: echo quit | %lldb %t/main_no_inlined.out -o "list foo.h:2" -o "exit" 2>&1 \ | ||
| # RUN: | FileCheck %s --check-prefix=CHECK-NO-INLINED | ||
|
|
||
| # CHECK-INLINED: 2 extern int* ptr; | ||
| # CHECK-INLINED: 3 void f(int x); | ||
| # CHECK-INLINED: 4 | ||
| # CHECK-INLINED: 5 inline void g(int x) { | ||
| # CHECK-INLINED: 6 *ptr = x; // should crash here | ||
| # CHECK-INLINED: 7 } | ||
|
|
||
| # CHECK-NO-INLINED: error: Could not find source file "foo.h". | ||
|
|
||
| #--- foo.h | ||
| // foo.h | ||
| extern int* ptr; | ||
| void f(int x); | ||
|
|
||
| inline void g(int x) { | ||
| *ptr = x; // should crash here | ||
| } | ||
|
|
||
| #--- foo.cc | ||
| #include "foo.h" | ||
|
|
||
| int* ptr; | ||
|
|
||
| void f(int x) { | ||
| *ptr = x; | ||
| } | ||
|
|
||
| #--- main_with_inlined.cc | ||
| #include "foo.h" | ||
|
|
||
| int main() { | ||
| g(123); // Call the inlined function | ||
| return 0; | ||
| } | ||
|
|
||
| #--- main_no_inlined.cc | ||
| #include "foo.h" | ||
|
|
||
| int main() { | ||
| f(234); | ||
| return 0; | ||
| } |
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.
I don't think this should be done here. The breakpoint setting code also goes through this code path and it works fine without it. I suggest looking at how that works and emulating it. I suspect it involves looking at the
target.inline-breakpoint-strategysetting. I think it'd make sense to do that here as well (if anyone disagrees with that, do chime in), even though the setting is called inline-breakpoint-strategy, as the setting is really about where we go to search when looking up a file.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.
Done! Thanks for the pointer! :)