[Lldb-commits] [lldb] [LLDB] Fix crash when using tab completion on class variables (PR #83234)

2024-02-28 Thread Sudharsan Veeravalli via lldb-commits

https://github.com/svs-quic created 
https://github.com/llvm/llvm-project/pull/83234

We weren't checking to see if the partial_path was empty before adding 
completions and this led to crashes when the class object and a variable both 
start with  the same substring.

Fixes [#81536](https://github.com/llvm/llvm-project/issues/81536)

>From a7d84af1a887169e9c1477628229a8091364eff6 Mon Sep 17 00:00:00 2001
From: Sudharsan Veeravalli 
Date: Wed, 28 Feb 2024 13:46:46 +0530
Subject: [PATCH] [LLDB] Fix crash when using tab completion on class variables

---
 lldb/source/Symbol/Variable.cpp | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp
index 2bb2ff7db4b721..a33c3433d9e245 100644
--- a/lldb/source/Symbol/Variable.cpp
+++ b/lldb/source/Symbol/Variable.cpp
@@ -509,15 +509,17 @@ static void PrivateAutoCompleteMembers(
   CompilerType member_compiler_type = compiler_type.GetFieldAtIndex(
   i, member_name, nullptr, nullptr, nullptr);
 
-  if (partial_member_name.empty() ||
-  llvm::StringRef(member_name).starts_with(partial_member_name)) {
+  if (partial_member_name.empty()) {
+request.AddCompletion((prefix_path + member_name).str());
+  } else if (llvm::StringRef(member_name)
+ .starts_with(partial_member_name)) {
 if (member_name == partial_member_name) {
   PrivateAutoComplete(
   frame, partial_path,
   prefix_path + member_name, // Anything that has been resolved
  // already will be in here
   member_compiler_type.GetCanonicalType(), request);
-} else {
+} else if (partial_path.empty()) {
   request.AddCompletion((prefix_path + member_name).str());
 }
   }

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


[Lldb-commits] [lldb] [LLDB] Fix crash when using tab completion on class variables (PR #83234)

2024-02-28 Thread via lldb-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from 
other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[Lldb-commits] [lldb] [LLDB] Fix crash when using tab completion on class variables (PR #83234)

2024-02-28 Thread Sudharsan Veeravalli via lldb-commits

https://github.com/svs-quic updated 
https://github.com/llvm/llvm-project/pull/83234

>From 87c442c0911fd4671da1ae03c5d967857fd363d1 Mon Sep 17 00:00:00 2001
From: Sudharsan Veeravalli 
Date: Wed, 28 Feb 2024 13:46:46 +0530
Subject: [PATCH] [LLDB] Fix crash when using tab completion on class variables

---
 lldb/source/Symbol/Variable.cpp | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp
index 2bb2ff7db4b721..a33c3433d9e245 100644
--- a/lldb/source/Symbol/Variable.cpp
+++ b/lldb/source/Symbol/Variable.cpp
@@ -509,15 +509,17 @@ static void PrivateAutoCompleteMembers(
   CompilerType member_compiler_type = compiler_type.GetFieldAtIndex(
   i, member_name, nullptr, nullptr, nullptr);
 
-  if (partial_member_name.empty() ||
-  llvm::StringRef(member_name).starts_with(partial_member_name)) {
+  if (partial_member_name.empty()) {
+request.AddCompletion((prefix_path + member_name).str());
+  } else if (llvm::StringRef(member_name)
+ .starts_with(partial_member_name)) {
 if (member_name == partial_member_name) {
   PrivateAutoComplete(
   frame, partial_path,
   prefix_path + member_name, // Anything that has been resolved
  // already will be in here
   member_compiler_type.GetCanonicalType(), request);
-} else {
+} else if (partial_path.empty()) {
   request.AddCompletion((prefix_path + member_name).str());
 }
   }

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


[Lldb-commits] [lldb] [LLDB] Fix completion of space-only lines in the REPL on Linux (PR #83203)

2024-02-28 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Test? I remember a file dedicated to completion tests somewhere.

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


[Lldb-commits] [lldb] [lldb][test] Exclude third_party packages by default (PR #83191)

2024-02-28 Thread David Spickett via lldb-commits

DavidSpickett wrote:

>  This introduces a LLDB_TEST_USE_VENDOR_PACKAGES cmake param that can be 
> enabled, and the tests will continue loading that tree.

I get the intent but doing it this way is actually going to be more of an 
issue. As changes to our bot config have to go through zorg, a master restart, 
then they finally hit the builders, this takes up to a week sometimes. With 
this new option defaulting to OFF that means potentially a week of broken 
builds.

I would suggest making this option default `ON`, and builders can turn it `OFF` 
once they've installed the right packages. Then finally remove the option 
altogether. It'll take a longer time but we won't have a period of broken 
builds during it.

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


[Lldb-commits] [lldb] [lldb][test] Exclude third_party packages by default (PR #83191)

2024-02-28 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Though maybe you intend this to break builds, that way obscure builders that we 
don't know about will still hear about this?

I can understand that angle, in which case do we want to make sure all known 
builders have pexpect installed before this commit goes in? I will sort out 
Linaro's bots this week.

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


[Lldb-commits] [lldb] [lldb][test] Exclude third_party packages by default (PR #83191)

2024-02-28 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Also are there known compatible/incompatible versions of pexpect? Is `pip 
install pexpect` going to install something with significant API differences to 
the vendored copy?

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


[Lldb-commits] [lldb] [LLDB] Fix crash when using tab completion on class variables (PR #83234)

2024-02-28 Thread Sudharsan Veeravalli via lldb-commits

https://github.com/svs-quic updated 
https://github.com/llvm/llvm-project/pull/83234

>From cf1359a825b09d48c312ce40da950c13f30c67c8 Mon Sep 17 00:00:00 2001
From: Sudharsan Veeravalli 
Date: Wed, 28 Feb 2024 13:46:46 +0530
Subject: [PATCH] [LLDB] Fix crash when using tab completion on class variables

---
 lldb/source/Symbol/Variable.cpp | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp
index 2bb2ff7db4b721..a33c3433d9e245 100644
--- a/lldb/source/Symbol/Variable.cpp
+++ b/lldb/source/Symbol/Variable.cpp
@@ -509,15 +509,17 @@ static void PrivateAutoCompleteMembers(
   CompilerType member_compiler_type = compiler_type.GetFieldAtIndex(
   i, member_name, nullptr, nullptr, nullptr);
 
-  if (partial_member_name.empty() ||
-  llvm::StringRef(member_name).starts_with(partial_member_name)) {
+  if (partial_member_name.empty()) {
+request.AddCompletion((prefix_path + member_name).str());
+  } else if (llvm::StringRef(member_name)
+ .starts_with(partial_member_name)) {
 if (member_name == partial_member_name) {
   PrivateAutoComplete(
   frame, partial_path,
   prefix_path + member_name, // Anything that has been resolved
  // already will be in here
   member_compiler_type.GetCanonicalType(), request);
-} else {
+} else if (partial_path.empty()) {
   request.AddCompletion((prefix_path + member_name).str());
 }
   }

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


[Lldb-commits] [lldb] [LLDB] Fix crash when using tab completion on class variables (PR #83234)

2024-02-28 Thread Sudharsan Veeravalli via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Fix crash when using tab completion on class variables (PR #83234)

2024-02-28 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Sudharsan Veeravalli (svs-quic)


Changes

We weren't checking to see if the partial_path was empty before adding 
completions and this led to crashes when the class object and a variable both 
start with  the same substring.

Fixes [#81536](https://github.com/llvm/llvm-project/issues/81536)

---
Full diff: https://github.com/llvm/llvm-project/pull/83234.diff


1 Files Affected:

- (modified) lldb/source/Symbol/Variable.cpp (+5-3) 


``diff
diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp
index 2bb2ff7db4b721..a33c3433d9e245 100644
--- a/lldb/source/Symbol/Variable.cpp
+++ b/lldb/source/Symbol/Variable.cpp
@@ -509,15 +509,17 @@ static void PrivateAutoCompleteMembers(
   CompilerType member_compiler_type = compiler_type.GetFieldAtIndex(
   i, member_name, nullptr, nullptr, nullptr);
 
-  if (partial_member_name.empty() ||
-  llvm::StringRef(member_name).starts_with(partial_member_name)) {
+  if (partial_member_name.empty()) {
+request.AddCompletion((prefix_path + member_name).str());
+  } else if (llvm::StringRef(member_name)
+ .starts_with(partial_member_name)) {
 if (member_name == partial_member_name) {
   PrivateAutoComplete(
   frame, partial_path,
   prefix_path + member_name, // Anything that has been resolved
  // already will be in here
   member_compiler_type.GetCanonicalType(), request);
-} else {
+} else if (partial_path.empty()) {
   request.AddCompletion((prefix_path + member_name).str());
 }
   }

``




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


[Lldb-commits] [lldb] [LLDB] Fix crash when using tab completion on class variables (PR #83234)

2024-02-28 Thread Michael Buch via lldb-commits

Michael137 wrote:

Change itself is fine. But could you please add a test in 
`lldb/test/API/commands/expression/completion/TestExprCompletion.py` or 
`lldb/test/API/functionalities/completion/TestCompletion.py`?

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


[Lldb-commits] [lldb] [lldb][test] Exclude third_party packages by default (PR #83191)

2024-02-28 Thread Jordan Rupprecht via lldb-commits

rupprecht wrote:

> Though maybe you intend this to break builds, that way obscure builders that 
> we don't know about will still hear about this?
> 

Yes, but I agree with your suggestion to land this with a default of `ON`, 
which makes this change NFC. I can then switch it to `OFF` once known buildbots 
are updated. I'll update the PR later today.

> I can understand that angle, in which case do we want to make sure all known 
> public builders have pexpect installed before this commit goes in? I will 
> sort out Linaro's bots this week.

Thanks!

> Also are there known compatible/incompatible versions of pexpect? Is `pip 
> install pexpect` going to install something with significant API differences 
> to the vendored copy?

- Our vendored version is at 4.6, with two local patches for timeouts:
  - a8419b1f2767c7fd5c0d0696b76d17efb2a5b418
  - 97c6ef4ea678ef9a69e1feaf9d77a0880bca09ba
- For my local machine (where tests are passing :) ), `python3-pexpect` is 4.8. 
Looks like that was released in 2020, and probably the version most people have.
- The page https://pypi.org/project/pexpect/ lists trunk as version 4.9.0. We 
have some internal builds using that version which also work.
- https://pexpect.readthedocs.io/en/stable/history.html doesn't seem to list 
anything significant recently

btw, I see many tests w/ comments like this: `@skipIfWindows  # 
llvm.org/pr22274: need a pexpect replacement for windows`. As of pexpect-4.0, 
there is (experimental) windows support. So if you're interested in Windows 
support, it'd be a good idea to see if those tests work now.

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


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-28 Thread Alexandre Ganea via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-28 Thread Alexandre Ganea via lldb-commits


@@ -209,25 +231,66 @@ class ThreadPool {
   /// Number of threads active for tasks in the given group (only non-zero).
   DenseMap ActiveGroups;
 
-#if LLVM_ENABLE_THREADS // avoids warning for unused variable
   /// Signal for the destruction of the pool, asking thread to exit.
   bool EnableFlag = true;
-#endif
 
   const ThreadPoolStrategy Strategy;
 
   /// Maximum number of threads to potentially grow this pool to.
   const unsigned MaxThreadCount;
 };
 
+/// A non-threaded implementation.
+class SingleThreadExecutor : public ThreadPoolInterface {

aganea wrote:

`#if !LLVM_ENABLE_THREADS`. But maybe if you didn't do it, you want this code 
compiled at all times?

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


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-28 Thread Alexandre Ganea via lldb-commits


@@ -140,54 +142,74 @@ class ThreadPool {
 },
 std::move(F)};
   }
+};
+
+/// A ThreadPool implementation using std::threads.
+///
+/// The pool keeps a vector of threads alive, waiting on a condition variable
+/// for some work to become available.
+class StdThreadPool : public ThreadPoolInterface {

aganea wrote:

Same here, `#if LLVM_ENABLE_THREADS` maybe? The definition in the .cpp has the 
define.

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


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-28 Thread Alexandre Ganea via lldb-commits

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

LGTM with two minor comments.

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


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-28 Thread Georgios Pinitas via lldb-commits

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


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


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-28 Thread Georgios Pinitas via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-28 Thread Georgios Pinitas via lldb-commits


@@ -227,7 +265,7 @@ class ThreadPool {
 class ThreadPoolTaskGroup {

GeorgeARM wrote:

Thanks for explaining @joker-eph. Looks good to me.

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


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-28 Thread Georgios Pinitas via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test] Exclude third_party packages by default (PR #83191)

2024-02-28 Thread Jordan Rupprecht via lldb-commits

https://github.com/rupprecht updated 
https://github.com/llvm/llvm-project/pull/83191

>From d21ac756226a364603acd0180f9a06c23600acb1 Mon Sep 17 00:00:00 2001
From: Jordan Rupprecht 
Date: Tue, 27 Feb 2024 13:25:12 -0800
Subject: [PATCH 1/2] [lldb][test] Exclude third_party packages by default

The goal here is to remove the third_party/Python/module tree, which LLDB tests 
only use to `import pexpect`. This package is available on `pip`, and I believe 
should not be hard to obtain.

However, in case it isn't easily available, deleting the tree right now could 
cause disruption. This introduces a `LLDB_TEST_USE_VENDOR_PACKAGES` cmake param 
that can be enabled, and the tests will continue loading that tree. By default, 
it is disabled, and an eager cmake check runs that makes sure `pexpect` is 
available before waiting for the test to fail in an obscure way.

Later, this option will go away, and when it does, we can delete the tree too. 
Ideally this is not disruptive, and we can remove it in a week or two.
---
 lldb/cmake/modules/LLDBConfig.cmake   |  2 ++
 lldb/test/API/lit.cfg.py  |  3 +++
 lldb/test/API/lit.site.cfg.py.in  |  1 +
 lldb/test/CMakeLists.txt  | 17 -
 lldb/use_lldb_suite_root.py   |  4 +++-
 lldb/utils/lldb-dotest/CMakeLists.txt |  1 +
 lldb/utils/lldb-dotest/lldb-dotest.in |  5 +
 7 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index a758261073ac57..5d62213c3f5838 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -67,6 +67,8 @@ option(LLDB_SKIP_STRIP "Whether to skip stripping of binaries 
when installing ll
 option(LLDB_SKIP_DSYM "Whether to skip generating a dSYM when installing 
lldb." OFF)
 option(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS
   "Fail to configure if certain requirements are not met for testing." OFF)
+option(LLDB_TEST_USE_VENDOR_PACKAGES
+  "Use packages from lldb/third_party/Python/module instead of system deps." 
OFF)
 
 set(LLDB_GLOBAL_INIT_DIRECTORY "" CACHE STRING
   "Path to the global lldbinit directory. Relative paths are resolved relative 
to the
diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index 12675edc0fd3b9..f9497b632fc504 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -309,3 +309,6 @@ def delete_module_cache(path):
 # Propagate XDG_CACHE_HOME
 if "XDG_CACHE_HOME" in os.environ:
 config.environment["XDG_CACHE_HOME"] = os.environ["XDG_CACHE_HOME"]
+
+if is_configured("use_vendor_packages"):
+config.environment["LLDB_TEST_USE_VENDOR_PACKAGES"] = "1"
diff --git a/lldb/test/API/lit.site.cfg.py.in b/lldb/test/API/lit.site.cfg.py.in
index 053331dc4881f7..c2602acd2ef85a 100644
--- a/lldb/test/API/lit.site.cfg.py.in
+++ b/lldb/test/API/lit.site.cfg.py.in
@@ -38,6 +38,7 @@ config.libcxx_include_target_dir = 
"@LIBCXX_GENERATED_INCLUDE_TARGET_DIR@"
 # The API tests use their own module caches.
 config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", 
"lldb-api")
 config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", 
"lldb-api")
+config.use_vendor_packages = @LLDB_TEST_USE_VENDOR_PACKAGES@
 
 # Plugins
 lldb_build_intel_pt = '@LLDB_BUILD_INTEL_PT@'
diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 1aa8843b6a2e78..d8cbb24b6c9b81 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -26,6 +26,20 @@ if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
   endforeach()
 endif()
 
+# The "pexpect" package should come from the system environment, not from the
+# LLDB tree. However, we delay the deletion of it from the tree in case
+# users/buildbots don't have the package yet and need some time to install it.
+if (NOT LLDB_TEST_USE_VENDOR_PACKAGES)
+  lldb_find_python_module(pexpect)
+  if (NOT PY_pexpect_FOUND)
+message(FATAL_ERROR
+  "Python module 'pexpect' not found. Please install it via pip or via "
+  "your operating system's package manager. For a temporary workaround, "
+  "use a version from the LLDB tree with "
+  "`LLDB_TEST_USE_VENDOR_PACKAGES=ON`")
+  endif()
+endif()
+
 if(LLDB_BUILT_STANDALONE)
   # In order to run check-lldb-* we need the correct map_config directives in
   # llvm-lit. Because this is a standalone build, LLVM doesn't know about LLDB,
@@ -240,7 +254,8 @@ llvm_canonicalize_cmake_booleans(
   LLDB_HAS_LIBCXX
   LLDB_TOOL_LLDB_SERVER_BUILD
   LLDB_USE_SYSTEM_DEBUGSERVER
-  LLDB_IS_64_BITS)
+  LLDB_IS_64_BITS
+  LLDB_TEST_USE_VENDOR_PACKAGES)
 
 # Configure the individual test suites.
 add_subdirectory(API)
diff --git a/lldb/use_lldb_suite_root.py b/lldb/use_lldb_suite_root.py
index fd42f63a3c7f30..b8f8acf5dd94a4 100644
--- a/lldb/use_lldb_suite_root.py
+++ b/lldb/use_lldb_suite_root.py
@@ -21,5 +21,7 @@ def add_lldbsuite_packages_dir(lldb_root):
 
 lldb_root = os.path.dirname(inspect.getfile(inspect.currentframe()))
 
-add_t

[Lldb-commits] [lldb] [lldb][test][NFC] Add option to exclude third_party packages (PR #83191)

2024-02-28 Thread Jordan Rupprecht via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Fix crash when using tab completion on class variables (PR #83234)

2024-02-28 Thread Sudharsan Veeravalli via lldb-commits

https://github.com/svs-quic updated 
https://github.com/llvm/llvm-project/pull/83234

>From cf1359a825b09d48c312ce40da950c13f30c67c8 Mon Sep 17 00:00:00 2001
From: Sudharsan Veeravalli 
Date: Wed, 28 Feb 2024 13:46:46 +0530
Subject: [PATCH 1/2] [LLDB] Fix crash when using tab completion on class
 variables

---
 lldb/source/Symbol/Variable.cpp | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp
index 2bb2ff7db4b721..a33c3433d9e245 100644
--- a/lldb/source/Symbol/Variable.cpp
+++ b/lldb/source/Symbol/Variable.cpp
@@ -509,15 +509,17 @@ static void PrivateAutoCompleteMembers(
   CompilerType member_compiler_type = compiler_type.GetFieldAtIndex(
   i, member_name, nullptr, nullptr, nullptr);
 
-  if (partial_member_name.empty() ||
-  llvm::StringRef(member_name).starts_with(partial_member_name)) {
+  if (partial_member_name.empty()) {
+request.AddCompletion((prefix_path + member_name).str());
+  } else if (llvm::StringRef(member_name)
+ .starts_with(partial_member_name)) {
 if (member_name == partial_member_name) {
   PrivateAutoComplete(
   frame, partial_path,
   prefix_path + member_name, // Anything that has been resolved
  // already will be in here
   member_compiler_type.GetCanonicalType(), request);
-} else {
+} else if (partial_path.empty()) {
   request.AddCompletion((prefix_path + member_name).str());
 }
   }

>From dab0c4b75bd07cc5fbad313311b6a747f985712d Mon Sep 17 00:00:00 2001
From: Sudharsan Veeravalli 
Date: Wed, 28 Feb 2024 21:04:28 +0530
Subject: [PATCH 2/2] Add test

---
 .../API/functionalities/completion/TestCompletion.py | 6 --
 lldb/test/API/functionalities/completion/main.cpp| 9 +
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py 
b/lldb/test/API/functionalities/completion/TestCompletion.py
index f71bc73928f0f4..2f6af3cfce109d 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -60,10 +60,12 @@ def test_dwim_print(self):
 
 def do_test_variable_completion(self, command):
 self.complete_from_to(f"{command} fo", f"{command} fooo")
-self.complete_from_to(f"{command} fooo.", f"{command} fooo.")
+self.complete_from_to(f"{command} fooo.", f"{command} fooo.t")
+self.complete_from_to(f"{command} fooo.t.", f"{command} fooo.t.x")
 self.complete_from_to(f"{command} fooo.dd", f"{command} fooo.dd")
 
-self.complete_from_to(f"{command} ptr_fooo->", f"{command} ptr_fooo->")
+self.complete_from_to(f"{command} ptr_fooo->", f"{command} 
ptr_fooo->t")
+self.complete_from_to(f"{command} ptr_fooo->t", f"{command} 
ptr_fooo->t.x")
 self.complete_from_to(f"{command} ptr_fooo->dd", f"{command} 
ptr_fooo->dd")
 
 self.complete_from_to(f"{command} cont", f"{command} container")
diff --git a/lldb/test/API/functionalities/completion/main.cpp 
b/lldb/test/API/functionalities/completion/main.cpp
index 06ff5773e8a9dc..104dcc88e8c118 100644
--- a/lldb/test/API/functionalities/completion/main.cpp
+++ b/lldb/test/API/functionalities/completion/main.cpp
@@ -1,8 +1,17 @@
 #include 
 
+class Baz
+{
+public:
+int x;
+};
+
 class Foo
 {
 public:
+Baz t;
+int temp;
+
 int Bar(int x, int y)
 {
 return x + y;

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


[Lldb-commits] [lldb] [LLDB] Fix crash when using tab completion on class variables (PR #83234)

2024-02-28 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 9f99eda1208787364b1a381b2d4e146fc4868cd5 
dab0c4b75bd07cc5fbad313311b6a747f985712d -- lldb/source/Symbol/Variable.cpp 
lldb/test/API/functionalities/completion/main.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/test/API/functionalities/completion/main.cpp 
b/lldb/test/API/functionalities/completion/main.cpp
index 104dcc88e8..f925c1d5ac 100644
--- a/lldb/test/API/functionalities/completion/main.cpp
+++ b/lldb/test/API/functionalities/completion/main.cpp
@@ -1,21 +1,17 @@
 #include 
 
-class Baz
-{
+class Baz {
 public:
-int x;
+  int x;
 };
 
 class Foo
 {
 public:
-Baz t;
-int temp;
+  Baz t;
+  int temp;
 
-int Bar(int x, int y)
-{
-return x + y;
-}
+  int Bar(int x, int y) { return x + y; }
 };
 
 namespace { int Quux (void) { return 0; } }

``




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


[Lldb-commits] [lldb] [LLDB] Fix crash when using tab completion on class variables (PR #83234)

2024-02-28 Thread Sudharsan Veeravalli via lldb-commits

https://github.com/svs-quic updated 
https://github.com/llvm/llvm-project/pull/83234

>From cf1359a825b09d48c312ce40da950c13f30c67c8 Mon Sep 17 00:00:00 2001
From: Sudharsan Veeravalli 
Date: Wed, 28 Feb 2024 13:46:46 +0530
Subject: [PATCH 1/3] [LLDB] Fix crash when using tab completion on class
 variables

---
 lldb/source/Symbol/Variable.cpp | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp
index 2bb2ff7db4b721..a33c3433d9e245 100644
--- a/lldb/source/Symbol/Variable.cpp
+++ b/lldb/source/Symbol/Variable.cpp
@@ -509,15 +509,17 @@ static void PrivateAutoCompleteMembers(
   CompilerType member_compiler_type = compiler_type.GetFieldAtIndex(
   i, member_name, nullptr, nullptr, nullptr);
 
-  if (partial_member_name.empty() ||
-  llvm::StringRef(member_name).starts_with(partial_member_name)) {
+  if (partial_member_name.empty()) {
+request.AddCompletion((prefix_path + member_name).str());
+  } else if (llvm::StringRef(member_name)
+ .starts_with(partial_member_name)) {
 if (member_name == partial_member_name) {
   PrivateAutoComplete(
   frame, partial_path,
   prefix_path + member_name, // Anything that has been resolved
  // already will be in here
   member_compiler_type.GetCanonicalType(), request);
-} else {
+} else if (partial_path.empty()) {
   request.AddCompletion((prefix_path + member_name).str());
 }
   }

>From dab0c4b75bd07cc5fbad313311b6a747f985712d Mon Sep 17 00:00:00 2001
From: Sudharsan Veeravalli 
Date: Wed, 28 Feb 2024 21:04:28 +0530
Subject: [PATCH 2/3] Add test

---
 .../API/functionalities/completion/TestCompletion.py | 6 --
 lldb/test/API/functionalities/completion/main.cpp| 9 +
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py 
b/lldb/test/API/functionalities/completion/TestCompletion.py
index f71bc73928f0f4..2f6af3cfce109d 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -60,10 +60,12 @@ def test_dwim_print(self):
 
 def do_test_variable_completion(self, command):
 self.complete_from_to(f"{command} fo", f"{command} fooo")
-self.complete_from_to(f"{command} fooo.", f"{command} fooo.")
+self.complete_from_to(f"{command} fooo.", f"{command} fooo.t")
+self.complete_from_to(f"{command} fooo.t.", f"{command} fooo.t.x")
 self.complete_from_to(f"{command} fooo.dd", f"{command} fooo.dd")
 
-self.complete_from_to(f"{command} ptr_fooo->", f"{command} ptr_fooo->")
+self.complete_from_to(f"{command} ptr_fooo->", f"{command} 
ptr_fooo->t")
+self.complete_from_to(f"{command} ptr_fooo->t", f"{command} 
ptr_fooo->t.x")
 self.complete_from_to(f"{command} ptr_fooo->dd", f"{command} 
ptr_fooo->dd")
 
 self.complete_from_to(f"{command} cont", f"{command} container")
diff --git a/lldb/test/API/functionalities/completion/main.cpp 
b/lldb/test/API/functionalities/completion/main.cpp
index 06ff5773e8a9dc..104dcc88e8c118 100644
--- a/lldb/test/API/functionalities/completion/main.cpp
+++ b/lldb/test/API/functionalities/completion/main.cpp
@@ -1,8 +1,17 @@
 #include 
 
+class Baz
+{
+public:
+int x;
+};
+
 class Foo
 {
 public:
+Baz t;
+int temp;
+
 int Bar(int x, int y)
 {
 return x + y;

>From 12b43652a14b0e1d31465859d58aedcd2d63dace Mon Sep 17 00:00:00 2001
From: Sudharsan Veeravalli 
Date: Wed, 28 Feb 2024 21:14:35 +0530
Subject: [PATCH 3/3] Clang-format changes

---
 lldb/test/API/functionalities/completion/main.cpp | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/lldb/test/API/functionalities/completion/main.cpp 
b/lldb/test/API/functionalities/completion/main.cpp
index 104dcc88e8c118..f925c1d5acf31c 100644
--- a/lldb/test/API/functionalities/completion/main.cpp
+++ b/lldb/test/API/functionalities/completion/main.cpp
@@ -1,21 +1,17 @@
 #include 
 
-class Baz
-{
+class Baz {
 public:
-int x;
+  int x;
 };
 
 class Foo
 {
 public:
-Baz t;
-int temp;
+  Baz t;
+  int temp;
 
-int Bar(int x, int y)
-{
-return x + y;
-}
+  int Bar(int x, int y) { return x + y; }
 };
 
 namespace { int Quux (void) { return 0; } }

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


[Lldb-commits] [lldb] [LLDB] Fix completion of space-only lines in the REPL on Linux (PR #83203)

2024-02-28 Thread Walter Erquinigo via lldb-commits

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

>From 3410fc7e0e9d73763e3edee6e008012ba571ad80 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Tue, 27 Feb 2024 17:59:20 -0500
Subject: [PATCH] [LLDB] Fix completion of space-only lines in the REPL on
 Linux

https://github.com/modularml/mojo/issues/1796 discovered that if you try to 
complete a space-only line in the REPL on Linux, LLDB crashes. I suspect that 
editline doesn't behave the same way on linux and on darwin, because I can't 
replicate this on darwin.

Adding a boundary check in the completion code prevents the crash from 
happening.
---
 lldb/source/Host/common/Editline.cpp  |  5 +++-
 lldb/test/API/repl/clang/TestClangREPL.py | 32 ---
 2 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/lldb/source/Host/common/Editline.cpp 
b/lldb/source/Host/common/Editline.cpp
index ce707e530d008b..e66271e8a6ee99 100644
--- a/lldb/source/Host/common/Editline.cpp
+++ b/lldb/source/Host/common/Editline.cpp
@@ -1029,8 +1029,11 @@ unsigned char Editline::TabCommand(int ch) {
 case CompletionMode::Normal: {
   std::string to_add = completion.GetCompletion();
   // Terminate the current argument with a quote if it started with a 
quote.
-  if (!request.GetParsedLine().empty() && 
request.GetParsedArg().IsQuoted())
+  Args &parsedLine = request.GetParsedLine();
+  if (!parsedLine.empty() && request.GetCursorIndex() < parsedLine.size() 
&&
+  request.GetParsedArg().IsQuoted()) {
 to_add.push_back(request.GetParsedArg().GetQuoteChar());
+  }
   to_add.push_back(' ');
   el_deletestr(m_editline, request.GetCursorArgumentPrefix().size());
   el_insertstr(m_editline, to_add.c_str());
diff --git a/lldb/test/API/repl/clang/TestClangREPL.py 
b/lldb/test/API/repl/clang/TestClangREPL.py
index 0b67955a7833c6..c37557fb94735d 100644
--- a/lldb/test/API/repl/clang/TestClangREPL.py
+++ b/lldb/test/API/repl/clang/TestClangREPL.py
@@ -1,7 +1,6 @@
-import lldb
 from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
 from lldbsuite.test.lldbpexpect import PExpectTest
+from lldbsuite.test.lldbtest import *
 
 
 class TestCase(PExpectTest):
@@ -17,13 +16,7 @@ def expect_repl(self, expr, substrs=[]):
 self.current_repl_line_number += 1
 self.child.expect_exact(str(self.current_repl_line_number) + ">")
 
-# PExpect uses many timeouts internally and doesn't play well
-# under ASAN on a loaded machine..
-@skipIfAsan
-@skipIf(oslist=["linux"], archs=["arm", "aarch64"])  # Randomly fails on 
buildbot
-@skipIfEditlineSupportMissing
-def test_basic_completion(self):
-"""Test that we can complete a simple multiline expression"""
+def start_repl(self):
 self.build()
 self.current_repl_line_number = 1
 
@@ -41,6 +34,14 @@ def test_basic_completion(self):
 self.child.send("expression --repl -l c --\n")
 self.child.expect_exact("1>")
 
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+@skipIf(oslist=["linux"], archs=["arm", "aarch64"])  # Randomly fails on 
buildbot
+@skipIfEditlineSupportMissing
+def test_basic_completion(self):
+"""Test that we can complete a simple multiline expression"""
+self.start_repl()
 # Try evaluating a simple expression.
 self.expect_repl("3 + 3", substrs=["(int) $0 = 6"])
 
@@ -54,3 +55,16 @@ def test_basic_completion(self):
 self.expect_repl("$persistent + 10", substrs=["(long) $2 = 17"])
 
 self.quit()
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+@skipIf(oslist=["linux"], archs=["arm", "aarch64"])  # Randomly fails on 
buildbot
+@skipIfEditlineSupportMissing
+def test_completion_with_space_only_line(self):
+"""Test that we don't crash when completing lines with spaces only"""
+self.start_repl()
+
+self.child.send("   ")
+self.child.send("\t")
+self.expect_repl("3 + 3", substrs=["(int) $0 = 6"])

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


[Lldb-commits] [lldb] [lldb][test][NFC] Add option to exclude third_party packages (PR #83191)

2024-02-28 Thread David Spickett via lldb-commits

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

You need to update the PR description but otherwise LGTM.

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


[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)

2024-02-28 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/83069

>From 63dded34a47dd161fa918e45aaeecf966ba08476 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Tue, 20 Feb 2024 13:56:53 -0800
Subject: [PATCH] [lldb][progress] Hook up new broadcast bit and progress
 manager

This commit adds the functionality to broadcast events using the
`Debugger::eBroadcastProgressCategory`
bit (https://github.com/llvm/llvm-project/pull/81169) by keeping track of these
reports with the `ProgressManager`
class (https://github.com/llvm/llvm-project/pull/81319). The new bit is
used in such a way that it will only broadcast the initial and final
progress reports for specific progress categories that are managed by
the progress manager.

This commit also adds a new test to the progress report unit test that
checks that only the initial/final reports are broadcasted when using
the new bit.
---
 lldb/include/lldb/Core/Debugger.h  | 10 +--
 lldb/include/lldb/Core/Progress.h  | 48 +-
 lldb/source/Core/Debugger.cpp  | 19 +++---
 lldb/source/Core/Progress.cpp  | 73 +++---
 lldb/unittests/Core/ProgressReportTest.cpp | 57 +
 5 files changed, 157 insertions(+), 50 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ba90eb6ed8fdf..b65ec1029ab24b 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -593,6 +593,7 @@ class Debugger : public 
std::enable_shared_from_this,
   friend class CommandInterpreter;
   friend class REPL;
   friend class Progress;
+  friend class ProgressManager;
 
   /// Report progress events.
   ///
@@ -623,10 +624,11 @@ class Debugger : public 
std::enable_shared_from_this,
   ///   debugger identifier that this progress should be delivered to. If this
   ///   optional parameter does not have a value, the progress will be
   ///   delivered to all debuggers.
-  static void ReportProgress(uint64_t progress_id, std::string title,
- std::string details, uint64_t completed,
- uint64_t total,
- std::optional debugger_id);
+  static void
+  ReportProgress(uint64_t progress_id, std::string title, std::string details,
+ uint64_t completed, uint64_t total,
+ std::optional debugger_id,
+ uint32_t progress_category_bit = eBroadcastBitProgress);
 
   static void ReportDiagnosticImpl(DiagnosticEventData::Type type,
std::string message,
diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index eb4d9f9d7af08e..1dad11a73429ba 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -9,10 +9,11 @@
 #ifndef LLDB_CORE_PROGRESS_H
 #define LLDB_CORE_PROGRESS_H
 
-#include "lldb/Utility/ConstString.h"
+#include "lldb/lldb-forward.h"
 #include "lldb/lldb-types.h"
 #include "llvm/ADT/StringMap.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -97,27 +98,37 @@ class Progress {
   /// Used to indicate a non-deterministic progress report
   static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX;
 
+  /// Use a struct to send data from a Progress object to
+  /// the progress manager.
+  struct ProgressData {
+/// The title of the progress activity, also used as a category to group
+/// reports.
+std::string title;
+/// More specific information about the current file being displayed in the
+/// report.
+std::string details;
+/// A unique integer identifier for progress reporting.
+uint64_t progress_id;
+/// How much work ([0...m_total]) that has been completed.
+uint64_t completed;
+/// Total amount of work, use a std::nullopt in the constructor for non
+/// deterministic progress.
+uint64_t total;
+/// The optional debugger ID to report progress to. If this has no value
+/// then all debuggers will receive this event.
+std::optional debugger_id;
+  };
+
 private:
   void ReportProgress();
   static std::atomic g_id;
-  /// The title of the progress activity.
-  std::string m_title;
-  std::string m_details;
   std::mutex m_mutex;
-  /// A unique integer identifier for progress reporting.
-  const uint64_t m_id;
-  /// How much work ([0...m_total]) that has been completed.
-  uint64_t m_completed;
-  /// Total amount of work, use a std::nullopt in the constructor for non
-  /// deterministic progress.
-  uint64_t m_total;
-  /// The optional debugger ID to report progress to. If this has no value then
-  /// all debuggers will receive this event.
-  std::optional m_debugger_id;
   /// Set to true when progress has been reported where m_completed == m_total
   /// to ensure that we don't send progress updates after progress has
   /// completed.
   bool m_complete = false;
+  /// Data needed by the debugger to broadcast a progress ev

[Lldb-commits] [lldb] [LLDB] Fix completion of space-only lines in the REPL on Linux (PR #83203)

2024-02-28 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

@DavidSpickett I was able to write a test for this. PTAL :)

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


[Lldb-commits] [lldb] [LLDB] Fix completion of space-only lines in the REPL on Linux (PR #83203)

2024-02-28 Thread David Spickett via lldb-commits


@@ -54,3 +55,16 @@ def test_basic_completion(self):
 self.expect_repl("$persistent + 10", substrs=["(long) $2 = 17"])
 
 self.quit()
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+@skipIf(oslist=["linux"], archs=["arm", "aarch64"])  # Randomly fails on 
buildbot

DavidSpickett wrote:

Is there some paper trail here, was this related to the expression or to 
buildbot setup? If it's not for sure because of the expression then leave the 
skip as is, It's probably a machine load problem like the comment for ASAN says.

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


[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)

2024-02-28 Thread Will Hawkins via lldb-commits


@@ -407,6 +407,117 @@ class LLDB_API SBProcess {
   /// the process isn't loaded from a core file.
   lldb::SBFileSpec GetCoreFile();
 
+  /// \{
+  /// \group Mask Address Methods
+  ///
+  /// \a type
+  /// All of the methods in this group take \a type argument
+  /// which is an AddressMaskType enum value.
+  /// There can be different address masks for code addresses and
+  /// data addresses, this argument can select which to get/set,
+  /// or to use when clearing non-addressable bits from an address.
+  /// On AArch32 code with arm+thumb code, where instructions start
+  /// on even addresses, the 0th bit may be used to indicate that
+  /// a function is thumb code.  On such a target, the eAddressMaskTypeCode
+  /// may clear the 0th bit from an address to get the actual address.
+  ///
+  /// \a addr_range
+  /// Many of the methods in this group take an \a addr_range argument
+  /// which is an AddressMaskRange enum value.
+  /// Needing to specify the address range is highly unusual, and the
+  /// default argument can be used in nearly all circumstances.
+  /// On some architectures like AArch64, it is possible to have
+  /// different page table setups for low and high memory, so different
+  /// numbers of bits relevant to addressing. It is possible to have
+  /// a program running in one half of memory and accessing the other
+  /// as heap, so we need to maintain two different sets of address masks
+  /// to debug this correctly.
+
+  /// Get the current address mask that will be applied to addresses
+  /// before reading from memory.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// eAddressMaskTypeAny is often a suitable value when code and
+  /// data masks are the same on a given target.
+  ///
+  /// \param[in] addr_range
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// This will default to eAddressMaskRangeLow which is the
+  /// only set of masks used normally.
+  ///
+  /// \return
+  /// The address mask currently in use.  Bits which are not used
+  /// for addressing will be set to 1 in the mask.
+  lldb::addr_t GetAddressMask(
+  lldb::AddressMaskType type,
+  lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow);
+
+  /// Set the current address mask that can be applied to addresses
+  /// before reading from memory.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// eAddressMaskTypeAll is often a suitable value when the
+  /// same mask is being set for both code and data.
+  ///
+  /// \param[in] mask
+  /// The address mask to set.  Bits which are not used for addressing
+  /// should be set to 1 in the mask.
+  ///
+  /// \param[in] addr_range
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// This will default to eAddressMaskRangeLow which is the
+  /// only set of masks used normally.
+  void SetAddressMask(
+  lldb::AddressMaskType type, lldb::addr_t mask,
+  lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow);
+
+  /// Set the number of bits used for addressing in this Process.
+  ///
+  /// In some environments, the number of bits that are used for addressing
+  /// is the natural representation instead of a mask, but lldb
+  /// internally represents this as a mask.  This method calculates
+  /// the addressing mask that lldb uses that number of addressable bits.

hawkinsw wrote:

I am not 100% sure what you are attempting to convey here (and it may be 
perfectly correct), but I am having a hard time parsing this sentence.

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


[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)

2024-02-28 Thread Will Hawkins via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)

2024-02-28 Thread Will Hawkins via lldb-commits

https://github.com/hawkinsw commented:

As I said before, I really appreciate you doing such in-depth documentation. I 
hope these little suggestions help!

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


[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)

2024-02-28 Thread Will Hawkins via lldb-commits


@@ -407,6 +407,117 @@ class LLDB_API SBProcess {
   /// the process isn't loaded from a core file.
   lldb::SBFileSpec GetCoreFile();
 
+  /// \{
+  /// \group Mask Address Methods
+  ///
+  /// \a type
+  /// All of the methods in this group take \a type argument
+  /// which is an AddressMaskType enum value.
+  /// There can be different address masks for code addresses and
+  /// data addresses, this argument can select which to get/set,
+  /// or to use when clearing non-addressable bits from an address.
+  /// On AArch32 code with arm+thumb code, where instructions start
+  /// on even addresses, the 0th bit may be used to indicate that
+  /// a function is thumb code.  On such a target, the eAddressMaskTypeCode
+  /// may clear the 0th bit from an address to get the actual address.
+  ///
+  /// \a addr_range
+  /// Many of the methods in this group take an \a addr_range argument
+  /// which is an AddressMaskRange enum value.
+  /// Needing to specify the address range is highly unusual, and the
+  /// default argument can be used in nearly all circumstances.
+  /// On some architectures like AArch64, it is possible to have
+  /// different page table setups for low and high memory, so different
+  /// numbers of bits relevant to addressing. It is possible to have
+  /// a program running in one half of memory and accessing the other
+  /// as heap, so we need to maintain two different sets of address masks
+  /// to debug this correctly.
+
+  /// Get the current address mask that will be applied to addresses
+  /// before reading from memory.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.

hawkinsw wrote:

```suggestion
  /// See \ref Mask Address Methods description of this argument.
```

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


[Lldb-commits] [lldb] [LLDB] Fix completion of space-only lines in the REPL on Linux (PR #83203)

2024-02-28 Thread David Spickett via lldb-commits

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

I'd like to know if there's a good reason for the skip beyond machine load, but 
this is fine as is. LGTM.

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


[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)

2024-02-28 Thread Will Hawkins via lldb-commits


@@ -407,6 +407,117 @@ class LLDB_API SBProcess {
   /// the process isn't loaded from a core file.
   lldb::SBFileSpec GetCoreFile();
 
+  /// \{
+  /// \group Mask Address Methods
+  ///
+  /// \a type
+  /// All of the methods in this group take \a type argument
+  /// which is an AddressMaskType enum value.
+  /// There can be different address masks for code addresses and
+  /// data addresses, this argument can select which to get/set,
+  /// or to use when clearing non-addressable bits from an address.
+  /// On AArch32 code with arm+thumb code, where instructions start
+  /// on even addresses, the 0th bit may be used to indicate that
+  /// a function is thumb code.  On such a target, the eAddressMaskTypeCode
+  /// may clear the 0th bit from an address to get the actual address.
+  ///
+  /// \a addr_range
+  /// Many of the methods in this group take an \a addr_range argument
+  /// which is an AddressMaskRange enum value.
+  /// Needing to specify the address range is highly unusual, and the
+  /// default argument can be used in nearly all circumstances.
+  /// On some architectures like AArch64, it is possible to have

hawkinsw wrote:

```suggestion
  /// On some architectures (e.g., AArch64), it is possible to have
```

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


[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)

2024-02-28 Thread Will Hawkins via lldb-commits


@@ -407,6 +407,117 @@ class LLDB_API SBProcess {
   /// the process isn't loaded from a core file.
   lldb::SBFileSpec GetCoreFile();
 
+  /// \{
+  /// \group Mask Address Methods
+  ///
+  /// \a type
+  /// All of the methods in this group take \a type argument
+  /// which is an AddressMaskType enum value.
+  /// There can be different address masks for code addresses and
+  /// data addresses, this argument can select which to get/set,
+  /// or to use when clearing non-addressable bits from an address.
+  /// On AArch32 code with arm+thumb code, where instructions start
+  /// on even addresses, the 0th bit may be used to indicate that
+  /// a function is thumb code.  On such a target, the eAddressMaskTypeCode
+  /// may clear the 0th bit from an address to get the actual address.
+  ///
+  /// \a addr_range
+  /// Many of the methods in this group take an \a addr_range argument
+  /// which is an AddressMaskRange enum value.
+  /// Needing to specify the address range is highly unusual, and the
+  /// default argument can be used in nearly all circumstances.
+  /// On some architectures like AArch64, it is possible to have
+  /// different page table setups for low and high memory, so different
+  /// numbers of bits relevant to addressing. It is possible to have
+  /// a program running in one half of memory and accessing the other
+  /// as heap, so we need to maintain two different sets of address masks
+  /// to debug this correctly.
+
+  /// Get the current address mask that will be applied to addresses
+  /// before reading from memory.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// eAddressMaskTypeAny is often a suitable value when code and
+  /// data masks are the same on a given target.
+  ///
+  /// \param[in] addr_range
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// This will default to eAddressMaskRangeLow which is the
+  /// only set of masks used normally.
+  ///
+  /// \return
+  /// The address mask currently in use.  Bits which are not used
+  /// for addressing will be set to 1 in the mask.
+  lldb::addr_t GetAddressMask(
+  lldb::AddressMaskType type,
+  lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow);
+
+  /// Set the current address mask that can be applied to addresses
+  /// before reading from memory.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.

hawkinsw wrote:

```suggestion
  /// See \ref Mask Address Methods description of this argument.
```

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


[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)

2024-02-28 Thread Will Hawkins via lldb-commits


@@ -407,6 +407,117 @@ class LLDB_API SBProcess {
   /// the process isn't loaded from a core file.
   lldb::SBFileSpec GetCoreFile();
 
+  /// \{
+  /// \group Mask Address Methods
+  ///
+  /// \a type
+  /// All of the methods in this group take \a type argument
+  /// which is an AddressMaskType enum value.

hawkinsw wrote:

Can our Doxygen system make a reference to the documentation for these named 
constants? Just a question. 

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


[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)

2024-02-28 Thread Will Hawkins via lldb-commits


@@ -407,6 +407,117 @@ class LLDB_API SBProcess {
   /// the process isn't loaded from a core file.
   lldb::SBFileSpec GetCoreFile();
 
+  /// \{
+  /// \group Mask Address Methods
+  ///
+  /// \a type
+  /// All of the methods in this group take \a type argument
+  /// which is an AddressMaskType enum value.
+  /// There can be different address masks for code addresses and
+  /// data addresses, this argument can select which to get/set,
+  /// or to use when clearing non-addressable bits from an address.
+  /// On AArch32 code with arm+thumb code, where instructions start
+  /// on even addresses, the 0th bit may be used to indicate that
+  /// a function is thumb code.  On such a target, the eAddressMaskTypeCode
+  /// may clear the 0th bit from an address to get the actual address.
+  ///
+  /// \a addr_range
+  /// Many of the methods in this group take an \a addr_range argument
+  /// which is an AddressMaskRange enum value.
+  /// Needing to specify the address range is highly unusual, and the
+  /// default argument can be used in nearly all circumstances.
+  /// On some architectures like AArch64, it is possible to have
+  /// different page table setups for low and high memory, so different
+  /// numbers of bits relevant to addressing. It is possible to have
+  /// a program running in one half of memory and accessing the other
+  /// as heap, so we need to maintain two different sets of address masks
+  /// to debug this correctly.
+
+  /// Get the current address mask that will be applied to addresses
+  /// before reading from memory.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// eAddressMaskTypeAny is often a suitable value when code and
+  /// data masks are the same on a given target.
+  ///
+  /// \param[in] addr_range
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// This will default to eAddressMaskRangeLow which is the
+  /// only set of masks used normally.
+  ///
+  /// \return
+  /// The address mask currently in use.  Bits which are not used
+  /// for addressing will be set to 1 in the mask.
+  lldb::addr_t GetAddressMask(
+  lldb::AddressMaskType type,
+  lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow);
+
+  /// Set the current address mask that can be applied to addresses
+  /// before reading from memory.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// eAddressMaskTypeAll is often a suitable value when the
+  /// same mask is being set for both code and data.
+  ///
+  /// \param[in] mask
+  /// The address mask to set.  Bits which are not used for addressing
+  /// should be set to 1 in the mask.
+  ///
+  /// \param[in] addr_range
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// This will default to eAddressMaskRangeLow which is the
+  /// only set of masks used normally.
+  void SetAddressMask(
+  lldb::AddressMaskType type, lldb::addr_t mask,
+  lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow);
+
+  /// Set the number of bits used for addressing in this Process.
+  ///
+  /// In some environments, the number of bits that are used for addressing
+  /// is the natural representation instead of a mask, but lldb
+  /// internally represents this as a mask.  This method calculates
+  /// the addressing mask that lldb uses that number of addressable bits.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// eAddressMaskTypeAll is often a suitable value when the
+  /// same mask is being set for both code and data.
+  ///
+  /// \param[in] num_bits
+  /// Number of bits that are used for addressing.
+  /// A value of 42 indicates that the low 42 bits are relevant for

hawkinsw wrote:

```suggestion
  /// For example, a value of 42 indicates that the low 42 bits are 
relevant for
```

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


[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)

2024-02-28 Thread Will Hawkins via lldb-commits


@@ -407,6 +407,117 @@ class LLDB_API SBProcess {
   /// the process isn't loaded from a core file.
   lldb::SBFileSpec GetCoreFile();
 
+  /// \{
+  /// \group Mask Address Methods
+  ///
+  /// \a type
+  /// All of the methods in this group take \a type argument
+  /// which is an AddressMaskType enum value.
+  /// There can be different address masks for code addresses and
+  /// data addresses, this argument can select which to get/set,
+  /// or to use when clearing non-addressable bits from an address.
+  /// On AArch32 code with arm+thumb code, where instructions start
+  /// on even addresses, the 0th bit may be used to indicate that
+  /// a function is thumb code.  On such a target, the eAddressMaskTypeCode
+  /// may clear the 0th bit from an address to get the actual address.
+  ///
+  /// \a addr_range
+  /// Many of the methods in this group take an \a addr_range argument
+  /// which is an AddressMaskRange enum value.
+  /// Needing to specify the address range is highly unusual, and the
+  /// default argument can be used in nearly all circumstances.
+  /// On some architectures like AArch64, it is possible to have
+  /// different page table setups for low and high memory, so different
+  /// numbers of bits relevant to addressing. It is possible to have
+  /// a program running in one half of memory and accessing the other
+  /// as heap, so we need to maintain two different sets of address masks
+  /// to debug this correctly.
+
+  /// Get the current address mask that will be applied to addresses
+  /// before reading from memory.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// eAddressMaskTypeAny is often a suitable value when code and
+  /// data masks are the same on a given target.
+  ///
+  /// \param[in] addr_range
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// This will default to eAddressMaskRangeLow which is the
+  /// only set of masks used normally.
+  ///
+  /// \return
+  /// The address mask currently in use.  Bits which are not used
+  /// for addressing will be set to 1 in the mask.
+  lldb::addr_t GetAddressMask(
+  lldb::AddressMaskType type,
+  lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow);
+
+  /// Set the current address mask that can be applied to addresses
+  /// before reading from memory.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// eAddressMaskTypeAll is often a suitable value when the
+  /// same mask is being set for both code and data.
+  ///
+  /// \param[in] mask
+  /// The address mask to set.  Bits which are not used for addressing
+  /// should be set to 1 in the mask.
+  ///
+  /// \param[in] addr_range
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// This will default to eAddressMaskRangeLow which is the
+  /// only set of masks used normally.
+  void SetAddressMask(
+  lldb::AddressMaskType type, lldb::addr_t mask,
+  lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow);
+
+  /// Set the number of bits used for addressing in this Process.
+  ///
+  /// In some environments, the number of bits that are used for addressing
+  /// is the natural representation instead of a mask, but lldb
+  /// internally represents this as a mask.  This method calculates
+  /// the addressing mask that lldb uses that number of addressable bits.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// eAddressMaskTypeAll is often a suitable value when the
+  /// same mask is being set for both code and data.
+  ///
+  /// \param[in] num_bits
+  /// Number of bits that are used for addressing.
+  /// A value of 42 indicates that the low 42 bits are relevant for
+  /// addressing, and that higher order bits may be used for various
+  /// metadata like pointer authentication, Type Byte Ignore, etc.
+  ///
+  /// \param[in] addr_range
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// This will default to eAddressMaskRangeLow which is the
+  /// only set of masks used normally.
+  void
+  SetAddressableBits(AddressMaskType type, uint32_t num_bits,
+ AddressMaskRange addr_range = lldb::eAddressMaskRangeLow);
+
+  /// Clear the non-addressable bits of an \a addr value and return a
+  /// virtual address in memory.
+  ///
+  /// Bits that are not used in addressing may be used for other purposes;
+  /// pointer authentication, or metadata in the top byte, or the 0th bit
+  /// of armv7 code addresses to indicate arm/thumb are common examples.
+  ///
+  /// \param[in] addr
+  /// The address that should be cleared of non-addressable bits.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.

hawkin

[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)

2024-02-28 Thread Will Hawkins via lldb-commits


@@ -407,6 +407,117 @@ class LLDB_API SBProcess {
   /// the process isn't loaded from a core file.
   lldb::SBFileSpec GetCoreFile();
 
+  /// \{
+  /// \group Mask Address Methods
+  ///
+  /// \a type
+  /// All of the methods in this group take \a type argument
+  /// which is an AddressMaskType enum value.
+  /// There can be different address masks for code addresses and
+  /// data addresses, this argument can select which to get/set,
+  /// or to use when clearing non-addressable bits from an address.
+  /// On AArch32 code with arm+thumb code, where instructions start
+  /// on even addresses, the 0th bit may be used to indicate that
+  /// a function is thumb code.  On such a target, the eAddressMaskTypeCode
+  /// may clear the 0th bit from an address to get the actual address.
+  ///
+  /// \a addr_range
+  /// Many of the methods in this group take an \a addr_range argument
+  /// which is an AddressMaskRange enum value.
+  /// Needing to specify the address range is highly unusual, and the
+  /// default argument can be used in nearly all circumstances.
+  /// On some architectures like AArch64, it is possible to have
+  /// different page table setups for low and high memory, so different
+  /// numbers of bits relevant to addressing. It is possible to have
+  /// a program running in one half of memory and accessing the other
+  /// as heap, so we need to maintain two different sets of address masks
+  /// to debug this correctly.
+
+  /// Get the current address mask that will be applied to addresses
+  /// before reading from memory.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// eAddressMaskTypeAny is often a suitable value when code and
+  /// data masks are the same on a given target.
+  ///
+  /// \param[in] addr_range
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// This will default to eAddressMaskRangeLow which is the
+  /// only set of masks used normally.
+  ///
+  /// \return
+  /// The address mask currently in use.  Bits which are not used
+  /// for addressing will be set to 1 in the mask.
+  lldb::addr_t GetAddressMask(
+  lldb::AddressMaskType type,
+  lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow);
+
+  /// Set the current address mask that can be applied to addresses
+  /// before reading from memory.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// eAddressMaskTypeAll is often a suitable value when the
+  /// same mask is being set for both code and data.
+  ///
+  /// \param[in] mask
+  /// The address mask to set.  Bits which are not used for addressing
+  /// should be set to 1 in the mask.
+  ///
+  /// \param[in] addr_range
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// This will default to eAddressMaskRangeLow which is the
+  /// only set of masks used normally.
+  void SetAddressMask(
+  lldb::AddressMaskType type, lldb::addr_t mask,
+  lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow);
+
+  /// Set the number of bits used for addressing in this Process.
+  ///
+  /// In some environments, the number of bits that are used for addressing
+  /// is the natural representation instead of a mask, but lldb
+  /// internally represents this as a mask.  This method calculates
+  /// the addressing mask that lldb uses that number of addressable bits.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// eAddressMaskTypeAll is often a suitable value when the
+  /// same mask is being set for both code and data.
+  ///
+  /// \param[in] num_bits
+  /// Number of bits that are used for addressing.
+  /// A value of 42 indicates that the low 42 bits are relevant for
+  /// addressing, and that higher order bits may be used for various
+  /// metadata like pointer authentication, Type Byte Ignore, etc.
+  ///
+  /// \param[in] addr_range
+  /// See \ref Mask Address Methods descripton of this argument.

hawkinsw wrote:

```suggestion
  /// See \ref Mask Address Methods description of this argument.
```

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


[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)

2024-02-28 Thread Will Hawkins via lldb-commits


@@ -407,6 +407,117 @@ class LLDB_API SBProcess {
   /// the process isn't loaded from a core file.
   lldb::SBFileSpec GetCoreFile();
 
+  /// \{
+  /// \group Mask Address Methods
+  ///
+  /// \a type
+  /// All of the methods in this group take \a type argument
+  /// which is an AddressMaskType enum value.
+  /// There can be different address masks for code addresses and
+  /// data addresses, this argument can select which to get/set,
+  /// or to use when clearing non-addressable bits from an address.
+  /// On AArch32 code with arm+thumb code, where instructions start
+  /// on even addresses, the 0th bit may be used to indicate that
+  /// a function is thumb code.  On such a target, the eAddressMaskTypeCode
+  /// may clear the 0th bit from an address to get the actual address.
+  ///
+  /// \a addr_range
+  /// Many of the methods in this group take an \a addr_range argument
+  /// which is an AddressMaskRange enum value.
+  /// Needing to specify the address range is highly unusual, and the
+  /// default argument can be used in nearly all circumstances.
+  /// On some architectures like AArch64, it is possible to have
+  /// different page table setups for low and high memory, so different
+  /// numbers of bits relevant to addressing. It is possible to have
+  /// a program running in one half of memory and accessing the other
+  /// as heap, so we need to maintain two different sets of address masks
+  /// to debug this correctly.
+
+  /// Get the current address mask that will be applied to addresses
+  /// before reading from memory.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// eAddressMaskTypeAny is often a suitable value when code and
+  /// data masks are the same on a given target.
+  ///
+  /// \param[in] addr_range
+  /// See \ref Mask Address Methods descripton of this argument.

hawkinsw wrote:

```suggestion
  /// See \ref Mask Address Methods description of this argument.
```

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


[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)

2024-02-28 Thread Will Hawkins via lldb-commits


@@ -407,6 +407,117 @@ class LLDB_API SBProcess {
   /// the process isn't loaded from a core file.
   lldb::SBFileSpec GetCoreFile();
 
+  /// \{
+  /// \group Mask Address Methods
+  ///
+  /// \a type
+  /// All of the methods in this group take \a type argument
+  /// which is an AddressMaskType enum value.
+  /// There can be different address masks for code addresses and
+  /// data addresses, this argument can select which to get/set,
+  /// or to use when clearing non-addressable bits from an address.
+  /// On AArch32 code with arm+thumb code, where instructions start
+  /// on even addresses, the 0th bit may be used to indicate that
+  /// a function is thumb code.  On such a target, the eAddressMaskTypeCode
+  /// may clear the 0th bit from an address to get the actual address.
+  ///
+  /// \a addr_range
+  /// Many of the methods in this group take an \a addr_range argument
+  /// which is an AddressMaskRange enum value.
+  /// Needing to specify the address range is highly unusual, and the
+  /// default argument can be used in nearly all circumstances.
+  /// On some architectures like AArch64, it is possible to have
+  /// different page table setups for low and high memory, so different
+  /// numbers of bits relevant to addressing. It is possible to have
+  /// a program running in one half of memory and accessing the other
+  /// as heap, so we need to maintain two different sets of address masks
+  /// to debug this correctly.
+
+  /// Get the current address mask that will be applied to addresses
+  /// before reading from memory.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// eAddressMaskTypeAny is often a suitable value when code and
+  /// data masks are the same on a given target.
+  ///
+  /// \param[in] addr_range
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// This will default to eAddressMaskRangeLow which is the
+  /// only set of masks used normally.
+  ///
+  /// \return
+  /// The address mask currently in use.  Bits which are not used
+  /// for addressing will be set to 1 in the mask.
+  lldb::addr_t GetAddressMask(
+  lldb::AddressMaskType type,
+  lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow);
+
+  /// Set the current address mask that can be applied to addresses
+  /// before reading from memory.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// eAddressMaskTypeAll is often a suitable value when the
+  /// same mask is being set for both code and data.
+  ///
+  /// \param[in] mask
+  /// The address mask to set.  Bits which are not used for addressing
+  /// should be set to 1 in the mask.
+  ///
+  /// \param[in] addr_range
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// This will default to eAddressMaskRangeLow which is the
+  /// only set of masks used normally.
+  void SetAddressMask(
+  lldb::AddressMaskType type, lldb::addr_t mask,
+  lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow);
+
+  /// Set the number of bits used for addressing in this Process.
+  ///
+  /// In some environments, the number of bits that are used for addressing
+  /// is the natural representation instead of a mask, but lldb
+  /// internally represents this as a mask.  This method calculates
+  /// the addressing mask that lldb uses that number of addressable bits.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.

hawkinsw wrote:

```suggestion
  /// See \ref Mask Address Methods description of this argument.
```

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


[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)

2024-02-28 Thread Will Hawkins via lldb-commits


@@ -407,6 +407,117 @@ class LLDB_API SBProcess {
   /// the process isn't loaded from a core file.
   lldb::SBFileSpec GetCoreFile();
 
+  /// \{
+  /// \group Mask Address Methods
+  ///
+  /// \a type
+  /// All of the methods in this group take \a type argument
+  /// which is an AddressMaskType enum value.
+  /// There can be different address masks for code addresses and
+  /// data addresses, this argument can select which to get/set,
+  /// or to use when clearing non-addressable bits from an address.
+  /// On AArch32 code with arm+thumb code, where instructions start
+  /// on even addresses, the 0th bit may be used to indicate that
+  /// a function is thumb code.  On such a target, the eAddressMaskTypeCode
+  /// may clear the 0th bit from an address to get the actual address.
+  ///
+  /// \a addr_range
+  /// Many of the methods in this group take an \a addr_range argument
+  /// which is an AddressMaskRange enum value.
+  /// Needing to specify the address range is highly unusual, and the
+  /// default argument can be used in nearly all circumstances.
+  /// On some architectures like AArch64, it is possible to have
+  /// different page table setups for low and high memory, so different
+  /// numbers of bits relevant to addressing. It is possible to have
+  /// a program running in one half of memory and accessing the other
+  /// as heap, so we need to maintain two different sets of address masks
+  /// to debug this correctly.
+
+  /// Get the current address mask that will be applied to addresses
+  /// before reading from memory.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// eAddressMaskTypeAny is often a suitable value when code and
+  /// data masks are the same on a given target.
+  ///
+  /// \param[in] addr_range
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// This will default to eAddressMaskRangeLow which is the
+  /// only set of masks used normally.
+  ///
+  /// \return
+  /// The address mask currently in use.  Bits which are not used
+  /// for addressing will be set to 1 in the mask.
+  lldb::addr_t GetAddressMask(
+  lldb::AddressMaskType type,
+  lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow);
+
+  /// Set the current address mask that can be applied to addresses
+  /// before reading from memory.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// eAddressMaskTypeAll is often a suitable value when the
+  /// same mask is being set for both code and data.
+  ///
+  /// \param[in] mask
+  /// The address mask to set.  Bits which are not used for addressing
+  /// should be set to 1 in the mask.
+  ///
+  /// \param[in] addr_range
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// This will default to eAddressMaskRangeLow which is the
+  /// only set of masks used normally.
+  void SetAddressMask(
+  lldb::AddressMaskType type, lldb::addr_t mask,
+  lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow);
+
+  /// Set the number of bits used for addressing in this Process.
+  ///
+  /// In some environments, the number of bits that are used for addressing
+  /// is the natural representation instead of a mask, but lldb
+  /// internally represents this as a mask.  This method calculates
+  /// the addressing mask that lldb uses that number of addressable bits.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// eAddressMaskTypeAll is often a suitable value when the
+  /// same mask is being set for both code and data.
+  ///
+  /// \param[in] num_bits
+  /// Number of bits that are used for addressing.
+  /// A value of 42 indicates that the low 42 bits are relevant for
+  /// addressing, and that higher order bits may be used for various

hawkinsw wrote:

```suggestion
  /// addressing, and that higher-order bits may be used for various
```

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


[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)

2024-02-28 Thread Will Hawkins via lldb-commits


@@ -407,6 +407,117 @@ class LLDB_API SBProcess {
   /// the process isn't loaded from a core file.
   lldb::SBFileSpec GetCoreFile();
 
+  /// \{
+  /// \group Mask Address Methods
+  ///
+  /// \a type
+  /// All of the methods in this group take \a type argument
+  /// which is an AddressMaskType enum value.
+  /// There can be different address masks for code addresses and
+  /// data addresses, this argument can select which to get/set,
+  /// or to use when clearing non-addressable bits from an address.
+  /// On AArch32 code with arm+thumb code, where instructions start
+  /// on even addresses, the 0th bit may be used to indicate that
+  /// a function is thumb code.  On such a target, the eAddressMaskTypeCode
+  /// may clear the 0th bit from an address to get the actual address.
+  ///
+  /// \a addr_range
+  /// Many of the methods in this group take an \a addr_range argument
+  /// which is an AddressMaskRange enum value.
+  /// Needing to specify the address range is highly unusual, and the
+  /// default argument can be used in nearly all circumstances.
+  /// On some architectures like AArch64, it is possible to have
+  /// different page table setups for low and high memory, so different
+  /// numbers of bits relevant to addressing. It is possible to have
+  /// a program running in one half of memory and accessing the other
+  /// as heap, so we need to maintain two different sets of address masks
+  /// to debug this correctly.
+
+  /// Get the current address mask that will be applied to addresses
+  /// before reading from memory.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// eAddressMaskTypeAny is often a suitable value when code and
+  /// data masks are the same on a given target.
+  ///
+  /// \param[in] addr_range
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// This will default to eAddressMaskRangeLow which is the
+  /// only set of masks used normally.
+  ///
+  /// \return
+  /// The address mask currently in use.  Bits which are not used
+  /// for addressing will be set to 1 in the mask.
+  lldb::addr_t GetAddressMask(
+  lldb::AddressMaskType type,
+  lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow);
+
+  /// Set the current address mask that can be applied to addresses
+  /// before reading from memory.
+  ///
+  /// \param[in] type
+  /// See \ref Mask Address Methods descripton of this argument.
+  /// eAddressMaskTypeAll is often a suitable value when the
+  /// same mask is being set for both code and data.
+  ///
+  /// \param[in] mask
+  /// The address mask to set.  Bits which are not used for addressing
+  /// should be set to 1 in the mask.
+  ///
+  /// \param[in] addr_range
+  /// See \ref Mask Address Methods descripton of this argument.

hawkinsw wrote:

```suggestion
  /// See \ref Mask Address Methods description of this argument.
```

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


[Lldb-commits] [lldb] [LLDB] Fix completion of space-only lines in the REPL on Linux (PR #83203)

2024-02-28 Thread Walter Erquinigo via lldb-commits


@@ -54,3 +55,16 @@ def test_basic_completion(self):
 self.expect_repl("$persistent + 10", substrs=["(long) $2 = 17"])
 
 self.quit()
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+@skipIf(oslist=["linux"], archs=["arm", "aarch64"])  # Randomly fails on 
buildbot

walter-erquinigo wrote:

I actually don't know. The existing test already has issues with basic expr 
eval, and the new test will have them as well, so I decided to just copy the 
same configuration.

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


[Lldb-commits] [lldb] cd344a4 - [LLDB] Fix completion of space-only lines in the REPL on Linux (#83203)

2024-02-28 Thread via lldb-commits

Author: Walter Erquinigo
Date: 2024-02-28T11:43:36-05:00
New Revision: cd344a4c20e295d49f8163ec9a0656c1061a6e42

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

LOG: [LLDB] Fix completion of space-only lines in the REPL on Linux (#83203)

https://github.com/modularml/mojo/issues/1796 discovered that if you try
to complete a space-only line in the REPL on Linux, LLDB crashes. I
suspect that editline doesn't behave the same way on linux and on
darwin, because I can't replicate this on darwin.

Adding a boundary check in the completion code prevents the crash from
happening.

Added: 


Modified: 
lldb/source/Host/common/Editline.cpp
lldb/test/API/repl/clang/TestClangREPL.py

Removed: 




diff  --git a/lldb/source/Host/common/Editline.cpp 
b/lldb/source/Host/common/Editline.cpp
index ce707e530d008b..e66271e8a6ee99 100644
--- a/lldb/source/Host/common/Editline.cpp
+++ b/lldb/source/Host/common/Editline.cpp
@@ -1029,8 +1029,11 @@ unsigned char Editline::TabCommand(int ch) {
 case CompletionMode::Normal: {
   std::string to_add = completion.GetCompletion();
   // Terminate the current argument with a quote if it started with a 
quote.
-  if (!request.GetParsedLine().empty() && 
request.GetParsedArg().IsQuoted())
+  Args &parsedLine = request.GetParsedLine();
+  if (!parsedLine.empty() && request.GetCursorIndex() < parsedLine.size() 
&&
+  request.GetParsedArg().IsQuoted()) {
 to_add.push_back(request.GetParsedArg().GetQuoteChar());
+  }
   to_add.push_back(' ');
   el_deletestr(m_editline, request.GetCursorArgumentPrefix().size());
   el_insertstr(m_editline, to_add.c_str());

diff  --git a/lldb/test/API/repl/clang/TestClangREPL.py 
b/lldb/test/API/repl/clang/TestClangREPL.py
index 0b67955a7833c6..c37557fb94735d 100644
--- a/lldb/test/API/repl/clang/TestClangREPL.py
+++ b/lldb/test/API/repl/clang/TestClangREPL.py
@@ -1,7 +1,6 @@
-import lldb
 from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
 from lldbsuite.test.lldbpexpect import PExpectTest
+from lldbsuite.test.lldbtest import *
 
 
 class TestCase(PExpectTest):
@@ -17,13 +16,7 @@ def expect_repl(self, expr, substrs=[]):
 self.current_repl_line_number += 1
 self.child.expect_exact(str(self.current_repl_line_number) + ">")
 
-# PExpect uses many timeouts internally and doesn't play well
-# under ASAN on a loaded machine..
-@skipIfAsan
-@skipIf(oslist=["linux"], archs=["arm", "aarch64"])  # Randomly fails on 
buildbot
-@skipIfEditlineSupportMissing
-def test_basic_completion(self):
-"""Test that we can complete a simple multiline expression"""
+def start_repl(self):
 self.build()
 self.current_repl_line_number = 1
 
@@ -41,6 +34,14 @@ def test_basic_completion(self):
 self.child.send("expression --repl -l c --\n")
 self.child.expect_exact("1>")
 
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+@skipIf(oslist=["linux"], archs=["arm", "aarch64"])  # Randomly fails on 
buildbot
+@skipIfEditlineSupportMissing
+def test_basic_completion(self):
+"""Test that we can complete a simple multiline expression"""
+self.start_repl()
 # Try evaluating a simple expression.
 self.expect_repl("3 + 3", substrs=["(int) $0 = 6"])
 
@@ -54,3 +55,16 @@ def test_basic_completion(self):
 self.expect_repl("$persistent + 10", substrs=["(long) $2 = 17"])
 
 self.quit()
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+@skipIf(oslist=["linux"], archs=["arm", "aarch64"])  # Randomly fails on 
buildbot
+@skipIfEditlineSupportMissing
+def test_completion_with_space_only_line(self):
+"""Test that we don't crash when completing lines with spaces only"""
+self.start_repl()
+
+self.child.send("   ")
+self.child.send("\t")
+self.expect_repl("3 + 3", substrs=["(int) $0 = 6"])



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


[Lldb-commits] [lldb] [LLDB] Fix completion of space-only lines in the REPL on Linux (PR #83203)

2024-02-28 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb][NFC] Move helpers to import record layout into ClangASTImporter (PR #83291)

2024-02-28 Thread Michael Buch via lldb-commits

https://github.com/Michael137 created 
https://github.com/llvm/llvm-project/pull/83291

This patch moves the logic for copying the layout info of a `RecordDecl`s 
origin into a target AST.

A follow-up patch re-uses the logic from within the `ClangASTImporter`, so the 
natural choice was to move it there.

>From 7ffc5c966a7a0542cbde20ead3144344e68e648f Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 28 Feb 2024 13:32:01 +
Subject: [PATCH] [lldb][NFC] Move helpers to import record layout into
 ClangASTImporter

---
 .../Clang/ClangASTImporter.cpp| 204 +
 .../ExpressionParser/Clang/ClangASTImporter.h |  61 
 .../ExpressionParser/Clang/ClangASTSource.cpp | 278 ++
 .../ExpressionParser/Clang/ClangASTSource.h   |   5 +
 4 files changed, 290 insertions(+), 258 deletions(-)

diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index 62a30c14912bc9..b9f2c834dd1197 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -10,9 +10,11 @@
 #include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
+#include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/RecordLayout.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Sema.h"
 #include "llvm/Support/raw_ostream.h"
@@ -26,6 +28,7 @@
 
 #include 
 #include 
+#include 
 
 using namespace lldb_private;
 using namespace clang;
@@ -517,6 +520,207 @@ bool ClangASTImporter::CompleteType(const CompilerType 
&compiler_type) {
   return false;
 }
 
+template 
+static bool ImportOffsetMap(clang::ASTContext *dest_ctx,
+llvm::DenseMap &destination_map,
+llvm::DenseMap &source_map,
+ClangASTImporter &importer) {
+  // When importing fields into a new record, clang has a hard requirement that
+  // fields be imported in field offset order.  Since they are stored in a
+  // DenseMap with a pointer as the key type, this means we cannot simply
+  // iterate over the map, as the order will be non-deterministic.  Instead we
+  // have to sort by the offset and then insert in sorted order.
+  typedef llvm::DenseMap MapType;
+  typedef typename MapType::value_type PairType;
+  std::vector sorted_items;
+  sorted_items.reserve(source_map.size());
+  sorted_items.assign(source_map.begin(), source_map.end());
+  llvm::sort(sorted_items, llvm::less_second());
+
+  for (const auto &item : sorted_items) {
+DeclFromUser user_decl(const_cast(item.first));
+DeclFromParser parser_decl(user_decl.Import(dest_ctx, importer));
+if (parser_decl.IsInvalid())
+  return false;
+destination_map.insert(
+std::pair(parser_decl.decl, item.second));
+  }
+
+  return true;
+}
+
+template 
+bool ExtractBaseOffsets(const ASTRecordLayout &record_layout,
+DeclFromUser &record,
+llvm::DenseMap &base_offsets) {
+  for (CXXRecordDecl::base_class_const_iterator
+   bi = (IsVirtual ? record->vbases_begin() : record->bases_begin()),
+   be = (IsVirtual ? record->vbases_end() : record->bases_end());
+   bi != be; ++bi) {
+if (!IsVirtual && bi->isVirtual())
+  continue;
+
+const clang::Type *origin_base_type = bi->getType().getTypePtr();
+const clang::RecordType *origin_base_record_type =
+origin_base_type->getAs();
+
+if (!origin_base_record_type)
+  return false;
+
+DeclFromUser origin_base_record(
+origin_base_record_type->getDecl());
+
+if (origin_base_record.IsInvalid())
+  return false;
+
+DeclFromUser origin_base_cxx_record(
+DynCast(origin_base_record));
+
+if (origin_base_cxx_record.IsInvalid())
+  return false;
+
+CharUnits base_offset;
+
+if (IsVirtual)
+  base_offset =
+  record_layout.getVBaseClassOffset(origin_base_cxx_record.decl);
+else
+  base_offset =
+  record_layout.getBaseClassOffset(origin_base_cxx_record.decl);
+
+base_offsets.insert(std::pair(
+origin_base_cxx_record.decl, base_offset));
+  }
+
+  return true;
+}
+
+bool ClangASTImporter::importRecordLayoutFromOrigin(
+const RecordDecl *record, uint64_t &size, uint64_t &alignment,
+llvm::DenseMap &field_offsets,
+llvm::DenseMap
+&base_offsets,
+llvm::DenseMap
+&vbase_offsets) {
+
+  Log *log = GetLog(LLDBLog::Expressions);
+
+  clang::ASTContext &dest_ctx = record->getASTContext();
+  LLDB_LOG(log,
+   "LayoutRecordType on (ASTContext*){0} '{1}' for (RecordDecl*)"
+   "{2} [name = '{3}']",
+   &dest_ctx,
+   TypeSystemClang::GetASTContext(&dest_ctx)->getDisplayName(), record,
+   record->getName());
+
+  Dec

[Lldb-commits] [lldb] [lldb][NFC] Move helpers to import record layout into ClangASTImporter (PR #83291)

2024-02-28 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

This patch moves the logic for copying the layout info of a `RecordDecl`s 
origin into a target AST.

A follow-up patch re-uses the logic from within the `ClangASTImporter`, so the 
natural choice was to move it there.

---

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


4 Files Affected:

- (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
(+204) 
- (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h 
(+61) 
- (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp 
(+20-258) 
- (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h (+5) 


``diff
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index 62a30c14912bc9..b9f2c834dd1197 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -10,9 +10,11 @@
 #include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
+#include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/RecordLayout.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Sema.h"
 #include "llvm/Support/raw_ostream.h"
@@ -26,6 +28,7 @@
 
 #include 
 #include 
+#include 
 
 using namespace lldb_private;
 using namespace clang;
@@ -517,6 +520,207 @@ bool ClangASTImporter::CompleteType(const CompilerType 
&compiler_type) {
   return false;
 }
 
+template 
+static bool ImportOffsetMap(clang::ASTContext *dest_ctx,
+llvm::DenseMap &destination_map,
+llvm::DenseMap &source_map,
+ClangASTImporter &importer) {
+  // When importing fields into a new record, clang has a hard requirement that
+  // fields be imported in field offset order.  Since they are stored in a
+  // DenseMap with a pointer as the key type, this means we cannot simply
+  // iterate over the map, as the order will be non-deterministic.  Instead we
+  // have to sort by the offset and then insert in sorted order.
+  typedef llvm::DenseMap MapType;
+  typedef typename MapType::value_type PairType;
+  std::vector sorted_items;
+  sorted_items.reserve(source_map.size());
+  sorted_items.assign(source_map.begin(), source_map.end());
+  llvm::sort(sorted_items, llvm::less_second());
+
+  for (const auto &item : sorted_items) {
+DeclFromUser user_decl(const_cast(item.first));
+DeclFromParser parser_decl(user_decl.Import(dest_ctx, importer));
+if (parser_decl.IsInvalid())
+  return false;
+destination_map.insert(
+std::pair(parser_decl.decl, item.second));
+  }
+
+  return true;
+}
+
+template 
+bool ExtractBaseOffsets(const ASTRecordLayout &record_layout,
+DeclFromUser &record,
+llvm::DenseMap &base_offsets) {
+  for (CXXRecordDecl::base_class_const_iterator
+   bi = (IsVirtual ? record->vbases_begin() : record->bases_begin()),
+   be = (IsVirtual ? record->vbases_end() : record->bases_end());
+   bi != be; ++bi) {
+if (!IsVirtual && bi->isVirtual())
+  continue;
+
+const clang::Type *origin_base_type = bi->getType().getTypePtr();
+const clang::RecordType *origin_base_record_type =
+origin_base_type->getAs();
+
+if (!origin_base_record_type)
+  return false;
+
+DeclFromUser origin_base_record(
+origin_base_record_type->getDecl());
+
+if (origin_base_record.IsInvalid())
+  return false;
+
+DeclFromUser origin_base_cxx_record(
+DynCast(origin_base_record));
+
+if (origin_base_cxx_record.IsInvalid())
+  return false;
+
+CharUnits base_offset;
+
+if (IsVirtual)
+  base_offset =
+  record_layout.getVBaseClassOffset(origin_base_cxx_record.decl);
+else
+  base_offset =
+  record_layout.getBaseClassOffset(origin_base_cxx_record.decl);
+
+base_offsets.insert(std::pair(
+origin_base_cxx_record.decl, base_offset));
+  }
+
+  return true;
+}
+
+bool ClangASTImporter::importRecordLayoutFromOrigin(
+const RecordDecl *record, uint64_t &size, uint64_t &alignment,
+llvm::DenseMap &field_offsets,
+llvm::DenseMap
+&base_offsets,
+llvm::DenseMap
+&vbase_offsets) {
+
+  Log *log = GetLog(LLDBLog::Expressions);
+
+  clang::ASTContext &dest_ctx = record->getASTContext();
+  LLDB_LOG(log,
+   "LayoutRecordType on (ASTContext*){0} '{1}' for (RecordDecl*)"
+   "{2} [name = '{3}']",
+   &dest_ctx,
+   TypeSystemClang::GetASTContext(&dest_ctx)->getDisplayName(), record,
+   record->getName());
+
+  DeclFromParser parser_record(record

[Lldb-commits] [lldb] [LLDB] Fix completion of space-only lines in the REPL on Linux (PR #83203)

2024-02-28 Thread David Spickett via lldb-commits


@@ -54,3 +55,16 @@ def test_basic_completion(self):
 self.expect_repl("$persistent + 10", substrs=["(long) $2 = 17"])
 
 self.quit()
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+@skipIf(oslist=["linux"], archs=["arm", "aarch64"])  # Randomly fails on 
buildbot

DavidSpickett wrote:

Fair enough, if there's no specific reason I bet it's a relic from when we had 
way too many bots on the same machine. Today we don't have as many as we used 
to, but not your problem to figure out. It's being run somewhere that's the 
main thing.

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


[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)

2024-02-28 Thread Jonas Devlieghere via lldb-commits


@@ -82,20 +94,37 @@ ProgressManager &ProgressManager::Instance() {
   return *g_progress_manager;
 }
 
-void ProgressManager::Increment(std::string title) {
+void ProgressManager::Increment(Progress::ProgressData progress_data) {

JDevlieghere wrote:

This should take a const ref to avoid the copy `const Progress::ProgressData& 
progress_data`. If we'd unconditionally store it in the map I'd say the copy is 
fine as you'd be able to move it into the map, but I'm assuming most of the 
time we're only using the title to do the lookup. 

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


[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)

2024-02-28 Thread Jonas Devlieghere via lldb-commits


@@ -97,27 +98,37 @@ class Progress {
   /// Used to indicate a non-deterministic progress report
   static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX;
 
+  /// Use a struct to send data from a Progress object to
+  /// the progress manager.
+  struct ProgressData {
+/// The title of the progress activity, also used as a category to group
+/// reports.
+std::string title;
+/// More specific information about the current file being displayed in the
+/// report.
+std::string details;
+/// A unique integer identifier for progress reporting.
+uint64_t progress_id;
+/// How much work ([0...m_total]) that has been completed.
+uint64_t completed;
+/// Total amount of work, use a std::nullopt in the constructor for non
+/// deterministic progress.
+uint64_t total;
+/// The optional debugger ID to report progress to. If this has no value
+/// then all debuggers will receive this event.
+std::optional debugger_id;
+  };
+
 private:
   void ReportProgress();
   static std::atomic g_id;
-  /// The title of the progress activity.
-  std::string m_title;
-  std::string m_details;
   std::mutex m_mutex;
-  /// A unique integer identifier for progress reporting.
-  const uint64_t m_id;
-  /// How much work ([0...m_total]) that has been completed.
-  uint64_t m_completed;
-  /// Total amount of work, use a std::nullopt in the constructor for non
-  /// deterministic progress.
-  uint64_t m_total;
-  /// The optional debugger ID to report progress to. If this has no value then
-  /// all debuggers will receive this event.
-  std::optional m_debugger_id;
   /// Set to true when progress has been reported where m_completed == m_total
   /// to ensure that we don't send progress updates after progress has
   /// completed.
   bool m_complete = false;
+  /// Data needed by the debugger to broadcast a progress event.

JDevlieghere wrote:

Suggestion:
```
/// Data data belonging to this Progress event. This data is used by the 
Debugger to broadcast the event and by the ProgressManager for bookkeeping.
```

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


[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)

2024-02-28 Thread Jonas Devlieghere via lldb-commits

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

LGTM with the nit addressed. 

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


[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)

2024-02-28 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb][ClangASTImporter] Import record layouts from origin if available (PR #83295)

2024-02-28 Thread Michael Buch via lldb-commits

https://github.com/Michael137 created 
https://github.com/llvm/llvm-project/pull/83295

Layout information for a record gets stored in the `ClangASTImporter` 
associated with the `DWARFASTParserClang` that originally parsed the record. 
LLDB sometimes moves clang types from one AST to another (in the reproducer the 
origin AST was a precompiled-header and the destination was the AST backing the 
executable). When clang then asks LLDB to `layoutRecordType`, it will do so 
with the help of the `ClangASTImporter` the type is associated with. If the 
type's origin is actually in a different LLDB module (and thus a different 
`DWARFASTParserClang` was used to set its layout info), we won't find the 
layout info in our local `ClangASTImporter`.

In the reproducer this meant we would drop the alignment info of the origin 
type and misread a variable's contents with `frame var` and `expr`.

There is logic in `ClangASTSource::layoutRecordType` to import an origin's 
layout info. This patch re-uses that infrastructure to import an origin's 
layout from one `ClangASTImporter` instance to another.

rdar://123274144

>From 9a6ed480fd407f9a9f12d6faccffbad952de0855 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 28 Feb 2024 13:52:54 +
Subject: [PATCH] [lldb][ClangASTImporter] Import record layouts from origin if
 available

---
 .../Clang/ClangASTImporter.cpp| 23 ---
 .../API/lang/cpp/gmodules/alignment/Makefile  |  4 ++
 .../gmodules/alignment/TestPchAlignment.py| 60 +++
 .../API/lang/cpp/gmodules/alignment/main.cpp  | 10 
 .../API/lang/cpp/gmodules/alignment/pch.h | 21 +++
 5 files changed, 111 insertions(+), 7 deletions(-)
 create mode 100644 lldb/test/API/lang/cpp/gmodules/alignment/Makefile
 create mode 100644 
lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py
 create mode 100644 lldb/test/API/lang/cpp/gmodules/alignment/main.cpp
 create mode 100644 lldb/test/API/lang/cpp/gmodules/alignment/pch.h

diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index 62a30c14912bc9..754191ad83fe8a 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -527,7 +527,6 @@ bool ClangASTImporter::LayoutRecordType(
 &vbase_offsets) {
   RecordDeclToLayoutMap::iterator pos =
   m_record_decl_to_layout_map.find(record_decl);
-  bool success = false;
   base_offsets.clear();
   vbase_offsets.clear();
   if (pos != m_record_decl_to_layout_map.end()) {
@@ -537,13 +536,23 @@ bool ClangASTImporter::LayoutRecordType(
 base_offsets.swap(pos->second.base_offsets);
 vbase_offsets.swap(pos->second.vbase_offsets);
 m_record_decl_to_layout_map.erase(pos);
-success = true;
-  } else {
-bit_size = 0;
-alignment = 0;
-field_offsets.clear();
+return true;
   }
-  return success;
+
+  // It's possible that we calculated the layout in a different
+  // ClangASTImporter instance. Try to import such layout if
+  // our decl has an origin.
+  if (auto origin = GetDeclOrigin(record_decl); origin.Valid())
+if (importRecordLayoutFromOrigin(record_decl, bit_size, alignment,
+ field_offsets, base_offsets,
+ vbase_offsets))
+  return true;
+
+  bit_size = 0;
+  alignment = 0;
+  field_offsets.clear();
+
+  return false;
 }
 
 void ClangASTImporter::SetRecordLayout(clang::RecordDecl *decl,
diff --git a/lldb/test/API/lang/cpp/gmodules/alignment/Makefile 
b/lldb/test/API/lang/cpp/gmodules/alignment/Makefile
new file mode 100644
index 00..a6c3e8ca84a3e4
--- /dev/null
+++ b/lldb/test/API/lang/cpp/gmodules/alignment/Makefile
@@ -0,0 +1,4 @@
+PCH_CXX_SOURCE = pch.h
+CXX_SOURCES = main.cpp
+
+include Makefile.rules
diff --git a/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py 
b/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py
new file mode 100644
index 00..535dd13d0ada48
--- /dev/null
+++ b/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py
@@ -0,0 +1,60 @@
+"""
+Tests that we correctly track AST layout info
+(specifically alignment) when moving AST nodes
+between ClangASTImporter instances (in this case,
+from pch to executable to expression AST).
+"""
+
+import lldb
+import os
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestPchAlignment(TestBase):
+@add_test_categories(["gmodules"])
+def test_expr(self):
+self.build()
+lldbutil.run_to_source_breakpoint(
+self, "return data", lldb.SBFileSpec("main.cpp")
+)
+
+self.expect(
+"frame variable data",
+substrs=["row = 1", "col = 2", "row = 3", "col = 4", "stride = 5"],
+)
+
+@add_test_categories(["gmodules"])
+de

[Lldb-commits] [lldb] [lldb][ClangASTImporter] Import record layouts from origin if available (PR #83295)

2024-02-28 Thread Michael Buch via lldb-commits

Michael137 wrote:

relies on https://github.com/llvm/llvm-project/pull/83291

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


[Lldb-commits] [lldb] [lldb][ClangASTImporter] Import record layouts from origin if available (PR #83295)

2024-02-28 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

Layout information for a record gets stored in the `ClangASTImporter` 
associated with the `DWARFASTParserClang` that originally parsed the record. 
LLDB sometimes moves clang types from one AST to another (in the reproducer the 
origin AST was a precompiled-header and the destination was the AST backing the 
executable). When clang then asks LLDB to `layoutRecordType`, it will do so 
with the help of the `ClangASTImporter` the type is associated with. If the 
type's origin is actually in a different LLDB module (and thus a different 
`DWARFASTParserClang` was used to set its layout info), we won't find the 
layout info in our local `ClangASTImporter`.

In the reproducer this meant we would drop the alignment info of the origin 
type and misread a variable's contents with `frame var` and `expr`.

There is logic in `ClangASTSource::layoutRecordType` to import an origin's 
layout info. This patch re-uses that infrastructure to import an origin's 
layout from one `ClangASTImporter` instance to another.

rdar://123274144

---
Full diff: https://github.com/llvm/llvm-project/pull/83295.diff


5 Files Affected:

- (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
(+16-7) 
- (added) lldb/test/API/lang/cpp/gmodules/alignment/Makefile (+4) 
- (added) lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py (+60) 
- (added) lldb/test/API/lang/cpp/gmodules/alignment/main.cpp (+10) 
- (added) lldb/test/API/lang/cpp/gmodules/alignment/pch.h (+21) 


``diff
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index 62a30c14912bc9..754191ad83fe8a 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -527,7 +527,6 @@ bool ClangASTImporter::LayoutRecordType(
 &vbase_offsets) {
   RecordDeclToLayoutMap::iterator pos =
   m_record_decl_to_layout_map.find(record_decl);
-  bool success = false;
   base_offsets.clear();
   vbase_offsets.clear();
   if (pos != m_record_decl_to_layout_map.end()) {
@@ -537,13 +536,23 @@ bool ClangASTImporter::LayoutRecordType(
 base_offsets.swap(pos->second.base_offsets);
 vbase_offsets.swap(pos->second.vbase_offsets);
 m_record_decl_to_layout_map.erase(pos);
-success = true;
-  } else {
-bit_size = 0;
-alignment = 0;
-field_offsets.clear();
+return true;
   }
-  return success;
+
+  // It's possible that we calculated the layout in a different
+  // ClangASTImporter instance. Try to import such layout if
+  // our decl has an origin.
+  if (auto origin = GetDeclOrigin(record_decl); origin.Valid())
+if (importRecordLayoutFromOrigin(record_decl, bit_size, alignment,
+ field_offsets, base_offsets,
+ vbase_offsets))
+  return true;
+
+  bit_size = 0;
+  alignment = 0;
+  field_offsets.clear();
+
+  return false;
 }
 
 void ClangASTImporter::SetRecordLayout(clang::RecordDecl *decl,
diff --git a/lldb/test/API/lang/cpp/gmodules/alignment/Makefile 
b/lldb/test/API/lang/cpp/gmodules/alignment/Makefile
new file mode 100644
index 00..a6c3e8ca84a3e4
--- /dev/null
+++ b/lldb/test/API/lang/cpp/gmodules/alignment/Makefile
@@ -0,0 +1,4 @@
+PCH_CXX_SOURCE = pch.h
+CXX_SOURCES = main.cpp
+
+include Makefile.rules
diff --git a/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py 
b/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py
new file mode 100644
index 00..535dd13d0ada48
--- /dev/null
+++ b/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py
@@ -0,0 +1,60 @@
+"""
+Tests that we correctly track AST layout info
+(specifically alignment) when moving AST nodes
+between ClangASTImporter instances (in this case,
+from pch to executable to expression AST).
+"""
+
+import lldb
+import os
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestPchAlignment(TestBase):
+@add_test_categories(["gmodules"])
+def test_expr(self):
+self.build()
+lldbutil.run_to_source_breakpoint(
+self, "return data", lldb.SBFileSpec("main.cpp")
+)
+
+self.expect(
+"frame variable data",
+substrs=["row = 1", "col = 2", "row = 3", "col = 4", "stride = 5"],
+)
+
+@add_test_categories(["gmodules"])
+def test_frame_var(self):
+self.build()
+lldbutil.run_to_source_breakpoint(
+self, "return data", lldb.SBFileSpec("main.cpp")
+)
+
+self.expect_expr(
+"data",
+result_type="MatrixData",
+result_children=[
+ValueCheck(
+name="section",
+children=[
+  

[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)

2024-02-28 Thread Chelsea Cassanova via lldb-commits


@@ -82,20 +94,37 @@ ProgressManager &ProgressManager::Instance() {
   return *g_progress_manager;
 }
 
-void ProgressManager::Increment(std::string title) {
+void ProgressManager::Increment(Progress::ProgressData progress_data) {

chelcassanova wrote:

Yeah, the title is used for map queries but the data itself isn't stored in the 
map, it's passed on to `ProgressManager::ReportProgress`.  If we change it to a 
const ref (`const Progress::ProgressData& progress_data`) here then we probably 
also want to do this for `Decrement` since it uses the map in a similar way.

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


[Lldb-commits] [lldb] Increase timeout to reduce test failure rate. (PR #83312)

2024-02-28 Thread Shubham Sandeep Rastogi via lldb-commits

https://github.com/rastogishubham created 
https://github.com/llvm/llvm-project/pull/83312

The timeout for this test was set to 1.0s which is very low, it should be a 
default of 10s and be increased by a factor of 10 if ASAN is enabled. This will 
help reduce the falkiness of the test, especially in ASAN builds.

>From 53c507046527e04b7faa70ea17cd59b45e724f55 Mon Sep 17 00:00:00 2001
From: Shubham Sandeep Rastogi 
Date: Wed, 28 Feb 2024 10:28:55 -0800
Subject: [PATCH] Increase timeout to reduce test failure rate.

The timeout for this test was set to 1.0s which is very low, it should
be a default of 10s and be increased by a factor of 10 if ASAN is
enabled. This will help reduce the falkiness of the test, especially in
ASAN builds.
---
 .../API/tools/lldb-dap/launch/TestDAP_launch.py   | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py 
b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
index 04d741c1d47201..635ec4f0baf190 100644
--- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
+++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
@@ -44,7 +44,8 @@ def test_termination(self):
 self.dap_server.request_disconnect()
 
 # Wait until the underlying lldb-dap process dies.
-self.dap_server.process.wait(timeout=10)
+timeoutval = 10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1)
+self.dap_server.process.wait(timeout=timeoutval)
 
 # Check the return code
 self.assertEqual(self.dap_server.process.poll(), 0)
@@ -334,14 +335,15 @@ def test_commands(self):
 # Get output from the console. This should contain both the
 # "stopCommands" that were run after the first breakpoint was hit
 self.continue_to_breakpoints(breakpoint_ids)
-output = self.get_console(timeout=1.0)
+timeoutval = 10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1)
+output = self.get_console(timeout=timeoutval)
 self.verify_commands("stopCommands", output, stopCommands)
 
 # Continue again and hit the second breakpoint.
 # Get output from the console. This should contain both the
 # "stopCommands" that were run after the second breakpoint was hit
 self.continue_to_breakpoints(breakpoint_ids)
-output = self.get_console(timeout=1.0)
+output = self.get_console(timeout=timeoutval)
 self.verify_commands("stopCommands", output, stopCommands)
 
 # Continue until the program exits
@@ -402,21 +404,22 @@ def test_extra_launch_commands(self):
 self.verify_commands("launchCommands", output, launchCommands)
 # Verify the "stopCommands" here
 self.continue_to_next_stop()
-output = self.get_console(timeout=1.0)
+timeoutval = 10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1)
+output = self.get_console(timeout=timeoutval)
 self.verify_commands("stopCommands", output, stopCommands)
 
 # Continue and hit the second breakpoint.
 # Get output from the console. This should contain both the
 # "stopCommands" that were run after the first breakpoint was hit
 self.continue_to_next_stop()
-output = self.get_console(timeout=1.0)
+output = self.get_console(timeout=timeoutval)
 self.verify_commands("stopCommands", output, stopCommands)
 
 # Continue until the program exits
 self.continue_to_exit()
 # Get output from the console. This should contain both the
 # "exitCommands" that were run after the second breakpoint was hit
-output = self.get_console(timeout=1.0)
+output = self.get_console(timeout=timeoutval)
 self.verify_commands("exitCommands", output, exitCommands)
 
 @skipIfWindows

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


[Lldb-commits] [lldb] Increase timeout to reduce test failure rate. (PR #83312)

2024-02-28 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Shubham Sandeep Rastogi (rastogishubham)


Changes

The timeout for this test was set to 1.0s which is very low, it should be a 
default of 10s and be increased by a factor of 10 if ASAN is enabled. This will 
help reduce the falkiness of the test, especially in ASAN builds.

---
Full diff: https://github.com/llvm/llvm-project/pull/83312.diff


1 Files Affected:

- (modified) lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py (+9-6) 


``diff
diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py 
b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
index 04d741c1d47201..635ec4f0baf190 100644
--- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
+++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
@@ -44,7 +44,8 @@ def test_termination(self):
 self.dap_server.request_disconnect()
 
 # Wait until the underlying lldb-dap process dies.
-self.dap_server.process.wait(timeout=10)
+timeoutval = 10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1)
+self.dap_server.process.wait(timeout=timeoutval)
 
 # Check the return code
 self.assertEqual(self.dap_server.process.poll(), 0)
@@ -334,14 +335,15 @@ def test_commands(self):
 # Get output from the console. This should contain both the
 # "stopCommands" that were run after the first breakpoint was hit
 self.continue_to_breakpoints(breakpoint_ids)
-output = self.get_console(timeout=1.0)
+timeoutval = 10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1)
+output = self.get_console(timeout=timeoutval)
 self.verify_commands("stopCommands", output, stopCommands)
 
 # Continue again and hit the second breakpoint.
 # Get output from the console. This should contain both the
 # "stopCommands" that were run after the second breakpoint was hit
 self.continue_to_breakpoints(breakpoint_ids)
-output = self.get_console(timeout=1.0)
+output = self.get_console(timeout=timeoutval)
 self.verify_commands("stopCommands", output, stopCommands)
 
 # Continue until the program exits
@@ -402,21 +404,22 @@ def test_extra_launch_commands(self):
 self.verify_commands("launchCommands", output, launchCommands)
 # Verify the "stopCommands" here
 self.continue_to_next_stop()
-output = self.get_console(timeout=1.0)
+timeoutval = 10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1)
+output = self.get_console(timeout=timeoutval)
 self.verify_commands("stopCommands", output, stopCommands)
 
 # Continue and hit the second breakpoint.
 # Get output from the console. This should contain both the
 # "stopCommands" that were run after the first breakpoint was hit
 self.continue_to_next_stop()
-output = self.get_console(timeout=1.0)
+output = self.get_console(timeout=timeoutval)
 self.verify_commands("stopCommands", output, stopCommands)
 
 # Continue until the program exits
 self.continue_to_exit()
 # Get output from the console. This should contain both the
 # "exitCommands" that were run after the second breakpoint was hit
-output = self.get_console(timeout=1.0)
+output = self.get_console(timeout=timeoutval)
 self.verify_commands("exitCommands", output, exitCommands)
 
 @skipIfWindows

``




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


[Lldb-commits] [lldb] Increase timeout to reduce test failure rate. (PR #83312)

2024-02-28 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
c1b8c6cf41df4a148e7a89c3a3c7e8049b0a47af...53c507046527e04b7faa70ea17cd59b45e724f55
 lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
``





View the diff from darker here.


``diff
--- TestDAP_launch.py   2024-02-28 18:40:35.00 +
+++ TestDAP_launch.py   2024-02-28 18:44:39.052136 +
@@ -42,11 +42,11 @@
 # The lldb-dap process should finish even though
 # we didn't close the communication socket explicitly
 self.dap_server.request_disconnect()
 
 # Wait until the underlying lldb-dap process dies.
-timeoutval = 10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1)
+timeoutval = 10 * (10 if ("ASAN_OPTIONS" in os.environ) else 1)
 self.dap_server.process.wait(timeout=timeoutval)
 
 # Check the return code
 self.assertEqual(self.dap_server.process.poll(), 0)
 
@@ -333,11 +333,11 @@
 
 # Continue after launch and hit the first breakpoint.
 # Get output from the console. This should contain both the
 # "stopCommands" that were run after the first breakpoint was hit
 self.continue_to_breakpoints(breakpoint_ids)
-timeoutval = 10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1)
+timeoutval = 10 * (10 if ("ASAN_OPTIONS" in os.environ) else 1)
 output = self.get_console(timeout=timeoutval)
 self.verify_commands("stopCommands", output, stopCommands)
 
 # Continue again and hit the second breakpoint.
 # Get output from the console. This should contain both the
@@ -402,11 +402,11 @@
 # Verify all "launchCommands" were found in console output
 # After execution, program should launch
 self.verify_commands("launchCommands", output, launchCommands)
 # Verify the "stopCommands" here
 self.continue_to_next_stop()
-timeoutval = 10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1)
+timeoutval = 10 * (10 if ("ASAN_OPTIONS" in os.environ) else 1)
 output = self.get_console(timeout=timeoutval)
 self.verify_commands("stopCommands", output, stopCommands)
 
 # Continue and hit the second breakpoint.
 # Get output from the console. This should contain both the

``




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


[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)

2024-02-28 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/83069

>From 03268312834c61a16c4bc28efc442fcd027ec0a9 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Tue, 20 Feb 2024 13:56:53 -0800
Subject: [PATCH] [lldb][progress] Hook up new broadcast bit and progress
 manager

This commit adds the functionality to broadcast events using the
`Debugger::eBroadcastProgressCategory`
bit (https://github.com/llvm/llvm-project/pull/81169) by keeping track of these
reports with the `ProgressManager`
class (https://github.com/llvm/llvm-project/pull/81319). The new bit is
used in such a way that it will only broadcast the initial and final
progress reports for specific progress categories that are managed by
the progress manager.

This commit also adds a new test to the progress report unit test that
checks that only the initial/final reports are broadcasted when using
the new bit.
---
 lldb/include/lldb/Core/Debugger.h  | 10 +--
 lldb/include/lldb/Core/Progress.h  | 48 +-
 lldb/source/Core/Debugger.cpp  | 19 +++---
 lldb/source/Core/Progress.cpp  | 73 +++---
 lldb/unittests/Core/ProgressReportTest.cpp | 57 +
 5 files changed, 157 insertions(+), 50 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ba90eb6ed8fdf..b65ec1029ab24b 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -593,6 +593,7 @@ class Debugger : public 
std::enable_shared_from_this,
   friend class CommandInterpreter;
   friend class REPL;
   friend class Progress;
+  friend class ProgressManager;
 
   /// Report progress events.
   ///
@@ -623,10 +624,11 @@ class Debugger : public 
std::enable_shared_from_this,
   ///   debugger identifier that this progress should be delivered to. If this
   ///   optional parameter does not have a value, the progress will be
   ///   delivered to all debuggers.
-  static void ReportProgress(uint64_t progress_id, std::string title,
- std::string details, uint64_t completed,
- uint64_t total,
- std::optional debugger_id);
+  static void
+  ReportProgress(uint64_t progress_id, std::string title, std::string details,
+ uint64_t completed, uint64_t total,
+ std::optional debugger_id,
+ uint32_t progress_category_bit = eBroadcastBitProgress);
 
   static void ReportDiagnosticImpl(DiagnosticEventData::Type type,
std::string message,
diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index eb4d9f9d7af08e..d3077ef4823eac 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -9,10 +9,11 @@
 #ifndef LLDB_CORE_PROGRESS_H
 #define LLDB_CORE_PROGRESS_H
 
-#include "lldb/Utility/ConstString.h"
+#include "lldb/lldb-forward.h"
 #include "lldb/lldb-types.h"
 #include "llvm/ADT/StringMap.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -97,27 +98,37 @@ class Progress {
   /// Used to indicate a non-deterministic progress report
   static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX;
 
+  /// Use a struct to send data from a Progress object to
+  /// the progress manager.
+  struct ProgressData {
+/// Data belonging to this Progress event. This data is used by the 
Debugger
+/// to broadcast the event and by the ProgressManager for bookkeeping.
+std::string title;
+/// More specific information about the current file being displayed in the
+/// report.
+std::string details;
+/// A unique integer identifier for progress reporting.
+uint64_t progress_id;
+/// How much work ([0...m_total]) that has been completed.
+uint64_t completed;
+/// Total amount of work, use a std::nullopt in the constructor for non
+/// deterministic progress.
+uint64_t total;
+/// The optional debugger ID to report progress to. If this has no value
+/// then all debuggers will receive this event.
+std::optional debugger_id;
+  };
+
 private:
   void ReportProgress();
   static std::atomic g_id;
-  /// The title of the progress activity.
-  std::string m_title;
-  std::string m_details;
   std::mutex m_mutex;
-  /// A unique integer identifier for progress reporting.
-  const uint64_t m_id;
-  /// How much work ([0...m_total]) that has been completed.
-  uint64_t m_completed;
-  /// Total amount of work, use a std::nullopt in the constructor for non
-  /// deterministic progress.
-  uint64_t m_total;
-  /// The optional debugger ID to report progress to. If this has no value then
-  /// all debuggers will receive this event.
-  std::optional m_debugger_id;
   /// Set to true when progress has been reported where m_completed == m_total
   /// to ensure that we don't send progress updates after progress has
   /// completed.
   bool m_complete = false

[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)

2024-02-28 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/83069

>From 40caaa80180d4845393fc4b80ee2dc09b7c87a7e Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Tue, 20 Feb 2024 13:56:53 -0800
Subject: [PATCH] [lldb][progress] Hook up new broadcast bit and progress
 manager

This commit adds the functionality to broadcast events using the
`Debugger::eBroadcastProgressCategory`
bit (https://github.com/llvm/llvm-project/pull/81169) by keeping track of these
reports with the `ProgressManager`
class (https://github.com/llvm/llvm-project/pull/81319). The new bit is
used in such a way that it will only broadcast the initial and final
progress reports for specific progress categories that are managed by
the progress manager.

This commit also adds a new test to the progress report unit test that
checks that only the initial/final reports are broadcasted when using
the new bit.
---
 lldb/include/lldb/Core/Debugger.h  | 10 +--
 lldb/include/lldb/Core/Progress.h  | 47 +-
 lldb/source/Core/Debugger.cpp  | 19 +++---
 lldb/source/Core/Progress.cpp  | 73 +++---
 lldb/unittests/Core/ProgressReportTest.cpp | 57 +
 5 files changed, 156 insertions(+), 50 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ba90eb6ed8fdf..b65ec1029ab24b 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -593,6 +593,7 @@ class Debugger : public 
std::enable_shared_from_this,
   friend class CommandInterpreter;
   friend class REPL;
   friend class Progress;
+  friend class ProgressManager;
 
   /// Report progress events.
   ///
@@ -623,10 +624,11 @@ class Debugger : public 
std::enable_shared_from_this,
   ///   debugger identifier that this progress should be delivered to. If this
   ///   optional parameter does not have a value, the progress will be
   ///   delivered to all debuggers.
-  static void ReportProgress(uint64_t progress_id, std::string title,
- std::string details, uint64_t completed,
- uint64_t total,
- std::optional debugger_id);
+  static void
+  ReportProgress(uint64_t progress_id, std::string title, std::string details,
+ uint64_t completed, uint64_t total,
+ std::optional debugger_id,
+ uint32_t progress_category_bit = eBroadcastBitProgress);
 
   static void ReportDiagnosticImpl(DiagnosticEventData::Type type,
std::string message,
diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index eb4d9f9d7af08e..b2038a9ffd9317 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -9,10 +9,11 @@
 #ifndef LLDB_CORE_PROGRESS_H
 #define LLDB_CORE_PROGRESS_H
 
-#include "lldb/Utility/ConstString.h"
+#include "lldb/lldb-forward.h"
 #include "lldb/lldb-types.h"
 #include "llvm/ADT/StringMap.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -97,27 +98,36 @@ class Progress {
   /// Used to indicate a non-deterministic progress report
   static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX;
 
+/// Data belonging to this Progress event. This data is used by the 
Debugger
+/// to broadcast the event and by the ProgressManager for bookkeeping.
+  struct ProgressData {
+/// The title of the progress activity, also used as a category.
+std::string title;
+/// More specific information about the current file being displayed in the
+/// report.
+std::string details;
+/// A unique integer identifier for progress reporting.
+uint64_t progress_id;
+/// How much work ([0...m_total]) that has been completed.
+uint64_t completed;
+/// Total amount of work, use a std::nullopt in the constructor for non
+/// deterministic progress.
+uint64_t total;
+/// The optional debugger ID to report progress to. If this has no value
+/// then all debuggers will receive this event.
+std::optional debugger_id;
+  };
+
 private:
   void ReportProgress();
   static std::atomic g_id;
-  /// The title of the progress activity.
-  std::string m_title;
-  std::string m_details;
   std::mutex m_mutex;
-  /// A unique integer identifier for progress reporting.
-  const uint64_t m_id;
-  /// How much work ([0...m_total]) that has been completed.
-  uint64_t m_completed;
-  /// Total amount of work, use a std::nullopt in the constructor for non
-  /// deterministic progress.
-  uint64_t m_total;
-  /// The optional debugger ID to report progress to. If this has no value then
-  /// all debuggers will receive this event.
-  std::optional m_debugger_id;
   /// Set to true when progress has been reported where m_completed == m_total
   /// to ensure that we don't send progress updates after progress has
   /// completed.
   bool m_complete = false;
+  /// Data need

[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)

2024-02-28 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff f01ed3bc8884223bf3edbaad8d3685622444cbf5 
40caaa80180d4845393fc4b80ee2dc09b7c87a7e -- lldb/include/lldb/Core/Debugger.h 
lldb/include/lldb/Core/Progress.h lldb/source/Core/Debugger.cpp 
lldb/source/Core/Progress.cpp lldb/unittests/Core/ProgressReportTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index b2038a9ffd..450c0b4399 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -98,8 +98,8 @@ public:
   /// Used to indicate a non-deterministic progress report
   static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX;
 
-/// Data belonging to this Progress event. This data is used by the 
Debugger
-/// to broadcast the event and by the ProgressManager for bookkeeping.
+  /// Data belonging to this Progress event. This data is used by the Debugger
+  /// to broadcast the event and by the ProgressManager for bookkeeping.
   struct ProgressData {
 /// The title of the progress activity, also used as a category.
 std::string title;

``




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


[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)

2024-02-28 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/83069

>From f38204941062691bf3e3f6e57d8171a5c0258f77 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Tue, 20 Feb 2024 13:56:53 -0800
Subject: [PATCH] [lldb][progress] Hook up new broadcast bit and progress
 manager

This commit adds the functionality to broadcast events using the
`Debugger::eBroadcastProgressCategory`
bit (https://github.com/llvm/llvm-project/pull/81169) by keeping track of these
reports with the `ProgressManager`
class (https://github.com/llvm/llvm-project/pull/81319). The new bit is
used in such a way that it will only broadcast the initial and final
progress reports for specific progress categories that are managed by
the progress manager.

This commit also adds a new test to the progress report unit test that
checks that only the initial/final reports are broadcasted when using
the new bit.
---
 lldb/include/lldb/Core/Debugger.h  | 10 +--
 lldb/include/lldb/Core/Progress.h  | 47 +-
 lldb/source/Core/Debugger.cpp  | 19 +++---
 lldb/source/Core/Progress.cpp  | 73 +++---
 lldb/unittests/Core/ProgressReportTest.cpp | 57 +
 5 files changed, 156 insertions(+), 50 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ba90eb6ed8fdf..b65ec1029ab24b 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -593,6 +593,7 @@ class Debugger : public 
std::enable_shared_from_this,
   friend class CommandInterpreter;
   friend class REPL;
   friend class Progress;
+  friend class ProgressManager;
 
   /// Report progress events.
   ///
@@ -623,10 +624,11 @@ class Debugger : public 
std::enable_shared_from_this,
   ///   debugger identifier that this progress should be delivered to. If this
   ///   optional parameter does not have a value, the progress will be
   ///   delivered to all debuggers.
-  static void ReportProgress(uint64_t progress_id, std::string title,
- std::string details, uint64_t completed,
- uint64_t total,
- std::optional debugger_id);
+  static void
+  ReportProgress(uint64_t progress_id, std::string title, std::string details,
+ uint64_t completed, uint64_t total,
+ std::optional debugger_id,
+ uint32_t progress_category_bit = eBroadcastBitProgress);
 
   static void ReportDiagnosticImpl(DiagnosticEventData::Type type,
std::string message,
diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index eb4d9f9d7af08e..450c0b439910f2 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -9,10 +9,11 @@
 #ifndef LLDB_CORE_PROGRESS_H
 #define LLDB_CORE_PROGRESS_H
 
-#include "lldb/Utility/ConstString.h"
+#include "lldb/lldb-forward.h"
 #include "lldb/lldb-types.h"
 #include "llvm/ADT/StringMap.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -97,27 +98,36 @@ class Progress {
   /// Used to indicate a non-deterministic progress report
   static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX;
 
+  /// Data belonging to this Progress event. This data is used by the Debugger
+  /// to broadcast the event and by the ProgressManager for bookkeeping.
+  struct ProgressData {
+/// The title of the progress activity, also used as a category.
+std::string title;
+/// More specific information about the current file being displayed in the
+/// report.
+std::string details;
+/// A unique integer identifier for progress reporting.
+uint64_t progress_id;
+/// How much work ([0...m_total]) that has been completed.
+uint64_t completed;
+/// Total amount of work, use a std::nullopt in the constructor for non
+/// deterministic progress.
+uint64_t total;
+/// The optional debugger ID to report progress to. If this has no value
+/// then all debuggers will receive this event.
+std::optional debugger_id;
+  };
+
 private:
   void ReportProgress();
   static std::atomic g_id;
-  /// The title of the progress activity.
-  std::string m_title;
-  std::string m_details;
   std::mutex m_mutex;
-  /// A unique integer identifier for progress reporting.
-  const uint64_t m_id;
-  /// How much work ([0...m_total]) that has been completed.
-  uint64_t m_completed;
-  /// Total amount of work, use a std::nullopt in the constructor for non
-  /// deterministic progress.
-  uint64_t m_total;
-  /// The optional debugger ID to report progress to. If this has no value then
-  /// all debuggers will receive this event.
-  std::optional m_debugger_id;
   /// Set to true when progress has been reported where m_completed == m_total
   /// to ensure that we don't send progress updates after progress has
   /// completed.
   bool m_complete = false;
+  /// Data needed by

[Lldb-commits] [lldb] [lldb] Ignore swig warnings about shadowed overloads (PR #83317)

2024-02-28 Thread Alex Langford via lldb-commits

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

This specifically addresses the warnings:
$LLVM/lldb/include/lldb/API/SBCommandReturnObject.h:119: Warning 509: 
Overloaded method lldb::SBCommandReturnObject::PutCString(char const *) 
effectively ignored, $LLVM/lldb/include/lldb/API/SBCommandReturnObject.h:119: 
Warning 509: as it is shadowed by lldb::SBCommandReturnObject::PutCString(char 
const *,int).

There is exactly one declaration of SBCommandReturnObject::PutCString. The 
second parameter (of type `int`) has default value `-1`. Without investigating 
why SWIG believes there are 2 method declarations, I believe it is safe to 
ignore this warning. It does not appear to actually impact functionality in any 
way.

rdar://117744660

>From 76a634a1ad00e90983391cdd04588f92b5f15432 Mon Sep 17 00:00:00 2001
From: Alex Langford 
Date: Wed, 28 Feb 2024 10:58:33 -0800
Subject: [PATCH] [lldb] Ignore swig warnings about shadowed overloads

This specifically addresses the warnings:
$LLVM/lldb/include/lldb/API/SBCommandReturnObject.h:119: Warning 509: 
Overloaded method lldb::SBCommandReturnObject::PutCString(char const *) 
effectively ignored,
$LLVM/lldb/include/lldb/API/SBCommandReturnObject.h:119: Warning 509: as it is 
shadowed by lldb::SBCommandReturnObject::PutCString(char const *,int).

There is exactly one declaration of SBCommandReturnObject::PutCString.
The second parameter (of type `int`) has default value `-1`. Without
investigating why SWIG believes there are 2 method declarations, I
believe it is safe to ignore this warning. It does not appear to
actually impact functionality in any way.

rdar://117744660
---
 lldb/bindings/CMakeLists.txt | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lldb/bindings/CMakeLists.txt b/lldb/bindings/CMakeLists.txt
index b44ed59aa662b2..296eae1ae77f86 100644
--- a/lldb/bindings/CMakeLists.txt
+++ b/lldb/bindings/CMakeLists.txt
@@ -23,7 +23,11 @@ endif()
 
 set(SWIG_COMMON_FLAGS
   -c++
-  -w361,362 # Ignore warnings about ignored operator overloads
+  # Ignored warnings:
+  # 361: operator! ignored.
+  # 362: operator= ignored.
+  # 509: Overloaded method declaration effectively ignored, shadowed by 
previous declaration.
+  -w361,362,509
   -features autodoc
   -I${LLDB_SOURCE_DIR}/include
   -I${CMAKE_CURRENT_SOURCE_DIR}

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


[Lldb-commits] [lldb] [lldb] Ignore swig warnings about shadowed overloads (PR #83317)

2024-02-28 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Alex Langford (bulbazord)


Changes

This specifically addresses the warnings:
$LLVM/lldb/include/lldb/API/SBCommandReturnObject.h:119: Warning 509: 
Overloaded method lldb::SBCommandReturnObject::PutCString(char const *) 
effectively ignored, $LLVM/lldb/include/lldb/API/SBCommandReturnObject.h:119: 
Warning 509: as it is shadowed by lldb::SBCommandReturnObject::PutCString(char 
const *,int).

There is exactly one declaration of SBCommandReturnObject::PutCString. The 
second parameter (of type `int`) has default value `-1`. Without investigating 
why SWIG believes there are 2 method declarations, I believe it is safe to 
ignore this warning. It does not appear to actually impact functionality in any 
way.

rdar://117744660

---
Full diff: https://github.com/llvm/llvm-project/pull/83317.diff


1 Files Affected:

- (modified) lldb/bindings/CMakeLists.txt (+5-1) 


``diff
diff --git a/lldb/bindings/CMakeLists.txt b/lldb/bindings/CMakeLists.txt
index b44ed59aa662b2..296eae1ae77f86 100644
--- a/lldb/bindings/CMakeLists.txt
+++ b/lldb/bindings/CMakeLists.txt
@@ -23,7 +23,11 @@ endif()
 
 set(SWIG_COMMON_FLAGS
   -c++
-  -w361,362 # Ignore warnings about ignored operator overloads
+  # Ignored warnings:
+  # 361: operator! ignored.
+  # 362: operator= ignored.
+  # 509: Overloaded method declaration effectively ignored, shadowed by 
previous declaration.
+  -w361,362,509
   -features autodoc
   -I${LLDB_SOURCE_DIR}/include
   -I${CMAKE_CURRENT_SOURCE_DIR}

``




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


[Lldb-commits] [lldb] [lldb-dap] Deduplicate watchpoints starting at the same address on SetDataBreakpointsRequest. (PR #83192)

2024-02-28 Thread Jordan Rupprecht via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb-dap] Deduplicate watchpoints starting at the same address on SetDataBreakpointsRequest. (PR #83192)

2024-02-28 Thread Zequan Wu via lldb-commits

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


[Lldb-commits] [lldb] 2cacc7a - [lldb-dap] Deduplicate watchpoints starting at the same address on SetDataBreakpointsRequest. (#83192)

2024-02-28 Thread via lldb-commits

Author: Zequan Wu
Date: 2024-02-28T14:56:55-05:00
New Revision: 2cacc7a61095577ff42177373d46c8cb8df0cb1f

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

LOG: [lldb-dap] Deduplicate watchpoints starting at the same address on 
SetDataBreakpointsRequest. (#83192)

If a SetDataBreakpointsRequest contains a list data breakpoints which
have duplicate starting addresses, the current behaviour is returning
`{verified: true}` to both watchpoints with duplicated starting
addresses. This confuses the client and what actually happens in lldb is
the second one overwrite the first one.

This fixes it by letting the last watchpoint at given address have
`{verified: true}` and all previous watchpoints at the same address
should have `{verfied: false}` at response.

Added: 


Modified: 
lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py
lldb/tools/lldb-dap/Watchpoint.cpp
lldb/tools/lldb-dap/Watchpoint.h
lldb/tools/lldb-dap/lldb-dap.cpp

Removed: 




diff  --git 
a/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py 
b/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py
index 17cdad89aa6d10..52c0bbfb33dad8 100644
--- a/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py
+++ b/lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py
@@ -12,6 +12,51 @@ def setUp(self):
 lldbdap_testcase.DAPTestCaseBase.setUp(self)
 self.accessTypes = ["read", "write", "readWrite"]
 
+@skipIfWindows
+@skipIfRemote
+def test_duplicate_start_addresses(self):
+"""Test setDataBreakpoints with multiple watchpoints starting at the 
same addresses."""
+program = self.getBuildArtifact("a.out")
+self.build_and_launch(program)
+source = "main.cpp"
+first_loop_break_line = line_number(source, "// first loop breakpoint")
+self.set_source_breakpoints(source, [first_loop_break_line])
+self.continue_to_next_stop()
+self.dap_server.get_stackFrame()
+# Test setting write watchpoint using expressions: &x, arr+2
+response_x = self.dap_server.request_dataBreakpointInfo(0, "&x")
+response_arr_2 = self.dap_server.request_dataBreakpointInfo(0, "arr+2")
+# Test response from dataBreakpointInfo request.
+self.assertEquals(response_x["body"]["dataId"].split("/")[1], "4")
+self.assertEquals(response_x["body"]["accessTypes"], self.accessTypes)
+self.assertEquals(response_arr_2["body"]["dataId"].split("/")[1], "4")
+self.assertEquals(response_arr_2["body"]["accessTypes"], 
self.accessTypes)
+# The first one should be overwritten by the third one as they start at
+# the same address. This is indicated by returning {verified: False} 
for
+# the first one.
+dataBreakpoints = [
+{"dataId": response_x["body"]["dataId"], "accessType": "read"},
+{"dataId": response_arr_2["body"]["dataId"], "accessType": 
"write"},
+{"dataId": response_x["body"]["dataId"], "accessType": "write"},
+]
+set_response = 
self.dap_server.request_setDataBreakpoint(dataBreakpoints)
+self.assertEquals(
+set_response["body"]["breakpoints"],
+[{"verified": False}, {"verified": True}, {"verified": True}],
+)
+
+self.continue_to_next_stop()
+x_val = self.dap_server.get_local_variable_value("x")
+i_val = self.dap_server.get_local_variable_value("i")
+self.assertEquals(x_val, "2")
+self.assertEquals(i_val, "1")
+
+self.continue_to_next_stop()
+arr_2 = self.dap_server.get_local_variable_child("arr", "[2]")
+i_val = self.dap_server.get_local_variable_value("i")
+self.assertEquals(arr_2["value"], "42")
+self.assertEquals(i_val, "2")
+
 @skipIfWindows
 @skipIfRemote
 def test_expression(self):

diff  --git a/lldb/tools/lldb-dap/Watchpoint.cpp 
b/lldb/tools/lldb-dap/Watchpoint.cpp
index 2f176e0da84f15..21765509449140 100644
--- a/lldb/tools/lldb-dap/Watchpoint.cpp
+++ b/lldb/tools/lldb-dap/Watchpoint.cpp
@@ -16,17 +16,11 @@ Watchpoint::Watchpoint(const llvm::json::Object &obj) : 
BreakpointBase(obj) {
   llvm::StringRef dataId = GetString(obj, "dataId");
   std::string accessType = GetString(obj, "accessType").str();
   auto [addr_str, size_str] = dataId.split('/');
-  lldb::addr_t addr;
-  size_t size;
   llvm::to_integer(addr_str, addr, 16);
   llvm::to_integer(size_str, size);
-  lldb::SBWatchpointOptions options;
   options.SetWatchpointTypeRead(accessType != "write");
   if (accessType != "read")
 options.SetWatchpointTypeWrite(lldb::eWatchpointWriteTypeOnModify);
-  wp = g_dap.target.Watchpoin

[Lldb-commits] [lldb] Increase timeout to reduce test failure rate. (PR #83312)

2024-02-28 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo requested changes to this pull request.

could you create instead a variable at the base test class level that can be 
used by other DAP tests when setting timeouts? I'm pretty sure at least one 
other test file uses timeouts.

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


[Lldb-commits] [lldb] Increase timeout to reduce test failure rate. (PR #83312)

2024-02-28 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test][NFC] Add option to exclude third_party packages (PR #83191)

2024-02-28 Thread Jordan Rupprecht via lldb-commits

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


[Lldb-commits] [lldb] 249cf35 - [lldb][test][NFC] Add option to exclude third_party packages (#83191)

2024-02-28 Thread via lldb-commits

Author: Jordan Rupprecht
Date: 2024-02-28T15:00:41-06:00
New Revision: 249cf356ef21d0b6ed0d1fa962f3fc5a9e3fcc9e

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

LOG: [lldb][test][NFC] Add option to exclude third_party packages (#83191)

The goal here is to remove the third_party/Python/module tree, which
LLDB tests only use to `import pexpect`. This package is available on
`pip`, and I believe should not be hard to obtain.

However, in case it isn't easily available, deleting the tree right now
could cause disruption. This introduces a
`LLDB_TEST_USE_VENDOR_PACKAGES` cmake param that can be enabled, and the
tests will continue loading that tree. By default, it is enabled,
meaning there's really no change here. A followup change will disable it
by default once all known build bots are updated to include this
package. When disabled, an eager cmake check runs that makes sure
`pexpect` is available before waiting for the test to fail in an obscure
way.

Later, this option will go away, and when it does, we can delete the
tree too. Ideally this is not disruptive, and we can remove it in a week
or two.

Added: 


Modified: 
lldb/cmake/modules/LLDBConfig.cmake
lldb/test/API/lit.cfg.py
lldb/test/API/lit.site.cfg.py.in
lldb/test/CMakeLists.txt
lldb/use_lldb_suite_root.py
lldb/utils/lldb-dotest/CMakeLists.txt
lldb/utils/lldb-dotest/lldb-dotest.in

Removed: 




diff  --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index a758261073ac57..93c8ffe4b7d8a0 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -67,6 +67,8 @@ option(LLDB_SKIP_STRIP "Whether to skip stripping of binaries 
when installing ll
 option(LLDB_SKIP_DSYM "Whether to skip generating a dSYM when installing 
lldb." OFF)
 option(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS
   "Fail to configure if certain requirements are not met for testing." OFF)
+option(LLDB_TEST_USE_VENDOR_PACKAGES
+  "Use packages from lldb/third_party/Python/module instead of system deps." 
ON)
 
 set(LLDB_GLOBAL_INIT_DIRECTORY "" CACHE STRING
   "Path to the global lldbinit directory. Relative paths are resolved relative 
to the

diff  --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index 12675edc0fd3b9..f9497b632fc504 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -309,3 +309,6 @@ def delete_module_cache(path):
 # Propagate XDG_CACHE_HOME
 if "XDG_CACHE_HOME" in os.environ:
 config.environment["XDG_CACHE_HOME"] = os.environ["XDG_CACHE_HOME"]
+
+if is_configured("use_vendor_packages"):
+config.environment["LLDB_TEST_USE_VENDOR_PACKAGES"] = "1"

diff  --git a/lldb/test/API/lit.site.cfg.py.in 
b/lldb/test/API/lit.site.cfg.py.in
index 053331dc4881f7..c2602acd2ef85a 100644
--- a/lldb/test/API/lit.site.cfg.py.in
+++ b/lldb/test/API/lit.site.cfg.py.in
@@ -38,6 +38,7 @@ config.libcxx_include_target_dir = 
"@LIBCXX_GENERATED_INCLUDE_TARGET_DIR@"
 # The API tests use their own module caches.
 config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", 
"lldb-api")
 config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", 
"lldb-api")
+config.use_vendor_packages = @LLDB_TEST_USE_VENDOR_PACKAGES@
 
 # Plugins
 lldb_build_intel_pt = '@LLDB_BUILD_INTEL_PT@'

diff  --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 1aa8843b6a2e78..d8cbb24b6c9b81 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -26,6 +26,20 @@ if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
   endforeach()
 endif()
 
+# The "pexpect" package should come from the system environment, not from the
+# LLDB tree. However, we delay the deletion of it from the tree in case
+# users/buildbots don't have the package yet and need some time to install it.
+if (NOT LLDB_TEST_USE_VENDOR_PACKAGES)
+  lldb_find_python_module(pexpect)
+  if (NOT PY_pexpect_FOUND)
+message(FATAL_ERROR
+  "Python module 'pexpect' not found. Please install it via pip or via "
+  "your operating system's package manager. For a temporary workaround, "
+  "use a version from the LLDB tree with "
+  "`LLDB_TEST_USE_VENDOR_PACKAGES=ON`")
+  endif()
+endif()
+
 if(LLDB_BUILT_STANDALONE)
   # In order to run check-lldb-* we need the correct map_config directives in
   # llvm-lit. Because this is a standalone build, LLVM doesn't know about LLDB,
@@ -240,7 +254,8 @@ llvm_canonicalize_cmake_booleans(
   LLDB_HAS_LIBCXX
   LLDB_TOOL_LLDB_SERVER_BUILD
   LLDB_USE_SYSTEM_DEBUGSERVER
-  LLDB_IS_64_BITS)
+  LLDB_IS_64_BITS
+  LLDB_TEST_USE_VENDOR_PACKAGES)
 
 # Configure the individual test suites.
 add_subdirectory(API)

diff  --git a/lldb/use_lldb_suite_root.py b/lldb/use_lldb_suite_root.py
index fd42f63a3c7f30..b8f8acf5dd94a4 100

[Lldb-commits] [lldb] [lldb][test][NFC] Add option to exclude third_party packages (PR #83191)

2024-02-28 Thread Jordan Rupprecht via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Remove -d(ebug) mode from the lldb driver (PR #83330)

2024-02-28 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere created 
https://github.com/llvm/llvm-project/pull/83330

The -d(ebug) option broke 5 years ago when I migrated the driver to libOption. 
Since then, we were never check if the option is set. We were incorrectly 
toggling the internal variable (m_debug_mode) based on OPT_no_use_colors 
instead.

Given that the functionality doesn't seem particularly useful and nobody 
noticed it has been broken for 5 years, I'm just removing the flag.

>From 0d2e89188398a69bdeb2ea3378e2ba4c86d4e98e Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Wed, 28 Feb 2024 12:56:05 -0800
Subject: [PATCH] [lldb] Remove -d(ebug) mode from the lldb driver

The -d(ebug) option broke 5 years ago when I migrated the driver to
libOption. Since then, we were never check if the option is set. We were
incorrectly toggling the internal variable (m_debug_mode) based on
OPT_no_use_colors instead.

Given that the functionality doesn't seem particularly useful and nobody
noticed it has been broken for 5 years, I'm just removing the flag.
---
 lldb/test/Shell/Driver/TestHelp.test |  2 --
 lldb/tools/driver/Driver.cpp | 15 ---
 lldb/tools/driver/Driver.h   |  1 -
 3 files changed, 18 deletions(-)

diff --git a/lldb/test/Shell/Driver/TestHelp.test 
b/lldb/test/Shell/Driver/TestHelp.test
index 0f73fdf0374fdd..2521b31a618836 100644
--- a/lldb/test/Shell/Driver/TestHelp.test
+++ b/lldb/test/Shell/Driver/TestHelp.test
@@ -37,8 +37,6 @@ CHECK: --arch
 CHECK: -a
 CHECK: --core
 CHECK: -c
-CHECK: --debug
-CHECK: -d
 CHECK: --editor
 CHECK: -e
 CHECK: --file
diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index c63ff0ff597e5c..9286abb27e1332 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -188,7 +188,6 @@ SBError Driver::ProcessArgs(const opt::InputArgList &args, 
bool &exiting) {
   if (args.hasArg(OPT_no_use_colors)) {
 m_debugger.SetUseColor(false);
 WithColor::setAutoDetectFunction(disable_color);
-m_option_data.m_debug_mode = true;
   }
 
   if (args.hasArg(OPT_version)) {
@@ -455,16 +454,7 @@ int Driver::MainLoop() {
   // Process lldbinit files before handling any options from the command line.
   SBCommandReturnObject result;
   sb_interpreter.SourceInitFileInGlobalDirectory(result);
-  if (m_option_data.m_debug_mode) {
-result.PutError(m_debugger.GetErrorFile());
-result.PutOutput(m_debugger.GetOutputFile());
-  }
-
   sb_interpreter.SourceInitFileInHomeDirectory(result, m_option_data.m_repl);
-  if (m_option_data.m_debug_mode) {
-result.PutError(m_debugger.GetErrorFile());
-result.PutOutput(m_debugger.GetOutputFile());
-  }
 
   // Source the local .lldbinit file if it exists and we're allowed to source.
   // Here we want to always print the return object because it contains the
@@ -536,11 +526,6 @@ int Driver::MainLoop() {
 "or -s) are ignored in REPL mode.\n";
   }
 
-  if (m_option_data.m_debug_mode) {
-result.PutError(m_debugger.GetErrorFile());
-result.PutOutput(m_debugger.GetOutputFile());
-  }
-
   const bool handle_events = true;
   const bool spawn_thread = false;
 
diff --git a/lldb/tools/driver/Driver.h b/lldb/tools/driver/Driver.h
index d5779b3c2c91b5..83e0d8a41cfdb1 100644
--- a/lldb/tools/driver/Driver.h
+++ b/lldb/tools/driver/Driver.h
@@ -75,7 +75,6 @@ class Driver : public lldb::SBBroadcaster {
 std::vector m_after_file_commands;
 std::vector m_after_crash_commands;
 
-bool m_debug_mode = false;
 bool m_source_quietly = false;
 bool m_print_version = false;
 bool m_print_python_path = false;

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


[Lldb-commits] [lldb] [lldb] Remove -d(ebug) mode from the lldb driver (PR #83330)

2024-02-28 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

The -d(ebug) option broke 5 years ago when I migrated the driver to libOption. 
Since then, we were never check if the option is set. We were incorrectly 
toggling the internal variable (m_debug_mode) based on OPT_no_use_colors 
instead.

Given that the functionality doesn't seem particularly useful and nobody 
noticed it has been broken for 5 years, I'm just removing the flag.

---
Full diff: https://github.com/llvm/llvm-project/pull/83330.diff


3 Files Affected:

- (modified) lldb/test/Shell/Driver/TestHelp.test (-2) 
- (modified) lldb/tools/driver/Driver.cpp (-15) 
- (modified) lldb/tools/driver/Driver.h (-1) 


``diff
diff --git a/lldb/test/Shell/Driver/TestHelp.test 
b/lldb/test/Shell/Driver/TestHelp.test
index 0f73fdf0374fdd..2521b31a618836 100644
--- a/lldb/test/Shell/Driver/TestHelp.test
+++ b/lldb/test/Shell/Driver/TestHelp.test
@@ -37,8 +37,6 @@ CHECK: --arch
 CHECK: -a
 CHECK: --core
 CHECK: -c
-CHECK: --debug
-CHECK: -d
 CHECK: --editor
 CHECK: -e
 CHECK: --file
diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index c63ff0ff597e5c..9286abb27e1332 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -188,7 +188,6 @@ SBError Driver::ProcessArgs(const opt::InputArgList &args, 
bool &exiting) {
   if (args.hasArg(OPT_no_use_colors)) {
 m_debugger.SetUseColor(false);
 WithColor::setAutoDetectFunction(disable_color);
-m_option_data.m_debug_mode = true;
   }
 
   if (args.hasArg(OPT_version)) {
@@ -455,16 +454,7 @@ int Driver::MainLoop() {
   // Process lldbinit files before handling any options from the command line.
   SBCommandReturnObject result;
   sb_interpreter.SourceInitFileInGlobalDirectory(result);
-  if (m_option_data.m_debug_mode) {
-result.PutError(m_debugger.GetErrorFile());
-result.PutOutput(m_debugger.GetOutputFile());
-  }
-
   sb_interpreter.SourceInitFileInHomeDirectory(result, m_option_data.m_repl);
-  if (m_option_data.m_debug_mode) {
-result.PutError(m_debugger.GetErrorFile());
-result.PutOutput(m_debugger.GetOutputFile());
-  }
 
   // Source the local .lldbinit file if it exists and we're allowed to source.
   // Here we want to always print the return object because it contains the
@@ -536,11 +526,6 @@ int Driver::MainLoop() {
 "or -s) are ignored in REPL mode.\n";
   }
 
-  if (m_option_data.m_debug_mode) {
-result.PutError(m_debugger.GetErrorFile());
-result.PutOutput(m_debugger.GetOutputFile());
-  }
-
   const bool handle_events = true;
   const bool spawn_thread = false;
 
diff --git a/lldb/tools/driver/Driver.h b/lldb/tools/driver/Driver.h
index d5779b3c2c91b5..83e0d8a41cfdb1 100644
--- a/lldb/tools/driver/Driver.h
+++ b/lldb/tools/driver/Driver.h
@@ -75,7 +75,6 @@ class Driver : public lldb::SBBroadcaster {
 std::vector m_after_file_commands;
 std::vector m_after_crash_commands;
 
-bool m_debug_mode = false;
 bool m_source_quietly = false;
 bool m_print_version = false;
 bool m_print_python_path = false;

``




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


[Lldb-commits] [lldb] [lldb] Remove -d(ebug) mode from the lldb driver (PR #83330)

2024-02-28 Thread Med Ismail Bennani via lldb-commits

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

LGTM!

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


[Lldb-commits] [lldb] [lldb] Ignore swig warnings about shadowed overloads (PR #83317)

2024-02-28 Thread Med Ismail Bennani via lldb-commits

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

Yeay 🥳

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


[Lldb-commits] [lldb] Change `image list -r` so that it actually shows the ref count and whether the image is in the shared cache. (PR #83341)

2024-02-28 Thread via lldb-commits

https://github.com/jimingham created 
https://github.com/llvm/llvm-project/pull/83341

The help for the `-r` option to `image list` says:

   -r[] ( --ref-count=[] )
Display the reference count if the module is still in the shared 
module cache.

but that's not what it actually does.  It unconditionally shows the use_count 
for all Module shared pointers, regardless of whether they are still in the 
shared module cache or whether they are just in the ModuleCollection and other 
entities are keeping them alive.  That seems like a more useful behavior, but 
then it is also useful to know what's in the shared cache, so I changed this to:

   -r[] ( --ref-count=[] )
Display whether the module is still in the the shared module cache 
(Y/N), and its shared pointer use_count.

So instead of just `{5}` you will see `{Y 5}` if it is in the shared cache and 
`{N 5}` if not.

I didn't add tests for this because I'm not sure how much we want to fix shared 
cache behavior in the testsuite.

>From b95ffa364ecfc8593dc48a1986385d81cbeb05c2 Mon Sep 17 00:00:00 2001
From: Jim Ingham 
Date: Wed, 28 Feb 2024 13:12:46 -0800
Subject: [PATCH] Change `image list -r` so that it actually shows the ref
 count and whether the image is in the shared cache.

---
 lldb/source/Commands/CommandObjectTarget.cpp | 8 ++--
 lldb/source/Commands/Options.td  | 4 ++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index 45265577e8b61c..b2346c2402a81d 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -3376,15 +3376,19 @@ class CommandObjectTargetModulesList : public 
CommandObjectParsed {
 
   case 'r': {
 size_t ref_count = 0;
+char in_shared_cache = 'Y';
+
 ModuleSP module_sp(module->shared_from_this());
+if (!ModuleList::ModuleIsInCache(module))
+  in_shared_cache = 'N';
 if (module_sp) {
   // Take one away to make sure we don't count our local "module_sp"
   ref_count = module_sp.use_count() - 1;
 }
 if (width)
-  strm.Printf("{%*" PRIu64 "}", width, (uint64_t)ref_count);
+  strm.Printf("{%c %*" PRIu64 "}", in_shared_cache, width, 
(uint64_t)ref_count);
 else
-  strm.Printf("{%" PRIu64 "}", (uint64_t)ref_count);
+  strm.Printf("{%c %" PRIu64 "}", in_shared_cache, 
(uint64_t)ref_count);
   } break;
 
   case 's':
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index ad4321d9a386cc..91d5eea830dedf 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -936,8 +936,8 @@ let Command = "target modules list" in {
 OptionalArg<"Width">, Desc<"Display the modification time with optional "
 "width of the module.">;
   def target_modules_list_ref_count : Option<"ref-count", "r">, Group<1>,
-OptionalArg<"Width">, Desc<"Display the reference count if the module is "
-"still in the shared module cache.">;
+OptionalArg<"Width">, Desc<"Display whether the module is still in the "
+"the shared module cache (Y/N), and its shared pointer use_count.">;
   def target_modules_list_pointer : Option<"pointer", "p">, Group<1>,
 OptionalArg<"None">, Desc<"Display the module pointer.">;
   def target_modules_list_global : Option<"global", "g">, Group<1>,

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


[Lldb-commits] [lldb] Change `image list -r` so that it actually shows the ref count and whether the image is in the shared cache. (PR #83341)

2024-02-28 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (jimingham)


Changes

The help for the `-r` option to `image list` says:

   -r[] ( --ref-count=[] )
Display the reference count if the module is still in the shared 
module cache.

but that's not what it actually does.  It unconditionally shows the use_count 
for all Module shared pointers, regardless of whether they are still in the 
shared module cache or whether they are just in the ModuleCollection and other 
entities are keeping them alive.  That seems like a more useful behavior, but 
then it is also useful to know what's in the shared cache, so I changed this to:

   -r[] ( --ref-count=[] )
Display whether the module is still in the the shared module cache 
(Y/N), and its shared pointer use_count.

So instead of just `{5}` you will see `{Y 5}` if it is in the shared cache and 
`{N 5}` if not.

I didn't add tests for this because I'm not sure how much we want to fix shared 
cache behavior in the testsuite.

---
Full diff: https://github.com/llvm/llvm-project/pull/83341.diff


2 Files Affected:

- (modified) lldb/source/Commands/CommandObjectTarget.cpp (+6-2) 
- (modified) lldb/source/Commands/Options.td (+2-2) 


``diff
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index 45265577e8b61c..b2346c2402a81d 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -3376,15 +3376,19 @@ class CommandObjectTargetModulesList : public 
CommandObjectParsed {
 
   case 'r': {
 size_t ref_count = 0;
+char in_shared_cache = 'Y';
+
 ModuleSP module_sp(module->shared_from_this());
+if (!ModuleList::ModuleIsInCache(module))
+  in_shared_cache = 'N';
 if (module_sp) {
   // Take one away to make sure we don't count our local "module_sp"
   ref_count = module_sp.use_count() - 1;
 }
 if (width)
-  strm.Printf("{%*" PRIu64 "}", width, (uint64_t)ref_count);
+  strm.Printf("{%c %*" PRIu64 "}", in_shared_cache, width, 
(uint64_t)ref_count);
 else
-  strm.Printf("{%" PRIu64 "}", (uint64_t)ref_count);
+  strm.Printf("{%c %" PRIu64 "}", in_shared_cache, 
(uint64_t)ref_count);
   } break;
 
   case 's':
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index ad4321d9a386cc..91d5eea830dedf 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -936,8 +936,8 @@ let Command = "target modules list" in {
 OptionalArg<"Width">, Desc<"Display the modification time with optional "
 "width of the module.">;
   def target_modules_list_ref_count : Option<"ref-count", "r">, Group<1>,
-OptionalArg<"Width">, Desc<"Display the reference count if the module is "
-"still in the shared module cache.">;
+OptionalArg<"Width">, Desc<"Display whether the module is still in the "
+"the shared module cache (Y/N), and its shared pointer use_count.">;
   def target_modules_list_pointer : Option<"pointer", "p">, Group<1>,
 OptionalArg<"None">, Desc<"Display the module pointer.">;
   def target_modules_list_global : Option<"global", "g">, Group<1>,

``




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


[Lldb-commits] [lldb] Change `image list -r` so that it actually shows the ref count and whether the image is in the shared cache. (PR #83341)

2024-02-28 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff e427e934f677567f8184ff900cb4cbdb8cf21a21 
b95ffa364ecfc8593dc48a1986385d81cbeb05c2 -- 
lldb/source/Commands/CommandObjectTarget.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index b2346c2402..0d52fde961 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -3377,7 +3377,7 @@ protected:
   case 'r': {
 size_t ref_count = 0;
 char in_shared_cache = 'Y';
-
+
 ModuleSP module_sp(module->shared_from_this());
 if (!ModuleList::ModuleIsInCache(module))
   in_shared_cache = 'N';
@@ -3386,7 +3386,8 @@ protected:
   ref_count = module_sp.use_count() - 1;
 }
 if (width)
-  strm.Printf("{%c %*" PRIu64 "}", in_shared_cache, width, 
(uint64_t)ref_count);
+  strm.Printf("{%c %*" PRIu64 "}", in_shared_cache, width,
+  (uint64_t)ref_count);
 else
   strm.Printf("{%c %" PRIu64 "}", in_shared_cache, 
(uint64_t)ref_count);
   } break;

``




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


[Lldb-commits] [lldb] [lldb] Ignore swig warnings about shadowed overloads (PR #83317)

2024-02-28 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] Change `image list -r` so that it actually shows the ref count and whether the image is in the shared cache. (PR #83341)

2024-02-28 Thread Med Ismail Bennani via lldb-commits

medismailben wrote:

Does it make sense to have an image multiple times in the shared cache ? If 
not, instead of saying `{Y/N count}` what about printing `{location(shared 
cache/module collection)} and only print it ref count if it's not in the shared 
cache ?

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


[Lldb-commits] [lldb] [lldb] Remove -d(ebug) mode from the lldb driver (PR #83330)

2024-02-28 Thread Alex Langford via lldb-commits

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

:)

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


[Lldb-commits] [lldb] [lldb] Fix nullptr dereference on running x86 binary with x86-disabled llvm (PR #82603)

2024-02-28 Thread Daniil Kovalev via lldb-commits

kovdan01 wrote:

> tbh I have no problems with the patch, but I think it's fixing something that 
> I think should be reconsidered altogether, I'm interested to hear more about 
> what the use case looks like that led to this being a problem.

@jasonmolenda The use case is very simple, describing it "as is". I was working 
on AArch64-specific stuff in lldb in downstream and revealed an x86-related 
issue while reading the code (see 
https://github.com/llvm/llvm-project/pull/82364). When working on the latter 
issue, I tried to run a random x86-64 executable inside lldb and got this 
error. It occurs literally on the simplest use case:

1. run `lldb /usr/bin/ls`
2. inside lldb, hit `r` to run
3. get the nullptr dereference described

Yes, it's *that* simple.

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


[Lldb-commits] [lldb] Change `image list -r` so that it actually shows the ref count and whether the image is in the shared cache. (PR #83341)

2024-02-28 Thread Med Ismail Bennani via lldb-commits

medismailben wrote:

> Does it make sense to have an image multiple times in the shared cache ? If 
> not, instead of saying `{Y/N count}` what about printing `{location(shared 
> cache/module collection)}` and only print it ref count if it's not in the 
> shared cache ?

My bad, I thought you were talking about the `dyld` shared cache as opposed to 
the lldb shared module cache. LGTM then.

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


[Lldb-commits] [lldb] Change `image list -r` so that it actually shows the ref count and whether the image is in the shared cache. (PR #83341)

2024-02-28 Thread Med Ismail Bennani via lldb-commits

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


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


[Lldb-commits] [lldb] Fix interactive use of "command script add". (PR #83350)

2024-02-28 Thread via lldb-commits

https://github.com/jimingham created 
https://github.com/llvm/llvm-project/pull/83350

There was a think-o in a previous commit that made us only able to define 1 
line commands when using command script add interactively.

There was also no test for this feature, so I fixed the think-o and added a 
test.

>From 76eeb252b1f5fa71a68b439c84d13c8bcf042da7 Mon Sep 17 00:00:00 2001
From: Jim Ingham 
Date: Wed, 28 Feb 2024 14:25:55 -0800
Subject: [PATCH] Fix interactive use of "command script add".

There was a think-o in a previous commit that made us only
able to define 1 line commands when using command script add
interactively.

There was also no test for this feature, so I fixed the think-o
and added a test.
---
 .../Python/ScriptInterpreterPython.cpp   |  2 +-
 .../commands/command/script/TestCommandScript.py | 16 
 .../API/commands/command/script/cmd_file.lldb|  4 
 3 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 lldb/test/API/commands/command/script/cmd_file.lldb

diff --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index a1ad3f569ec71a..ce52f359524785 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -1417,7 +1417,7 @@ bool 
ScriptInterpreterPythonImpl::GenerateScriptAliasFunction(
   sstr.Printf("def %s (debugger, args, exe_ctx, result, internal_dict):",
   auto_generated_function_name.c_str());
 
-  if (!GenerateFunction(sstr.GetData(), user_input, /*is_callback=*/true)
+  if (!GenerateFunction(sstr.GetData(), user_input, /*is_callback=*/false)
.Success())
 return false;
 
diff --git a/lldb/test/API/commands/command/script/TestCommandScript.py 
b/lldb/test/API/commands/command/script/TestCommandScript.py
index 850552032902fd..21ebfce2f3c437 100644
--- a/lldb/test/API/commands/command/script/TestCommandScript.py
+++ b/lldb/test/API/commands/command/script/TestCommandScript.py
@@ -216,3 +216,19 @@ def test_persistence(self):
 # The result object will be replaced by an empty result object (in the
 # "Started" state).
 self.expect("script str(persistence.result_copy)", substrs=["Started"])
+
+def test_interactive(self):
+"""
+Test that we can add multiple lines interactively.
+"""
+interp = self.dbg.GetCommandInterpreter()
+cmd_file = self.getSourcePath("cmd_file.lldb")
+result = lldb.SBCommandReturnObject()
+interp.HandleCommand(f"command source {cmd_file}", result)
+self.assertCommandReturn(result, "Sourcing the command should cause no 
errors.")
+self.assertTrue(interp.UserCommandExists("my_cmd"), "Command defined.")
+interp.HandleCommand("my_cmd", result)
+self.assertCommandReturn(result, "Running the command succeeds")
+self.assertIn("My Command Result", result.GetOutput(), "Command was 
correct")
+
+
diff --git a/lldb/test/API/commands/command/script/cmd_file.lldb 
b/lldb/test/API/commands/command/script/cmd_file.lldb
new file mode 100644
index 00..1589a7cfe0b8d9
--- /dev/null
+++ b/lldb/test/API/commands/command/script/cmd_file.lldb
@@ -0,0 +1,4 @@
+command script add my_cmd
+result.PutCString("My Command Result")
+result.SetStatus(lldb.eReturnStatusSuccessFinishResult)
+DONE

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


[Lldb-commits] [lldb] Fix interactive use of "command script add". (PR #83350)

2024-02-28 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (jimingham)


Changes

There was a think-o in a previous commit that made us only able to define 1 
line commands when using command script add interactively.

There was also no test for this feature, so I fixed the think-o and added a 
test.

---
Full diff: https://github.com/llvm/llvm-project/pull/83350.diff


3 Files Affected:

- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (+1-1) 
- (modified) lldb/test/API/commands/command/script/TestCommandScript.py (+16) 
- (added) lldb/test/API/commands/command/script/cmd_file.lldb (+4) 


``diff
diff --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index a1ad3f569ec71a..ce52f359524785 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -1417,7 +1417,7 @@ bool 
ScriptInterpreterPythonImpl::GenerateScriptAliasFunction(
   sstr.Printf("def %s (debugger, args, exe_ctx, result, internal_dict):",
   auto_generated_function_name.c_str());
 
-  if (!GenerateFunction(sstr.GetData(), user_input, /*is_callback=*/true)
+  if (!GenerateFunction(sstr.GetData(), user_input, /*is_callback=*/false)
.Success())
 return false;
 
diff --git a/lldb/test/API/commands/command/script/TestCommandScript.py 
b/lldb/test/API/commands/command/script/TestCommandScript.py
index 850552032902fd..21ebfce2f3c437 100644
--- a/lldb/test/API/commands/command/script/TestCommandScript.py
+++ b/lldb/test/API/commands/command/script/TestCommandScript.py
@@ -216,3 +216,19 @@ def test_persistence(self):
 # The result object will be replaced by an empty result object (in the
 # "Started" state).
 self.expect("script str(persistence.result_copy)", substrs=["Started"])
+
+def test_interactive(self):
+"""
+Test that we can add multiple lines interactively.
+"""
+interp = self.dbg.GetCommandInterpreter()
+cmd_file = self.getSourcePath("cmd_file.lldb")
+result = lldb.SBCommandReturnObject()
+interp.HandleCommand(f"command source {cmd_file}", result)
+self.assertCommandReturn(result, "Sourcing the command should cause no 
errors.")
+self.assertTrue(interp.UserCommandExists("my_cmd"), "Command defined.")
+interp.HandleCommand("my_cmd", result)
+self.assertCommandReturn(result, "Running the command succeeds")
+self.assertIn("My Command Result", result.GetOutput(), "Command was 
correct")
+
+
diff --git a/lldb/test/API/commands/command/script/cmd_file.lldb 
b/lldb/test/API/commands/command/script/cmd_file.lldb
new file mode 100644
index 00..1589a7cfe0b8d9
--- /dev/null
+++ b/lldb/test/API/commands/command/script/cmd_file.lldb
@@ -0,0 +1,4 @@
+command script add my_cmd
+result.PutCString("My Command Result")
+result.SetStatus(lldb.eReturnStatusSuccessFinishResult)
+DONE

``




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


[Lldb-commits] [lldb] Fix interactive use of "command script add". (PR #83350)

2024-02-28 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
4df364bc93af49ae413ec1ae8328f34ac70730c4...76eeb252b1f5fa71a68b439c84d13c8bcf042da7
 lldb/test/API/commands/command/script/TestCommandScript.py
``





View the diff from darker here.


``diff
--- TestCommandScript.py2024-02-28 22:25:55.00 +
+++ TestCommandScript.py2024-02-28 22:30:52.097582 +
@@ -228,7 +228,5 @@
 self.assertCommandReturn(result, "Sourcing the command should cause no 
errors.")
 self.assertTrue(interp.UserCommandExists("my_cmd"), "Command defined.")
 interp.HandleCommand("my_cmd", result)
 self.assertCommandReturn(result, "Running the command succeeds")
 self.assertIn("My Command Result", result.GetOutput(), "Command was 
correct")
-
-

``




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


[Lldb-commits] [lldb] [lldb][X86] Fix setting target features in ClangExpressionParser (PR #82364)

2024-02-28 Thread Daniil Kovalev via lldb-commits

kovdan01 wrote:

> Would this change be observable by a test?

@adrian-prantl Theoretically, it should be: in 
`ClangExpressionParser::ClangExpressionParser`, we try to hardcode sse and sse2 
for both x86 and x86_64, while in `X86TargetInfo::initFeatureMap`, sse2 
(implying sse) is only hardcoded for x86_64. So, for x86 the observable 
behavior should change.

Unfortunately, I'm not sure where and how this could be tested. I suppose the 
proper place for such a test is somewhere in lldb/unittests/Expression, but I 
don't see existing tests which check similar stuff. Please let me know if I 
miss something. 

@Michael137 would be glad to see your thoughts on this.

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


[Lldb-commits] [lldb] [lldb] Fix nullptr dereference on running x86 binary with x86-disabled llvm (PR #82603)

2024-02-28 Thread Daniil Kovalev via lldb-commits

kovdan01 wrote:

> Can this code be hit when using an x86 core file?

Thanks for suggestion! I'll try that and notify here if such approach succeeded.

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


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-28 Thread Mehdi Amini via lldb-commits


@@ -209,25 +231,66 @@ class ThreadPool {
   /// Number of threads active for tasks in the given group (only non-zero).
   DenseMap ActiveGroups;
 
-#if LLVM_ENABLE_THREADS // avoids warning for unused variable
   /// Signal for the destruction of the pool, asking thread to exit.
   bool EnableFlag = true;
-#endif
 
   const ThreadPoolStrategy Strategy;
 
   /// Maximum number of threads to potentially grow this pool to.
   const unsigned MaxThreadCount;
 };
 
+/// A non-threaded implementation.
+class SingleThreadExecutor : public ThreadPoolInterface {

joker-eph wrote:

I was trying to use as little as possible so that the code is always at least 
"parsed" and we are less likely to break it (and also my IDE does not gray this 
entirely as a comment because of the macro).

But this is a weak argument, happy to restore a big `#if LLVM_ENABLE_THREADS` 
`#else` around the two classes.

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


[Lldb-commits] [lldb] d3173f4 - [lldb] Remove -d(ebug) mode from the lldb driver (#83330)

2024-02-28 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-02-28T15:23:55-08:00
New Revision: d3173f4ab61c17337908eb7df3f1c515ddcd428c

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

LOG: [lldb] Remove -d(ebug) mode from the lldb driver (#83330)

The -d(ebug) option broke 5 years ago when I migrated the driver to
libOption. Since then, we were never check if the option is set. We were
incorrectly toggling the internal variable (m_debug_mode) based on
OPT_no_use_colors instead.

Given that the functionality doesn't seem particularly useful and nobody
noticed it has been broken for 5 years, I'm just removing the flag.

Added: 


Modified: 
lldb/test/Shell/Driver/TestHelp.test
lldb/tools/driver/Driver.cpp
lldb/tools/driver/Driver.h

Removed: 




diff  --git a/lldb/test/Shell/Driver/TestHelp.test 
b/lldb/test/Shell/Driver/TestHelp.test
index 0f73fdf0374fdd..2521b31a618836 100644
--- a/lldb/test/Shell/Driver/TestHelp.test
+++ b/lldb/test/Shell/Driver/TestHelp.test
@@ -37,8 +37,6 @@ CHECK: --arch
 CHECK: -a
 CHECK: --core
 CHECK: -c
-CHECK: --debug
-CHECK: -d
 CHECK: --editor
 CHECK: -e
 CHECK: --file

diff  --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index c63ff0ff597e5c..9286abb27e1332 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -188,7 +188,6 @@ SBError Driver::ProcessArgs(const opt::InputArgList &args, 
bool &exiting) {
   if (args.hasArg(OPT_no_use_colors)) {
 m_debugger.SetUseColor(false);
 WithColor::setAutoDetectFunction(disable_color);
-m_option_data.m_debug_mode = true;
   }
 
   if (args.hasArg(OPT_version)) {
@@ -455,16 +454,7 @@ int Driver::MainLoop() {
   // Process lldbinit files before handling any options from the command line.
   SBCommandReturnObject result;
   sb_interpreter.SourceInitFileInGlobalDirectory(result);
-  if (m_option_data.m_debug_mode) {
-result.PutError(m_debugger.GetErrorFile());
-result.PutOutput(m_debugger.GetOutputFile());
-  }
-
   sb_interpreter.SourceInitFileInHomeDirectory(result, m_option_data.m_repl);
-  if (m_option_data.m_debug_mode) {
-result.PutError(m_debugger.GetErrorFile());
-result.PutOutput(m_debugger.GetOutputFile());
-  }
 
   // Source the local .lldbinit file if it exists and we're allowed to source.
   // Here we want to always print the return object because it contains the
@@ -536,11 +526,6 @@ int Driver::MainLoop() {
 "or -s) are ignored in REPL mode.\n";
   }
 
-  if (m_option_data.m_debug_mode) {
-result.PutError(m_debugger.GetErrorFile());
-result.PutOutput(m_debugger.GetOutputFile());
-  }
-
   const bool handle_events = true;
   const bool spawn_thread = false;
 

diff  --git a/lldb/tools/driver/Driver.h b/lldb/tools/driver/Driver.h
index d5779b3c2c91b5..83e0d8a41cfdb1 100644
--- a/lldb/tools/driver/Driver.h
+++ b/lldb/tools/driver/Driver.h
@@ -75,7 +75,6 @@ class Driver : public lldb::SBBroadcaster {
 std::vector m_after_file_commands;
 std::vector m_after_crash_commands;
 
-bool m_debug_mode = false;
 bool m_source_quietly = false;
 bool m_print_version = false;
 bool m_print_python_path = false;



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


[Lldb-commits] [lldb] [lldb] Remove -d(ebug) mode from the lldb driver (PR #83330)

2024-02-28 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] Change `image list -r` so that it actually shows the ref count and whether the image is in the shared cache. (PR #83341)

2024-02-28 Thread Alex Langford via lldb-commits

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


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


[Lldb-commits] [lldb] Fix interactive use of "command script add". (PR #83350)

2024-02-28 Thread Alex Langford via lldb-commits

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

Thinkos are the most insidious bugs. Nice catch.

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


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-28 Thread Alexandre Ganea via lldb-commits


@@ -209,25 +231,66 @@ class ThreadPool {
   /// Number of threads active for tasks in the given group (only non-zero).
   DenseMap ActiveGroups;
 
-#if LLVM_ENABLE_THREADS // avoids warning for unused variable
   /// Signal for the destruction of the pool, asking thread to exit.
   bool EnableFlag = true;
-#endif
 
   const ThreadPoolStrategy Strategy;
 
   /// Maximum number of threads to potentially grow this pool to.
   const unsigned MaxThreadCount;
 };
 
+/// A non-threaded implementation.
+class SingleThreadExecutor : public ThreadPoolInterface {

aganea wrote:

In that case, do you think we can add or extend some of the existing unit 
tests, to exercise the `SingleThreadExecutor` explicitly?

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


  1   2   >