Michael137 updated this revision to Diff 470791. Michael137 added a comment.
- Add more test cases Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D136761/new/ https://reviews.llvm.org/D136761 Files: lldb/source/Core/FormatEntity.cpp lldb/test/Shell/Settings/Inputs/names.cpp lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test Index: lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test =================================================================== --- /dev/null +++ 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<int ()>(t={{.*}}) +c +# CHECK: frame int foo<std::__1::function<int ()>>(t= Function = bar() ) +c +# CHECK: frame int foo<(anonymous namespace)::$_0>(t={{.*}}) +c +# CHECK: frame int foo<std::__1::function<int ()>>(t= Function = (anonymous namespace)::anon_bar() ) +c +# CHECK: frame int foo<void (Foo::*)(std::__1::function<int (int)> const&) const noexcept>(t={{.*}}) +c +# CHECK: frame void Foo::foo<std::__1::function<int ()>>(this={{.*}}, t= Function = bar() ) const +c +# CHECK: frame void Foo::foo<std::__1::function<int ()>>(this={{.*}}, t= Function = (anonymous namespace)::anon_bar() ) const +q Index: lldb/test/Shell/Settings/Inputs/names.cpp =================================================================== --- /dev/null +++ lldb/test/Shell/Settings/Inputs/names.cpp @@ -0,0 +1,26 @@ +#include <functional> + +struct Foo { + template <typename T> void foo(T const &t) const noexcept(true) {} +}; + +template <typename T> int foo(T const &t) { return 0; } + +int bar() { return 1; } + +namespace { +int anon_bar() { return 1; } +auto anon_lambda = [](std::function<int(int (*)(int))>) mutable {}; +} // namespace + +int main() { + foo(bar); + foo(std::function{bar}); + foo(anon_lambda); + foo(std::function{anon_bar}); + foo(&Foo::foo<std::function<int(int)>>); + Foo f; + f.foo(std::function{bar}); + f.foo(std::function{anon_bar}); + return 0; +} Index: lldb/source/Core/FormatEntity.cpp =================================================================== --- lldb/source/Core/FormatEntity.cpp +++ 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)
Index: lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test =================================================================== --- /dev/null +++ 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<int ()>(t={{.*}}) +c +# CHECK: frame int foo<std::__1::function<int ()>>(t= Function = bar() ) +c +# CHECK: frame int foo<(anonymous namespace)::$_0>(t={{.*}}) +c +# CHECK: frame int foo<std::__1::function<int ()>>(t= Function = (anonymous namespace)::anon_bar() ) +c +# CHECK: frame int foo<void (Foo::*)(std::__1::function<int (int)> const&) const noexcept>(t={{.*}}) +c +# CHECK: frame void Foo::foo<std::__1::function<int ()>>(this={{.*}}, t= Function = bar() ) const +c +# CHECK: frame void Foo::foo<std::__1::function<int ()>>(this={{.*}}, t= Function = (anonymous namespace)::anon_bar() ) const +q Index: lldb/test/Shell/Settings/Inputs/names.cpp =================================================================== --- /dev/null +++ lldb/test/Shell/Settings/Inputs/names.cpp @@ -0,0 +1,26 @@ +#include <functional> + +struct Foo { + template <typename T> void foo(T const &t) const noexcept(true) {} +}; + +template <typename T> int foo(T const &t) { return 0; } + +int bar() { return 1; } + +namespace { +int anon_bar() { return 1; } +auto anon_lambda = [](std::function<int(int (*)(int))>) mutable {}; +} // namespace + +int main() { + foo(bar); + foo(std::function{bar}); + foo(anon_lambda); + foo(std::function{anon_bar}); + foo(&Foo::foo<std::function<int(int)>>); + Foo f; + f.foo(std::function{bar}); + f.foo(std::function{anon_bar}); + return 0; +} Index: lldb/source/Core/FormatEntity.cpp =================================================================== --- lldb/source/Core/FormatEntity.cpp +++ 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)
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits