diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -1670,9 +1670,9 @@ open_paren = strchr(open_paren + strlen("(anonymous namespace)"), '('); if (open_paren) - close_paren = strchr(open_paren, ')'); + close_paren = strrchr(open_paren, ')'); } else - close_paren = strchr(open_paren, ')'); + close_paren = strrchr(open_paren, ')'); } if (open_paren) diff --git a/lldb/test/Shell/Settings/Inputs/names.cpp b/lldb/test/Shell/Settings/Inputs/names.cpp new file mode 100644 --- /dev/null +++ b/lldb/test/Shell/Settings/Inputs/names.cpp @@ -0,0 +1,26 @@ +#include + +struct Foo { + template void foo(T const &t) const noexcept(true) {} +}; + +template int foo(T const &t) { return 0; } + +int bar() { return 1; } + +namespace { +int anon_bar() { return 1; } +auto anon_lambda = [](std::function) mutable {}; +} // namespace + +int main() { + foo(bar); + foo(std::function{bar}); + foo(anon_lambda); + foo(std::function{anon_bar}); + foo(&Foo::foo>); + Foo f; + f.foo(std::function{bar}); + f.foo(std::function{anon_bar}); + return 0; +} diff --git a/lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test b/lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test new file mode 100644 --- /dev/null +++ b/lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test @@ -0,0 +1,19 @@ +# RUN: %clangxx_host -g -O0 %S/Inputs/names.cpp -std=c++17 -o %t.out +# RUN: %lldb -b -s %s %t.out | FileCheck %s +settings set -f frame-format "frame ${function.name-with-args}\n" +break set -n foo +run +# CHECK: frame int foo(t={{.*}}) +c +# CHECK: frame int foo>(t= Function = bar() ) +c +# CHECK: frame int foo<(anonymous namespace)::$_0>(t={{.*}}) +c +# CHECK: frame int foo>(t= Function = (anonymous namespace)::anon_bar() ) +c +# CHECK: frame int foo const&) const noexcept>(t={{.*}}) +c +# CHECK: frame void Foo::foo>(this={{.*}}, t= Function = bar() ) const +c +# CHECK: frame void Foo::foo>(this={{.*}}, t= Function = (anonymous namespace)::anon_bar() ) const +q