-
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
Changes from 6 commits
5746e99
b0af06e
0e82340
692a387
11ef887
240b59e
923b9b4
7a2ab92
3bd78d5
85daeff
93a1a64
83e5879
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -714,6 +714,8 @@ uint32_t ModuleList::ResolveSymbolContextsForFileSpec( | |
| const FileSpec &file_spec, uint32_t line, bool check_inlines, | ||
| SymbolContextItem resolve_scope, SymbolContextList &sc_list) const { | ||
| std::lock_guard<std::recursive_mutex> guard(m_modules_mutex); | ||
| // If we're looking for a header (not source), then need to check inline. | ||
| check_inlines = check_inlines || !file_spec.IsSourceImplementationFile(); | ||
|
||
| for (const ModuleSP &module_sp : m_modules) { | ||
| module_sp->ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines, | ||
| resolve_scope, sc_list); | ||
|
|
||
| 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 raise a SIGILL | ||
oontvoo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # 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; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.