JDevlieghere created this revision. JDevlieghere added reviewers: labath, teemperor, jingham. JDevlieghere added a project: LLDB. Herald added subscribers: abidh, aprantl.
I was going through some of the old bugs and came across PR21069 which I was able to reproduce. The issue is that we match the regex `^foo` against the `DW_AT_name` in the DWARF, which for our anonymous function is indeed `foo`. However, when we get the function name from the symbol context, the result is `(anonymous namespace)::foo()`. This throws off completions, which assumes that it's appending to whatever is already present on the input, resulting in a bogus `b fooonymous\ namespace)::foo()`. I'm not super familiar with the completion framework, so please let me know if there's a better way to solve this issue. https://bugs.llvm.org/show_bug.cgi?id=21069 Repository: rLLDB LLDB https://reviews.llvm.org/D65498 Files: lldb/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py lldb/packages/Python/lldbsuite/test/functionalities/completion/main.cpp lldb/source/Commands/CommandCompletions.cpp Index: lldb/source/Commands/CommandCompletions.cpp =================================================================== --- lldb/source/Commands/CommandCompletions.cpp +++ lldb/source/Commands/CommandCompletions.cpp @@ -471,7 +471,11 @@ for (uint32_t i = 0; i < sc_list.GetSize(); i++) { if (sc_list.GetContextAtIndex(i, sc)) { ConstString func_name = sc.GetFunctionName(Mangled::ePreferDemangled); - if (!func_name.IsEmpty()) + // Ensure that the function name matches the regex. This is more than a + // sanity check. It is possible that the demangled function name does + // not start with the prefix, for example when it's in an anonymous + // namespace. + if (!func_name.IsEmpty() && m_regex.Execute(func_name.GetStringRef())) m_match_set.insert(func_name); } } Index: lldb/packages/Python/lldbsuite/test/functionalities/completion/main.cpp =================================================================== --- lldb/packages/Python/lldbsuite/test/functionalities/completion/main.cpp +++ lldb/packages/Python/lldbsuite/test/functionalities/completion/main.cpp @@ -7,6 +7,8 @@ } }; +namespace { int Quux (void) { return 0; } } + struct Container { int MemberVar; }; int main() @@ -17,5 +19,6 @@ Container container; Container *ptr_container = &container; + int q = Quux(); return container.MemberVar = 3; // Break here } Index: lldb/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py =================================================================== --- lldb/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py +++ lldb/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py @@ -297,3 +297,6 @@ self.complete_from_to('breakpoint set -n Fo', 'breakpoint set -n Foo::Bar(int,\\ int)', turn_off_re_match=True) + # No completion for Qu because the candidate is + # (anonymous namespace)::Quux(). + self.complete_from_to('breakpoint set -n Qu', '')
Index: lldb/source/Commands/CommandCompletions.cpp =================================================================== --- lldb/source/Commands/CommandCompletions.cpp +++ lldb/source/Commands/CommandCompletions.cpp @@ -471,7 +471,11 @@ for (uint32_t i = 0; i < sc_list.GetSize(); i++) { if (sc_list.GetContextAtIndex(i, sc)) { ConstString func_name = sc.GetFunctionName(Mangled::ePreferDemangled); - if (!func_name.IsEmpty()) + // Ensure that the function name matches the regex. This is more than a + // sanity check. It is possible that the demangled function name does + // not start with the prefix, for example when it's in an anonymous + // namespace. + if (!func_name.IsEmpty() && m_regex.Execute(func_name.GetStringRef())) m_match_set.insert(func_name); } } Index: lldb/packages/Python/lldbsuite/test/functionalities/completion/main.cpp =================================================================== --- lldb/packages/Python/lldbsuite/test/functionalities/completion/main.cpp +++ lldb/packages/Python/lldbsuite/test/functionalities/completion/main.cpp @@ -7,6 +7,8 @@ } }; +namespace { int Quux (void) { return 0; } } + struct Container { int MemberVar; }; int main() @@ -17,5 +19,6 @@ Container container; Container *ptr_container = &container; + int q = Quux(); return container.MemberVar = 3; // Break here } Index: lldb/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py =================================================================== --- lldb/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py +++ lldb/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py @@ -297,3 +297,6 @@ self.complete_from_to('breakpoint set -n Fo', 'breakpoint set -n Foo::Bar(int,\\ int)', turn_off_re_match=True) + # No completion for Qu because the candidate is + # (anonymous namespace)::Quux(). + self.complete_from_to('breakpoint set -n Qu', '')
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits