[Lldb-commits] [lldb] [lldb] Save the edited line before clearing it in Editline::PrintAsync (PR #84154)
DavidSpickett wrote: This failed on our AArch64 bot but due to zombie processes hanging about from other runs, not anything to do with this change specifically. https://github.com/llvm/llvm-project/pull/84154 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add `pexpect` category for tests that `import pexpect` (PR #84860)
@@ -914,6 +914,25 @@ def checkForkVForkSupport(): configuration.skip_categories.append("fork") +def checkPexpectSupport(): +from lldbsuite.test import lldbplatformutil + +platform = lldbplatformutil.getPlatform() + +# llvm.org/pr22274: need a pexpect replacement for windows +if platform in ["windows"]: +if configuration.verbose: +print("pexpect tests will be skipped because of unsupported platform") +configuration.skip_categories.append("pexpect") +elif not configuration.shouldSkipBecauseOfCategories(["pexpect"]): +try: +import pexpect +except: +print( +"Warning: pexpect is not installed, but pexpect tests are not being skipped." DavidSpickett wrote: Would it be even safer to error here? https://github.com/llvm/llvm-project/pull/84860 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Update test past bdbad0d07bb600301cb324e87a6be37ca4af591a (PR #84889)
https://github.com/dklimkin created https://github.com/llvm/llvm-project/pull/84889 None >From 04886b73fc9ca7b4a6adc52f5306cb6addc85e5c Mon Sep 17 00:00:00 2001 From: Danial Klimkin Date: Tue, 12 Mar 2024 11:02:32 +0100 Subject: [PATCH] Update test past bdbad0d07bb600301cb324e87a6be37ca4af591a --- .../data-formatter/builtin-formats/TestBuiltinFormats.py| 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py b/lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py index 8c3bdabeaac1ba..4d6f44db0195b4 100644 --- a/lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py +++ b/lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py @@ -308,5 +308,5 @@ def test_pointer(self): @no_debug_info_test def test_instruction(self): self.assertIn( -" addq 0xa(%rdi), %r8\n", self.getFormatted("instruction", "0x0a47034c") +"= addq 0xa(%rdi), %r8\n", self.getFormatted("instruction", "0x0a47034c") ) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Update test past bdbad0d07bb600301cb324e87a6be37ca4af591a (PR #84889)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Danial Klimkin (dklimkin) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/84889.diff 1 Files Affected: - (modified) lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py (+1-1) ``diff diff --git a/lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py b/lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py index 8c3bdabeaac1ba..4d6f44db0195b4 100644 --- a/lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py +++ b/lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py @@ -308,5 +308,5 @@ def test_pointer(self): @no_debug_info_test def test_instruction(self): self.assertIn( -" addq 0xa(%rdi), %r8\n", self.getFormatted("instruction", "0x0a47034c") +"= addq 0xa(%rdi), %r8\n", self.getFormatted("instruction", "0x0a47034c") ) `` https://github.com/llvm/llvm-project/pull/84889 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Update test past bdbad0d07bb600301cb324e87a6be37ca4af591a (PR #84889)
github-actions[bot] wrote: ⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo. Please turn off [Keep my email addresses private](https://github.com/settings/emails) setting in your account. See [LLVM Discourse](https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it) for more information. https://github.com/llvm/llvm-project/pull/84889 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] TestExprCompletion.py: add tests for completion of reserved identifiers (PR #84890)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/84890 None >From ecb8e2744628207dd0ec72272428e3f57e8d68bb Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Tue, 12 Mar 2024 10:04:12 + Subject: [PATCH] [lldb][test] TestExprCompletion.py: add tests for completion of reserved identifiers --- .../expression/completion/TestExprCompletion.py| 14 ++ .../API/commands/expression/completion/main.cpp| 11 +++ 2 files changed, 25 insertions(+) diff --git a/lldb/test/API/commands/expression/completion/TestExprCompletion.py b/lldb/test/API/commands/expression/completion/TestExprCompletion.py index c6a1e3c0f42275..d322b9c323d1ef 100644 --- a/lldb/test/API/commands/expression/completion/TestExprCompletion.py +++ b/lldb/test/API/commands/expression/completion/TestExprCompletion.py @@ -246,6 +246,20 @@ def test_expr_completion(self): "expr some_expr.Self(). FooNoArgs", "expr some_expr.Self(). FooNoArgsBar()" ) +self.complete_from_to( +"expr myVec.__f", "expr myVec.__func()" +) +self.complete_from_to( +"expr myVec._F", "expr myVec._Func()" +) +self.complete_from_to( +"expr myVec.__m", "expr myVec.__mem" +) +self.complete_from_to( +"expr myVec._M", "expr myVec._Mem" +) + + def test_expr_completion_with_descriptions(self): self.build() self.main_source = "main.cpp" diff --git a/lldb/test/API/commands/expression/completion/main.cpp b/lldb/test/API/commands/expression/completion/main.cpp index 908bebbebff568..b87f9626c93283 100644 --- a/lldb/test/API/commands/expression/completion/main.cpp +++ b/lldb/test/API/commands/expression/completion/main.cpp @@ -1,3 +1,11 @@ +class MyVec { +int __mem; +int _Mem; +public: +void __func() {} +void _Func() {} +}; + namespace LongNamespaceName { class NestedClass { long m; }; } // Defined in other.cpp, we only have a forward declaration here. @@ -31,5 +39,8 @@ int main() some_expr.FooNumbersBar1(); Expr::StaticMemberMethodBar(); ForwardDecl *fwd_decl_ptr = &fwd_decl; +MyVec myVec; +myVec.__func(); +myVec._Func(); return 0; // Break here } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] TestExprCompletion.py: add tests for completion of reserved identifiers (PR #84890)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/84890 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] TestExprCompletion.py: add tests for completion of reserved identifiers (PR #84890)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes Depends on https://github.com/llvm/llvm-project/pull/84891 --- Full diff: https://github.com/llvm/llvm-project/pull/84890.diff 2 Files Affected: - (modified) lldb/test/API/commands/expression/completion/TestExprCompletion.py (+14) - (modified) lldb/test/API/commands/expression/completion/main.cpp (+11) ``diff diff --git a/lldb/test/API/commands/expression/completion/TestExprCompletion.py b/lldb/test/API/commands/expression/completion/TestExprCompletion.py index c6a1e3c0f42275..d322b9c323d1ef 100644 --- a/lldb/test/API/commands/expression/completion/TestExprCompletion.py +++ b/lldb/test/API/commands/expression/completion/TestExprCompletion.py @@ -246,6 +246,20 @@ def test_expr_completion(self): "expr some_expr.Self(). FooNoArgs", "expr some_expr.Self(). FooNoArgsBar()" ) +self.complete_from_to( +"expr myVec.__f", "expr myVec.__func()" +) +self.complete_from_to( +"expr myVec._F", "expr myVec._Func()" +) +self.complete_from_to( +"expr myVec.__m", "expr myVec.__mem" +) +self.complete_from_to( +"expr myVec._M", "expr myVec._Mem" +) + + def test_expr_completion_with_descriptions(self): self.build() self.main_source = "main.cpp" diff --git a/lldb/test/API/commands/expression/completion/main.cpp b/lldb/test/API/commands/expression/completion/main.cpp index 908bebbebff568..b87f9626c93283 100644 --- a/lldb/test/API/commands/expression/completion/main.cpp +++ b/lldb/test/API/commands/expression/completion/main.cpp @@ -1,3 +1,11 @@ +class MyVec { +int __mem; +int _Mem; +public: +void __func() {} +void _Func() {} +}; + namespace LongNamespaceName { class NestedClass { long m; }; } // Defined in other.cpp, we only have a forward declaration here. @@ -31,5 +39,8 @@ int main() some_expr.FooNumbersBar1(); Expr::StaticMemberMethodBar(); ForwardDecl *fwd_decl_ptr = &fwd_decl; +MyVec myVec; +myVec.__func(); +myVec._Func(); return 0; // Break here } `` https://github.com/llvm/llvm-project/pull/84890 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] TestExprCompletion.py: add tests for completion of reserved identifiers (PR #84890)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r 6c39fa9e9f198498ff7cf9646081437a0fc0882a...ecb8e2744628207dd0ec72272428e3f57e8d68bb lldb/test/API/commands/expression/completion/TestExprCompletion.py `` View the diff from darker here. ``diff --- TestExprCompletion.py 2024-03-12 10:04:12.00 + +++ TestExprCompletion.py 2024-03-12 10:08:45.666282 + @@ -244,23 +244,14 @@ ) self.complete_from_to( "expr some_expr.Self(). FooNoArgs", "expr some_expr.Self(). FooNoArgsBar()" ) -self.complete_from_to( -"expr myVec.__f", "expr myVec.__func()" -) -self.complete_from_to( -"expr myVec._F", "expr myVec._Func()" -) -self.complete_from_to( -"expr myVec.__m", "expr myVec.__mem" -) -self.complete_from_to( -"expr myVec._M", "expr myVec._Mem" -) - +self.complete_from_to("expr myVec.__f", "expr myVec.__func()") +self.complete_from_to("expr myVec._F", "expr myVec._Func()") +self.complete_from_to("expr myVec.__m", "expr myVec.__mem") +self.complete_from_to("expr myVec._M", "expr myVec._Mem") def test_expr_completion_with_descriptions(self): self.build() self.main_source = "main.cpp" self.main_source_spec = lldb.SBFileSpec(self.main_source) `` https://github.com/llvm/llvm-project/pull/84890 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] TestExprCompletion.py: add tests for completion of reserved identifiers (PR #84890)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 6c39fa9e9f198498ff7cf9646081437a0fc0882a ecb8e2744628207dd0ec72272428e3f57e8d68bb -- lldb/test/API/commands/expression/completion/main.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/test/API/commands/expression/completion/main.cpp b/lldb/test/API/commands/expression/completion/main.cpp index b87f9626c9..ecbb226318 100644 --- a/lldb/test/API/commands/expression/completion/main.cpp +++ b/lldb/test/API/commands/expression/completion/main.cpp @@ -1,9 +1,10 @@ class MyVec { -int __mem; -int _Mem; + int __mem; + int _Mem; + public: -void __func() {} -void _Func() {} + void __func() {} + void _Func() {} }; namespace LongNamespaceName { class NestedClass { long m; }; } `` https://github.com/llvm/llvm-project/pull/84890 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] TestExprCompletion.py: add tests for completion of reserved identifiers (PR #84890)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/84890 >From ecb8e2744628207dd0ec72272428e3f57e8d68bb Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Tue, 12 Mar 2024 10:04:12 + Subject: [PATCH 1/2] [lldb][test] TestExprCompletion.py: add tests for completion of reserved identifiers --- .../expression/completion/TestExprCompletion.py| 14 ++ .../API/commands/expression/completion/main.cpp| 11 +++ 2 files changed, 25 insertions(+) diff --git a/lldb/test/API/commands/expression/completion/TestExprCompletion.py b/lldb/test/API/commands/expression/completion/TestExprCompletion.py index c6a1e3c0f42275..d322b9c323d1ef 100644 --- a/lldb/test/API/commands/expression/completion/TestExprCompletion.py +++ b/lldb/test/API/commands/expression/completion/TestExprCompletion.py @@ -246,6 +246,20 @@ def test_expr_completion(self): "expr some_expr.Self(). FooNoArgs", "expr some_expr.Self(). FooNoArgsBar()" ) +self.complete_from_to( +"expr myVec.__f", "expr myVec.__func()" +) +self.complete_from_to( +"expr myVec._F", "expr myVec._Func()" +) +self.complete_from_to( +"expr myVec.__m", "expr myVec.__mem" +) +self.complete_from_to( +"expr myVec._M", "expr myVec._Mem" +) + + def test_expr_completion_with_descriptions(self): self.build() self.main_source = "main.cpp" diff --git a/lldb/test/API/commands/expression/completion/main.cpp b/lldb/test/API/commands/expression/completion/main.cpp index 908bebbebff568..b87f9626c93283 100644 --- a/lldb/test/API/commands/expression/completion/main.cpp +++ b/lldb/test/API/commands/expression/completion/main.cpp @@ -1,3 +1,11 @@ +class MyVec { +int __mem; +int _Mem; +public: +void __func() {} +void _Func() {} +}; + namespace LongNamespaceName { class NestedClass { long m; }; } // Defined in other.cpp, we only have a forward declaration here. @@ -31,5 +39,8 @@ int main() some_expr.FooNumbersBar1(); Expr::StaticMemberMethodBar(); ForwardDecl *fwd_decl_ptr = &fwd_decl; +MyVec myVec; +myVec.__func(); +myVec._Func(); return 0; // Break here } >From 68364e2c6e20fbe6b57672d2cb4f07d6fcf3f34e Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Tue, 12 Mar 2024 10:11:59 + Subject: [PATCH 2/2] fixup! python format --- .../expression/completion/TestExprCompletion.py | 17 - 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/lldb/test/API/commands/expression/completion/TestExprCompletion.py b/lldb/test/API/commands/expression/completion/TestExprCompletion.py index d322b9c323d1ef..022b9436ee8ea6 100644 --- a/lldb/test/API/commands/expression/completion/TestExprCompletion.py +++ b/lldb/test/API/commands/expression/completion/TestExprCompletion.py @@ -246,19 +246,10 @@ def test_expr_completion(self): "expr some_expr.Self(). FooNoArgs", "expr some_expr.Self(). FooNoArgsBar()" ) -self.complete_from_to( -"expr myVec.__f", "expr myVec.__func()" -) -self.complete_from_to( -"expr myVec._F", "expr myVec._Func()" -) -self.complete_from_to( -"expr myVec.__m", "expr myVec.__mem" -) -self.complete_from_to( -"expr myVec._M", "expr myVec._Mem" -) - +self.complete_from_to("expr myVec.__f", "expr myVec.__func()") +self.complete_from_to("expr myVec._F", "expr myVec._Func()") +self.complete_from_to("expr myVec.__m", "expr myVec.__mem") +self.complete_from_to("expr myVec._M", "expr myVec._Mem") def test_expr_completion_with_descriptions(self): self.build() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Update test past bdbad0d07bb600301cb324e87a6be37ca4af591a (PR #84889)
https://github.com/dklimkin closed https://github.com/llvm/llvm-project/pull/84889 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] ce1fd92 - Update test past bdbad0d07bb600301cb324e87a6be37ca4af591a (#84889)
Author: Danial Klimkin Date: 2024-03-12T11:19:48+01:00 New Revision: ce1fd9281707c2163728085d126ff83041e1db51 URL: https://github.com/llvm/llvm-project/commit/ce1fd9281707c2163728085d126ff83041e1db51 DIFF: https://github.com/llvm/llvm-project/commit/ce1fd9281707c2163728085d126ff83041e1db51.diff LOG: Update test past bdbad0d07bb600301cb324e87a6be37ca4af591a (#84889) Added: Modified: lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py Removed: diff --git a/lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py b/lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py index 8c3bdabeaac1ba..4d6f44db0195b4 100644 --- a/lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py +++ b/lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py @@ -308,5 +308,5 @@ def test_pointer(self): @no_debug_info_test def test_instruction(self): self.assertIn( -" addq 0xa(%rdi), %r8\n", self.getFormatted("instruction", "0x0a47034c") +"= addq 0xa(%rdi), %r8\n", self.getFormatted("instruction", "0x0a47034c") ) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] TestExprCompletion.py: add tests for completion of reserved identifiers (PR #84890)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/84890 >From ecb8e2744628207dd0ec72272428e3f57e8d68bb Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Tue, 12 Mar 2024 10:04:12 + Subject: [PATCH 1/3] [lldb][test] TestExprCompletion.py: add tests for completion of reserved identifiers --- .../expression/completion/TestExprCompletion.py| 14 ++ .../API/commands/expression/completion/main.cpp| 11 +++ 2 files changed, 25 insertions(+) diff --git a/lldb/test/API/commands/expression/completion/TestExprCompletion.py b/lldb/test/API/commands/expression/completion/TestExprCompletion.py index c6a1e3c0f42275..d322b9c323d1ef 100644 --- a/lldb/test/API/commands/expression/completion/TestExprCompletion.py +++ b/lldb/test/API/commands/expression/completion/TestExprCompletion.py @@ -246,6 +246,20 @@ def test_expr_completion(self): "expr some_expr.Self(). FooNoArgs", "expr some_expr.Self(). FooNoArgsBar()" ) +self.complete_from_to( +"expr myVec.__f", "expr myVec.__func()" +) +self.complete_from_to( +"expr myVec._F", "expr myVec._Func()" +) +self.complete_from_to( +"expr myVec.__m", "expr myVec.__mem" +) +self.complete_from_to( +"expr myVec._M", "expr myVec._Mem" +) + + def test_expr_completion_with_descriptions(self): self.build() self.main_source = "main.cpp" diff --git a/lldb/test/API/commands/expression/completion/main.cpp b/lldb/test/API/commands/expression/completion/main.cpp index 908bebbebff568..b87f9626c93283 100644 --- a/lldb/test/API/commands/expression/completion/main.cpp +++ b/lldb/test/API/commands/expression/completion/main.cpp @@ -1,3 +1,11 @@ +class MyVec { +int __mem; +int _Mem; +public: +void __func() {} +void _Func() {} +}; + namespace LongNamespaceName { class NestedClass { long m; }; } // Defined in other.cpp, we only have a forward declaration here. @@ -31,5 +39,8 @@ int main() some_expr.FooNumbersBar1(); Expr::StaticMemberMethodBar(); ForwardDecl *fwd_decl_ptr = &fwd_decl; +MyVec myVec; +myVec.__func(); +myVec._Func(); return 0; // Break here } >From 68364e2c6e20fbe6b57672d2cb4f07d6fcf3f34e Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Tue, 12 Mar 2024 10:11:59 + Subject: [PATCH 2/3] fixup! python format --- .../expression/completion/TestExprCompletion.py | 17 - 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/lldb/test/API/commands/expression/completion/TestExprCompletion.py b/lldb/test/API/commands/expression/completion/TestExprCompletion.py index d322b9c323d1ef..022b9436ee8ea6 100644 --- a/lldb/test/API/commands/expression/completion/TestExprCompletion.py +++ b/lldb/test/API/commands/expression/completion/TestExprCompletion.py @@ -246,19 +246,10 @@ def test_expr_completion(self): "expr some_expr.Self(). FooNoArgs", "expr some_expr.Self(). FooNoArgsBar()" ) -self.complete_from_to( -"expr myVec.__f", "expr myVec.__func()" -) -self.complete_from_to( -"expr myVec._F", "expr myVec._Func()" -) -self.complete_from_to( -"expr myVec.__m", "expr myVec.__mem" -) -self.complete_from_to( -"expr myVec._M", "expr myVec._Mem" -) - +self.complete_from_to("expr myVec.__f", "expr myVec.__func()") +self.complete_from_to("expr myVec._F", "expr myVec._Func()") +self.complete_from_to("expr myVec.__m", "expr myVec.__mem") +self.complete_from_to("expr myVec._M", "expr myVec._Mem") def test_expr_completion_with_descriptions(self): self.build() >From 2961ca8068b2a90999e694ce40f53da80684e5b7 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Tue, 12 Mar 2024 10:21:20 + Subject: [PATCH 3/3] fixup! move type into header --- lldb/test/API/commands/expression/completion/Makefile | 1 + lldb/test/API/commands/expression/completion/main.cpp | 8 +--- .../API/commands/expression/completion/sys/reserved.h | 7 +++ 3 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 lldb/test/API/commands/expression/completion/sys/reserved.h diff --git a/lldb/test/API/commands/expression/completion/Makefile b/lldb/test/API/commands/expression/completion/Makefile index 020dce7c31d11d..9882622b2189ea 100644 --- a/lldb/test/API/commands/expression/completion/Makefile +++ b/lldb/test/API/commands/expression/completion/Makefile @@ -1,3 +1,4 @@ CXX_SOURCES := main.cpp other.cpp +CXXFLAGS += -isystem $(SRCDIR)/sys include Makefile.rules diff --git a/lldb/test/API/commands/expression/completion/main.cpp b/lldb/test/API/commands/expression/completion/main.cpp index b87f9626c93283..5e03805a7a4d5c 100644 --- a/lldb/test/API/commands/expression/completion/main.cpp +++ b/lldb/test/API/commands/expression/c
[Lldb-commits] [lldb] [lldb][test] TestExprCompletion.py: add tests for completion of reserved identifiers (PR #84890)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/84890 >From ecb8e2744628207dd0ec72272428e3f57e8d68bb Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Tue, 12 Mar 2024 10:04:12 + Subject: [PATCH 1/4] [lldb][test] TestExprCompletion.py: add tests for completion of reserved identifiers --- .../expression/completion/TestExprCompletion.py| 14 ++ .../API/commands/expression/completion/main.cpp| 11 +++ 2 files changed, 25 insertions(+) diff --git a/lldb/test/API/commands/expression/completion/TestExprCompletion.py b/lldb/test/API/commands/expression/completion/TestExprCompletion.py index c6a1e3c0f42275..d322b9c323d1ef 100644 --- a/lldb/test/API/commands/expression/completion/TestExprCompletion.py +++ b/lldb/test/API/commands/expression/completion/TestExprCompletion.py @@ -246,6 +246,20 @@ def test_expr_completion(self): "expr some_expr.Self(). FooNoArgs", "expr some_expr.Self(). FooNoArgsBar()" ) +self.complete_from_to( +"expr myVec.__f", "expr myVec.__func()" +) +self.complete_from_to( +"expr myVec._F", "expr myVec._Func()" +) +self.complete_from_to( +"expr myVec.__m", "expr myVec.__mem" +) +self.complete_from_to( +"expr myVec._M", "expr myVec._Mem" +) + + def test_expr_completion_with_descriptions(self): self.build() self.main_source = "main.cpp" diff --git a/lldb/test/API/commands/expression/completion/main.cpp b/lldb/test/API/commands/expression/completion/main.cpp index 908bebbebff568..b87f9626c93283 100644 --- a/lldb/test/API/commands/expression/completion/main.cpp +++ b/lldb/test/API/commands/expression/completion/main.cpp @@ -1,3 +1,11 @@ +class MyVec { +int __mem; +int _Mem; +public: +void __func() {} +void _Func() {} +}; + namespace LongNamespaceName { class NestedClass { long m; }; } // Defined in other.cpp, we only have a forward declaration here. @@ -31,5 +39,8 @@ int main() some_expr.FooNumbersBar1(); Expr::StaticMemberMethodBar(); ForwardDecl *fwd_decl_ptr = &fwd_decl; +MyVec myVec; +myVec.__func(); +myVec._Func(); return 0; // Break here } >From 68364e2c6e20fbe6b57672d2cb4f07d6fcf3f34e Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Tue, 12 Mar 2024 10:11:59 + Subject: [PATCH 2/4] fixup! python format --- .../expression/completion/TestExprCompletion.py | 17 - 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/lldb/test/API/commands/expression/completion/TestExprCompletion.py b/lldb/test/API/commands/expression/completion/TestExprCompletion.py index d322b9c323d1ef..022b9436ee8ea6 100644 --- a/lldb/test/API/commands/expression/completion/TestExprCompletion.py +++ b/lldb/test/API/commands/expression/completion/TestExprCompletion.py @@ -246,19 +246,10 @@ def test_expr_completion(self): "expr some_expr.Self(). FooNoArgs", "expr some_expr.Self(). FooNoArgsBar()" ) -self.complete_from_to( -"expr myVec.__f", "expr myVec.__func()" -) -self.complete_from_to( -"expr myVec._F", "expr myVec._Func()" -) -self.complete_from_to( -"expr myVec.__m", "expr myVec.__mem" -) -self.complete_from_to( -"expr myVec._M", "expr myVec._Mem" -) - +self.complete_from_to("expr myVec.__f", "expr myVec.__func()") +self.complete_from_to("expr myVec._F", "expr myVec._Func()") +self.complete_from_to("expr myVec.__m", "expr myVec.__mem") +self.complete_from_to("expr myVec._M", "expr myVec._Mem") def test_expr_completion_with_descriptions(self): self.build() >From 2961ca8068b2a90999e694ce40f53da80684e5b7 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Tue, 12 Mar 2024 10:21:20 + Subject: [PATCH 3/4] fixup! move type into header --- lldb/test/API/commands/expression/completion/Makefile | 1 + lldb/test/API/commands/expression/completion/main.cpp | 8 +--- .../API/commands/expression/completion/sys/reserved.h | 7 +++ 3 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 lldb/test/API/commands/expression/completion/sys/reserved.h diff --git a/lldb/test/API/commands/expression/completion/Makefile b/lldb/test/API/commands/expression/completion/Makefile index 020dce7c31d11d..9882622b2189ea 100644 --- a/lldb/test/API/commands/expression/completion/Makefile +++ b/lldb/test/API/commands/expression/completion/Makefile @@ -1,3 +1,4 @@ CXX_SOURCES := main.cpp other.cpp +CXXFLAGS += -isystem $(SRCDIR)/sys include Makefile.rules diff --git a/lldb/test/API/commands/expression/completion/main.cpp b/lldb/test/API/commands/expression/completion/main.cpp index b87f9626c93283..5e03805a7a4d5c 100644 --- a/lldb/test/API/commands/expression/completion/main.cpp +++ b/lldb/test/API/commands/expression/c
[Lldb-commits] [lldb] [lldb] Add frame recognizer for __builtin_verbose_trap (PR #80368)
@@ -0,0 +1,98 @@ +#include "lldb/Target/VerboseTrapFrameRecognizer.h" + +#include "lldb/Core/Module.h" +#include "lldb/Symbol/Function.h" +#include "lldb/Symbol/SymbolContext.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" + +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" + +using namespace llvm; +using namespace lldb; +using namespace lldb_private; + +VerboseTrapRecognizedStackFrame::VerboseTrapRecognizedStackFrame( +StackFrameSP most_relevant_frame_sp, std::string stop_desc) +: m_most_relevant_frame(most_relevant_frame_sp) { + m_stop_desc = std::move(stop_desc); +} + +lldb::RecognizedStackFrameSP +VerboseTrapFrameRecognizer::RecognizeFrame(lldb::StackFrameSP frame_sp) { + if (frame_sp->GetFrameIndex()) +return {}; + + ThreadSP thread_sp = frame_sp->GetThread(); + ProcessSP process_sp = thread_sp->GetProcess(); + + StackFrameSP most_relevant_frame_sp = thread_sp->GetStackFrameAtIndex(1); + + if (!most_relevant_frame_sp) { +Log *log = GetLog(LLDBLog::Unwind); +LLDB_LOG( +log, +"Failed to find most relevant frame: Hit unwinding bound (1 frame)!"); +return {}; + } + + SymbolContext sc = frame_sp->GetSymbolContext(eSymbolContextEverything); + + if (!sc.block) +return {}; + + // The runtime error is set as the function name in the inlined function info + // of frame #0 by the compiler + const InlineFunctionInfo *inline_info = nullptr; + Block *inline_block = sc.block->GetContainingInlinedBlock(); + + if (!inline_block) +return {}; + + inline_info = sc.block->GetInlinedFunctionInfo(); + + if (!inline_info) +return {}; + + auto error_message = inline_info->GetName().GetString(); + if (error_message.empty()) +return {}; + + // Replaces "__llvm_verbose_trap: " with "Runtime Error: " + auto space_position = error_message.find(" "); + if (space_position == std::string::npos) { +Log *log = GetLog(LLDBLog::Unwind); +LLDB_LOGF(log, + "Unexpected function name format. Expected ': " + "' but got: '%s'.", + error_message.c_str()); + +return {}; + } + + error_message.replace(0, space_position, "Runtime Error:"); + + return lldb::RecognizedStackFrameSP(new VerboseTrapRecognizedStackFrame( + most_relevant_frame_sp, std::move(error_message))); +} + +lldb::StackFrameSP VerboseTrapRecognizedStackFrame::GetMostRelevantFrame() { + return m_most_relevant_frame; +} + +namespace lldb_private { + +void RegisterVerboseTrapFrameRecognizer(Process &process) { + RegularExpressionSP module_regex_sp = nullptr; + RegularExpressionSP symbol_regex_sp( + new RegularExpression("^__llvm_verbose_trap: ")); Michael137 wrote: Yup that would be nice I'll leave it to @ahatanak to do it in https://github.com/llvm/llvm-project/pull/79230 and then use it from LLDB https://github.com/llvm/llvm-project/pull/80368 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add frame recognizer for __builtin_verbose_trap (PR #80368)
@@ -0,0 +1,9 @@ +# RUN: %clang_host -g -O0 %S/Inputs/verbose_trap.cpp -o %t.out +# RUN: %lldb -b -s %s %t.out | FileCheck %s +run +# CHECK: thread #{{.*}}stop reason = Runtime Error: Function is not implemented Michael137 wrote: How about `Runtime trap: ...`? https://github.com/llvm/llvm-project/pull/80368 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add frame recognizer for __builtin_verbose_trap (PR #80368)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/80368 >From 4ffcb261af05b2a68781cf353d8e45bf921f8cb7 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 25 Jan 2024 11:05:02 + Subject: [PATCH 1/6] [lldb] Add frame recognizer for __builtin_verbose_trap This patch adds a frame recognizer for Clang's `__builtin_verbose_trap`, which behaves like a `__builtin_trap`, but emits a failure-reason string into debug-info in order for debuggers to display it to a user. The frame recognizer triggers when we encounter a frame with a function name that begins with `__llvm_verbose_trap`, which is the magic prefix Clang emits into debug-info for verbose traps. Once such frame is encountered we display the frame function name as the `Stop Reason` and display that frame to the user. Example output: ``` (lldb) run warning: a.out was compiled with optimization - stepping may behave oddly; variables may not be available. Process 35942 launched: 'a.out' (arm64) Process 35942 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = __llvm_verbose_trap: Function is not implemented frame #1: 0x00013fa4 a.out`main [inlined] Dummy::func(this=) at verbose_trap.cpp:3:5 [opt] 1struct Dummy { 2 void func() { -> 3__builtin_verbose_trap("Function is not implemented"); 4 } 5}; 6 7int main() { (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = __llvm_verbose_trap: Function is not implemented frame #0: 0x00013fa4 a.out`main [inlined] __llvm_verbose_trap: Function is not implemented at verbose_trap.cpp:0 [opt] * frame #1: 0x00013fa4 a.out`main [inlined] Dummy::func(this=) at verbose_trap.cpp:3:5 [opt] frame #2: 0x00013fa4 a.out`main at verbose_trap.cpp:8:13 [opt] frame #3: 0x000189d518b4 dyld`start + 1988 ``` --- .../lldb/Target/VerboseTrapFrameRecognizer.h | 39 + lldb/source/Target/CMakeLists.txt | 1 + lldb/source/Target/Process.cpp| 2 + .../Target/VerboseTrapFrameRecognizer.cpp | 85 +++ .../Shell/Recognizer/Inputs/verbose_trap.cpp | 8 ++ lldb/test/Shell/Recognizer/verbose_trap.test | 9 ++ 6 files changed, 144 insertions(+) create mode 100644 lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h create mode 100644 lldb/source/Target/VerboseTrapFrameRecognizer.cpp create mode 100644 lldb/test/Shell/Recognizer/Inputs/verbose_trap.cpp create mode 100644 lldb/test/Shell/Recognizer/verbose_trap.test diff --git a/lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h b/lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h new file mode 100644 index 00..7e045760a28be6 --- /dev/null +++ b/lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h @@ -0,0 +1,39 @@ +#ifndef LLDB_TARGET_VERBOSETRAPFRAMERECOGNIZER_H +#define LLDB_TARGET_VERBOSETRAPFRAMERECOGNIZER_H + +#include "lldb/Target/StackFrameRecognizer.h" + +namespace lldb_private { + +void RegisterVerboseTrapFrameRecognizer(Process &process); + +/// Holds the stack frame that caused the Verbose trap and the inlined stop +/// reason message. +class VerboseTrapRecognizedStackFrame : public RecognizedStackFrame { +public: + VerboseTrapRecognizedStackFrame(lldb::StackFrameSP most_relevant_frame_sp, + std::string stop_desc); + + lldb::StackFrameSP GetMostRelevantFrame() override; + +private: + lldb::StackFrameSP m_most_relevant_frame; +}; + +/// When a thread stops, it checks the current frame contains a +/// Verbose Trap diagnostic. If so, it returns a \a +/// VerboseTrapRecognizedStackFrame holding the diagnostic a stop reason +/// description with and the parent frame as the most relavant frame. +class VerboseTrapFrameRecognizer : public StackFrameRecognizer { +public: + std::string GetName() override { +return "Verbose Trap StackFrame Recognizer"; + } + + lldb::RecognizedStackFrameSP + RecognizeFrame(lldb::StackFrameSP frame) override; +}; + +} // namespace lldb_private + +#endif // LLDB_TARGET_VERBOSETRAPFRAMERECOGNIZER_H diff --git a/lldb/source/Target/CMakeLists.txt b/lldb/source/Target/CMakeLists.txt index cf4818eae3eb8b..8186ccbea27d42 100644 --- a/lldb/source/Target/CMakeLists.txt +++ b/lldb/source/Target/CMakeLists.txt @@ -78,6 +78,7 @@ add_lldb_library(lldbTarget UnixSignals.cpp UnwindAssembly.cpp UnwindLLDB.cpp + VerboseTrapFrameRecognizer.cpp LINK_LIBS lldbBreakpoint diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 6d58873b54a3ad..cd9b48248e4bd9 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -63,6 +63,7 @@ #include "lldb/Target/ThreadPlanCallFunction.h" #include "lldb/Target/ThreadPlanStack.h" #include "lldb/Target/UnixSignals.h" +#include "lldb/Target/VerboseTrapFrameRecognizer.h" #include "lldb/Utility/Event.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" @@ -497,6
[Lldb-commits] [lldb] [lldb] Add frame recognizer for __builtin_verbose_trap (PR #80368)
@@ -0,0 +1,39 @@ +#ifndef LLDB_TARGET_VERBOSETRAPFRAMERECOGNIZER_H Michael137 wrote: done https://github.com/llvm/llvm-project/pull/80368 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add `pexpect` category for tests that `import pexpect` (PR #84860)
https://github.com/rupprecht updated https://github.com/llvm/llvm-project/pull/84860 >From b5e04eb49c89c8c654305c6ba5db5e2f237bccec Mon Sep 17 00:00:00 2001 From: Jordan Rupprecht Date: Mon, 11 Mar 2024 11:23:59 -0700 Subject: [PATCH 1/3] [lldb][test] Add `pexpect` category for tests that `import pexpect` - Add pexpect category - Replace skipIfWindows with this - Make categories apply to test classes too --- .../Python/lldbsuite/test/decorators.py | 4 lldb/packages/Python/lldbsuite/test/dotest.py | 20 +++ .../Python/lldbsuite/test/lldbpexpect.py | 2 +- .../Python/lldbsuite/test/test_categories.py | 1 + .../Python/lldbsuite/test/test_result.py | 10 +- .../expression/TestExpressionCmd.py | 5 + .../expression/TestRepeatedExprs.py | 5 + .../TestFrameVariableResponse.py | 5 + .../benchmarks/startup/TestStartupDelays.py | 5 + .../benchmarks/stepping/TestSteppingSpeed.py | 5 + .../TestCompileRunToBreakpointTurnaround.py | 5 + .../API/terminal/TestSTTYBeforeAndAfter.py| 2 +- 12 files changed, 34 insertions(+), 35 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index b691f82b90652c..8e13aa6a13882f 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -409,10 +409,6 @@ def add_test_categories(cat): cat = test_categories.validate(cat, True) def impl(func): -if isinstance(func, type) and issubclass(func, unittest.TestCase): -raise Exception( -"@add_test_categories can only be used to decorate a test method" -) try: if hasattr(func, "categories"): cat.extend(func.categories) diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py index 291d7bad5c0897..268c02e6b49dde 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest.py +++ b/lldb/packages/Python/lldbsuite/test/dotest.py @@ -914,6 +914,25 @@ def checkForkVForkSupport(): configuration.skip_categories.append("fork") +def checkPexpectSupport(): +from lldbsuite.test import lldbplatformutil + +platform = lldbplatformutil.getPlatform() + +# llvm.org/pr22274: need a pexpect replacement for windows +if platform in ["windows"]: +if configuration.verbose: +print("pexpect tests will be skipped because of unsupported platform") +configuration.skip_categories.append("pexpect") +elif not configuration.shouldSkipBecauseOfCategories(["pexpect"]): +try: +import pexpect +except: +print( +"Warning: pexpect is not installed, but pexpect tests are not being skipped." +) + + def run_suite(): # On MacOS X, check to make sure that domain for com.apple.DebugSymbols defaults # does not exist before proceeding to running the test suite. @@ -1013,6 +1032,7 @@ def run_suite(): checkDebugServerSupport() checkObjcSupport() checkForkVForkSupport() +checkPexpectSupport() skipped_categories_list = ", ".join(configuration.skip_categories) print( diff --git a/lldb/packages/Python/lldbsuite/test/lldbpexpect.py b/lldb/packages/Python/lldbsuite/test/lldbpexpect.py index 9d216d90307473..998a080565b6b3 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbpexpect.py +++ b/lldb/packages/Python/lldbsuite/test/lldbpexpect.py @@ -10,7 +10,7 @@ @skipIfRemote -@skipIfWindows # llvm.org/pr22274: need a pexpect replacement for windows +@add_test_categories(["pexpect"]) class PExpectTest(TestBase): NO_DEBUG_INFO_TESTCASE = True PROMPT = "(lldb) " diff --git a/lldb/packages/Python/lldbsuite/test/test_categories.py b/lldb/packages/Python/lldbsuite/test/test_categories.py index 3f8de175e29df3..036bda9c957d11 100644 --- a/lldb/packages/Python/lldbsuite/test/test_categories.py +++ b/lldb/packages/Python/lldbsuite/test/test_categories.py @@ -33,6 +33,7 @@ "lldb-server": "Tests related to lldb-server", "lldb-dap": "Tests for the Debug Adaptor Protocol with lldb-dap", "llgs": "Tests for the gdb-server functionality of lldb-server", +"pexpect": "Tests requiring the pexpect library to be available", "objc": "Tests related to the Objective-C programming language support", "pyapi": "Tests related to the Python API", "std-module": "Tests related to importing the std module", diff --git a/lldb/packages/Python/lldbsuite/test/test_result.py b/lldb/packages/Python/lldbsuite/test/test_result.py index 20365f53a67541..cda67ae27d4674 100644 --- a/lldb/packages/Python/lldbsuite/test/test_result.py +++ b/lldb/packages/Python/lldbsuite/test/test_result.py @@ -148,9 +148,11 @@ def getCategoriesForTest(self, test): Gets all the categories for the currently running test meth
[Lldb-commits] [lldb] [lldb][test] Add `pexpect` category for tests that `import pexpect` (PR #84860)
@@ -914,6 +914,25 @@ def checkForkVForkSupport(): configuration.skip_categories.append("fork") +def checkPexpectSupport(): +from lldbsuite.test import lldbplatformutil + +platform = lldbplatformutil.getPlatform() + +# llvm.org/pr22274: need a pexpect replacement for windows +if platform in ["windows"]: +if configuration.verbose: +print("pexpect tests will be skipped because of unsupported platform") +configuration.skip_categories.append("pexpect") +elif not configuration.shouldSkipBecauseOfCategories(["pexpect"]): +try: +import pexpect +except: +print( +"Warning: pexpect is not installed, but pexpect tests are not being skipped." rupprecht wrote: For a pexpect test, it would fail either way, but raising an error here would be more clear about the failure. For a non-pexpect test, this will unnecessarily fail. `ninja check-lldb-api` will have ~1k test failures instead of ~30 failures. Updated to `raise` instead here. https://github.com/llvm/llvm-project/pull/84860 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add `pexpect` category for tests that `import pexpect` (PR #84860)
@@ -914,6 +914,25 @@ def checkForkVForkSupport(): configuration.skip_categories.append("fork") +def checkPexpectSupport(): +from lldbsuite.test import lldbplatformutil + +platform = lldbplatformutil.getPlatform() + +# llvm.org/pr22274: need a pexpect replacement for windows +if platform in ["windows"]: +if configuration.verbose: +print("pexpect tests will be skipped because of unsupported platform") +configuration.skip_categories.append("pexpect") +elif not configuration.shouldSkipBecauseOfCategories(["pexpect"]): +try: +import pexpect +except: +print( +"Warning: pexpect is not installed, but pexpect tests are not being skipped." rupprecht wrote: `checkPexpectSupport()` will be called for every test, just like the other check* methods above. This `try` block here will only run if a non-Windows platform is configured to run `pexpect` tests, either because: * The test is running w/ various `--skip-category=foo --skip-category=bar`, and `pexpect` is not one of the skipped categories, or * The test is running w/ `--category=pexpect` (this is unusual) I don't think there's a way to only run this check if the test has a certain category. We don't know what the category is, because the test file isn't loaded, and loading it would mean potentially evaluating the `import pexpect` statement that will fail. The whole `elif` block is just to provide a better message if `pexpect` is not installed. If I remove it, then running a `pexpect` test will fail like so: ``` $ bin/lldb-dotest -p TestSTTYBeforeAndAfter.py ... lldb version 19.0.0git (https://github.com/llvm/llvm-project.git revision b5e04eb49c89c8c654305c6ba5db5e2f237bccec) clang revision b5e04eb49c89c8c654305c6ba5db5e2f237bccec llvm revision b5e04eb49c89c8c654305c6ba5db5e2f237bccec Skipping the following test categories: ['dsym', 'gmodules', 'debugserver', 'objc'] FAIL: LLDB (/home/rupprecht/src/llvm-build/dev/bin/clang-x86_64) :: test_stty_dash_a_before_and_afetr_invoking_lldb_command (TestSTTYBeforeAndAfter.TestSTTYBeforeAndAfter.test_stty_dash_a_before_and_afetr_invoking_lldb_command) == ERROR: test_stty_dash_a_before_and_afetr_invoking_lldb_command (TestSTTYBeforeAndAfter.TestSTTYBeforeAndAfter.test_stty_dash_a_before_and_afetr_invoking_lldb_command) Test that 'stty -a' displays the same output before and after running the lldb command. -- Traceback (most recent call last): File "/home/rupprecht/src/llvm-project/lldb/packages/Python/lldbsuite/test/decorators.py", line 446, in wrapper return func(self, *args, **kwargs) ^^^ File "/home/rupprecht/src/llvm-project/lldb/test/API/terminal/TestSTTYBeforeAndAfter.py", line 26, in test_stty_dash_a_before_and_afetr_invoking_lldb_command import pexpect ModuleNotFoundError: No module named 'pexpect' Config=x86_64-/home/rupprecht/src/llvm-build/dev/bin/clang -- Ran 1 test in 0.011s FAILED (errors=1) ``` I suppose the error raised by the `elif` block, as written, doesn't provide much benefit on top of that -- it's clear that the issue is trying to run a pexpect test w/o pexpect being installed. So maybe I should replace it with something more actionable, e.g. to suggest configuring cmake w/ `-DLLDB_TEST_USER_ARGS=--skip-category=pexpect`. Or just remove it altogether? https://github.com/llvm/llvm-project/pull/84860 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] [debugserver] Handle interrupted reads correctly (PR #84872)
https://github.com/JDevlieghere approved this pull request. Makes sense. LGTM. https://github.com/llvm/llvm-project/pull/84872 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add `pexpect` category for tests that `import pexpect` (PR #84860)
@@ -914,6 +914,25 @@ def checkForkVForkSupport(): configuration.skip_categories.append("fork") +def checkPexpectSupport(): +from lldbsuite.test import lldbplatformutil + +platform = lldbplatformutil.getPlatform() + +# llvm.org/pr22274: need a pexpect replacement for windows +if platform in ["windows"]: +if configuration.verbose: +print("pexpect tests will be skipped because of unsupported platform") +configuration.skip_categories.append("pexpect") +elif not configuration.shouldSkipBecauseOfCategories(["pexpect"]): +try: +import pexpect +except: +print( +"Warning: pexpect is not installed, but pexpect tests are not being skipped." DavidSpickett wrote: I understand now. Yeah adding something actionable would be a good improvement, tell them to install pexpect or to skip the category. https://github.com/llvm/llvm-project/pull/84860 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add `pexpect` category for tests that `import pexpect` (PR #84860)
@@ -914,6 +914,25 @@ def checkForkVForkSupport(): configuration.skip_categories.append("fork") +def checkPexpectSupport(): +from lldbsuite.test import lldbplatformutil + +platform = lldbplatformutil.getPlatform() + +# llvm.org/pr22274: need a pexpect replacement for windows +if platform in ["windows"]: +if configuration.verbose: +print("pexpect tests will be skipped because of unsupported platform") +configuration.skip_categories.append("pexpect") +elif not configuration.shouldSkipBecauseOfCategories(["pexpect"]): +try: +import pexpect +except: +print( +"Warning: pexpect is not installed, but pexpect tests are not being skipped." JDevlieghere wrote: So what would happens without this code? Wouldn't we try to import pexpect anyway in the relevant test? In other words, do we even need this? It seems that printing a warning for non-pexpect either adds noise to the already verbose test output or will be invisible if the test passes. If the error message is poor enough that we would want to print something more actionable, could we do it from the `PExpectTest` base class? https://github.com/llvm/llvm-project/pull/84860 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 87dc068 - [lldb] [debugserver] Handle interrupted reads correctly (#84872)
Author: Jason Molenda Date: 2024-03-12T09:03:28-07:00 New Revision: 87dc068280aaddc98acb7865ae3df1d248f4a170 URL: https://github.com/llvm/llvm-project/commit/87dc068280aaddc98acb7865ae3df1d248f4a170 DIFF: https://github.com/llvm/llvm-project/commit/87dc068280aaddc98acb7865ae3df1d248f4a170.diff LOG: [lldb] [debugserver] Handle interrupted reads correctly (#84872) The first half of this patch is a long-standing annoyance, if I attach to debugserver with lldb while it is waiting for an lldb connection, the syscall is interrupted and it doesn't retry, debugserver exits immediately. The second half is a request from another tool that is communicating with debugserver, that we retry reads on our sockets in the same way. I haven't dug in to the details of how they're communicating that this is necessary, but the best I've been able to find reading the POSIX API docs, this is fine. rdar://117113298 Added: Modified: lldb/tools/debugserver/source/RNBSocket.cpp Removed: diff --git a/lldb/tools/debugserver/source/RNBSocket.cpp b/lldb/tools/debugserver/source/RNBSocket.cpp index 1282ea221625a0..fc55dbf2e1f1b0 100644 --- a/lldb/tools/debugserver/source/RNBSocket.cpp +++ b/lldb/tools/debugserver/source/RNBSocket.cpp @@ -120,8 +120,13 @@ rnb_err_t RNBSocket::Listen(const char *listen_host, uint16_t port, while (!accept_connection) { struct kevent event_list[4]; -int num_events = -kevent(queue_id, events.data(), events.size(), event_list, 4, NULL); +int num_events; +do { + errno = 0; + num_events = + kevent(queue_id, events.data(), events.size(), event_list, 4, NULL); +} while (num_events == -1 && + (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR)); if (num_events < 0) { err.SetError(errno, DNBError::MachKernel); @@ -291,7 +296,12 @@ rnb_err_t RNBSocket::Read(std::string &p) { // DNBLogThreadedIf(LOG_RNB_COMM, "%8u RNBSocket::%s calling read()", // (uint32_t)m_timer.ElapsedMicroSeconds(true), __FUNCTION__); DNBError err; - ssize_t bytesread = read(m_fd, buf, sizeof(buf)); + ssize_t bytesread; + do { +errno = 0; +bytesread = read(m_fd, buf, sizeof(buf)); + } while (bytesread == -1 && + (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR)); if (bytesread <= 0) err.SetError(errno, DNBError::POSIX); else ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] [debugserver] Handle interrupted reads correctly (PR #84872)
https://github.com/jasonmolenda closed https://github.com/llvm/llvm-project/pull/84872 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 93503aa - Fix MSVC build issues (#84362)
Author: Hiroshi Yamauchi Date: 2024-03-12T10:26:44-07:00 New Revision: 93503aafcdc66837ecf220243aaa530c05c35895 URL: https://github.com/llvm/llvm-project/commit/93503aafcdc66837ecf220243aaa530c05c35895 DIFF: https://github.com/llvm/llvm-project/commit/93503aafcdc66837ecf220243aaa530c05c35895.diff LOG: Fix MSVC build issues (#84362) MSVC fails when there is ambiguity (multiple options) around implicit type conversion operators. Make ConstString's conversion operator to string_view explicit to avoid ambiguity with one to StringRef and remove an unused local variable that MSVC also fails on. Added: Modified: lldb/include/lldb/Utility/ConstString.h lldb/source/Core/Mangled.cpp lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp Removed: diff --git a/lldb/include/lldb/Utility/ConstString.h b/lldb/include/lldb/Utility/ConstString.h index 470a554ca04869..f7f7ec7605eba4 100644 --- a/lldb/include/lldb/Utility/ConstString.h +++ b/lldb/include/lldb/Utility/ConstString.h @@ -168,8 +168,8 @@ class ConstString { // Implicitly convert \class ConstString instances to \class StringRef. operator llvm::StringRef() const { return GetStringRef(); } - // Implicitly convert \class ConstString instances to \class std::string_view. - operator std::string_view() const { + // Explicitly convert \class ConstString instances to \class std::string_view. + explicit operator std::string_view() const { return std::string_view(m_string, GetLength()); } diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp index 23ae3913093faf..b167c51fdce247 100644 --- a/lldb/source/Core/Mangled.cpp +++ b/lldb/source/Core/Mangled.cpp @@ -125,7 +125,7 @@ void Mangled::SetValue(ConstString name) { } // Local helpers for diff erent demangling implementations. -static char *GetMSVCDemangledStr(std::string_view M) { +static char *GetMSVCDemangledStr(llvm::StringRef M) { char *demangled_cstr = llvm::microsoftDemangle( M, nullptr, nullptr, llvm::MSDemangleFlags( @@ -169,27 +169,29 @@ static char *GetItaniumDemangledStr(const char *M) { return demangled_cstr; } -static char *GetRustV0DemangledStr(std::string_view M) { +static char *GetRustV0DemangledStr(llvm::StringRef M) { char *demangled_cstr = llvm::rustDemangle(M); if (Log *log = GetLog(LLDBLog::Demangle)) { if (demangled_cstr && demangled_cstr[0]) LLDB_LOG(log, "demangled rustv0: {0} -> \"{1}\"", M, demangled_cstr); else - LLDB_LOG(log, "demangled rustv0: {0} -> error: failed to demangle", M); + LLDB_LOG(log, "demangled rustv0: {0} -> error: failed to demangle", + static_cast(M)); } return demangled_cstr; } -static char *GetDLangDemangledStr(std::string_view M) { +static char *GetDLangDemangledStr(llvm::StringRef M) { char *demangled_cstr = llvm::dlangDemangle(M); if (Log *log = GetLog(LLDBLog::Demangle)) { if (demangled_cstr && demangled_cstr[0]) LLDB_LOG(log, "demangled dlang: {0} -> \"{1}\"", M, demangled_cstr); else - LLDB_LOG(log, "demangled dlang: {0} -> error: failed to demangle", M); + LLDB_LOG(log, "demangled dlang: {0} -> error: failed to demangle", + static_cast(M)); } return demangled_cstr; diff --git a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp index 6a2ea8c4a41b1c..f237dd63ab1cce 100644 --- a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp +++ b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp @@ -527,7 +527,6 @@ TEST_F(SymbolFilePDBTests, TestTypedefs) { SymbolFilePDB *symfile = static_cast(module->GetSymbolFile()); llvm::pdb::IPDBSession &session = symfile->GetPDBSession(); - TypeMap results; const char *TypedefsToCheck[] = {"ClassTypedef", "NSClassTypedef", "FuncPointerTypedef", ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix MSVC build issues (PR #84362)
https://github.com/hjyamauchi closed https://github.com/llvm/llvm-project/pull/84362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement coalescing of disjoint progress events (PR #84854)
@@ -0,0 +1,88 @@ +//===-- Alarm.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_HOST_ALARM_H +#define LLDB_HOST_ALARM_H + +#include "lldb/Host/HostThread.h" +#include "lldb/lldb-types.h" +#include "llvm/Support/Chrono.h" + +namespace lldb_private { + +class Alarm { +public: + using Handle = uint64_t; + using Callback = std::function; + using TimePoint = llvm::sys::TimePoint<>; + using Duration = std::chrono::milliseconds; + + Alarm(Duration timeout, bool run_callback_on_exit = false); + ~Alarm(); + + Handle Create(Callback callback); adrian-prantl wrote: Maybe in the toplevel doxygen comment explain what the expected flow is, ie, that one Alarm can deal with multiple handles and what the expected behavior is? https://github.com/llvm/llvm-project/pull/84854 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement coalescing of disjoint progress events (PR #84854)
@@ -0,0 +1,88 @@ +//===-- Alarm.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_HOST_ALARM_H +#define LLDB_HOST_ALARM_H + +#include "lldb/Host/HostThread.h" +#include "lldb/lldb-types.h" +#include "llvm/Support/Chrono.h" + +namespace lldb_private { + +class Alarm { adrian-prantl wrote: Can you add Doxygen comment explaining what this is to be used for? https://github.com/llvm/llvm-project/pull/84854 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement coalescing of disjoint progress events (PR #84854)
@@ -146,19 +147,31 @@ class ProgressManager { void Increment(const Progress::ProgressData &); void Decrement(const Progress::ProgressData &); + static void Initialize(); + static void Terminate(); + static bool Enabled(); static ProgressManager &Instance(); -private: +protected: enum class EventType { Begin, End, }; static void ReportProgress(const Progress::ProgressData &progress_data, EventType type); - llvm::StringMap> - m_progress_category_map; - std::mutex m_progress_map_mutex; + static std::optional &InstanceImpl(); + + void Expire(llvm::StringRef key); adrian-prantl wrote: Can you add a Doxygen comment? https://github.com/llvm/llvm-project/pull/84854 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement coalescing of disjoint progress events (PR #84854)
@@ -146,19 +147,31 @@ class ProgressManager { void Increment(const Progress::ProgressData &); void Decrement(const Progress::ProgressData &); + static void Initialize(); + static void Terminate(); + static bool Enabled(); static ProgressManager &Instance(); -private: +protected: enum class EventType { Begin, End, }; static void ReportProgress(const Progress::ProgressData &progress_data, EventType type); - llvm::StringMap> - m_progress_category_map; - std::mutex m_progress_map_mutex; + static std::optional &InstanceImpl(); + + void Expire(llvm::StringRef key); + struct Entry { adrian-prantl wrote: same here https://github.com/llvm/llvm-project/pull/84854 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] TestExprCompletion.py: add tests for completion of reserved identifiers (PR #84890)
https://github.com/adrian-prantl approved this pull request. https://github.com/llvm/llvm-project/pull/84890 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement coalescing of disjoint progress events (PR #84854)
@@ -75,45 +81,86 @@ void Progress::ReportProgress() { } } -ProgressManager::ProgressManager() : m_progress_category_map() {} +ProgressManager::ProgressManager() +: m_alarm(std::chrono::milliseconds(100)), m_entries() {} ProgressManager::~ProgressManager() {} +void ProgressManager::Initialize() { + assert(!InstanceImpl() && "Already initialized."); + InstanceImpl().emplace(); +} + +void ProgressManager::Terminate() { + assert(InstanceImpl() && "Already terminated."); + InstanceImpl().reset(); +} + +bool ProgressManager::Enabled() { return InstanceImpl().operator bool(); } + ProgressManager &ProgressManager::Instance() { - static std::once_flag g_once_flag; - static ProgressManager *g_progress_manager = nullptr; - std::call_once(g_once_flag, []() { -// NOTE: known leak to avoid global destructor chain issues. -g_progress_manager = new ProgressManager(); - }); - return *g_progress_manager; + assert(InstanceImpl() && "ProgressManager must be initialized"); + return *InstanceImpl(); +} + +std::optional &ProgressManager::InstanceImpl() { + static std::optional g_progress_manager; + return g_progress_manager; } void ProgressManager::Increment(const Progress::ProgressData &progress_data) { - std::lock_guard lock(m_progress_map_mutex); - // If the current category exists in the map then it is not an initial report, - // therefore don't broadcast to the category bit. Also, store the current - // progress data in the map so that we have a note of the ID used for the - // initial progress report. - if (!m_progress_category_map.contains(progress_data.title)) { -m_progress_category_map[progress_data.title].second = progress_data; + std::lock_guard lock(m_entries_mutex); + llvm::StringRef key = progress_data.title; + + // This is a new progress event. + if (!m_entries.contains(key)) { ReportProgress(progress_data, EventType::Begin); +Entry &entry = m_entries[key]; +entry.data = progress_data; +entry.refcount = 1; +return; + } + + // This is an existing progress event. + Entry &entry = m_entries[key]; clayborg wrote: Since we are always calling `m_entries[key]` anyway, this code could be a bit simpler: ``` Entry &entry = m_entries[key]; if (entry.refcount == 0) { // This is a new progress event. entry.data = progress_data; entry.refcount = 1; return; } // This is an existing progress event. ``` I assume that accessing a non existent key in the string map will return an default constructed object right? https://github.com/llvm/llvm-project/pull/84854 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement coalescing of disjoint progress events (PR #84854)
@@ -75,45 +81,86 @@ void Progress::ReportProgress() { } } -ProgressManager::ProgressManager() : m_progress_category_map() {} +ProgressManager::ProgressManager() +: m_alarm(std::chrono::milliseconds(100)), m_entries() {} clayborg wrote: Make this a lldb setting instead of hard coding to 100ms? https://github.com/llvm/llvm-project/pull/84854 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement coalescing of disjoint progress events (PR #84854)
@@ -75,45 +81,86 @@ void Progress::ReportProgress() { } } -ProgressManager::ProgressManager() : m_progress_category_map() {} +ProgressManager::ProgressManager() +: m_alarm(std::chrono::milliseconds(100)), m_entries() {} ProgressManager::~ProgressManager() {} +void ProgressManager::Initialize() { + assert(!InstanceImpl() && "Already initialized."); + InstanceImpl().emplace(); +} + +void ProgressManager::Terminate() { + assert(InstanceImpl() && "Already terminated."); + InstanceImpl().reset(); +} + +bool ProgressManager::Enabled() { return InstanceImpl().operator bool(); } + ProgressManager &ProgressManager::Instance() { - static std::once_flag g_once_flag; - static ProgressManager *g_progress_manager = nullptr; - std::call_once(g_once_flag, []() { -// NOTE: known leak to avoid global destructor chain issues. -g_progress_manager = new ProgressManager(); - }); - return *g_progress_manager; + assert(InstanceImpl() && "ProgressManager must be initialized"); + return *InstanceImpl(); +} + +std::optional &ProgressManager::InstanceImpl() { + static std::optional g_progress_manager; + return g_progress_manager; } void ProgressManager::Increment(const Progress::ProgressData &progress_data) { - std::lock_guard lock(m_progress_map_mutex); - // If the current category exists in the map then it is not an initial report, - // therefore don't broadcast to the category bit. Also, store the current - // progress data in the map so that we have a note of the ID used for the - // initial progress report. - if (!m_progress_category_map.contains(progress_data.title)) { -m_progress_category_map[progress_data.title].second = progress_data; + std::lock_guard lock(m_entries_mutex); + llvm::StringRef key = progress_data.title; + + // This is a new progress event. + if (!m_entries.contains(key)) { ReportProgress(progress_data, EventType::Begin); +Entry &entry = m_entries[key]; +entry.data = progress_data; +entry.refcount = 1; +return; + } + + // This is an existing progress event. + Entry &entry = m_entries[key]; + + // The progress event was scheduled to be deleted but a new one came in before + // the timer expired. + if (entry.refcount == 0) { +assert(entry.handle != Alarm::INVALID_HANDLE); + +if (!m_alarm.Cancel(entry.handle)) { + // The timer expired before we had a chance to cancel it. We have to treat + // this as an entirely new progress event. + ReportProgress(progress_data, EventType::Begin); +} +entry.refcount = 1; +entry.handle = Alarm::INVALID_HANDLE; + } else { +entry.refcount++; } clayborg wrote: One idea for this code could be: ``` if (entry.refcount++ == 1) { // This entry was scheduled to be expired, but no longer is. assert(entry.handle != Alarm::INVALID_HANDLE); if (!m_alarm.Cancel(entry.handle)) { // The timer expired before we had a chance to cancel it. We have to treat // this as an entirely new progress event. ReportProgress(progress_data, EventType::Begin); } entry.handle = Alarm::INVALID_HANDLE; } ``` This just removes the need to manually set `entry.refcount = 1;` or to separately increment refcount in the else body https://github.com/llvm/llvm-project/pull/84854 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement coalescing of disjoint progress events (PR #84854)
@@ -75,45 +81,86 @@ void Progress::ReportProgress() { } } -ProgressManager::ProgressManager() : m_progress_category_map() {} +ProgressManager::ProgressManager() +: m_alarm(std::chrono::milliseconds(100)), m_entries() {} ProgressManager::~ProgressManager() {} +void ProgressManager::Initialize() { + assert(!InstanceImpl() && "Already initialized."); + InstanceImpl().emplace(); +} + +void ProgressManager::Terminate() { + assert(InstanceImpl() && "Already terminated."); + InstanceImpl().reset(); +} + +bool ProgressManager::Enabled() { return InstanceImpl().operator bool(); } + ProgressManager &ProgressManager::Instance() { - static std::once_flag g_once_flag; - static ProgressManager *g_progress_manager = nullptr; - std::call_once(g_once_flag, []() { -// NOTE: known leak to avoid global destructor chain issues. -g_progress_manager = new ProgressManager(); - }); - return *g_progress_manager; + assert(InstanceImpl() && "ProgressManager must be initialized"); + return *InstanceImpl(); +} + +std::optional &ProgressManager::InstanceImpl() { + static std::optional g_progress_manager; + return g_progress_manager; } void ProgressManager::Increment(const Progress::ProgressData &progress_data) { - std::lock_guard lock(m_progress_map_mutex); - // If the current category exists in the map then it is not an initial report, - // therefore don't broadcast to the category bit. Also, store the current - // progress data in the map so that we have a note of the ID used for the - // initial progress report. - if (!m_progress_category_map.contains(progress_data.title)) { -m_progress_category_map[progress_data.title].second = progress_data; + std::lock_guard lock(m_entries_mutex); + llvm::StringRef key = progress_data.title; + + // This is a new progress event. + if (!m_entries.contains(key)) { ReportProgress(progress_data, EventType::Begin); +Entry &entry = m_entries[key]; +entry.data = progress_data; +entry.refcount = 1; +return; + } + + // This is an existing progress event. + Entry &entry = m_entries[key]; + + // The progress event was scheduled to be deleted but a new one came in before + // the timer expired. + if (entry.refcount == 0) { +assert(entry.handle != Alarm::INVALID_HANDLE); + +if (!m_alarm.Cancel(entry.handle)) { + // The timer expired before we had a chance to cancel it. We have to treat + // this as an entirely new progress event. + ReportProgress(progress_data, EventType::Begin); +} +entry.refcount = 1; +entry.handle = Alarm::INVALID_HANDLE; + } else { +entry.refcount++; } - m_progress_category_map[progress_data.title].first++; } void ProgressManager::Decrement(const Progress::ProgressData &progress_data) { - std::lock_guard lock(m_progress_map_mutex); - auto pos = m_progress_category_map.find(progress_data.title); + std::lock_guard lock(m_entries_mutex); + llvm::StringRef key = progress_data.title; - if (pos == m_progress_category_map.end()) + if (!m_entries.contains(key)) return; - if (pos->second.first <= 1) { -ReportProgress(pos->second.second, EventType::End); -m_progress_category_map.erase(progress_data.title); + Entry &entry = m_entries[key]; + if (entry.refcount <= 1) { +assert(entry.handle == Alarm::INVALID_HANDLE); +// Start a timer. If it expires before we see another progress event, it +// will be reported. +entry.refcount = 0; +// Copy the key to a std::string so we can pass it by value to the lambda. +// The underlying StringRef will not exist by the time the callback is +// called. +std::string key_str = std::string(key); +entry.handle = m_alarm.Create([=]() { Expire(key_str); }); } else { ---pos->second.first; +entry.refcount--; } clayborg wrote: This can similarly always decrement, similar to previous suggestion: ``` Entry &entry = m_entries[key]; if (entry.refcount > 0 && --entry.refcount == 0) { assert(entry.handle == Alarm::INVALID_HANDLE); // Start a timer. If it expires before we see another progress event, it // will be reported. // Copy the key to a std::string so we can pass it by value to the lambda. // The underlying StringRef will not exist by the time the callback is // called. std::string key_str = std::string(key); entry.handle = m_alarm.Create([=]() { Expire(key_str); }); } ``` This stops the manual editing of `entry.refcount = 0;` and the separate decrement in the else https://github.com/llvm/llvm-project/pull/84854 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Allow languages to filter breakpoints set by line (PR #83908)
https://github.com/felipepiovezan updated https://github.com/llvm/llvm-project/pull/83908 >From 51307b548d09c34ee06037ccf459110e451970a9 Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Mon, 4 Mar 2024 09:56:18 -0800 Subject: [PATCH 1/5] [lldb] Allow languages to filter breakpoints set by line Some languages may create artificial functions that have no real user code, even though there is line table information for them. One such case is with coroutine code that receives the CoroSplitter transformation in LLVM IR. That code transformation creates many different Functions, cloning one Instruction into many Instructions in many different Functions and copying the associated debug locations. It would be difficult to make that pass delete debug locations of cloned instructions in a language agnostic way (is it even possible?), but LLDB can ignore certain locations by querying its Language APIs and having it decide based on, for example, mangling information. --- lldb/include/lldb/Target/Language.h | 4 lldb/source/Breakpoint/BreakpointResolver.cpp | 12 2 files changed, 16 insertions(+) diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index 0cbd8a32dccd54..957c40eb7c0772 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -339,6 +339,10 @@ class Language : public PluginInterface { virtual llvm::StringRef GetInstanceVariableName() { return {}; } + virtual bool IsInterestingCtxForLineBreakpoint(const SymbolContext &) const { +return true; + } + protected: // Classes that inherit from Language can see and modify these diff --git a/lldb/source/Breakpoint/BreakpointResolver.cpp b/lldb/source/Breakpoint/BreakpointResolver.cpp index bc6348716ef418..876b30c6d76d55 100644 --- a/lldb/source/Breakpoint/BreakpointResolver.cpp +++ b/lldb/source/Breakpoint/BreakpointResolver.cpp @@ -23,6 +23,7 @@ #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/SymbolContext.h" +#include "lldb/Target/Language.h" #include "lldb/Target/Target.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" @@ -199,6 +200,15 @@ bool operator<(const SourceLoc lhs, const SourceLoc rhs) { } } // namespace +static void +ApplyLanguageFilters(llvm::SmallVectorImpl &sc_list) { + llvm::erase_if(sc_list, [](SymbolContext &sc) { +if (Language *lang = Language::FindPlugin(sc.GetLanguage())) + return !lang->IsInterestingCtxForLineBreakpoint(sc); +return false; + }); +} + void BreakpointResolver::SetSCMatchesByLine( SearchFilter &filter, SymbolContextList &sc_list, bool skip_prologue, llvm::StringRef log_ident, uint32_t line, std::optional column) { @@ -206,6 +216,8 @@ void BreakpointResolver::SetSCMatchesByLine( for (uint32_t i = 0; i < sc_list.GetSize(); ++i) all_scs.push_back(sc_list[i]); + ApplyLanguageFilters(all_scs); + while (all_scs.size()) { uint32_t closest_line = UINT32_MAX; >From 7ea76d6c04d063d50da52756179639f2037aa793 Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Tue, 5 Mar 2024 18:47:51 -0800 Subject: [PATCH 2/5] fixup! add target option --- lldb/include/lldb/Target/Language.h | 9 ++-- lldb/include/lldb/Target/Target.h | 2 ++ lldb/source/Breakpoint/BreakpointResolver.cpp | 23 +-- lldb/source/Target/Target.cpp | 8 +++ lldb/source/Target/TargetProperties.td| 3 +++ 5 files changed, 31 insertions(+), 14 deletions(-) diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index 957c40eb7c0772..9db9f4e297e114 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -339,8 +339,13 @@ class Language : public PluginInterface { virtual llvm::StringRef GetInstanceVariableName() { return {}; } - virtual bool IsInterestingCtxForLineBreakpoint(const SymbolContext &) const { -return true; + // Returns true if this SymbolContext should be used when setting breakpoints + // by line (number or regex). This is useful for languages that create + // artificial functions without any meaningful user code associated with them + // (e.g. code that gets expanded in late compilation stages, like by + // CoroSplitter). + virtual bool IsArtificialCtxForLineBreakpoint(const SymbolContext &) const { +return false; } protected: diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 8f57358981d4d2..ab04aa57f17300 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -258,6 +258,8 @@ class TargetProperties : public Properties { bool GetDebugUtilityExpression() const; + bool GetIgnoreBreakpointsFromLanguageArtificialLocations() const; + private: // Callbacks for m_launch_info. void Arg0ValueChangedCallback(); diff --git a/lldb/source/Breakpoint/
[Lldb-commits] [lldb] [lldb] Implement coalescing of disjoint progress events (PR #84854)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/84854 >From aae699eb956d1e235682b34e6407f6a9990028b3 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 5 Mar 2024 22:57:43 -0800 Subject: [PATCH 1/2] [lldb] Add an Alarm class Add an Alarm class which allows scheduling callbacks after a specific timeout has elapsed. --- lldb/include/lldb/Host/Alarm.h | 112 + lldb/source/Host/CMakeLists.txt| 1 + lldb/source/Host/common/Alarm.cpp | 193 + lldb/unittests/Host/AlarmTest.cpp | 164 lldb/unittests/Host/CMakeLists.txt | 1 + 5 files changed, 471 insertions(+) create mode 100644 lldb/include/lldb/Host/Alarm.h create mode 100644 lldb/source/Host/common/Alarm.cpp create mode 100644 lldb/unittests/Host/AlarmTest.cpp diff --git a/lldb/include/lldb/Host/Alarm.h b/lldb/include/lldb/Host/Alarm.h new file mode 100644 index 00..7bdbc8f2b0ed74 --- /dev/null +++ b/lldb/include/lldb/Host/Alarm.h @@ -0,0 +1,112 @@ +//===-- Alarm.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_HOST_ALARM_H +#define LLDB_HOST_ALARM_H + +#include "lldb/Host/HostThread.h" +#include "lldb/lldb-types.h" +#include "llvm/Support/Chrono.h" + +namespace lldb_private { + +/// \class Alarm abstraction that enables scheduling a callback function after a +/// specified timeout. Creating an alarm for a callback returns a Handle that +/// can be used to restart or cancel the alarm. +class Alarm { +public: + using Handle = uint64_t; + using Callback = std::function; + using TimePoint = llvm::sys::TimePoint<>; + using Duration = std::chrono::milliseconds; + + Alarm(Duration timeout, bool run_callback_on_exit = false); + ~Alarm(); + + /// Create an alarm for the given callback. The alarm will expire and the + /// callback will be called after the timeout. + /// + /// \returns + /// Handle which can be used to restart or cancel the alarm. + Handle Create(Callback callback); + + /// Restart the alarm for the given Handle. The alarm will expire and the + /// callback will be called after the timeout. + /// + /// \returns + /// True if the alarm was successfully restarted. False if there is no alarm + /// for the given Handle or the alarm already expired. + bool Restart(Handle handle); + + /// Cancel the alarm for the given Handle. The alarm and its handle will be + /// removed. + /// + /// \returns + /// True if the alarm was successfully canceled and the Handle removed. + /// False if there is no alarm for the given Handle or the alarm already + /// expired. + bool Cancel(Handle handle); + + static constexpr Handle INVALID_HANDLE = 0; + +private: + /// Helper functions to start, stop and check the status of the alarm thread. + /// @{ + void StartAlarmThread(); + void StopAlarmThread(); + bool AlarmThreadRunning(); + /// @} + + /// Return an unique, monotonically increasing handle. + static Handle GetNextUniqueHandle(); + + /// Helper to compute the next time the alarm thread needs to wake up. + TimePoint GetNextExpiration() const; + + /// Alarm entry. + struct Entry { +Handle handle; +Callback callback; +TimePoint expiration; + +Entry(Callback callback, TimePoint expiration); +bool operator==(const Entry &rhs) { return handle == rhs.handle; } + }; + + /// List of alarm entries. + std::vector m_entries; + + /// Timeout between when an alarm is created and when it fires. + Duration m_timeout; + + /// The alarm thread. + /// @{ + HostThread m_alarm_thread; + lldb::thread_result_t AlarmThread(); + /// @} + + /// Synchronize access between the alarm thread and the main thread. + std::mutex m_alarm_mutex; + + /// Condition variable used to wake up the alarm thread. + std::condition_variable m_alarm_cv; + + /// Flag to signal the alarm thread that something changed and we need to + /// recompute the next alarm. + bool m_recompute_next_alarm = false; + + /// Flag to signal the alarm thread to exit. + bool m_exit = false; + + /// Flag to signal we should run all callbacks on exit. + bool m_run_callbacks_on_exit = false; +}; + +} // namespace lldb_private + +#endif // LLDB_HOST_ALARM_H diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt index fe6e539f758fda..c2e091ee8555b7 100644 --- a/lldb/source/Host/CMakeLists.txt +++ b/lldb/source/Host/CMakeLists.txt @@ -13,6 +13,7 @@ macro(add_host_subdirectory group) endmacro() add_host_subdirectory(common + common/Alarm.cpp common/FileAction.cpp common/FileCache.cpp common/File.cpp diff --git a/lldb/source/Host/common/Alarm.cpp b
[Lldb-commits] [lldb] [lldb] Implement coalescing of disjoint progress events (PR #84854)
@@ -0,0 +1,164 @@ +//===-- AlarmTest.cpp -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Host/Alarm.h" +#include "gtest/gtest.h" + +#include +#include + +using namespace lldb_private; +using namespace std::chrono_literals; + +static constexpr auto ALARM_TIMEOUT = 500ms; +static constexpr auto TEST_TIMEOUT = 1000ms; +static constexpr bool RUN_CALLBACKS_ON_EXIT = true; + +// Enable strict checking of the ALARM_TIMEOUTs. This should only be enabled for +// development and never during automated testing where scheduling and +// ALARM_TIMEOUTs are unpredictable. +#define STRICT_ALARM_TIMEOUT 1 + +#if STRICT_ALARM_TIMEOUT +static constexpr auto EPSILON = 10ms; +#endif + +TEST(AlarmTest, Create) { + std::mutex m; + + std::vector callbacks_actual; + std::vector callbacks_expected; + + Alarm alarm(ALARM_TIMEOUT, RUN_CALLBACKS_ON_EXIT); + + // Create 5 alarms some time apart. + for (size_t i = 0; i < 5; ++i) { +callbacks_actual.emplace_back(); +callbacks_expected.emplace_back(std::chrono::system_clock::now() + +ALARM_TIMEOUT); + +alarm.Create([&callbacks_actual, &m, i]() { + std::lock_guard guard(m); + callbacks_actual[i] = std::chrono::system_clock::now(); +}); + +std::this_thread::sleep_for(ALARM_TIMEOUT / 5); + } + + // Leave plenty of time for all the alarms to fire. + std::this_thread::sleep_for(TEST_TIMEOUT); + + // Make sure all the alarms around the expected time. + for (size_t i = 0; i < 5; ++i) { +EXPECT_GE(callbacks_actual[i], callbacks_expected[i]); +#if STRICT_ALARM_TIMEOUT +EXPECT_LE(callbacks_actual[i], callbacks_expected[i] + EPSILON); +#endif + } +} + +TEST(AlarmTest, Exit) { + std::mutex m; + + std::vector handles; + std::vector callbacks; + + { +Alarm alarm(ALARM_TIMEOUT, RUN_CALLBACKS_ON_EXIT); + +// Create 5 alarms. +for (size_t i = 0; i < 5; ++i) { + callbacks.emplace_back(false); + + handles.push_back(alarm.Create([&callbacks, &m, i]() { +std::lock_guard guard(m); +callbacks[i] = true; + })); +} + +// Let the alarm go out of scope before any alarm had a chance to fire. + } + + // Make sure none of the first 4 alarms fired. + for (bool callback : callbacks) +EXPECT_TRUE(callback); JDevlieghere wrote: Yup, that's a typo. https://github.com/llvm/llvm-project/pull/84854 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 88bf640 - [lldb][test] TestExprCompletion.py: add tests for completion of reserved identifiers (#84890)
Author: Michael Buch Date: 2024-03-12T22:19:27Z New Revision: 88bf64097e453deca73c91ec7de1af7eebe296a9 URL: https://github.com/llvm/llvm-project/commit/88bf64097e453deca73c91ec7de1af7eebe296a9 DIFF: https://github.com/llvm/llvm-project/commit/88bf64097e453deca73c91ec7de1af7eebe296a9.diff LOG: [lldb][test] TestExprCompletion.py: add tests for completion of reserved identifiers (#84890) Added: lldb/test/API/commands/expression/completion/sys/reserved.h Modified: lldb/test/API/commands/expression/completion/Makefile lldb/test/API/commands/expression/completion/TestExprCompletion.py lldb/test/API/commands/expression/completion/main.cpp Removed: diff --git a/lldb/test/API/commands/expression/completion/Makefile b/lldb/test/API/commands/expression/completion/Makefile index 020dce7c31d11d..9882622b2189ea 100644 --- a/lldb/test/API/commands/expression/completion/Makefile +++ b/lldb/test/API/commands/expression/completion/Makefile @@ -1,3 +1,4 @@ CXX_SOURCES := main.cpp other.cpp +CXXFLAGS += -isystem $(SRCDIR)/sys include Makefile.rules diff --git a/lldb/test/API/commands/expression/completion/TestExprCompletion.py b/lldb/test/API/commands/expression/completion/TestExprCompletion.py index c6a1e3c0f42275..022b9436ee8ea6 100644 --- a/lldb/test/API/commands/expression/completion/TestExprCompletion.py +++ b/lldb/test/API/commands/expression/completion/TestExprCompletion.py @@ -246,6 +246,11 @@ def test_expr_completion(self): "expr some_expr.Self(). FooNoArgs", "expr some_expr.Self(). FooNoArgsBar()" ) +self.complete_from_to("expr myVec.__f", "expr myVec.__func()") +self.complete_from_to("expr myVec._F", "expr myVec._Func()") +self.complete_from_to("expr myVec.__m", "expr myVec.__mem") +self.complete_from_to("expr myVec._M", "expr myVec._Mem") + def test_expr_completion_with_descriptions(self): self.build() self.main_source = "main.cpp" diff --git a/lldb/test/API/commands/expression/completion/main.cpp b/lldb/test/API/commands/expression/completion/main.cpp index 908bebbebff568..5e03805a7a4d5c 100644 --- a/lldb/test/API/commands/expression/completion/main.cpp +++ b/lldb/test/API/commands/expression/completion/main.cpp @@ -1,3 +1,5 @@ +#include + namespace LongNamespaceName { class NestedClass { long m; }; } // Defined in other.cpp, we only have a forward declaration here. @@ -31,5 +33,8 @@ int main() some_expr.FooNumbersBar1(); Expr::StaticMemberMethodBar(); ForwardDecl *fwd_decl_ptr = &fwd_decl; +MyVec myVec; +myVec.__func(); +myVec._Func(); return 0; // Break here } diff --git a/lldb/test/API/commands/expression/completion/sys/reserved.h b/lldb/test/API/commands/expression/completion/sys/reserved.h new file mode 100644 index 00..0ce10ebec62bfd --- /dev/null +++ b/lldb/test/API/commands/expression/completion/sys/reserved.h @@ -0,0 +1,8 @@ +class MyVec { + int __mem; + int _Mem; + +public: + void __func() {} + void _Func() {} +}; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] TestExprCompletion.py: add tests for completion of reserved identifiers (PR #84890)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/84890 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement coalescing of disjoint progress events (PR #84854)
@@ -75,45 +81,86 @@ void Progress::ReportProgress() { } } -ProgressManager::ProgressManager() : m_progress_category_map() {} +ProgressManager::ProgressManager() +: m_alarm(std::chrono::milliseconds(100)), m_entries() {} JDevlieghere wrote: I initially wanted to make this a setting, but you need this when initializing the ProgressManager, which happens way before we even have a debugger or a command interpreter, so there wouldn't be a way to set the setting even. I could move the timeout out of the constructor and allow you to set the timeout after the fact, but that would still leave the question of where to get the setting from: the ProgressManager is shared across debuggers. https://github.com/llvm/llvm-project/pull/84854 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Avoid a potential exit(1) in LLVMContext::diagnose() (PR #84992)
https://github.com/adrian-prantl created https://github.com/llvm/llvm-project/pull/84992 by handling *all* errors in IRExecDiagnosticHandler. The function that call this handles all unhandled errors with an `exit(1)`. rdar://124459751 I don't really have a testcase for this, since the crash report I got for this involved the Swift language plugin. >From 0c805bfc91d92a364b02bd2e555192bc996fc83f Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Tue, 12 Mar 2024 16:22:33 -0700 Subject: [PATCH] Avoid a potential exit(1) in LLVMContext::diagnose() by handling *all* errors in IRExecDiagnosticHandler. rdar://124459751 --- lldb/source/Expression/IRExecutionUnit.cpp | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp index e4e131d70d4319..cb9bee8733e15d 100644 --- a/lldb/source/Expression/IRExecutionUnit.cpp +++ b/lldb/source/Expression/IRExecutionUnit.cpp @@ -212,18 +212,17 @@ struct IRExecDiagnosticHandler : public llvm::DiagnosticHandler { Status *err; IRExecDiagnosticHandler(Status *err) : err(err) {} bool handleDiagnostics(const llvm::DiagnosticInfo &DI) override { -if (DI.getKind() == llvm::DK_SrcMgr) { +if (DI.getSeverity() == llvm::DS_Error) { const auto &DISM = llvm::cast(DI); if (err && err->Success()) { err->SetErrorToGenericError(); err->SetErrorStringWithFormat( -"Inline assembly error: %s", +"IRExecution error: %s", DISM.getSMDiag().getMessage().str().c_str()); } - return true; } -return false; +return true; } }; } // namespace ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Avoid a potential exit(1) in LLVMContext::diagnose() (PR #84992)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Adrian Prantl (adrian-prantl) Changes by handling *all* errors in IRExecDiagnosticHandler. The function that call this handles all unhandled errors with an `exit(1)`. rdar://124459751 I don't really have a testcase for this, since the crash report I got for this involved the Swift language plugin. --- Full diff: https://github.com/llvm/llvm-project/pull/84992.diff 1 Files Affected: - (modified) lldb/source/Expression/IRExecutionUnit.cpp (+3-4) ``diff diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp index e4e131d70d4319..cb9bee8733e15d 100644 --- a/lldb/source/Expression/IRExecutionUnit.cpp +++ b/lldb/source/Expression/IRExecutionUnit.cpp @@ -212,18 +212,17 @@ struct IRExecDiagnosticHandler : public llvm::DiagnosticHandler { Status *err; IRExecDiagnosticHandler(Status *err) : err(err) {} bool handleDiagnostics(const llvm::DiagnosticInfo &DI) override { -if (DI.getKind() == llvm::DK_SrcMgr) { +if (DI.getSeverity() == llvm::DS_Error) { const auto &DISM = llvm::cast(DI); if (err && err->Success()) { err->SetErrorToGenericError(); err->SetErrorStringWithFormat( -"Inline assembly error: %s", +"IRExecution error: %s", DISM.getSMDiag().getMessage().str().c_str()); } - return true; } -return false; +return true; } }; } // namespace `` https://github.com/llvm/llvm-project/pull/84992 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Allow languages to filter breakpoints set by line (PR #83908)
https://github.com/felipepiovezan updated https://github.com/llvm/llvm-project/pull/83908 >From 51307b548d09c34ee06037ccf459110e451970a9 Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Mon, 4 Mar 2024 09:56:18 -0800 Subject: [PATCH 1/5] [lldb] Allow languages to filter breakpoints set by line Some languages may create artificial functions that have no real user code, even though there is line table information for them. One such case is with coroutine code that receives the CoroSplitter transformation in LLVM IR. That code transformation creates many different Functions, cloning one Instruction into many Instructions in many different Functions and copying the associated debug locations. It would be difficult to make that pass delete debug locations of cloned instructions in a language agnostic way (is it even possible?), but LLDB can ignore certain locations by querying its Language APIs and having it decide based on, for example, mangling information. --- lldb/include/lldb/Target/Language.h | 4 lldb/source/Breakpoint/BreakpointResolver.cpp | 12 2 files changed, 16 insertions(+) diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index 0cbd8a32dccd54..957c40eb7c0772 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -339,6 +339,10 @@ class Language : public PluginInterface { virtual llvm::StringRef GetInstanceVariableName() { return {}; } + virtual bool IsInterestingCtxForLineBreakpoint(const SymbolContext &) const { +return true; + } + protected: // Classes that inherit from Language can see and modify these diff --git a/lldb/source/Breakpoint/BreakpointResolver.cpp b/lldb/source/Breakpoint/BreakpointResolver.cpp index bc6348716ef418..876b30c6d76d55 100644 --- a/lldb/source/Breakpoint/BreakpointResolver.cpp +++ b/lldb/source/Breakpoint/BreakpointResolver.cpp @@ -23,6 +23,7 @@ #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/SymbolContext.h" +#include "lldb/Target/Language.h" #include "lldb/Target/Target.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" @@ -199,6 +200,15 @@ bool operator<(const SourceLoc lhs, const SourceLoc rhs) { } } // namespace +static void +ApplyLanguageFilters(llvm::SmallVectorImpl &sc_list) { + llvm::erase_if(sc_list, [](SymbolContext &sc) { +if (Language *lang = Language::FindPlugin(sc.GetLanguage())) + return !lang->IsInterestingCtxForLineBreakpoint(sc); +return false; + }); +} + void BreakpointResolver::SetSCMatchesByLine( SearchFilter &filter, SymbolContextList &sc_list, bool skip_prologue, llvm::StringRef log_ident, uint32_t line, std::optional column) { @@ -206,6 +216,8 @@ void BreakpointResolver::SetSCMatchesByLine( for (uint32_t i = 0; i < sc_list.GetSize(); ++i) all_scs.push_back(sc_list[i]); + ApplyLanguageFilters(all_scs); + while (all_scs.size()) { uint32_t closest_line = UINT32_MAX; >From 7ea76d6c04d063d50da52756179639f2037aa793 Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Tue, 5 Mar 2024 18:47:51 -0800 Subject: [PATCH 2/5] fixup! add target option --- lldb/include/lldb/Target/Language.h | 9 ++-- lldb/include/lldb/Target/Target.h | 2 ++ lldb/source/Breakpoint/BreakpointResolver.cpp | 23 +-- lldb/source/Target/Target.cpp | 8 +++ lldb/source/Target/TargetProperties.td| 3 +++ 5 files changed, 31 insertions(+), 14 deletions(-) diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index 957c40eb7c0772..9db9f4e297e114 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -339,8 +339,13 @@ class Language : public PluginInterface { virtual llvm::StringRef GetInstanceVariableName() { return {}; } - virtual bool IsInterestingCtxForLineBreakpoint(const SymbolContext &) const { -return true; + // Returns true if this SymbolContext should be used when setting breakpoints + // by line (number or regex). This is useful for languages that create + // artificial functions without any meaningful user code associated with them + // (e.g. code that gets expanded in late compilation stages, like by + // CoroSplitter). + virtual bool IsArtificialCtxForLineBreakpoint(const SymbolContext &) const { +return false; } protected: diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 8f57358981d4d2..ab04aa57f17300 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -258,6 +258,8 @@ class TargetProperties : public Properties { bool GetDebugUtilityExpression() const; + bool GetIgnoreBreakpointsFromLanguageArtificialLocations() const; + private: // Callbacks for m_launch_info. void Arg0ValueChangedCallback(); diff --git a/lldb/source/Breakpoint/
[Lldb-commits] [lldb] [lldb] [Mach-O] ProcessMachCore needs to strip TBI data from addrs (PR #84998)
https://github.com/jasonmolenda created https://github.com/llvm/llvm-project/pull/84998 Darwin AArch64 application processors are run with Top Byte Ignore mode enabled so metadata may be stored in the top byte, it needs to be ignored when reading/writing memory. David Spickett handled this already in the base class Process::ReadMemory but ProcessMachCore overrides that method (to avoid the memory cache) and did not pick up the same change. I add a test case that creates a pointer with metadata in the top byte and dereferences it with a live process and with a corefile. rdar://123784501 >From 4278537c262b01b1d6432391bd9d8017eb96c60a Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Tue, 12 Mar 2024 17:09:30 -0700 Subject: [PATCH] [lldb] [Mach-O] ProcessMachCore needs to strip TBI data from addrs Darwin AArch64 application processors are run with Top Byte Ignore mode enabled so metadata may be stored in the top byte, it needs to be ignored when reading/writing memory. David Spickett handled this already in the base class Process::ReadMemory but ProcessMachCore overrides that method (to avoid the memory cache) and did not pick up the same change. I add a test case that creates a pointer with metadata in the top byte and dereferences it with a live process and with a corefile. rdar://123784501 --- .../Process/mach-core/ProcessMachCore.cpp | 2 +- lldb/test/API/macosx/tbi-honored/Makefile | 3 ++ .../API/macosx/tbi-honored/TestTBIHonored.py | 49 +++ lldb/test/API/macosx/tbi-honored/main.c | 13 + 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 lldb/test/API/macosx/tbi-honored/Makefile create mode 100644 lldb/test/API/macosx/tbi-honored/TestTBIHonored.py create mode 100644 lldb/test/API/macosx/tbi-honored/main.c diff --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp index 3961dcf0fbcc0e..7b9938d4f02020 100644 --- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp +++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp @@ -652,7 +652,7 @@ size_t ProcessMachCore::ReadMemory(addr_t addr, void *buf, size_t size, Status &error) { // Don't allow the caching that lldb_private::Process::ReadMemory does since // in core files we have it all cached our our core file anyway. - return DoReadMemory(addr, buf, size, error); + return DoReadMemory(FixAnyAddress(addr), buf, size, error); } size_t ProcessMachCore::DoReadMemory(addr_t addr, void *buf, size_t size, diff --git a/lldb/test/API/macosx/tbi-honored/Makefile b/lldb/test/API/macosx/tbi-honored/Makefile new file mode 100644 index 00..10495940055b63 --- /dev/null +++ b/lldb/test/API/macosx/tbi-honored/Makefile @@ -0,0 +1,3 @@ +C_SOURCES := main.c + +include Makefile.rules diff --git a/lldb/test/API/macosx/tbi-honored/TestTBIHonored.py b/lldb/test/API/macosx/tbi-honored/TestTBIHonored.py new file mode 100644 index 00..d38685359af6d1 --- /dev/null +++ b/lldb/test/API/macosx/tbi-honored/TestTBIHonored.py @@ -0,0 +1,49 @@ +"""Test that lldb on Darwin ignores metadata in the top byte of addresses.""" + +import os +import re +import subprocess + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestTBIHonored(TestBase): +@no_debug_info_test +@skipUnlessDarwin +@skipIf(archs=no_match(["arm64", "arm64e"])) +@skipIfRemote +def do_variable_access_tests(self, frame): +self.assertEqual( +frame.variables["pb"][0] +.GetChildMemberWithName("p") +.Dereference() +.GetValueAsUnsigned(), +15, +) +addr = frame.variables["pb"][0].GetChildMemberWithName("p").GetValueAsUnsigned() +self.expect("expr -- *pb.p", substrs=["15"]) +self.expect("frame variable *pb.p", substrs=["15"]) +self.expect("expr -- *(int*)0x%x" % addr, substrs=["15"]) + +def test(self): +corefile = self.getBuildArtifact("process.core") +self.build() +(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( +self, "// break here", lldb.SBFileSpec("main.c") +) + +self.do_variable_access_tests(thread.GetFrameAtIndex(0)) + +self.runCmd("process save-core -s stack " + corefile) +self.dbg.DeleteTarget(target) + +# Now load the corefile +target = self.dbg.CreateTarget("") +process = target.LoadCore(corefile) +thread = process.GetSelectedThread() +self.assertTrue(process.GetSelectedThread().IsValid()) + +self.do_variable_access_tests(thread.GetFrameAtIndex(0)) diff --git a/lldb/test/API/macosx/tbi-honored/main.c b/lldb/test/API/macosx/tbi-honored/main.c new file mode 100644 index 00..3d7ad0b04cd664 --- /dev/null +++ b/lldb/test/API/
[Lldb-commits] [lldb] [lldb] [Mach-O] ProcessMachCore needs to strip TBI data from addrs (PR #84998)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jason Molenda (jasonmolenda) Changes Darwin AArch64 application processors are run with Top Byte Ignore mode enabled so metadata may be stored in the top byte, it needs to be ignored when reading/writing memory. David Spickett handled this already in the base class Process::ReadMemory but ProcessMachCore overrides that method (to avoid the memory cache) and did not pick up the same change. I add a test case that creates a pointer with metadata in the top byte and dereferences it with a live process and with a corefile. rdar://123784501 --- Full diff: https://github.com/llvm/llvm-project/pull/84998.diff 4 Files Affected: - (modified) lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp (+1-1) - (added) lldb/test/API/macosx/tbi-honored/Makefile (+3) - (added) lldb/test/API/macosx/tbi-honored/TestTBIHonored.py (+49) - (added) lldb/test/API/macosx/tbi-honored/main.c (+13) ``diff diff --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp index 3961dcf0fbcc0e..7b9938d4f02020 100644 --- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp +++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp @@ -652,7 +652,7 @@ size_t ProcessMachCore::ReadMemory(addr_t addr, void *buf, size_t size, Status &error) { // Don't allow the caching that lldb_private::Process::ReadMemory does since // in core files we have it all cached our our core file anyway. - return DoReadMemory(addr, buf, size, error); + return DoReadMemory(FixAnyAddress(addr), buf, size, error); } size_t ProcessMachCore::DoReadMemory(addr_t addr, void *buf, size_t size, diff --git a/lldb/test/API/macosx/tbi-honored/Makefile b/lldb/test/API/macosx/tbi-honored/Makefile new file mode 100644 index 00..10495940055b63 --- /dev/null +++ b/lldb/test/API/macosx/tbi-honored/Makefile @@ -0,0 +1,3 @@ +C_SOURCES := main.c + +include Makefile.rules diff --git a/lldb/test/API/macosx/tbi-honored/TestTBIHonored.py b/lldb/test/API/macosx/tbi-honored/TestTBIHonored.py new file mode 100644 index 00..d38685359af6d1 --- /dev/null +++ b/lldb/test/API/macosx/tbi-honored/TestTBIHonored.py @@ -0,0 +1,49 @@ +"""Test that lldb on Darwin ignores metadata in the top byte of addresses.""" + +import os +import re +import subprocess + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestTBIHonored(TestBase): +@no_debug_info_test +@skipUnlessDarwin +@skipIf(archs=no_match(["arm64", "arm64e"])) +@skipIfRemote +def do_variable_access_tests(self, frame): +self.assertEqual( +frame.variables["pb"][0] +.GetChildMemberWithName("p") +.Dereference() +.GetValueAsUnsigned(), +15, +) +addr = frame.variables["pb"][0].GetChildMemberWithName("p").GetValueAsUnsigned() +self.expect("expr -- *pb.p", substrs=["15"]) +self.expect("frame variable *pb.p", substrs=["15"]) +self.expect("expr -- *(int*)0x%x" % addr, substrs=["15"]) + +def test(self): +corefile = self.getBuildArtifact("process.core") +self.build() +(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( +self, "// break here", lldb.SBFileSpec("main.c") +) + +self.do_variable_access_tests(thread.GetFrameAtIndex(0)) + +self.runCmd("process save-core -s stack " + corefile) +self.dbg.DeleteTarget(target) + +# Now load the corefile +target = self.dbg.CreateTarget("") +process = target.LoadCore(corefile) +thread = process.GetSelectedThread() +self.assertTrue(process.GetSelectedThread().IsValid()) + +self.do_variable_access_tests(thread.GetFrameAtIndex(0)) diff --git a/lldb/test/API/macosx/tbi-honored/main.c b/lldb/test/API/macosx/tbi-honored/main.c new file mode 100644 index 00..3d7ad0b04cd664 --- /dev/null +++ b/lldb/test/API/macosx/tbi-honored/main.c @@ -0,0 +1,13 @@ +#include +#include +union ptrbytes { + int *p; + uint8_t bytes[8]; +}; +int main() { + int c = 15; + union ptrbytes pb; + pb.p = &c; + pb.bytes[7] = 0xfe; + printf("%d\n", *pb.p); // break here +} `` https://github.com/llvm/llvm-project/pull/84998 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] e2468bf - [lldb][debugserver] Update flags past to app launch request
Author: Jason Molenda Date: 2024-03-12T17:19:46-07:00 New Revision: e2468bf16a0c1f63a39aa417c15c03ebd77fab9e URL: https://github.com/llvm/llvm-project/commit/e2468bf16a0c1f63a39aa417c15c03ebd77fab9e DIFF: https://github.com/llvm/llvm-project/commit/e2468bf16a0c1f63a39aa417c15c03ebd77fab9e.diff LOG: [lldb][debugserver] Update flags past to app launch request rdar://117421999 Added: Modified: lldb/tools/debugserver/source/MacOSX/MachProcess.mm Removed: diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm index 87bdbf835bfd10..70b4564a027b1b 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm +++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm @@ -472,6 +472,8 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options, // And there are some other options at the top level in this dictionary: [options setObject:[NSNumber numberWithBool:YES] forKey:FBSOpenApplicationOptionKeyUnlockDevice]; + [options setObject:[NSNumber numberWithBool:YES] + forKey:FBSOpenApplicationOptionKeyPromptUnlockDevice]; // We have to get the "sequence ID & UUID" for this app bundle path and send // them to FBS: ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Avoid a potential exit(1) in LLVMContext::diagnose() (PR #84992)
jimingham wrote: This makes sense to me. It still gives me the willies that there's exit's lurking in the llvm libraries, but so long as there are, we really do need to side-step them. https://github.com/llvm/llvm-project/pull/84992 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Allow languages to filter breakpoints set by line (PR #83908)
https://github.com/jimingham approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/83908 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Allow languages to filter breakpoints set by line (PR #83908)
https://github.com/felipepiovezan updated https://github.com/llvm/llvm-project/pull/83908 >From 51307b548d09c34ee06037ccf459110e451970a9 Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Mon, 4 Mar 2024 09:56:18 -0800 Subject: [PATCH 1/6] [lldb] Allow languages to filter breakpoints set by line Some languages may create artificial functions that have no real user code, even though there is line table information for them. One such case is with coroutine code that receives the CoroSplitter transformation in LLVM IR. That code transformation creates many different Functions, cloning one Instruction into many Instructions in many different Functions and copying the associated debug locations. It would be difficult to make that pass delete debug locations of cloned instructions in a language agnostic way (is it even possible?), but LLDB can ignore certain locations by querying its Language APIs and having it decide based on, for example, mangling information. --- lldb/include/lldb/Target/Language.h | 4 lldb/source/Breakpoint/BreakpointResolver.cpp | 12 2 files changed, 16 insertions(+) diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index 0cbd8a32dccd54..957c40eb7c0772 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -339,6 +339,10 @@ class Language : public PluginInterface { virtual llvm::StringRef GetInstanceVariableName() { return {}; } + virtual bool IsInterestingCtxForLineBreakpoint(const SymbolContext &) const { +return true; + } + protected: // Classes that inherit from Language can see and modify these diff --git a/lldb/source/Breakpoint/BreakpointResolver.cpp b/lldb/source/Breakpoint/BreakpointResolver.cpp index bc6348716ef418..876b30c6d76d55 100644 --- a/lldb/source/Breakpoint/BreakpointResolver.cpp +++ b/lldb/source/Breakpoint/BreakpointResolver.cpp @@ -23,6 +23,7 @@ #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/SymbolContext.h" +#include "lldb/Target/Language.h" #include "lldb/Target/Target.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" @@ -199,6 +200,15 @@ bool operator<(const SourceLoc lhs, const SourceLoc rhs) { } } // namespace +static void +ApplyLanguageFilters(llvm::SmallVectorImpl &sc_list) { + llvm::erase_if(sc_list, [](SymbolContext &sc) { +if (Language *lang = Language::FindPlugin(sc.GetLanguage())) + return !lang->IsInterestingCtxForLineBreakpoint(sc); +return false; + }); +} + void BreakpointResolver::SetSCMatchesByLine( SearchFilter &filter, SymbolContextList &sc_list, bool skip_prologue, llvm::StringRef log_ident, uint32_t line, std::optional column) { @@ -206,6 +216,8 @@ void BreakpointResolver::SetSCMatchesByLine( for (uint32_t i = 0; i < sc_list.GetSize(); ++i) all_scs.push_back(sc_list[i]); + ApplyLanguageFilters(all_scs); + while (all_scs.size()) { uint32_t closest_line = UINT32_MAX; >From 7ea76d6c04d063d50da52756179639f2037aa793 Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Tue, 5 Mar 2024 18:47:51 -0800 Subject: [PATCH 2/6] fixup! add target option --- lldb/include/lldb/Target/Language.h | 9 ++-- lldb/include/lldb/Target/Target.h | 2 ++ lldb/source/Breakpoint/BreakpointResolver.cpp | 23 +-- lldb/source/Target/Target.cpp | 8 +++ lldb/source/Target/TargetProperties.td| 3 +++ 5 files changed, 31 insertions(+), 14 deletions(-) diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index 957c40eb7c0772..9db9f4e297e114 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -339,8 +339,13 @@ class Language : public PluginInterface { virtual llvm::StringRef GetInstanceVariableName() { return {}; } - virtual bool IsInterestingCtxForLineBreakpoint(const SymbolContext &) const { -return true; + // Returns true if this SymbolContext should be used when setting breakpoints + // by line (number or regex). This is useful for languages that create + // artificial functions without any meaningful user code associated with them + // (e.g. code that gets expanded in late compilation stages, like by + // CoroSplitter). + virtual bool IsArtificialCtxForLineBreakpoint(const SymbolContext &) const { +return false; } protected: diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 8f57358981d4d2..ab04aa57f17300 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -258,6 +258,8 @@ class TargetProperties : public Properties { bool GetDebugUtilityExpression() const; + bool GetIgnoreBreakpointsFromLanguageArtificialLocations() const; + private: // Callbacks for m_launch_info. void Arg0ValueChangedCallback(); diff --git a/lldb/source/Breakpoint/
[Lldb-commits] [lldb] [lldb][test] Add `pexpect` category for tests that `import pexpect` (PR #84860)
https://github.com/rupprecht updated https://github.com/llvm/llvm-project/pull/84860 >From b5e04eb49c89c8c654305c6ba5db5e2f237bccec Mon Sep 17 00:00:00 2001 From: Jordan Rupprecht Date: Mon, 11 Mar 2024 11:23:59 -0700 Subject: [PATCH 1/4] [lldb][test] Add `pexpect` category for tests that `import pexpect` - Add pexpect category - Replace skipIfWindows with this - Make categories apply to test classes too --- .../Python/lldbsuite/test/decorators.py | 4 lldb/packages/Python/lldbsuite/test/dotest.py | 20 +++ .../Python/lldbsuite/test/lldbpexpect.py | 2 +- .../Python/lldbsuite/test/test_categories.py | 1 + .../Python/lldbsuite/test/test_result.py | 10 +- .../expression/TestExpressionCmd.py | 5 + .../expression/TestRepeatedExprs.py | 5 + .../TestFrameVariableResponse.py | 5 + .../benchmarks/startup/TestStartupDelays.py | 5 + .../benchmarks/stepping/TestSteppingSpeed.py | 5 + .../TestCompileRunToBreakpointTurnaround.py | 5 + .../API/terminal/TestSTTYBeforeAndAfter.py| 2 +- 12 files changed, 34 insertions(+), 35 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index b691f82b90652c..8e13aa6a13882f 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -409,10 +409,6 @@ def add_test_categories(cat): cat = test_categories.validate(cat, True) def impl(func): -if isinstance(func, type) and issubclass(func, unittest.TestCase): -raise Exception( -"@add_test_categories can only be used to decorate a test method" -) try: if hasattr(func, "categories"): cat.extend(func.categories) diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py index 291d7bad5c0897..268c02e6b49dde 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest.py +++ b/lldb/packages/Python/lldbsuite/test/dotest.py @@ -914,6 +914,25 @@ def checkForkVForkSupport(): configuration.skip_categories.append("fork") +def checkPexpectSupport(): +from lldbsuite.test import lldbplatformutil + +platform = lldbplatformutil.getPlatform() + +# llvm.org/pr22274: need a pexpect replacement for windows +if platform in ["windows"]: +if configuration.verbose: +print("pexpect tests will be skipped because of unsupported platform") +configuration.skip_categories.append("pexpect") +elif not configuration.shouldSkipBecauseOfCategories(["pexpect"]): +try: +import pexpect +except: +print( +"Warning: pexpect is not installed, but pexpect tests are not being skipped." +) + + def run_suite(): # On MacOS X, check to make sure that domain for com.apple.DebugSymbols defaults # does not exist before proceeding to running the test suite. @@ -1013,6 +1032,7 @@ def run_suite(): checkDebugServerSupport() checkObjcSupport() checkForkVForkSupport() +checkPexpectSupport() skipped_categories_list = ", ".join(configuration.skip_categories) print( diff --git a/lldb/packages/Python/lldbsuite/test/lldbpexpect.py b/lldb/packages/Python/lldbsuite/test/lldbpexpect.py index 9d216d90307473..998a080565b6b3 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbpexpect.py +++ b/lldb/packages/Python/lldbsuite/test/lldbpexpect.py @@ -10,7 +10,7 @@ @skipIfRemote -@skipIfWindows # llvm.org/pr22274: need a pexpect replacement for windows +@add_test_categories(["pexpect"]) class PExpectTest(TestBase): NO_DEBUG_INFO_TESTCASE = True PROMPT = "(lldb) " diff --git a/lldb/packages/Python/lldbsuite/test/test_categories.py b/lldb/packages/Python/lldbsuite/test/test_categories.py index 3f8de175e29df3..036bda9c957d11 100644 --- a/lldb/packages/Python/lldbsuite/test/test_categories.py +++ b/lldb/packages/Python/lldbsuite/test/test_categories.py @@ -33,6 +33,7 @@ "lldb-server": "Tests related to lldb-server", "lldb-dap": "Tests for the Debug Adaptor Protocol with lldb-dap", "llgs": "Tests for the gdb-server functionality of lldb-server", +"pexpect": "Tests requiring the pexpect library to be available", "objc": "Tests related to the Objective-C programming language support", "pyapi": "Tests related to the Python API", "std-module": "Tests related to importing the std module", diff --git a/lldb/packages/Python/lldbsuite/test/test_result.py b/lldb/packages/Python/lldbsuite/test/test_result.py index 20365f53a67541..cda67ae27d4674 100644 --- a/lldb/packages/Python/lldbsuite/test/test_result.py +++ b/lldb/packages/Python/lldbsuite/test/test_result.py @@ -148,9 +148,11 @@ def getCategoriesForTest(self, test): Gets all the categories for the currently running test meth
[Lldb-commits] [lldb] [lldb][test] Add `pexpect` category for tests that `import pexpect` (PR #84860)
https://github.com/rupprecht updated https://github.com/llvm/llvm-project/pull/84860 >From b5e04eb49c89c8c654305c6ba5db5e2f237bccec Mon Sep 17 00:00:00 2001 From: Jordan Rupprecht Date: Mon, 11 Mar 2024 11:23:59 -0700 Subject: [PATCH 1/5] [lldb][test] Add `pexpect` category for tests that `import pexpect` - Add pexpect category - Replace skipIfWindows with this - Make categories apply to test classes too --- .../Python/lldbsuite/test/decorators.py | 4 lldb/packages/Python/lldbsuite/test/dotest.py | 20 +++ .../Python/lldbsuite/test/lldbpexpect.py | 2 +- .../Python/lldbsuite/test/test_categories.py | 1 + .../Python/lldbsuite/test/test_result.py | 10 +- .../expression/TestExpressionCmd.py | 5 + .../expression/TestRepeatedExprs.py | 5 + .../TestFrameVariableResponse.py | 5 + .../benchmarks/startup/TestStartupDelays.py | 5 + .../benchmarks/stepping/TestSteppingSpeed.py | 5 + .../TestCompileRunToBreakpointTurnaround.py | 5 + .../API/terminal/TestSTTYBeforeAndAfter.py| 2 +- 12 files changed, 34 insertions(+), 35 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index b691f82b90652c..8e13aa6a13882f 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -409,10 +409,6 @@ def add_test_categories(cat): cat = test_categories.validate(cat, True) def impl(func): -if isinstance(func, type) and issubclass(func, unittest.TestCase): -raise Exception( -"@add_test_categories can only be used to decorate a test method" -) try: if hasattr(func, "categories"): cat.extend(func.categories) diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py index 291d7bad5c0897..268c02e6b49dde 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest.py +++ b/lldb/packages/Python/lldbsuite/test/dotest.py @@ -914,6 +914,25 @@ def checkForkVForkSupport(): configuration.skip_categories.append("fork") +def checkPexpectSupport(): +from lldbsuite.test import lldbplatformutil + +platform = lldbplatformutil.getPlatform() + +# llvm.org/pr22274: need a pexpect replacement for windows +if platform in ["windows"]: +if configuration.verbose: +print("pexpect tests will be skipped because of unsupported platform") +configuration.skip_categories.append("pexpect") +elif not configuration.shouldSkipBecauseOfCategories(["pexpect"]): +try: +import pexpect +except: +print( +"Warning: pexpect is not installed, but pexpect tests are not being skipped." +) + + def run_suite(): # On MacOS X, check to make sure that domain for com.apple.DebugSymbols defaults # does not exist before proceeding to running the test suite. @@ -1013,6 +1032,7 @@ def run_suite(): checkDebugServerSupport() checkObjcSupport() checkForkVForkSupport() +checkPexpectSupport() skipped_categories_list = ", ".join(configuration.skip_categories) print( diff --git a/lldb/packages/Python/lldbsuite/test/lldbpexpect.py b/lldb/packages/Python/lldbsuite/test/lldbpexpect.py index 9d216d90307473..998a080565b6b3 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbpexpect.py +++ b/lldb/packages/Python/lldbsuite/test/lldbpexpect.py @@ -10,7 +10,7 @@ @skipIfRemote -@skipIfWindows # llvm.org/pr22274: need a pexpect replacement for windows +@add_test_categories(["pexpect"]) class PExpectTest(TestBase): NO_DEBUG_INFO_TESTCASE = True PROMPT = "(lldb) " diff --git a/lldb/packages/Python/lldbsuite/test/test_categories.py b/lldb/packages/Python/lldbsuite/test/test_categories.py index 3f8de175e29df3..036bda9c957d11 100644 --- a/lldb/packages/Python/lldbsuite/test/test_categories.py +++ b/lldb/packages/Python/lldbsuite/test/test_categories.py @@ -33,6 +33,7 @@ "lldb-server": "Tests related to lldb-server", "lldb-dap": "Tests for the Debug Adaptor Protocol with lldb-dap", "llgs": "Tests for the gdb-server functionality of lldb-server", +"pexpect": "Tests requiring the pexpect library to be available", "objc": "Tests related to the Objective-C programming language support", "pyapi": "Tests related to the Python API", "std-module": "Tests related to importing the std module", diff --git a/lldb/packages/Python/lldbsuite/test/test_result.py b/lldb/packages/Python/lldbsuite/test/test_result.py index 20365f53a67541..cda67ae27d4674 100644 --- a/lldb/packages/Python/lldbsuite/test/test_result.py +++ b/lldb/packages/Python/lldbsuite/test/test_result.py @@ -148,9 +148,11 @@ def getCategoriesForTest(self, test): Gets all the categories for the currently running test meth
[Lldb-commits] [lldb] [lldb][test] Add `pexpect` category for tests that `import pexpect` (PR #84860)
@@ -914,6 +914,25 @@ def checkForkVForkSupport(): configuration.skip_categories.append("fork") +def checkPexpectSupport(): +from lldbsuite.test import lldbplatformutil + +platform = lldbplatformutil.getPlatform() + +# llvm.org/pr22274: need a pexpect replacement for windows +if platform in ["windows"]: +if configuration.verbose: +print("pexpect tests will be skipped because of unsupported platform") +configuration.skip_categories.append("pexpect") +elif not configuration.shouldSkipBecauseOfCategories(["pexpect"]): +try: +import pexpect +except: +print( +"Warning: pexpect is not installed, but pexpect tests are not being skipped." rupprecht wrote: Proposed some more specific wording in https://github.com/llvm/llvm-project/pull/84860/commits/bcfc5e8f2f18e8eb8f5a96e18c649f3cb2e248c0 But this `elif` block is the least thing that I care about actually landing :) I think it's helpful, but if this is contentious, it's not a big deal to drop it and just have a potentially worse error message. So I dropped it altogether in https://github.com/llvm/llvm-project/pull/84860/commits/03e13152eac8416c31414b4f469e281c40b80deb. I can always add it back if needed, either in this PR or as a followup commit. > So what would happens without this code? Wouldn't we try to import pexpect > anyway in the relevant test? In other words, do we even need this? Yep, see the snippet above ([link](#discussion_r1521684820)) for what it'd look like if we just remove it. Having a specific check+error text here is not essential, but might help some developer if they aren't aware of how to skip this category. > It seems that printing a warning for non-pexpect either adds noise to the > already verbose test output or will be invisible if the test passes. Agreed about spamminess; that was changed in https://github.com/llvm/llvm-project/pull/84860/commits/7f2ec70a35d1f5426afcf354f9b16b0052e81df2 to make this a hard error. > If the error message is poor enough that we would want to print something > more actionable, could we do it from the PExpectTest base class? That would not work for tests that use pexpect outside of `PExpectTest`, which are: - lldb/test/API/terminal/TestSTTYBeforeAndAfter.py - lldb/test/API/macosx/nslog/TestDarwinNSLogOutput.py - lldb/test/API/benchmarks/expression/TestRepeatedExprs.py (and many other benchmark tests) So if the user just runs `ninja check-lldb`, they'd get an actionable message from PExpectTest-based tests, but a potentially confusing one from TestSTTYBeforeAndAfter. https://github.com/llvm/llvm-project/pull/84860 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits