[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-03-07 Thread David Spickett via lldb-commits


@@ -1925,6 +1959,17 @@ void Debugger::CancelForwardEvents(const ListenerSP 
&listener_sp) {
   m_forward_listener_sp.reset();
 }
 
+bool Debugger::StatuslineSupported() {
+  if (GetShowStatusline()) {
+if (lldb::LockableStreamFileSP stream_sp = GetOutputStreamSP()) {
+  File &file = stream_sp->GetUnlockedFile();
+  return file.GetIsInteractive() && file.GetIsRealTerminal() &&
+ file.GetIsTerminalWithColors();

DavidSpickett wrote:

The status bar does work with use-color set to false, but changing it does not 
redraw the status bar until something else forces it to. Should it?

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


[Lldb-commits] [lldb] [LLDB][Telemetry]Define TargetInfo for collecting data about a target (PR #127834)

2025-03-07 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/127834

>From 0d6a36d84df50ccb9eef9ef3dd6f59d4299edeac Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Wed, 19 Feb 2025 12:47:57 -0500
Subject: [PATCH 1/9] [LLDB][Telemetry]Define TargetInfo for collecting data
 about a target

---
 lldb/include/lldb/Core/Telemetry.h | 86 +-
 lldb/source/Core/Telemetry.cpp | 99 ++
 2 files changed, 170 insertions(+), 15 deletions(-)

diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
index b72556ecaf3c9..4be81951254de 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -13,6 +13,7 @@
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Utility/StructuredData.h"
 #include "lldb/lldb-forward.h"
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
@@ -29,6 +30,9 @@ namespace telemetry {
 
 struct LLDBEntryKind : public ::llvm::telemetry::EntryKind {
   static const llvm::telemetry::KindType BaseInfo = 0b11000;
+  static const KindType TargetInfo = 0b11010;
+  // There are other entries in between (added in separate PRs)
+  static const llvm::telemetry::KindType MiscInfo = 0b0;
 };
 
 /// Defines a convenient type for timestamp of various events.
@@ -56,14 +60,88 @@ struct LLDBBaseTelemetryInfo : public 
llvm::telemetry::TelemetryInfo {
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 };
 
+/// Describes an exit status.
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct TargetTelemetryInfo : public LldbBaseTelemetryInfo {
+  lldb::ModuleSP exec_mod;
+  Target *target_ptr;
+
+  // The same as the executable-module's UUID.
+  std::string target_uuid;
+  std::string file_format;
+
+  std::string binary_path;
+  size_t binary_size;
+
+  std::optional exit_desc;
+  TargetTelemetryInfo() = default;
+
+  TargetTelemetryInfo(const TargetTelemetryInfo &other) {
+exec_mod = other.exec_mod;
+target_uuid = other.target_uuid;
+file_format = other.file_format;
+binary_path = other.binary_path;
+binary_size = other.binary_size;
+exit_desc = other.exit_desc;
+  }
+
+  KindType getKind() const override { return LldbEntryKind::TargetInfo; }
+
+  static bool classof(const TelemetryInfo *T) {
+if (T == nullptr)
+  return false;
+return T->getKind() == LldbEntryKind::TargetInfo;
+  }
+
+  void serialize(Serializer &serializer) const override;
+};
+
+/// The "catch-all" entry to store a set of non-standard data, such as
+/// error-messages, etc.
+struct MiscTelemetryInfo : public LLDBBaseTelemetryInfo {
+  /// If the event is/can be associated with a target entry,
+  /// this field contains that target's UUID.
+  ///  otherwise.
+  std::string target_uuid;
+
+  /// Set of key-value pairs for any optional (or impl-specific) data
+  std::map meta_data;
+
+  MiscTelemetryInfo() = default;
+
+  MiscTelemetryInfo(const MiscTelemetryInfo &other) {
+target_uuid = other.target_uuid;
+meta_data = other.meta_data;
+  }
+
+  llvm::telemetry::KindType getKind() const override {
+return LLDBEntryKind::MiscInfo;
+  }
+
+  static bool classof(const llvm::telemetry::TelemetryInfo *T) {
+return T->getKind() == LLDBEntryKind::MiscInfo;
+  }
+
+  void serialize(llvm::telemetry::Serializer &serializer) const override;
+};
+
 /// The base Telemetry manager instance in LLDB.
 /// This class declares additional instrumentation points
 /// applicable to LLDB.
-class TelemetryManager : public llvm::telemetry::Manager {
+class TelemetryMager : public llvm::telemetry::Manager {
 public:
   llvm::Error preDispatch(llvm::telemetry::TelemetryInfo *entry) override;
 
-  virtual llvm::StringRef GetInstanceName() const = 0;
+  const llvm::telemetry::Config *getConfig();
+
+  virtual void AtMainExecutableLoadStart(TargetInfo * entry);
+  virtual void AtMainExecutableLoadEnd(TargetInfo *entry);
+
+  virtual llvm::StringRef GetInstanceName() const = 0;
   static TelemetryManager *getInstance();
 
 protected:
@@ -73,6 +151,10 @@ class TelemetryManager : public llvm::telemetry::Manager {
 
 private:
   std::unique_ptr m_config;
+  // Each debugger is assigned a unique ID (session_id).
+  // All TelemetryInfo entries emitted for the same debugger instance
+  // will get the same session_id.
+  llvm::DenseMap session_ids;
   static std::unique_ptr g_instance;
 };
 
diff --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp
index 5222f76704f91..da7aee01680fc 100644
--- a/lldb/source/Core/Telemetry.cpp
+++ b/lldb/source/Core/Telemetry.cpp
@@ -10,14 +10,20 @@
 
 #ifdef LLVM_BUILD_TELEMETRY
 
-#include "lldb/Core/Telemetry.h"
 #include "lldb/Core/Debugger.h"
+#include "lldb/Core/Telemetry.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Target/Process.h"
+#include "lld

[Lldb-commits] [lldb] [lldb-dap] Restore the override FD used by the output redirect on stop. (PR #129964)

2025-03-07 Thread John Harrison via lldb-commits

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


[Lldb-commits] [lldb] [LLDB][Minidump]Update MinidumpFileBuilder to read and write in chunks (PR #129307)

2025-03-07 Thread via lldb-commits


@@ -969,6 +969,84 @@ Status MinidumpFileBuilder::DumpDirectories() const {
   return error;
 }
 
+Status MinidumpFileBuilder::ReadWriteMemoryInChunks(
+const std::unique_ptr &data_up,
+const lldb_private::CoreFileMemoryRange &range, uint64_t *bytes_read) {
+  if (!data_up)
+return Status::FromErrorString("No buffer supplied to read memory.");
+  Log *log = GetLog(LLDBLog::Object);
+  const lldb::addr_t addr = range.range.start();
+  const lldb::addr_t size = range.range.size();
+  // First we set the byte tally to 0, so if we do exit gracefully
+  // the caller doesn't think the random garbage on the stack is a
+  // success.
+  if (bytes_read)
+*bytes_read = 0;
+
+  uint64_t bytes_remaining = size;
+  uint64_t total_bytes_read = 0;
+  Status error;
+  while (bytes_remaining > 0) {
+// Get the next read chunk size as the minimum of the remaining bytes and
+// the write chunk max size.
+const size_t bytes_to_read =
+std::min(bytes_remaining, MAX_WRITE_CHUNK_SIZE);

jeffreytan81 wrote:

I am not a big fan of this -- you are trying to ensure the reading won't exceed 
`data_up` buffer size, then you should use `data_up->GetSize()` here instead of 
`MAX_WRITE_CHUNK_SIZE`. What is the `data_up` is smaller than 
`MAX_WRITE_CHUNK_SIZE`? Then you are relying on the fact that `size` from the 
range ensures `data_up` size. You can see there are two much coupling logic 
between caller and callee here. 

I would change to `std::min(bytes_remaining, data_up->GetSize());`. That's the 
purpose of passing `data_up` into this function anyway, otherwise, we should 
pass `data_up->GetBytes()` into this function.

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


[Lldb-commits] [lldb] [lldb-dap] Add process picker command to VS Code extension (PR #128943)

2025-03-07 Thread Matthew Bastien via lldb-commits


@@ -65,6 +65,19 @@ This will attach to a process `a.out` whose process ID is 
123:
 }
 ```
 
+You can also use the variable substituion `${command:PickProcess}` to select a
+process at the start of the debug session instead of setting the pid manually:
+
+```javascript
+{
+  "type": "lldb-dap",
+  "request": "attach",
+  "name": "Attach to PID",
+  "program": "/tmp/a.out",

matthewbastien wrote:

Whoops. Copy and paste issue. Good catch!

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


[Lldb-commits] [lldb] [LLDB][Minidump]Update MinidumpFileBuilder to read and write in chunks (PR #129307)

2025-03-07 Thread via lldb-commits


@@ -969,12 +969,83 @@ Status MinidumpFileBuilder::DumpDirectories() const {
   return error;
 }
 
-static uint64_t
-GetLargestRangeSize(const std::vector &ranges) {
-  uint64_t max_size = 0;
-  for (const auto &core_range : ranges)
-max_size = std::max(max_size, core_range.range.size());
-  return max_size;
+Status MinidumpFileBuilder::ReadWriteMemoryInChunks(
+const lldb_private::CoreFileMemoryRange &range, uint64_t *bytes_read) {
+  Log *log = GetLog(LLDBLog::Object);
+  lldb::addr_t addr = range.range.start();
+  lldb::addr_t size = range.range.size();
+  // First we set the byte tally to 0, so if we do exit gracefully
+  // the caller doesn't think the random garbage on the stack is a
+  // success.
+  if (bytes_read)

jeffreytan81 wrote:

I would agree with @mbucko here to ensure caller pass a valid `bytes_read`. 
Then you can get rid of `total_bytes_read` variable with `*bytes_read`

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


[Lldb-commits] [lldb] [lldb] Remove progress report coalescing (PR #130329)

2025-03-07 Thread Chelsea Cassanova via lldb-commits




chelcassanova wrote:

Makes sense, I also figured it could be restored from history if needed if 
we're not keeping it around, thanks for explaining!

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


[Lldb-commits] [lldb] [llvm] Modify the localCache API to require an explicit commit on CachedFile… (PR #115331)

2025-03-07 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-ppc64le-rhel` 
running on `ppc64le-clang-rhel-test` while building `lldb,llvm` at step 5 
"build-unified-tree".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/145/builds/5513


Here is the relevant piece of the build log for the reference

```
Step 5 (build-unified-tree) failure: build (failure)
...
47.720 [1501/192/4741] Building CXX object 
tools/clang/tools/extra/clang-tidy/utils/CMakeFiles/obj.clangTidyUtils.dir/DesignatedInitializers.cpp.o
47.732 [1500/192/4742] Building CXX object 
tools/clang/tools/extra/clang-tidy/utils/CMakeFiles/obj.clangTidyUtils.dir/ExceptionSpecAnalyzer.cpp.o
47.738 [1499/192/4743] Building CXX object 
tools/clang/tools/extra/clang-tidy/utils/CMakeFiles/obj.clangTidyUtils.dir/FileExtensionsUtils.cpp.o
47.744 [1498/192/4744] Building CXX object 
tools/clang/tools/extra/clang-tidy/utils/CMakeFiles/obj.clangTidyUtils.dir/LexerUtils.cpp.o
47.751 [1497/192/4745] Building CXX object 
tools/clang/tools/extra/clang-include-fixer/CMakeFiles/obj.clangIncludeFixer.dir/IncludeFixerContext.cpp.o
47.769 [1496/192/4746] Building CXX object 
tools/clang/tools/extra/clang-include-fixer/CMakeFiles/obj.clangIncludeFixer.dir/SymbolIndexManager.cpp.o
47.793 [1495/192/4747] Building CXX object 
tools/clang/tools/extra/clang-include-fixer/find-all-symbols/CMakeFiles/obj.findAllSymbols.dir/HeaderMapCollector.cpp.o
47.799 [1494/192/4748] Linking CXX shared library 
lib/libLLVMFrontendHLSL.so.21.0git
47.807 [1493/192/4749] Linking CXX shared library 
lib/libLLVMLoongArchInfo.so.21.0git
47.817 [1492/192/4750] Building CXX object 
lib/Debuginfod/CMakeFiles/LLVMDebuginfod.dir/Debuginfod.cpp.o
FAILED: lib/Debuginfod/CMakeFiles/LLVMDebuginfod.dir/Debuginfod.cpp.o 
ccache /home/buildbots/llvm-external-buildbots/clang.19.1.7/bin/clang++ 
--gcc-toolchain=/gcc-toolchain/usr -DGTEST_HAS_RTTI=0 -D_DEBUG 
-D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/lib/Debuginfod
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/lib/Debuginfod
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/include
 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -O3 -DNDEBUG -std=c++17 -fPIC  
-fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT 
lib/Debuginfod/CMakeFiles/LLVMDebuginfod.dir/Debuginfod.cpp.o -MF 
lib/Debuginfod/CMakeFiles/LLVMDebuginfod.dir/Debuginfod.cpp.o.d -o 
lib/Debuginfod/CMakeFiles/LLVMDebuginfod.dir/Debuginfod.cpp.o -c 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/lib/Debuginfod/Debuginfod.cpp
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/lib/Debuginfod/Debuginfod.cpp:312:15:
 error: using the result of an assignment as a condition without parentheses 
[-Werror,-Wparentheses]
  312 |   if (Err = Handler.commit())
  |   ^~
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/lib/Debuginfod/Debuginfod.cpp:312:15:
 note: place parentheses around the assignment to silence this warning
  312 |   if (Err = Handler.commit())
  |   ^ 
  |   ( )
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/lib/Debuginfod/Debuginfod.cpp:312:15:
 note: use '==' to turn this assignment into an equality comparison
  312 |   if (Err = Handler.commit())
  |   ^
  |   ==
1 error generated.
47.820 [1492/191/4751] Building CXX object 
tools/clang/tools/extra/clang-tidy/readability/CMakeFiles/obj.clangTidyReadabilityModule.dir/RedundantStringCStrCheck.cpp.o
47.826 [1492/190/4752] Building CXX object 
tools/clang/tools/extra/clang-tidy/readability/CMakeFiles/obj.clangTidyReadabilityModule.dir/RedundantStringInitCheck.cpp.o
47.829 [1492/189/4753] Building CXX object 
tools/clang/tools/extra/clang-tidy/readability/CMakeFiles/obj.clangTidyReadabilityModule.dir/UppercaseLiteralSuffixCheck.cpp.o
47.837 [1492/188

[Lldb-commits] [lldb] [llvm] Modify the localCache API to require an explicit commit on CachedFile… (PR #115331)

2025-03-07 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `llvm-nvptx64-nvidia-win` 
running on `as-builder-8` while building `lldb,llvm` at step 7 
"test-build-unified-tree-check-llvm".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/155/builds/7284


Here is the relevant piece of the build log for the reference

```
Step 7 (test-build-unified-tree-check-llvm) failure: test (failure)
 TEST 'LLVM-Unit :: Support/./SupportTests.exe/50/87' 
FAILED 
Script(shard):
--
GTEST_OUTPUT=json:C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\unittests\Support\.\SupportTests.exe-LLVM-Unit-26688-50-87.json
 GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=87 GTEST_SHARD_INDEX=50 
C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\unittests\Support\.\SupportTests.exe
--

Script:
--
C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\unittests\Support\.\SupportTests.exe
 --gtest_filter=Caching.WriteAfterCommit
--
C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\llvm-project\llvm\unittests\Support\Caching.cpp(103):
 error: Value of: AddStream
  Actual: false
Expected: true


C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\llvm-project\llvm\unittests\Support\Caching.cpp:103
Value of: AddStream
  Actual: false
Expected: true






```



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


[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-03-07 Thread Jonas Devlieghere via lldb-commits


@@ -172,6 +172,14 @@ let Definition = "debugger" in {
 Global,
 DefaultStringValue<"${ansi.normal}">,
 Desc<"When displaying progress in a color-enabled terminal, use the ANSI 
terminal code specified in this format immediately after the progress 
message.">;
+  def ShowStatusline: Property<"show-statusline", "Boolean">,
+Global,
+DefaultTrue,
+Desc<"Whether to show a statusline at the bottom of the terminal.">;
+  def StatuslineFormat: Property<"statusline-format", "FormatEntity">,
+Global,
+
DefaultStringValue<"${ansi.bg.blue}${ansi.fg.black}{${target.file.basename}}{ | 
${line.file.basename}:${line.number}:${line.column}}{ | ${thread.stop-reason}}{ 
| {${progress.count} }${progress.message}}">,
+Desc<"List of statusline format entities.">;

JDevlieghere wrote:

It's using these: https://lldb.llvm.org/use/formatting.html#format-strings

I'll update the description as it's also not a list anymore. 

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


[Lldb-commits] [lldb] [lldb] Remove progress report coalescing (PR #130329)

2025-03-07 Thread Jonas Devlieghere via lldb-commits

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

Remove support for coalescing progress reports in LLDB. This functionality was 
motivated by Xcode, which wanted to listen for less frequent, aggregated 
progress events at the cost of losing some detail. See the original RFC [1] for 
more details. Since then, they've reevaluated this trade-off and opted to 
listen for the regular, full fidelity progress events and do any post 
processing on their end.

rdar://146425487

>From b3055ce5680f22f9b044f8653e39ce625527e6ba Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 7 Mar 2025 10:52:36 -0800
Subject: [PATCH] [lldb] Remove progress report coalescing

Remove support for coalescing progress reports in LLDB. This
functionality was motivated by Xcode, which wanted to listen for less
frequent, aggregated progress events at the cost of losing some detail.
See the original RFC [1] for more details. Since then, they've
reevaluated this trade-off and opted to listen for the regular, full
fidelity progress events and do any post processing on their end.

rdar://146425487
---
 lldb/include/lldb/Core/Progress.h |  85 +--
 lldb/include/lldb/Host/Alarm.h| 115 -
 lldb/include/lldb/lldb-enumerations.h |   4 +-
 lldb/source/API/SystemInitializerFull.cpp |   6 -
 lldb/source/Core/Debugger.cpp |   6 +-
 lldb/source/Core/Progress.cpp | 151 +---
 lldb/source/Host/CMakeLists.txt   |   1 -
 lldb/source/Host/common/Alarm.cpp | 222 --
 .../Callback/TestBreakpointSetCallback.cpp|   3 +-
 lldb/unittests/Core/ProgressReportTest.cpp| 116 +
 lldb/unittests/Host/AlarmTest.cpp | 172 --
 lldb/unittests/Host/CMakeLists.txt|   1 -
 12 files changed, 33 insertions(+), 849 deletions(-)
 delete mode 100644 lldb/include/lldb/Host/Alarm.h
 delete mode 100644 lldb/source/Host/common/Alarm.cpp
 delete mode 100644 lldb/unittests/Host/AlarmTest.cpp

diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index 5876eae717e96..3003568e8946b 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -9,7 +9,6 @@
 #ifndef LLDB_CORE_PROGRESS_H
 #define LLDB_CORE_PROGRESS_H
 
-#include "lldb/Host/Alarm.h"
 #include "lldb/Utility/Timeout.h"
 #include "lldb/lldb-forward.h"
 #include "lldb/lldb-types.h"
@@ -18,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace lldb_private {
 
@@ -115,21 +115,6 @@ class Progress {
   /// Used to indicate a non-deterministic progress report
   static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX;
 
-  /// Data belonging to this Progress event that is used for bookkeeping by
-  /// ProgressManager.
-  struct ProgressData {
-/// The title of the progress activity, also used as a category.
-std::string title;
-/// A unique integer identifier for progress reporting.
-uint64_t progress_id;
-/// The optional debugger ID to report progress to. If this has no value
-/// then all debuggers will receive this event.
-std::optional debugger_id;
-
-/// The origin of the progress event, wheter it is internal or external.
-Origin origin;
-  };
-
 private:
   void ReportProgress();
   static std::atomic g_id;
@@ -141,8 +126,18 @@ class Progress {
   // Minimum amount of time between two progress reports.
   const Timeout m_minimum_report_time;
 
-  /// Data needed by the debugger to broadcast a progress event.
-  const ProgressData m_progress_data;
+  /// The title of the progress activity, also used as a category.
+  const std::string m_title;
+
+  /// A unique integer identifier for progress reporting.
+  const uint64_t m_progress_id;
+
+  /// The optional debugger ID to report progress to. If this has no value
+  /// then all debuggers will receive this event.
+  const std::optional m_debugger_id;
+
+  /// The origin of the progress event, whether it is internal or external.
+  const Origin m_origin;
 
   /// How much work ([0...m_total]) that has been completed.
   std::atomic m_completed = 0;
@@ -161,60 +156,6 @@ class Progress {
   std::optional m_prev_completed;
 };
 
-/// A class used to group progress reports by category. This is done by using a
-/// map that maintains a refcount of each category of progress reports that 
have
-/// come in. Keeping track of progress reports this way will be done if a
-/// debugger is listening to the eBroadcastBitProgressByCategory broadcast bit.
-class ProgressManager {
-public:
-  ProgressManager();
-  ~ProgressManager();
-
-  /// Control the refcount of the progress report category as needed.
-  void Increment(const Progress::ProgressData &);
-  void Decrement(const Progress::ProgressData &);
-
-  static void Initialize();
-  static void Terminate();
-  static bool Enabled();
-  static ProgressManager &Instance();
-
-protected:
-  enum class Event

[Lldb-commits] [lldb] [lldb][lldb-dap] Return optional from json utils (PR #129919)

2025-03-07 Thread Walter Erquinigo via lldb-commits


@@ -13,8 +13,8 @@
 using namespace lldb_dap;
 
 BreakpointBase::BreakpointBase(DAP &d, const llvm::json::Object &obj)
-: dap(d), condition(std::string(GetString(obj, "condition"))),
-  hitCondition(std::string(GetString(obj, "hitCondition"))) {}
+: dap(d), condition(std::string(GetString(obj, "condition").value_or(""))),

walter-erquinigo wrote:

I think that instead of `""` you should use `{}`, which would create an empty 
StringRef without an actual string being backed by it. That is closer to the 
original source code.
I don't think why `""` would break with your patch, but if there's a place that 
does `GetString().GetData() == nullptr`, then there would be some divergence. 
So I'd rather play safe.

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


[Lldb-commits] [lldb] [lldb-dap] Allow providing debug adapter arguments in the extension (PR #129262)

2025-03-07 Thread Walter Erquinigo via lldb-commits


@@ -66,19 +70,17 @@ async function findDAPExecutable(): Promise {
 }
 
 async function getDAPExecutable(
-  session: vscode.DebugSession,
+  folder: vscode.WorkspaceFolder | undefined,

walter-erquinigo wrote:

call this workspaceFolder because this is not any folder

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


[Lldb-commits] [lldb] Add complete ObjectFileJSON support for sections. (PR #129916)

2025-03-07 Thread Greg Clayton via lldb-commits

https://github.com/clayborg updated 
https://github.com/llvm/llvm-project/pull/129916

>From 150bbe0d8c3e2fb4e2dd324a0d9080a462eda156 Mon Sep 17 00:00:00 2001
From: Greg Clayton 
Date: Wed, 5 Mar 2025 11:21:40 -0800
Subject: [PATCH 1/2] Add complete ObjectFileJSON support for sections.

Sections now support specifying:
- user IDs
- file offset/size
- alignment
- flags
- bool values for fake, encrypted and thread specific sections
---
 lldb/include/lldb/Core/Section.h  | 11 +++
 lldb/source/Core/Section.cpp  | 34 +
 .../ObjectFile/JSON/ObjectFileJSON.cpp| 43 ++-
 .../json/object-file/TestObjectFileJSON.py| 75 +--
 4 files changed, 120 insertions(+), 43 deletions(-)

diff --git a/lldb/include/lldb/Core/Section.h b/lldb/include/lldb/Core/Section.h
index 17b3cb454949f..f0f5a0b3499c0 100644
--- a/lldb/include/lldb/Core/Section.h
+++ b/lldb/include/lldb/Core/Section.h
@@ -101,14 +101,25 @@ class SectionList {
 };
 
 struct JSONSection {
+  std::optional user_id;
   std::string name;
   std::optional type;
   std::optional address;
   std::optional size;
+  std::optional file_offset;
+  std::optional file_size;
+  std::optional log2align;
+  std::optional flags;
+
   // Section permissions;
   std::optional read;
   std::optional write;
   std::optional execute;
+
+  std::optional fake;
+  std::optional encrypted;
+  std::optional thread_specific;
+
   std::vector subsections;
 };
 
diff --git a/lldb/source/Core/Section.cpp b/lldb/source/Core/Section.cpp
index 608e2a5fc3093..b3a0814750aa5 100644
--- a/lldb/source/Core/Section.cpp
+++ b/lldb/source/Core/Section.cpp
@@ -160,10 +160,9 @@ const char *Section::GetTypeAsCString() const {
 }
 
 Section::Section(const ModuleSP &module_sp, ObjectFile *obj_file,
- user_id_t sect_id, ConstString name,
- SectionType sect_type, addr_t file_addr, addr_t byte_size,
- lldb::offset_t file_offset, lldb::offset_t file_size,
- uint32_t log2align, uint32_t flags,
+ user_id_t sect_id, ConstString name, SectionType sect_type,
+ addr_t file_addr, addr_t byte_size, lldb::offset_t 
file_offset,
+ lldb::offset_t file_size, uint32_t log2align, uint32_t flags,
  uint32_t target_byte_size /*=1*/)
 : ModuleChild(module_sp), UserID(sect_id), Flags(flags),
   m_obj_file(obj_file), m_type(sect_type), m_parent_wp(), m_name(name),
@@ -171,15 +170,14 @@ Section::Section(const ModuleSP &module_sp, ObjectFile 
*obj_file,
   m_file_offset(file_offset), m_file_size(file_size),
   m_log2align(log2align), m_children(), m_fake(false), m_encrypted(false),
   m_thread_specific(false), m_readable(false), m_writable(false),
-  m_executable(false), m_relocated(false), 
m_target_byte_size(target_byte_size) {
-}
+  m_executable(false), m_relocated(false),
+  m_target_byte_size(target_byte_size) {}
 
 Section::Section(const lldb::SectionSP &parent_section_sp,
  const ModuleSP &module_sp, ObjectFile *obj_file,
- user_id_t sect_id, ConstString name,
- SectionType sect_type, addr_t file_addr, addr_t byte_size,
- lldb::offset_t file_offset, lldb::offset_t file_size,
- uint32_t log2align, uint32_t flags,
+ user_id_t sect_id, ConstString name, SectionType sect_type,
+ addr_t file_addr, addr_t byte_size, lldb::offset_t 
file_offset,
+ lldb::offset_t file_size, uint32_t log2align, uint32_t flags,
  uint32_t target_byte_size /*=1*/)
 : ModuleChild(module_sp), UserID(sect_id), Flags(flags),
   m_obj_file(obj_file), m_type(sect_type), m_parent_wp(), m_name(name),
@@ -187,7 +185,8 @@ Section::Section(const lldb::SectionSP &parent_section_sp,
   m_file_offset(file_offset), m_file_size(file_size),
   m_log2align(log2align), m_children(), m_fake(false), m_encrypted(false),
   m_thread_specific(false), m_readable(false), m_writable(false),
-  m_executable(false), m_relocated(false), 
m_target_byte_size(target_byte_size) {
+  m_executable(false), m_relocated(false),
+  m_target_byte_size(target_byte_size) {
   if (parent_section_sp)
 m_parent_wp = parent_section_sp;
 }
@@ -469,7 +468,6 @@ bool Section::ContainsOnlyDebugInfo() const {
   return false;
 }
 
-
 #pragma mark SectionList
 
 SectionList &SectionList::operator=(const SectionList &rhs) {
@@ -554,8 +552,7 @@ SectionSP SectionList::GetSectionAtIndex(size_t idx) const {
   return sect_sp;
 }
 
-SectionSP
-SectionList::FindSectionByName(ConstString section_dstr) const {
+SectionSP SectionList::FindSectionByName(ConstString section_dstr) const {
   SectionSP sect_sp;
   // Check if we have a valid section string
   if (section_dstr && !m_sections.empty()) {
@@ -693,7 +690,14 @@ bool fromJSON(const llvm::json::Value &value,
  o.map("address", section.address) && o.

[Lldb-commits] [lldb] [lldb-dap] Add process picker command to VS Code extension (PR #128943)

2025-03-07 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

I have an idea for using lldb's process list logic, although it's a bit of code.

1. Don't use `"${command:pickProcess}"` at all. We need to bypass the regular 
command logic. You could use a wildcard like `${pickProcess}`.
2. In the debug config resolution logic, which is invoked before launching the 
debugger, you look for this wildcard. If you see it, then you programmatically 
invoke lldb-dap (you know its path at this point), and then invoke it with a 
new flag `--list-processes` that will just dump the list of processes in JSON 
format to stdout. With this information, you can show a custom made picker and 
await the result.
3. With the result, you can then modify the debug configuration and resume the 
debug process.

We shouldn't invoke lldb directly because we just don't know where it is, and 
it might be error-prone to try to find it. Instead, it might be better to 
simply add a flag to lldb-dap for this, which seems to be kind of appropriate 
for this kind of flow.

Let me know what you think.

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


[Lldb-commits] [lldb] Add complete ObjectFileJSON support for sections. (PR #129916)

2025-03-07 Thread Jonas Devlieghere via lldb-commits

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

Thanks! 

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


[Lldb-commits] [lldb] [lldb-dap] Allow providing debug adapter arguments in the extension (PR #129262)

2025-03-07 Thread Matthew Bastien via lldb-commits

https://github.com/matthewbastien updated 
https://github.com/llvm/llvm-project/pull/129262

>From b40c3e7e4ebb154c5f231676451acbd17e1f39f7 Mon Sep 17 00:00:00 2001
From: Matthew Bastien 
Date: Fri, 28 Feb 2025 11:08:25 -0500
Subject: [PATCH 1/6] allow providing debug adapter arguments

---
 lldb/tools/lldb-dap/package.json  | 23 ++
 .../lldb-dap/src-ts/debug-adapter-factory.ts  | 72 +--
 2 files changed, 72 insertions(+), 23 deletions(-)

diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index cd450a614b3f7..aa11d8bcaa66e 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -75,6 +75,15 @@
   "type": "string",
   "description": "The path to the lldb-dap binary."
 },
+"lldb-dap.arguments": {
+  "scope": "resource",
+  "type": "array",
+  "default": [],
+  "items": {
+"type": "string"
+  },
+  "description": "The arguments provided to the lldb-dap process."
+},
 "lldb-dap.log-path": {
   "scope": "resource",
   "type": "string",
@@ -162,6 +171,13 @@
 "type": "string",
 "markdownDescription": "The absolute path to the LLDB debug 
adapter executable to use."
   },
+  "debugAdapterArgs": {
+"type": "array",
+"items": {
+  "type": "string"
+},
+"markdownDescription": "The list of arguments used to launch 
the debug adapter executable."
+  },
   "program": {
 "type": "string",
 "description": "Path to the program to debug."
@@ -352,6 +368,13 @@
 "type": "string",
 "markdownDescription": "The absolute path to the LLDB debug 
adapter executable to use."
   },
+  "debugAdapterArgs": {
+"type": "array",
+"items": {
+  "type": "string"
+},
+"markdownDescription": "The list of arguments used to launch 
the debug adapter executable."
+  },
   "program": {
 "type": "string",
 "description": "Path to the program to attach to."
diff --git a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts 
b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
index 1f76fe31b00ad..51f45f87d660a 100644
--- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
+++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
@@ -25,7 +25,7 @@ async function findWithXcrun(executable: string): 
Promise {
   if (stdout) {
 return stdout.toString().trimEnd();
   }
-} catch (error) { }
+} catch (error) {}
   }
   return undefined;
 }
@@ -93,13 +93,33 @@ async function getDAPExecutable(
   return undefined;
 }
 
+function getDAPArguments(session: vscode.DebugSession): string[] {
+  // Check the debug configuration for arguments first
+  const debugConfigArgs = session.configuration.debugAdapterArgs;
+  if (
+Array.isArray(debugConfigArgs) &&
+debugConfigArgs.findIndex((entry) => typeof entry !== "string") === -1
+  ) {
+return debugConfigArgs;
+  }
+  // Fall back on the workspace configuration
+  return vscode.workspace
+.getConfiguration("lldb-dap")
+.get("arguments", []);
+}
+
 /**
  * This class defines a factory used to find the lldb-dap binary to use
  * depending on the session configuration.
  */
 export class LLDBDapDescriptorFactory
-  implements vscode.DebugAdapterDescriptorFactory, vscode.Disposable {
-  private server?: Promise<{ process: child_process.ChildProcess, host: 
string, port: number }>;
+  implements vscode.DebugAdapterDescriptorFactory, vscode.Disposable
+{
+  private server?: Promise<{
+process: child_process.ChildProcess;
+host: string;
+port: number;
+  }>;
 
   dispose() {
 this.server?.then(({ process }) => {
@@ -109,7 +129,7 @@ export class LLDBDapDescriptorFactory
 
   async createDebugAdapterDescriptor(
 session: vscode.DebugSession,
-executable: vscode.DebugAdapterExecutable | undefined,
+_executable: vscode.DebugAdapterExecutable | undefined,
   ): Promise {
 const config = vscode.workspace.getConfiguration(
   "lldb-dap",
@@ -123,7 +143,7 @@ export class LLDBDapDescriptorFactory
 }
 const configEnvironment =
   config.get<{ [key: string]: string }>("environment") || {};
-const dapPath = (await getDAPExecutable(session)) ?? executable?.command;
+const dapPath = await getDAPExecutable(session);
 
 if (!dapPath) {
   LLDBDapDescriptorFactory.showLLDBDapNotFoundMessage();
@@ -137,32 +157,38 @@ export class LLDBDapDescriptorFactory
 
 const dbgOptions = {
   env: {
-...executable?.options?.env,
 ...configEnvironment,
 ...env,
   },
 };
-const dbgArgs = executable?.args ?? [];
+

[Lldb-commits] [lldb] Add complete ObjectFileJSON support for sections. (PR #129916)

2025-03-07 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 
024362f413dbfcf8188003762c9cc299f274d76e...48fec8f9fd6fd19426943f0daf3eb6fcaf6fe8f0
 lldb/test/API/functionalities/json/object-file/TestObjectFileJSON.py
``





View the diff from darker here.


``diff
--- TestObjectFileJSON.py   2025-03-07 23:29:50.00 +
+++ TestObjectFileJSON.py   2025-03-07 23:33:27.931147 +
@@ -78,13 +78,13 @@
 "user_id": 0x100,
 "name": "__PAGEZERO",
 "type": "container",
 "address": 0,
 "size": 0x1,
-"flags": 0x101
-  },
-  {
+"flags": 0x101,
+},
+{
 "user_id": 0x200,
 "name": "__TEXT",
 "type": "container",
 "address": TEXT_file_addr,
 "size": TEXT_size,
@@ -107,24 +107,24 @@
 },
 {
 "name": "__fake",
 "address": TEXT_file_addr + 1 * text_size,
 "size": text_size,
-"fake": True
+"fake": True,
 },
 {
 "name": "__encrypted",
 "address": TEXT_file_addr + 2 * text_size,
 "size": text_size,
-"encrypted": True
+"encrypted": True,
 },
 {
 "name": "__tls",
 "address": TEXT_file_addr + 2 * text_size,
 "size": text_size,
-"thread_specific": True
-}
+"thread_specific": True,
+},
 ],
 },
 {
 "name": "__DATA",
 "type": "data",
@@ -220,20 +220,22 @@
 self.assertEqual(bar_symbol.addr.GetFileAddress(), bar_file_addr)
 self.assertEqual(bar_symbol.GetSize(), bar_size)
 
 # Verify the user_ids and flags are set correctly since there is no API
 # for this on lldb.SBSection
-self.expect("target modules dump sections c.json",
-substrs = [
+self.expect(
+"target modules dump sections c.json",
+substrs=[
 "0x0100 container  
[0x-0x0001)  ---  0x 0x 0x0101 
c.json.__PAGEZERO",
 "0x0200 container  
[0x0001-0x00010222)  r-x  0x 0x0222 0x0202 
c.json.__TEXT",
 "0x0001 code   
[0x0001-0x00010020)  r-x  0x 0x 0x 
c.json.__TEXT.__text",
 "0x0002 code   
[0x00010020-0x00010040)  ---  0x 0x 0x 
c.json.__TEXT.__fake",
 "0x0003 code   
[0x00010040-0x00010060)  ---  0x 0x 0x 
c.json.__TEXT.__encrypted",
 "0x0004 code   
[0x00010040-0x00010060)  ---  0x 0x 0x 
c.json.__TEXT.__tls",
-"0x0005 data   
[0x00011000-0x00011333)  rw-  0x1000 0x0333 0x0303 
c.json.__DATA"
-])
+"0x0005 data   
[0x00011000-0x00011333)  rw-  0x1000 0x0333 0x0303 
c.json.__DATA",
+],
+)
 
 error = target.SetSectionLoadAddress(TEXT_section, TEXT_file_addr + 
slide)
 self.assertSuccess(error)
 error = target.SetSectionLoadAddress(DATA_section, DATA_file_addr + 
slide)
 self.assertSuccess(error)

``




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


[Lldb-commits] [lldb] [lldb-dap] Allow providing debug adapter arguments in the extension (PR #129262)

2025-03-07 Thread Matthew Bastien via lldb-commits

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


[Lldb-commits] [lldb] 8ac359b - Add complete ObjectFileJSON support for sections. (#129916)

2025-03-07 Thread via lldb-commits

Author: Greg Clayton
Date: 2025-03-07T15:34:27-08:00
New Revision: 8ac359ba0d7ec1f1e7334a50405f0f20983b997a

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

LOG: Add complete ObjectFileJSON support for sections. (#129916)

Sections now support specifying:
- user IDs
- file offset/size
- alignment
- flags
- bool values for fake, encrypted and thread specific sections

Added: 


Modified: 
lldb/docs/use/symbolfilejson.rst
lldb/include/lldb/Core/Section.h
lldb/source/Core/Section.cpp
lldb/source/Plugins/ObjectFile/JSON/ObjectFileJSON.cpp
lldb/test/API/functionalities/json/object-file/TestObjectFileJSON.py

Removed: 




diff  --git a/lldb/docs/use/symbolfilejson.rst 
b/lldb/docs/use/symbolfilejson.rst
index 9d15d704f3574..2ad28a14e9320 100644
--- a/lldb/docs/use/symbolfilejson.rst
+++ b/lldb/docs/use/symbolfilejson.rst
@@ -74,14 +74,61 @@ sections
 * ``type``: a string representing the section type (see below).
 * ``address``: a number representing the section file address.
 * ``size``: a number representing the section size in bytes.
+* ``read``: a boolean value indicating if the section has read permissions.
+* ``write``: a boolean value indicating if the section has write permissions.
+* ``execute``: a boolean value indicating if the section has execute 
permissions.
+* ``subsections``: An array of child sections in the same format.
+* ``user_id``: a number representing the section identifier.
+* ``file_offset``: a number that represents the offset in the file for this 
section's contents.
+* ``file_size``: a number that represents the size in bytes in the file for 
this section's contents.
+* ``alignment``: a boolean value indicating if the section has execute 
permissions.
+* ``fake``: a boolean value indicating if the section is fake.
+* ``encrypted``: a boolean value indicating if the section is encrypted.
+* ``thread_specific``: a boolean value indicating if the section is thread 
specific.
 
 .. code-block:: JSON
 
   {
-  "name": "__TEXT",
-  "type": "code",
-  "address": 0,
-  "size": 546,
+"user_id": 256,
+"name": "__TEXT",
+"type": "code",
+"address": 0,
+"size": 546,
+"file_offset": 0,
+"file_size": 4096,
+"read": true,
+"write": false,
+"executable": true,
+"subsections": [
+  {
+"name": "__text",
+"type": "code",
+"address": 0,
+"size": 200,
+"alignment": 2,
+"read": true,
+"write": false,
+"execute": true
+  },
+  {
+  "name": "__fake",
+  "address": 200,
+  "size": 10,
+  "fake": true
+  },
+  {
+  "name": "__encrypted",
+  "address": 210,
+  "size": 20,
+  "encrypted": true
+  },
+  {
+  "name": "__tls",
+  "address": 230,
+  "size": 30,
+  "thread_specific": true
+  }
+]
   }
 
 The ``type`` field accepts the following values: ``code``, ``container``,

diff  --git a/lldb/include/lldb/Core/Section.h 
b/lldb/include/lldb/Core/Section.h
index 17b3cb454949f..f0f5a0b3499c0 100644
--- a/lldb/include/lldb/Core/Section.h
+++ b/lldb/include/lldb/Core/Section.h
@@ -101,14 +101,25 @@ class SectionList {
 };
 
 struct JSONSection {
+  std::optional user_id;
   std::string name;
   std::optional type;
   std::optional address;
   std::optional size;
+  std::optional file_offset;
+  std::optional file_size;
+  std::optional log2align;
+  std::optional flags;
+
   // Section permissions;
   std::optional read;
   std::optional write;
   std::optional execute;
+
+  std::optional fake;
+  std::optional encrypted;
+  std::optional thread_specific;
+
   std::vector subsections;
 };
 

diff  --git a/lldb/source/Core/Section.cpp b/lldb/source/Core/Section.cpp
index 608e2a5fc3093..27dcf987b0278 100644
--- a/lldb/source/Core/Section.cpp
+++ b/lldb/source/Core/Section.cpp
@@ -160,10 +160,9 @@ const char *Section::GetTypeAsCString() const {
 }
 
 Section::Section(const ModuleSP &module_sp, ObjectFile *obj_file,
- user_id_t sect_id, ConstString name,
- SectionType sect_type, addr_t file_addr, addr_t byte_size,
- lldb::offset_t file_offset, lldb::offset_t file_size,
- uint32_t log2align, uint32_t flags,
+ user_id_t sect_id, ConstString name, SectionType sect_type,
+ addr_t file_addr, addr_t byte_size, lldb::offset_t 
file_offset,
+ lldb::offset_t file_size, uint32_t log2align, uint32_t flags,
  uint32_t target_byte_size /*=1*/)
 : ModuleChild(module_sp), UserID(sect_id), Flags(flags),
   m_obj_file(obj_file), m_type(sect_type), m_parent_wp(), m_name(name),
@@ -171,15 +170,14 @@ Section:

[Lldb-commits] [lldb] [lldb] Avoid force loading symbol files in statistics collection (PR #129593)

2025-03-07 Thread Greg Clayton via lldb-commits


@@ -0,0 +1,31 @@
+# RUN: %clang_host -g %S/Inputs/main.c -o %t-main.exe
+
+# When we enable symbol preload and dump stats there should be a non-zero
+# time for parsing symbol tables for the main module.
+# RUN: %lldb %t-main.exe \
+# RUN:   -O "settings set plugin.jit-loader.gdb.enable off" \

clayborg wrote:

It is fine to not run the program and just test that symbols are not loaded 
when pre-load is off. That will stop all of the normal system runtime plug-ins 
from being loaded as they only get loaded when the process is launched.

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


[Lldb-commits] [lldb] Add complete ObjectFileJSON support for sections. (PR #129916)

2025-03-07 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] 61efe36 - [lldb] Avoid unnecessary regex check in dwim-print (#114608)

2025-03-07 Thread via lldb-commits

Author: Dave Lee
Date: 2025-03-07T21:57:05-08:00
New Revision: 61efe360f9ba70736ca27ad289277c5c8268ffc0

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

LOG: [lldb] Avoid unnecessary regex check in dwim-print (#114608)

An (unmeasured) improvement to performance of `dwim-print` when used as `po`.

This change lifts the check for `note_shown` to the top of the lambda, to avoid 
all subsequent work when the hint has already been shown. The main effect is to 
avoid performing a regex match when the hint is not going to be shown.

This change also constructs the `std::regex` only once, by making it static.

Added: 


Modified: 
lldb/source/Commands/CommandObjectDWIMPrint.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp 
b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
index 04142427717bd..17c60297a521e 100644
--- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp
+++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
@@ -101,6 +101,10 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
   // Add a hint if object description was requested, but no description
   // function was implemented.
   auto maybe_add_hint = [&](llvm::StringRef output) {
+static bool note_shown = false;
+if (note_shown)
+  return;
+
 // Identify the default output of object description for Swift and
 // Objective-C
 // ". The regex is:
@@ -110,17 +114,14 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
 // - Followed by 5 or more hex digits.
 // - Followed by ">".
 // - End with zero or more whitespace characters.
-const std::regex swift_class_regex("^<\\S+: 0x[[:xdigit:]]{5,}>\\s*$");
+static const std::regex swift_class_regex(
+"^<\\S+: 0x[[:xdigit:]]{5,}>\\s*$");
 
 if (GetDebugger().GetShowDontUsePoHint() && target_ptr &&
 (language == lldb::eLanguageTypeSwift ||
  language == lldb::eLanguageTypeObjC) &&
 std::regex_match(output.data(), swift_class_regex)) {
 
-  static bool note_shown = false;
-  if (note_shown)
-return;
-
   result.AppendNote(
   "object description requested, but type doesn't implement "
   "a custom object description. Consider using \"p\" instead of "



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


[Lldb-commits] [lldb] [lldb] Update dwim-print to show expanded objc instances (PR #117500)

2025-03-07 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [LLDB][Docstrings] Fix some poorly formatted Docstrings (PR #129605)

2025-03-07 Thread Jacob Lalonde via lldb-commits

https://github.com/Jlalond updated 
https://github.com/llvm/llvm-project/pull/129605

>From 6c8f3ee0b033917213c802ddd978c63f8947616b Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Mon, 3 Mar 2025 15:12:29 -0800
Subject: [PATCH 1/2] Drop markdown backticks for codeblock

---
 lldb/bindings/interface/SBProcessDocstrings.i | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lldb/bindings/interface/SBProcessDocstrings.i 
b/lldb/bindings/interface/SBProcessDocstrings.i
index b5b22052a6094..2438a6bfc124c 100644
--- a/lldb/bindings/interface/SBProcessDocstrings.i
+++ b/lldb/bindings/interface/SBProcessDocstrings.i
@@ -260,12 +260,12 @@ SBProcess supports thread iteration. For example (from 
test/lldbutil.py), ::
 ) lldb::SBProcess::DeallocateMemory;
 
 %feature("docstring", "
-Get a list of all the memory regions associated with this process.
-```
+Get a list of all the memory regions associated with this process. ::
+
 readable_regions = []
 for region in process.GetMemoryRegions():
 if region.IsReadable():
 readable_regions.append(region)
-```
+
 "
 ) lldb::SBProcess::GetMemoryRegions;

>From fff16a7d99d611846f5df7532f9ee9bcad49cf3b Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Thu, 6 Mar 2025 15:56:36 -0800
Subject: [PATCH 2/2] Fix the other doc strings I know of

---
 lldb/bindings/interface/SBProgressDocstrings.i| 4 ++--
 lldb/bindings/interface/SBSaveCoreOptionsDocstrings.i | 9 +++--
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/lldb/bindings/interface/SBProgressDocstrings.i 
b/lldb/bindings/interface/SBProgressDocstrings.i
index 7b7e1dc79187c..8d252ef1f370c 100644
--- a/lldb/bindings/interface/SBProgressDocstrings.i
+++ b/lldb/bindings/interface/SBProgressDocstrings.i
@@ -23,7 +23,7 @@ specify a new detail. Some implementations differ on 
throttling updates and this
 if the progress is deterministic or non-deterministic. For DAP, 
non-deterministic update messages have a higher
 throttling rate than deterministic ones.
 
-Below are examples in Python for deterministic and non-deterministic 
progresses.
+Below are examples in Python for deterministic and non-deterministic 
progresses. ::
 
 deterministic_progress1 = lldb.SBProgress('Deterministic Progress', 
'Detail', 3, lldb.SBDebugger) 
 for i in range(3): 
@@ -44,7 +44,7 @@ If you don't call Finalize() when the progress is not done, 
the progress object
 garbage collected by the Python runtime, the end event will eventually get 
sent, but it is best not to 
 rely on the garbage collection when using lldb.SBProgress.
 
-Non-deterministic progresses behave the same, but omit the total in the 
constructor.
+Non-deterministic progresses behave the same, but omit the total in the 
constructor. ::
 
 non_deterministic_progress = lldb.SBProgress('Non deterministic progress, 
'Detail', lldb.SBDebugger)
 for i in range(10):
diff --git a/lldb/bindings/interface/SBSaveCoreOptionsDocstrings.i 
b/lldb/bindings/interface/SBSaveCoreOptionsDocstrings.i
index 08bbdf89d68de..6efbe45d2d3ab 100644
--- a/lldb/bindings/interface/SBSaveCoreOptionsDocstrings.i
+++ b/lldb/bindings/interface/SBSaveCoreOptionsDocstrings.i
@@ -4,16 +4,13 @@
 SBSaveCoreOptions includes API's to specify the memory regions and threads to 
include
 when generating a core file. It extends the existing SaveCoreStyle option.
 
-* eSaveCoreFull will save off all thread and memory regions, ignoring the 
memory regions and threads in
-the options object.
+* eSaveCoreFull will save off all thread and memory regions, ignoring the 
memory regions and threads in the options object.
 
-* eSaveCoreDirtyOnly pages will capture all threads and all rw- memory 
regions, in addition to the regions specified
-in the options object if they are not already captured.
+* eSaveCoreDirtyOnly pages will capture all threads and all rw- memory 
regions, in addition to the regions specified in the options object if they are 
not already captured.
 
 * eSaveCoreStackOnly will capture all threads, but no memory regions unless 
specified.
 
-* eSaveCoreCustomOnly Custom defers entirely to the SBSaveCoreOptions object 
and will only save what is specified. 
-  Picking custom and specifying nothing will result in an error being returned.
+* eSaveCoreCustomOnly Custom defers entirely to the SBSaveCoreOptions object 
and will only save what is specified. Picking custom and specifying nothing 
will result in an error being returned.
 
 Note that currently ELF Core files are not supported."
 ) lldb::SBSaveCoreOptions;

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


[Lldb-commits] [lldb] [lldb] Avoid unnecessary regex check in dwim-print (PR #114608)

2025-03-07 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Avoid unnecessary regex check in dwim-print (PR #114608)

2025-03-07 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [clang] [lldb] [C++20][Modules] Do not update the generation number if the redeclaration chain completion was delayed. (PR #129982)

2025-03-07 Thread Michael Park via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Add process picker command to VS Code extension (PR #128943)

2025-03-07 Thread Matthew Bastien via lldb-commits


@@ -34,6 +34,23 @@ function convertToInteger(value: any): number | undefined {
 export class LLDBDapConfigurationProvider
   implements vscode.DebugConfigurationProvider
 {
+  resolveDebugConfiguration(
+_folder: vscode.WorkspaceFolder | undefined,
+debugConfiguration: vscode.DebugConfiguration,
+_token?: vscode.CancellationToken,
+  ): vscode.ProviderResult {
+// Default "pid" to ${command:pickProcess} if neither "pid" nor "program" 
are specified
+// in an "attach" request.
+if (
+  debugConfiguration.request === "attach" &&
+  !("pid" in debugConfiguration) &&
+  !("program" in debugConfiguration)
+) {
+  debugConfiguration.pid = "${command:pickProcess}";

matthewbastien wrote:

I've updated both of these to better reflect my changes. I did a pretty major 
overhaul of the `README` section on attaching and would appreciate another 
thorough review there to make sure the wording sounds good.

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


[Lldb-commits] [lldb] [LLDB][Docstrings] Fix some poorly formatted Docstrings (PR #129605)

2025-03-07 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> Is there a good place to add a blurb about these swig gotcha's? Maybe a `.md` 
> in `bindings/swig`?

That's a great question. There's a lot of institutional knowledge about how 
SWIG is used in LLDB that hasn't been written down. I think it'd be worth it to 
have a page on the website (under the section "developing lldb") to cover that. 
I'd be happy to contribute with some of the caveats/challenges/intricacies of 
how we use SWIG in LLDB. 

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


[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-03-07 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test] Skip libsanitizers tests for now (PR #130305)

2025-03-07 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [llvm] Modify the localCache API to require an explicit commit on CachedFile… (PR #115331)

2025-03-07 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `llvm-nvptx-nvidia-ubuntu` 
running on `as-builder-7` while building `lldb,llvm` at step 6 
"test-build-unified-tree-check-llvm".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/180/builds/14226


Here is the relevant piece of the build log for the reference

```
Step 6 (test-build-unified-tree-check-llvm) failure: test (failure)
 TEST 'LLVM-Unit :: Support/./SupportTests/134/175' FAILED 

Script(shard):
--
GTEST_OUTPUT=json:/home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/build/unittests/Support/./SupportTests-LLVM-Unit-1311025-134-175.json
 GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=175 GTEST_SHARD_INDEX=134 
/home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/build/unittests/Support/./SupportTests
--

Script:
--
/home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/build/unittests/Support/./SupportTests
 --gtest_filter=Caching.Normal
--
/home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/unittests/Support/Caching.cpp:55:
 Failure
Value of: AddStream
  Actual: false
Expected: true


/home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/unittests/Support/Caching.cpp:55
Value of: AddStream
  Actual: false
Expected: true






```



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


[Lldb-commits] [lldb] [llvm] Modify the localCache API to require an explicit commit on CachedFile… (PR #115331)

2025-03-07 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-ppc64-aix` running 
on `aix-ppc64` while building `lldb,llvm` at step 3 "clean-build-dir".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/64/builds/2433


Here is the relevant piece of the build log for the reference

```
Step 3 (clean-build-dir) failure: Delete failed. (failure) (timed out)
Step 5 (build-unified-tree) failure: build (failure)
...
1520.469 [3887/10/1418] Linking CXX static library lib/libLLVMRemarks.a
1522.586 [3886/10/1419] Building CXX object 
lib/ObjectYAML/CMakeFiles/LLVMObjectYAML.dir/YAML.cpp.o
1523.646 [3885/10/1420] Building CXX object 
lib/ObjectYAML/CMakeFiles/LLVMObjectYAML.dir/XCOFFYAML.cpp.o
1524.371 [3884/10/1421] Building CXX object 
lib/Debuginfod/CMakeFiles/LLVMDebuginfod.dir/BuildIDFetcher.cpp.o
1525.557 [3883/10/1422] Building CXX object 
lib/Debuginfod/CMakeFiles/LLVMDebuginfod.dir/HTTPClient.cpp.o
1526.305 [3882/10/1423] Building CXX object 
lib/ObjectYAML/CMakeFiles/LLVMObjectYAML.dir/XCOFFEmitter.cpp.o
1527.143 [3881/10/1424] Building CXX object 
lib/Debuginfod/CMakeFiles/LLVMDebuginfod.dir/HTTPServer.cpp.o
1528.083 [3880/10/1425] Building CXX object 
lib/ObjectYAML/CMakeFiles/LLVMObjectYAML.dir/WasmEmitter.cpp.o
1528.700 [3879/10/1426] Building CXX object 
lib/ObjectYAML/CMakeFiles/LLVMObjectYAML.dir/WasmYAML.cpp.o
1529.395 [3878/10/1427] Building CXX object 
lib/Debuginfod/CMakeFiles/LLVMDebuginfod.dir/Debuginfod.cpp.o
FAILED: lib/Debuginfod/CMakeFiles/LLVMDebuginfod.dir/Debuginfod.cpp.o 
/usr/local/clang-17.0.2/bin/clang++ -DGTEST_HAS_RTTI=0 -D_DEBUG 
-D_GLIBCXX_ASSERTIONS -D_LARGE_FILE_API -D_XOPEN_SOURCE=700 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/lib/Debuginfod 
-I/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/lib/Debuginfod
 -I/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/include 
-I/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/include
 -mcmodel=large -fPIC -Werror -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -O3 -DNDEBUG -std=c++17  -fno-exceptions 
-funwind-tables -fno-rtti -UNDEBUG -MD -MT 
lib/Debuginfod/CMakeFiles/LLVMDebuginfod.dir/Debuginfod.cpp.o -MF 
lib/Debuginfod/CMakeFiles/LLVMDebuginfod.dir/Debuginfod.cpp.o.d -o 
lib/Debuginfod/CMakeFiles/LLVMDebuginfod.dir/Debuginfod.cpp.o -c 
/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/lib/Debuginfod/Debuginfod.cpp
/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/lib/Debuginfod/Debuginfod.cpp:312:15:
 error: using the result of an assignment as a condition without parentheses 
[-Werror,-Wparentheses]
  312 |   if (Err = Handler.commit())
  |   ^~
/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/lib/Debuginfod/Debuginfod.cpp:312:15:
 note: place parentheses around the assignment to silence this warning
  312 |   if (Err = Handler.commit())
  |   ^ 
  |   ( )
/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/lib/Debuginfod/Debuginfod.cpp:312:15:
 note: use '==' to turn this assignment into an equality comparison
  312 |   if (Err = Handler.commit())
  |   ^
  |   ==
1 error generated.
1529.491 [3878/9/1428] Building CXX object 
lib/DebugInfo/DWARF/CMakeFiles/LLVMDebugInfoDWARF.dir/DWARFAddressRange.cpp.o
1529.760 [3878/8/1429] Building CXX object 
lib/DebugInfo/DWARF/CMakeFiles/LLVMDebugInfoDWARF.dir/DWARFAbbreviationDeclaration.cpp.o
1530.533 [3878/7/1430] Building CXX object 
lib/ObjectYAML/CMakeFiles/LLVMObjectYAML.dir/ELFEmitter.cpp.o
1531.419 [3878/6/1431] Building CXX object 
lib/DebugInfo/DWARF/CMakeFiles/LLVMDebugInfoDWARF.dir/DWARFCompileUnit.cpp.o
1531.700 [3878/5/1432] Building CXX object 
lib/ObjectYAML/CMakeFiles/LLVMObjectYAML.dir/yaml2obj.cpp.o
1532.946 [3878/4/1433] Building CXX object 
lib/DebugInfo/DWARF/CMakeFiles/LLVMDebugInfoDWARF.dir/DWARFDataExtractor.cpp.o
1535.341 [3878/3/1434] Building CXX object 
lib/DebugInfo/DWARF/CMakeFiles/LLVMDebugInfoDWARF.dir/DWARFAcceleratorTable.cpp.o
1540.017 [3878/2/1435] Building CXX object 
lib/ObjectYAML/CMakeFiles/LLVMObjectYAML.dir/ELFYAML.cpp.o
1544.981 [3878/1/1436] Building CXX object 
lib/DebugInfo/DWARF/CMakeFiles/LLVMDebugInfoDWARF.dir/DWARFContext.cpp.o
ninja: build stopped: subcommand failed.

```



https://github.com/llvm/llvm-projec

[Lldb-commits] [lldb] [lldb] Avoid unnecessary regex check in dwim-print (PR #114608)

2025-03-07 Thread Dave Lee via lldb-commits

kastiglione wrote:

@adrian-prantl @JDevlieghere I'm going to merge this, since this change 
improves performance and doesn't introduce the logic being discussed. I'm happy 
to do a follow up, but it's still unclear to me what exactly that looks like.

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


[Lldb-commits] [lldb] [lldb-dap] Add process picker command to VS Code extension (PR #128943)

2025-03-07 Thread Adrian Vogelsgesang via lldb-commits


@@ -34,6 +34,23 @@ function convertToInteger(value: any): number | undefined {
 export class LLDBDapConfigurationProvider
   implements vscode.DebugConfigurationProvider
 {
+  resolveDebugConfiguration(
+_folder: vscode.WorkspaceFolder | undefined,
+debugConfiguration: vscode.DebugConfiguration,
+_token?: vscode.CancellationToken,
+  ): vscode.ProviderResult {
+// Default "pid" to ${command:pickProcess} if neither "pid" nor "program" 
are specified
+// in an "attach" request.
+if (
+  debugConfiguration.request === "attach" &&
+  !("pid" in debugConfiguration) &&

vogelsgesang wrote:

> shouldn't the program be required for LLDB to properly load debug symbols?

Not sure. I guess, it would be theoretically possible for LLDB to figure out 
the loaded binary from the PID, and hence debug based on only the PID. Not sure 
if that is actually implemented, though.

@walter-erquinigo mentioned in [this 
comment](https://github.com/llvm/llvm-project/pull/128943#discussion_r1980448889),
 that `program` would be optional. Can you confirm that lldb-dap infers the 
loaded binary based on just the PID, Walter?

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


[Lldb-commits] [lldb] [lldb-dap] Updating naming and documentation to follow style guide. (PR #130202)

2025-03-07 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)


Changes

Updating the naming and adding documentation to better follow the style guide.

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


2 Files Affected:

- (modified) lldb/tools/lldb-dap/OutputRedirector.cpp (+3-3) 
- (modified) lldb/tools/lldb-dap/OutputRedirector.h (+7-1) 


``diff
diff --git a/lldb/tools/lldb-dap/OutputRedirector.cpp 
b/lldb/tools/lldb-dap/OutputRedirector.cpp
index 9ff25ad4149dd..fe278faca87bf 100644
--- a/lldb/tools/lldb-dap/OutputRedirector.cpp
+++ b/lldb/tools/lldb-dap/OutputRedirector.cpp
@@ -38,7 +38,7 @@ Expected OutputRedirector::GetWriteFileDescriptor() {
   return m_fd;
 }
 
-Error OutputRedirector::RedirectTo(std::FILE *fileOverride,
+Error OutputRedirector::RedirectTo(std::FILE *file_override,
std::function callback) {
   assert(m_fd == kInvalidDescriptor && "Output readirector already started.");
   int new_fd[2];
@@ -56,8 +56,8 @@ Error OutputRedirector::RedirectTo(std::FILE *fileOverride,
   int read_fd = new_fd[0];
   m_fd = new_fd[1];
 
-  if (fileOverride) {
-int override_fd = fileno(fileOverride);
+  if (file_override) {
+int override_fd = fileno(file_override);
 
 // Backup the FD to restore once redirection is complete.
 m_original_fd = override_fd;
diff --git a/lldb/tools/lldb-dap/OutputRedirector.h 
b/lldb/tools/lldb-dap/OutputRedirector.h
index 45571c0d5f344..77b1b76ec4d89 100644
--- a/lldb/tools/lldb-dap/OutputRedirector.h
+++ b/lldb/tools/lldb-dap/OutputRedirector.h
@@ -24,10 +24,16 @@ class OutputRedirector {
   /// Creates writable file descriptor that will invoke the given callback on
   /// each write in a background thread.
   ///
+  /// \param[in] file_override
+  /// Updates the file descriptor to the redirection pipe, if not null.
+  ///
+  /// \param[in] callback
+  /// A callback invoked when any data is written to the file handle.
+  ///
   /// \return
   /// \a Error::success if the redirection was set up correctly, or an 
error
   /// otherwise.
-  llvm::Error RedirectTo(std::FILE *overrideFile,
+  llvm::Error RedirectTo(std::FILE *file_override,
  std::function callback);
 
   llvm::Expected GetWriteFileDescriptor();

``




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


[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-03-07 Thread David Spickett via lldb-commits


@@ -0,0 +1,171 @@
+//===-- Statusline.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Core/Statusline.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/FormatEntity.h"
+#include "lldb/Host/StreamFile.h"
+#include "lldb/Host/ThreadLauncher.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/StackFrame.h"
+#include "lldb/Utility/AnsiTerminal.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
+#include "llvm/Support/Locale.h"
+
+#define ESCAPE "\x1b"
+#define ANSI_NORMAL ESCAPE "[0m"
+#define ANSI_SAVE_CURSOR ESCAPE "7"
+#define ANSI_RESTORE_CURSOR ESCAPE "8"
+#define ANSI_CLEAR_BELOW ESCAPE "[J"
+#define ANSI_CLEAR_LINE "\r\x1B[2K"
+#define ANSI_SET_SCROLL_ROWS ESCAPE "[0;%ur"
+#define ANSI_TO_START_OF_ROW ESCAPE "[%u;0f"
+#define ANSI_UP_ROWS ESCAPE "[%dA"
+#define ANSI_DOWN_ROWS ESCAPE "[%dB"
+#define ANSI_FORWARD_COLS ESCAPE "\033[%dC"
+#define ANSI_BACKWARD_COLS ESCAPE "\033[%dD"
+
+using namespace lldb;
+using namespace lldb_private;
+
+static size_t ColumnWidth(llvm::StringRef str) {
+  std::string stripped = ansi::StripAnsiTerminalCodes(str);
+  return llvm::sys::locale::columnWidth(stripped);
+}
+
+Statusline::Statusline(Debugger &debugger) : m_debugger(debugger) { Enable(); }
+
+Statusline::~Statusline() { Disable(); }
+
+void Statusline::TerminalSizeChanged() {
+  m_terminal_size_has_changed = 1;
+
+  // This definitely isn't signal safe, but the best we can do, until we
+  // have proper signal-catching thread.
+  Redraw(/*update=*/false);
+}
+
+void Statusline::Enable() {
+  UpdateTerminalProperties();
+
+  // Reduce the scroll window to make space for the status bar below.
+  SetScrollWindow(m_terminal_height - 1);
+
+  // Draw the statusline.
+  Redraw();
+}
+
+void Statusline::Disable() {
+  UpdateTerminalProperties();
+
+  // Extend the scroll window to cover the status bar.
+  SetScrollWindow(m_terminal_height);

DavidSpickett wrote:

It does not move anything down, it would be very distracting if it did.

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


[Lldb-commits] [lldb] [LLDB][Telemetry]Define telemetry::CommandInfo (PR #129354)

2025-03-07 Thread Vy Nguyen via lldb-commits

oontvoo wrote:

Thanks!

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


[Lldb-commits] [lldb] de9cee1 - [LLDB][Telemetry]Define telemetry::CommandInfo (#129354)

2025-03-07 Thread via lldb-commits

Author: Vy Nguyen
Date: 2025-03-07T05:59:05-05:00
New Revision: de9cee1c97882dc69a20ac688d20a84f831b62c6

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

LOG: [LLDB][Telemetry]Define telemetry::CommandInfo  (#129354)

and collect telemetry about a command's execution.

*NOTE: Please consider this PR a DRAFT ( Waiting on PR/127696 to be
submitted. )

-

Co-authored-by: Jonas Devlieghere 

Added: 


Modified: 
lldb/include/lldb/Core/Telemetry.h
lldb/source/Core/Telemetry.cpp
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/unittests/Core/TelemetryTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
index 7d8716f1659b5..56259e4a673bf 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -13,12 +13,14 @@
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/StructuredData.h"
+#include "lldb/Utility/UUID.h"
 #include "lldb/lldb-forward.h"
 #include "llvm/ADT/FunctionExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Telemetry/Telemetry.h"
+#include 
 #include 
 #include 
 #include 
@@ -28,6 +30,17 @@
 namespace lldb_private {
 namespace telemetry {
 
+struct LLDBConfig : public ::llvm::telemetry::Config {
+  // If true, we will collect full details about a debug command (eg., args and
+  // original command). Note: This may contain PII, hence can only be enabled 
by
+  // the vendor while creating the Manager.
+  const bool detailed_command_telemetry;
+
+  explicit LLDBConfig(bool enable_telemetry, bool detailed_command_telemetry)
+  : ::llvm::telemetry::Config(enable_telemetry),
+detailed_command_telemetry(detailed_command_telemetry) {}
+};
+
 // We expect each (direct) subclass of LLDBTelemetryInfo to
 // have an LLDBEntryKind in the form 0b11
 // Specifically:
@@ -37,6 +50,7 @@ namespace telemetry {
 // must have their LLDBEntryKind in the similar form (ie., share common prefix)
 struct LLDBEntryKind : public ::llvm::telemetry::EntryKind {
   static const llvm::telemetry::KindType BaseInfo = 0b1100;
+  static const llvm::telemetry::KindType CommandInfo = 0b1101;
   static const llvm::telemetry::KindType DebuggerInfo = 0b11000100;
 };
 
@@ -66,6 +80,52 @@ struct LLDBBaseTelemetryInfo : public 
llvm::telemetry::TelemetryInfo {
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 };
 
+struct CommandInfo : public LLDBBaseTelemetryInfo {
+  /// If the command is/can be associated with a target entry this field
+  /// contains that target's UUID.  otherwise.
+  UUID target_uuid;
+  /// A unique ID for a command so the manager can match the start entry with
+  /// its end entry. These values only need to be unique within the same
+  /// session. Necessary because we'd send off an entry right before a 
command's
+  /// execution and another right after. This is to avoid losing telemetry if
+  /// the command does not execute successfully.
+  uint64_t command_id;
+  /// The command name(eg., "breakpoint set")
+  std::string command_name;
+  /// These two fields are not collected by default due to PII risks.
+  /// Vendor may allow them by setting the
+  /// LLDBConfig::detailed_command_telemetry.
+  /// @{
+  std::optional original_command;
+  std::optional args;
+  /// @}
+  /// Return status of a command and any error description in case of error.
+  std::optional ret_status;
+  std::optional error_data;
+
+  CommandInfo() = default;
+
+  llvm::telemetry::KindType getKind() const override {
+return LLDBEntryKind::CommandInfo;
+  }
+
+  static bool classof(const llvm::telemetry::TelemetryInfo *T) {
+return (T->getKind() & LLDBEntryKind::CommandInfo) ==
+   LLDBEntryKind::CommandInfo;
+  }
+
+  void serialize(llvm::telemetry::Serializer &serializer) const override;
+
+  static uint64_t GetNextId();
+
+private:
+  // We assign each command (in the same session) a unique id so that their
+  // "start" and "end" entries can be matched up.
+  // These values don't need to be unique across runs (because they are
+  // secondary-key), hence a simple counter is sufficent.
+  static std::atomic g_command_id_seed;
+};
+
 struct DebuggerInfo : public LLDBBaseTelemetryInfo {
   std::string lldb_version;
 
@@ -93,24 +153,21 @@ class TelemetryManager : public llvm::telemetry::Manager {
 public:
   llvm::Error preDispatch(llvm::telemetry::TelemetryInfo *entry) override;
 
-  const llvm::telemetry::Config *GetConfig();
+  const LLDBConfig *GetConfig() { return m_config.get(); }
 
   virtual llvm::StringRef GetInstanceName() const = 0;
 
   static TelemetryManager *GetInstance();
 
-  stati

[Lldb-commits] [lldb] [LLDB][Telemetry]Define telemetry::CommandInfo (PR #129354)

2025-03-07 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] [LLDB][Telemetry]Define telemetry::CommandInfo (PR #129354)

2025-03-07 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/129354

>From 5a992aff351a93ff820d15ace3ebc2bea59dd5fc Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Fri, 28 Feb 2025 23:03:35 -0500
Subject: [PATCH 01/22] [LLDB][Telemetry]Defind telemetry::CommandInfo and
 collect telemetry about a command's execution.

---
 lldb/include/lldb/Core/Telemetry.h| 127 +-
 lldb/source/Core/Telemetry.cpp|  14 ++
 .../source/Interpreter/CommandInterpreter.cpp |  20 +++
 3 files changed, 158 insertions(+), 3 deletions(-)

diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
index b72556ecaf3c9..30b8474156124 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -12,11 +12,14 @@
 #include "lldb/Core/StructuredDataImpl.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Utility/StructuredData.h"
+#include "lldb/Utility/LLDBLog.h"
 #include "lldb/lldb-forward.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/FunctionExtras.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Telemetry/Telemetry.h"
+#include 
 #include 
 #include 
 #include 
@@ -27,8 +30,16 @@
 namespace lldb_private {
 namespace telemetry {
 
+struct LLDBConfig : public ::llvm::telemetry::Config {
+  const bool m_collect_original_command;
+
+  explicit LLDBConfig(bool enable_telemetry, bool collect_original_command)
+  : ::llvm::telemetry::Config(enable_telemetry), 
m_collect_original_command(collect_original_command) {}
+};
+
 struct LLDBEntryKind : public ::llvm::telemetry::EntryKind {
-  static const llvm::telemetry::KindType BaseInfo = 0b11000;
+  static const llvm::telemetry::KindType BaseInfo = 0b1100;
+  static const llvm::telemetry::KindType CommandInfo = 0b1101;
 };
 
 /// Defines a convenient type for timestamp of various events.
@@ -41,6 +52,7 @@ struct LLDBBaseTelemetryInfo : public 
llvm::telemetry::TelemetryInfo {
   std::optional end_time;
   // TBD: could add some memory stats here too?
 
+  lldb::user_id_t debugger_id = LLDB_INVALID_UID;
   Debugger *debugger;
 
   // For dyn_cast, isa, etc operations.
@@ -56,6 +68,42 @@ struct LLDBBaseTelemetryInfo : public 
llvm::telemetry::TelemetryInfo {
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 };
 
+
+struct CommandInfo : public LLDBBaseTelemetryInfo {
+
+  // If the command is/can be associated with a target entry this field 
contains
+  // that target's UUID.  otherwise.
+  std::string target_uuid;
+  // A unique ID for a command so the manager can match the start entry with
+  // its end entry. These values only need to be unique within the same 
session.
+  // Necessary because we'd send off an entry right before a command's 
execution
+  // and another right after. This is to avoid losing telemetry if the command
+  // does not execute successfully.
+  int command_id;
+
+  // Eg., "breakpoint set"
+  std::string command_name;
+
+  // !!NOTE!! These two fields are not collected (upstream) due to PII risks.
+  // (Downstream impl may add them if needed).
+  // std::string original_command;
+  // std::string args;
+
+  lldb::ReturnStatus ret_status;
+  std::string error_data;
+
+
+  CommandInfo() = default;
+
+  llvm::telemetry::KindType getKind() const override { return 
LLDBEntryKind::CommandInfo; }
+
+  static bool classof(const llvm::telemetry::TelemetryInfo *T) {
+return (T->getKind() & LLDBEntryKind::CommandInfo) == 
LLDBEntryKind::CommandInfo;
+  }
+
+  void serialize(Serializer &serializer) const override;
+};
+
 /// The base Telemetry manager instance in LLDB.
 /// This class declares additional instrumentation points
 /// applicable to LLDB.
@@ -63,19 +111,92 @@ class TelemetryManager : public llvm::telemetry::Manager {
 public:
   llvm::Error preDispatch(llvm::telemetry::TelemetryInfo *entry) override;
 
+  int MakeNextCommandId();
+
+  LLDBConfig* GetConfig() { return m_config.get(); }
+
   virtual llvm::StringRef GetInstanceName() const = 0;
   static TelemetryManager *getInstance();
 
 protected:
-  TelemetryManager(std::unique_ptr config);
+  TelemetryManager(std::unique_ptr config);
 
   static void setInstance(std::unique_ptr manger);
 
 private:
-  std::unique_ptr m_config;
+  std::unique_ptr m_config;
+  const std::string m_id;
+  // We assign each command (in the same session) a unique id so that their
+  // "start" and "end" entries can be matched up.
+  // These values don't need to be unique across runs (because they are
+  // secondary-key), hence a simple counter is sufficent.
+  std::atomic command_id_seed = 0;
   static std::unique_ptr g_instance;
 };
 
+/// Helper RAII class for collecting telemetry.
+template  struct ScopedDispatcher {
+  // The debugger pointer is optional because we may not have a debugger yet.
+  // In that case, caller must set the debugger later.
+  ScopedDispatcher(Debugger *debugger = nullptr) {
+// Sta

[Lldb-commits] [lldb] [lldb-dap] Add process picker command to VS Code extension (PR #128943)

2025-03-07 Thread Matthew Bastien via lldb-commits


@@ -0,0 +1,42 @@
+import * as path from "path";
+import * as vscode from "vscode";
+import { createProcessTree } from "../process-tree";
+
+interface ProcessQuickPick extends vscode.QuickPickItem {
+  processId: number;
+}
+
+/**
+ * Prompts the user to select a running process.
+ *
+ * The return value must be a string so that it is compatible with VS Code's
+ * string substitution infrastructure. The value will eventually be converted
+ * to a number by the debug configuration provider.
+ *
+ * @returns The pid of the process as a string or undefined if cancelled.
+ */
+export async function pickProcess(): Promise {

matthewbastien wrote:

I really like this idea! I've added a filter to the process picker if the 
`program` is also set.

As a side note: I hadn't actually anticipated setting both `pid` and `program` 
at the same time. I accidentally left the `program` property in my example 
launch configuration.

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


[Lldb-commits] [lldb] [lldb-dap] Restore the override FD used by the output redirect on stop. (PR #129964)

2025-03-07 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`cross-project-tests-sie-ubuntu` running on `doug-worker-1a` while building 
`lldb` at step 5 "build-unified-tree".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/181/builds/14956


Here is the relevant piece of the build log for the reference

```
Step 5 (build-unified-tree) failure: build (failure)
...
1.017 [157/8/8] Building CXX object 
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Version.cpp.o
2.364 [156/8/9] Building CXX object 
tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/FunctionBreakpoint.cpp.o
3.163 [155/8/10] Building CXX object 
tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/EventHelper.cpp.o
3.369 [154/8/11] Building CXX object 
tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/ExceptionBreakpoint.cpp.o
4.180 [153/8/12] Building CXX object 
lib/Object/CMakeFiles/LLVMObject.dir/IRSymtab.cpp.o
4.287 [152/8/13] Linking CXX static library lib/libLLVMObject.a
4.677 [151/8/14] Building CXX object 
tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/InstructionBreakpoint.cpp.o
5.787 [150/8/15] Building CXX object 
tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/DAP.cpp.o
5.939 [149/8/16] Building CXX object 
tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/LLDBUtils.cpp.o
6.581 [148/8/17] Building CXX object 
tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o
FAILED: 
tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o 
/opt/ccache/bin/g++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -DLLVM_BUILD_STATIC 
-D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/tools/lldb/tools/lldb-dap
 
-I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/tools/lldb-dap
 
-I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/include
 
-I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/tools/lldb/include
 -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/include 
-I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/include
 -I/usr/include/python3.8 
-I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../clang/include
 
-I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/tools/lldb/../clang/include
 -isystem /usr/include/libxml2 -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move 
-Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor 
-Wsuggest-override -Wno-comment -Wno-misleading-indentation -fdiagnostics-color 
-ffunction-sections -fdata-sections -Wno-unknown-pragmas -Wno-strict-aliasing 
-Wno-stringop-truncation -O3 -DNDEBUG  -fno-exceptions -funwind-tables 
-fno-rtti -UNDEBUG -std=c++17 -MD -MT 
tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o -MF 
tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o.d -o 
tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o -c 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/tools/lldb-dap/OutputRedirector.cpp
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/tools/lldb-dap/OutputRedirector.cpp:
 In member function ‘llvm::Error lldb_dap::OutputRedirector::RedirectTo(FILE*, 
std::function)’:
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/tools/lldb-dap/OutputRedirector.cpp:59:7:
 error: ‘override’ was not declared in this scope
   59 |   if (override) {
  |   ^~~~
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/tools/lldb-dap/OutputRedirector.cpp:
 In member function ‘void lldb_dap::OutputRedirector::Stop()’:
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/tools/lldb-dap/OutputRedirector.cpp:108:18:
 warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’, 
declared with attribute warn_unused_result [-Wunused-result]
  108 | (void)::write(fd, kCloseSentinel.data(), kCloseSentinel.size());
  |   ~~~^~
7.321 [148/7/18] Building CXX object 
tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/lldb-dap.cpp.o
7.533 [148/6/19] Building CXX object 
tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/SourceBreakpoint.cpp.o
8.283 [148/5/20] Building CXX object 
tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/JSONUtils.cpp.o
8.395 [148/4/21] Building CXX object 
tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Watchpoint.cpp.o
8.708 [148/3/22] Building CXX object 
tools/lldb/tools/lldb-da

[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-03-07 Thread David Spickett via lldb-commits

DavidSpickett wrote:

I had to try some Unicode of course. I think you have a TODO in there about 
this already but just because it was fun...
```
>>> "東".encode()
b'\xe6\x9d\xb1'
>>> "a".encode()
b'a'
```
I can get way more 'a' before I get the '...' than '東'. Same for an emoji, 
which is a more likely use case. They do display though so as long as you're 
not going to hit the column limit anyway, you would never know.

Also editing these unicode strings in LLDB is rather strange, presumably 
because of the same character counting issue (could be my terminal though).

I thought that the calculation for the end might be off:
```
(lldb) settings set statusline-format 
"a"
(lldb)
a
   << terminal ends here, there are 3 empty columns.
```
If I set it to one more I get the ...
```
(lldb) settings set statusline-format 
"aa"
(lldb)
aa...

[Lldb-commits] [lldb] [lldb-dap] Add process picker command to VS Code extension (PR #128943)

2025-03-07 Thread Matthew Bastien via lldb-commits

https://github.com/matthewbastien updated 
https://github.com/llvm/llvm-project/pull/128943

>From b9083ea16c7b1dba70cc04acf78f5001f0fb86c6 Mon Sep 17 00:00:00 2001
From: Matthew Bastien 
Date: Wed, 26 Feb 2025 11:18:21 -0500
Subject: [PATCH 01/11] add a process picker for attaching by PID

---
 lldb/tools/lldb-dap/package.json  |  30 +-
 .../lldb-dap/src-ts/commands/pick-process.ts  |  37 +++
 lldb/tools/lldb-dap/src-ts/extension.ts   |   7 +-
 .../src-ts/process-tree/base-process-tree.ts  | 102 ++
 .../lldb-dap/src-ts/process-tree/index.ts |  36 +++
 .../platforms/darwin-process-tree.ts  |  16 +++
 .../platforms/linux-process-tree.ts   |  38 +++
 .../platforms/windows-process-tree.ts |  52 +
 8 files changed, 315 insertions(+), 3 deletions(-)
 create mode 100644 lldb/tools/lldb-dap/src-ts/commands/pick-process.ts
 create mode 100644 lldb/tools/lldb-dap/src-ts/process-tree/base-process-tree.ts
 create mode 100644 lldb/tools/lldb-dap/src-ts/process-tree/index.ts
 create mode 100644 
lldb/tools/lldb-dap/src-ts/process-tree/platforms/darwin-process-tree.ts
 create mode 100644 
lldb/tools/lldb-dap/src-ts/process-tree/platforms/linux-process-tree.ts
 create mode 100644 
lldb/tools/lldb-dap/src-ts/process-tree/platforms/windows-process-tree.ts

diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index 31d808eda4c35..1bbdbf045dd1b 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -146,6 +146,9 @@
 "windows": {
   "program": "./bin/lldb-dap.exe"
 },
+"variables": {
+  "PickProcess": "lldb-dap.pickProcess"
+},
 "configurationAttributes": {
   "launch": {
 "required": [
@@ -517,6 +520,16 @@
   "cwd": "^\"\\${workspaceRoot}\""
 }
   },
+  {
+"label": "LLDB: Attach to Process",
+"description": "",
+"body": {
+  "type": "lldb-dap",
+  "request": "attach",
+  "name": "${1:Attach}",
+  "pid": "^\"\\${command:PickProcess}\""
+}
+  },
   {
 "label": "LLDB: Attach",
 "description": "",
@@ -541,6 +554,21 @@
   }
 ]
   }
-]
+],
+"commands": [
+  {
+"command": "lldb-dap.pickProcess",
+"title": "Pick Process",
+"category": "LLDB DAP"
+  }
+],
+"menus": {
+  "commandPalette": [
+{
+  "command": "lldb-dap.pickProcess",
+  "when": "false"
+}
+  ]
+}
   }
 }
diff --git a/lldb/tools/lldb-dap/src-ts/commands/pick-process.ts 
b/lldb/tools/lldb-dap/src-ts/commands/pick-process.ts
new file mode 100644
index 0..b83e749e7da7b
--- /dev/null
+++ b/lldb/tools/lldb-dap/src-ts/commands/pick-process.ts
@@ -0,0 +1,37 @@
+import * as path from "path";
+import * as vscode from "vscode";
+import { createProcessTree } from "../process-tree";
+
+interface ProcessQuickPick extends vscode.QuickPickItem {
+  processId: number;
+}
+
+/**
+ * Prompts the user to select a running process.
+ *
+ * @returns The pid of the process as a string or undefined if cancelled.
+ */
+export async function pickProcess(): Promise {
+  const processTree = createProcessTree();
+  const selectedProcess = await vscode.window.showQuickPick(
+processTree.listAllProcesses().then((processes): ProcessQuickPick[] => {
+  return processes
+.sort((a, b) => b.start - a.start) // Sort by start date in descending 
order
+.map((proc) => {
+  return {
+processId: proc.id,
+label: path.basename(proc.command),
+description: proc.id.toString(),
+detail: proc.arguments,
+  } satisfies ProcessQuickPick;
+});
+}),
+{
+  placeHolder: "Select a process to attach the debugger to",
+},
+  );
+  if (!selectedProcess) {
+return;
+  }
+  return selectedProcess.processId.toString();
+}
diff --git a/lldb/tools/lldb-dap/src-ts/extension.ts 
b/lldb/tools/lldb-dap/src-ts/extension.ts
index 71fd48298f8f5..3532a2143155b 100644
--- a/lldb/tools/lldb-dap/src-ts/extension.ts
+++ b/lldb/tools/lldb-dap/src-ts/extension.ts
@@ -1,7 +1,6 @@
-import * as path from "path";
-import * as util from "util";
 import * as vscode from "vscode";
 
+import { pickProcess } from "./commands/pick-process";
 import {
   LLDBDapDescriptorFactory,
   isExecutable,
@@ -38,6 +37,10 @@ export class LLDBDapExtension extends DisposableContext {
 }
   }),
 );
+
+this.pushSubscription(
+  vscode.commands.registerCommand("lldb-dap.pickProcess", pickProcess),
+);
   }
 }
 
diff --git a/lldb/tools/lldb-dap/src-ts/process-tree/base-process-tree.ts 
b/lldb/tools/lldb-dap/src-ts/process-tree/base-process-tree.ts
new file mode 100644
index 0..3c08f49035b35
--- /dev/nul

[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-03-07 Thread David Spickett via lldb-commits


@@ -1925,6 +1959,17 @@ void Debugger::CancelForwardEvents(const ListenerSP 
&listener_sp) {
   m_forward_listener_sp.reset();
 }
 
+bool Debugger::StatuslineSupported() {
+  if (GetShowStatusline()) {
+if (lldb::LockableStreamFileSP stream_sp = GetOutputStreamSP()) {
+  File &file = stream_sp->GetUnlockedFile();
+  return file.GetIsInteractive() && file.GetIsRealTerminal() &&
+ file.GetIsTerminalWithColors();

DavidSpickett wrote:

If I set the setting via `-o "settings set use-color false"`, the initial 
status bar does not use colour, which is good.

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


[Lldb-commits] [lldb] [lldb] Add more ARM checks in TestLldbGdbServer.py (PR #130277)

2025-03-07 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)


Changes

When https://github.com/llvm/llvm-project/pull/130034 enabled RISC-V here I 
noticed that these should run for ARM as well.

ARM only has 4 argument registers, which matches Arm's ABI for it: 
https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst#core-registers

The ABI defines a link register LR, and I assume that's what becomes 'ra' in 
LLDB.

Tested on ARM and AArch64 Linux.

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


2 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/lldbtest.py (+7) 
- (modified) lldb/test/API/tools/lldb-server/TestLldbGdbServer.py (+4-4) 


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 7d0e6e9a970eb..590024ef77119 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1344,6 +1344,13 @@ def isAArch64(self):
 arch = self.getArchitecture().lower()
 return arch in ["aarch64", "arm64", "arm64e"]
 
+def isARM(self):
+"""Returns true if the architecture is ARM, meaning 32-bit ARM. Which 
could
+be M profile, A profile Armv7-a, or the AArch32 mode of Armv8-a."""
+return not self.isAArch64() and (
+self.getArchitecture().lower().startswith("arm")
+)
+
 def isAArch64SVE(self):
 return self.isAArch64() and "sve" in self.getCPUInfo()
 
diff --git a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py 
b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
index ce75e3e89e0a6..12c97bc62dcef 100644
--- a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
+++ b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
@@ -199,12 +199,12 @@ def 
test_qRegisterInfo_contains_required_generics_debugserver(self):
 if not self.isRISCV():
 self.assertIn("flags", generic_regs)
 
-if self.isRISCV():
-# Special RISC-V register for a return address
+if self.isRISCV() or self.isAArch64() or self.isARM():
+# Specific register for a return address
 self.assertIn("ra", generic_regs)
 
-# RISC-V's function arguments registers
-for i in range(1, 9):
+# Function arguments registers
+for i in range(1, 5 if self.isARM() else 9):
 self.assertIn(f"arg{i}", generic_regs)
 
 def test_qRegisterInfo_contains_at_least_one_register_set(self):

``




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


[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-03-07 Thread David Spickett via lldb-commits

DavidSpickett wrote:

> displayed the bottom of the screen

displayed **at** the bottom of the screen

> The statusline supersedes the current progress reporting implementation.

I will find this out looking at the code shortly, but - does this mean that if 
you disable the statusline, you get the current progress reporting 
implementation, or not progress reporting at all?

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


[Lldb-commits] [lldb] [lldb-dap] Add process picker command to VS Code extension (PR #128943)

2025-03-07 Thread Matthew Bastien via lldb-commits

matthewbastien wrote:

> You can go one level beyond this and provide a way to attach to programs 
> without needing launch.json configs at all!
> 
> 1. Create a new pallete command "attach to process"
> 2. Reuse the same process picker and once the user has selected one item, 
> issue a vscode.debug.StartDebugging() call passing a minimal debug config 
> with the selected process as PID.

That's a great idea and simple to add! I've added a new command `LLDB DAP: 
Attach to process...` in the command palette.

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


[Lldb-commits] [lldb] [lldb-dap] Restore the override FD used by the output redirect on stop. (PR #129964)

2025-03-07 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-03-07 Thread David Spickett via lldb-commits


@@ -0,0 +1,171 @@
+//===-- Statusline.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Core/Statusline.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/FormatEntity.h"
+#include "lldb/Host/StreamFile.h"
+#include "lldb/Host/ThreadLauncher.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/StackFrame.h"
+#include "lldb/Utility/AnsiTerminal.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
+#include "llvm/Support/Locale.h"
+
+#define ESCAPE "\x1b"
+#define ANSI_NORMAL ESCAPE "[0m"
+#define ANSI_SAVE_CURSOR ESCAPE "7"
+#define ANSI_RESTORE_CURSOR ESCAPE "8"
+#define ANSI_CLEAR_BELOW ESCAPE "[J"
+#define ANSI_CLEAR_LINE "\r\x1B[2K"
+#define ANSI_SET_SCROLL_ROWS ESCAPE "[0;%ur"
+#define ANSI_TO_START_OF_ROW ESCAPE "[%u;0f"
+#define ANSI_UP_ROWS ESCAPE "[%dA"
+#define ANSI_DOWN_ROWS ESCAPE "[%dB"
+#define ANSI_FORWARD_COLS ESCAPE "\033[%dC"
+#define ANSI_BACKWARD_COLS ESCAPE "\033[%dD"
+
+using namespace lldb;
+using namespace lldb_private;
+
+static size_t ColumnWidth(llvm::StringRef str) {
+  std::string stripped = ansi::StripAnsiTerminalCodes(str);
+  return llvm::sys::locale::columnWidth(stripped);
+}
+
+Statusline::Statusline(Debugger &debugger) : m_debugger(debugger) { Enable(); }
+
+Statusline::~Statusline() { Disable(); }
+
+void Statusline::TerminalSizeChanged() {
+  m_terminal_size_has_changed = 1;
+
+  // This definitely isn't signal safe, but the best we can do, until we
+  // have proper signal-catching thread.
+  Redraw(/*update=*/false);
+}
+
+void Statusline::Enable() {
+  UpdateTerminalProperties();
+
+  // Reduce the scroll window to make space for the status bar below.
+  SetScrollWindow(m_terminal_height - 1);
+
+  // Draw the statusline.
+  Redraw();
+}
+
+void Statusline::Disable() {
+  UpdateTerminalProperties();
+
+  // Extend the scroll window to cover the status bar.
+  SetScrollWindow(m_terminal_height);
+}
+
+void Statusline::Draw(std::string str) {
+  static constexpr const size_t g_ellipsis = 3;
+
+  UpdateTerminalProperties();
+
+  m_last_str = str;
+
+  size_t column_width = ColumnWidth(str);
+
+  if (column_width + g_ellipsis >= m_terminal_width) {
+// FIXME: If there are hidden characters (e.g. UTF-8, ANSI escape
+// characters), this will strip the string more than necessary. Ideally we
+// want to strip until column_width == m_terminal_width.
+str = str.substr(0, m_terminal_width);
+str.replace(m_terminal_width - g_ellipsis, g_ellipsis, "...");
+column_width = ColumnWidth(str);
+  }
+
+  if (lldb::LockableStreamFileSP stream_sp = m_debugger.GetOutputStreamSP()) {
+LockedStreamFile locked_stream = stream_sp->Lock();
+locked_stream << ANSI_SAVE_CURSOR;
+locked_stream.Printf(ANSI_TO_START_OF_ROW,
+ static_cast(m_terminal_height));

DavidSpickett wrote:

Are rows 1 based then? Add a comment to mention that if so.

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


[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-03-07 Thread David Spickett via lldb-commits


@@ -0,0 +1,171 @@
+//===-- Statusline.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Core/Statusline.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/FormatEntity.h"
+#include "lldb/Host/StreamFile.h"
+#include "lldb/Host/ThreadLauncher.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/StackFrame.h"
+#include "lldb/Utility/AnsiTerminal.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
+#include "llvm/Support/Locale.h"
+
+#define ESCAPE "\x1b"
+#define ANSI_NORMAL ESCAPE "[0m"
+#define ANSI_SAVE_CURSOR ESCAPE "7"
+#define ANSI_RESTORE_CURSOR ESCAPE "8"
+#define ANSI_CLEAR_BELOW ESCAPE "[J"
+#define ANSI_CLEAR_LINE "\r\x1B[2K"
+#define ANSI_SET_SCROLL_ROWS ESCAPE "[0;%ur"
+#define ANSI_TO_START_OF_ROW ESCAPE "[%u;0f"
+#define ANSI_UP_ROWS ESCAPE "[%dA"
+#define ANSI_DOWN_ROWS ESCAPE "[%dB"
+#define ANSI_FORWARD_COLS ESCAPE "\033[%dC"
+#define ANSI_BACKWARD_COLS ESCAPE "\033[%dD"
+
+using namespace lldb;
+using namespace lldb_private;
+
+static size_t ColumnWidth(llvm::StringRef str) {
+  std::string stripped = ansi::StripAnsiTerminalCodes(str);
+  return llvm::sys::locale::columnWidth(stripped);
+}
+
+Statusline::Statusline(Debugger &debugger) : m_debugger(debugger) { Enable(); }
+
+Statusline::~Statusline() { Disable(); }
+
+void Statusline::TerminalSizeChanged() {
+  m_terminal_size_has_changed = 1;
+
+  // This definitely isn't signal safe, but the best we can do, until we
+  // have proper signal-catching thread.
+  Redraw(/*update=*/false);
+}
+
+void Statusline::Enable() {
+  UpdateTerminalProperties();
+
+  // Reduce the scroll window to make space for the status bar below.
+  SetScrollWindow(m_terminal_height - 1);
+
+  // Draw the statusline.
+  Redraw();
+}
+
+void Statusline::Disable() {
+  UpdateTerminalProperties();
+
+  // Extend the scroll window to cover the status bar.
+  SetScrollWindow(m_terminal_height);
+}
+
+void Statusline::Draw(std::string str) {
+  static constexpr const size_t g_ellipsis = 3;
+
+  UpdateTerminalProperties();
+
+  m_last_str = str;
+
+  size_t column_width = ColumnWidth(str);
+
+  if (column_width + g_ellipsis >= m_terminal_width) {
+// FIXME: If there are hidden characters (e.g. UTF-8, ANSI escape
+// characters), this will strip the string more than necessary. Ideally we
+// want to strip until column_width == m_terminal_width.
+str = str.substr(0, m_terminal_width);
+str.replace(m_terminal_width - g_ellipsis, g_ellipsis, "...");
+column_width = ColumnWidth(str);
+  }
+
+  if (lldb::LockableStreamFileSP stream_sp = m_debugger.GetOutputStreamSP()) {

DavidSpickett wrote:

If we don't have an output steam sp here, was there any point doing the work 
above?

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


[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-03-07 Thread David Spickett via lldb-commits


@@ -1912,7 +1919,30 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
   return true;
 }
 return false;
+
+  case Entry::Type::ProgressCount:
+if (Target *target = Target::GetTargetFromContexts(exe_ctx, sc)) {
+  Debugger &debugger = target->GetDebugger();

DavidSpickett wrote:

You could combine this into the if below to save a line. Given that you have no 
null checking for target and GetDebugger returns a reference, you're assuming 
it will succeed.

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


[Lldb-commits] [lldb] [lldb-dap] Updating naming and documentation to follow style guide. (PR #130202)

2025-03-07 Thread Jacob Lalonde via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-03-07 Thread David Spickett via lldb-commits


@@ -0,0 +1,171 @@
+//===-- Statusline.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Core/Statusline.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/FormatEntity.h"
+#include "lldb/Host/StreamFile.h"
+#include "lldb/Host/ThreadLauncher.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/StackFrame.h"
+#include "lldb/Utility/AnsiTerminal.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
+#include "llvm/Support/Locale.h"
+
+#define ESCAPE "\x1b"
+#define ANSI_NORMAL ESCAPE "[0m"
+#define ANSI_SAVE_CURSOR ESCAPE "7"
+#define ANSI_RESTORE_CURSOR ESCAPE "8"
+#define ANSI_CLEAR_BELOW ESCAPE "[J"
+#define ANSI_CLEAR_LINE "\r\x1B[2K"
+#define ANSI_SET_SCROLL_ROWS ESCAPE "[0;%ur"
+#define ANSI_TO_START_OF_ROW ESCAPE "[%u;0f"
+#define ANSI_UP_ROWS ESCAPE "[%dA"
+#define ANSI_DOWN_ROWS ESCAPE "[%dB"
+#define ANSI_FORWARD_COLS ESCAPE "\033[%dC"
+#define ANSI_BACKWARD_COLS ESCAPE "\033[%dD"
+
+using namespace lldb;
+using namespace lldb_private;
+
+static size_t ColumnWidth(llvm::StringRef str) {
+  std::string stripped = ansi::StripAnsiTerminalCodes(str);
+  return llvm::sys::locale::columnWidth(stripped);
+}
+
+Statusline::Statusline(Debugger &debugger) : m_debugger(debugger) { Enable(); }
+
+Statusline::~Statusline() { Disable(); }
+
+void Statusline::TerminalSizeChanged() {
+  m_terminal_size_has_changed = 1;
+
+  // This definitely isn't signal safe, but the best we can do, until we
+  // have proper signal-catching thread.
+  Redraw(/*update=*/false);
+}
+
+void Statusline::Enable() {
+  UpdateTerminalProperties();
+
+  // Reduce the scroll window to make space for the status bar below.
+  SetScrollWindow(m_terminal_height - 1);
+
+  // Draw the statusline.
+  Redraw();
+}
+
+void Statusline::Disable() {
+  UpdateTerminalProperties();
+
+  // Extend the scroll window to cover the status bar.
+  SetScrollWindow(m_terminal_height);
+}
+
+void Statusline::Draw(std::string str) {
+  static constexpr const size_t g_ellipsis = 3;

DavidSpickett wrote:

Add _len on the end of this, something to say it isn't the "..." string itself.

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


[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-03-07 Thread David Spickett via lldb-commits


@@ -1925,6 +1959,17 @@ void Debugger::CancelForwardEvents(const ListenerSP 
&listener_sp) {
   m_forward_listener_sp.reset();
 }
 
+bool Debugger::StatuslineSupported() {
+  if (GetShowStatusline()) {
+if (lldb::LockableStreamFileSP stream_sp = GetOutputStreamSP()) {
+  File &file = stream_sp->GetUnlockedFile();
+  return file.GetIsInteractive() && file.GetIsRealTerminal() &&
+ file.GetIsTerminalWithColors();

DavidSpickett wrote:

Maybe WithColours means can support colours not whether lldb has been told to 
use them.

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


[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-03-07 Thread David Spickett via lldb-commits


@@ -1925,6 +1959,17 @@ void Debugger::CancelForwardEvents(const ListenerSP 
&listener_sp) {
   m_forward_listener_sp.reset();
 }
 
+bool Debugger::StatuslineSupported() {
+  if (GetShowStatusline()) {
+if (lldb::LockableStreamFileSP stream_sp = GetOutputStreamSP()) {
+  File &file = stream_sp->GetUnlockedFile();
+  return file.GetIsInteractive() && file.GetIsRealTerminal() &&
+ file.GetIsTerminalWithColors();

DavidSpickett wrote:

So we cannot use the status line without colours, is this intentional?

It would be a niche audience for sure but you could come up with a format 
string that made it stand out without colour I think.

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


[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-03-07 Thread David Spickett via lldb-commits


@@ -0,0 +1,171 @@
+//===-- Statusline.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Core/Statusline.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/FormatEntity.h"
+#include "lldb/Host/StreamFile.h"
+#include "lldb/Host/ThreadLauncher.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/StackFrame.h"
+#include "lldb/Utility/AnsiTerminal.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
+#include "llvm/Support/Locale.h"
+
+#define ESCAPE "\x1b"
+#define ANSI_NORMAL ESCAPE "[0m"
+#define ANSI_SAVE_CURSOR ESCAPE "7"
+#define ANSI_RESTORE_CURSOR ESCAPE "8"
+#define ANSI_CLEAR_BELOW ESCAPE "[J"
+#define ANSI_CLEAR_LINE "\r\x1B[2K"
+#define ANSI_SET_SCROLL_ROWS ESCAPE "[0;%ur"
+#define ANSI_TO_START_OF_ROW ESCAPE "[%u;0f"
+#define ANSI_UP_ROWS ESCAPE "[%dA"
+#define ANSI_DOWN_ROWS ESCAPE "[%dB"
+#define ANSI_FORWARD_COLS ESCAPE "\033[%dC"
+#define ANSI_BACKWARD_COLS ESCAPE "\033[%dD"
+
+using namespace lldb;
+using namespace lldb_private;
+
+static size_t ColumnWidth(llvm::StringRef str) {
+  std::string stripped = ansi::StripAnsiTerminalCodes(str);
+  return llvm::sys::locale::columnWidth(stripped);
+}
+
+Statusline::Statusline(Debugger &debugger) : m_debugger(debugger) { Enable(); }
+
+Statusline::~Statusline() { Disable(); }
+
+void Statusline::TerminalSizeChanged() {
+  m_terminal_size_has_changed = 1;
+
+  // This definitely isn't signal safe, but the best we can do, until we
+  // have proper signal-catching thread.
+  Redraw(/*update=*/false);
+}
+
+void Statusline::Enable() {
+  UpdateTerminalProperties();
+
+  // Reduce the scroll window to make space for the status bar below.
+  SetScrollWindow(m_terminal_height - 1);
+
+  // Draw the statusline.
+  Redraw();
+}
+
+void Statusline::Disable() {
+  UpdateTerminalProperties();
+
+  // Extend the scroll window to cover the status bar.
+  SetScrollWindow(m_terminal_height);

DavidSpickett wrote:

Does this actually move things down or is there a blank line until you output 
some more data? Either is fine, just curious.

(going to try this out locally, so I will find out myself I expect)

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


[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-03-07 Thread David Spickett via lldb-commits


@@ -0,0 +1,171 @@
+//===-- Statusline.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Core/Statusline.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/FormatEntity.h"
+#include "lldb/Host/StreamFile.h"
+#include "lldb/Host/ThreadLauncher.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/StackFrame.h"
+#include "lldb/Utility/AnsiTerminal.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
+#include "llvm/Support/Locale.h"
+
+#define ESCAPE "\x1b"
+#define ANSI_NORMAL ESCAPE "[0m"
+#define ANSI_SAVE_CURSOR ESCAPE "7"
+#define ANSI_RESTORE_CURSOR ESCAPE "8"
+#define ANSI_CLEAR_BELOW ESCAPE "[J"
+#define ANSI_CLEAR_LINE "\r\x1B[2K"
+#define ANSI_SET_SCROLL_ROWS ESCAPE "[0;%ur"
+#define ANSI_TO_START_OF_ROW ESCAPE "[%u;0f"
+#define ANSI_UP_ROWS ESCAPE "[%dA"
+#define ANSI_DOWN_ROWS ESCAPE "[%dB"
+#define ANSI_FORWARD_COLS ESCAPE "\033[%dC"
+#define ANSI_BACKWARD_COLS ESCAPE "\033[%dD"
+
+using namespace lldb;
+using namespace lldb_private;
+
+static size_t ColumnWidth(llvm::StringRef str) {
+  std::string stripped = ansi::StripAnsiTerminalCodes(str);
+  return llvm::sys::locale::columnWidth(stripped);
+}
+
+Statusline::Statusline(Debugger &debugger) : m_debugger(debugger) { Enable(); }
+
+Statusline::~Statusline() { Disable(); }
+
+void Statusline::TerminalSizeChanged() {
+  m_terminal_size_has_changed = 1;
+
+  // This definitely isn't signal safe, but the best we can do, until we
+  // have proper signal-catching thread.

DavidSpickett wrote:

What happens if we get unlucky here, will it just be mangled until the next 
redraw happens?

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


[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-03-07 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-03-07 Thread David Spickett via lldb-commits


@@ -172,6 +172,14 @@ let Definition = "debugger" in {
 Global,
 DefaultStringValue<"${ansi.normal}">,
 Desc<"When displaying progress in a color-enabled terminal, use the ANSI 
terminal code specified in this format immediately after the progress 
message.">;
+  def ShowStatusline: Property<"show-statusline", "Boolean">,
+Global,
+DefaultTrue,
+Desc<"Whether to show a statusline at the bottom of the terminal.">;
+  def StatuslineFormat: Property<"statusline-format", "FormatEntity">,
+Global,
+
DefaultStringValue<"${ansi.bg.blue}${ansi.fg.black}{${target.file.basename}}{ | 
${line.file.basename}:${line.number}:${line.column}}{ | ${thread.stop-reason}}{ 
| {${progress.count} }${progress.message}}">,
+Desc<"List of statusline format entities.">;

DavidSpickett wrote:

How does someone discover what format entities are and what they can choose 
from?

The website search doesn't find anything but Google points me to 
https://lldb.llvm.org/use/variable.html. Are they the same thing?

Obviously we wouldn't list them in this option description but if we have 
another option or command that does use them and does talk about them already, 
we could reference that.

Otherwise we don't have a good answer to "is there a format entity for X", just 
like we get asked "is there an API for Y", because finding API calls can be 
tricky if you don't know the project already.

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


[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-03-07 Thread David Spickett via lldb-commits


@@ -765,6 +765,8 @@ def setUpCommands(cls):
 # Disable fix-its by default so that incorrect expressions in 
tests don't
 # pass just because Clang thinks it has a fix-it.
 "settings set target.auto-apply-fixits false",
+# Disable the statusline in PExpect tests.
+"settings set show-statusline false",

DavidSpickett wrote:

Isn't this disabling the statusline in all tests not just PExpect?

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


[Lldb-commits] [lldb] [lldb-dap] Refactoring IOStream into Transport handler. (PR #130026)

2025-03-07 Thread Adrian Vogelsgesang via lldb-commits


@@ -237,65 +238,25 @@ void DAP::StopEventHandlers() {
   }
 }
 
-// Send the JSON in "json_str" to the "out" stream. Correctly send the
-// "Content-Length:" field followed by the length, followed by the raw
-// JSON bytes.
-void DAP::SendJSON(const std::string &json_str) {
-  output.write_full("Content-Length: ");
-  output.write_full(llvm::utostr(json_str.size()));
-  output.write_full("\r\n\r\n");
-  output.write_full(json_str);
-}
-
 // Serialize the JSON value into a string and send the JSON packet to
 // the "out" stream.
 void DAP::SendJSON(const llvm::json::Value &json) {
-  std::string json_str;
-  llvm::raw_string_ostream strm(json_str);
-  strm << json;
-  static std::mutex mutex;
-  std::lock_guard locker(mutex);
-  SendJSON(json_str);
-
-  if (log) {
-auto now = std::chrono::duration(
-std::chrono::system_clock::now().time_since_epoch());
-*log << llvm::formatv("{0:f9} {1} <-- ", now.count(), name).str()
- << std::endl
- << "Content-Length: " << json_str.size() << "\r\n\r\n"
- << llvm::formatv("{0:2}", json).str() << std::endl;
-  }
-}
-
-// Read a JSON packet from the "in" stream.
-std::string DAP::ReadJSON() {
-  std::string length_str;
-  std::string json_str;
-  int length;
-
-  if (!input.read_expected(log, "Content-Length: "))
-return json_str;
-
-  if (!input.read_line(log, length_str))
-return json_str;
-
-  if (!llvm::to_integer(length_str, length))
-return json_str;
-
-  if (!input.read_expected(log, "\r\n"))
-return json_str;
-
-  if (!input.read_full(log, length, json_str))
-return json_str;
-
-  if (log) {
-auto now = std::chrono::duration(
-std::chrono::system_clock::now().time_since_epoch());
-*log << llvm::formatv("{0:f9} {1} --> ", now.count(), name).str()
- << std::endl
- << "Content-Length: " << length << "\r\n\r\n";
+  protocol::Message M;
+  llvm::json::Path::Root root;
+  if (!protocol::fromJSON(json, M, root)) {

vogelsgesang wrote:

I assume this is only temporary?

```suggestion
  // FIXME: Instead of parsing the output message from JSON, pass the `Message` 
as parameter to `SendJSON`
  if (!protocol::fromJSON(json, M, root)) {
```

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


[Lldb-commits] [lldb] [lldb-dap] Add process picker command to VS Code extension (PR #128943)

2025-03-07 Thread via lldb-commits


@@ -0,0 +1,57 @@
+import * as path from "path";
+import * as vscode from "vscode";
+import { createProcessTree } from "../process-tree";
+
+interface ProcessQuickPick extends vscode.QuickPickItem {
+  processId?: number;
+}
+
+/**
+ * Prompts the user to select a running process.
+ *
+ * The return value must be a string so that it is compatible with VS Code's
+ * string substitution infrastructure. The value will eventually be converted
+ * to a number by the debug configuration provider.
+ *
+ * @param configuration The related debug configuration, if any
+ * @returns The pid of the process as a string or undefined if cancelled.
+ */
+export async function pickProcess(
+  configuration?: vscode.DebugConfiguration,
+): Promise {
+  const processTree = createProcessTree();
+  const selectedProcess = await vscode.window.showQuickPick(
+processTree.listAllProcesses().then((processes): ProcessQuickPick[] => {
+  // Sort by start date in descending order
+  processes.sort((a, b) => b.start - a.start);
+  // Filter by program if requested
+  if (typeof configuration?.program === "string") {
+processes = processes.filter(
+  (proc) => proc.command === configuration.program,
+);
+// Show a better message if all processes were filtered out
+if (processes.length === 0) {
+  return [
+{
+  label: "No processes matched the debug configuration's program",
+},
+  ];
+}
+  }
+  // Convert to a QuickPickItem
+  return processes.map((proc) => {
+return {
+  processId: proc.id,
+  label: path.basename(proc.command),
+  description: proc.id.toString(),
+  detail: proc.arguments,
+} satisfies ProcessQuickPick;
+  });
+}),
+{
+  placeHolder: "Select a process to attach the debugger to",
+  matchOnDetail: true,

Da-Viper wrote:

```suggestion
  matchOnDetail: true,
  matchOnDescription: true,
```
The user can also search by process Id

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


[Lldb-commits] [lldb] [lldb-dap] Add process picker command to VS Code extension (PR #128943)

2025-03-07 Thread via lldb-commits

https://github.com/Da-Viper requested changes to this pull request.


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


[Lldb-commits] [lldb] [lldb-dap] Add process picker command to VS Code extension (PR #128943)

2025-03-07 Thread via lldb-commits


@@ -34,6 +34,23 @@ function convertToInteger(value: any): number | undefined {
 export class LLDBDapConfigurationProvider
   implements vscode.DebugConfigurationProvider
 {
+  resolveDebugConfiguration(
+_folder: vscode.WorkspaceFolder | undefined,
+debugConfiguration: vscode.DebugConfiguration,
+_token?: vscode.CancellationToken,
+  ): vscode.ProviderResult {
+// Default "pid" to ${command:pickProcess} if neither "pid" nor "program" 
are specified
+// in an "attach" request.
+if (
+  debugConfiguration.request === "attach" &&
+  !("pid" in debugConfiguration) &&

Da-Viper wrote:

I do not think that program is needed based on the current lldb-dap 
`AttachReqestHandler` as it only uses the PID , port or attachCommands to 
attach to the process. So even if we pass the program name it will not be read. 

see 
https://github.com/llvm/llvm-project/blob/50a0931ccd82a7e4541650744363c87d9e0e5496/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp#L62-L64

https://github.com/llvm/llvm-project/blob/50a0931ccd82a7e4541650744363c87d9e0e5496/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp#L141-L144

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


[Lldb-commits] [lldb] [lldb-dap] Add process picker command to VS Code extension (PR #128943)

2025-03-07 Thread Matthew Bastien via lldb-commits

https://github.com/matthewbastien updated 
https://github.com/llvm/llvm-project/pull/128943

>From b9083ea16c7b1dba70cc04acf78f5001f0fb86c6 Mon Sep 17 00:00:00 2001
From: Matthew Bastien 
Date: Wed, 26 Feb 2025 11:18:21 -0500
Subject: [PATCH 01/17] add a process picker for attaching by PID

---
 lldb/tools/lldb-dap/package.json  |  30 +-
 .../lldb-dap/src-ts/commands/pick-process.ts  |  37 +++
 lldb/tools/lldb-dap/src-ts/extension.ts   |   7 +-
 .../src-ts/process-tree/base-process-tree.ts  | 102 ++
 .../lldb-dap/src-ts/process-tree/index.ts |  36 +++
 .../platforms/darwin-process-tree.ts  |  16 +++
 .../platforms/linux-process-tree.ts   |  38 +++
 .../platforms/windows-process-tree.ts |  52 +
 8 files changed, 315 insertions(+), 3 deletions(-)
 create mode 100644 lldb/tools/lldb-dap/src-ts/commands/pick-process.ts
 create mode 100644 lldb/tools/lldb-dap/src-ts/process-tree/base-process-tree.ts
 create mode 100644 lldb/tools/lldb-dap/src-ts/process-tree/index.ts
 create mode 100644 
lldb/tools/lldb-dap/src-ts/process-tree/platforms/darwin-process-tree.ts
 create mode 100644 
lldb/tools/lldb-dap/src-ts/process-tree/platforms/linux-process-tree.ts
 create mode 100644 
lldb/tools/lldb-dap/src-ts/process-tree/platforms/windows-process-tree.ts

diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index 31d808eda4c35..1bbdbf045dd1b 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -146,6 +146,9 @@
 "windows": {
   "program": "./bin/lldb-dap.exe"
 },
+"variables": {
+  "PickProcess": "lldb-dap.pickProcess"
+},
 "configurationAttributes": {
   "launch": {
 "required": [
@@ -517,6 +520,16 @@
   "cwd": "^\"\\${workspaceRoot}\""
 }
   },
+  {
+"label": "LLDB: Attach to Process",
+"description": "",
+"body": {
+  "type": "lldb-dap",
+  "request": "attach",
+  "name": "${1:Attach}",
+  "pid": "^\"\\${command:PickProcess}\""
+}
+  },
   {
 "label": "LLDB: Attach",
 "description": "",
@@ -541,6 +554,21 @@
   }
 ]
   }
-]
+],
+"commands": [
+  {
+"command": "lldb-dap.pickProcess",
+"title": "Pick Process",
+"category": "LLDB DAP"
+  }
+],
+"menus": {
+  "commandPalette": [
+{
+  "command": "lldb-dap.pickProcess",
+  "when": "false"
+}
+  ]
+}
   }
 }
diff --git a/lldb/tools/lldb-dap/src-ts/commands/pick-process.ts 
b/lldb/tools/lldb-dap/src-ts/commands/pick-process.ts
new file mode 100644
index 0..b83e749e7da7b
--- /dev/null
+++ b/lldb/tools/lldb-dap/src-ts/commands/pick-process.ts
@@ -0,0 +1,37 @@
+import * as path from "path";
+import * as vscode from "vscode";
+import { createProcessTree } from "../process-tree";
+
+interface ProcessQuickPick extends vscode.QuickPickItem {
+  processId: number;
+}
+
+/**
+ * Prompts the user to select a running process.
+ *
+ * @returns The pid of the process as a string or undefined if cancelled.
+ */
+export async function pickProcess(): Promise {
+  const processTree = createProcessTree();
+  const selectedProcess = await vscode.window.showQuickPick(
+processTree.listAllProcesses().then((processes): ProcessQuickPick[] => {
+  return processes
+.sort((a, b) => b.start - a.start) // Sort by start date in descending 
order
+.map((proc) => {
+  return {
+processId: proc.id,
+label: path.basename(proc.command),
+description: proc.id.toString(),
+detail: proc.arguments,
+  } satisfies ProcessQuickPick;
+});
+}),
+{
+  placeHolder: "Select a process to attach the debugger to",
+},
+  );
+  if (!selectedProcess) {
+return;
+  }
+  return selectedProcess.processId.toString();
+}
diff --git a/lldb/tools/lldb-dap/src-ts/extension.ts 
b/lldb/tools/lldb-dap/src-ts/extension.ts
index 71fd48298f8f5..3532a2143155b 100644
--- a/lldb/tools/lldb-dap/src-ts/extension.ts
+++ b/lldb/tools/lldb-dap/src-ts/extension.ts
@@ -1,7 +1,6 @@
-import * as path from "path";
-import * as util from "util";
 import * as vscode from "vscode";
 
+import { pickProcess } from "./commands/pick-process";
 import {
   LLDBDapDescriptorFactory,
   isExecutable,
@@ -38,6 +37,10 @@ export class LLDBDapExtension extends DisposableContext {
 }
   }),
 );
+
+this.pushSubscription(
+  vscode.commands.registerCommand("lldb-dap.pickProcess", pickProcess),
+);
   }
 }
 
diff --git a/lldb/tools/lldb-dap/src-ts/process-tree/base-process-tree.ts 
b/lldb/tools/lldb-dap/src-ts/process-tree/base-process-tree.ts
new file mode 100644
index 0..3c08f49035b35
--- /dev/nul

[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-03-07 Thread David Spickett via lldb-commits


@@ -243,6 +243,19 @@ Status Debugger::SetPropertyValue(const ExecutionContext 
*exe_ctx,
   // Prompt colors changed. Ping the prompt so it can reset the ansi
   // terminal codes.
   SetPrompt(GetPrompt());
+} else if (property_path ==
+   g_debugger_properties[ePropertyShowStatusline].name) {
+  // Statusline setting changed. If we have a statusline instance, update 
it
+  // now. Otherwise it will get created in the default event handler.

DavidSpickett wrote:

This implies that if I had a messed up status line, setting the setting to true 
again would force a refresh, is that the case?

Perhaps this only gets called if the value changes.

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


[Lldb-commits] [lldb] [lldb] Add more ARM checks in TestLldbGdbServer.py (PR #130277)

2025-03-07 Thread David Spickett via lldb-commits

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

When https://github.com/llvm/llvm-project/pull/130034 enabled RISC-V here I 
noticed that these should run for ARM as well.

ARM only has 4 argument registers, which matches Arm's ABI for it: 
https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst#core-registers

The ABI defines a link register LR, and I assume that's what becomes 'ra' in 
LLDB.

Tested on ARM and AArch64 Linux.

>From 091dd938faad4c28fe746af0093c2249078adc5a Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Fri, 7 Mar 2025 12:08:29 +
Subject: [PATCH] [lldb] Add more ARM checks in TestLldbGdbServer.py

When https://github.com/llvm/llvm-project/pull/130034 enabled
RISC-V here I noticed that these should run for ARM as well.

ARM only has 4 argument registers, which matches Arm's ABI for it:
https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst#core-registers

The ABI defines a link register LR, and I assume that's what becomes
'ra' in LLDB.

Tested on ARM and AArch64 Linux.
---
 lldb/packages/Python/lldbsuite/test/lldbtest.py  | 7 +++
 lldb/test/API/tools/lldb-server/TestLldbGdbServer.py | 8 
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 7d0e6e9a970eb..590024ef77119 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1344,6 +1344,13 @@ def isAArch64(self):
 arch = self.getArchitecture().lower()
 return arch in ["aarch64", "arm64", "arm64e"]
 
+def isARM(self):
+"""Returns true if the architecture is ARM, meaning 32-bit ARM. Which 
could
+be M profile, A profile Armv7-a, or the AArch32 mode of Armv8-a."""
+return not self.isAArch64() and (
+self.getArchitecture().lower().startswith("arm")
+)
+
 def isAArch64SVE(self):
 return self.isAArch64() and "sve" in self.getCPUInfo()
 
diff --git a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py 
b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
index ce75e3e89e0a6..12c97bc62dcef 100644
--- a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
+++ b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
@@ -199,12 +199,12 @@ def 
test_qRegisterInfo_contains_required_generics_debugserver(self):
 if not self.isRISCV():
 self.assertIn("flags", generic_regs)
 
-if self.isRISCV():
-# Special RISC-V register for a return address
+if self.isRISCV() or self.isAArch64() or self.isARM():
+# Specific register for a return address
 self.assertIn("ra", generic_regs)
 
-# RISC-V's function arguments registers
-for i in range(1, 9):
+# Function arguments registers
+for i in range(1, 5 if self.isARM() else 9):
 self.assertIn(f"arg{i}", generic_regs)
 
 def test_qRegisterInfo_contains_at_least_one_register_set(self):

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


[Lldb-commits] [lldb] [lldb][lldb-dap] Return optional from json utils (PR #129919)

2025-03-07 Thread via lldb-commits

https://github.com/Da-Viper updated 
https://github.com/llvm/llvm-project/pull/129919

>From 7d97648317c3cadf63a60d92da67e9050ad675d4 Mon Sep 17 00:00:00 2001
From: Ezike Ebuka 
Date: Fri, 7 Mar 2025 13:40:34 +
Subject: [PATCH] [lldb] [lldb-dap] Return optional values for string json
 values.

---
 lldb/tools/lldb-dap/BreakpointBase.cpp|  4 +-
 lldb/tools/lldb-dap/DAP.cpp   | 14 ++---
 lldb/tools/lldb-dap/FunctionBreakpoint.cpp|  3 +-
 .../lldb-dap/Handler/AttachRequestHandler.cpp | 16 +++---
 .../Handler/BreakpointLocationsHandler.cpp|  2 +-
 .../Handler/CompileUnitsRequestHandler.cpp|  3 +-
 .../lldb-dap/Handler/CompletionsHandler.cpp   |  2 +-
 .../DataBreakpointInfoRequestHandler.cpp  |  2 +-
 .../Handler/DisassembleRequestHandler.cpp |  3 +-
 .../Handler/EvaluateRequestHandler.cpp|  5 +-
 .../lldb-dap/Handler/LaunchRequestHandler.cpp | 10 ++--
 .../Handler/ReadMemoryRequestHandler.cpp  |  3 +-
 .../tools/lldb-dap/Handler/RequestHandler.cpp |  4 +-
 .../Handler/SetBreakpointsRequestHandler.cpp  |  2 +-
 .../Handler/SetVariableRequestHandler.cpp |  4 +-
 lldb/tools/lldb-dap/InstructionBreakpoint.cpp |  1 +
 lldb/tools/lldb-dap/JSONUtils.cpp | 54 +--
 lldb/tools/lldb-dap/JSONUtils.h   | 13 ++---
 lldb/tools/lldb-dap/SourceBreakpoint.cpp  |  2 +-
 lldb/tools/lldb-dap/Watchpoint.cpp|  4 +-
 20 files changed, 79 insertions(+), 72 deletions(-)

diff --git a/lldb/tools/lldb-dap/BreakpointBase.cpp 
b/lldb/tools/lldb-dap/BreakpointBase.cpp
index 1e28c29082a9f..7979bac098766 100644
--- a/lldb/tools/lldb-dap/BreakpointBase.cpp
+++ b/lldb/tools/lldb-dap/BreakpointBase.cpp
@@ -13,8 +13,8 @@
 using namespace lldb_dap;
 
 BreakpointBase::BreakpointBase(DAP &d, const llvm::json::Object &obj)
-: dap(d), condition(std::string(GetString(obj, "condition"))),
-  hitCondition(std::string(GetString(obj, "hitCondition"))) {}
+: dap(d), condition(std::string(GetString(obj, "condition").value_or(""))),
+  hitCondition(std::string(GetString(obj, "hitCondition").value_or(""))) {}
 
 void BreakpointBase::UpdateBreakpoint(const BreakpointBase &request_bp) {
   if (condition != request_bp.condition) {
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 1f7b25e7c5bcc..177739e1bfbb4 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -672,9 +672,11 @@ DAP::CreateTargetFromArguments(const llvm::json::Object 
&arguments,
   // enough information to determine correct arch and platform (or ELF can be
   // omitted at all), so it is good to leave the user an apportunity to specify
   // those. Any of those three can be left empty.
-  llvm::StringRef target_triple = GetString(arguments, "targetTriple");
-  llvm::StringRef platform_name = GetString(arguments, "platformName");
-  llvm::StringRef program = GetString(arguments, "program");
+  const llvm::StringRef target_triple =
+  GetString(arguments, "targetTriple").value_or("");
+  const llvm::StringRef platform_name =
+  GetString(arguments, "platformName").value_or("");
+  const llvm::StringRef program = GetString(arguments, "program").value_or("");
   auto target = this->debugger.CreateTarget(
   program.data(), target_triple.data(), platform_name.data(),
   true, // Add dependent modules.
@@ -734,9 +736,9 @@ PacketStatus DAP::GetNextObject(llvm::json::Object &object) 
{
 }
 
 bool DAP::HandleObject(const llvm::json::Object &object) {
-  const auto packet_type = GetString(object, "type");
+  const auto packet_type = GetString(object, "type").value_or("");
   if (packet_type == "request") {
-const auto command = GetString(object, "command");
+const auto command = GetString(object, "command").value_or("");
 
 auto new_handler_pos = request_handlers.find(command);
 if (new_handler_pos != request_handlers.end()) {
@@ -774,7 +776,7 @@ bool DAP::HandleObject(const llvm::json::Object &object) {
   }
   (*response_handler)(Result);
 } else {
-  llvm::StringRef message = GetString(object, "message");
+  llvm::StringRef message = GetString(object, "message").value_or("");
   if (message.empty()) {
 message = "Unknown error, response failed";
   }
diff --git a/lldb/tools/lldb-dap/FunctionBreakpoint.cpp 
b/lldb/tools/lldb-dap/FunctionBreakpoint.cpp
index f266d751833c7..cafae32b662f2 100644
--- a/lldb/tools/lldb-dap/FunctionBreakpoint.cpp
+++ b/lldb/tools/lldb-dap/FunctionBreakpoint.cpp
@@ -13,7 +13,8 @@
 namespace lldb_dap {
 
 FunctionBreakpoint::FunctionBreakpoint(DAP &d, const llvm::json::Object &obj)
-: Breakpoint(d, obj), functionName(std::string(GetString(obj, "name"))) {}
+: Breakpoint(d, obj),
+  functionName(std::string(GetString(obj, "name").value_or(""))) {}
 
 void FunctionBreakpoint::SetBreakpoint() {
   if (functionName.empty())
diff --git a/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handle

[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-03-07 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Some of this will be expected, but reporting it in case it's not.
```
$ ./bin/lldb /tmp/test.o
(lldb) target create "/tmp/test.o"
Current executable set to '/tmp/test.o' (aarch64).
(lldb)
   << should this be here?
test.o << is the status line
```
Is that empty line meant to be there on initial startup? Some visual space 
between commands and statusline is nice though, so it's not bad but it isn't 
always there after you run a few commands.
```
$ ./bin/lldb /tmp/test.o
(lldb) target create "/tmp/test.o"
Current executable set to '/tmp/test.o' (aarch64).
(lldb) settings set show-statusline false
(lldb)
  << had one blank when I started up
  << another one was added when I disabled the status line (expected?)

```
When I disable it, the statusline line is cleared but not reclaimed or moved or 
whatever, giving me a second blank line.
```
$ ./bin/lldb /tmp/test.o
(lldb) target create "/tmp/test.o"
Current executable set to '/tmp/test.o' (aarch64).
(lldb) settings set show-statusline false
(lldb) settings set show-statusline true
(lldb)

test.o << status line, reclaiming the bottom line
```
Enabling it again, the line is reclaimed.

Probably expected because imagine you had a 24" monitor worth of output, we 
don't want to shift every line up and down 1 do we.

What does seem to be a bug is that tab complete hides the status bar, not just 
during but after:
```
(lldb)
test.o <<< status line
```
```

<...>
add-dsym  -- Add a <...>
More (Y/n/a):
<< empty line where the status line was
```
```

More (Y/n/a):
(lldb)
 << empty line where the status line was
```

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


[Lldb-commits] [lldb] [lldb][test] Skip libsanitizers tests for now (PR #130305)

2025-03-07 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test] Skip libsanitizers tests for now (PR #130305)

2025-03-07 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

These are macOS tests only and are currently failing on the x86_64 CI and on 
arm64 on recent versions of macOS/Xcode.

The tests are failing because we're stopping in:
```
Process 17458 stopped
* thread #1: tid = 0xbda69a, 0x0002735bd000
  libsystem_malloc.dylib`purgeable_print_self.cold.1, stop reason = 
EXC_BREAKPOINT (code=1, subcode=0x2735bd000)
```
instead of the libsanitizers library.

Skip these for now until we figure out the root cause.

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


2 Files Affected:

- (modified) lldb/test/API/functionalities/asan/TestMemoryHistory.py (+1) 
- (modified) lldb/test/API/functionalities/asan/TestReportData.py (+1) 


``diff
diff --git a/lldb/test/API/functionalities/asan/TestMemoryHistory.py 
b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
index 41ab25823f5cc..b04182a543719 100644
--- a/lldb/test/API/functionalities/asan/TestMemoryHistory.py
+++ b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
@@ -19,6 +19,7 @@ def test(self):
 self.asan_tests()
 
 @skipIf(oslist=no_match(["macosx"]))
+@skipIf(bugnumber="rdar://144997976")
 def test_libsanitizers_asan(self):
 try:
 self.build(make_targets=["libsanitizers"])
diff --git a/lldb/test/API/functionalities/asan/TestReportData.py 
b/lldb/test/API/functionalities/asan/TestReportData.py
index 29bdf1fac8e73..3319677be9b51 100644
--- a/lldb/test/API/functionalities/asan/TestReportData.py
+++ b/lldb/test/API/functionalities/asan/TestReportData.py
@@ -20,6 +20,7 @@ def test(self):
 self.asan_tests()
 
 @skipIf(oslist=no_match(["macosx"]))
+@skipIf(bugnumber="rdar://144997976")
 def test_libsanitizers_asan(self):
 try:
 self.build(make_targets=["libsanitizers"])

``




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


[Lldb-commits] [lldb] [lldb] Implement a statusline in LLDB (PR #121860)

2025-03-07 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett commented:

I was going to bikeshed (or indeed bike shed) "statusline" vs. "status line" 
but I see that NeoVim spells it this way. That's popular already, so one word 
is fine with me.

Going to try this locally now.

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


[Lldb-commits] [clang] [lldb] [C++20][Modules] Do not update the declaration generation number if the redeclaration chain completion was delayed. (PR #129982)

2025-03-07 Thread Michael Park via lldb-commits

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


[Lldb-commits] [clang] [lldb] [C++20][Modules] Do not update the declaration generation number if the redeclaration chain completion was delayed. (PR #129982)

2025-03-07 Thread Michael Park via lldb-commits


@@ -9180,6 +9180,12 @@ bool Sema::hasAcceptableDefinition(NamedDecl *D, 
NamedDecl **Suggested,
   if (!getLangOpts().Modules && !getLangOpts().ModulesLocalVisibility)
 return true;
 
+  // The external source may have additional definitions of this entity that 
are
+  // visible, so complete the redeclaration chain now.
+  if (auto *Source = Context.getExternalSource()) {
+Source->CompleteRedeclChain(D);
+  }

mpark wrote:

On one thought, it seems like the decls inside `DC` should be notified of the 
fact that there have been new additions made to `Lookups[DC]`... but on the 
other hand, it's not clear to me whether this is an expected sequence of events 
in the first place. If this is an expected sequence of events, I'm a bit 
surprised that this doesn't seem to be a bigger issue. If this is not an 
expected sequence of events, do we expect that the first call to 
`CompleteRedeclChain` should have the `Lookups` populated with everything 
already?

CC @ChuanqiXu9, maybe @Bigcheese can help here too?

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


[Lldb-commits] [lldb] [lldb-dap] Refactoring IOStream into Transport handler. (PR #130026)

2025-03-07 Thread Jonas Devlieghere via lldb-commits


@@ -219,65 +220,27 @@ void DAP::StopEventHandlers() {
   }
 }
 
-// Send the JSON in "json_str" to the "out" stream. Correctly send the
-// "Content-Length:" field followed by the length, followed by the raw
-// JSON bytes.
-void DAP::SendJSON(const std::string &json_str) {
-  output.write_full("Content-Length: ");
-  output.write_full(llvm::utostr(json_str.size()));
-  output.write_full("\r\n\r\n");
-  output.write_full(json_str);
-}
-
 // Serialize the JSON value into a string and send the JSON packet to
 // the "out" stream.
 void DAP::SendJSON(const llvm::json::Value &json) {
-  std::string json_str;
-  llvm::raw_string_ostream strm(json_str);
-  strm << json;
-  static std::mutex mutex;
-  std::lock_guard locker(mutex);
-  SendJSON(json_str);
-
-  if (log) {
-auto now = std::chrono::duration(
-std::chrono::system_clock::now().time_since_epoch());
-*log << llvm::formatv("{0:f9} {1} <-- ", now.count(), name).str()
- << std::endl
- << "Content-Length: " << json_str.size() << "\r\n\r\n"
- << llvm::formatv("{0:2}", json).str() << std::endl;
-  }
-}
-
-// Read a JSON packet from the "in" stream.
-std::string DAP::ReadJSON() {
-  std::string length_str;
-  std::string json_str;
-  int length;
-
-  if (!input.read_expected(log, "Content-Length: "))
-return json_str;
-
-  if (!input.read_line(log, length_str))
-return json_str;
-
-  if (!llvm::to_integer(length_str, length))
-return json_str;
-
-  if (!input.read_expected(log, "\r\n"))
-return json_str;
-
-  if (!input.read_full(log, length, json_str))
-return json_str;
-
-  if (log) {
-auto now = std::chrono::duration(
-std::chrono::system_clock::now().time_since_epoch());
-*log << llvm::formatv("{0:f9} {1} --> ", now.count(), name).str()
- << std::endl
- << "Content-Length: " << length << "\r\n\r\n";
+  // FIXME: Instead of parsing the output message from JSON, pass the `Message`
+  // as parameter to `SendJSON`.
+  protocol::Message M;

JDevlieghere wrote:

This patch is using a mix of LLVM and LLDB naming conventions. Let's be 
consistent and use lower_camel_case. 

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


[Lldb-commits] [clang] [lldb] [C++20][Modules] Do not update the declaration generation number if the redeclaration chain completion was delayed. (PR #129982)

2025-03-07 Thread Michael Park via lldb-commits

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


[Lldb-commits] [clang] [lldb] [C++20][Modules] Do not update the declaration generation number if the redeclaration chain completion was delayed. (PR #129982)

2025-03-07 Thread Michael Park via lldb-commits

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


[Lldb-commits] [lldb] 397696b - [lldb][Mach-O] Don't read symbol table of specially marked binary (#129967)

2025-03-07 Thread via lldb-commits

Author: Jason Molenda
Date: 2025-03-06T16:34:13-08:00
New Revision: 397696bb3d26c1298bf265e4907b0b6416ad59c9

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

LOG: [lldb][Mach-O] Don't read symbol table of specially marked binary (#129967)

We have a binary image on Darwin that has no code, only metadata. It has
a large symbol table with many external symbol names that will not be
needed in the debugger. And it is possible to not have this binary on
the debugger system - so lldb must read all of the symbol names out of
memory, one at a time, which can be quite slow.

We're adding a section __TEXT,__lldb_no_nlist, to this binary to
indicate that lldb should not read the nlist symbols for it when we are
reading out of memory. If lldb is run with an on-disk version of the
binary, we will load the symbol table as we normally would, there's no
benefit to handling this binary differently.

I added a test where I create a dylib with this specially named section,
launch the process. The main binary deletes the dylib from the disk so
lldb is forced to read it out of memory. lldb attaches to the binary,
confirms that the dylib is present in the process and is a memory
Module. If the binary is not present, or lldb found the on-disk copy
because it hasn't been deleted yet, we delete the target, flush the
Debugger's module cache, sleep and retry, up to ten times. I create the
specially named section by compiling an assembly file that puts a byte
in the section which makes for a bit of a messy Makefile (the pre-canned
actions to build a dylib don't quite handle this case) but I don't think
it's much of a problem. This is a purely skipUnlessDarwin test case.

rdar://146167816

Added: 
lldb/test/API/macosx/no-nlist-memory-module/Makefile
lldb/test/API/macosx/no-nlist-memory-module/TestNoNlistsDylib.py
lldb/test/API/macosx/no-nlist-memory-module/has-nlists.c
lldb/test/API/macosx/no-nlist-memory-module/main.c
lldb/test/API/macosx/no-nlist-memory-module/no-nlist-sect.s
lldb/test/API/macosx/no-nlist-memory-module/no-nlists.c

Modified: 
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index a19322ff1e263..f31b56b9f81e6 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -918,6 +918,11 @@ ConstString ObjectFileMachO::GetSectionNameEHFrame() {
   return g_section_name_eh_frame;
 }
 
+ConstString ObjectFileMachO::GetSectionNameLLDBNoNlist() {
+  static ConstString g_section_name_lldb_no_nlist("__lldb_no_nlist");
+  return g_section_name_lldb_no_nlist;
+}
+
 bool ObjectFileMachO::MagicBytesMatch(DataBufferSP data_sp,
   lldb::addr_t data_offset,
   lldb::addr_t data_length) {
@@ -2394,8 +2399,39 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
   uint32_t memory_module_load_level = eMemoryModuleLoadLevelComplete;
   bool is_shared_cache_image = IsSharedCacheBinary();
   bool is_local_shared_cache_image = is_shared_cache_image && !IsInMemory();
+
+  ConstString g_segment_name_TEXT = GetSegmentNameTEXT();
+  ConstString g_segment_name_DATA = GetSegmentNameDATA();
+  ConstString g_segment_name_DATA_DIRTY = GetSegmentNameDATA_DIRTY();
+  ConstString g_segment_name_DATA_CONST = GetSegmentNameDATA_CONST();
+  ConstString g_segment_name_OBJC = GetSegmentNameOBJC();
+  ConstString g_section_name_eh_frame = GetSectionNameEHFrame();
+  ConstString g_section_name_lldb_no_nlist = GetSectionNameLLDBNoNlist();
+  SectionSP text_section_sp(
+  section_list->FindSectionByName(g_segment_name_TEXT));
+  SectionSP data_section_sp(
+  section_list->FindSectionByName(g_segment_name_DATA));
   SectionSP linkedit_section_sp(
   section_list->FindSectionByName(GetSegmentNameLINKEDIT()));
+  SectionSP data_dirty_section_sp(
+  section_list->FindSectionByName(g_segment_name_DATA_DIRTY));
+  SectionSP data_const_section_sp(
+  section_list->FindSectionByName(g_segment_name_DATA_CONST));
+  SectionSP objc_section_sp(
+  section_list->FindSectionByName(g_segment_name_OBJC));
+  SectionSP eh_frame_section_sp;
+  SectionSP lldb_no_nlist_section_sp;
+  if (text_section_sp.get()) {
+eh_frame_section_sp = text_section_sp->GetChildren().FindSectionByName(
+g_section_name_eh_frame);
+lldb_no_nlist_section_sp = 
text_section_sp->GetChildren().FindSectionByName(
+g_section_name_lldb_no_nlist);
+  } else {
+eh_frame_section_sp =
+section_list->FindSectionByName(g_section_name_eh_frame);

[Lldb-commits] [clang] [lldb] [C++20][Modules] Do not update the declaration generation number if the redeclaration chain completion was delayed. (PR #129982)

2025-03-07 Thread Michael Park via lldb-commits


@@ -9180,6 +9180,12 @@ bool Sema::hasAcceptableDefinition(NamedDecl *D, 
NamedDecl **Suggested,
   if (!getLangOpts().Modules && !getLangOpts().ModulesLocalVisibility)
 return true;
 
+  // The external source may have additional definitions of this entity that 
are
+  // visible, so complete the redeclaration chain now.
+  if (auto *Source = Context.getExternalSource()) {
+Source->CompleteRedeclChain(D);
+  }

mpark wrote:

Hm, okay... so the `DC->lookup(Name)` have different behaviors because of 
[`Source->FindExternalVisibleDeclsByName(...)`](https://github.com/llvm/llvm-project/blob/release/20.x/clang/lib/AST/DeclBase.cpp#L1913).
 In `ASTReader::FindExternalVisibleDeclsByName`, we get to 
[here](https://github.com/llvm/llvm-project/blob/c6d95c441a29a45782ff72d6cb82839b86fd0e4a/clang/lib/Serialization/ASTReader.cpp#L8494-L8501)
 looking through `Lookups` data structure. In the first call, 
`Lookups[DC].Table[Name]` has 1 entry (just a decl), whereas in the second call 
it has 2 entries (the decl and a defn).

In summary, we have `LazyGenerationalUpdatePtr::get` calling 
`CompleteRedeclChain` where `Lookups` isn't populated with the definition, and 
updates the generation number. The second time `LazyGenerationUpdatePtr::get` 
is called, `Lookups` **is** populated with the definition, but the generation 
number matches, and so it doesn't call `CompleteRedeclChain` even though it 
would yield a different result.

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


[Lldb-commits] [lldb] [lldb] Adapt llgs tests for RISC-V (PR #130034)

2025-03-07 Thread David Spickett via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [lldb] Adapt llgs tests for RISC-V (PR #130034)

2025-03-07 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] 9c08e65 - [lldb] Adapt llgs tests for RISC-V (#130034)

2025-03-07 Thread via lldb-commits

Author: Georgiy Samoylov
Date: 2025-03-07T09:27:39Z
New Revision: 9c08e650cd83e3e891dd2972ae1852ae1763c7ff

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

LOG: [lldb] Adapt llgs tests for RISC-V (#130034)

Some lldb tests from llgs category fail on RISC-V target due to lack of
necessary condition checks. This patch adapts these tests by taking into
account the peculiarities of the RISC-V architecture

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
lldb/test/API/tools/lldb-server/main.cpp

lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
index 3d8c713562e9b..a1ab06076dcb2 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -35,7 +35,7 @@ def check_first_register_readable(test_case):
 test_case.expect("register read r0", substrs=["r0 = 0x"])
 elif arch in ["powerpc64le"]:
 test_case.expect("register read r0", substrs=["r0 = 0x"])
-elif re.match("^rv(32|64)", arch):
+elif arch in ["riscv64", "riscv32"]:
 test_case.expect("register read zero", substrs=["zero = 0x"])
 else:
 # TODO: Add check for other architectures
@@ -240,6 +240,10 @@ def getArchitecture():
 arch = "x86_64"
 if arch in ["armv7l", "armv8l"]:
 arch = "arm"
+if re.match("rv64*", arch):
+arch = "riscv64"
+if re.match("rv32*", arch):
+arch = "riscv32"
 return arch
 
 

diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 81b286340560d..7d0e6e9a970eb 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1393,6 +1393,10 @@ def isLoongArchLSX(self):
 def isLoongArchLASX(self):
 return self.isLoongArch() and "lasx" in self.getCPUInfo()
 
+def isRISCV(self):
+"""Returns true if the architecture is RISCV64 or RISCV32."""
+return self.getArchitecture() in ["riscv64", "riscv32"]
+
 def getArchitecture(self):
 """Returns the architecture in effect the test suite is running 
with."""
 return lldbplatformutil.getArchitecture()

diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index fb96b3d4de560..3d3ecb9aa8f95 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -682,7 +682,7 @@ def assert_valid_reg_info(self, reg_info):
 self.assertTrue("name" in reg_info)
 self.assertTrue("bitsize" in reg_info)
 
-if not self.getArchitecture() == "aarch64":
+if not (self.getArchitecture() == "aarch64" or self.isRISCV()):
 self.assertTrue("offset" in reg_info)
 
 self.assertTrue("encoding" in reg_info)

diff  --git a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py 
b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
index 592037db502aa..ce75e3e89e0a6 100644
--- a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
+++ b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
@@ -195,8 +195,17 @@ def 
test_qRegisterInfo_contains_required_generics_debugserver(self):
 # Ensure we have a stack pointer register.
 self.assertIn("sp", generic_regs)
 
-# Ensure we have a flags register.
-self.assertIn("flags", generic_regs)
+# Ensure we have a flags register. RISC-V doesn't have a flags register
+if not self.isRISCV():
+self.assertIn("flags", generic_regs)
+
+if self.isRISCV():
+# Special RISC-V register for a return address
+self.assertIn("ra", generic_regs)
+
+# RISC-V's function arguments registers
+for i in range(1, 9):
+self.assertIn(f"arg{i}", generic_regs)
 
 def test_qRegisterInfo_contains_at_least_one_register_set(self):
 self.build()

diff  --git a/lldb/test/API/tools/lldb-server/main.cpp 
b/lldb/test/API/tools/lldb-server/main.cpp
index 484da8aa4bef9..c661f5b4e82c4 100644
--- a/lldb/test/API/tools/lldb-server/main.cpp
+++ b/lldb/test/API/tools/lldb-server/main.cpp
@@ -128,6 +128,15 @@ static void swap_chars() {
:
 

[Lldb-commits] [lldb] [lldb-dap] Allow providing debug adapter arguments in the extension (PR #129262)

2025-03-07 Thread Matthew Bastien via lldb-commits


@@ -162,6 +171,13 @@
 "type": "string",
 "markdownDescription": "The absolute path to the LLDB debug 
adapter executable to use."
   },
+  "debugAdapterArgs": {
+"type": "array",
+"items": {
+  "type": "string"
+},
+"markdownDescription": "The list of additional arguments used 
to launch the debug adapter executable."

matthewbastien wrote:

Done.

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


[Lldb-commits] [clang] [flang] [lldb] [llvm] [mlir] [polly] [IR] Store Triple in Module (NFC) (PR #129868)

2025-03-07 Thread Matt Arsenault via lldb-commits

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


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


[Lldb-commits] [lldb] 8eec3d7 - [lldb][tests] Add ability to run API tests with qemu-user simulator (#89765)

2025-03-07 Thread via lldb-commits

Author: ita-sc
Date: 2025-03-06T09:57:03Z
New Revision: 8eec3d77a93aa3111426a2988fc0a3ac927899a0

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

LOG: [lldb][tests] Add ability to run API tests with qemu-user simulator 
(#89765)

Added: 


Modified: 
lldb/test/API/lit.cfg.py

Removed: 




diff  --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index 06c685ebc3f5a..08cf11c8a68db 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -179,6 +179,9 @@ def delete_module_cache(path):
 elif lldb_use_simulator == "tvos":
 lit_config.note("Running API tests on tvOS simulator")
 config.available_features.add("lldb-simulator-tvos")
+elif lldb_use_simulator == "qemu-user":
+lit_config.note("Running API tests on qemu-user simulator")
+config.available_features.add("lldb-simulator-qemu-user")
 else:
 lit_config.error("Unknown simulator id 
'{}'".format(lldb_use_simulator))
 
@@ -285,6 +288,9 @@ def delete_module_cache(path):
 "tvos-simulator",
 ]
 
+if "lldb-simulator-qemu-user" in config.available_features:
+dotest_cmd += ["--platform-name", "qemu-user"]
+
 if is_configured("enabled_plugins"):
 for plugin in config.enabled_plugins:
 dotest_cmd += ["--enable-plugin", plugin]



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


[Lldb-commits] [lldb] [lldb] Avoid unnecessary regex check in dwim-print (PR #114608)

2025-03-07 Thread Dave Lee via lldb-commits

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/114608

>From e1c631e49474027c65fc8f14a0d6baafbbf704be Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Fri, 1 Nov 2024 14:38:19 -0700
Subject: [PATCH] [lldb] Avoid unnecessary regex check in dwim-print

---
 lldb/source/Commands/CommandObjectDWIMPrint.cpp | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp 
b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
index 04142427717bd..091cab20bb82b 100644
--- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp
+++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
@@ -101,6 +101,10 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
   // Add a hint if object description was requested, but no description
   // function was implemented.
   auto maybe_add_hint = [&](llvm::StringRef output) {
+static bool note_shown = false;
+if (note_shown)
+  return;
+
 // Identify the default output of object description for Swift and
 // Objective-C
 // ". The regex is:
@@ -110,17 +114,13 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
 // - Followed by 5 or more hex digits.
 // - Followed by ">".
 // - End with zero or more whitespace characters.
-const std::regex swift_class_regex("^<\\S+: 0x[[:xdigit:]]{5,}>\\s*$");
+static const std::regex swift_class_regex("^<\\S+: 
0x[[:xdigit:]]{5,}>\\s*$");
 
 if (GetDebugger().GetShowDontUsePoHint() && target_ptr &&
 (language == lldb::eLanguageTypeSwift ||
  language == lldb::eLanguageTypeObjC) &&
 std::regex_match(output.data(), swift_class_regex)) {
 
-  static bool note_shown = false;
-  if (note_shown)
-return;
-
   result.AppendNote(
   "object description requested, but type doesn't implement "
   "a custom object description. Consider using \"p\" instead of "

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


[Lldb-commits] [lldb] [LLDB][Telemetry]Define TargetInfo for collecting data about a target (PR #127834)

2025-03-07 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/127834

>From 0d6a36d84df50ccb9eef9ef3dd6f59d4299edeac Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Wed, 19 Feb 2025 12:47:57 -0500
Subject: [PATCH 01/14] [LLDB][Telemetry]Define TargetInfo for collecting data
 about a target

---
 lldb/include/lldb/Core/Telemetry.h | 86 +-
 lldb/source/Core/Telemetry.cpp | 99 ++
 2 files changed, 170 insertions(+), 15 deletions(-)

diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
index b72556ecaf3c9..4be81951254de 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -13,6 +13,7 @@
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Utility/StructuredData.h"
 #include "lldb/lldb-forward.h"
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
@@ -29,6 +30,9 @@ namespace telemetry {
 
 struct LLDBEntryKind : public ::llvm::telemetry::EntryKind {
   static const llvm::telemetry::KindType BaseInfo = 0b11000;
+  static const KindType TargetInfo = 0b11010;
+  // There are other entries in between (added in separate PRs)
+  static const llvm::telemetry::KindType MiscInfo = 0b0;
 };
 
 /// Defines a convenient type for timestamp of various events.
@@ -56,14 +60,88 @@ struct LLDBBaseTelemetryInfo : public 
llvm::telemetry::TelemetryInfo {
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 };
 
+/// Describes an exit status.
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct TargetTelemetryInfo : public LldbBaseTelemetryInfo {
+  lldb::ModuleSP exec_mod;
+  Target *target_ptr;
+
+  // The same as the executable-module's UUID.
+  std::string target_uuid;
+  std::string file_format;
+
+  std::string binary_path;
+  size_t binary_size;
+
+  std::optional exit_desc;
+  TargetTelemetryInfo() = default;
+
+  TargetTelemetryInfo(const TargetTelemetryInfo &other) {
+exec_mod = other.exec_mod;
+target_uuid = other.target_uuid;
+file_format = other.file_format;
+binary_path = other.binary_path;
+binary_size = other.binary_size;
+exit_desc = other.exit_desc;
+  }
+
+  KindType getKind() const override { return LldbEntryKind::TargetInfo; }
+
+  static bool classof(const TelemetryInfo *T) {
+if (T == nullptr)
+  return false;
+return T->getKind() == LldbEntryKind::TargetInfo;
+  }
+
+  void serialize(Serializer &serializer) const override;
+};
+
+/// The "catch-all" entry to store a set of non-standard data, such as
+/// error-messages, etc.
+struct MiscTelemetryInfo : public LLDBBaseTelemetryInfo {
+  /// If the event is/can be associated with a target entry,
+  /// this field contains that target's UUID.
+  ///  otherwise.
+  std::string target_uuid;
+
+  /// Set of key-value pairs for any optional (or impl-specific) data
+  std::map meta_data;
+
+  MiscTelemetryInfo() = default;
+
+  MiscTelemetryInfo(const MiscTelemetryInfo &other) {
+target_uuid = other.target_uuid;
+meta_data = other.meta_data;
+  }
+
+  llvm::telemetry::KindType getKind() const override {
+return LLDBEntryKind::MiscInfo;
+  }
+
+  static bool classof(const llvm::telemetry::TelemetryInfo *T) {
+return T->getKind() == LLDBEntryKind::MiscInfo;
+  }
+
+  void serialize(llvm::telemetry::Serializer &serializer) const override;
+};
+
 /// The base Telemetry manager instance in LLDB.
 /// This class declares additional instrumentation points
 /// applicable to LLDB.
-class TelemetryManager : public llvm::telemetry::Manager {
+class TelemetryMager : public llvm::telemetry::Manager {
 public:
   llvm::Error preDispatch(llvm::telemetry::TelemetryInfo *entry) override;
 
-  virtual llvm::StringRef GetInstanceName() const = 0;
+  const llvm::telemetry::Config *getConfig();
+
+  virtual void AtMainExecutableLoadStart(TargetInfo * entry);
+  virtual void AtMainExecutableLoadEnd(TargetInfo *entry);
+
+  virtual llvm::StringRef GetInstanceName() const = 0;
   static TelemetryManager *getInstance();
 
 protected:
@@ -73,6 +151,10 @@ class TelemetryManager : public llvm::telemetry::Manager {
 
 private:
   std::unique_ptr m_config;
+  // Each debugger is assigned a unique ID (session_id).
+  // All TelemetryInfo entries emitted for the same debugger instance
+  // will get the same session_id.
+  llvm::DenseMap session_ids;
   static std::unique_ptr g_instance;
 };
 
diff --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp
index 5222f76704f91..da7aee01680fc 100644
--- a/lldb/source/Core/Telemetry.cpp
+++ b/lldb/source/Core/Telemetry.cpp
@@ -10,14 +10,20 @@
 
 #ifdef LLVM_BUILD_TELEMETRY
 
-#include "lldb/Core/Telemetry.h"
 #include "lldb/Core/Debugger.h"
+#include "lldb/Core/Telemetry.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Target/Process.h"
+#include "l

[Lldb-commits] [lldb] [lldb] Avoid unnecessary regex check in dwim-print (PR #114608)

2025-03-07 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 5bc166728abe3c80a271d3883d12805161b96335 
e1c631e49474027c65fc8f14a0d6baafbbf704be --extensions cpp -- 
lldb/source/Commands/CommandObjectDWIMPrint.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp 
b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
index 091cab20bb..17c60297a5 100644
--- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp
+++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
@@ -114,7 +114,8 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
 // - Followed by 5 or more hex digits.
 // - Followed by ">".
 // - End with zero or more whitespace characters.
-static const std::regex swift_class_regex("^<\\S+: 
0x[[:xdigit:]]{5,}>\\s*$");
+static const std::regex swift_class_regex(
+"^<\\S+: 0x[[:xdigit:]]{5,}>\\s*$");
 
 if (GetDebugger().GetShowDontUsePoHint() && target_ptr &&
 (language == lldb::eLanguageTypeSwift ||

``




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


[Lldb-commits] [lldb] [lldb] Avoid unnecessary regex check in dwim-print (PR #114608)

2025-03-07 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][docs] Added LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS to build.rst for macOS configuration (PR #130381)

2025-03-07 Thread Julius Alexandre via lldb-commits

https://github.com/wizardengineer created 
https://github.com/llvm/llvm-project/pull/130381

Referenced here: 
https://github.com/llvm/llvm-project/issues/130171#issuecomment-2707058235

I think this will allow for issues relating towards missing modules for test 
suites to be more manageable.

cc @adrian-prantl

>From 3a8005bcf9780b51e7afbfba17e7bd43e7638cbc Mon Sep 17 00:00:00 2001
From: medievalghoul <61852278+medievalgh...@users.noreply.github.com>
Date: Fri, 7 Mar 2025 21:15:46 -0500
Subject: [PATCH] added LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS in macOS
 configuration

---
 lldb/docs/resources/build.rst | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst
index 214c5f63f2c73..53d749da6bb5a 100644
--- a/lldb/docs/resources/build.rst
+++ b/lldb/docs/resources/build.rst
@@ -340,7 +340,8 @@ On macOS the LLDB test suite requires libc++. Either add
   code-signed with identity ``lldb_codesign`` (see :ref:`CodeSigning`).
 * ``LLDB_USE_SYSTEM_DEBUGSERVER:BOOL``: Use the system's debugserver, so lldb 
is
   functional without setting up code-signing.
-
+* ``LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS:BOOL``: This helps with determining 
missing
+  packages or modules at configuration time.
 
 .. _CMakeCaches:
 
@@ -371,6 +372,7 @@ LLVM `_):
   -C /path/to/llvm-project/lldb/cmake/caches/Apple-lldb-macOS.cmake \
   -DLLVM_ENABLE_PROJECTS="clang;lldb" \
   -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
+  -DLLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=ON \
   llvm-project/llvm
 
   $ DESTDIR=/path/to/lldb-install ninja -C /path/to/lldb-build check-lldb 
install-distribution
@@ -387,6 +389,7 @@ Build LLDB standalone for development with Xcode:
   -C /path/to/llvm-project/lldb/cmake/caches/Apple-lldb-base.cmake \
   -DLLVM_ENABLE_PROJECTS="clang" \
   -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
+  -DLLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=ON \
   llvm-project/llvm
   $ ninja -C /path/to/llvm-build
 

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


[Lldb-commits] [lldb] [lldb][docs] Added LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS to build.rst for macOS configuration (PR #130381)

2025-03-07 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Julius Alexandre (wizardengineer)


Changes

Referenced here: 
https://github.com/llvm/llvm-project/issues/130171#issuecomment-2707058235

I think this will allow for issues relating towards missing modules for test 
suites to be more manageable.

cc @adrian-prantl

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


1 Files Affected:

- (modified) lldb/docs/resources/build.rst (+4-1) 


``diff
diff --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst
index 214c5f63f2c73..53d749da6bb5a 100644
--- a/lldb/docs/resources/build.rst
+++ b/lldb/docs/resources/build.rst
@@ -340,7 +340,8 @@ On macOS the LLDB test suite requires libc++. Either add
   code-signed with identity ``lldb_codesign`` (see :ref:`CodeSigning`).
 * ``LLDB_USE_SYSTEM_DEBUGSERVER:BOOL``: Use the system's debugserver, so lldb 
is
   functional without setting up code-signing.
-
+* ``LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS:BOOL``: This helps with determining 
missing
+  packages or modules at configuration time.
 
 .. _CMakeCaches:
 
@@ -371,6 +372,7 @@ LLVM `_):
   -C /path/to/llvm-project/lldb/cmake/caches/Apple-lldb-macOS.cmake \
   -DLLVM_ENABLE_PROJECTS="clang;lldb" \
   -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
+  -DLLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=ON \
   llvm-project/llvm
 
   $ DESTDIR=/path/to/lldb-install ninja -C /path/to/lldb-build check-lldb 
install-distribution
@@ -387,6 +389,7 @@ Build LLDB standalone for development with Xcode:
   -C /path/to/llvm-project/lldb/cmake/caches/Apple-lldb-base.cmake \
   -DLLVM_ENABLE_PROJECTS="clang" \
   -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
+  -DLLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=ON \
   llvm-project/llvm
   $ ninja -C /path/to/llvm-build
 

``




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


[Lldb-commits] [lldb] [lldb][docs] Added LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS to build.rst for macOS configuration (PR #130381)

2025-03-07 Thread via lldb-commits

github-actions[bot] wrote:

⚠️ We detected that you are using a GitHub private e-mail address to contribute 
to the repo. Please turn off [Keep my email addresses 
private](https://github.com/settings/emails) setting in your account. See 
[LLVM 
Discourse](https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it)
 for more information.

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


[Lldb-commits] [lldb] [lldb][docs] Added LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS for macOS configuration (PR #130381)

2025-03-07 Thread Julius Alexandre via lldb-commits

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


[Lldb-commits] [lldb] [LLDB][Telemetry]Define TargetInfo for collecting data about a target (PR #127834)

2025-03-07 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/127834

>From 0d6a36d84df50ccb9eef9ef3dd6f59d4299edeac Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Wed, 19 Feb 2025 12:47:57 -0500
Subject: [PATCH 01/15] [LLDB][Telemetry]Define TargetInfo for collecting data
 about a target

---
 lldb/include/lldb/Core/Telemetry.h | 86 +-
 lldb/source/Core/Telemetry.cpp | 99 ++
 2 files changed, 170 insertions(+), 15 deletions(-)

diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
index b72556ecaf3c9..4be81951254de 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -13,6 +13,7 @@
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Utility/StructuredData.h"
 #include "lldb/lldb-forward.h"
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
@@ -29,6 +30,9 @@ namespace telemetry {
 
 struct LLDBEntryKind : public ::llvm::telemetry::EntryKind {
   static const llvm::telemetry::KindType BaseInfo = 0b11000;
+  static const KindType TargetInfo = 0b11010;
+  // There are other entries in between (added in separate PRs)
+  static const llvm::telemetry::KindType MiscInfo = 0b0;
 };
 
 /// Defines a convenient type for timestamp of various events.
@@ -56,14 +60,88 @@ struct LLDBBaseTelemetryInfo : public 
llvm::telemetry::TelemetryInfo {
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 };
 
+/// Describes an exit status.
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct TargetTelemetryInfo : public LldbBaseTelemetryInfo {
+  lldb::ModuleSP exec_mod;
+  Target *target_ptr;
+
+  // The same as the executable-module's UUID.
+  std::string target_uuid;
+  std::string file_format;
+
+  std::string binary_path;
+  size_t binary_size;
+
+  std::optional exit_desc;
+  TargetTelemetryInfo() = default;
+
+  TargetTelemetryInfo(const TargetTelemetryInfo &other) {
+exec_mod = other.exec_mod;
+target_uuid = other.target_uuid;
+file_format = other.file_format;
+binary_path = other.binary_path;
+binary_size = other.binary_size;
+exit_desc = other.exit_desc;
+  }
+
+  KindType getKind() const override { return LldbEntryKind::TargetInfo; }
+
+  static bool classof(const TelemetryInfo *T) {
+if (T == nullptr)
+  return false;
+return T->getKind() == LldbEntryKind::TargetInfo;
+  }
+
+  void serialize(Serializer &serializer) const override;
+};
+
+/// The "catch-all" entry to store a set of non-standard data, such as
+/// error-messages, etc.
+struct MiscTelemetryInfo : public LLDBBaseTelemetryInfo {
+  /// If the event is/can be associated with a target entry,
+  /// this field contains that target's UUID.
+  ///  otherwise.
+  std::string target_uuid;
+
+  /// Set of key-value pairs for any optional (or impl-specific) data
+  std::map meta_data;
+
+  MiscTelemetryInfo() = default;
+
+  MiscTelemetryInfo(const MiscTelemetryInfo &other) {
+target_uuid = other.target_uuid;
+meta_data = other.meta_data;
+  }
+
+  llvm::telemetry::KindType getKind() const override {
+return LLDBEntryKind::MiscInfo;
+  }
+
+  static bool classof(const llvm::telemetry::TelemetryInfo *T) {
+return T->getKind() == LLDBEntryKind::MiscInfo;
+  }
+
+  void serialize(llvm::telemetry::Serializer &serializer) const override;
+};
+
 /// The base Telemetry manager instance in LLDB.
 /// This class declares additional instrumentation points
 /// applicable to LLDB.
-class TelemetryManager : public llvm::telemetry::Manager {
+class TelemetryMager : public llvm::telemetry::Manager {
 public:
   llvm::Error preDispatch(llvm::telemetry::TelemetryInfo *entry) override;
 
-  virtual llvm::StringRef GetInstanceName() const = 0;
+  const llvm::telemetry::Config *getConfig();
+
+  virtual void AtMainExecutableLoadStart(TargetInfo * entry);
+  virtual void AtMainExecutableLoadEnd(TargetInfo *entry);
+
+  virtual llvm::StringRef GetInstanceName() const = 0;
   static TelemetryManager *getInstance();
 
 protected:
@@ -73,6 +151,10 @@ class TelemetryManager : public llvm::telemetry::Manager {
 
 private:
   std::unique_ptr m_config;
+  // Each debugger is assigned a unique ID (session_id).
+  // All TelemetryInfo entries emitted for the same debugger instance
+  // will get the same session_id.
+  llvm::DenseMap session_ids;
   static std::unique_ptr g_instance;
 };
 
diff --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp
index 5222f76704f91..da7aee01680fc 100644
--- a/lldb/source/Core/Telemetry.cpp
+++ b/lldb/source/Core/Telemetry.cpp
@@ -10,14 +10,20 @@
 
 #ifdef LLVM_BUILD_TELEMETRY
 
-#include "lldb/Core/Telemetry.h"
 #include "lldb/Core/Debugger.h"
+#include "lldb/Core/Telemetry.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Target/Process.h"
+#include "l

[Lldb-commits] [lldb] [lldb] Avoid unnecessary regex check in dwim-print (PR #114608)

2025-03-07 Thread Dave Lee via lldb-commits

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/114608

>From a974b175a67a40fbf1f9a422731be3771734a357 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Fri, 1 Nov 2024 14:38:19 -0700
Subject: [PATCH] [lldb] Avoid unnecessary regex check in dwim-print

---
 lldb/source/Commands/CommandObjectDWIMPrint.cpp | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp 
b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
index 04142427717bd..17c60297a521e 100644
--- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp
+++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
@@ -101,6 +101,10 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
   // Add a hint if object description was requested, but no description
   // function was implemented.
   auto maybe_add_hint = [&](llvm::StringRef output) {
+static bool note_shown = false;
+if (note_shown)
+  return;
+
 // Identify the default output of object description for Swift and
 // Objective-C
 // ". The regex is:
@@ -110,17 +114,14 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
 // - Followed by 5 or more hex digits.
 // - Followed by ">".
 // - End with zero or more whitespace characters.
-const std::regex swift_class_regex("^<\\S+: 0x[[:xdigit:]]{5,}>\\s*$");
+static const std::regex swift_class_regex(
+"^<\\S+: 0x[[:xdigit:]]{5,}>\\s*$");
 
 if (GetDebugger().GetShowDontUsePoHint() && target_ptr &&
 (language == lldb::eLanguageTypeSwift ||
  language == lldb::eLanguageTypeObjC) &&
 std::regex_match(output.data(), swift_class_regex)) {
 
-  static bool note_shown = false;
-  if (note_shown)
-return;
-
   result.AppendNote(
   "object description requested, but type doesn't implement "
   "a custom object description. Consider using \"p\" instead of "

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


[Lldb-commits] [lldb] [llvm] Modify the localCache API to require an explicit commit on CachedFile… (PR #115331)

2025-03-07 Thread Teresa Johnson via lldb-commits

teresajohnson wrote:

@anjenner are you looking at the remaining reported buildbot failures? E.g. the 
unit testing failure below. Please fix or revert this change.

> LLVM Buildbot has detected a new failure on builder 
> `llvm-nvptx-nvidia-ubuntu` running on `as-builder-7` while building 
> `lldb,llvm` at step 6 "test-build-unified-tree-check-llvm".
> 
> Full details are available at: 
> https://lab.llvm.org/buildbot/#/builders/180/builds/14226
> 
> Here is the relevant piece of the build log for the reference
> ```
> Step 6 (test-build-unified-tree-check-llvm) failure: test (failure)
>  TEST 'LLVM-Unit :: Support/./SupportTests/134/175' 
> FAILED 
> Script(shard):
> --
> GTEST_OUTPUT=json:/home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/build/unittests/Support/./SupportTests-LLVM-Unit-1311025-134-175.json
>  GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=175 GTEST_SHARD_INDEX=134 
> /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/build/unittests/Support/./SupportTests
> --
> 
> Script:
> --
> /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/build/unittests/Support/./SupportTests
>  --gtest_filter=Caching.Normal
> --
> /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/unittests/Support/Caching.cpp:55:
>  Failure
> Value of: AddStream
>   Actual: false
> Expected: true
> 
> 
> /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/unittests/Support/Caching.cpp:55
> Value of: AddStream
>   Actual: false
> Expected: true
> 
> 
> 
> 
> ```



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


[Lldb-commits] [lldb] [llvm] Modify the localCache API to require an explicit commit on CachedFile… (PR #115331)

2025-03-07 Thread via lldb-commits

dyung wrote:

@anjenner The unittest you added at `unittests/Support/Caching.cpp` seems to be 
randomly failing on a Windows bot:
- https://lab.llvm.org/buildbot/#/builders/46/builds/13196
- https://lab.llvm.org/buildbot/#/builders/46/builds/13202
- https://lab.llvm.org/buildbot/#/builders/46/builds/13207
- https://lab.llvm.org/buildbot/#/builders/46/builds/13208

Can you take a look and make this test more reliable?

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


  1   2   >