[Lldb-commits] [lldb] [LLDB] Fix crash when using tab completion on class variables (PR #83234)
https://github.com/svs-quic created https://github.com/llvm/llvm-project/pull/83234 We weren't checking to see if the partial_path was empty before adding completions and this led to crashes when the class object and a variable both start with the same substring. Fixes [#81536](https://github.com/llvm/llvm-project/issues/81536) >From a7d84af1a887169e9c1477628229a8091364eff6 Mon Sep 17 00:00:00 2001 From: Sudharsan Veeravalli Date: Wed, 28 Feb 2024 13:46:46 +0530 Subject: [PATCH] [LLDB] Fix crash when using tab completion on class variables --- lldb/source/Symbol/Variable.cpp | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp index 2bb2ff7db4b721..a33c3433d9e245 100644 --- a/lldb/source/Symbol/Variable.cpp +++ b/lldb/source/Symbol/Variable.cpp @@ -509,15 +509,17 @@ static void PrivateAutoCompleteMembers( CompilerType member_compiler_type = compiler_type.GetFieldAtIndex( i, member_name, nullptr, nullptr, nullptr); - if (partial_member_name.empty() || - llvm::StringRef(member_name).starts_with(partial_member_name)) { + if (partial_member_name.empty()) { +request.AddCompletion((prefix_path + member_name).str()); + } else if (llvm::StringRef(member_name) + .starts_with(partial_member_name)) { if (member_name == partial_member_name) { PrivateAutoComplete( frame, partial_path, prefix_path + member_name, // Anything that has been resolved // already will be in here member_compiler_type.GetCanonicalType(), request); -} else { +} else if (partial_path.empty()) { request.AddCompletion((prefix_path + member_name).str()); } } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix crash when using tab completion on class variables (PR #83234)
https://github.com/svs-quic updated https://github.com/llvm/llvm-project/pull/83234 >From 87c442c0911fd4671da1ae03c5d967857fd363d1 Mon Sep 17 00:00:00 2001 From: Sudharsan Veeravalli Date: Wed, 28 Feb 2024 13:46:46 +0530 Subject: [PATCH] [LLDB] Fix crash when using tab completion on class variables --- lldb/source/Symbol/Variable.cpp | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp index 2bb2ff7db4b721..a33c3433d9e245 100644 --- a/lldb/source/Symbol/Variable.cpp +++ b/lldb/source/Symbol/Variable.cpp @@ -509,15 +509,17 @@ static void PrivateAutoCompleteMembers( CompilerType member_compiler_type = compiler_type.GetFieldAtIndex( i, member_name, nullptr, nullptr, nullptr); - if (partial_member_name.empty() || - llvm::StringRef(member_name).starts_with(partial_member_name)) { + if (partial_member_name.empty()) { +request.AddCompletion((prefix_path + member_name).str()); + } else if (llvm::StringRef(member_name) + .starts_with(partial_member_name)) { if (member_name == partial_member_name) { PrivateAutoComplete( frame, partial_path, prefix_path + member_name, // Anything that has been resolved // already will be in here member_compiler_type.GetCanonicalType(), request); -} else { +} else if (partial_path.empty()) { request.AddCompletion((prefix_path + member_name).str()); } } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix crash when using tab completion on class variables (PR #83234)
https://github.com/svs-quic updated https://github.com/llvm/llvm-project/pull/83234 >From cf1359a825b09d48c312ce40da950c13f30c67c8 Mon Sep 17 00:00:00 2001 From: Sudharsan Veeravalli Date: Wed, 28 Feb 2024 13:46:46 +0530 Subject: [PATCH] [LLDB] Fix crash when using tab completion on class variables --- lldb/source/Symbol/Variable.cpp | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp index 2bb2ff7db4b721..a33c3433d9e245 100644 --- a/lldb/source/Symbol/Variable.cpp +++ b/lldb/source/Symbol/Variable.cpp @@ -509,15 +509,17 @@ static void PrivateAutoCompleteMembers( CompilerType member_compiler_type = compiler_type.GetFieldAtIndex( i, member_name, nullptr, nullptr, nullptr); - if (partial_member_name.empty() || - llvm::StringRef(member_name).starts_with(partial_member_name)) { + if (partial_member_name.empty()) { +request.AddCompletion((prefix_path + member_name).str()); + } else if (llvm::StringRef(member_name) + .starts_with(partial_member_name)) { if (member_name == partial_member_name) { PrivateAutoComplete( frame, partial_path, prefix_path + member_name, // Anything that has been resolved // already will be in here member_compiler_type.GetCanonicalType(), request); -} else { +} else if (partial_path.empty()) { request.AddCompletion((prefix_path + member_name).str()); } } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix crash when using tab completion on class variables (PR #83234)
https://github.com/svs-quic ready_for_review https://github.com/llvm/llvm-project/pull/83234 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix crash when using tab completion on class variables (PR #83234)
https://github.com/svs-quic updated https://github.com/llvm/llvm-project/pull/83234 >From cf1359a825b09d48c312ce40da950c13f30c67c8 Mon Sep 17 00:00:00 2001 From: Sudharsan Veeravalli Date: Wed, 28 Feb 2024 13:46:46 +0530 Subject: [PATCH 1/2] [LLDB] Fix crash when using tab completion on class variables --- lldb/source/Symbol/Variable.cpp | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp index 2bb2ff7db4b721..a33c3433d9e245 100644 --- a/lldb/source/Symbol/Variable.cpp +++ b/lldb/source/Symbol/Variable.cpp @@ -509,15 +509,17 @@ static void PrivateAutoCompleteMembers( CompilerType member_compiler_type = compiler_type.GetFieldAtIndex( i, member_name, nullptr, nullptr, nullptr); - if (partial_member_name.empty() || - llvm::StringRef(member_name).starts_with(partial_member_name)) { + if (partial_member_name.empty()) { +request.AddCompletion((prefix_path + member_name).str()); + } else if (llvm::StringRef(member_name) + .starts_with(partial_member_name)) { if (member_name == partial_member_name) { PrivateAutoComplete( frame, partial_path, prefix_path + member_name, // Anything that has been resolved // already will be in here member_compiler_type.GetCanonicalType(), request); -} else { +} else if (partial_path.empty()) { request.AddCompletion((prefix_path + member_name).str()); } } >From dab0c4b75bd07cc5fbad313311b6a747f985712d Mon Sep 17 00:00:00 2001 From: Sudharsan Veeravalli Date: Wed, 28 Feb 2024 21:04:28 +0530 Subject: [PATCH 2/2] Add test --- .../API/functionalities/completion/TestCompletion.py | 6 -- lldb/test/API/functionalities/completion/main.cpp| 9 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py index f71bc73928f0f4..2f6af3cfce109d 100644 --- a/lldb/test/API/functionalities/completion/TestCompletion.py +++ b/lldb/test/API/functionalities/completion/TestCompletion.py @@ -60,10 +60,12 @@ def test_dwim_print(self): def do_test_variable_completion(self, command): self.complete_from_to(f"{command} fo", f"{command} fooo") -self.complete_from_to(f"{command} fooo.", f"{command} fooo.") +self.complete_from_to(f"{command} fooo.", f"{command} fooo.t") +self.complete_from_to(f"{command} fooo.t.", f"{command} fooo.t.x") self.complete_from_to(f"{command} fooo.dd", f"{command} fooo.dd") -self.complete_from_to(f"{command} ptr_fooo->", f"{command} ptr_fooo->") +self.complete_from_to(f"{command} ptr_fooo->", f"{command} ptr_fooo->t") +self.complete_from_to(f"{command} ptr_fooo->t", f"{command} ptr_fooo->t.x") self.complete_from_to(f"{command} ptr_fooo->dd", f"{command} ptr_fooo->dd") self.complete_from_to(f"{command} cont", f"{command} container") diff --git a/lldb/test/API/functionalities/completion/main.cpp b/lldb/test/API/functionalities/completion/main.cpp index 06ff5773e8a9dc..104dcc88e8c118 100644 --- a/lldb/test/API/functionalities/completion/main.cpp +++ b/lldb/test/API/functionalities/completion/main.cpp @@ -1,8 +1,17 @@ #include +class Baz +{ +public: +int x; +}; + class Foo { public: +Baz t; +int temp; + int Bar(int x, int y) { return x + y; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix crash when using tab completion on class variables (PR #83234)
https://github.com/svs-quic updated https://github.com/llvm/llvm-project/pull/83234 >From cf1359a825b09d48c312ce40da950c13f30c67c8 Mon Sep 17 00:00:00 2001 From: Sudharsan Veeravalli Date: Wed, 28 Feb 2024 13:46:46 +0530 Subject: [PATCH 1/3] [LLDB] Fix crash when using tab completion on class variables --- lldb/source/Symbol/Variable.cpp | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp index 2bb2ff7db4b721..a33c3433d9e245 100644 --- a/lldb/source/Symbol/Variable.cpp +++ b/lldb/source/Symbol/Variable.cpp @@ -509,15 +509,17 @@ static void PrivateAutoCompleteMembers( CompilerType member_compiler_type = compiler_type.GetFieldAtIndex( i, member_name, nullptr, nullptr, nullptr); - if (partial_member_name.empty() || - llvm::StringRef(member_name).starts_with(partial_member_name)) { + if (partial_member_name.empty()) { +request.AddCompletion((prefix_path + member_name).str()); + } else if (llvm::StringRef(member_name) + .starts_with(partial_member_name)) { if (member_name == partial_member_name) { PrivateAutoComplete( frame, partial_path, prefix_path + member_name, // Anything that has been resolved // already will be in here member_compiler_type.GetCanonicalType(), request); -} else { +} else if (partial_path.empty()) { request.AddCompletion((prefix_path + member_name).str()); } } >From dab0c4b75bd07cc5fbad313311b6a747f985712d Mon Sep 17 00:00:00 2001 From: Sudharsan Veeravalli Date: Wed, 28 Feb 2024 21:04:28 +0530 Subject: [PATCH 2/3] Add test --- .../API/functionalities/completion/TestCompletion.py | 6 -- lldb/test/API/functionalities/completion/main.cpp| 9 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py index f71bc73928f0f4..2f6af3cfce109d 100644 --- a/lldb/test/API/functionalities/completion/TestCompletion.py +++ b/lldb/test/API/functionalities/completion/TestCompletion.py @@ -60,10 +60,12 @@ def test_dwim_print(self): def do_test_variable_completion(self, command): self.complete_from_to(f"{command} fo", f"{command} fooo") -self.complete_from_to(f"{command} fooo.", f"{command} fooo.") +self.complete_from_to(f"{command} fooo.", f"{command} fooo.t") +self.complete_from_to(f"{command} fooo.t.", f"{command} fooo.t.x") self.complete_from_to(f"{command} fooo.dd", f"{command} fooo.dd") -self.complete_from_to(f"{command} ptr_fooo->", f"{command} ptr_fooo->") +self.complete_from_to(f"{command} ptr_fooo->", f"{command} ptr_fooo->t") +self.complete_from_to(f"{command} ptr_fooo->t", f"{command} ptr_fooo->t.x") self.complete_from_to(f"{command} ptr_fooo->dd", f"{command} ptr_fooo->dd") self.complete_from_to(f"{command} cont", f"{command} container") diff --git a/lldb/test/API/functionalities/completion/main.cpp b/lldb/test/API/functionalities/completion/main.cpp index 06ff5773e8a9dc..104dcc88e8c118 100644 --- a/lldb/test/API/functionalities/completion/main.cpp +++ b/lldb/test/API/functionalities/completion/main.cpp @@ -1,8 +1,17 @@ #include +class Baz +{ +public: +int x; +}; + class Foo { public: +Baz t; +int temp; + int Bar(int x, int y) { return x + y; >From 12b43652a14b0e1d31465859d58aedcd2d63dace Mon Sep 17 00:00:00 2001 From: Sudharsan Veeravalli Date: Wed, 28 Feb 2024 21:14:35 +0530 Subject: [PATCH 3/3] Clang-format changes --- lldb/test/API/functionalities/completion/main.cpp | 14 +- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lldb/test/API/functionalities/completion/main.cpp b/lldb/test/API/functionalities/completion/main.cpp index 104dcc88e8c118..f925c1d5acf31c 100644 --- a/lldb/test/API/functionalities/completion/main.cpp +++ b/lldb/test/API/functionalities/completion/main.cpp @@ -1,21 +1,17 @@ #include -class Baz -{ +class Baz { public: -int x; + int x; }; class Foo { public: -Baz t; -int temp; + Baz t; + int temp; -int Bar(int x, int y) -{ -return x + y; -} + int Bar(int x, int y) { return x + y; } }; namespace { int Quux (void) { return 0; } } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix crash when using tab completion on class variables (PR #83234)
svs-quic wrote: > Change itself is fine. But could you please add a test in > `lldb/test/API/functionalities/completion/TestCompletion.py`? Specifically in > `do_test_variable_completion` Done https://github.com/llvm/llvm-project/pull/83234 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix crash when using tab completion on class variables (PR #83234)
svs-quic wrote: > lgtm thanks! Thanks. I dont think I have commit access . Would you be able to merge this for me? https://github.com/llvm/llvm-project/pull/83234 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix crash when using tab completion on class variables (PR #83234)
@@ -60,10 +60,12 @@ def test_dwim_print(self): def do_test_variable_completion(self, command): self.complete_from_to(f"{command} fo", f"{command} fooo") -self.complete_from_to(f"{command} fooo.", f"{command} fooo.") +self.complete_from_to(f"{command} fooo.", f"{command} fooo.t") +self.complete_from_to(f"{command} fooo.t.", f"{command} fooo.t.x") self.complete_from_to(f"{command} fooo.dd", f"{command} fooo.dd") -self.complete_from_to(f"{command} ptr_fooo->", f"{command} ptr_fooo->") +self.complete_from_to(f"{command} ptr_fooo->", f"{command} ptr_fooo->t") +self.complete_from_to(f"{command} ptr_fooo->t", f"{command} ptr_fooo->t.x") svs-quic wrote: This should have been ptr_fooo->t. Will fix this in a follow up patch https://github.com/llvm/llvm-project/pull/83234 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix test failure introduced by #83234 (PR #83406)
https://github.com/svs-quic created https://github.com/llvm/llvm-project/pull/83406 Missed adding a . in the test check >From 1e686b765ba8a456f6a53731a2de2f28d41f6a9c Mon Sep 17 00:00:00 2001 From: Sudharsan Veeravalli Date: Thu, 29 Feb 2024 16:20:35 +0530 Subject: [PATCH] [LLDB] Fix test failure introduced by #83234 --- lldb/test/API/functionalities/completion/TestCompletion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py index 2f6af3cfce109d..0d6907e0c3d229 100644 --- a/lldb/test/API/functionalities/completion/TestCompletion.py +++ b/lldb/test/API/functionalities/completion/TestCompletion.py @@ -65,7 +65,7 @@ def do_test_variable_completion(self, command): self.complete_from_to(f"{command} fooo.dd", f"{command} fooo.dd") self.complete_from_to(f"{command} ptr_fooo->", f"{command} ptr_fooo->t") -self.complete_from_to(f"{command} ptr_fooo->t", f"{command} ptr_fooo->t.x") +self.complete_from_to(f"{command} ptr_fooo->t.", f"{command} ptr_fooo->t.x") self.complete_from_to(f"{command} ptr_fooo->dd", f"{command} ptr_fooo->dd") self.complete_from_to(f"{command} cont", f"{command} container") ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix test failure introduced by #83234 (PR #83406)
https://github.com/svs-quic ready_for_review https://github.com/llvm/llvm-project/pull/83406 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix test failure introduced by #83234 (PR #83406)
svs-quic wrote: @Michael137 could you please help merge this one as well. https://github.com/llvm/llvm-project/pull/83406 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Extended if conditions to support alias names for registers (PR #124475)
svs-quic wrote: Please add a test for this. https://github.com/llvm/llvm-project/pull/124475 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Extended if conditions to support alias names for registers (PR #124475)
svs-quic wrote: > A test for this would be finding the tests that check basic reads of > registers, and adding reads with the new names. There should be one for core > files and one for live processes. Basic support was added in https://github.com/llvm/llvm-project/commit/847de9c332775d1841fec9fea5cb5c41592a4c8f and I dont see any tests added there. We may have to write a new one for live process at the very least. > I haven't checked, but it's possible that this already works for core files Yeah this should work for core files. ``` (lldb) target create "lldb/test/API/functionalities/postmortem/elf-core/linux-riscv64.gpr_only.out" --core "ldb/test/API/functionalities/postmortem/elf-core/linux-riscv64.gpr_only.core" Core file 'lldb/test/API/functionalities/postmortem/elf-core/linux-riscv64.gpr_only.core' (riscv64) was loaded. (lldb) re re x8 fp = 0x00fff4d5fcf0 (lldb) re re x21 s5 = 0x00fffccd8d28 ``` https://github.com/llvm/llvm-project/pull/124475 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits