[Lldb-commits] [lldb] [lldb] Correctly invalidate unloaded image tokens (PR #65945)

2023-09-11 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett review_requested 
https://github.com/llvm/llvm-project/pull/65945
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Correctly invalidate unloaded image tokens (PR #65945)

2023-09-11 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett created 
https://github.com/llvm/llvm-project/pull/65945:

Some functions in Process were using LLDB_INVALID_ADDRESS instead of 
LLDB_INVALID_TOKEN.

The only visible effect of this appears to be that "process unload " would 
complete to 0 even after the image was unloaded. Since the command is checking 
for LLDB_INVALID_TOKEN.

Everything else worked somehow. I've added a check to the existing load unload 
tests anyway.

The tab completion cannot be checked as is, but when I make them more strict in 
a later patch it will be tested.

>From a2d71320d618cc3900c3d20e0ea9c5e7b0220561 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 11 Sep 2023 10:46:53 +
Subject: [PATCH] [lldb] Correctly invalidate unloaded image tokens

Some functions in Process were using LLDB_INVALID_ADDRESS
instead of LLDB_INVALID_TOKEN.

The only visible effect of this appears to be that
"process unload " would complete to 0 even after the
image was unloaded. Since the command is checking for
LLDB_INVALID_TOKEN.

Everything else worked somehow. I've added a check to the
existing load unload tests anyway.

The tab completion cannot be checked as is, but when I make
them more strict in a later patch it will be tested.
---
 lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp | 2 +-
 lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp | 2 +-
 lldb/source/Target/Process.cpp   | 4 ++--
 .../API/functionalities/load_unload/TestLoadUnload.py| 9 +
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp 
b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index 1e91f2ccd198259..b4f1b76c39dbebf 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -949,7 +949,7 @@ uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process 
*process,
 Status PlatformPOSIX::UnloadImage(lldb_private::Process *process,
   uint32_t image_token) {
   const addr_t image_addr = process->GetImagePtrFromToken(image_token);
-  if (image_addr == LLDB_INVALID_ADDRESS)
+  if (image_addr == LLDB_INVALID_IMAGE_TOKEN)
 return Status("Invalid image token");
 
   StreamString expr;
diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp 
b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
index cbac14e2ccf7a92..88d543289a8470e 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -415,7 +415,7 @@ uint32_t PlatformWindows::DoLoadImage(Process *process,
 
 Status PlatformWindows::UnloadImage(Process *process, uint32_t image_token) {
   const addr_t address = process->GetImagePtrFromToken(image_token);
-  if (address == LLDB_INVALID_ADDRESS)
+  if (address == LLDB_INVALID_IMAGE_TOKEN)
 return Status("invalid image token");
 
   StreamString expression;
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 2b0774588138881..f82ab05362fbee9 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -5911,12 +5911,12 @@ size_t Process::AddImageToken(lldb::addr_t image_ptr) {
 lldb::addr_t Process::GetImagePtrFromToken(size_t token) const {
   if (token < m_image_tokens.size())
 return m_image_tokens[token];
-  return LLDB_INVALID_ADDRESS;
+  return LLDB_INVALID_IMAGE_TOKEN;
 }
 
 void Process::ResetImageToken(size_t token) {
   if (token < m_image_tokens.size())
-m_image_tokens[token] = LLDB_INVALID_ADDRESS;
+m_image_tokens[token] = LLDB_INVALID_IMAGE_TOKEN;
 }
 
 Address
diff --git a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py 
b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
index 7e8acfa3021acfc..2208e520f1d5612 100644
--- a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
+++ b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
@@ -307,6 +307,15 @@ def run_lldb_process_load_and_unload_commands(self):
 patterns=["Unloading .* with index %s.*ok" % index],
 )
 
+# Confirm that we unloaded properly.
+self.expect(
+"image lookup -n a_function",
+"a_function should not exist after unload",
+error=True,
+matching=False,
+patterns=["1 match found"],
+)
+
 self.runCmd("process continue")
 
 @expectedFailureAll(oslist=["windows"])  # breakpoint not hit

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Correctly invalidate unloaded image tokens (PR #65945)

2023-09-11 Thread via lldb-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/65945
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Correctly invalidate unloaded image tokens (PR #65945)

2023-09-11 Thread via lldb-commits

llvmbot wrote:

@llvm/pr-subscribers-lldb


Changes

Some functions in Process were using LLDB_INVALID_ADDRESS instead of 
LLDB_INVALID_TOKEN.

The only visible effect of this appears to be that "process unload " would 
complete to 0 even after the image was unloaded. Since the command is checking 
for LLDB_INVALID_TOKEN.

Everything else worked somehow. I've added a check to the existing load unload 
tests anyway.

The tab completion cannot be checked as is, but when I make them more strict in 
a later patch it will be tested.
--
Full diff: https://github.com/llvm/llvm-project/pull/65945.diff

4 Files Affected:

- (modified) lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp (+1-1) 
- (modified) lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp (+1-1) 
- (modified) lldb/source/Target/Process.cpp (+2-2) 
- (modified) lldb/test/API/functionalities/load_unload/TestLoadUnload.py (+9) 



diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp 
b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index 1e91f2ccd198259..b4f1b76c39dbebf 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -949,7 +949,7 @@ uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process 
*process,
 Status PlatformPOSIX::UnloadImage(lldb_private::Process *process,
   uint32_t image_token) {
   const addr_t image_addr = process->GetImagePtrFromToken(image_token);
-  if (image_addr == LLDB_INVALID_ADDRESS)
+  if (image_addr == LLDB_INVALID_IMAGE_TOKEN)
 return Status("Invalid image token");
 
   StreamString expr;
diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp 
b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
index cbac14e2ccf7a92..88d543289a8470e 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -415,7 +415,7 @@ uint32_t PlatformWindows::DoLoadImage(Process *process,
 
 Status PlatformWindows::UnloadImage(Process *process, uint32_t image_token) {
   const addr_t address = process->GetImagePtrFromToken(image_token);
-  if (address == LLDB_INVALID_ADDRESS)
+  if (address == LLDB_INVALID_IMAGE_TOKEN)
 return Status("invalid image token");
 
   StreamString expression;
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 2b0774588138881..f82ab05362fbee9 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -5911,12 +5911,12 @@ size_t Process::AddImageToken(lldb::addr_t image_ptr) {
 lldb::addr_t Process::GetImagePtrFromToken(size_t token) const {
   if (token < m_image_tokens.size())
 return m_image_tokens[token];
-  return LLDB_INVALID_ADDRESS;
+  return LLDB_INVALID_IMAGE_TOKEN;
 }
 
 void Process::ResetImageToken(size_t token) {
   if (token < m_image_tokens.size())
-m_image_tokens[token] = LLDB_INVALID_ADDRESS;
+m_image_tokens[token] = LLDB_INVALID_IMAGE_TOKEN;
 }
 
 Address
diff --git a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py 
b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
index 7e8acfa3021acfc..2208e520f1d5612 100644
--- a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
+++ b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
@@ -307,6 +307,15 @@ def run_lldb_process_load_and_unload_commands(self):
 patterns=["Unloading .* with index %s.*ok" % index],
 )
 
+# Confirm that we unloaded properly.
+self.expect(
+"image lookup -n a_function",
+"a_function should not exist after unload",
+error=True,
+matching=False,
+patterns=["1 match found"],
+)
+
 self.runCmd("process continue")
 
 @expectedFailureAll(oslist=["windows"])  # breakpoint not hit




https://github.com/llvm/llvm-project/pull/65945
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 825adbe - [lldb] Don't tab complete stop-hook delete beyond 1st argument

2023-09-11 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2023-09-11T11:00:57Z
New Revision: 825adbe5585219ce731045defa019defaf96faab

URL: 
https://github.com/llvm/llvm-project/commit/825adbe5585219ce731045defa019defaf96faab
DIFF: 
https://github.com/llvm/llvm-project/commit/825adbe5585219ce731045defa019defaf96faab.diff

LOG: [lldb] Don't tab complete stop-hook delete beyond 1st argument

This already applies to enable and disable, delete was missing
a check.

This cannot be tested properly with the current completion tests,
but it will be when I make them more strict in a follow up patch.

Added: 


Modified: 
lldb/source/Commands/CommandObjectTarget.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index 3e024ff91b382d7..0ef0926d61f 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -4942,6 +4942,8 @@ class CommandObjectTargetStopHookDelete : public 
CommandObjectParsed {
   void
   HandleArgumentCompletion(CompletionRequest &request,
OptionElementVector &opt_element_vector) override {
+if (request.GetCursorIndex())
+  return;
 lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks(
 GetCommandInterpreter(), lldb::eStopHookIDCompletion, request, 
nullptr);
   }



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Fix a bug with cancelling "attach -w" after you have run a process previously (PR #65822)

2023-09-11 Thread via lldb-commits

jimingham wrote:

It seems a bit weird to have an Execution context with a thread and a stack 
frame but not the process they belong to.  I think it's easier to deal with it 
when we hand them out. 

Jim


> On Sep 9, 2023, at 11:57 AM, Greg Clayton ***@***.***> wrote:
> 
> 
> @clayborg commented on this pull request.
> 
> A different way to approach this fix is to just fix ExecutionContext so that 
> this can never be out of date by removing the "m_process_sp" member variable. 
> Is is not great that we can an execution context that has an older process, 
> and would we ever want an ExecutionContext to be able to have a mismatched 
> process? If we remove m_process_sp, we can always get the process from the 
> m_target_sp and then we can never get it wrong that way and we might avoid 
> some of the changes in this patch? Lemme know what you think as It would be 
> good to make sure our ExecutionContext variables can't get the wrong info.
> 
> —
> Reply to this email directly, view it on GitHub 
> ,
>  or unsubscribe 
> .
> You are receiving this because you authored the thread.
> 



https://github.com/llvm/llvm-project/pull/65822
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Correctly invalidate unloaded image tokens (PR #65945)

2023-09-11 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/65945:

>From b041cf0965a397104cd44d76d29f8d69ab26856d Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 11 Sep 2023 10:46:53 +
Subject: [PATCH] [lldb] Correctly invalidate unloaded image tokens

Some functions in Process were using LLDB_INVALID_ADDRESS
instead of LLDB_INVALID_TOKEN.

The only visible effect of this appears to be that
"process unload " would complete to 0 even after the
image was unloaded. Since the command is checking for
LLDB_INVALID_TOKEN.

Everything else worked somehow. I've added a check to the
existing load unload tests anyway.

The tab completion cannot be checked as is, but when I make
them more strict in a later patch it will be tested.
---
 lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp | 2 +-
 lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp | 2 +-
 lldb/source/Target/Process.cpp   | 4 ++--
 .../API/functionalities/load_unload/TestLoadUnload.py| 9 +
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp 
b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index 1e91f2ccd198259..b4f1b76c39dbebf 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -949,7 +949,7 @@ uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process 
*process,
 Status PlatformPOSIX::UnloadImage(lldb_private::Process *process,
   uint32_t image_token) {
   const addr_t image_addr = process->GetImagePtrFromToken(image_token);
-  if (image_addr == LLDB_INVALID_ADDRESS)
+  if (image_addr == LLDB_INVALID_IMAGE_TOKEN)
 return Status("Invalid image token");
 
   StreamString expr;
diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp 
b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
index cbac14e2ccf7a92..88d543289a8470e 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -415,7 +415,7 @@ uint32_t PlatformWindows::DoLoadImage(Process *process,
 
 Status PlatformWindows::UnloadImage(Process *process, uint32_t image_token) {
   const addr_t address = process->GetImagePtrFromToken(image_token);
-  if (address == LLDB_INVALID_ADDRESS)
+  if (address == LLDB_INVALID_IMAGE_TOKEN)
 return Status("invalid image token");
 
   StreamString expression;
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 2b0774588138881..f82ab05362fbee9 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -5911,12 +5911,12 @@ size_t Process::AddImageToken(lldb::addr_t image_ptr) {
 lldb::addr_t Process::GetImagePtrFromToken(size_t token) const {
   if (token < m_image_tokens.size())
 return m_image_tokens[token];
-  return LLDB_INVALID_ADDRESS;
+  return LLDB_INVALID_IMAGE_TOKEN;
 }
 
 void Process::ResetImageToken(size_t token) {
   if (token < m_image_tokens.size())
-m_image_tokens[token] = LLDB_INVALID_ADDRESS;
+m_image_tokens[token] = LLDB_INVALID_IMAGE_TOKEN;
 }
 
 Address
diff --git a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py 
b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
index 7e8acfa3021acfc..2208e520f1d5612 100644
--- a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
+++ b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
@@ -307,6 +307,15 @@ def run_lldb_process_load_and_unload_commands(self):
 patterns=["Unloading .* with index %s.*ok" % index],
 )
 
+# Confirm that we unloaded properly.
+self.expect(
+"image lookup -n a_function",
+"a_function should not exist after unload",
+error=True,
+matching=False,
+patterns=["1 match found"],
+)
+
 self.runCmd("process continue")
 
 @expectedFailureAll(oslist=["windows"])  # breakpoint not hit

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Correctly invalidate unloaded image tokens (PR #65945)

2023-09-11 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere approved this pull request.


https://github.com/llvm/llvm-project/pull/65945
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Improve completion tests (PR #65973)

2023-09-11 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett created 
https://github.com/llvm/llvm-project/pull/65973:

* Assert no completions for tests that should not find completions.
* Remove regex mode from complete_from_to, which was unused.

This exposed bugs in 2 of the tests, target stop-hook and
process unload. These were fixed in previous commits but
couldn't be tested properly until this patch.

>From f1f7de482046fd9a1347d040827005841c4d863c Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 11 Sep 2023 10:46:53 +
Subject: [PATCH 1/2] [lldb] Correctly invalidate unloaded image tokens

Some functions in Process were using LLDB_INVALID_ADDRESS
instead of LLDB_INVALID_TOKEN.

The only visible effect of this appears to be that
"process unload " would complete to 0 even after the
image was unloaded. Since the command is checking for
LLDB_INVALID_TOKEN.

Everything else worked somehow. I've added a check to the
existing load unload tests anyway.

The tab completion cannot be checked as is, but when I make
them more strict in a later patch it will be tested.
---
 lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp | 2 +-
 lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp | 2 +-
 lldb/source/Target/Process.cpp   | 4 ++--
 .../API/functionalities/load_unload/TestLoadUnload.py| 9 +
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp 
b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index 1e91f2ccd198259..b4f1b76c39dbebf 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -949,7 +949,7 @@ uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process 
*process,
 Status PlatformPOSIX::UnloadImage(lldb_private::Process *process,
   uint32_t image_token) {
   const addr_t image_addr = process->GetImagePtrFromToken(image_token);
-  if (image_addr == LLDB_INVALID_ADDRESS)
+  if (image_addr == LLDB_INVALID_IMAGE_TOKEN)
 return Status("Invalid image token");
 
   StreamString expr;
diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp 
b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
index cbac14e2ccf7a92..88d543289a8470e 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -415,7 +415,7 @@ uint32_t PlatformWindows::DoLoadImage(Process *process,
 
 Status PlatformWindows::UnloadImage(Process *process, uint32_t image_token) {
   const addr_t address = process->GetImagePtrFromToken(image_token);
-  if (address == LLDB_INVALID_ADDRESS)
+  if (address == LLDB_INVALID_IMAGE_TOKEN)
 return Status("invalid image token");
 
   StreamString expression;
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 2b0774588138881..f82ab05362fbee9 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -5911,12 +5911,12 @@ size_t Process::AddImageToken(lldb::addr_t image_ptr) {
 lldb::addr_t Process::GetImagePtrFromToken(size_t token) const {
   if (token < m_image_tokens.size())
 return m_image_tokens[token];
-  return LLDB_INVALID_ADDRESS;
+  return LLDB_INVALID_IMAGE_TOKEN;
 }
 
 void Process::ResetImageToken(size_t token) {
   if (token < m_image_tokens.size())
-m_image_tokens[token] = LLDB_INVALID_ADDRESS;
+m_image_tokens[token] = LLDB_INVALID_IMAGE_TOKEN;
 }
 
 Address
diff --git a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py 
b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
index 7e8acfa3021acfc..2208e520f1d5612 100644
--- a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
+++ b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
@@ -307,6 +307,15 @@ def run_lldb_process_load_and_unload_commands(self):
 patterns=["Unloading .* with index %s.*ok" % index],
 )
 
+# Confirm that we unloaded properly.
+self.expect(
+"image lookup -n a_function",
+"a_function should not exist after unload",
+error=True,
+matching=False,
+patterns=["1 match found"],
+)
+
 self.runCmd("process continue")
 
 @expectedFailureAll(oslist=["windows"])  # breakpoint not hit

>From f7082c3bf9ee5ef68713998352566a08d92869ab Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 11 Sep 2023 09:09:31 +
Subject: [PATCH 2/2] [lldb] Improve completion tests

* Assert no completions for tests that should not find completions.
* Remove regex mode from complete_from_to, which was unused.

This exposed bugs in 2 of the tests, target stop-hook and
process unload. These were fixed in previous commits but
couldn't be tested properly until this patch.
---
 .../Python/lldbsuite/test/lldbtest.py | 30 +++---
 .../completion/TestExprCompletion.py  | 92 +--
 .../completion/TestCompletion.p

[Lldb-commits] [lldb] [lldb] Improve completion tests (PR #65973)

2023-09-11 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett review_requested 
https://github.com/llvm/llvm-project/pull/65973
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Improve completion tests (PR #65973)

2023-09-11 Thread via lldb-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/65973
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Improve completion tests (PR #65973)

2023-09-11 Thread via lldb-commits

llvmbot wrote:

@llvm/pr-subscribers-lldb


Changes

* Assert no completions for tests that should not find completions.
* Remove regex mode from complete_from_to, which was unused.

This exposed bugs in 2 of the tests, target stop-hook and
process unload. These were fixed in previous commits but
couldn't be tested properly until this patch.
--
Full diff: https://github.com/llvm/llvm-project/pull/65973.diff

7 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/lldbtest.py (+12-18) 
- (modified) lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp (+1-1) 
- (modified) lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp (+1-1) 
- (modified) lldb/source/Target/Process.cpp (+2-2) 
- (modified) lldb/test/API/commands/expression/completion/TestExprCompletion.py 
(+46-46) 
- (modified) lldb/test/API/functionalities/completion/TestCompletion.py (+4-10) 
- (modified) lldb/test/API/functionalities/load_unload/TestLoadUnload.py (+9) 



diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 49355d61911837f..4f8bdcd7263dc35 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2223,10 +2223,7 @@ def check_completion_with_desc(
 )
 self.assertFalse(got_failure, error_msg)
 
-def complete_exactly(self, str_input, patterns):
-self.complete_from_to(str_input, patterns, True)
-
-def complete_from_to(self, str_input, patterns, turn_off_re_match=False):
+def complete_from_to(self, str_input, patterns):
 """Test that the completion mechanism completes str_input to patterns,
 where patterns could be a pattern-string or a list of 
pattern-strings"""
 # Patterns should not be None in order to proceed.
@@ -2254,21 +2251,18 @@ def complete_from_to(self, str_input, patterns, 
turn_off_re_match=False):
 for idx in range(1, num_matches + 1):
 compare_string += match_strings.GetStringAtIndex(idx) + 
"\n"
 
+# If the singular pattern is the same as the input, assume that we
+# shouldn't have any completions.
+if len(patterns) == 1 and str_input == patterns[0] and num_matches:
+self.fail("Expected no completions but got:\n" + compare_string)
+
 for p in patterns:
-if turn_off_re_match:
-self.expect(
-compare_string,
-msg=COMPLETION_MSG(str_input, p, match_strings),
-exe=False,
-substrs=[p],
-)
-else:
-self.expect(
-compare_string,
-msg=COMPLETION_MSG(str_input, p, match_strings),
-exe=False,
-patterns=[p],
-)
+self.expect(
+compare_string,
+msg=COMPLETION_MSG(str_input, p, match_strings),
+exe=False,
+substrs=[p],
+)
 
 def completions_match(self, command, completions):
 """Checks that the completions for the given command are equal to the
diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp 
b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index 1e91f2ccd198259..b4f1b76c39dbebf 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -949,7 +949,7 @@ uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process 
*process,
 Status PlatformPOSIX::UnloadImage(lldb_private::Process *process,
   uint32_t image_token) {
   const addr_t image_addr = process->GetImagePtrFromToken(image_token);
-  if (image_addr == LLDB_INVALID_ADDRESS)
+  if (image_addr == LLDB_INVALID_IMAGE_TOKEN)
 return Status("Invalid image token");
 
   StreamString expr;
diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp 
b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
index cbac14e2ccf7a92..88d543289a8470e 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -415,7 +415,7 @@ uint32_t PlatformWindows::DoLoadImage(Process *process,
 
 Status PlatformWindows::UnloadImage(Process *process, uint32_t image_token) {
   const addr_t address = process->GetImagePtrFromToken(image_token);
-  if (address == LLDB_INVALID_ADDRESS)
+  if (address == LLDB_INVALID_IMAGE_TOKEN)
 return Status("invalid image token");
 
   StreamString expression;
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 2b0774588138881..f82ab05362fbee9 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -5911,12 +5911,12 @@ size_t Process::AddImageToken(lldb::addr_t image_ptr) {
 lldb::addr_t Process::GetImagePtrFromToken(size_t token) const {
   if (token < m_image_tokens.size(

[Lldb-commits] [lldb] [lldb] Improve completion tests (PR #65973)

2023-09-11 Thread David Spickett via lldb-commits

DavidSpickett wrote:

This builds on https://github.com/llvm/llvm-project/pull/65945, so the first 
commit is from that PR. If you review using the per commit tab instead that 
should make it clearer, I hope.

This is me trying to imitate a stacked PR and maybe failing, let's see how it 
goes.

https://github.com/llvm/llvm-project/pull/65973
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Treat user aliases the same as built-ins when tab completing (PR #65974)

2023-09-11 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett created 
https://github.com/llvm/llvm-project/pull/65974:

Previously we would check all built-ins first for suggestions,
then check built-ins and aliases. This meant that if you had
an alias brkpt -> breakpoint, "br" would complete to "breakpoint".

Instead of giving you the choice of "brkpt" or "breakpoint".

>From f1f7de482046fd9a1347d040827005841c4d863c Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 11 Sep 2023 10:46:53 +
Subject: [PATCH 1/3] [lldb] Correctly invalidate unloaded image tokens

Some functions in Process were using LLDB_INVALID_ADDRESS
instead of LLDB_INVALID_TOKEN.

The only visible effect of this appears to be that
"process unload " would complete to 0 even after the
image was unloaded. Since the command is checking for
LLDB_INVALID_TOKEN.

Everything else worked somehow. I've added a check to the
existing load unload tests anyway.

The tab completion cannot be checked as is, but when I make
them more strict in a later patch it will be tested.
---
 lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp | 2 +-
 lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp | 2 +-
 lldb/source/Target/Process.cpp   | 4 ++--
 .../API/functionalities/load_unload/TestLoadUnload.py| 9 +
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp 
b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index 1e91f2ccd198259..b4f1b76c39dbebf 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -949,7 +949,7 @@ uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process 
*process,
 Status PlatformPOSIX::UnloadImage(lldb_private::Process *process,
   uint32_t image_token) {
   const addr_t image_addr = process->GetImagePtrFromToken(image_token);
-  if (image_addr == LLDB_INVALID_ADDRESS)
+  if (image_addr == LLDB_INVALID_IMAGE_TOKEN)
 return Status("Invalid image token");
 
   StreamString expr;
diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp 
b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
index cbac14e2ccf7a92..88d543289a8470e 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -415,7 +415,7 @@ uint32_t PlatformWindows::DoLoadImage(Process *process,
 
 Status PlatformWindows::UnloadImage(Process *process, uint32_t image_token) {
   const addr_t address = process->GetImagePtrFromToken(image_token);
-  if (address == LLDB_INVALID_ADDRESS)
+  if (address == LLDB_INVALID_IMAGE_TOKEN)
 return Status("invalid image token");
 
   StreamString expression;
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 2b0774588138881..f82ab05362fbee9 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -5911,12 +5911,12 @@ size_t Process::AddImageToken(lldb::addr_t image_ptr) {
 lldb::addr_t Process::GetImagePtrFromToken(size_t token) const {
   if (token < m_image_tokens.size())
 return m_image_tokens[token];
-  return LLDB_INVALID_ADDRESS;
+  return LLDB_INVALID_IMAGE_TOKEN;
 }
 
 void Process::ResetImageToken(size_t token) {
   if (token < m_image_tokens.size())
-m_image_tokens[token] = LLDB_INVALID_ADDRESS;
+m_image_tokens[token] = LLDB_INVALID_IMAGE_TOKEN;
 }
 
 Address
diff --git a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py 
b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
index 7e8acfa3021acfc..2208e520f1d5612 100644
--- a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
+++ b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
@@ -307,6 +307,15 @@ def run_lldb_process_load_and_unload_commands(self):
 patterns=["Unloading .* with index %s.*ok" % index],
 )
 
+# Confirm that we unloaded properly.
+self.expect(
+"image lookup -n a_function",
+"a_function should not exist after unload",
+error=True,
+matching=False,
+patterns=["1 match found"],
+)
+
 self.runCmd("process continue")
 
 @expectedFailureAll(oslist=["windows"])  # breakpoint not hit

>From f7082c3bf9ee5ef68713998352566a08d92869ab Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 11 Sep 2023 09:09:31 +
Subject: [PATCH 2/3] [lldb] Improve completion tests

* Assert no completions for tests that should not find completions.
* Remove regex mode from complete_from_to, which was unused.

This exposed bugs in 2 of the tests, target stop-hook and
process unload. These were fixed in previous commits but
couldn't be tested properly until this patch.
---
 .../Python/lldbsuite/test/lldbtest.py | 30 +++---
 .../completion/TestExprCompletion.py  | 92 +--
 .../completion/TestCompletion.py  | 14 +--
 3 files chang

[Lldb-commits] [lldb] [lldb] Treat user aliases the same as built-ins when tab completing (PR #65974)

2023-09-11 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett review_requested 
https://github.com/llvm/llvm-project/pull/65974
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Treat user aliases the same as built-ins when tab completing (PR #65974)

2023-09-11 Thread via lldb-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/65974
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Treat user aliases the same as built-ins when tab completing (PR #65974)

2023-09-11 Thread David Spickett via lldb-commits

DavidSpickett wrote:

This is a PR "stacked" on https://github.com/llvm/llvm-project/pull/65973, so 
the first 2 commits are from that and the original one. Review with the commits 
tab instead of "files changed".

https://github.com/llvm/llvm-project/pull/65974
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Treat user aliases the same as built-ins when tab completing (PR #65974)

2023-09-11 Thread via lldb-commits

llvmbot wrote:

@llvm/pr-subscribers-lldb


Changes

Previously we would check all built-ins first for suggestions,
then check built-ins and aliases. This meant that if you had
an alias brkpt -> breakpoint, "br" would complete to "breakpoint".

Instead of giving you the choice of "brkpt" or "breakpoint".
--
Full diff: https://github.com/llvm/llvm-project/pull/65974.diff

9 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/lldbtest.py (+12-18) 
- (modified) lldb/source/Interpreter/CommandInterpreter.cpp (+5-30) 
- (modified) lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp (+1-1) 
- (modified) lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp (+1-1) 
- (modified) lldb/source/Target/Process.cpp (+2-2) 
- (modified) lldb/test/API/commands/expression/completion/TestExprCompletion.py 
(+46-46) 
- (modified) lldb/test/API/functionalities/abbreviation/TestAbbreviations.py 
(+1-1) 
- (modified) lldb/test/API/functionalities/completion/TestCompletion.py 
(+11-21) 
- (modified) lldb/test/API/functionalities/load_unload/TestLoadUnload.py (+9) 



diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 49355d61911837f..4f8bdcd7263dc35 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2223,10 +2223,7 @@ def check_completion_with_desc(
 )
 self.assertFalse(got_failure, error_msg)
 
-def complete_exactly(self, str_input, patterns):
-self.complete_from_to(str_input, patterns, True)
-
-def complete_from_to(self, str_input, patterns, turn_off_re_match=False):
+def complete_from_to(self, str_input, patterns):
 """Test that the completion mechanism completes str_input to patterns,
 where patterns could be a pattern-string or a list of 
pattern-strings"""
 # Patterns should not be None in order to proceed.
@@ -2254,21 +2251,18 @@ def complete_from_to(self, str_input, patterns, 
turn_off_re_match=False):
 for idx in range(1, num_matches + 1):
 compare_string += match_strings.GetStringAtIndex(idx) + 
"\n"
 
+# If the singular pattern is the same as the input, assume that we
+# shouldn't have any completions.
+if len(patterns) == 1 and str_input == patterns[0] and num_matches:
+self.fail("Expected no completions but got:\n" + compare_string)
+
 for p in patterns:
-if turn_off_re_match:
-self.expect(
-compare_string,
-msg=COMPLETION_MSG(str_input, p, match_strings),
-exe=False,
-substrs=[p],
-)
-else:
-self.expect(
-compare_string,
-msg=COMPLETION_MSG(str_input, p, match_strings),
-exe=False,
-patterns=[p],
-)
+self.expect(
+compare_string,
+msg=COMPLETION_MSG(str_input, p, match_strings),
+exe=False,
+substrs=[p],
+)
 
 def completions_match(self, command, completions):
 """Checks that the completions for the given command are equal to the
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index 6d1ad799f2d10fb..fc94bf6fbfe117c 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1227,36 +1227,11 @@ CommandObject *
 CommandInterpreter::GetCommandObject(llvm::StringRef cmd_str,
  StringList *matches,
  StringList *descriptions) const {
-  CommandObject *command_obj =
-  GetCommandSP(cmd_str, false, true, matches, descriptions).get();
-
-  // If we didn't find an exact match to the command string in the commands,
-  // look in the aliases.
-
-  if (command_obj)
-return command_obj;
-
-  command_obj = GetCommandSP(cmd_str, true, true, matches, descriptions).get();
-
-  if (command_obj)
-return command_obj;
-
-  // If there wasn't an exact match then look for an inexact one in just the
-  // commands
-  command_obj = GetCommandSP(cmd_str, false, false, nullptr).get();
-
-  // Finally, if there wasn't an inexact match among the commands, look for an
-  // inexact match in both the commands and aliases.
-
-  if (command_obj) {
-if (matches)
-  matches->AppendString(command_obj->GetCommandName());
-if (descriptions)
-  descriptions->AppendString(command_obj->GetHelp());
-return command_obj;
-  }
-
-  return GetCommandSP(cmd_str, true, false, matches, descriptions).get();
+  // Try to find a match among commands and aliases. Allowing inexact matches,
+  // but perferring exact matches.
+  return GetCommandSP(cmd_str, /*include_aliases=*/true, /*exact=*/false,
+

[Lldb-commits] [lldb] 3125bd4 - [lldb] Correctly invalidate unloaded image tokens (#65945)

2023-09-11 Thread via lldb-commits

Author: David Spickett
Date: 2023-09-11T17:12:09+01:00
New Revision: 3125bd4bc7367a05ddf5477793a1ee51cecc3046

URL: 
https://github.com/llvm/llvm-project/commit/3125bd4bc7367a05ddf5477793a1ee51cecc3046
DIFF: 
https://github.com/llvm/llvm-project/commit/3125bd4bc7367a05ddf5477793a1ee51cecc3046.diff

LOG: [lldb] Correctly invalidate unloaded image tokens (#65945)

Some functions in Process were using LLDB_INVALID_ADDRESS instead of
LLDB_INVALID_TOKEN.

The only visible effect of this appears to be that "process unload
" would complete to 0 even after the image was unloaded. Since the
command is checking for LLDB_INVALID_TOKEN.

Everything else worked somehow. I've added a check to the existing load
unload tests anyway.

The tab completion cannot be checked as is, but when I make them more
strict in a later patch it will be tested.

Added: 


Modified: 
lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
lldb/source/Target/Process.cpp
lldb/test/API/functionalities/load_unload/TestLoadUnload.py

Removed: 




diff  --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp 
b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index 1e91f2ccd198259..b4f1b76c39dbebf 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -949,7 +949,7 @@ uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process 
*process,
 Status PlatformPOSIX::UnloadImage(lldb_private::Process *process,
   uint32_t image_token) {
   const addr_t image_addr = process->GetImagePtrFromToken(image_token);
-  if (image_addr == LLDB_INVALID_ADDRESS)
+  if (image_addr == LLDB_INVALID_IMAGE_TOKEN)
 return Status("Invalid image token");
 
   StreamString expr;

diff  --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp 
b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
index cbac14e2ccf7a92..88d543289a8470e 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -415,7 +415,7 @@ uint32_t PlatformWindows::DoLoadImage(Process *process,
 
 Status PlatformWindows::UnloadImage(Process *process, uint32_t image_token) {
   const addr_t address = process->GetImagePtrFromToken(image_token);
-  if (address == LLDB_INVALID_ADDRESS)
+  if (address == LLDB_INVALID_IMAGE_TOKEN)
 return Status("invalid image token");
 
   StreamString expression;

diff  --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 2b0774588138881..f82ab05362fbee9 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -5911,12 +5911,12 @@ size_t Process::AddImageToken(lldb::addr_t image_ptr) {
 lldb::addr_t Process::GetImagePtrFromToken(size_t token) const {
   if (token < m_image_tokens.size())
 return m_image_tokens[token];
-  return LLDB_INVALID_ADDRESS;
+  return LLDB_INVALID_IMAGE_TOKEN;
 }
 
 void Process::ResetImageToken(size_t token) {
   if (token < m_image_tokens.size())
-m_image_tokens[token] = LLDB_INVALID_ADDRESS;
+m_image_tokens[token] = LLDB_INVALID_IMAGE_TOKEN;
 }
 
 Address

diff  --git a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py 
b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
index 7e8acfa3021acfc..2208e520f1d5612 100644
--- a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
+++ b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
@@ -307,6 +307,15 @@ def run_lldb_process_load_and_unload_commands(self):
 patterns=["Unloading .* with index %s.*ok" % index],
 )
 
+# Confirm that we unloaded properly.
+self.expect(
+"image lookup -n a_function",
+"a_function should not exist after unload",
+error=True,
+matching=False,
+patterns=["1 match found"],
+)
+
 self.runCmd("process continue")
 
 @expectedFailureAll(oslist=["windows"])  # breakpoint not hit



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Correctly invalidate unloaded image tokens (PR #65945)

2023-09-11 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett closed 
https://github.com/llvm/llvm-project/pull/65945
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Improve completion tests (PR #65973)

2023-09-11 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/65973:

>From ea172bdf8b1d66087076b7ed842021749a49b9fb Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 11 Sep 2023 09:09:31 +
Subject: [PATCH] [lldb] Improve completion tests

* Assert no completions for tests that should not find completions.
* Remove regex mode from complete_from_to, which was unused.

This exposed bugs in 2 of the tests, target stop-hook and
process unload. These were fixed in previous commits but
couldn't be tested properly until this patch.
---
 .../Python/lldbsuite/test/lldbtest.py | 30 +++---
 .../completion/TestExprCompletion.py  | 92 +--
 .../completion/TestCompletion.py  | 14 +--
 3 files changed, 62 insertions(+), 74 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 49355d61911837f..4f8bdcd7263dc35 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2223,10 +2223,7 @@ def check_completion_with_desc(
 )
 self.assertFalse(got_failure, error_msg)
 
-def complete_exactly(self, str_input, patterns):
-self.complete_from_to(str_input, patterns, True)
-
-def complete_from_to(self, str_input, patterns, turn_off_re_match=False):
+def complete_from_to(self, str_input, patterns):
 """Test that the completion mechanism completes str_input to patterns,
 where patterns could be a pattern-string or a list of 
pattern-strings"""
 # Patterns should not be None in order to proceed.
@@ -2254,21 +2251,18 @@ def complete_from_to(self, str_input, patterns, 
turn_off_re_match=False):
 for idx in range(1, num_matches + 1):
 compare_string += match_strings.GetStringAtIndex(idx) + 
"\n"
 
+# If the singular pattern is the same as the input, assume that we
+# shouldn't have any completions.
+if len(patterns) == 1 and str_input == patterns[0] and num_matches:
+self.fail("Expected no completions but got:\n" + compare_string)
+
 for p in patterns:
-if turn_off_re_match:
-self.expect(
-compare_string,
-msg=COMPLETION_MSG(str_input, p, match_strings),
-exe=False,
-substrs=[p],
-)
-else:
-self.expect(
-compare_string,
-msg=COMPLETION_MSG(str_input, p, match_strings),
-exe=False,
-patterns=[p],
-)
+self.expect(
+compare_string,
+msg=COMPLETION_MSG(str_input, p, match_strings),
+exe=False,
+substrs=[p],
+)
 
 def completions_match(self, command, completions):
 """Checks that the completions for the given command are equal to the
diff --git a/lldb/test/API/commands/expression/completion/TestExprCompletion.py 
b/lldb/test/API/commands/expression/completion/TestExprCompletion.py
index 3c354a3bce1a9b5..ada818989c789a1 100644
--- a/lldb/test/API/commands/expression/completion/TestExprCompletion.py
+++ b/lldb/test/API/commands/expression/completion/TestExprCompletion.py
@@ -29,34 +29,34 @@ def test_expr_completion(self):
 )
 
 # Completing member functions
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooNoArgs", "expr some_expr.FooNoArgsBar()"
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooWithArgs", "expr some_expr.FooWithArgsBar("
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooWithMultipleArgs",
 "expr some_expr.FooWithMultipleArgsBar(",
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooUnderscore", "expr 
some_expr.FooUnderscoreBar_()"
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooNumbers", "expr some_expr.FooNumbersBar1()"
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.StaticMemberMethod",
 "expr some_expr.StaticMemberMethodBar()",
 )
 
 # Completing static functions
-self.complete_exactly(
+self.complete_from_to(
 "expr Expr::StaticMemberMethod", "expr 
Expr::StaticMemberMethodBar()"
 )
 
 # Completing member variables
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.MemberVariab", "expr some_expr.MemberVariableBar"
 )
 
@@ -94,43 +94,43 @@ def test_expr_completion(self):
 self.completions_contain("expr 1+", ["1+some_expr", "1+static_cast"])
 
 

[Lldb-commits] [lldb] [lldb] Improve completion tests (PR #65973)

2023-09-11 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/65973:

>From ea172bdf8b1d66087076b7ed842021749a49b9fb Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 11 Sep 2023 09:09:31 +
Subject: [PATCH 1/2] [lldb] Improve completion tests

* Assert no completions for tests that should not find completions.
* Remove regex mode from complete_from_to, which was unused.

This exposed bugs in 2 of the tests, target stop-hook and
process unload. These were fixed in previous commits but
couldn't be tested properly until this patch.
---
 .../Python/lldbsuite/test/lldbtest.py | 30 +++---
 .../completion/TestExprCompletion.py  | 92 +--
 .../completion/TestCompletion.py  | 14 +--
 3 files changed, 62 insertions(+), 74 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 49355d61911837f..4f8bdcd7263dc35 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2223,10 +2223,7 @@ def check_completion_with_desc(
 )
 self.assertFalse(got_failure, error_msg)
 
-def complete_exactly(self, str_input, patterns):
-self.complete_from_to(str_input, patterns, True)
-
-def complete_from_to(self, str_input, patterns, turn_off_re_match=False):
+def complete_from_to(self, str_input, patterns):
 """Test that the completion mechanism completes str_input to patterns,
 where patterns could be a pattern-string or a list of 
pattern-strings"""
 # Patterns should not be None in order to proceed.
@@ -2254,21 +2251,18 @@ def complete_from_to(self, str_input, patterns, 
turn_off_re_match=False):
 for idx in range(1, num_matches + 1):
 compare_string += match_strings.GetStringAtIndex(idx) + 
"\n"
 
+# If the singular pattern is the same as the input, assume that we
+# shouldn't have any completions.
+if len(patterns) == 1 and str_input == patterns[0] and num_matches:
+self.fail("Expected no completions but got:\n" + compare_string)
+
 for p in patterns:
-if turn_off_re_match:
-self.expect(
-compare_string,
-msg=COMPLETION_MSG(str_input, p, match_strings),
-exe=False,
-substrs=[p],
-)
-else:
-self.expect(
-compare_string,
-msg=COMPLETION_MSG(str_input, p, match_strings),
-exe=False,
-patterns=[p],
-)
+self.expect(
+compare_string,
+msg=COMPLETION_MSG(str_input, p, match_strings),
+exe=False,
+substrs=[p],
+)
 
 def completions_match(self, command, completions):
 """Checks that the completions for the given command are equal to the
diff --git a/lldb/test/API/commands/expression/completion/TestExprCompletion.py 
b/lldb/test/API/commands/expression/completion/TestExprCompletion.py
index 3c354a3bce1a9b5..ada818989c789a1 100644
--- a/lldb/test/API/commands/expression/completion/TestExprCompletion.py
+++ b/lldb/test/API/commands/expression/completion/TestExprCompletion.py
@@ -29,34 +29,34 @@ def test_expr_completion(self):
 )
 
 # Completing member functions
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooNoArgs", "expr some_expr.FooNoArgsBar()"
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooWithArgs", "expr some_expr.FooWithArgsBar("
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooWithMultipleArgs",
 "expr some_expr.FooWithMultipleArgsBar(",
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooUnderscore", "expr 
some_expr.FooUnderscoreBar_()"
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooNumbers", "expr some_expr.FooNumbersBar1()"
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.StaticMemberMethod",
 "expr some_expr.StaticMemberMethodBar()",
 )
 
 # Completing static functions
-self.complete_exactly(
+self.complete_from_to(
 "expr Expr::StaticMemberMethod", "expr 
Expr::StaticMemberMethodBar()"
 )
 
 # Completing member variables
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.MemberVariab", "expr some_expr.MemberVariableBar"
 )
 
@@ -94,43 +94,43 @@ def test_expr_completion(self):
 self.completions_contain("expr 1+", ["1+some_expr", "1+static_cast"])

[Lldb-commits] [lldb] [lldb] Treat user aliases the same as built-ins when tab completing (PR #65974)

2023-09-11 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/65974:

>From ea172bdf8b1d66087076b7ed842021749a49b9fb Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 11 Sep 2023 09:09:31 +
Subject: [PATCH 1/3] [lldb] Improve completion tests

* Assert no completions for tests that should not find completions.
* Remove regex mode from complete_from_to, which was unused.

This exposed bugs in 2 of the tests, target stop-hook and
process unload. These were fixed in previous commits but
couldn't be tested properly until this patch.
---
 .../Python/lldbsuite/test/lldbtest.py | 30 +++---
 .../completion/TestExprCompletion.py  | 92 +--
 .../completion/TestCompletion.py  | 14 +--
 3 files changed, 62 insertions(+), 74 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 49355d61911837f..4f8bdcd7263dc35 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2223,10 +2223,7 @@ def check_completion_with_desc(
 )
 self.assertFalse(got_failure, error_msg)
 
-def complete_exactly(self, str_input, patterns):
-self.complete_from_to(str_input, patterns, True)
-
-def complete_from_to(self, str_input, patterns, turn_off_re_match=False):
+def complete_from_to(self, str_input, patterns):
 """Test that the completion mechanism completes str_input to patterns,
 where patterns could be a pattern-string or a list of 
pattern-strings"""
 # Patterns should not be None in order to proceed.
@@ -2254,21 +2251,18 @@ def complete_from_to(self, str_input, patterns, 
turn_off_re_match=False):
 for idx in range(1, num_matches + 1):
 compare_string += match_strings.GetStringAtIndex(idx) + 
"\n"
 
+# If the singular pattern is the same as the input, assume that we
+# shouldn't have any completions.
+if len(patterns) == 1 and str_input == patterns[0] and num_matches:
+self.fail("Expected no completions but got:\n" + compare_string)
+
 for p in patterns:
-if turn_off_re_match:
-self.expect(
-compare_string,
-msg=COMPLETION_MSG(str_input, p, match_strings),
-exe=False,
-substrs=[p],
-)
-else:
-self.expect(
-compare_string,
-msg=COMPLETION_MSG(str_input, p, match_strings),
-exe=False,
-patterns=[p],
-)
+self.expect(
+compare_string,
+msg=COMPLETION_MSG(str_input, p, match_strings),
+exe=False,
+substrs=[p],
+)
 
 def completions_match(self, command, completions):
 """Checks that the completions for the given command are equal to the
diff --git a/lldb/test/API/commands/expression/completion/TestExprCompletion.py 
b/lldb/test/API/commands/expression/completion/TestExprCompletion.py
index 3c354a3bce1a9b5..ada818989c789a1 100644
--- a/lldb/test/API/commands/expression/completion/TestExprCompletion.py
+++ b/lldb/test/API/commands/expression/completion/TestExprCompletion.py
@@ -29,34 +29,34 @@ def test_expr_completion(self):
 )
 
 # Completing member functions
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooNoArgs", "expr some_expr.FooNoArgsBar()"
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooWithArgs", "expr some_expr.FooWithArgsBar("
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooWithMultipleArgs",
 "expr some_expr.FooWithMultipleArgsBar(",
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooUnderscore", "expr 
some_expr.FooUnderscoreBar_()"
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooNumbers", "expr some_expr.FooNumbersBar1()"
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.StaticMemberMethod",
 "expr some_expr.StaticMemberMethodBar()",
 )
 
 # Completing static functions
-self.complete_exactly(
+self.complete_from_to(
 "expr Expr::StaticMemberMethod", "expr 
Expr::StaticMemberMethodBar()"
 )
 
 # Completing member variables
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.MemberVariab", "expr some_expr.MemberVariableBar"
 )
 
@@ -94,43 +94,43 @@ def test_expr_completion(self):
 self.completions_contain("expr 1+", ["1+some_expr", "1+static_cast"])

[Lldb-commits] [lldb] Fix a bug with cancelling "attach -w" after you have run a process previously (PR #65822)

2023-09-11 Thread via lldb-commits

jimingham wrote:

> > This is in reply to Alex's comment about why we keep the process around, 
> > but the quote this reply didn't seem to work...
> > After a process exits you might still want to ask it what its exit status 
> > was. Plus there might be other system accounting we've gathered for that 
> > process. So until you replace it with another process, you very well might 
> > want to ask questions of it. So we can't just destroy it as soon as it 
> > exits.
> 
> That definitely explains why we persist the previous process even after its 
> finished, but this doesn't sound like there's a technical limitation to 
> actually removing the Process from the Target after it exits. To be more 
> specific, you could either make it so the Process object in `m_process_sp` 
> could be moved out and into another member of Target, or you could just 
> persist the data you care about instead of the entire process.
> 
> That might be an alternative to this solution but I'm not sure if that would 
> be any better or more useful than what you're doing here. I'm mostly thinking 
> aloud here (and trying to improve my knowledge of LLDB).

I'm not sure this would make things easier.  The model where you just ask info 
of the dead process till you make another one is very straightforward.  Also, 
the window where this is likely to cause problems is very small, and all 
internal to launching and attaching, so making the handling of the old process 
more complex to solve this problem seems like overkill.  

https://github.com/llvm/llvm-project/pull/65822
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 6bf923d - [lldb][Tests] Reformat API tests with black

2023-09-11 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2023-09-11T16:44:12Z
New Revision: 6bf923d5c3daf5d66e0acf53d037a12ceff4a275

URL: 
https://github.com/llvm/llvm-project/commit/6bf923d5c3daf5d66e0acf53d037a12ceff4a275
DIFF: 
https://github.com/llvm/llvm-project/commit/6bf923d5c3daf5d66e0acf53d037a12ceff4a275.diff

LOG: [lldb][Tests] Reformat API tests with black

These are all recent additions I think, including a few of mine
for AArch64.

Going forward the CI checks should help us fix these earlier.

Added: 


Modified: 
lldb/test/API/commands/gui/spawn-threads/TestGuiSpawnThreads.py

lldb/test/API/commands/register/register/aarch64_mte_ctrl_register/TestMTECtrlRegister.py

lldb/test/API/commands/register/register/aarch64_sve_simd_registers/TestSVESIMDRegisters.py
lldb/test/API/functionalities/archives/TestBSDArchives.py

lldb/test/API/functionalities/dyld-multiple-rdebug/TestDyldWithMultupleRDebug.py

lldb/test/API/functionalities/interactive_scripted_process/TestInteractiveScriptedProcess.py
lldb/test/API/lang/rust/enum-structs/RustEnumValue.py
lldb/test/API/lang/rust/enum-structs/TestRustEnumStructs.py
lldb/test/API/python_api/event/TestEvents.py
lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py

Removed: 




diff  --git a/lldb/test/API/commands/gui/spawn-threads/TestGuiSpawnThreads.py 
b/lldb/test/API/commands/gui/spawn-threads/TestGuiSpawnThreads.py
index 54726de22b100ee..de61d7967d2e677 100644
--- a/lldb/test/API/commands/gui/spawn-threads/TestGuiSpawnThreads.py
+++ b/lldb/test/API/commands/gui/spawn-threads/TestGuiSpawnThreads.py
@@ -10,6 +10,7 @@
 
 import sys
 
+
 class TestGuiSpawnThreadsTest(PExpectTest):
 # PExpect uses many timeouts internally and doesn't play well
 # under ASAN on a loaded machine..
@@ -18,12 +19,14 @@ class TestGuiSpawnThreadsTest(PExpectTest):
 def test_gui(self):
 self.build()
 
-self.launch(executable=self.getBuildArtifact('a.out'), 
dimensions=(100, 500))
+self.launch(executable=self.getBuildArtifact("a.out"), 
dimensions=(100, 500))
 self.expect(
-'breakpoint set -f main.cpp -p "break here"', substrs=['Breakpoint 
1', 'address =']
+'breakpoint set -f main.cpp -p "break here"',
+substrs=["Breakpoint 1", "address ="],
 )
 self.expect(
-'breakpoint set -f main.cpp -p "before join"', 
substrs=['Breakpoint 2', 'address =']
+'breakpoint set -f main.cpp -p "before join"',
+substrs=["Breakpoint 2", "address ="],
 )
 self.expect("run", substrs=["stop reason ="])
 

diff  --git 
a/lldb/test/API/commands/register/register/aarch64_mte_ctrl_register/TestMTECtrlRegister.py
 
b/lldb/test/API/commands/register/register/aarch64_mte_ctrl_register/TestMTECtrlRegister.py
index 48e8bb872e3f029..7fd6b2dada640e6 100644
--- 
a/lldb/test/API/commands/register/register/aarch64_mte_ctrl_register/TestMTECtrlRegister.py
+++ 
b/lldb/test/API/commands/register/register/aarch64_mte_ctrl_register/TestMTECtrlRegister.py
@@ -47,4 +47,4 @@ def test_mte_ctrl_register(self):
 # This would return to synchronous faults if we did not restore the
 # previous value.
 self.expect("expression setup_mte()", substrs=["= 0"])
-self.expect("register read mte_ctrl", substrs=["0x0005"])
\ No newline at end of file
+self.expect("register read mte_ctrl", substrs=["0x0005"])

diff  --git 
a/lldb/test/API/commands/register/register/aarch64_sve_simd_registers/TestSVESIMDRegisters.py
 
b/lldb/test/API/commands/register/register/aarch64_sve_simd_registers/TestSVESIMDRegisters.py
index c38a255aac6e296..814ca98369fca57 100644
--- 
a/lldb/test/API/commands/register/register/aarch64_sve_simd_registers/TestSVESIMDRegisters.py
+++ 
b/lldb/test/API/commands/register/register/aarch64_sve_simd_registers/TestSVESIMDRegisters.py
@@ -52,8 +52,10 @@ def check_simd_values(self, value_offset):
 # These are 128 bit registers, so getting them from the API as unsigned
 # values doesn't work. Check the command output instead.
 for i in range(32):
-self.expect("register read v{}".format(i),
-substrs=[self.make_simd_value(i+value_offset)])
+self.expect(
+"register read v{}".format(i),
+substrs=[self.make_simd_value(i + value_offset)],
+)
 
 def sve_simd_registers_impl(self, mode):
 self.skip_if_needed(mode)

diff  --git a/lldb/test/API/functionalities/archives/TestBSDArchives.py 
b/lldb/test/API/functionalities/archives/TestBSDArchives.py
index 9ec21ba2e821c1f..b0609ac7410bd8c 100644
--- a/lldb/test/API/functionalities/archives/TestBSDArchives.py
+++ b/lldb/test/API/functionalities/archives/TestBSDArchives.py
@@ -70,7 +70,6 @@ def test

[Lldb-commits] [lldb] [lldb] Format more Python files with black (PR #65979)

2023-09-11 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett review_requested 
https://github.com/llvm/llvm-project/pull/65979
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Format more Python files with black (PR #65979)

2023-09-11 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett created 
https://github.com/llvm/llvm-project/pull/65979:

By running this from lldb/

$ black --exclude "third_party/|scripts/|utils/" ./

>From 56cea5795e0274fe7672c727340330cf46aa30a4 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 11 Sep 2023 16:52:05 +
Subject: [PATCH] [lldb] Format more Python files with black

By running this from lldb/

$ black --exclude "third_party/|scripts/|utils/" ./
---
 lldb/bindings/python/createPythonInit.py  |   6 +-
 lldb/bindings/python/get-python-config.py |  21 +-
 lldb/docs/conf.py |   8 +-
 .../Python/lldbsuite/test/lldbtest.py |   5 +-
 .../tools/lldb-vscode/lldbvscode_testcase.py  |   2 +-
 .../test/tools/lldb-vscode/vscode.py  |   8 +-
 .../Interpreter/embedded_interpreter.py   |  26 ++-
 .../intel-mpx/test/TestMPXTable.py| 199 +++---
 lldb/use_lldb_suite_root.py   |   4 +-
 9 files changed, 166 insertions(+), 113 deletions(-)

diff --git a/lldb/bindings/python/createPythonInit.py 
b/lldb/bindings/python/createPythonInit.py
index 4ad7320675f45b2..f343832b949bafe 100644
--- a/lldb/bindings/python/createPythonInit.py
+++ b/lldb/bindings/python/createPythonInit.py
@@ -5,7 +5,7 @@
 pkgFiles = sys.argv[2:]
 
 getFileName = lambda f: os.path.splitext(os.path.basename(f))[0]
-importNames = ', '.join('"{}"'.format(getFileName(f)) for f in pkgFiles)
+importNames = ", ".join('"{}"'.format(getFileName(f)) for f in pkgFiles)
 
 script = """__all__ = [{import_names}]
 for x in __all__:
@@ -18,7 +18,9 @@ def __lldb_init_module(debugger, internal_dict):
 lldb_init = getattr(submodule, '__lldb_init_module', None)
 if lldb_init:
   lldb_init(debugger, internal_dict)
-""".format(import_names=importNames, pkg_name=pkgRelDir.replace("/", "."))
+""".format(
+import_names=importNames, pkg_name=pkgRelDir.replace("/", ".")
+)
 
 pkgIniFile = os.path.normpath(os.path.join(pkgRelDir, "__init__.py"))
 with open(pkgIniFile, "w") as f:
diff --git a/lldb/bindings/python/get-python-config.py 
b/lldb/bindings/python/get-python-config.py
index 6369e32a49168c7..ae84cbb1215a9e3 100755
--- a/lldb/bindings/python/get-python-config.py
+++ b/lldb/bindings/python/get-python-config.py
@@ -10,10 +10,11 @@ def relpath_nodots(path, base):
 rel = os.path.normpath(os.path.relpath(path, base))
 assert not os.path.isabs(rel)
 parts = rel.split(os.path.sep)
-if parts and parts[0] == '..':
+if parts and parts[0] == "..":
 raise ValueError(f"{path} is not under {base}")
 return rel
 
+
 def main():
 parser = argparse.ArgumentParser(description="extract cmake variables from 
python")
 parser.add_argument("variable_name")
@@ -35,10 +36,10 @@ def main():
 except ValueError:
 # Try to fall back to something reasonable if sysconfig's platlib
 # is outside of sys.prefix
-if os.name == 'posix':
-print('lib/python%d.%d/site-packages' % sys.version_info[:2])
-elif os.name == 'nt':
-print('Lib\\site-packages')
+if os.name == "posix":
+print("lib/python%d.%d/site-packages" % sys.version_info[:2])
+elif os.name == "nt":
+print("Lib\\site-packages")
 else:
 raise
 elif args.variable_name == "LLDB_PYTHON_EXE_RELATIVE_PATH":
@@ -57,16 +58,20 @@ def main():
 exe = os.path.realpath(exe)
 continue
 else:
-print("Could not find a relative path to sys.executable 
under sys.prefix", file=sys.stderr)
+print(
+"Could not find a relative path to sys.executable 
under sys.prefix",
+file=sys.stderr,
+)
 for e in tried:
 print("tried:", e, file=sys.stderr)
 print("realpath(sys.prefix):", prefix, file=sys.stderr)
 print("sys.prefix:", sys.prefix, file=sys.stderr)
 sys.exit(1)
 elif args.variable_name == "LLDB_PYTHON_EXT_SUFFIX":
-print(sysconfig.get_config_var('EXT_SUFFIX'))
+print(sysconfig.get_config_var("EXT_SUFFIX"))
 else:
 parser.error(f"unknown variable {args.variable_name}")
 
-if __name__ == '__main__':
+
+if __name__ == "__main__":
 main()
diff --git a/lldb/docs/conf.py b/lldb/docs/conf.py
index 730a8608b5ba44f..ec7f93710ab6f20 100644
--- a/lldb/docs/conf.py
+++ b/lldb/docs/conf.py
@@ -42,9 +42,7 @@
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ["sphinx.ext.todo", "sphinx.ext.mathjax", 
"sphinx.ext.intersphinx"]
 
-autodoc_default_options = {
-"special-members": True
-}
+autodoc_default_options = {"special-members": True}
 
 # Unless we only generate the basic manpage we need the plugin for generating
 # the Python API document

[Lldb-commits] [lldb] [lldb] Format more Python files with black (PR #65979)

2023-09-11 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett review_requested 
https://github.com/llvm/llvm-project/pull/65979
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Format more Python files with black (PR #65979)

2023-09-11 Thread via lldb-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/65979
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Format more Python files with black (PR #65979)

2023-09-11 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Putting this into review mainly to ask @JDevlieghere if any of these shouldn't 
be formatted.

Third party obviously we don't want to format that. Scripts and utils I don't 
see why not but maybe there are downstream concerns?

https://github.com/llvm/llvm-project/pull/65979
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Format more Python files with black (PR #65979)

2023-09-11 Thread via lldb-commits

llvmbot wrote:

@llvm/pr-subscribers-lldb


Changes

By running this from lldb/

$ black --exclude "third_party/|scripts/|utils/" ./
--

Patch is 21.03 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/65979.diff

9 Files Affected:

- (modified) lldb/bindings/python/createPythonInit.py (+4-2) 
- (modified) lldb/bindings/python/get-python-config.py (+13-8) 
- (modified) lldb/docs/conf.py (+2-6) 
- (modified) lldb/packages/Python/lldbsuite/test/lldbtest.py (+3-2) 
- (modified) 
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py 
(+1-1) 
- (modified) lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py 
(+5-3) 
- (modified) lldb/source/Interpreter/embedded_interpreter.py (+16-10) 
- (modified) lldb/tools/intel-features/intel-mpx/test/TestMPXTable.py (+120-79) 
- (modified) lldb/use_lldb_suite_root.py (+2-2) 



diff --git a/lldb/bindings/python/createPythonInit.py 
b/lldb/bindings/python/createPythonInit.py
index 4ad7320675f45b2..f343832b949bafe 100644
--- a/lldb/bindings/python/createPythonInit.py
+++ b/lldb/bindings/python/createPythonInit.py
@@ -5,7 +5,7 @@
 pkgFiles = sys.argv[2:]
 
 getFileName = lambda f: os.path.splitext(os.path.basename(f))[0]
-importNames = ', '.join('"{}"'.format(getFileName(f)) for f in pkgFiles)
+importNames = ", ".join('"{}"'.format(getFileName(f)) for f in pkgFiles)
 
 script = """__all__ = [{import_names}]
 for x in __all__:
@@ -18,7 +18,9 @@ def __lldb_init_module(debugger, internal_dict):
 lldb_init = getattr(submodule, '__lldb_init_module', None)
 if lldb_init:
   lldb_init(debugger, internal_dict)
-""".format(import_names=importNames, pkg_name=pkgRelDir.replace("/", "."))
+""".format(
+import_names=importNames, pkg_name=pkgRelDir.replace("/", ".")
+)
 
 pkgIniFile = os.path.normpath(os.path.join(pkgRelDir, "__init__.py"))
 with open(pkgIniFile, "w") as f:
diff --git a/lldb/bindings/python/get-python-config.py 
b/lldb/bindings/python/get-python-config.py
index 6369e32a49168c7..ae84cbb1215a9e3 100755
--- a/lldb/bindings/python/get-python-config.py
+++ b/lldb/bindings/python/get-python-config.py
@@ -10,10 +10,11 @@ def relpath_nodots(path, base):
 rel = os.path.normpath(os.path.relpath(path, base))
 assert not os.path.isabs(rel)
 parts = rel.split(os.path.sep)
-if parts and parts[0] == '..':
+if parts and parts[0] == "..":
 raise ValueError(f"{path} is not under {base}")
 return rel
 
+
 def main():
 parser = argparse.ArgumentParser(description="extract cmake variables from 
python")
 parser.add_argument("variable_name")
@@ -35,10 +36,10 @@ def main():
 except ValueError:
 # Try to fall back to something reasonable if sysconfig's platlib
 # is outside of sys.prefix
-if os.name == 'posix':
-print('lib/python%d.%d/site-packages' % sys.version_info[:2])
-elif os.name == 'nt':
-print('Lib\\site-packages')
+if os.name == "posix":
+print("lib/python%d.%d/site-packages" % sys.version_info[:2])
+elif os.name == "nt":
+print("Lib\\site-packages")
 else:
 raise
 elif args.variable_name == "LLDB_PYTHON_EXE_RELATIVE_PATH":
@@ -57,16 +58,20 @@ def main():
 exe = os.path.realpath(exe)
 continue
 else:
-print("Could not find a relative path to sys.executable 
under sys.prefix", file=sys.stderr)
+print(
+"Could not find a relative path to sys.executable 
under sys.prefix",
+file=sys.stderr,
+)
 for e in tried:
 print("tried:", e, file=sys.stderr)
 print("realpath(sys.prefix):", prefix, file=sys.stderr)
 print("sys.prefix:", sys.prefix, file=sys.stderr)
 sys.exit(1)
 elif args.variable_name == "LLDB_PYTHON_EXT_SUFFIX":
-print(sysconfig.get_config_var('EXT_SUFFIX'))
+print(sysconfig.get_config_var("EXT_SUFFIX"))
 else:
 parser.error(f"unknown variable {args.variable_name}")
 
-if __name__ == '__main__':
+
+if __name__ == "__main__":
 main()
diff --git a/lldb/docs/conf.py b/lldb/docs/conf.py
index 730a8608b5ba44f..ec7f93710ab6f20 100644
--- a/lldb/docs/conf.py
+++ b/lldb/docs/conf.py
@@ -42,9 +42,7 @@
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ["sphinx.ext.todo", "sphinx.ext.mathjax", 
"sphinx.ext.intersphinx"]
 
-autodoc_default_options = {
-"special-members": True
-}
+autodoc_default_options = {"special-members": True}
 
 # Unless we only generate the basic manpage we need the plugin for generating
 # the Python API documentation.
@@ -60,9 +58,7 @@
 try:
 import furo
 except ModuleNotFoundError:
-print(
-f"install

[Lldb-commits] [lldb] [lldb] Format more Python files with black (PR #65979)

2023-09-11 Thread David Spickett via lldb-commits

DavidSpickett wrote:

I looked around for a way to exclude dirs from black but unfortunately the way 
is `--exclude`. I was hoping to place some settings file in third_party/ to 
disable it.

https://github.com/llvm/llvm-project/pull/65979
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Treat user aliases the same as built-ins when tab completing (PR #65974)

2023-09-11 Thread via lldb-commits


@@ -20,7 +20,7 @@ def test_command_abbreviations_and_aliases(self):
 self.assertTrue(result.Succeeded())
 self.assertEqual("apropos script", result.GetOutput())
 
-command_interpreter.ResolveCommand("h", result)
+command_interpreter.ResolveCommand("he", result)

jimingham wrote:

Why did you need to change "h" to "he" here?  "help" is the only command that 
begins with "h" so "h" should complete to "help".

https://github.com/llvm/llvm-project/pull/65974
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Treat user aliases the same as built-ins when tab completing (PR #65974)

2023-09-11 Thread via lldb-commits

https://github.com/jimingham commented:

This looks right to me, but I'm worried about why you had to change the "h" 
completion test to "he"?

https://github.com/llvm/llvm-project/pull/65974
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Treat user aliases the same as built-ins when tab completing (PR #65974)

2023-09-11 Thread David Spickett via lldb-commits


@@ -20,7 +20,7 @@ def test_command_abbreviations_and_aliases(self):
 self.assertTrue(result.Succeeded())
 self.assertEqual("apropos script", result.GetOutput())
 
-command_interpreter.ResolveCommand("h", result)
+command_interpreter.ResolveCommand("he", result)

DavidSpickett wrote:

```
$ ./bin/lldb
(lldb) h
Ambiguous command 'h'. Possible matches:
help
history
<...>
'history' is an abbreviation for 'session history'
```

I figured if we're treating aliases and abreviations and the like all the same, 
then changing this test was the logical thing to do. Unless abbreviations 
should never resolve to aliases?

https://github.com/llvm/llvm-project/pull/65974
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Improve completion tests (PR #65973)

2023-09-11 Thread via lldb-commits

https://github.com/jimingham edited 
https://github.com/llvm/llvm-project/pull/65973
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Improve completion tests (PR #65973)

2023-09-11 Thread via lldb-commits

https://github.com/jimingham approved this pull request.

Other than that tiny quibble, this looks fine to me.

https://github.com/llvm/llvm-project/pull/65973
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Improve completion tests (PR #65973)

2023-09-11 Thread via lldb-commits


@@ -2254,21 +2251,18 @@ def complete_from_to(self, str_input, patterns, 
turn_off_re_match=False):
 for idx in range(1, num_matches + 1):
 compare_string += match_strings.GetStringAtIndex(idx) + 
"\n"
 
+# If the singular pattern is the same as the input, assume that we

jimingham wrote:

This is describing how the function handles its input, maybe it would be better 
to put it up with the triple-quote doc comment at the beginning of the function?

https://github.com/llvm/llvm-project/pull/65973
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Treat user aliases the same as built-ins when tab completing (PR #65974)

2023-09-11 Thread David Spickett via lldb-commits


@@ -20,7 +20,7 @@ def test_command_abbreviations_and_aliases(self):
 self.assertTrue(result.Succeeded())
 self.assertEqual("apropos script", result.GetOutput())
 
-command_interpreter.ResolveCommand("h", result)
+command_interpreter.ResolveCommand("he", result)

DavidSpickett wrote:

Though even if I was right, I should explain that in the test case.

https://github.com/llvm/llvm-project/pull/65974
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Treat user aliases the same as built-ins when tab completing (PR #65974)

2023-09-11 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/65974:

>From ea172bdf8b1d66087076b7ed842021749a49b9fb Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 11 Sep 2023 09:09:31 +
Subject: [PATCH 1/4] [lldb] Improve completion tests

* Assert no completions for tests that should not find completions.
* Remove regex mode from complete_from_to, which was unused.

This exposed bugs in 2 of the tests, target stop-hook and
process unload. These were fixed in previous commits but
couldn't be tested properly until this patch.
---
 .../Python/lldbsuite/test/lldbtest.py | 30 +++---
 .../completion/TestExprCompletion.py  | 92 +--
 .../completion/TestCompletion.py  | 14 +--
 3 files changed, 62 insertions(+), 74 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 49355d61911837f..4f8bdcd7263dc35 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2223,10 +2223,7 @@ def check_completion_with_desc(
 )
 self.assertFalse(got_failure, error_msg)
 
-def complete_exactly(self, str_input, patterns):
-self.complete_from_to(str_input, patterns, True)
-
-def complete_from_to(self, str_input, patterns, turn_off_re_match=False):
+def complete_from_to(self, str_input, patterns):
 """Test that the completion mechanism completes str_input to patterns,
 where patterns could be a pattern-string or a list of 
pattern-strings"""
 # Patterns should not be None in order to proceed.
@@ -2254,21 +2251,18 @@ def complete_from_to(self, str_input, patterns, 
turn_off_re_match=False):
 for idx in range(1, num_matches + 1):
 compare_string += match_strings.GetStringAtIndex(idx) + 
"\n"
 
+# If the singular pattern is the same as the input, assume that we
+# shouldn't have any completions.
+if len(patterns) == 1 and str_input == patterns[0] and num_matches:
+self.fail("Expected no completions but got:\n" + compare_string)
+
 for p in patterns:
-if turn_off_re_match:
-self.expect(
-compare_string,
-msg=COMPLETION_MSG(str_input, p, match_strings),
-exe=False,
-substrs=[p],
-)
-else:
-self.expect(
-compare_string,
-msg=COMPLETION_MSG(str_input, p, match_strings),
-exe=False,
-patterns=[p],
-)
+self.expect(
+compare_string,
+msg=COMPLETION_MSG(str_input, p, match_strings),
+exe=False,
+substrs=[p],
+)
 
 def completions_match(self, command, completions):
 """Checks that the completions for the given command are equal to the
diff --git a/lldb/test/API/commands/expression/completion/TestExprCompletion.py 
b/lldb/test/API/commands/expression/completion/TestExprCompletion.py
index 3c354a3bce1a9b5..ada818989c789a1 100644
--- a/lldb/test/API/commands/expression/completion/TestExprCompletion.py
+++ b/lldb/test/API/commands/expression/completion/TestExprCompletion.py
@@ -29,34 +29,34 @@ def test_expr_completion(self):
 )
 
 # Completing member functions
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooNoArgs", "expr some_expr.FooNoArgsBar()"
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooWithArgs", "expr some_expr.FooWithArgsBar("
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooWithMultipleArgs",
 "expr some_expr.FooWithMultipleArgsBar(",
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooUnderscore", "expr 
some_expr.FooUnderscoreBar_()"
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooNumbers", "expr some_expr.FooNumbersBar1()"
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.StaticMemberMethod",
 "expr some_expr.StaticMemberMethodBar()",
 )
 
 # Completing static functions
-self.complete_exactly(
+self.complete_from_to(
 "expr Expr::StaticMemberMethod", "expr 
Expr::StaticMemberMethodBar()"
 )
 
 # Completing member variables
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.MemberVariab", "expr some_expr.MemberVariableBar"
 )
 
@@ -94,43 +94,43 @@ def test_expr_completion(self):
 self.completions_contain("expr 1+", ["1+some_expr", "1+static_cast"])

[Lldb-commits] [lldb] [lldb] Improve completion tests (PR #65973)

2023-09-11 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/65973:

>From ea172bdf8b1d66087076b7ed842021749a49b9fb Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 11 Sep 2023 09:09:31 +
Subject: [PATCH 1/3] [lldb] Improve completion tests

* Assert no completions for tests that should not find completions.
* Remove regex mode from complete_from_to, which was unused.

This exposed bugs in 2 of the tests, target stop-hook and
process unload. These were fixed in previous commits but
couldn't be tested properly until this patch.
---
 .../Python/lldbsuite/test/lldbtest.py | 30 +++---
 .../completion/TestExprCompletion.py  | 92 +--
 .../completion/TestCompletion.py  | 14 +--
 3 files changed, 62 insertions(+), 74 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 49355d61911837f..4f8bdcd7263dc35 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2223,10 +2223,7 @@ def check_completion_with_desc(
 )
 self.assertFalse(got_failure, error_msg)
 
-def complete_exactly(self, str_input, patterns):
-self.complete_from_to(str_input, patterns, True)
-
-def complete_from_to(self, str_input, patterns, turn_off_re_match=False):
+def complete_from_to(self, str_input, patterns):
 """Test that the completion mechanism completes str_input to patterns,
 where patterns could be a pattern-string or a list of 
pattern-strings"""
 # Patterns should not be None in order to proceed.
@@ -2254,21 +2251,18 @@ def complete_from_to(self, str_input, patterns, 
turn_off_re_match=False):
 for idx in range(1, num_matches + 1):
 compare_string += match_strings.GetStringAtIndex(idx) + 
"\n"
 
+# If the singular pattern is the same as the input, assume that we
+# shouldn't have any completions.
+if len(patterns) == 1 and str_input == patterns[0] and num_matches:
+self.fail("Expected no completions but got:\n" + compare_string)
+
 for p in patterns:
-if turn_off_re_match:
-self.expect(
-compare_string,
-msg=COMPLETION_MSG(str_input, p, match_strings),
-exe=False,
-substrs=[p],
-)
-else:
-self.expect(
-compare_string,
-msg=COMPLETION_MSG(str_input, p, match_strings),
-exe=False,
-patterns=[p],
-)
+self.expect(
+compare_string,
+msg=COMPLETION_MSG(str_input, p, match_strings),
+exe=False,
+substrs=[p],
+)
 
 def completions_match(self, command, completions):
 """Checks that the completions for the given command are equal to the
diff --git a/lldb/test/API/commands/expression/completion/TestExprCompletion.py 
b/lldb/test/API/commands/expression/completion/TestExprCompletion.py
index 3c354a3bce1a9b5..ada818989c789a1 100644
--- a/lldb/test/API/commands/expression/completion/TestExprCompletion.py
+++ b/lldb/test/API/commands/expression/completion/TestExprCompletion.py
@@ -29,34 +29,34 @@ def test_expr_completion(self):
 )
 
 # Completing member functions
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooNoArgs", "expr some_expr.FooNoArgsBar()"
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooWithArgs", "expr some_expr.FooWithArgsBar("
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooWithMultipleArgs",
 "expr some_expr.FooWithMultipleArgsBar(",
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooUnderscore", "expr 
some_expr.FooUnderscoreBar_()"
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooNumbers", "expr some_expr.FooNumbersBar1()"
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.StaticMemberMethod",
 "expr some_expr.StaticMemberMethodBar()",
 )
 
 # Completing static functions
-self.complete_exactly(
+self.complete_from_to(
 "expr Expr::StaticMemberMethod", "expr 
Expr::StaticMemberMethodBar()"
 )
 
 # Completing member variables
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.MemberVariab", "expr some_expr.MemberVariableBar"
 )
 
@@ -94,43 +94,43 @@ def test_expr_completion(self):
 self.completions_contain("expr 1+", ["1+some_expr", "1+static_cast"])

[Lldb-commits] [lldb] [lldb] Improve completion tests (PR #65973)

2023-09-11 Thread David Spickett via lldb-commits


@@ -2254,21 +2251,18 @@ def complete_from_to(self, str_input, patterns, 
turn_off_re_match=False):
 for idx in range(1, num_matches + 1):
 compare_string += match_strings.GetStringAtIndex(idx) + 
"\n"
 
+# If the singular pattern is the same as the input, assume that we

DavidSpickett wrote:

Yes, done.

https://github.com/llvm/llvm-project/pull/65973
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Improve completion tests (PR #65973)

2023-09-11 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett resolved 
https://github.com/llvm/llvm-project/pull/65973
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 2378ba6 - [lldb] Improve completion tests (#65973)

2023-09-11 Thread via lldb-commits

Author: David Spickett
Date: 2023-09-11T18:26:51+01:00
New Revision: 2378ba632e5cdc761584a4154449833ac0f86384

URL: 
https://github.com/llvm/llvm-project/commit/2378ba632e5cdc761584a4154449833ac0f86384
DIFF: 
https://github.com/llvm/llvm-project/commit/2378ba632e5cdc761584a4154449833ac0f86384.diff

LOG: [lldb] Improve completion tests (#65973)

* Assert no completions for tests that should not find completions.
* Remove regex mode from complete_from_to, which was unused.

This exposed bugs in 2 of the tests, target stop-hook and
process unload. These were fixed in previous commits but
couldn't be tested properly until this patch.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/test/API/commands/expression/completion/TestExprCompletion.py
lldb/test/API/functionalities/completion/TestCompletion.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 49355d61911837f..50e8ad08a9d8e89 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2223,12 +2223,15 @@ def check_completion_with_desc(
 )
 self.assertFalse(got_failure, error_msg)
 
-def complete_exactly(self, str_input, patterns):
-self.complete_from_to(str_input, patterns, True)
-
-def complete_from_to(self, str_input, patterns, turn_off_re_match=False):
+def complete_from_to(self, str_input, patterns):
 """Test that the completion mechanism completes str_input to patterns,
-where patterns could be a pattern-string or a list of 
pattern-strings"""
+where patterns could be a single pattern-string or a list of
+pattern-strings.
+
+If there is only one pattern and it is exactly equal to str_input, this
+assumes that there should be no completions provided and that the 
result
+should be the same as the input."""
+
 # Patterns should not be None in order to proceed.
 self.assertFalse(patterns is None)
 # And should be either a string or list of strings.  Check for list 
type
@@ -2254,21 +2257,16 @@ def complete_from_to(self, str_input, patterns, 
turn_off_re_match=False):
 for idx in range(1, num_matches + 1):
 compare_string += match_strings.GetStringAtIndex(idx) + 
"\n"
 
+if len(patterns) == 1 and str_input == patterns[0] and num_matches:
+self.fail("Expected no completions but got:\n" + compare_string)
+
 for p in patterns:
-if turn_off_re_match:
-self.expect(
-compare_string,
-msg=COMPLETION_MSG(str_input, p, match_strings),
-exe=False,
-substrs=[p],
-)
-else:
-self.expect(
-compare_string,
-msg=COMPLETION_MSG(str_input, p, match_strings),
-exe=False,
-patterns=[p],
-)
+self.expect(
+compare_string,
+msg=COMPLETION_MSG(str_input, p, match_strings),
+exe=False,
+substrs=[p],
+)
 
 def completions_match(self, command, completions):
 """Checks that the completions for the given command are equal to the

diff  --git 
a/lldb/test/API/commands/expression/completion/TestExprCompletion.py 
b/lldb/test/API/commands/expression/completion/TestExprCompletion.py
index 3c354a3bce1a9b5..ada818989c789a1 100644
--- a/lldb/test/API/commands/expression/completion/TestExprCompletion.py
+++ b/lldb/test/API/commands/expression/completion/TestExprCompletion.py
@@ -29,34 +29,34 @@ def test_expr_completion(self):
 )
 
 # Completing member functions
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooNoArgs", "expr some_expr.FooNoArgsBar()"
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooWithArgs", "expr some_expr.FooWithArgsBar("
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooWithMultipleArgs",
 "expr some_expr.FooWithMultipleArgsBar(",
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooUnderscore", "expr 
some_expr.FooUnderscoreBar_()"
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.FooNumbers", "expr some_expr.FooNumbersBar1()"
 )
-self.complete_exactly(
+self.complete_from_to(
 "expr some_expr.StaticMemberMethod",
 "expr some_expr.StaticMemberMethodBar()",
 )
 
 # Completing static functions
-self.complete_exact

[Lldb-commits] [lldb] [lldb] Improve completion tests (PR #65973)

2023-09-11 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett closed 
https://github.com/llvm/llvm-project/pull/65973
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Treat user aliases the same as built-ins when tab completing (PR #65974)

2023-09-11 Thread via lldb-commits


@@ -20,7 +20,7 @@ def test_command_abbreviations_and_aliases(self):
 self.assertTrue(result.Succeeded())
 self.assertEqual("apropos script", result.GetOutput())
 
-command_interpreter.ResolveCommand("h", result)
+command_interpreter.ResolveCommand("he", result)

jimingham wrote:

But there's an explicit alias from "h" to "help".  So "h" shouldn't be 
ambiguous, and it isn't on current TOT lldb.  If this change is making `h` 
ambiguous, then that's not right.

https://github.com/llvm/llvm-project/pull/65974
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Treat user aliases the same as built-ins when tab completing (PR #65974)

2023-09-11 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/65974:

>From a279ee8b0a7fca5561f5c4703fc7bdd599419a43 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 11 Sep 2023 11:42:45 +
Subject: [PATCH 1/2] [lldb] Treat user aliases the same as built-ins when tab
 completing

Previously we would check all built-ins first for suggestions,
then check built-ins and aliases. This meant that if you had
an alias brkpt -> breakpoint, "br" would complete to "breakpoint".

Instead of giving you the choice of "brkpt" or "breakpoint".
---
 .../source/Interpreter/CommandInterpreter.cpp | 35 +++
 .../abbreviation/TestAbbreviations.py |  2 +-
 .../completion/TestCompletion.py  | 18 --
 3 files changed, 13 insertions(+), 42 deletions(-)

diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index 6d1ad799f2d10fb..fc94bf6fbfe117c 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1227,36 +1227,11 @@ CommandObject *
 CommandInterpreter::GetCommandObject(llvm::StringRef cmd_str,
  StringList *matches,
  StringList *descriptions) const {
-  CommandObject *command_obj =
-  GetCommandSP(cmd_str, false, true, matches, descriptions).get();
-
-  // If we didn't find an exact match to the command string in the commands,
-  // look in the aliases.
-
-  if (command_obj)
-return command_obj;
-
-  command_obj = GetCommandSP(cmd_str, true, true, matches, descriptions).get();
-
-  if (command_obj)
-return command_obj;
-
-  // If there wasn't an exact match then look for an inexact one in just the
-  // commands
-  command_obj = GetCommandSP(cmd_str, false, false, nullptr).get();
-
-  // Finally, if there wasn't an inexact match among the commands, look for an
-  // inexact match in both the commands and aliases.
-
-  if (command_obj) {
-if (matches)
-  matches->AppendString(command_obj->GetCommandName());
-if (descriptions)
-  descriptions->AppendString(command_obj->GetHelp());
-return command_obj;
-  }
-
-  return GetCommandSP(cmd_str, true, false, matches, descriptions).get();
+  // Try to find a match among commands and aliases. Allowing inexact matches,
+  // but perferring exact matches.
+  return GetCommandSP(cmd_str, /*include_aliases=*/true, /*exact=*/false,
+ matches, descriptions)
+.get();
 }
 
 CommandObject *CommandInterpreter::GetUserCommandObject(
diff --git a/lldb/test/API/functionalities/abbreviation/TestAbbreviations.py 
b/lldb/test/API/functionalities/abbreviation/TestAbbreviations.py
index 10431e41dc81a2e..cade8d87e7f76f5 100644
--- a/lldb/test/API/functionalities/abbreviation/TestAbbreviations.py
+++ b/lldb/test/API/functionalities/abbreviation/TestAbbreviations.py
@@ -20,7 +20,7 @@ def test_command_abbreviations_and_aliases(self):
 self.assertTrue(result.Succeeded())
 self.assertEqual("apropos script", result.GetOutput())
 
-command_interpreter.ResolveCommand("h", result)
+command_interpreter.ResolveCommand("he", result)
 self.assertTrue(result.Succeeded())
 self.assertEqual("help", result.GetOutput())
 
diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py 
b/lldb/test/API/functionalities/completion/TestCompletion.py
index e01bc0ce03f5c95..b1c2d37d3e22192 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -618,19 +618,15 @@ def test_command_unalias(self):
 
 def test_command_aliases(self):
 self.runCmd("command alias brkpt breakpoint")
-# If there is an unambiguous completion from the built-in commands,
-# we choose that.
-self.complete_from_to("br", "breakpoint")
-# Only if there is not, do we then look for an unambiguous completion
-# from the user defined aliases.
+# Exact matches are chosen if possible, even if there are longer
+# completions we could use.
+self.complete_from_to("b", "b ")
+# Aliases are included in possible completions.
+self.complete_from_to("br", ["breakpoint", "brkpt"])
+# An alias can be the chosen completion.
 self.complete_from_to("brk", "brkpt")
 
-# Aliases are included when there's no exact match.
-self.runCmd("command alias play breakpoint")
-self.complete_from_to("pl", ["plugin", "platform", "play"])
-
-# That list can also contain only aliases if there's no built-ins to
-# match.
+# The list can contain only aliases if there's no built-ins to match.
 self.runCmd("command alias test_1 breakpoint")
 self.runCmd("command alias test_2 breakpoint")
 self.complete_from_to("test_", ["test_1", "test_2"])

>From

[Lldb-commits] [lldb] [lldb] Treat user aliases the same as built-ins when tab completing (PR #65974)

2023-09-11 Thread via lldb-commits


@@ -20,7 +20,7 @@ def test_command_abbreviations_and_aliases(self):
 self.assertTrue(result.Succeeded())
 self.assertEqual("apropos script", result.GetOutput())
 
-command_interpreter.ResolveCommand("h", result)
+command_interpreter.ResolveCommand("he", result)

jimingham wrote:

Huh, I don't see where we explicitly alias "help" to "h", but in the current 
TOT lldb (well, as of last Friday) and in the latest Apple release, "h" is not 
ambiguous:

(lldb) version
lldb version 18.0.0git (g...@github.com:llvm/llvm-project.git revision 
04a6dc24db333ee8bfdf50791a18024f30086ff6)
  clang revision 04a6dc24db333ee8bfdf50791a18024f30086ff6
  llvm revision 04a6dc24db333ee8bfdf50791a18024f30086ff6
(lldb) h
Debugger commands:
  apropos   -- List debugger commands related to a word or subject.
  breakpoint-- Commands for operating on breakpoints (see 'help b' for

I wonder what's different.  Whatever we do, `h` really should mean "help" 
that's a far more common usage.

https://github.com/llvm/llvm-project/pull/65974
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Treat user aliases the same as built-ins when tab completing (PR #65974)

2023-09-11 Thread via lldb-commits

https://github.com/jimingham edited 
https://github.com/llvm/llvm-project/pull/65974
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 8012518 - Revert "[lldb] Improve completion tests (#65973)"

2023-09-11 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2023-09-11T17:35:27Z
New Revision: 8012518f600bebaa4ed99a57d553eeea25c2d0c9

URL: 
https://github.com/llvm/llvm-project/commit/8012518f600bebaa4ed99a57d553eeea25c2d0c9
DIFF: 
https://github.com/llvm/llvm-project/commit/8012518f600bebaa4ed99a57d553eeea25c2d0c9.diff

LOG: Revert "[lldb] Improve completion tests (#65973)"

This reverts commit 2378ba632e5cdc761584a4154449833ac0f86384.

I need to fix the x86 specific register tests.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/test/API/commands/expression/completion/TestExprCompletion.py
lldb/test/API/functionalities/completion/TestCompletion.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 50e8ad08a9d8e89..49355d61911837f 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2223,15 +2223,12 @@ def check_completion_with_desc(
 )
 self.assertFalse(got_failure, error_msg)
 
-def complete_from_to(self, str_input, patterns):
-"""Test that the completion mechanism completes str_input to patterns,
-where patterns could be a single pattern-string or a list of
-pattern-strings.
-
-If there is only one pattern and it is exactly equal to str_input, this
-assumes that there should be no completions provided and that the 
result
-should be the same as the input."""
+def complete_exactly(self, str_input, patterns):
+self.complete_from_to(str_input, patterns, True)
 
+def complete_from_to(self, str_input, patterns, turn_off_re_match=False):
+"""Test that the completion mechanism completes str_input to patterns,
+where patterns could be a pattern-string or a list of 
pattern-strings"""
 # Patterns should not be None in order to proceed.
 self.assertFalse(patterns is None)
 # And should be either a string or list of strings.  Check for list 
type
@@ -2257,16 +2254,21 @@ def complete_from_to(self, str_input, patterns):
 for idx in range(1, num_matches + 1):
 compare_string += match_strings.GetStringAtIndex(idx) + 
"\n"
 
-if len(patterns) == 1 and str_input == patterns[0] and num_matches:
-self.fail("Expected no completions but got:\n" + compare_string)
-
 for p in patterns:
-self.expect(
-compare_string,
-msg=COMPLETION_MSG(str_input, p, match_strings),
-exe=False,
-substrs=[p],
-)
+if turn_off_re_match:
+self.expect(
+compare_string,
+msg=COMPLETION_MSG(str_input, p, match_strings),
+exe=False,
+substrs=[p],
+)
+else:
+self.expect(
+compare_string,
+msg=COMPLETION_MSG(str_input, p, match_strings),
+exe=False,
+patterns=[p],
+)
 
 def completions_match(self, command, completions):
 """Checks that the completions for the given command are equal to the

diff  --git 
a/lldb/test/API/commands/expression/completion/TestExprCompletion.py 
b/lldb/test/API/commands/expression/completion/TestExprCompletion.py
index ada818989c789a1..3c354a3bce1a9b5 100644
--- a/lldb/test/API/commands/expression/completion/TestExprCompletion.py
+++ b/lldb/test/API/commands/expression/completion/TestExprCompletion.py
@@ -29,34 +29,34 @@ def test_expr_completion(self):
 )
 
 # Completing member functions
-self.complete_from_to(
+self.complete_exactly(
 "expr some_expr.FooNoArgs", "expr some_expr.FooNoArgsBar()"
 )
-self.complete_from_to(
+self.complete_exactly(
 "expr some_expr.FooWithArgs", "expr some_expr.FooWithArgsBar("
 )
-self.complete_from_to(
+self.complete_exactly(
 "expr some_expr.FooWithMultipleArgs",
 "expr some_expr.FooWithMultipleArgsBar(",
 )
-self.complete_from_to(
+self.complete_exactly(
 "expr some_expr.FooUnderscore", "expr 
some_expr.FooUnderscoreBar_()"
 )
-self.complete_from_to(
+self.complete_exactly(
 "expr some_expr.FooNumbers", "expr some_expr.FooNumbersBar1()"
 )
-self.complete_from_to(
+self.complete_exactly(
 "expr some_expr.StaticMemberMethod",
 "expr some_expr.StaticMemberMethodBar()",
 )
 
 # Completing static functions
-self.complete_from_to(
+self.complete_exactly(
 "expr Expr::StaticMemberMethod", "expr 
Expr::StaticMemberMethodBar()"
 

[Lldb-commits] [lldb] [lldb] Format more Python files with black (PR #65979)

2023-09-11 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere approved this pull request.

LGTM. I formatted the test, examples and script subdirectory. This is more 
comprehensive. 

https://github.com/llvm/llvm-project/pull/65979
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D159313: [lldb][NFCI] Remove use of ConstString in StructuredData

2023-09-11 Thread Alex Langford via Phabricator via lldb-commits
bulbazord updated this revision to Diff 556469.
bulbazord marked 7 inline comments as done.
bulbazord added a comment.

Address feedback from @fdeazeve


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159313/new/

https://reviews.llvm.org/D159313

Files:
  lldb/include/lldb/Utility/StructuredData.h
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
  lldb/source/Target/Target.cpp
  lldb/source/Utility/StructuredData.cpp

Index: lldb/source/Utility/StructuredData.cpp
===
--- lldb/source/Utility/StructuredData.cpp
+++ lldb/source/Utility/StructuredData.cpp
@@ -162,8 +162,18 @@
 
 void StructuredData::Dictionary::Serialize(json::OStream &s) const {
   s.objectBegin();
-  for (const auto &pair : m_dict) {
-s.attributeBegin(pair.first.GetStringRef());
+
+  // To ensure the output format is always stable, we sort the dictionary by key
+  // first.
+  using Entry = std::pair;
+  std::vector sorted_entries;
+  for (const auto &pair : m_dict)
+sorted_entries.push_back({pair.first(), pair.second});
+
+  llvm::sort(sorted_entries);
+
+  for (const auto &pair : sorted_entries) {
+s.attributeBegin(pair.first);
 pair.second->Serialize(s);
 s.attributeEnd();
   }
@@ -228,9 +238,22 @@
 
 void StructuredData::Dictionary::GetDescription(lldb_private::Stream &s) const {
   size_t indentation_level = s.GetIndentLevel();
-  for (auto iter = m_dict.begin(); iter != m_dict.end(); iter++) {
+
+  // To ensure the output format is always stable, we sort the dictionary by key
+  // first.
+  using Entry = std::pair;
+  std::vector sorted_entries;
+  for (const auto &pair : m_dict)
+sorted_entries.push_back({pair.first(), pair.second});
+
+  llvm::sort(sorted_entries, [&](const Entry &lhs, const Entry &rhs) -> bool {
+return lhs.first < rhs.first;
+  });
+
+  for (auto iter = sorted_entries.begin(); iter != sorted_entries.end();
+   iter++) {
 // Sanitize.
-if (iter->first.IsNull() || iter->first.IsEmpty() || !iter->second)
+if (iter->first.empty() || !iter->second)
   continue;
 
 // Reset original indentation level.
@@ -238,7 +261,7 @@
 s.Indent();
 
 // Print key.
-s.Printf("%s:", iter->first.AsCString());
+s.Format("{0}:", iter->first);
 
 // Return to new line and increase indentation if value is record type.
 // Otherwise add spacing.
@@ -252,7 +275,7 @@
 
 // Print value and new line if now last pair.
 iter->second->GetDescription(s);
-if (std::next(iter) != m_dict.end())
+if (std::next(iter) != sorted_entries.end())
   s.EOL();
 
 // Reset indentation level if it was incremented previously.
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -3859,11 +3859,10 @@
   s.Indent("Args:\n");
   s.SetIndentLevel(s.GetIndentLevel() + 4);
 
-  auto print_one_element = [&s](ConstString key,
+  auto print_one_element = [&s](llvm::StringRef key,
 StructuredData::Object *object) {
 s.Indent();
-s.Printf("%s : %s\n", key.GetCString(),
-  object->GetStringValue().str().c_str());
+s.Format("{0} : {1}\n", key, object->GetStringValue());
 return true;
   };
 
Index: lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
===
--- lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
+++ lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
@@ -224,7 +224,7 @@
   [&module_sp, new_style_source_remapping_dictionary,
original_DBGSourcePath_value,
do_truncate_remapping_names](
-  ConstString key,
+  llvm::StringRef key,
   StructuredData::Object *object) -> bool {
 if (object && object->GetAsString()) {
 
@@ -237,7 +237,7 @@
 DBGSourcePath = original_DBGSourcePath_value;
   }
   module_sp->GetSourceMappingList().Append(
-  key.GetStringRef(), DBGSourcePath, true);
+  key, DBGSourcePath, true);
   // With version 2 of DBGSourcePathRemapping, we
   // can chop off the last two filename parts
   // from the source remapping and get a more
@@ -245,7 +245,7 @@
   // Add this as another option in addition to
   // the full source path remap.
   if (

[Lldb-commits] [PATCH] D159313: [lldb][NFCI] Remove use of ConstString in StructuredData

2023-09-11 Thread Alex Langford via Phabricator via lldb-commits
bulbazord added inline comments.



Comment at: lldb/include/lldb/Utility/StructuredData.h:436
   auto array_sp = std::make_shared();
-  collection::const_iterator iter;
-  for (iter = m_dict.begin(); iter != m_dict.end(); ++iter) {
+  for (auto iter = m_dict.begin(); iter != m_dict.end(); ++iter) {
 auto key_object_sp = std::make_shared();

fdeazeve wrote:
> Since we are touching this line anyway, could you replace this with
> 
> ```
> for (StringRef key : llvm::make_first_range(m_dict))
> ```
> 
> This has a bit less cognitive burden IMO
Unfortunately no, `llvm::make_first_range` assumes that you can refer to 
`first` on an iterator, but `first` is actually a method to be called. The 
iterator code will have to stay for now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159313/new/

https://reviews.llvm.org/D159313

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] c154ba8 - [LLDB][NFC] Add the mojo language to Language::GetPrimaryLanguage

2023-09-11 Thread walter erquinigo via lldb-commits

Author: walter erquinigo
Date: 2023-09-11T15:25:05-04:00
New Revision: c154ba8abeb6f59f85a9bb6fdf7bd79ad0d8c05c

URL: 
https://github.com/llvm/llvm-project/commit/c154ba8abeb6f59f85a9bb6fdf7bd79ad0d8c05c
DIFF: 
https://github.com/llvm/llvm-project/commit/c154ba8abeb6f59f85a9bb6fdf7bd79ad0d8c05c.diff

LOG: [LLDB][NFC] Add the mojo language to Language::GetPrimaryLanguage

This doesn't change the current behavior of the function, but the explicit 
declaration looks cleaner.

Added: 


Modified: 
lldb/source/Target/Language.cpp

Removed: 




diff  --git a/lldb/source/Target/Language.cpp b/lldb/source/Target/Language.cpp
index 78785352676da31..42c3350806d90f5 100644
--- a/lldb/source/Target/Language.cpp
+++ b/lldb/source/Target/Language.cpp
@@ -374,6 +374,7 @@ LanguageType Language::GetPrimaryLanguage(LanguageType 
language) {
   case eLanguageTypeJulia:
   case eLanguageTypeDylan:
   case eLanguageTypeMipsAssembler:
+  case eLanguageTypeMojo:
   case eLanguageTypeUnknown:
   default:
 return language;



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][NFCI] BreakpointResolverName ctor shouldn't unnecessarily copy data (PR #66001)

2023-09-11 Thread via lldb-commits

https://github.com/bulbazord created 
https://github.com/llvm/llvm-project/pull/66001:

Instead of creating a copy of the vector, we should just pass a reference 
along. The only method that calls this Ctor also holds onto a non-mutable 
reference to the vector of strings, so this should just make sense.

>From 8a2298fd612c10ac409256b675e02fc2912acac7 Mon Sep 17 00:00:00 2001
From: Alex Langford 
Date: Mon, 11 Sep 2023 11:40:50 -0700
Subject: [PATCH] [lldb][NFCI] BreakpointResolverName ctor shouldn't
 unnecessarily copy data

Instead of creating a copy of the vector, we should just pass a
reference along. The only method that calls this Ctor also holds onto a
non-mutable reference to the vector of strings, so this should just make
sense.
---
 lldb/include/lldb/Breakpoint/BreakpointResolverName.h |  2 +-
 lldb/source/Breakpoint/BreakpointResolverName.cpp | 10 --
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/lldb/include/lldb/Breakpoint/BreakpointResolverName.h 
b/lldb/include/lldb/Breakpoint/BreakpointResolverName.h
index 7a9fc466076799a..cbfcbc9af0ea1cb 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointResolverName.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointResolverName.h
@@ -38,7 +38,7 @@ class BreakpointResolverName : public BreakpointResolver {
 
   // This one takes a C++ array of names.  It is always MatchType = Exact.
   BreakpointResolverName(const lldb::BreakpointSP &bkpt,
- std::vector names,
+ const std::vector &names,
  lldb::FunctionNameType name_type_mask,
  lldb::LanguageType language, lldb::addr_t offset,
  bool skip_prologue);
diff --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp 
b/lldb/source/Breakpoint/BreakpointResolverName.cpp
index b533bdfb9c11ce5..861377a5ddabfb5 100644
--- a/lldb/source/Breakpoint/BreakpointResolverName.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp
@@ -56,12 +56,10 @@ BreakpointResolverName::BreakpointResolverName(
   }
 }
 
-BreakpointResolverName::BreakpointResolverName(const BreakpointSP &bkpt,
-   std::vector names,
-   FunctionNameType name_type_mask,
-   LanguageType language,
-   lldb::addr_t offset,
-   bool skip_prologue)
+BreakpointResolverName::BreakpointResolverName(
+const BreakpointSP &bkpt, const std::vector &names,
+FunctionNameType name_type_mask, LanguageType language, lldb::addr_t 
offset,
+bool skip_prologue)
 : BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset),
   m_match_type(Breakpoint::Exact), m_language(language),
   m_skip_prologue(skip_prologue) {

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][NFCI] BreakpointResolverName ctor shouldn't unnecessarily copy data (PR #66001)

2023-09-11 Thread via lldb-commits

https://github.com/bulbazord review_requested 
https://github.com/llvm/llvm-project/pull/66001
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][NFCI] BreakpointResolverName ctor shouldn't unnecessarily copy data (PR #66001)

2023-09-11 Thread via lldb-commits

https://github.com/bulbazord edited 
https://github.com/llvm/llvm-project/pull/66001
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][NFCI] BreakpointResolverName ctor shouldn't unnecessarily copy data (PR #66001)

2023-09-11 Thread via lldb-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/66001
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][NFCI] BreakpointResolverName ctor shouldn't unnecessarily copy data (PR #66001)

2023-09-11 Thread via lldb-commits

llvmbot wrote:

@llvm/pr-subscribers-lldb


Changes

Instead of creating a copy of the vector, we should just pass a reference 
along. The only method that calls this Ctor also holds onto a non-mutable 
reference to the vector of strings so a copy should be unnecessary.
--
Full diff: https://github.com/llvm/llvm-project/pull/66001.diff

2 Files Affected:

- (modified) lldb/include/lldb/Breakpoint/BreakpointResolverName.h (+1-1) 
- (modified) lldb/source/Breakpoint/BreakpointResolverName.cpp (+4-6) 



diff --git a/lldb/include/lldb/Breakpoint/BreakpointResolverName.h 
b/lldb/include/lldb/Breakpoint/BreakpointResolverName.h
index 7a9fc466076799a..cbfcbc9af0ea1cb 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointResolverName.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointResolverName.h
@@ -38,7 +38,7 @@ class BreakpointResolverName : public BreakpointResolver {
 
   // This one takes a C++ array of names.  It is always MatchType = Exact.
   BreakpointResolverName(const lldb::BreakpointSP &bkpt,
- std::vector names,
+ const std::vector &names,
  lldb::FunctionNameType name_type_mask,
  lldb::LanguageType language, lldb::addr_t offset,
  bool skip_prologue);
diff --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp 
b/lldb/source/Breakpoint/BreakpointResolverName.cpp
index b533bdfb9c11ce5..861377a5ddabfb5 100644
--- a/lldb/source/Breakpoint/BreakpointResolverName.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp
@@ -56,12 +56,10 @@ BreakpointResolverName::BreakpointResolverName(
   }
 }
 
-BreakpointResolverName::BreakpointResolverName(const BreakpointSP &bkpt,
-   std::vector names,
-   FunctionNameType name_type_mask,
-   LanguageType language,
-   lldb::addr_t offset,
-   bool skip_prologue)
+BreakpointResolverName::BreakpointResolverName(
+const BreakpointSP &bkpt, const std::vector &names,
+FunctionNameType name_type_mask, LanguageType language, lldb::addr_t 
offset,
+bool skip_prologue)
 : BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset),
   m_match_type(Breakpoint::Exact), m_language(language),
   m_skip_prologue(skip_prologue) {




https://github.com/llvm/llvm-project/pull/66001
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-vscode] Make descriptive summaries and raw child for synthetics configurable (PR #65687)

2023-09-11 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo edited 
https://github.com/llvm/llvm-project/pull/65687
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-vscode] Make descriptive summaries and raw child for synthetics configurable (PR #65687)

2023-09-11 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/65687:

>From 6415738e5c359553212d4a04780694587a536a82 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Thu, 7 Sep 2023 18:35:10 -0400
Subject: [PATCH] [lldb-vscode] Make descriptive summaries and raw child for
 synthetics configurable

"descriptive summaries" should only be used for small to medium binaries 
because of the performance penalty the cause when completing types. I'm 
defaulting it to false.
Besides that, the "raw child" for synthetics should be optional as well. I'm 
defaulting it to false as well.

Both options can be set via a launch or attach config, following the pattern of 
most settings. javascript extension wrappers can set these settings on their 
own as well.
---
 .../tools/lldb-vscode/lldbvscode_testcase.py  | 15 +++-
 .../test/tools/lldb-vscode/vscode.py  |  6 +-
 .../evaluate/TestVSCode_evaluate.py   | 16 ++--
 .../variables/TestVSCode_variables.py | 81 +++
 lldb/tools/lldb-vscode/JSONUtils.cpp  | 12 ++-
 lldb/tools/lldb-vscode/VSCode.cpp |  2 +
 lldb/tools/lldb-vscode/VSCode.h   |  2 +
 lldb/tools/lldb-vscode/lldb-vscode.cpp| 11 ++-
 lldb/tools/lldb-vscode/package.json   | 20 +
 9 files changed, 136 insertions(+), 29 deletions(-)

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
index a6c370ccd2036de..8cd4e8454c89099 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
@@ -1,8 +1,9 @@
-from lldbsuite.test.lldbtest import *
 import os
-import vscode
 import time
 
+import vscode
+from lldbsuite.test.lldbtest import *
+
 
 class VSCodeTestCaseBase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
@@ -267,7 +268,7 @@ def disassemble(self, threadId=None, frameIndex=None):
 
 if memoryReference not in self.vscode.disassembled_instructions:
 self.vscode.request_disassemble(memoryReference=memoryReference)
-
+
 return self.vscode.disassembled_instructions[memoryReference]
 
 def attach(
@@ -348,6 +349,8 @@ def launch(
 runInTerminal=False,
 expectFailure=False,
 postRunCommands=None,
+enableAutoVariableSummaries=False,
+enableSyntheticChildDebugging=False,
 ):
 """Sending launch request to vscode"""
 
@@ -384,6 +387,8 @@ def cleanup():
 sourceMap=sourceMap,
 runInTerminal=runInTerminal,
 postRunCommands=postRunCommands,
+enableAutoVariableSummaries=enableAutoVariableSummaries,
+enableSyntheticChildDebugging=enableSyntheticChildDebugging,
 )
 
 if expectFailure:
@@ -418,6 +423,8 @@ def build_and_launch(
 disconnectAutomatically=True,
 postRunCommands=None,
 lldbVSCodeEnv=None,
+enableAutoVariableSummaries=False,
+enableSyntheticChildDebugging=False,
 ):
 """Build the default Makefile target, create the VSCode debug adaptor,
 and launch the process.
@@ -446,4 +453,6 @@ def build_and_launch(
 runInTerminal=runInTerminal,
 disconnectAutomatically=disconnectAutomatically,
 postRunCommands=postRunCommands,
+enableAutoVariableSummaries=enableAutoVariableSummaries,
+enableSyntheticChildDebugging=enableSyntheticChildDebugging,
 )
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
index 14f0bf0a2d4ed3d..b30443e2e2acb9e 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -648,7 +648,7 @@ def request_disconnect(self, terminateDebuggee=None):
 "arguments": args_dict,
 }
 return self.send_recv(command_dict)
-
+
 def request_disassemble(self, memoryReference, offset=-50, 
instructionCount=200, resolveSymbols=True):
 args_dict = {
 "memoryReference": memoryReference,
@@ -727,6 +727,8 @@ def request_launch(
 sourceMap=None,
 runInTerminal=False,
 postRunCommands=None,
+enableAutoVariableSummaries=False,
+enableSyntheticChildDebugging=False,
 ):
 args_dict = {"program": program}
 if args:
@@ -768,6 +770,8 @@ def request_launch(
 args_dict["runInTerminal"] = runInTerminal
 if postRunCommands:
 args_dict["postRunCommands"] = postRunCommands
+args_dict["enableAutoVariableSummaries"] = enableAutoVariableSummaries
+args_dict["enableSyntheticChildDebugging"] = 
enableSyntheticChildDebugging
 command_dict = {"command": "launch", "type": "request",

[Lldb-commits] [lldb] [lldb][NFCI] BreakpointResolverName ctor shouldn't unnecessarily copy data (PR #66001)

2023-09-11 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere approved this pull request.


https://github.com/llvm/llvm-project/pull/66001
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D158785: [lldb] Add a "thread extrainfo" LC_NOTE for Mach-O corefiles, to store the thread IDs of the threads

2023-09-11 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

I really dislike all the manual memory management that's going on in this file, 
but I realize that's not the result of this patch, but rather because of the 
code that was factored out. I'd love if someone would replace the mallo'c 
buffers with `SmallString<0>`s but that's orthogonal to this patch. LGTM.




Comment at: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp:73
 #include 
+#include 
 

I don't think this is needed (anymore)? 



Comment at: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h:124
+  std::vector>
+  FindLC_NOTEByName(std::string name);
+

Thanks for factoring this out!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158785/new/

https://reviews.llvm.org/D158785

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-vscode] Make descriptive summaries and raw child for synthetics configurable (PR #65687)

2023-09-11 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/65687:

>From 6415738e5c359553212d4a04780694587a536a82 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Thu, 7 Sep 2023 18:35:10 -0400
Subject: [PATCH 1/2] [lldb-vscode] Make descriptive summaries and raw child
 for synthetics configurable

"descriptive summaries" should only be used for small to medium binaries 
because of the performance penalty the cause when completing types. I'm 
defaulting it to false.
Besides that, the "raw child" for synthetics should be optional as well. I'm 
defaulting it to false as well.

Both options can be set via a launch or attach config, following the pattern of 
most settings. javascript extension wrappers can set these settings on their 
own as well.
---
 .../tools/lldb-vscode/lldbvscode_testcase.py  | 15 +++-
 .../test/tools/lldb-vscode/vscode.py  |  6 +-
 .../evaluate/TestVSCode_evaluate.py   | 16 ++--
 .../variables/TestVSCode_variables.py | 81 +++
 lldb/tools/lldb-vscode/JSONUtils.cpp  | 12 ++-
 lldb/tools/lldb-vscode/VSCode.cpp |  2 +
 lldb/tools/lldb-vscode/VSCode.h   |  2 +
 lldb/tools/lldb-vscode/lldb-vscode.cpp| 11 ++-
 lldb/tools/lldb-vscode/package.json   | 20 +
 9 files changed, 136 insertions(+), 29 deletions(-)

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
index a6c370ccd2036de..8cd4e8454c89099 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
@@ -1,8 +1,9 @@
-from lldbsuite.test.lldbtest import *
 import os
-import vscode
 import time
 
+import vscode
+from lldbsuite.test.lldbtest import *
+
 
 class VSCodeTestCaseBase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
@@ -267,7 +268,7 @@ def disassemble(self, threadId=None, frameIndex=None):
 
 if memoryReference not in self.vscode.disassembled_instructions:
 self.vscode.request_disassemble(memoryReference=memoryReference)
-
+
 return self.vscode.disassembled_instructions[memoryReference]
 
 def attach(
@@ -348,6 +349,8 @@ def launch(
 runInTerminal=False,
 expectFailure=False,
 postRunCommands=None,
+enableAutoVariableSummaries=False,
+enableSyntheticChildDebugging=False,
 ):
 """Sending launch request to vscode"""
 
@@ -384,6 +387,8 @@ def cleanup():
 sourceMap=sourceMap,
 runInTerminal=runInTerminal,
 postRunCommands=postRunCommands,
+enableAutoVariableSummaries=enableAutoVariableSummaries,
+enableSyntheticChildDebugging=enableSyntheticChildDebugging,
 )
 
 if expectFailure:
@@ -418,6 +423,8 @@ def build_and_launch(
 disconnectAutomatically=True,
 postRunCommands=None,
 lldbVSCodeEnv=None,
+enableAutoVariableSummaries=False,
+enableSyntheticChildDebugging=False,
 ):
 """Build the default Makefile target, create the VSCode debug adaptor,
 and launch the process.
@@ -446,4 +453,6 @@ def build_and_launch(
 runInTerminal=runInTerminal,
 disconnectAutomatically=disconnectAutomatically,
 postRunCommands=postRunCommands,
+enableAutoVariableSummaries=enableAutoVariableSummaries,
+enableSyntheticChildDebugging=enableSyntheticChildDebugging,
 )
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
index 14f0bf0a2d4ed3d..b30443e2e2acb9e 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -648,7 +648,7 @@ def request_disconnect(self, terminateDebuggee=None):
 "arguments": args_dict,
 }
 return self.send_recv(command_dict)
-
+
 def request_disassemble(self, memoryReference, offset=-50, 
instructionCount=200, resolveSymbols=True):
 args_dict = {
 "memoryReference": memoryReference,
@@ -727,6 +727,8 @@ def request_launch(
 sourceMap=None,
 runInTerminal=False,
 postRunCommands=None,
+enableAutoVariableSummaries=False,
+enableSyntheticChildDebugging=False,
 ):
 args_dict = {"program": program}
 if args:
@@ -768,6 +770,8 @@ def request_launch(
 args_dict["runInTerminal"] = runInTerminal
 if postRunCommands:
 args_dict["postRunCommands"] = postRunCommands
+args_dict["enableAutoVariableSummaries"] = enableAutoVariableSummaries
+args_dict["enableSyntheticChildDebugging"] = 
enableSyntheticChildDebugging
 command_dict = {"command": "launch", "type": "reque

[Lldb-commits] [lldb] [lldb-vscode] Make descriptive summaries and raw child for synthetics configurable (PR #65687)

2023-09-11 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo closed 
https://github.com/llvm/llvm-project/pull/65687
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] a2a9918 - [lldb-vscode] Make descriptive summaries and raw child for synthetics configurable (#65687)

2023-09-11 Thread via lldb-commits

Author: Walter Erquinigo
Date: 2023-09-11T17:00:01-04:00
New Revision: a2a9918a8524f3f7675297b75daa2a80bc0790ff

URL: 
https://github.com/llvm/llvm-project/commit/a2a9918a8524f3f7675297b75daa2a80bc0790ff
DIFF: 
https://github.com/llvm/llvm-project/commit/a2a9918a8524f3f7675297b75daa2a80bc0790ff.diff

LOG: [lldb-vscode] Make descriptive summaries and raw child for synthetics 
configurable (#65687)

"descriptive summaries" should only be used for small to medium binaries
because of the performance penalty the cause when completing types. I'm
defaulting it to false.
Besides that, the "raw child" for synthetics should be optional as well.
I'm defaulting it to false.

Both options can be set via a launch or attach config, following the
pattern of most settings. javascript extension wrappers can set these
settings on their own as well.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
lldb/tools/lldb-vscode/JSONUtils.cpp
lldb/tools/lldb-vscode/VSCode.cpp
lldb/tools/lldb-vscode/VSCode.h
lldb/tools/lldb-vscode/lldb-vscode.cpp
lldb/tools/lldb-vscode/package.json

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
index a6c370ccd2036de..8cd4e8454c89099 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
@@ -1,8 +1,9 @@
-from lldbsuite.test.lldbtest import *
 import os
-import vscode
 import time
 
+import vscode
+from lldbsuite.test.lldbtest import *
+
 
 class VSCodeTestCaseBase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
@@ -267,7 +268,7 @@ def disassemble(self, threadId=None, frameIndex=None):
 
 if memoryReference not in self.vscode.disassembled_instructions:
 self.vscode.request_disassemble(memoryReference=memoryReference)
-
+
 return self.vscode.disassembled_instructions[memoryReference]
 
 def attach(
@@ -348,6 +349,8 @@ def launch(
 runInTerminal=False,
 expectFailure=False,
 postRunCommands=None,
+enableAutoVariableSummaries=False,
+enableSyntheticChildDebugging=False,
 ):
 """Sending launch request to vscode"""
 
@@ -384,6 +387,8 @@ def cleanup():
 sourceMap=sourceMap,
 runInTerminal=runInTerminal,
 postRunCommands=postRunCommands,
+enableAutoVariableSummaries=enableAutoVariableSummaries,
+enableSyntheticChildDebugging=enableSyntheticChildDebugging,
 )
 
 if expectFailure:
@@ -418,6 +423,8 @@ def build_and_launch(
 disconnectAutomatically=True,
 postRunCommands=None,
 lldbVSCodeEnv=None,
+enableAutoVariableSummaries=False,
+enableSyntheticChildDebugging=False,
 ):
 """Build the default Makefile target, create the VSCode debug adaptor,
 and launch the process.
@@ -446,4 +453,6 @@ def build_and_launch(
 runInTerminal=runInTerminal,
 disconnectAutomatically=disconnectAutomatically,
 postRunCommands=postRunCommands,
+enableAutoVariableSummaries=enableAutoVariableSummaries,
+enableSyntheticChildDebugging=enableSyntheticChildDebugging,
 )

diff  --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
index 14f0bf0a2d4ed3d..b30443e2e2acb9e 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -648,7 +648,7 @@ def request_disconnect(self, terminateDebuggee=None):
 "arguments": args_dict,
 }
 return self.send_recv(command_dict)
-
+
 def request_disassemble(self, memoryReference, offset=-50, 
instructionCount=200, resolveSymbols=True):
 args_dict = {
 "memoryReference": memoryReference,
@@ -727,6 +727,8 @@ def request_launch(
 sourceMap=None,
 runInTerminal=False,
 postRunCommands=None,
+enableAutoVariableSummaries=False,
+enableSyntheticChildDebugging=False,
 ):
 args_dict = {"program": program}
 if args:
@@ -768,6 +770,8 @@ def request_launch(
 args_dict["runInTerminal"] = runInTerminal
 if postRunCommands:
 args_dict["postRunCommands"] = postRunCommands
+args_dict["enableAutoVariableSummaries"] = enableAutoVariableSummaries
+args_dict["enableSyntheticChildDebugging"] = 

[Lldb-commits] [lldb] [lldb][NFCI] BreakpointResolverName ctor shouldn't unnecessarily copy data (PR #66001)

2023-09-11 Thread via lldb-commits

https://github.com/jimingham approved this pull request.

Makes sense


https://github.com/llvm/llvm-project/pull/66001
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Fix a bug with cancelling "attach -w" after you have run a process previously (PR #65822)

2023-09-11 Thread via lldb-commits

https://github.com/jimingham resolved 
https://github.com/llvm/llvm-project/pull/65822
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Fix a bug with cancelling "attach -w" after you have run a process previously (PR #65822)

2023-09-11 Thread via lldb-commits

https://github.com/jimingham resolved 
https://github.com/llvm/llvm-project/pull/65822
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D158785: [lldb] Add a "thread extrainfo" LC_NOTE for Mach-O corefiles, to store the thread IDs of the threads

2023-09-11 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda updated this revision to Diff 556505.
jasonmolenda added a comment.

Update patch to not use malloc/free for a temporary heap allocation; a 
std::string works fine.  One caveat is that the c-strings we read in may have a 
nul byte terminator, and left alone the std::string will consider that part of 
the string; that can be preserved when using a string_view etc representation.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158785/new/

https://reviews.llvm.org/D158785

Files:
  lldb/include/lldb/Symbol/ObjectFile.h
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
  lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
  lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
  lldb/source/Plugins/Process/mach-core/ThreadMachCore.h
  lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py

Index: lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py
===
--- lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py
+++ lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py
@@ -26,6 +26,11 @@
 self.runCmd("continue")
 
 self.runCmd("process save-core -s stack " + corefile)
+live_tids = []
+if self.TraceOn():
+self.runCmd("thread list")
+for t in process.threads:
+live_tids.append(t.GetThreadID())
 process.Kill()
 self.dbg.DeleteTarget(target)
 
@@ -42,3 +47,9 @@
 self.assertEqual(
 thread.GetStopDescription(256), "ESR_EC_DABORT_EL0 (fault address: 0x0)"
 )
+
+if self.TraceOn():
+self.runCmd("thread list")
+for i in range(process.GetNumThreads()):
+t = process.GetThreadAtIndex(i)
+self.assertEqual(t.GetThreadID(), live_tids[i])
Index: lldb/source/Plugins/Process/mach-core/ThreadMachCore.h
===
--- lldb/source/Plugins/Process/mach-core/ThreadMachCore.h
+++ lldb/source/Plugins/Process/mach-core/ThreadMachCore.h
@@ -17,7 +17,8 @@
 
 class ThreadMachCore : public lldb_private::Thread {
 public:
-  ThreadMachCore(lldb_private::Process &process, lldb::tid_t tid);
+  ThreadMachCore(lldb_private::Process &process, lldb::tid_t tid,
+ uint32_t objfile_lc_thread_idx);
 
   ~ThreadMachCore() override;
 
@@ -57,6 +58,7 @@
   std::string m_dispatch_queue_name;
   lldb::addr_t m_thread_dispatch_qaddr;
   lldb::RegisterContextSP m_thread_reg_ctx_sp;
+  uint32_t m_objfile_lc_thread_idx;
 
   // Protected member functions.
   bool CalculateStopInfo() override;
Index: lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
===
--- lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
+++ lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
@@ -33,9 +33,11 @@
 
 // Thread Registers
 
-ThreadMachCore::ThreadMachCore(Process &process, lldb::tid_t tid)
+ThreadMachCore::ThreadMachCore(Process &process, lldb::tid_t tid,
+   uint32_t objfile_lc_thread_idx)
 : Thread(process, tid), m_thread_name(), m_dispatch_queue_name(),
-  m_thread_dispatch_qaddr(LLDB_INVALID_ADDRESS), m_thread_reg_ctx_sp() {}
+  m_thread_dispatch_qaddr(LLDB_INVALID_ADDRESS), m_thread_reg_ctx_sp(),
+  m_objfile_lc_thread_idx(objfile_lc_thread_idx) {}
 
 ThreadMachCore::~ThreadMachCore() { DestroyThread(); }
 
@@ -81,8 +83,8 @@
   ObjectFile *core_objfile =
   static_cast(process_sp.get())->GetCoreObjectFile();
   if (core_objfile)
-m_thread_reg_ctx_sp =
-core_objfile->GetThreadContextAtIndex(GetID(), *this);
+m_thread_reg_ctx_sp = core_objfile->GetThreadContextAtIndex(
+m_objfile_lc_thread_idx, *this);
 }
 reg_ctx_sp = m_thread_reg_ctx_sp;
   } else {
Index: lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
===
--- lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
+++ lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
@@ -594,9 +594,34 @@
 ObjectFile *core_objfile = m_core_module_sp->GetObjectFile();
 
 if (core_objfile) {
+  std::set used_tids;
   const uint32_t num_threads = core_objfile->GetNumThreadContexts();
-  for (lldb::tid_t tid = 0; tid < num_threads; ++tid) {
-ThreadSP thread_sp(new ThreadMachCore(*this, tid));
+  std::vector tids;
+  if (core_objfile->GetCorefileThreadExtraInfos(tids)) {
+assert(tids.size() == num_threads);
+
+// Find highest tid value.
+tid_t highest_tid = 0;
+for (uint32_t i = 0; i < num_threads; i++) {
+  if (tids[i] != LLDB_INVALID_THREAD_ID && tids[i] > highest_tid)
+

[Lldb-commits] [lldb] [libc][libm][GPU] Added missing vendor entry points to `libm` for GPUs (PR #66031)

2023-09-11 Thread Anton Rydahl via lldb-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,MaheshRavishankar
 <1663364+maheshravishan...@users.noreply.github.com>,Fangrui Song
 ,Razvan Lupusoru ,Walter Erquinigo
 ,"Yaxun (Sam) Liu" ,Nico Weber
 ,Stella Laurenzo ,Lang Hames
 ,Matthias Braun ,Arthur Eubanks
 ,Nico Weber ,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Vitaly Buka
 ,Vitaly Buka ,Fangrui Song
 ,Fangrui Song ,Fangrui Song 
,Fangrui
 Song ,erichkeane ,Amir Ayupov
 ,Amir Ayupov ,yinying-lisa-li
 <107574043+yinying-lisa...@users.noreply.github.com>,Christopher Di Bella
 ,Konstantin Varlamov ,Alexey Bader
 ,Vitaly Buka 


https://github.com/AntonRydahl review_requested 
https://github.com/llvm/llvm-project/pull/66031
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [libc][libm][GPU] Added missing vendor entry points to `libm` for GPUs (PR #66031)

2023-09-11 Thread Anton Rydahl via lldb-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,MaheshRavishankar
 <1663364+maheshravishan...@users.noreply.github.com>,Fangrui Song
 ,Razvan Lupusoru ,Walter Erquinigo
 ,"Yaxun (Sam) Liu" ,Nico Weber
 ,Stella Laurenzo ,Lang Hames
 ,Matthias Braun ,Arthur Eubanks
 ,Nico Weber ,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Vitaly Buka
 ,Vitaly Buka ,Fangrui Song
 ,Fangrui Song ,Fangrui Song 
,Fangrui
 Song ,erichkeane ,Amir Ayupov
 ,Amir Ayupov ,yinying-lisa-li
 <107574043+yinying-lisa...@users.noreply.github.com>,Christopher Di Bella
 ,Konstantin Varlamov ,Alexey Bader
 ,Vitaly Buka 


https://github.com/AntonRydahl review_requested 
https://github.com/llvm/llvm-project/pull/66031
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [libc][libm][GPU] Added missing vendor entry points to `libm` for GPUs (PR #66031)

2023-09-11 Thread Anton Rydahl via lldb-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,MaheshRavishankar
 <1663364+maheshravishan...@users.noreply.github.com>,Fangrui Song
 ,Razvan Lupusoru ,Walter Erquinigo
 ,"Yaxun (Sam) Liu" ,Nico Weber
 ,Stella Laurenzo ,Lang Hames
 ,Matthias Braun ,Arthur Eubanks
 ,Nico Weber ,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Vitaly Buka
 ,Vitaly Buka ,Fangrui Song
 ,Fangrui Song ,Fangrui Song 
,Fangrui
 Song ,erichkeane ,Amir Ayupov
 ,Amir Ayupov ,yinying-lisa-li
 <107574043+yinying-lisa...@users.noreply.github.com>,Christopher Di Bella
 ,Konstantin Varlamov ,Alexey Bader
 ,Vitaly Buka 


https://github.com/AntonRydahl review_requested 
https://github.com/llvm/llvm-project/pull/66031
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [libc][libm][GPU] Added missing vendor entry points to `libm` for GPUs (PR #66031)

2023-09-11 Thread Anton Rydahl via lldb-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,MaheshRavishankar
 <1663364+maheshravishan...@users.noreply.github.com>,Fangrui Song
 ,Razvan Lupusoru ,Walter Erquinigo
 ,"Yaxun (Sam) Liu" ,Nico Weber
 ,Stella Laurenzo ,Lang Hames
 ,Matthias Braun ,Arthur Eubanks
 ,Nico Weber ,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Vitaly Buka
 ,Vitaly Buka ,Fangrui Song
 ,Fangrui Song ,Fangrui Song 
,Fangrui
 Song ,erichkeane ,Amir Ayupov
 ,Amir Ayupov ,yinying-lisa-li
 <107574043+yinying-lisa...@users.noreply.github.com>,Christopher Di Bella
 ,Konstantin Varlamov ,Alexey Bader
 ,Vitaly Buka 


https://github.com/AntonRydahl labeled 
https://github.com/llvm/llvm-project/pull/66031
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [libc][libm][GPU] Added missing vendor entry points to `libm` for GPUs (PR #66031)

2023-09-11 Thread Anton Rydahl via lldb-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,MaheshRavishankar
 <1663364+maheshravishan...@users.noreply.github.com>,Fangrui Song
 ,Razvan Lupusoru ,Walter Erquinigo
 ,"Yaxun (Sam) Liu" ,Nico Weber
 ,Stella Laurenzo ,Lang Hames
 ,Matthias Braun ,Arthur Eubanks
 ,Nico Weber ,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Vitaly Buka
 ,Vitaly Buka ,Fangrui Song
 ,Fangrui Song ,Fangrui Song 
,Fangrui
 Song ,erichkeane ,Amir Ayupov
 ,Amir Ayupov ,yinying-lisa-li
 <107574043+yinying-lisa...@users.noreply.github.com>,Christopher Di Bella
 ,Konstantin Varlamov ,Alexey Bader
 ,Vitaly Buka 


https://github.com/AntonRydahl review_requested 
https://github.com/llvm/llvm-project/pull/66031
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [libc][libm][GPU] Added missing vendor entry points to `libm` for GPUs (PR #66031)

2023-09-11 Thread via lldb-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,MaheshRavishankar
 <1663364+maheshravishan...@users.noreply.github.com>,Fangrui Song
 ,Razvan Lupusoru ,Walter Erquinigo
 ,"Yaxun (Sam) Liu" ,Nico Weber
 ,Stella Laurenzo ,Lang Hames
 ,Matthias Braun ,Arthur Eubanks
 ,Nico Weber ,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Vitaly Buka
 ,Vitaly Buka ,Fangrui Song
 ,Fangrui Song ,Fangrui Song 
,Fangrui
 Song ,erichkeane ,Amir Ayupov
 ,Amir Ayupov ,yinying-lisa-li
 <107574043+yinying-lisa...@users.noreply.github.com>,Christopher Di Bella
 ,Konstantin Varlamov ,Alexey Bader
 ,Vitaly Buka 


llvmbot wrote:

@llvm/pr-subscribers-libc


Changes

There are a number of mathematical functions where no target-agnostic 
implementations exist, and the compiler built-ins are not correctly lowered on 
all GPU targets. This patch adds inlined wrappers for those functions to the 
GPU version of `libm` for AMDGPU and NVPTX targets.
--

Patch is 51.98 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/66031.diff

50 Files Affected:

- (modified) libc/config/gpu/entrypoints.txt (+34-3) 
- (modified) libc/src/math/CMakeLists.txt (+15) 
- (added) libc/src/math/acos.h (+18) 
- (added) libc/src/math/acosh.h (+18) 
- (added) libc/src/math/asin.h (+18) 
- (added) libc/src/math/asinh.h (+18) 
- (added) libc/src/math/atan.h (+18) 
- (added) libc/src/math/atan2.h (+18) 
- (added) libc/src/math/atan2f.h (+18) 
- (added) libc/src/math/atanh.h (+18) 
- (added) libc/src/math/erf.h (+18) 
- (added) libc/src/math/expm1.h (+18) 
- (modified) libc/src/math/gpu/vendor/CMakeLists.txt (+143) 
- (added) libc/src/math/gpu/vendor/acos.cpp (+18) 
- (added) libc/src/math/gpu/vendor/acosh.cpp (+18) 
- (modified) libc/src/math/gpu/vendor/amdgpu/amdgpu.h (+25) 
- (modified) libc/src/math/gpu/vendor/amdgpu/declarations.h (+31-3) 
- (added) libc/src/math/gpu/vendor/asin.cpp (+18) 
- (added) libc/src/math/gpu/vendor/asinh.cpp (+18) 
- (added) libc/src/math/gpu/vendor/atan.cpp (+18) 
- (added) libc/src/math/gpu/vendor/atan2.cpp (+20) 
- (added) libc/src/math/gpu/vendor/atan2f.cpp (+21) 
- (added) libc/src/math/gpu/vendor/atanh.cpp (+18) 
- (added) libc/src/math/gpu/vendor/erf.cpp (+18) 
- (added) libc/src/math/gpu/vendor/erff.cpp (+18) 
- (added) libc/src/math/gpu/vendor/exp.cpp (+18) 
- (added) libc/src/math/gpu/vendor/exp10.cpp (+18) 
- (added) libc/src/math/gpu/vendor/exp2.cpp (+18) 
- (added) libc/src/math/gpu/vendor/expm1.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log10.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log10f.cpp (+19) 
- (added) libc/src/math/gpu/vendor/log1p.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log1pf.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log2.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log2f.cpp (+18) 
- (added) libc/src/math/gpu/vendor/logb.cpp (+18) 
- (added) libc/src/math/gpu/vendor/logbf.cpp (+19) 
- (added) libc/src/math/gpu/vendor/logf.cpp (+18) 
- (added) libc/src/math/gpu/vendor/lrint.cpp (+18) 
- (added) libc/src/math/gpu/vendor/lrintf.cpp (+18) 
- (added) libc/src/math/gpu/vendor/lround.cpp (+18) 
- (added) libc/src/math/gpu/vendor/lroundf.cpp (+20) 
- (modified) libc/src/math/gpu/vendor/nvptx/declarations.h (+25) 
- (modified) libc/src/math/gpu/vendor/nvptx/nvptx.h (+25) 
- (added) libc/src/math/gpu/vendor/tgamma.cpp (+18) 
- (added) libc/src/math/gpu/vendor/tgammaf.cpp (+18) 
- (added) libc/src/math/sincos.h (+18) 
- (added) libc/src/math/tgamma.h (+18) 
- (added) libc/src/math/tgammaf.h (+18) 



diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt
index 0e314c60870c6a..730f76cbd6fbb9 100644
--- a/libc/config/gpu/entrypoints.txt
+++ b/libc/config/gpu/entrypoints.txt
@@ -113,11 +113,19 @@ set(TARGET_LIBC_ENTRYPOINTS
 
 set(TARGET_LIBM_ENTRYPOINTS
 # math.h entrypoints
+libc.src.math.acos
 libc.src.math.acosf
+libc.src.math.acosh
 libc.src.math.acoshf
+libc.src.math.asin
 libc.src.math.asinf
+libc.src.math.asinh
 libc.src.math.asinhf
+libc.src.math.atan
 libc.src.math.atanf
+libc.src.math.atan2
+libc.src.math.atan2f
+libc.src.math.atanh
 libc.src.math.atanhf
 libc.src.math.ceil
 libc.src.math.ceilf
@@ -127,9 +135,15 @@ set(TARGET_LIBM_ENTRYPOINTS
 libc.src.math.cosf
 libc.src.math.cosh
 libc.src.math.coshf
+libc.src.math.erf
+libc.src.math.erff
+libc.src.math.exp10
 libc.src.math.exp10f
+libc.src.math.exp2
 libc.src.math.exp2f
+libc.src.math.exp
 libc.src.math.expf
+libc.src.math.expm1
 libc.src.math.expm1f
 libc.src.math.fabs
 libc.src.math.fabsf
@@ -157,15 +171,26 @@ set(TARGET_LIBM_ENTRYPOINTS
 libc.src.math.llrintf
 libc.src.math.llround
 libc.src.math.llroundf
-libc.src.math.pow
-libc.src.math.powf
-libc.src.math.sin
+libc.src.math.log10
+libc.src.math.log10f
+libc.src.math.log1p
+

[Lldb-commits] [lldb] [libc][libm][GPU] Added missing vendor entry points to `libm` for GPUs (PR #66031)

2023-09-11 Thread via lldb-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,MaheshRavishankar
 <1663364+maheshravishan...@users.noreply.github.com>,Fangrui Song
 ,Razvan Lupusoru ,Walter Erquinigo
 ,"Yaxun (Sam) Liu" ,Nico Weber
 ,Stella Laurenzo ,Lang Hames
 ,Matthias Braun ,Arthur Eubanks
 ,Nico Weber ,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Vitaly Buka
 ,Vitaly Buka ,Fangrui Song
 ,Fangrui Song ,Fangrui Song 
,Fangrui
 Song ,erichkeane ,Amir Ayupov
 ,Amir Ayupov ,yinying-lisa-li
 <107574043+yinying-lisa...@users.noreply.github.com>,Christopher Di Bella
 ,Konstantin Varlamov ,Alexey Bader
 ,Vitaly Buka 


llvmbot wrote:

@llvm/pr-subscribers-backend-amdgpu


Changes

There are a number of mathematical functions where no target-agnostic 
implementations exist, and the compiler built-ins are not correctly lowered on 
all GPU targets. This patch adds inlined wrappers for those functions to the 
GPU version of `libm` for AMDGPU and NVPTX targets.
--

Patch is 52.08 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/66031.diff

50 Files Affected:

- (modified) libc/config/gpu/entrypoints.txt (+34-3) 
- (modified) libc/src/math/CMakeLists.txt (+15) 
- (added) libc/src/math/acos.h (+18) 
- (added) libc/src/math/acosh.h (+18) 
- (added) libc/src/math/asin.h (+18) 
- (added) libc/src/math/asinh.h (+18) 
- (added) libc/src/math/atan.h (+18) 
- (added) libc/src/math/atan2.h (+18) 
- (added) libc/src/math/atan2f.h (+18) 
- (added) libc/src/math/atanh.h (+18) 
- (added) libc/src/math/erf.h (+18) 
- (added) libc/src/math/expm1.h (+18) 
- (modified) libc/src/math/gpu/vendor/CMakeLists.txt (+143) 
- (added) libc/src/math/gpu/vendor/acos.cpp (+18) 
- (added) libc/src/math/gpu/vendor/acosh.cpp (+18) 
- (modified) libc/src/math/gpu/vendor/amdgpu/amdgpu.h (+25) 
- (modified) libc/src/math/gpu/vendor/amdgpu/declarations.h (+31-3) 
- (added) libc/src/math/gpu/vendor/asin.cpp (+18) 
- (added) libc/src/math/gpu/vendor/asinh.cpp (+18) 
- (added) libc/src/math/gpu/vendor/atan.cpp (+18) 
- (added) libc/src/math/gpu/vendor/atan2.cpp (+20) 
- (added) libc/src/math/gpu/vendor/atan2f.cpp (+21) 
- (added) libc/src/math/gpu/vendor/atanh.cpp (+18) 
- (added) libc/src/math/gpu/vendor/erf.cpp (+18) 
- (added) libc/src/math/gpu/vendor/erff.cpp (+18) 
- (added) libc/src/math/gpu/vendor/exp.cpp (+18) 
- (added) libc/src/math/gpu/vendor/exp10.cpp (+18) 
- (added) libc/src/math/gpu/vendor/exp2.cpp (+18) 
- (added) libc/src/math/gpu/vendor/expm1.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log10.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log10f.cpp (+19) 
- (added) libc/src/math/gpu/vendor/log1p.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log1pf.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log2.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log2f.cpp (+18) 
- (added) libc/src/math/gpu/vendor/logb.cpp (+18) 
- (added) libc/src/math/gpu/vendor/logbf.cpp (+19) 
- (added) libc/src/math/gpu/vendor/logf.cpp (+18) 
- (added) libc/src/math/gpu/vendor/lrint.cpp (+18) 
- (added) libc/src/math/gpu/vendor/lrintf.cpp (+18) 
- (added) libc/src/math/gpu/vendor/lround.cpp (+18) 
- (added) libc/src/math/gpu/vendor/lroundf.cpp (+20) 
- (modified) libc/src/math/gpu/vendor/nvptx/declarations.h (+25) 
- (modified) libc/src/math/gpu/vendor/nvptx/nvptx.h (+25) 
- (added) libc/src/math/gpu/vendor/tgamma.cpp (+18) 
- (added) libc/src/math/gpu/vendor/tgammaf.cpp (+18) 
- (added) libc/src/math/sincos.h (+18) 
- (added) libc/src/math/tgamma.h (+18) 
- (added) libc/src/math/tgammaf.h (+18) 



diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt
index 0e314c60870c6ae..730f76cbd6fbb9c 100644
--- a/libc/config/gpu/entrypoints.txt
+++ b/libc/config/gpu/entrypoints.txt
@@ -113,11 +113,19 @@ set(TARGET_LIBC_ENTRYPOINTS
 
 set(TARGET_LIBM_ENTRYPOINTS
 # math.h entrypoints
+libc.src.math.acos
 libc.src.math.acosf
+libc.src.math.acosh
 libc.src.math.acoshf
+libc.src.math.asin
 libc.src.math.asinf
+libc.src.math.asinh
 libc.src.math.asinhf
+libc.src.math.atan
 libc.src.math.atanf
+libc.src.math.atan2
+libc.src.math.atan2f
+libc.src.math.atanh
 libc.src.math.atanhf
 libc.src.math.ceil
 libc.src.math.ceilf
@@ -127,9 +135,15 @@ set(TARGET_LIBM_ENTRYPOINTS
 libc.src.math.cosf
 libc.src.math.cosh
 libc.src.math.coshf
+libc.src.math.erf
+libc.src.math.erff
+libc.src.math.exp10
 libc.src.math.exp10f
+libc.src.math.exp2
 libc.src.math.exp2f
+libc.src.math.exp
 libc.src.math.expf
+libc.src.math.expm1
 libc.src.math.expm1f
 libc.src.math.fabs
 libc.src.math.fabsf
@@ -157,15 +171,26 @@ set(TARGET_LIBM_ENTRYPOINTS
 libc.src.math.llrintf
 libc.src.math.llround
 libc.src.math.llroundf
-libc.src.math.pow
-libc.src.math.powf
-libc.src.math.sin
+libc.src.math.log10
+libc.src.math.log10f
+libc.src.

[Lldb-commits] [lldb] 2cab996 - Add "process metadata" Mach-O LC_NOTE for corefiles

2023-09-11 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2023-09-11T16:46:18-07:00
New Revision: 2cab996192cf143d10e3381fcefa75e270cc7ddb

URL: 
https://github.com/llvm/llvm-project/commit/2cab996192cf143d10e3381fcefa75e270cc7ddb
DIFF: 
https://github.com/llvm/llvm-project/commit/2cab996192cf143d10e3381fcefa75e270cc7ddb.diff

LOG: Add "process metadata" Mach-O LC_NOTE for corefiles

Add a new LC_NOTE for Mach-O corefiles, "proces metadata", which is a
JSON string.  Currently there may be a `threads` key in the JSON,
and if `threads` is present, it is an array with the same number of
elements as there are LC_THREADs in the corefile.  This patch adds
support for a `thread_id` key-value for each `thread` entry, to
supply a thread ID for that LC_THREAD.

Differential Revision: https://reviews.llvm.org/D158785
rdar://113037252

Added: 


Modified: 
lldb/include/lldb/Symbol/ObjectFile.h
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
lldb/source/Plugins/Process/mach-core/ThreadMachCore.h

lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py

Removed: 




diff  --git a/lldb/include/lldb/Symbol/ObjectFile.h 
b/lldb/include/lldb/Symbol/ObjectFile.h
index 9519635c24f9ff..6348d8103f85de 100644
--- a/lldb/include/lldb/Symbol/ObjectFile.h
+++ b/lldb/include/lldb/Symbol/ObjectFile.h
@@ -538,6 +538,30 @@ class ObjectFile : public 
std::enable_shared_from_this,
 return false;
   }
 
+  /// Get metadata about threads from the corefile.
+  ///
+  /// The corefile may have metadata (e.g. a Mach-O "thread extrainfo"
+  /// LC_NOTE) which for the threads in the process; this method tries
+  /// to retrieve them.
+  ///
+  /// \param[out] tids
+  /// Filled in with a vector of tid_t's that matches the number
+  /// of threads in the corefile (ObjectFile::GetNumThreadContexts).
+  /// If a tid is not specified for one of the corefile threads,
+  /// that entry in the vector will have LLDB_INVALID_THREAD_ID and
+  /// the caller should assign a tid to the thread that does not
+  /// conflict with the ones provided in this array.
+  /// As additional metadata are added, this method may return a
+  /// \a tids vector with no thread id's specified at all; the
+  /// corefile may only specify one of the other metadata.
+  ///
+  /// \return
+  /// Returns true if thread metadata was found in this corefile.
+  ///
+  virtual bool GetCorefileThreadExtraInfos(std::vector &tids) {
+return false;
+  }
+
   virtual lldb::RegisterContextSP
   GetThreadContextAtIndex(uint32_t idx, lldb_private::Thread &thread) {
 return lldb::RegisterContextSP();

diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 3ce2057d537227..efcfdf5ac2cd37 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -5415,17 +5415,14 @@ uint32_t ObjectFileMachO::GetNumThreadContexts() {
   return m_thread_context_offsets.GetSize();
 }
 
-std::string ObjectFileMachO::GetIdentifierString() {
-  std::string result;
-  Log *log(
-  GetLog(LLDBLog::Symbols | LLDBLog::Process | LLDBLog::DynamicLoader));
+std::vector>
+ObjectFileMachO::FindLC_NOTEByName(std::string name) {
+  std::vector> results;
   ModuleSP module_sp(GetModule());
   if (module_sp) {
 std::lock_guard guard(module_sp->GetMutex());
 
-// First, look over the load commands for an LC_NOTE load command with
-// data_owner string "kern ver str" & use that if found.
-lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
+offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
 for (uint32_t i = 0; i < m_header.ncmds; ++i) {
   const uint32_t cmd_offset = offset;
   llvm::MachO::load_command lc = {};
@@ -5436,58 +5433,67 @@ std::string ObjectFileMachO::GetIdentifierString() {
 m_data.CopyData(offset, 16, data_owner);
 data_owner[16] = '\0';
 offset += 16;
-uint64_t fileoff = m_data.GetU64_unchecked(&offset);
-uint64_t size = m_data.GetU64_unchecked(&offset);
-
-// "kern ver str" has a uint32_t version and then a nul terminated
-// c-string.
-if (strcmp("kern ver str", data_owner) == 0) {
-  offset = fileoff;
-  uint32_t version;
-  if (m_data.GetU32(&offset, &version, 1) != nullptr) {
-if (version == 1) {
-  uint32_t strsize = size - sizeof(uint32_t);
-  char *buf = (char *)malloc(strsize);
-  if (buf) {
-m_data.CopyData(offset, strsize, buf);
-buf[strsize - 1] = '\0';
-result = buf;

[Lldb-commits] [PATCH] D158785: [lldb] Add a "thread extrainfo" LC_NOTE for Mach-O corefiles, to store the thread IDs of the threads

2023-09-11 Thread Jason Molenda via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2cab996192cf: Add "process metadata" Mach-O 
LC_NOTE for corefiles (authored by jasonmolenda).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158785/new/

https://reviews.llvm.org/D158785

Files:
  lldb/include/lldb/Symbol/ObjectFile.h
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
  lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
  lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
  lldb/source/Plugins/Process/mach-core/ThreadMachCore.h
  lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py

Index: lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py
===
--- lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py
+++ lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py
@@ -26,6 +26,11 @@
 self.runCmd("continue")
 
 self.runCmd("process save-core -s stack " + corefile)
+live_tids = []
+if self.TraceOn():
+self.runCmd("thread list")
+for t in process.threads:
+live_tids.append(t.GetThreadID())
 process.Kill()
 self.dbg.DeleteTarget(target)
 
@@ -42,3 +47,9 @@
 self.assertEqual(
 thread.GetStopDescription(256), "ESR_EC_DABORT_EL0 (fault address: 0x0)"
 )
+
+if self.TraceOn():
+self.runCmd("thread list")
+for i in range(process.GetNumThreads()):
+t = process.GetThreadAtIndex(i)
+self.assertEqual(t.GetThreadID(), live_tids[i])
Index: lldb/source/Plugins/Process/mach-core/ThreadMachCore.h
===
--- lldb/source/Plugins/Process/mach-core/ThreadMachCore.h
+++ lldb/source/Plugins/Process/mach-core/ThreadMachCore.h
@@ -17,7 +17,8 @@
 
 class ThreadMachCore : public lldb_private::Thread {
 public:
-  ThreadMachCore(lldb_private::Process &process, lldb::tid_t tid);
+  ThreadMachCore(lldb_private::Process &process, lldb::tid_t tid,
+ uint32_t objfile_lc_thread_idx);
 
   ~ThreadMachCore() override;
 
@@ -57,6 +58,7 @@
   std::string m_dispatch_queue_name;
   lldb::addr_t m_thread_dispatch_qaddr;
   lldb::RegisterContextSP m_thread_reg_ctx_sp;
+  uint32_t m_objfile_lc_thread_idx;
 
   // Protected member functions.
   bool CalculateStopInfo() override;
Index: lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
===
--- lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
+++ lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
@@ -33,9 +33,11 @@
 
 // Thread Registers
 
-ThreadMachCore::ThreadMachCore(Process &process, lldb::tid_t tid)
+ThreadMachCore::ThreadMachCore(Process &process, lldb::tid_t tid,
+   uint32_t objfile_lc_thread_idx)
 : Thread(process, tid), m_thread_name(), m_dispatch_queue_name(),
-  m_thread_dispatch_qaddr(LLDB_INVALID_ADDRESS), m_thread_reg_ctx_sp() {}
+  m_thread_dispatch_qaddr(LLDB_INVALID_ADDRESS), m_thread_reg_ctx_sp(),
+  m_objfile_lc_thread_idx(objfile_lc_thread_idx) {}
 
 ThreadMachCore::~ThreadMachCore() { DestroyThread(); }
 
@@ -81,8 +83,8 @@
   ObjectFile *core_objfile =
   static_cast(process_sp.get())->GetCoreObjectFile();
   if (core_objfile)
-m_thread_reg_ctx_sp =
-core_objfile->GetThreadContextAtIndex(GetID(), *this);
+m_thread_reg_ctx_sp = core_objfile->GetThreadContextAtIndex(
+m_objfile_lc_thread_idx, *this);
 }
 reg_ctx_sp = m_thread_reg_ctx_sp;
   } else {
Index: lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
===
--- lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
+++ lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
@@ -594,9 +594,34 @@
 ObjectFile *core_objfile = m_core_module_sp->GetObjectFile();
 
 if (core_objfile) {
+  std::set used_tids;
   const uint32_t num_threads = core_objfile->GetNumThreadContexts();
-  for (lldb::tid_t tid = 0; tid < num_threads; ++tid) {
-ThreadSP thread_sp(new ThreadMachCore(*this, tid));
+  std::vector tids;
+  if (core_objfile->GetCorefileThreadExtraInfos(tids)) {
+assert(tids.size() == num_threads);
+
+// Find highest tid value.
+tid_t highest_tid = 0;
+for (uint32_t i = 0; i < num_threads; i++) {
+  if (tids[i] != LLDB_INVALID_THREAD_ID && tids[i] > highest_tid)
+highest_tid = tids[i];
+}
+tid_t current_unused_tid = highest_tid + 1;
+for (uint32_t i = 0; i < num_threads; i++) {
+  if (tids[i] == LLDB_INVALID_THREAD_ID) {
+t

[Lldb-commits] [lldb] [libc][libm][GPU] Added missing vendor entry points to `libm` for GPUs (PR #66031)

2023-09-11 Thread Anton Rydahl via lldb-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,MaheshRavishankar
 <1663364+maheshravishan...@users.noreply.github.com>,Fangrui Song
 ,Razvan Lupusoru ,Walter Erquinigo
 ,"Yaxun (Sam) Liu" ,Nico Weber
 ,Stella Laurenzo ,Lang Hames
 ,Matthias Braun ,Arthur Eubanks
 ,Nico Weber ,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Vitaly Buka
 ,Vitaly Buka ,Fangrui Song
 ,Fangrui Song ,Fangrui Song 
,Fangrui
 Song ,erichkeane ,Amir Ayupov
 ,Amir Ayupov ,yinying-lisa-li
 <107574043+yinying-lisa...@users.noreply.github.com>,Christopher Di Bella
 ,Konstantin Varlamov ,Alexey Bader
 ,Vitaly Buka 


https://github.com/AntonRydahl closed 
https://github.com/llvm/llvm-project/pull/66031
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `target modules dump separate-debug-info` (PR #66035)

2023-09-11 Thread Tom Yang via lldb-commits

https://github.com/zhyty review_requested 
https://github.com/llvm/llvm-project/pull/66035
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `target modules dump separate-debug-info` (PR #66035)

2023-09-11 Thread Tom Yang via lldb-commits

https://github.com/zhyty review_requested 
https://github.com/llvm/llvm-project/pull/66035
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `target modules dump separate-debug-info` (PR #66035)

2023-09-11 Thread Tom Yang via lldb-commits

https://github.com/zhyty review_requested 
https://github.com/llvm/llvm-project/pull/66035
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `target modules dump separate-debug-info` (PR #66035)

2023-09-11 Thread Tom Yang via lldb-commits

https://github.com/zhyty created 
https://github.com/llvm/llvm-project/pull/66035:

Summary:

Add a new command
```
target modules dump separate-debug-info [ ...]
```
or
```
image dump separate-debug-info [ ...]
```
(since `image` is an alias for `target modules`).

This lists the separate debug info files and their current status (loaded or 
not loaded) for the specified modules. This diff implements this command for 
mach-O files with OSO and ELF files with dwo.

Example dwo:
```
(lldb) image dump separate-debug-info
[
  {
"separate-debug-info-files": [
  {
"comp_dir": ".",
"dwo_id": 7516252579671439727,
"dwo_name": "a-main.dwo",
"loaded": true,
"resolved_dwo_path": "/home/toyang/workspace/dwo-scratch/a-main.dwo"
  },
  {
"comp_dir": ".",
"dwo_id": 13601198072221073203,
"dwo_name": "a-foo.dwo",
"loaded": true,
"resolved_dwo_path": "/home/toyang/workspace/dwo-scratch/a-foo.dwo"
  }
],
"symfile": "/home/toyang/workspace/dwo-scratch/a.out"
  }
]
```

Example dwo with missing dwo:
```
warning: (x86_64) /home/toyang/workspace/dwp/a.out unable to locate separate 
debug file (dwo, dwp). Debugging will be degraded. (troubleshoot with 
https://fburl.com/missing_dwo)
Current executable set to '/home/toyang/workspace/dwp/a.out' (x86_64).
(lldb) image dump separate-debug-info
[
  {
"separate-debug-info-files": [
  {
"comp_dir": "/home/toyang/workspace/dwp",
"dwo_id": 5620165179865774,
"dwo_name": "a-main.dwo",
"loaded": false
  },
  {
"comp_dir": "/home/toyang/workspace/dwp",
"dwo_id": 13601198072221073203,
"dwo_name": "a-foo.dwo",
"loaded": false
  }
],
"symfile": "/home/toyang/workspace/dwp/a.out"
  }
]
```

Example output with dwp:
```
(lldb) image dump separate-debug-info
[
  {
"separate-debug-info-files": [
  {
"comp_dir": "/home/toyang/workspace/dwp",
"dwo_id": 5620165179865774,
"dwo_name": "a-main.dwo",
"loaded": true,
"resolved_dwo_path": "/home/toyang/workspace/dwp/a.out.dwp"
  },
  {
"comp_dir": "/home/toyang/workspace/dwp",
"dwo_id": 13601198072221073203,
"dwo_name": "a-foo.dwo",
"loaded": true,
"resolved_dwo_path": "/home/toyang/workspace/dwp/a.out.dwp"
  }
],
"symfile": "/home/toyang/workspace/dwp/a.out"
  }
]
```

Example oso on my Mac (after manipulating the mod times with `touch`):
```
[
  {
"separate-debug-info-files": [
  {
"error": "debug map object file 
\"/Users/toyang/workspace/scratch/main.o\" changed (actual: 0x64e64868, debug 
map: 0x64e4fb23) since this executable was linked, debug info will not be 
loaded",
"loaded": false,
"oso_mod_time": 1692728099,
"oso_path": "/Users/toyang/workspace/scratch/main.o",
"so_file": "/Users/toyang/workspace/scratch/main.cpp"
  },
  {
"error": "debug map object file 
\"/Users/toyang/workspace/scratch/foo.o\" changed (actual: 0x64e64868, debug 
map: 0x64e4fb23) since this executable was linked, debug info will not be 
loaded",
"loaded": false,
"oso_mod_time": 1692728099,
"oso_path": "/Users/toyang/workspace/scratch/foo.o",
"so_file": "/Users/toyang/workspace/scratch/foo.cpp"
  }
],
"symfile": "/Users/toyang/workspace/scratch/a-oso.out"
  }
]
```

Test Plan:

Tested on Mac OS and Linux.
```
lldb-dotest -p TestDumpDwo

lldb-dotest -p TestDumpOso
```

Reviewers:

Subscribers:

Tasks:

Tags:

>From 3a7096f324e3c8b3ab3206f52e92db3728f59d41 Mon Sep 17 00:00:00 2001
From: Tom Yang 
Date: Mon, 11 Sep 2023 17:17:13 -0700
Subject: [PATCH] Add `target modules dump separate-debug-info`

Summary:

Add a new command
```
target modules dump separate-debug-info [ ...]
```
or
```
image dump separate-debug-info [ ...]
```
(since `image` is an alias for `target modules`).

This lists the separate debug info files and their current status (loaded or 
not loaded) for the specified modules. This diff implements this command for 
mach-O files with OSO and ELF files with dwo.

Example dwo:
```
(lldb) image dump separate-debug-info
[
  {
"separate-debug-info-files": [
  {
"comp_dir": ".",
"dwo_id": 7516252579671439727,
"dwo_name": "a-main.dwo",
"loaded": true,
"resolved_dwo_path": "/home/toyang/workspace/dwo-scratch/a-main.dwo"
  },
  {
"comp_dir": ".",
"dwo_id": 13601198072221073203,
"dwo_name": "a-foo.dwo",
"loaded": true,
"resolved_dwo_path": "/home/toyang/workspace/dwo-scratch/a-foo.dwo"
  }
],
"symfile": "/home/toyang/workspace/dwo-scratch/a.out"
  }
]
```

Example dwo with missing dwo:
```
warning: (x86_64) /home/toyang/workspace/dwp/a.out unable to locate separate 
debug file (dwo, dwp). Debugging will be degraded. (troubleshoot with 
https://fburl.com/m

[Lldb-commits] [lldb] Add `target modules dump separate-debug-info` (PR #66035)

2023-09-11 Thread via lldb-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/66035
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `target modules dump separate-debug-info` (PR #66035)

2023-09-11 Thread via lldb-commits

llvmbot wrote:

@llvm/pr-subscribers-lldb


Changes

Summary:

Add a new command
```
target modules dump separate-debug-info [ ...]
```
or
```
image dump separate-debug-info [ ...]
```
(since `image` is an alias for `target modules`).

This lists the separate debug info files and their current status (loaded or 
not loaded) for the specified modules. This diff implements this command for 
mach-O files with OSO and ELF files with dwo.

Example dwo:
```
(lldb) image dump separate-debug-info
[
  {
"separate-debug-info-files": [
  {
"comp_dir": ".",
"dwo_id": 7516252579671439727,
"dwo_name": "a-main.dwo",
"loaded": true,
"resolved_dwo_path": "/home/toyang/workspace/dwo-scratch/a-main.dwo"
  },
  {
"comp_dir": ".",
"dwo_id": 13601198072221073203,
"dwo_name": "a-foo.dwo",
"loaded": true,
"resolved_dwo_path": "/home/toyang/workspace/dwo-scratch/a-foo.dwo"
  }
],
"symfile": "/home/toyang/workspace/dwo-scratch/a.out"
  }
]
```

Example dwo with missing dwo:
```
warning: (x86_64) /home/toyang/workspace/dwp/a.out unable to locate separate 
debug file (dwo, dwp). Debugging will be degraded. (troubleshoot with 
https://fburl.com/missing_dwo)
Current executable set to '/home/toyang/workspace/dwp/a.out' (x86_64).
(lldb) image dump separate-debug-info
[
  {
"separate-debug-info-files": [
  {
"comp_dir": "/home/toyang/workspace/dwp",
"dwo_id": 5620165179865774,
"dwo_name": "a-main.dwo",
"loaded": false
  },
  {
"comp_dir": "/home/toyang/workspace/dwp",
"dwo_id": 13601198072221073203,
"dwo_name": "a-foo.dwo",
"loaded": false
  }
],
"symfile": "/home/toyang/workspace/dwp/a.out"
  }
]
```

Example output with dwp:
```
(lldb) image dump separate-debug-info
[
  {
"separate-debug-info-files": [
  {
"comp_dir": "/home/toyang/workspace/dwp",
"dwo_id": 5620165179865774,
"dwo_name": "a-main.dwo",
"loaded": true,
"resolved_dwo_path": "/home/toyang/workspace/dwp/a.out.dwp"
  },
  {
"comp_dir": "/home/toyang/workspace/dwp",
"dwo_id": 13601198072221073203,
"dwo_name": "a-foo.dwo",
"loaded": true,
"resolved_dwo_path": "/home/toyang/workspace/dwp/a.out.dwp"
  }
],
"symfile": "/home/toyang/workspace/dwp/a.out"
  }
]
```

Example oso on my Mac (after manipulating the mod times with `touch`):
```
[
  {
"separate-debug-info-files": [
  {
"error": "debug map object file 
\"/Users/toyang/workspace/scratch/main.o\" changed (actual: 0x64e64868, debug 
map: 0x64e4fb23) since this executable was linked, debug info will not be 
loaded",
"loaded": false,
"oso_mod_time": 1692728099,
"oso_path": "/Users/toyang/workspace/scratch/main.o",
"so_file": "/Users/toyang/workspace/scratch/main.cpp"
  },
  {
"error": "debug map object file 
\"/Users/toyang/workspace/scratch/foo.o\" changed (actual: 0x64e64868, debug 
map: 0x64e4fb23) since this executable was linked, debug info will not be 
loaded",
"loaded": false,
"oso_mod_time": 1692728099,
"oso_path": "/Users/toyang/workspace/scratch/foo.o",
"so_file": "/Users/toyang/workspace/scratch/foo.cpp"
  }
],
"symfile": "/Users/toyang/workspace/scratch/a-oso.out"
  }
]
```

Test Plan:

Tested on Mac OS and Linux.
```
lldb-dotest -p TestDumpDwo

lldb-dotest -p TestDumpOso
```

Reviewers:

Subscribers:

Tasks:

Tags:
--

Patch is 26.45 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/66035.diff

17 Files Affected:

- (modified) lldb/include/lldb/Symbol/SymbolFile.h (+11) 
- (modified) lldb/source/Commands/CommandObjectTarget.cpp (+129-17) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+58) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (+5) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp 
(+32-1) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h 
(+5) 
- (modified) lldb/source/Symbol/SymbolFile.cpp (+14) 
- (added) lldb/test/API/commands/target/dump-separate-debug-info/dwo/Makefile 
(+4) 
- (added) 
lldb/test/API/commands/target/dump-separate-debug-info/dwo/TestDumpDwo.py (+69) 
- (added) lldb/test/API/commands/target/dump-separate-debug-info/dwo/foo.cpp 
(+3) 
- (added) lldb/test/API/commands/target/dump-separate-debug-info/dwo/foo.h (+6) 
- (added) lldb/test/API/commands/target/dump-separate-debug-info/dwo/main.cpp 
(+3) 
- (added) lldb/test/API/commands/target/dump-separate-debug-info/oso/Makefile 
(+3) 
- (added) 
lldb/test/API/commands/target/dump-separate-debug-info/oso/TestDumpOso.py (+68) 
- (added) lldb/test/API/commands/target/dump-separate-debug-info/oso/foo.cpp 
(+3) 
- (added) lldb/test/API/commands/target/dump-separate-debug-info/oso/foo.h (+6

[Lldb-commits] [lldb] Add `target modules dump separate-debug-info` (PR #66035)

2023-09-11 Thread Tom Yang via lldb-commits

https://github.com/zhyty updated 
https://github.com/llvm/llvm-project/pull/66035:

>From 0f4cf3648bd1a8d6e9114965e6eb6cdbc7ed01dd Mon Sep 17 00:00:00 2001
From: Tom Yang 
Date: Mon, 11 Sep 2023 17:17:13 -0700
Subject: [PATCH] Add `target modules dump separate-debug-info`

Summary:

Add a new command
```
target modules dump separate-debug-info [ ...]
```
or
```
image dump separate-debug-info [ ...]
```
(since `image` is an alias for `target modules`).

This lists the separate debug info files and their current status (loaded or 
not loaded) for the specified modules. This diff implements this command for 
mach-O files with OSO and ELF files with dwo.

Example dwo:
```
(lldb) image dump separate-debug-info
[
  {
"separate-debug-info-files": [
  {
"comp_dir": ".",
"dwo_id": 7516252579671439727,
"dwo_name": "a-main.dwo",
"loaded": true,
"resolved_dwo_path": "/home/toyang/workspace/dwo-scratch/a-main.dwo"
  },
  {
"comp_dir": ".",
"dwo_id": 13601198072221073203,
"dwo_name": "a-foo.dwo",
"loaded": true,
"resolved_dwo_path": "/home/toyang/workspace/dwo-scratch/a-foo.dwo"
  }
],
"symfile": "/home/toyang/workspace/dwo-scratch/a.out"
  }
]
```

Example dwo with missing dwo:
```
warning: (x86_64) /home/toyang/workspace/dwp/a.out unable to locate separate 
debug file (dwo, dwp). Debugging will be degraded. (troubleshoot with 
https://fburl.com/missing_dwo)
Current executable set to '/home/toyang/workspace/dwp/a.out' (x86_64).
(lldb) image dump separate-debug-info
[
  {
"separate-debug-info-files": [
  {
"comp_dir": "/home/toyang/workspace/dwp",
"dwo_id": 5620165179865774,
"dwo_name": "a-main.dwo",
"loaded": false
  },
  {
"comp_dir": "/home/toyang/workspace/dwp",
"dwo_id": 13601198072221073203,
"dwo_name": "a-foo.dwo",
"loaded": false
  }
],
"symfile": "/home/toyang/workspace/dwp/a.out"
  }
]
```

Example output with dwp:
```
(lldb) image dump separate-debug-info
[
  {
"separate-debug-info-files": [
  {
"comp_dir": "/home/toyang/workspace/dwp",
"dwo_id": 5620165179865774,
"dwo_name": "a-main.dwo",
"loaded": true,
"resolved_dwo_path": "/home/toyang/workspace/dwp/a.out.dwp"
  },
  {
"comp_dir": "/home/toyang/workspace/dwp",
"dwo_id": 13601198072221073203,
"dwo_name": "a-foo.dwo",
"loaded": true,
"resolved_dwo_path": "/home/toyang/workspace/dwp/a.out.dwp"
  }
],
"symfile": "/home/toyang/workspace/dwp/a.out"
  }
]
```

Example oso on my Mac (after manipulating the mod times with `touch`):
```
[
  {
"separate-debug-info-files": [
  {
"error": "debug map object file 
\"/Users/toyang/workspace/scratch/main.o\" changed (actual: 0x64e64868, debug 
map: 0x64e4fb23) since this executable was linked, debug info will not be 
loaded",
"loaded": false,
"oso_mod_time": 1692728099,
"oso_path": "/Users/toyang/workspace/scratch/main.o",
"so_file": "/Users/toyang/workspace/scratch/main.cpp"
  },
  {
"error": "debug map object file 
\"/Users/toyang/workspace/scratch/foo.o\" changed (actual: 0x64e64868, debug 
map: 0x64e4fb23) since this executable was linked, debug info will not be 
loaded",
"loaded": false,
"oso_mod_time": 1692728099,
"oso_path": "/Users/toyang/workspace/scratch/foo.o",
"so_file": "/Users/toyang/workspace/scratch/foo.cpp"
  }
],
"symfile": "/Users/toyang/workspace/scratch/a-oso.out"
  }
]
```

Test Plan:

Tested on Mac OS and Linux.
```
lldb-dotest -p TestDumpDwo

lldb-dotest -p TestDumpOso
```

Reviewers:

Subscribers:

Tasks:

Tags:
---
 lldb/include/lldb/Symbol/SymbolFile.h |  11 ++
 lldb/source/Commands/CommandObjectTarget.cpp  | 146 --
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  58 +++
 .../SymbolFile/DWARF/SymbolFileDWARF.h|   5 +
 .../DWARF/SymbolFileDWARFDebugMap.cpp |  33 +++-
 .../DWARF/SymbolFileDWARFDebugMap.h   |   5 +
 lldb/source/Symbol/SymbolFile.cpp |  14 ++
 .../dump-separate-debug-info/dwo/Makefile |   4 +
 .../dwo/TestDumpDwo.py|  68 
 .../dump-separate-debug-info/dwo/foo.cpp  |   3 +
 .../target/dump-separate-debug-info/dwo/foo.h |   6 +
 .../dump-separate-debug-info/dwo/main.cpp |   3 +
 .../dump-separate-debug-info/oso/Makefile |   3 +
 .../oso/TestDumpOso.py|  68 
 .../dump-separate-debug-info/oso/foo.cpp  |   3 +
 .../target/dump-separate-debug-info/oso/foo.h |   6 +
 .../dump-separate-debug-info/oso/main.cpp |   3 +
 17 files changed, 421 insertions(+), 18 deletions(-)
 create mode 100644 
lldb/test/API/commands/target/dump-separate-debug-info/dwo/Makefile
 create mode 100644 
lldb/test/API/commands/target/dump-separate-de

[Lldb-commits] [lldb] Add `target modules dump separate-debug-info` (PR #66035)

2023-09-11 Thread via lldb-commits

jimingham wrote:

I don't think the lldb command line dumps raw JSON anywhere as a command 
result.  Can we make something a little more human readable?

https://github.com/llvm/llvm-project/pull/66035
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `target modules dump separate-debug-info` (PR #66035)

2023-09-11 Thread via lldb-commits

jimingham wrote:

BTW, the idea seems useful to me, but particularly if you're doing OSO you can 
get a whole lot of these so a space efficient presentation where you can scan 
the names easily, etc, will be important as well.

https://github.com/llvm/llvm-project/pull/66035
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `target modules dump separate-debug-info` (PR #66035)

2023-09-11 Thread Greg Clayton via lldb-commits

clayborg wrote:

> I don't think the lldb command line dumps raw JSON anywhere as a command 
> result. Can we make something a little more human readable?

It was my idea to make this JSON. The problem is each debug info (.dwo and 
DWARF in .o files for Mac) has very different fields and pretty printing these 
items free form looked like it should be JSON. For DWO we have the 
DW_AT_dwo_name, DW_AT_comp_dir, and DW_AT_dwo_id to display, and for OSO we 
have .o file path + mod time. I wanted the ability to be able to parse the 
output and use it in a script so the JSON was nice for that end game. It also 
allows us to include this information in "statistics dump". 

> BTW, the idea seems useful to me, but particularly if you're doing OSO you 
> can get a whole lot of these so a space efficient presentation where you can 
> scan the names easily, etc, will be important as well.

Maybe we can add an extra "flavor" to the JSON output, and then have a format 
string for how the output can look akin to the "frame-format" that the command 
would use by default? That would allow us to format the output in a nice human 
readable way for the command output, and also add a --json option to the 
command. The format string could use the "flavor" ("oso" or "dwo") to format 
the output string as needed?

https://github.com/llvm/llvm-project/pull/66035
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `target modules dump separate-debug-info` (PR #66035)

2023-09-11 Thread Greg Clayton via lldb-commits

clayborg wrote:

We also want to show the .dwo error or OSO error strings that explain why the 
file wasn't loaded as we see when we do "frame variable" and the OSO or DWO are 
missing. 

https://github.com/llvm/llvm-project/pull/66035
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D157609: [lldb] Add more ways to find split DWARF files

2023-09-11 Thread David Blaikie via Phabricator via lldb-commits
dblaikie added a comment.

Any chance we could simplify this situation and have dwo searches use exactly 
the same/shared logic as source file searches? It seems like the dwarf spec 
intent was for that to be the case.

I don't mind adding more ways to find things, but think it'd be useful if we 
only had one set of rules instead of two, to prevent divergence.

(The script idea from Greg sounds ok too (but ideally, also in the context of 
one search system for both source and dwo) - but yeah, maybe invasive enough 
that it merits a separate/broader design discussion)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157609/new/

https://reviews.llvm.org/D157609

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits