[Lldb-commits] [lldb] [llvm] [DRAFT][llvm]Added lib/Telemetry (PR #98528)

2024-07-12 Thread Vy Nguyen via lldb-commits

oontvoo wrote:

> Why does any part of this need to be in llvm/ at all?

Please see comments on the rfc at 
https://discourse.llvm.org/t/rfc-lldb-telemetry-metrics/64588/15

TL;DR : A few people feel that Telemetry is not something unique to LLDB and 
that other tools might be interested in having it too. So rather than having 
mutliple Telemetry libs doing similar things, it might be good to have at least 
a common API

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


[Lldb-commits] [lldb] [llvm] [DRAFT][llvm]Added lib/Telemetry (PR #98528)

2024-07-23 Thread Vy Nguyen via lldb-commits

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

>From 2fa1fa227e6ff93f8904d0f9d56432401d673ed7 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Wed, 10 Jul 2024 15:27:38 -0400
Subject: [PATCH 1/2] [llvm]Added lib/Telemetry  - Provide a base API for llvm
 Telemetry  - Provide some concrete implementation for it in lldb/Telemetry

---
 lldb/include/lldb/API/SBDebugger.h|   4 +
 lldb/include/lldb/Core/Debugger.h |   8 +
 lldb/include/lldb/Core/Telemetry.h| 153 +
 lldb/include/lldb/Target/Process.h|   3 +
 lldb/source/API/SBDebugger.cpp|   9 +
 lldb/source/Core/CMakeLists.txt   |   2 +
 lldb/source/Core/Debugger.cpp |  31 +-
 lldb/source/Core/Telemetry.cpp| 606 ++
 .../source/Interpreter/CommandInterpreter.cpp |  44 +-
 lldb/source/Target/Process.cpp|   7 +-
 lldb/source/Target/Target.cpp |  15 +-
 lldb/tools/lldb-dap/DAP.cpp   |   6 +-
 llvm/include/llvm/Telemetry/Telemetry.h   |  99 +++
 llvm/lib/CMakeLists.txt   |   1 +
 llvm/lib/Telemetry/CMakeLists.txt |   6 +
 llvm/lib/Telemetry/Telemetry.cpp  |  32 +
 16 files changed, 1011 insertions(+), 15 deletions(-)
 create mode 100644 lldb/include/lldb/Core/Telemetry.h
 create mode 100644 lldb/source/Core/Telemetry.cpp
 create mode 100644 llvm/include/llvm/Telemetry/Telemetry.h
 create mode 100644 llvm/lib/Telemetry/CMakeLists.txt
 create mode 100644 llvm/lib/Telemetry/Telemetry.cpp

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index 84ea9c0f772e1..de09995679ad9 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -9,10 +9,12 @@
 #ifndef LLDB_API_SBDEBUGGER_H
 #define LLDB_API_SBDEBUGGER_H
 
+#include 
 #include 
 
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBPlatform.h"
+#include "lldb/API/SBStructuredData.h"
 
 namespace lldb_private {
 class CommandPluginInterfaceImplementation;
@@ -245,6 +247,8 @@ class LLDB_API SBDebugger {
 
   lldb::SBTarget GetDummyTarget();
 
+  void SendTelemetry(SBStructuredData *entry);
+
   // Return true if target is deleted from the target list of the debugger.
   bool DeleteTarget(lldb::SBTarget &target);
 
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index a72c2596cc2c5..13a444e438fec 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -19,6 +19,7 @@
 #include "lldb/Core/FormatEntity.h"
 #include "lldb/Core/IOHandler.h"
 #include "lldb/Core/SourceManager.h"
+#include "lldb/Core/Telemetry.h"
 #include "lldb/Core/UserSettingsController.h"
 #include "lldb/Host/HostThread.h"
 #include "lldb/Host/StreamFile.h"
@@ -31,6 +32,7 @@
 #include "lldb/Utility/Diagnostics.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
+#include "lldb/Utility/StructuredData.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-enumerations.h"
@@ -137,6 +139,10 @@ class Debugger : public 
std::enable_shared_from_this,
 
   lldb::StreamFileSP GetErrorStreamSP() { return m_error_stream_sp; }
 
+  std::shared_ptr GetTelemeter() { return m_telemeter; }
+
+  void SendClientTelemetry(lldb_private::StructuredData::Object *entry);
+
   File &GetInputFile() { return *m_input_file_sp; }
 
   File &GetOutputFile() { return m_output_stream_sp->GetFile(); }
@@ -754,6 +760,7 @@ class Debugger : public 
std::enable_shared_from_this,
   uint32_t m_interrupt_requested = 0; ///< Tracks interrupt requests
   std::mutex m_interrupt_mutex;
 
+  std::shared_ptr m_telemeter;
   // Events for m_sync_broadcaster
   enum {
 eBroadcastBitEventThreadIsListening = (1 << 0),
@@ -766,6 +773,7 @@ class Debugger : public 
std::enable_shared_from_this,
 
   Debugger(const Debugger &) = delete;
   const Debugger &operator=(const Debugger &) = delete;
+  TelemetryEventStats stats;
 };
 
 } // namespace lldb_private
diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
new file mode 100644
index 0..15cc3139764ad
--- /dev/null
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -0,0 +1,153 @@
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+using namespace llvm::telemetry;
+
+namespace lldb_private {
+
+struct DebuggerTelemetryInfo : public ::llvm::telemetry::TelemetryInfo {
+  std::string username;
+  std::string lldb_git_sha;
+  std::string lldb_path;
+  std::string cwd;
+
+  std::string ToString() const override;
+};
+
+struct TargetTelemetryInfo : public ::llvm::t

[Lldb-commits] [lldb] [llvm] [llvm]Added lib/Telemetry (PR #98528)

2024-07-23 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [llvm]Added lib/Telemetry (PR #98528)

2024-07-24 Thread Vy Nguyen via lldb-commits


@@ -0,0 +1,153 @@
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+using namespace llvm::telemetry;
+
+namespace lldb_private {
+
+struct DebuggerTelemetryInfo : public ::llvm::telemetry::TelemetryInfo {
+  std::string username;
+  std::string lldb_git_sha;
+  std::string lldb_path;
+  std::string cwd;
+
+  std::string ToString() const override;
+};
+
+struct TargetTelemetryInfo : public ::llvm::telemetry::TelemetryInfo {
+  // All entries emitted for the same SBTarget will have the same
+  // target_uuid.
+  std::string target_uuid;

oontvoo wrote:

This UUID is the same as the executable module's UUID.
If the process does execve, then a new set of TargetTelemetryInfo will be 
created for the new UUID.

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


[Lldb-commits] [lldb] [llvm] [llvm]Added lib/Telemetry (PR #98528)

2024-08-06 Thread Vy Nguyen via lldb-commits


@@ -0,0 +1,619 @@
+
+//===-- Telemetry.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/Telemetry.h"
+
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBProcess.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Statistics.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/UUID.h"
+#include "lldb/Version/Version.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/LineIterator.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/RandomNumberGenerator.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+#ifdef HAS_VENDOR_TELEMETRY_PLUGINS
+// TODO: could make this path a build-variable rather than hard-coded
+#include "lldb/Core/VendorTelemetryPlugin.h"
+
+// This must include definitions for these functions
+extern void ApplyVendorSpecificConfigs(
+llvm::telemetry::TelemetryConfig *config) /* __attribute__((weak))*/;
+extern std::shared_ptr SanitizeSensitiveFields(
+const llvm::telemetry::TelemetryInfo *entry) /*__attribute__((weak))*/;
+extern std::shared_ptr
+CreateVendorSpecificTelemeter(
+llvm::telemetry::TelemetryConfig *config) /*__attribute__((weak))*/;
+#endif
+
+namespace lldb_private {
+
+static std::string GetDuration(const TelemetryEventStats &stats) {
+  if (stats.m_end.has_value())
+return std::to_string((stats.m_end.value() - stats.m_start).count()) +
+   "(nanosec)";
+  return "";
+}
+
+std::string DebuggerTelemetryInfo::ToString() const {
+  std::string duration_desc =
+  (exit_description.has_value() ? "  lldb session duration: "
+: "  lldb startup duration: ") +
+  std::to_string((stats.m_end.value() - stats.m_start).count()) +
+  "(nanosec)\n";
+
+  return TelemetryInfo::ToString() + "\n" + ("[DebuggerTelemetryInfo]\n") +
+ ("  username: " + username + "\n") +
+ ("  lldb_git_sha: " + lldb_git_sha + "\n") +
+ ("  lldb_path: " + lldb_path + "\n") + ("  cwd: " + cwd + "\n") +
+ duration_desc + "\n";
+}
+
+std::string ClientTelemetryInfo::ToString() const {
+  return TelemetryInfo::ToString() + "\n" + ("[DapRequestInfoEntry]\n") +
+ ("  request_name: " + request_name + "\n") +
+ ("  request_duration: " + GetDuration(stats) + "(nanosec)\n") +
+ ("  error_msg: " + error_msg + "\n");
+}
+
+std::string TargetTelemetryInfo::ToString() const {
+  std::string exit_or_load_desc;
+  if (exit_description.has_value()) {
+// If this entry was emitted for an exit
+exit_or_load_desc = "  process_duration: " + GetDuration(stats) +
+"  exit: " + exit_description->ToString() + "\n";
+  } else {
+// This was emitted for a load event.
+// See if it was the start-load or end-load entry
+if (stats.m_end.has_value()) {
+  exit_or_load_desc =
+  "  startup_init_duration: " + GetDuration(stats) + "\n";
+} else {
+  exit_or_load_desc = " startup_init_start\n";
+}
+  }
+  return TelemetryInfo::ToString() + "\n" + ("[TargetTelemetryInfo]\n") +
+ ("  target_uuid: " + target_uuid + "\n") +
+ ("  file_format: " + file_format + "\n") +
+ ("  binary_path: " + binary_path + "\n") +
+ ("  binary_size: " + std::to_string(binary_size) + "\n") +
+ exit_or_load_desc;
+}
+
+static std::string StatusToString(CommandReturnObject *result) {
+  std::string msg;
+  switch (result->GetStatus()) {
+  case lldb::eReturnStatusInvalid:
+msg = "invalid";
+break;
+  case lldb::eReturnStatusSuccessFinishNoResult:
+msg = "success_finish_no_result";
+break;
+  case lldb::eReturnStatusSuccessFinishResult:
+msg = "success_finish_result";
+break;
+  case lldb::eReturnStatusSuccessContinuingNoResult:
+msg = "success_continuing_no_result";
+break;
+  case lldb::eReturnStatusSuccessContinuingResult:
+msg = "success_continuing_result";
+break;
+  case lldb::eReturnStatusStarted:
+msg = "started";
+break;
+  case lldb::eReturnStatusFailed:
+msg = "failed";
+break;
+  case lldb::eReturnStatusQuit:
+  

[Lldb-commits] [lldb] [llvm] [llvm]Added lib/Telemetry (PR #98528)

2024-08-06 Thread Vy Nguyen via lldb-commits


@@ -0,0 +1,619 @@
+
+//===-- Telemetry.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/Telemetry.h"
+
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBProcess.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Statistics.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/UUID.h"
+#include "lldb/Version/Version.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/LineIterator.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/RandomNumberGenerator.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+#ifdef HAS_VENDOR_TELEMETRY_PLUGINS
+// TODO: could make this path a build-variable rather than hard-coded
+#include "lldb/Core/VendorTelemetryPlugin.h"
+
+// This must include definitions for these functions
+extern void ApplyVendorSpecificConfigs(
+llvm::telemetry::TelemetryConfig *config) /* __attribute__((weak))*/;
+extern std::shared_ptr SanitizeSensitiveFields(
+const llvm::telemetry::TelemetryInfo *entry) /*__attribute__((weak))*/;
+extern std::shared_ptr
+CreateVendorSpecificTelemeter(
+llvm::telemetry::TelemetryConfig *config) /*__attribute__((weak))*/;
+#endif
+
+namespace lldb_private {
+
+static std::string GetDuration(const TelemetryEventStats &stats) {
+  if (stats.m_end.has_value())
+return std::to_string((stats.m_end.value() - stats.m_start).count()) +
+   "(nanosec)";
+  return "";
+}
+
+std::string DebuggerTelemetryInfo::ToString() const {
+  std::string duration_desc =
+  (exit_description.has_value() ? "  lldb session duration: "
+: "  lldb startup duration: ") +
+  std::to_string((stats.m_end.value() - stats.m_start).count()) +
+  "(nanosec)\n";
+
+  return TelemetryInfo::ToString() + "\n" + ("[DebuggerTelemetryInfo]\n") +
+ ("  username: " + username + "\n") +
+ ("  lldb_git_sha: " + lldb_git_sha + "\n") +
+ ("  lldb_path: " + lldb_path + "\n") + ("  cwd: " + cwd + "\n") +
+ duration_desc + "\n";
+}
+
+std::string ClientTelemetryInfo::ToString() const {
+  return TelemetryInfo::ToString() + "\n" + ("[DapRequestInfoEntry]\n") +
+ ("  request_name: " + request_name + "\n") +
+ ("  request_duration: " + GetDuration(stats) + "(nanosec)\n") +
+ ("  error_msg: " + error_msg + "\n");
+}
+
+std::string TargetTelemetryInfo::ToString() const {
+  std::string exit_or_load_desc;
+  if (exit_description.has_value()) {
+// If this entry was emitted for an exit
+exit_or_load_desc = "  process_duration: " + GetDuration(stats) +
+"  exit: " + exit_description->ToString() + "\n";
+  } else {
+// This was emitted for a load event.
+// See if it was the start-load or end-load entry
+if (stats.m_end.has_value()) {
+  exit_or_load_desc =
+  "  startup_init_duration: " + GetDuration(stats) + "\n";
+} else {
+  exit_or_load_desc = " startup_init_start\n";
+}
+  }
+  return TelemetryInfo::ToString() + "\n" + ("[TargetTelemetryInfo]\n") +
+ ("  target_uuid: " + target_uuid + "\n") +
+ ("  file_format: " + file_format + "\n") +
+ ("  binary_path: " + binary_path + "\n") +
+ ("  binary_size: " + std::to_string(binary_size) + "\n") +
+ exit_or_load_desc;
+}
+
+static std::string StatusToString(CommandReturnObject *result) {
+  std::string msg;
+  switch (result->GetStatus()) {
+  case lldb::eReturnStatusInvalid:
+msg = "invalid";
+break;
+  case lldb::eReturnStatusSuccessFinishNoResult:
+msg = "success_finish_no_result";
+break;
+  case lldb::eReturnStatusSuccessFinishResult:
+msg = "success_finish_result";
+break;
+  case lldb::eReturnStatusSuccessContinuingNoResult:
+msg = "success_continuing_no_result";
+break;
+  case lldb::eReturnStatusSuccessContinuingResult:
+msg = "success_continuing_result";
+break;
+  case lldb::eReturnStatusStarted:
+msg = "started";
+break;
+  case lldb::eReturnStatusFailed:
+msg = "failed";
+break;
+  case lldb::eReturnStatusQuit:
+  

[Lldb-commits] [lldb] [llvm] [llvm]Added lib/Telemetry (PR #98528)

2024-08-07 Thread Vy Nguyen via lldb-commits

oontvoo wrote:




> I've made one pass over the PR. I think this would be easier to review if it 
> was split into multiple patches:
> 
> * core llvm infrastructure
> * core lldb infrastructure
> * ~one patch per event type
> 
> I think the biggest hurdle will be finding someone to approve the addition of 
> the new llvm library (I doubt it's going to be someone from the current 
> reviewer set). I wouldn't be surprised if this ends up needing its own RFC.

Good point - so here's the plane:
 - I'll create a separate PR for the first bullet point (llvm core infra).
 - keep this PR as is - since branching is such a pain (and controversial) in 
llvm, you can "pretend" to not see the llvm/lib/ changes in this PR . hopefully 
the diff will disappear once the first PR goes in.


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


[Lldb-commits] [lldb] [llvm] [lldb]Implement LLDB Telemetry (PR #98528)

2024-08-07 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [lldb]Implement LLDB Telemetry (PR #98528)

2024-08-07 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [lldb]Implement LLDB Telemetry (PR #98528)

2024-08-07 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-05-14 Thread Vy Nguyen via lldb-commits

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

>From cdee622a6646ba5c16a3c8156a5a50a938a14b57 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Fri, 5 Apr 2024 14:14:30 -0400
Subject: [PATCH 1/3] [lldb]POC implementation for telemetry in LLDB

---
 lldb/include/lldb/API/SBDebugger.h|   4 +
 lldb/include/lldb/Core/Debugger.h |  10 +
 lldb/include/lldb/Core/Telemetry.h| 206 ++
 lldb/include/lldb/Target/Process.h|   3 +
 lldb/source/API/SBDebugger.cpp|   9 +
 lldb/source/Core/CMakeLists.txt   |   1 +
 lldb/source/Core/Debugger.cpp |  32 +-
 lldb/source/Core/Telemetry.cpp| 620 ++
 .../source/Interpreter/CommandInterpreter.cpp |  44 +-
 lldb/source/Target/Process.cpp|   7 +-
 lldb/source/Target/Target.cpp |  17 +-
 lldb/tools/lldb-dap/DAP.cpp   |  18 +-
 12 files changed, 953 insertions(+), 18 deletions(-)
 create mode 100644 lldb/include/lldb/Core/Telemetry.h
 create mode 100644 lldb/source/Core/Telemetry.cpp

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index 62b2f91f5076d..c4b51fc925f09 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -9,10 +9,12 @@
 #ifndef LLDB_API_SBDEBUGGER_H
 #define LLDB_API_SBDEBUGGER_H
 
+#include 
 #include 
 
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBPlatform.h"
+#include 
"third_party/llvm/llvm-project/lldb/include/lldb/API/SBStructuredData.h"
 
 namespace lldb_private {
 class CommandPluginInterfaceImplementation;
@@ -243,6 +245,8 @@ class LLDB_API SBDebugger {
 
   lldb::SBTarget GetDummyTarget();
 
+  void SendTelemetry(SBStructuredData *entry);
+
   // Return true if target is deleted from the target list of the debugger.
   bool DeleteTarget(lldb::SBTarget &target);
 
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 418c2403d020f..a3ecb7e472437 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -19,6 +19,7 @@
 #include "lldb/Core/FormatEntity.h"
 #include "lldb/Core/IOHandler.h"
 #include "lldb/Core/SourceManager.h"
+#include "lldb/Core/Telemetry.h"
 #include "lldb/Core/UserSettingsController.h"
 #include "lldb/Host/HostThread.h"
 #include "lldb/Host/StreamFile.h"
@@ -38,6 +39,7 @@
 #include "lldb/lldb-private-enumerations.h"
 #include "lldb/lldb-private-types.h"
 #include "lldb/lldb-types.h"
+#include 
"third_party/llvm/llvm-project/lldb/include/lldb/Utility/StructuredData.h"
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringMap.h"
@@ -145,6 +147,12 @@ class Debugger : public 
std::enable_shared_from_this,
 
   lldb::StreamFileSP GetErrorStreamSP() { return m_error_stream_sp; }
 
+  std::shared_ptr GetTelemetryLogger() {
+return m_telemetry_logger;
+  }
+
+  void SendClientTelemetry(lldb_private::StructuredData::Object *entry);
+
   File &GetInputFile() { return *m_input_file_sp; }
 
   File &GetOutputFile() { return m_output_stream_sp->GetFile(); }
@@ -737,6 +745,7 @@ class Debugger : public 
std::enable_shared_from_this,
   uint32_t m_interrupt_requested = 0; ///< Tracks interrupt requests
   std::mutex m_interrupt_mutex;
 
+  std::shared_ptr m_telemetry_logger;
   // Events for m_sync_broadcaster
   enum {
 eBroadcastBitEventThreadIsListening = (1 << 0),
@@ -749,6 +758,7 @@ class Debugger : public 
std::enable_shared_from_this,
 
   Debugger(const Debugger &) = delete;
   const Debugger &operator=(const Debugger &) = delete;
+  TelemetryEventStats stats;
 };
 
 } // namespace lldb_private
diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
new file mode 100644
index 0..1c7b030bb2a49
--- /dev/null
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -0,0 +1,206 @@
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+
+using SteadyTimePoint = std::chrono::time_point;
+
+struct TelemetryEventStats {
+  // REQUIRED: Start time of event
+  SteadyTimePoint m_start;
+  // OPTIONAL: End time of event - may be empty if not meaningful.
+  std::optional m_end;
+
+  // TBD: could add some memory stats here too?
+
+  TelemetryEventStats() = default;
+  TelemetryEventStats(SteadyTimePoint start) : m_start(start) {}
+  TelemetryEventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : m_start(start), m_end(end) {}
+
+  std::optional Duration() const {
+if (m_end.has_value())
+  return *m_end - m_start;
+else
+  return std::nullopt;
+  }
+};
+
+struct LoggerConfig {
+  // If true, loggings will be enabled.
+  bool enable_logging;
+
+  // Additi

[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-05-24 Thread Vy Nguyen via lldb-commits

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

>From 7a0af7b0b5699abe4ac5fe5415c849ffe81aa2ee Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Wed, 3 Apr 2024 16:14:40 -0400
Subject: [PATCH] [lldb][lldb-dap] Cleanup breakpoint filters.

Details:
  - remove Swift breakpoint filter because this version of LLDB does not 
support Swift.
  - only return objc filters when working on macos.
---
 lldb/tools/lldb-dap/DAP.cpp  | 4 +---
 lldb/tools/lldb-dap/lldb-dap.cpp | 7 +++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index b254ddfef0d5f..52e607350407a 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -36,9 +36,7 @@ DAP::DAP()
   {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
{"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
{"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
-   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
-   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
-   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
+   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}}),
   focus_tid(LLDB_INVALID_THREAD_ID), sent_terminated_event(false),
   stop_at_entry(false), is_attach(false),
   enable_auto_variable_summaries(false),
diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp
index 55f8c920e6001..5f5014eaab90f 100644
--- a/lldb/tools/lldb-dap/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/lldb-dap.cpp
@@ -1628,7 +1628,14 @@ void request_initialize(const llvm::json::Object 
&request) {
   body.try_emplace("supportsEvaluateForHovers", true);
   // Available filters or options for the setExceptionBreakpoints request.
   llvm::json::Array filters;
+  std::string triple =
+  std::string(g_dap.debugger.GetSelectedPlatform().GetTriple());
   for (const auto &exc_bp : g_dap.exception_breakpoints) {
+// Skipping objc breakpoint filters if not working on macos.
+if (exc_bp.language == lldb::eLanguageTypeObjC &&
+triple.find("macos") == std::string::npos) {
+  continue;
+}
 filters.emplace_back(CreateExceptionBreakpointFilter(exc_bp));
   }
   body.try_emplace("exceptionBreakpointFilters", std::move(filters));

___
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] Cleanup breakpoint filters. (PR #87550)

2024-05-24 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo reopened 
https://github.com/llvm/llvm-project/pull/87550
___
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] Cleanup breakpoint filters. (PR #87550)

2024-05-24 Thread Vy Nguyen via lldb-commits

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

>From e86d5f95f74a0b2b5f8ec334d8fd4ff519fe7b27 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Fri, 24 May 2024 09:19:12 -0400
Subject: [PATCH] [lldb]Clean up breakpoint filters  - added util function for
 querying whether a language is supported by the type system  - populate the
 breakpoint filters table based on the supported language(s)

---
 lldb/include/lldb/API/SBDebugger.h|  2 ++
 lldb/include/lldb/Symbol/TypeSystem.h |  1 +
 lldb/source/API/SBDebugger.cpp|  4 +++
 lldb/source/Symbol/TypeSystem.cpp | 11 
 lldb/tools/lldb-dap/DAP.cpp   | 36 +--
 lldb/tools/lldb-dap/DAP.h |  3 +++
 lldb/tools/lldb-dap/lldb-dap.cpp  |  1 +
 7 files changed, 50 insertions(+), 8 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index af19b1faf3bf5..84ea9c0f772e1 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -57,6 +57,8 @@ class LLDB_API SBDebugger {
 
   static const char *GetBroadcasterClass();
 
+  static bool SupportsLanguage(lldb::LanguageType language);
+
   lldb::SBBroadcaster GetBroadcaster();
 
   /// Get progress data from a SBEvent whose type is eBroadcastBitProgress.
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index b4025c173a186..7d48f9b316138 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -209,6 +209,7 @@ class TypeSystem : public PluginInterface,
   // TypeSystems can support more than one language
   virtual bool SupportsLanguage(lldb::LanguageType language) = 0;
 
+  static bool SupportsLanguageStatic(lldb::LanguageType language);
   // Type Completion
 
   virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0;
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 7ef0d6efd4aaa..29da7d33dd80b 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1742,3 +1742,7 @@ bool SBDebugger::InterruptRequested()   {
 return m_opaque_sp->InterruptRequested();
   return false;
 }
+
+bool SBDebugger::SupportsLanguage(lldb::LanguageType language) {
+  return TypeSystem::SupportsLanguageStatic(language);
+}
diff --git a/lldb/source/Symbol/TypeSystem.cpp 
b/lldb/source/Symbol/TypeSystem.cpp
index 4956f10a0b0a7..f7d14420fba69 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -335,3 +335,14 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
   }
   return GetTypeSystemForLanguage(language);
 }
+
+bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) {
+  if (language == eLanguageTypeUnknown)
+return false;
+
+  LanguageSet plugins =
+  PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
+  if (plugins.Empty())
+return false;
+  return plugins[language];
+}
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index c7eb3db4304a9..81aabc55b08da 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -32,14 +32,7 @@ namespace lldb_dap {
 DAP g_dap;
 
 DAP::DAP()
-: broadcaster("lldb-dap"),
-  exception_breakpoints(
-  {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
-   {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
-   {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
-   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
-   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
-   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
+: broadcaster("lldb-dap"), exception_breakpoints(),
   focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), 
is_attach(false),
   enable_auto_variable_summaries(false),
   enable_synthetic_child_debugging(false),
@@ -61,11 +54,37 @@ DAP::DAP()
 #endif
   if (log_file_path)
 log.reset(new std::ofstream(log_file_path));
+
+  bp_initted = false;
 }
 
 DAP::~DAP() = default;
 
+void DAP::PopulateExceptionBreakpoints() {
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
+exception_breakpoints.emplace_back(
+{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus});
+exception_breakpoints.emplace_back(
+{"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus});
+  }
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeObjC)) {
+exception_breakpoints.emplace_back(
+{"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC});
+exception_breakpoints.emplace_back(
+{"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC});
+  }
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeSwift)) {
+exception_breakpoints.emplace_back(
+{"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift});
+exception_breakpoints.emplace_back(

[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-05-24 Thread Vy Nguyen via lldb-commits

oontvoo wrote:

> I would be nice if we can detect if we support Swift dynamically. Internally 
> in LLDB, we can ask for a TypeSystem by language using:
> 
> ```
> llvm::Expected
> TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language,
> Module *module, bool can_create);
> llvm::Expected
> TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language,
> Target *target, bool can_create);
> ```
> 
> These functions will return respectively:
> 
> ```
> TypeSystem::CreateInstance(language, module);
> TypeSystem::CreateInstance(language, target);
> ```
> 
> We should be able to add a new static method to the TypeSystem.h/.cpp that 
> can answer if a language is supported with something like:
> 
> ```
> static bool TypeSystem::SupportsLanguage(lldb::LanguageType language);
> ```
> 
> Each TypeSystem plugin can register a new callback that can answer if they 
> support a language. Then we can add a static function on SBDebugger that 
> would expose this function with something like:
> 
> ```
> static bool SBDebugger::SupportsLanguage(lldb::LanguageType language);
> ```
> 
> I will make comments in the DAP.cpp where this would be used.

Done!

https://github.com/llvm/llvm-project/pull/87550
___
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] Cleanup breakpoint filters. (PR #87550)

2024-05-24 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo closed 
https://github.com/llvm/llvm-project/pull/87550
___
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] Cleanup breakpoint filters. (PR #87550)

2024-05-24 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo reopened 
https://github.com/llvm/llvm-project/pull/87550
___
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] Cleanup breakpoint filters. (PR #87550)

2024-05-24 Thread Vy Nguyen via lldb-commits

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

>From e86d5f95f74a0b2b5f8ec334d8fd4ff519fe7b27 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Fri, 24 May 2024 09:19:12 -0400
Subject: [PATCH 1/2] [lldb]Clean up breakpoint filters  - added util function
 for querying whether a language is supported by the type system  - populate
 the breakpoint filters table based on the supported language(s)

---
 lldb/include/lldb/API/SBDebugger.h|  2 ++
 lldb/include/lldb/Symbol/TypeSystem.h |  1 +
 lldb/source/API/SBDebugger.cpp|  4 +++
 lldb/source/Symbol/TypeSystem.cpp | 11 
 lldb/tools/lldb-dap/DAP.cpp   | 36 +--
 lldb/tools/lldb-dap/DAP.h |  3 +++
 lldb/tools/lldb-dap/lldb-dap.cpp  |  1 +
 7 files changed, 50 insertions(+), 8 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index af19b1faf3bf5..84ea9c0f772e1 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -57,6 +57,8 @@ class LLDB_API SBDebugger {
 
   static const char *GetBroadcasterClass();
 
+  static bool SupportsLanguage(lldb::LanguageType language);
+
   lldb::SBBroadcaster GetBroadcaster();
 
   /// Get progress data from a SBEvent whose type is eBroadcastBitProgress.
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index b4025c173a186..7d48f9b316138 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -209,6 +209,7 @@ class TypeSystem : public PluginInterface,
   // TypeSystems can support more than one language
   virtual bool SupportsLanguage(lldb::LanguageType language) = 0;
 
+  static bool SupportsLanguageStatic(lldb::LanguageType language);
   // Type Completion
 
   virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0;
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 7ef0d6efd4aaa..29da7d33dd80b 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1742,3 +1742,7 @@ bool SBDebugger::InterruptRequested()   {
 return m_opaque_sp->InterruptRequested();
   return false;
 }
+
+bool SBDebugger::SupportsLanguage(lldb::LanguageType language) {
+  return TypeSystem::SupportsLanguageStatic(language);
+}
diff --git a/lldb/source/Symbol/TypeSystem.cpp 
b/lldb/source/Symbol/TypeSystem.cpp
index 4956f10a0b0a7..f7d14420fba69 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -335,3 +335,14 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
   }
   return GetTypeSystemForLanguage(language);
 }
+
+bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) {
+  if (language == eLanguageTypeUnknown)
+return false;
+
+  LanguageSet plugins =
+  PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
+  if (plugins.Empty())
+return false;
+  return plugins[language];
+}
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index c7eb3db4304a9..81aabc55b08da 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -32,14 +32,7 @@ namespace lldb_dap {
 DAP g_dap;
 
 DAP::DAP()
-: broadcaster("lldb-dap"),
-  exception_breakpoints(
-  {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
-   {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
-   {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
-   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
-   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
-   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
+: broadcaster("lldb-dap"), exception_breakpoints(),
   focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), 
is_attach(false),
   enable_auto_variable_summaries(false),
   enable_synthetic_child_debugging(false),
@@ -61,11 +54,37 @@ DAP::DAP()
 #endif
   if (log_file_path)
 log.reset(new std::ofstream(log_file_path));
+
+  bp_initted = false;
 }
 
 DAP::~DAP() = default;
 
+void DAP::PopulateExceptionBreakpoints() {
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
+exception_breakpoints.emplace_back(
+{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus});
+exception_breakpoints.emplace_back(
+{"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus});
+  }
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeObjC)) {
+exception_breakpoints.emplace_back(
+{"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC});
+exception_breakpoints.emplace_back(
+{"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC});
+  }
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeSwift)) {
+exception_breakpoints.emplace_back(
+{"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift});
+exception_breakpoints.emplace_ba

[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-05-28 Thread Vy Nguyen via lldb-commits

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

>From e86d5f95f74a0b2b5f8ec334d8fd4ff519fe7b27 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Fri, 24 May 2024 09:19:12 -0400
Subject: [PATCH 1/2] [lldb]Clean up breakpoint filters  - added util function
 for querying whether a language is supported by the type system  - populate
 the breakpoint filters table based on the supported language(s)

---
 lldb/include/lldb/API/SBDebugger.h|  2 ++
 lldb/include/lldb/Symbol/TypeSystem.h |  1 +
 lldb/source/API/SBDebugger.cpp|  4 +++
 lldb/source/Symbol/TypeSystem.cpp | 11 
 lldb/tools/lldb-dap/DAP.cpp   | 36 +--
 lldb/tools/lldb-dap/DAP.h |  3 +++
 lldb/tools/lldb-dap/lldb-dap.cpp  |  1 +
 7 files changed, 50 insertions(+), 8 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index af19b1faf3bf5..84ea9c0f772e1 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -57,6 +57,8 @@ class LLDB_API SBDebugger {
 
   static const char *GetBroadcasterClass();
 
+  static bool SupportsLanguage(lldb::LanguageType language);
+
   lldb::SBBroadcaster GetBroadcaster();
 
   /// Get progress data from a SBEvent whose type is eBroadcastBitProgress.
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index b4025c173a186..7d48f9b316138 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -209,6 +209,7 @@ class TypeSystem : public PluginInterface,
   // TypeSystems can support more than one language
   virtual bool SupportsLanguage(lldb::LanguageType language) = 0;
 
+  static bool SupportsLanguageStatic(lldb::LanguageType language);
   // Type Completion
 
   virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0;
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 7ef0d6efd4aaa..29da7d33dd80b 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1742,3 +1742,7 @@ bool SBDebugger::InterruptRequested()   {
 return m_opaque_sp->InterruptRequested();
   return false;
 }
+
+bool SBDebugger::SupportsLanguage(lldb::LanguageType language) {
+  return TypeSystem::SupportsLanguageStatic(language);
+}
diff --git a/lldb/source/Symbol/TypeSystem.cpp 
b/lldb/source/Symbol/TypeSystem.cpp
index 4956f10a0b0a7..f7d14420fba69 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -335,3 +335,14 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
   }
   return GetTypeSystemForLanguage(language);
 }
+
+bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) {
+  if (language == eLanguageTypeUnknown)
+return false;
+
+  LanguageSet plugins =
+  PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
+  if (plugins.Empty())
+return false;
+  return plugins[language];
+}
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index c7eb3db4304a9..81aabc55b08da 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -32,14 +32,7 @@ namespace lldb_dap {
 DAP g_dap;
 
 DAP::DAP()
-: broadcaster("lldb-dap"),
-  exception_breakpoints(
-  {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
-   {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
-   {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
-   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
-   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
-   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
+: broadcaster("lldb-dap"), exception_breakpoints(),
   focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), 
is_attach(false),
   enable_auto_variable_summaries(false),
   enable_synthetic_child_debugging(false),
@@ -61,11 +54,37 @@ DAP::DAP()
 #endif
   if (log_file_path)
 log.reset(new std::ofstream(log_file_path));
+
+  bp_initted = false;
 }
 
 DAP::~DAP() = default;
 
+void DAP::PopulateExceptionBreakpoints() {
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
+exception_breakpoints.emplace_back(
+{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus});
+exception_breakpoints.emplace_back(
+{"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus});
+  }
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeObjC)) {
+exception_breakpoints.emplace_back(
+{"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC});
+exception_breakpoints.emplace_back(
+{"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC});
+  }
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeSwift)) {
+exception_breakpoints.emplace_back(
+{"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift});
+exception_breakpoints.emplace_ba

[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-05-28 Thread Vy Nguyen via lldb-commits

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

>From e86d5f95f74a0b2b5f8ec334d8fd4ff519fe7b27 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Fri, 24 May 2024 09:19:12 -0400
Subject: [PATCH 1/3] [lldb]Clean up breakpoint filters  - added util function
 for querying whether a language is supported by the type system  - populate
 the breakpoint filters table based on the supported language(s)

---
 lldb/include/lldb/API/SBDebugger.h|  2 ++
 lldb/include/lldb/Symbol/TypeSystem.h |  1 +
 lldb/source/API/SBDebugger.cpp|  4 +++
 lldb/source/Symbol/TypeSystem.cpp | 11 
 lldb/tools/lldb-dap/DAP.cpp   | 36 +--
 lldb/tools/lldb-dap/DAP.h |  3 +++
 lldb/tools/lldb-dap/lldb-dap.cpp  |  1 +
 7 files changed, 50 insertions(+), 8 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index af19b1faf3bf5..84ea9c0f772e1 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -57,6 +57,8 @@ class LLDB_API SBDebugger {
 
   static const char *GetBroadcasterClass();
 
+  static bool SupportsLanguage(lldb::LanguageType language);
+
   lldb::SBBroadcaster GetBroadcaster();
 
   /// Get progress data from a SBEvent whose type is eBroadcastBitProgress.
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index b4025c173a186..7d48f9b316138 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -209,6 +209,7 @@ class TypeSystem : public PluginInterface,
   // TypeSystems can support more than one language
   virtual bool SupportsLanguage(lldb::LanguageType language) = 0;
 
+  static bool SupportsLanguageStatic(lldb::LanguageType language);
   // Type Completion
 
   virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0;
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 7ef0d6efd4aaa..29da7d33dd80b 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1742,3 +1742,7 @@ bool SBDebugger::InterruptRequested()   {
 return m_opaque_sp->InterruptRequested();
   return false;
 }
+
+bool SBDebugger::SupportsLanguage(lldb::LanguageType language) {
+  return TypeSystem::SupportsLanguageStatic(language);
+}
diff --git a/lldb/source/Symbol/TypeSystem.cpp 
b/lldb/source/Symbol/TypeSystem.cpp
index 4956f10a0b0a7..f7d14420fba69 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -335,3 +335,14 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
   }
   return GetTypeSystemForLanguage(language);
 }
+
+bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) {
+  if (language == eLanguageTypeUnknown)
+return false;
+
+  LanguageSet plugins =
+  PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
+  if (plugins.Empty())
+return false;
+  return plugins[language];
+}
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index c7eb3db4304a9..81aabc55b08da 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -32,14 +32,7 @@ namespace lldb_dap {
 DAP g_dap;
 
 DAP::DAP()
-: broadcaster("lldb-dap"),
-  exception_breakpoints(
-  {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
-   {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
-   {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
-   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
-   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
-   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
+: broadcaster("lldb-dap"), exception_breakpoints(),
   focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), 
is_attach(false),
   enable_auto_variable_summaries(false),
   enable_synthetic_child_debugging(false),
@@ -61,11 +54,37 @@ DAP::DAP()
 #endif
   if (log_file_path)
 log.reset(new std::ofstream(log_file_path));
+
+  bp_initted = false;
 }
 
 DAP::~DAP() = default;
 
+void DAP::PopulateExceptionBreakpoints() {
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
+exception_breakpoints.emplace_back(
+{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus});
+exception_breakpoints.emplace_back(
+{"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus});
+  }
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeObjC)) {
+exception_breakpoints.emplace_back(
+{"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC});
+exception_breakpoints.emplace_back(
+{"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC});
+  }
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeSwift)) {
+exception_breakpoints.emplace_back(
+{"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift});
+exception_breakpoints.emplace_ba

[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-05-28 Thread Vy Nguyen via lldb-commits

oontvoo wrote:

@clayborg  Hi, do you have any further comments/feedback on this? Thanks!
(If not, I plan to merge this in the next few days)

https://github.com/llvm/llvm-project/pull/87550
___
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] Cleanup breakpoint filters. (PR #87550)

2024-05-29 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] Reapply PR/87550 (PR #94625)

2024-06-06 Thread Vy Nguyen via lldb-commits

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

>From bbaa8ef4434a1d97a31a5dd7cbfc3cdfebcbe41d Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Thu, 6 Jun 2024 10:17:06 -0400
Subject: [PATCH 1/4] Reapply "[lldb][lldb-dap] Cleanup breakpoint filters."
 (#93739)

This reverts commit 6595e7fa1b5588f860aa057aac47c43623169584.
---
 lldb/include/lldb/API/SBDebugger.h|  2 ++
 lldb/include/lldb/Symbol/TypeSystem.h |  1 +
 lldb/source/API/SBDebugger.cpp|  4 +++
 lldb/source/Symbol/TypeSystem.cpp | 11 
 lldb/tools/lldb-dap/DAP.cpp   | 39 ---
 lldb/tools/lldb-dap/DAP.h |  4 ++-
 lldb/tools/lldb-dap/lldb-dap.cpp  |  6 +++--
 7 files changed, 54 insertions(+), 13 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index af19b1faf3bf5..84ea9c0f772e1 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -57,6 +57,8 @@ class LLDB_API SBDebugger {
 
   static const char *GetBroadcasterClass();
 
+  static bool SupportsLanguage(lldb::LanguageType language);
+
   lldb::SBBroadcaster GetBroadcaster();
 
   /// Get progress data from a SBEvent whose type is eBroadcastBitProgress.
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index b4025c173a186..7d48f9b316138 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -209,6 +209,7 @@ class TypeSystem : public PluginInterface,
   // TypeSystems can support more than one language
   virtual bool SupportsLanguage(lldb::LanguageType language) = 0;
 
+  static bool SupportsLanguageStatic(lldb::LanguageType language);
   // Type Completion
 
   virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0;
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 7ef0d6efd4aaa..29da7d33dd80b 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1742,3 +1742,7 @@ bool SBDebugger::InterruptRequested()   {
 return m_opaque_sp->InterruptRequested();
   return false;
 }
+
+bool SBDebugger::SupportsLanguage(lldb::LanguageType language) {
+  return TypeSystem::SupportsLanguageStatic(language);
+}
diff --git a/lldb/source/Symbol/TypeSystem.cpp 
b/lldb/source/Symbol/TypeSystem.cpp
index 4956f10a0b0a7..5d56d9b1829da 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -335,3 +335,14 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
   }
   return GetTypeSystemForLanguage(language);
 }
+
+bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) {
+  if (language == eLanguageTypeUnknown)
+return false;
+
+  LanguageSet languages =
+  PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
+  if (languages.Empty())
+return false;
+  return languages[language];
+}
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index d419f821999e6..807d27c2c869d 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -32,14 +32,7 @@ namespace lldb_dap {
 DAP g_dap;
 
 DAP::DAP()
-: broadcaster("lldb-dap"),
-  exception_breakpoints(
-  {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
-   {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
-   {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
-   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
-   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
-   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
+: broadcaster("lldb-dap"), exception_breakpoints(),
   focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), 
is_attach(false),
   enable_auto_variable_summaries(false),
   enable_synthetic_child_debugging(false),
@@ -65,8 +58,32 @@ DAP::DAP()
 
 DAP::~DAP() = default;
 
+void DAP::PopulateExceptionBreakpoints() {
+  exception_breakpoints = {};
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
+exception_breakpoints->emplace_back("cpp_catch", "C++ Catch",
+lldb::eLanguageTypeC_plus_plus);
+exception_breakpoints->emplace_back("cpp_throw", "C++ Throw",
+lldb::eLanguageTypeC_plus_plus);
+  }
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeObjC)) {
+exception_breakpoints->emplace_back("objc_catch", "Objective-C Catch",
+lldb::eLanguageTypeObjC);
+exception_breakpoints->emplace_back("objc_throw", "Objective-C Throw",
+lldb::eLanguageTypeObjC);
+  }
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeSwift)) {
+exception_breakpoints->emplace_back("swift_catch", "Swift Catch",
+lldb::eLanguageTypeSwift);
+exception_breakpoints-

[Lldb-commits] [lldb] Reapply PR/87550 (PR #94625)

2024-06-06 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] Reapply PR/87550 (PR #94625)

2024-06-07 Thread Vy Nguyen via lldb-commits

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

>From bbaa8ef4434a1d97a31a5dd7cbfc3cdfebcbe41d Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Thu, 6 Jun 2024 10:17:06 -0400
Subject: [PATCH 1/5] Reapply "[lldb][lldb-dap] Cleanup breakpoint filters."
 (#93739)

This reverts commit 6595e7fa1b5588f860aa057aac47c43623169584.
---
 lldb/include/lldb/API/SBDebugger.h|  2 ++
 lldb/include/lldb/Symbol/TypeSystem.h |  1 +
 lldb/source/API/SBDebugger.cpp|  4 +++
 lldb/source/Symbol/TypeSystem.cpp | 11 
 lldb/tools/lldb-dap/DAP.cpp   | 39 ---
 lldb/tools/lldb-dap/DAP.h |  4 ++-
 lldb/tools/lldb-dap/lldb-dap.cpp  |  6 +++--
 7 files changed, 54 insertions(+), 13 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index af19b1faf3bf5..84ea9c0f772e1 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -57,6 +57,8 @@ class LLDB_API SBDebugger {
 
   static const char *GetBroadcasterClass();
 
+  static bool SupportsLanguage(lldb::LanguageType language);
+
   lldb::SBBroadcaster GetBroadcaster();
 
   /// Get progress data from a SBEvent whose type is eBroadcastBitProgress.
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index b4025c173a186..7d48f9b316138 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -209,6 +209,7 @@ class TypeSystem : public PluginInterface,
   // TypeSystems can support more than one language
   virtual bool SupportsLanguage(lldb::LanguageType language) = 0;
 
+  static bool SupportsLanguageStatic(lldb::LanguageType language);
   // Type Completion
 
   virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0;
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 7ef0d6efd4aaa..29da7d33dd80b 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1742,3 +1742,7 @@ bool SBDebugger::InterruptRequested()   {
 return m_opaque_sp->InterruptRequested();
   return false;
 }
+
+bool SBDebugger::SupportsLanguage(lldb::LanguageType language) {
+  return TypeSystem::SupportsLanguageStatic(language);
+}
diff --git a/lldb/source/Symbol/TypeSystem.cpp 
b/lldb/source/Symbol/TypeSystem.cpp
index 4956f10a0b0a7..5d56d9b1829da 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -335,3 +335,14 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
   }
   return GetTypeSystemForLanguage(language);
 }
+
+bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) {
+  if (language == eLanguageTypeUnknown)
+return false;
+
+  LanguageSet languages =
+  PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
+  if (languages.Empty())
+return false;
+  return languages[language];
+}
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index d419f821999e6..807d27c2c869d 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -32,14 +32,7 @@ namespace lldb_dap {
 DAP g_dap;
 
 DAP::DAP()
-: broadcaster("lldb-dap"),
-  exception_breakpoints(
-  {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
-   {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
-   {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
-   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
-   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
-   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
+: broadcaster("lldb-dap"), exception_breakpoints(),
   focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), 
is_attach(false),
   enable_auto_variable_summaries(false),
   enable_synthetic_child_debugging(false),
@@ -65,8 +58,32 @@ DAP::DAP()
 
 DAP::~DAP() = default;
 
+void DAP::PopulateExceptionBreakpoints() {
+  exception_breakpoints = {};
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
+exception_breakpoints->emplace_back("cpp_catch", "C++ Catch",
+lldb::eLanguageTypeC_plus_plus);
+exception_breakpoints->emplace_back("cpp_throw", "C++ Throw",
+lldb::eLanguageTypeC_plus_plus);
+  }
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeObjC)) {
+exception_breakpoints->emplace_back("objc_catch", "Objective-C Catch",
+lldb::eLanguageTypeObjC);
+exception_breakpoints->emplace_back("objc_throw", "Objective-C Throw",
+lldb::eLanguageTypeObjC);
+  }
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeSwift)) {
+exception_breakpoints->emplace_back("swift_catch", "Swift Catch",
+lldb::eLanguageTypeSwift);
+exception_breakpoints-

[Lldb-commits] [lldb] Reapply PR/87550 (PR #94625)

2024-06-07 Thread Vy Nguyen via lldb-commits


@@ -65,16 +58,60 @@ DAP::DAP()
 
 DAP::~DAP() = default;
 
+void DAP::PopulateExceptionBreakpoints() {
+  exception_breakpoints = {};
+  if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
+exception_breakpoints->emplace_back("cpp_catch", "C++ Catch",
+lldb::eLanguageTypeC_plus_plus);
+exception_breakpoints->emplace_back("cpp_throw", "C++ Throw",
+lldb::eLanguageTypeC_plus_plus);
+  }
+  if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeObjC)) {
+exception_breakpoints->emplace_back("objc_catch", "Objective-C Catch",
+lldb::eLanguageTypeObjC);
+exception_breakpoints->emplace_back("objc_throw", "Objective-C Throw",
+lldb::eLanguageTypeObjC);
+  }
+  if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeSwift)) {
+exception_breakpoints->emplace_back("swift_catch", "Swift Catch",
+lldb::eLanguageTypeSwift);
+exception_breakpoints->emplace_back("swift_throw", "Swift Throw",
+lldb::eLanguageTypeSwift);
+  }
+}
+
 ExceptionBreakpoint *DAP::GetExceptionBreakpoint(const std::string &filter) {
-  for (auto &bp : exception_breakpoints) {
+  // PopulateExceptionBreakpoints() is called after g_dap.debugger is created
+  // in a request-initialize.
+  //
+  // But this GetExceptionBreakpoint() method may be called before attaching, 
in
+  // which case, we may not have populated the filter yet.
+  //
+  // We also cannot call PopulateExceptionBreakpoints() in DAP::DAP() because
+  // we need SBDebugger::Initialize() to have been called before this.
+  //
+  // So just checking the filter list and do lazy-populating seems easiest.
+  // Two other options include:
+  //  + call g_dap.PopulateExceptionBreakpoints() in lldb-dap.cpp::main()
+  //right after the call to SBDebugger::Initialize()
+  //  + Just call PopulateExceptionBreakpoints() to get a fresh list  everytime
+  //we query (a bit overkill since it's not likely to change?)
+  if (!exception_breakpoints.has_value())

oontvoo wrote:

Thanks! I've removed the `if()` check and wrap the block of code that populates 
`exception_breakpoints` in a call_once so the callers of 
`PopulateExceptionBreakpoints` don't have to do that

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


[Lldb-commits] [lldb] Reapply PR/87550 (PR #94625)

2024-06-07 Thread Vy Nguyen via lldb-commits

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

>From bbaa8ef4434a1d97a31a5dd7cbfc3cdfebcbe41d Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Thu, 6 Jun 2024 10:17:06 -0400
Subject: [PATCH 1/6] Reapply "[lldb][lldb-dap] Cleanup breakpoint filters."
 (#93739)

This reverts commit 6595e7fa1b5588f860aa057aac47c43623169584.
---
 lldb/include/lldb/API/SBDebugger.h|  2 ++
 lldb/include/lldb/Symbol/TypeSystem.h |  1 +
 lldb/source/API/SBDebugger.cpp|  4 +++
 lldb/source/Symbol/TypeSystem.cpp | 11 
 lldb/tools/lldb-dap/DAP.cpp   | 39 ---
 lldb/tools/lldb-dap/DAP.h |  4 ++-
 lldb/tools/lldb-dap/lldb-dap.cpp  |  6 +++--
 7 files changed, 54 insertions(+), 13 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index af19b1faf3bf5..84ea9c0f772e1 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -57,6 +57,8 @@ class LLDB_API SBDebugger {
 
   static const char *GetBroadcasterClass();
 
+  static bool SupportsLanguage(lldb::LanguageType language);
+
   lldb::SBBroadcaster GetBroadcaster();
 
   /// Get progress data from a SBEvent whose type is eBroadcastBitProgress.
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index b4025c173a186..7d48f9b316138 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -209,6 +209,7 @@ class TypeSystem : public PluginInterface,
   // TypeSystems can support more than one language
   virtual bool SupportsLanguage(lldb::LanguageType language) = 0;
 
+  static bool SupportsLanguageStatic(lldb::LanguageType language);
   // Type Completion
 
   virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0;
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 7ef0d6efd4aaa..29da7d33dd80b 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1742,3 +1742,7 @@ bool SBDebugger::InterruptRequested()   {
 return m_opaque_sp->InterruptRequested();
   return false;
 }
+
+bool SBDebugger::SupportsLanguage(lldb::LanguageType language) {
+  return TypeSystem::SupportsLanguageStatic(language);
+}
diff --git a/lldb/source/Symbol/TypeSystem.cpp 
b/lldb/source/Symbol/TypeSystem.cpp
index 4956f10a0b0a7..5d56d9b1829da 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -335,3 +335,14 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
   }
   return GetTypeSystemForLanguage(language);
 }
+
+bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) {
+  if (language == eLanguageTypeUnknown)
+return false;
+
+  LanguageSet languages =
+  PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
+  if (languages.Empty())
+return false;
+  return languages[language];
+}
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index d419f821999e6..807d27c2c869d 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -32,14 +32,7 @@ namespace lldb_dap {
 DAP g_dap;
 
 DAP::DAP()
-: broadcaster("lldb-dap"),
-  exception_breakpoints(
-  {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
-   {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
-   {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
-   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
-   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
-   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
+: broadcaster("lldb-dap"), exception_breakpoints(),
   focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), 
is_attach(false),
   enable_auto_variable_summaries(false),
   enable_synthetic_child_debugging(false),
@@ -65,8 +58,32 @@ DAP::DAP()
 
 DAP::~DAP() = default;
 
+void DAP::PopulateExceptionBreakpoints() {
+  exception_breakpoints = {};
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
+exception_breakpoints->emplace_back("cpp_catch", "C++ Catch",
+lldb::eLanguageTypeC_plus_plus);
+exception_breakpoints->emplace_back("cpp_throw", "C++ Throw",
+lldb::eLanguageTypeC_plus_plus);
+  }
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeObjC)) {
+exception_breakpoints->emplace_back("objc_catch", "Objective-C Catch",
+lldb::eLanguageTypeObjC);
+exception_breakpoints->emplace_back("objc_throw", "Objective-C Throw",
+lldb::eLanguageTypeObjC);
+  }
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeSwift)) {
+exception_breakpoints->emplace_back("swift_catch", "Swift Catch",
+lldb::eLanguageTypeSwift);
+exception_breakpoints-

[Lldb-commits] [lldb] Reapply PR/87550 (PR #94625)

2024-06-07 Thread Vy Nguyen via lldb-commits


@@ -59,25 +59,29 @@ DAP::DAP()
 DAP::~DAP() = default;
 
 void DAP::PopulateExceptionBreakpoints() {
-  exception_breakpoints = {};
-  if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
-exception_breakpoints->emplace_back("cpp_catch", "C++ Catch",
-lldb::eLanguageTypeC_plus_plus);
-exception_breakpoints->emplace_back("cpp_throw", "C++ Throw",
-lldb::eLanguageTypeC_plus_plus);
-  }
-  if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeObjC)) {
-exception_breakpoints->emplace_back("objc_catch", "Objective-C Catch",
-lldb::eLanguageTypeObjC);
-exception_breakpoints->emplace_back("objc_throw", "Objective-C Throw",
-lldb::eLanguageTypeObjC);
-  }
-  if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeSwift)) {
-exception_breakpoints->emplace_back("swift_catch", "Swift Catch",
-lldb::eLanguageTypeSwift);
-exception_breakpoints->emplace_back("swift_throw", "Swift Throw",
-lldb::eLanguageTypeSwift);
-  }
+  if (exception_breakpoints.has_value())
+return;

oontvoo wrote:

thanks!

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


[Lldb-commits] [lldb] Reapply PR/87550 (PR #94625)

2024-06-07 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] Reapply PR/87550 (again) (PR #95571)

2024-06-14 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo created 
https://github.com/llvm/llvm-project/pull/95571

New fixes:
-  properly init the `std::optional` to an empty vector as opposed 
to `{}` (which was effectively `std::nullopt`).


>From 018c7a6052add708e0b0d09b911a904b52199da5 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 11 Jun 2024 14:15:43 -0400
Subject: [PATCH 1/3] Reapply "Reapply PR/87550 (#94625)"

This reverts commit adcf33f8fbcc0f068bd4b8254994b16dda525009.
---
 lldb/include/lldb/API/SBDebugger.h|  2 +
 lldb/include/lldb/Symbol/TypeSystem.h |  1 +
 lldb/source/API/SBDebugger.cpp|  4 ++
 lldb/source/Symbol/TypeSystem.cpp | 11 +
 lldb/tools/lldb-dap/DAP.cpp   | 61 ++-
 lldb/tools/lldb-dap/DAP.h |  5 ++-
 lldb/tools/lldb-dap/lldb-dap.cpp  |  6 ++-
 7 files changed, 77 insertions(+), 13 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index af19b1faf3bf5..84ea9c0f772e1 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -57,6 +57,8 @@ class LLDB_API SBDebugger {
 
   static const char *GetBroadcasterClass();
 
+  static bool SupportsLanguage(lldb::LanguageType language);
+
   lldb::SBBroadcaster GetBroadcaster();
 
   /// Get progress data from a SBEvent whose type is eBroadcastBitProgress.
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index b4025c173a186..7d48f9b316138 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -209,6 +209,7 @@ class TypeSystem : public PluginInterface,
   // TypeSystems can support more than one language
   virtual bool SupportsLanguage(lldb::LanguageType language) = 0;
 
+  static bool SupportsLanguageStatic(lldb::LanguageType language);
   // Type Completion
 
   virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0;
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 7ef0d6efd4aaa..29da7d33dd80b 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1742,3 +1742,7 @@ bool SBDebugger::InterruptRequested()   {
 return m_opaque_sp->InterruptRequested();
   return false;
 }
+
+bool SBDebugger::SupportsLanguage(lldb::LanguageType language) {
+  return TypeSystem::SupportsLanguageStatic(language);
+}
diff --git a/lldb/source/Symbol/TypeSystem.cpp 
b/lldb/source/Symbol/TypeSystem.cpp
index 4956f10a0b0a7..5d56d9b1829da 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -335,3 +335,14 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
   }
   return GetTypeSystemForLanguage(language);
 }
+
+bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) {
+  if (language == eLanguageTypeUnknown)
+return false;
+
+  LanguageSet languages =
+  PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
+  if (languages.Empty())
+return false;
+  return languages[language];
+}
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index d419f821999e6..263e841b7254d 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -32,14 +32,7 @@ namespace lldb_dap {
 DAP g_dap;
 
 DAP::DAP()
-: broadcaster("lldb-dap"),
-  exception_breakpoints(
-  {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
-   {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
-   {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
-   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
-   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
-   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
+: broadcaster("lldb-dap"), exception_breakpoints(),
   focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), 
is_attach(false),
   enable_auto_variable_summaries(false),
   enable_synthetic_child_debugging(false),
@@ -65,8 +58,51 @@ DAP::DAP()
 
 DAP::~DAP() = default;
 
+void DAP::PopulateExceptionBreakpoints() {
+  llvm::call_once(initExceptionBreakpoints, [this]() {
+exception_breakpoints = {};
+if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
+  exception_breakpoints->emplace_back("cpp_catch", "C++ Catch",
+  lldb::eLanguageTypeC_plus_plus);
+  exception_breakpoints->emplace_back("cpp_throw", "C++ Throw",
+  lldb::eLanguageTypeC_plus_plus);
+}
+if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeObjC)) {
+  exception_breakpoints->emplace_back("objc_catch", "Objective-C Catch",
+  lldb::eLanguageTypeObjC);
+  exception_breakpoints->emplace_back("objc_throw", "Objective-C Throw",
+  lldb::eLanguageTypeObjC);
+}
+if (lldb::SBDebugger::Support

[Lldb-commits] [lldb] Reapply PR/87550 (again) (PR #95571)

2024-06-17 Thread Vy Nguyen via lldb-commits

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

>From 018c7a6052add708e0b0d09b911a904b52199da5 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 11 Jun 2024 14:15:43 -0400
Subject: [PATCH 1/3] Reapply "Reapply PR/87550 (#94625)"

This reverts commit adcf33f8fbcc0f068bd4b8254994b16dda525009.
---
 lldb/include/lldb/API/SBDebugger.h|  2 +
 lldb/include/lldb/Symbol/TypeSystem.h |  1 +
 lldb/source/API/SBDebugger.cpp|  4 ++
 lldb/source/Symbol/TypeSystem.cpp | 11 +
 lldb/tools/lldb-dap/DAP.cpp   | 61 ++-
 lldb/tools/lldb-dap/DAP.h |  5 ++-
 lldb/tools/lldb-dap/lldb-dap.cpp  |  6 ++-
 7 files changed, 77 insertions(+), 13 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index af19b1faf3bf5..84ea9c0f772e1 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -57,6 +57,8 @@ class LLDB_API SBDebugger {
 
   static const char *GetBroadcasterClass();
 
+  static bool SupportsLanguage(lldb::LanguageType language);
+
   lldb::SBBroadcaster GetBroadcaster();
 
   /// Get progress data from a SBEvent whose type is eBroadcastBitProgress.
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index b4025c173a186..7d48f9b316138 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -209,6 +209,7 @@ class TypeSystem : public PluginInterface,
   // TypeSystems can support more than one language
   virtual bool SupportsLanguage(lldb::LanguageType language) = 0;
 
+  static bool SupportsLanguageStatic(lldb::LanguageType language);
   // Type Completion
 
   virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0;
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 7ef0d6efd4aaa..29da7d33dd80b 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1742,3 +1742,7 @@ bool SBDebugger::InterruptRequested()   {
 return m_opaque_sp->InterruptRequested();
   return false;
 }
+
+bool SBDebugger::SupportsLanguage(lldb::LanguageType language) {
+  return TypeSystem::SupportsLanguageStatic(language);
+}
diff --git a/lldb/source/Symbol/TypeSystem.cpp 
b/lldb/source/Symbol/TypeSystem.cpp
index 4956f10a0b0a7..5d56d9b1829da 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -335,3 +335,14 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
   }
   return GetTypeSystemForLanguage(language);
 }
+
+bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) {
+  if (language == eLanguageTypeUnknown)
+return false;
+
+  LanguageSet languages =
+  PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
+  if (languages.Empty())
+return false;
+  return languages[language];
+}
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index d419f821999e6..263e841b7254d 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -32,14 +32,7 @@ namespace lldb_dap {
 DAP g_dap;
 
 DAP::DAP()
-: broadcaster("lldb-dap"),
-  exception_breakpoints(
-  {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
-   {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
-   {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
-   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
-   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
-   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
+: broadcaster("lldb-dap"), exception_breakpoints(),
   focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), 
is_attach(false),
   enable_auto_variable_summaries(false),
   enable_synthetic_child_debugging(false),
@@ -65,8 +58,51 @@ DAP::DAP()
 
 DAP::~DAP() = default;
 
+void DAP::PopulateExceptionBreakpoints() {
+  llvm::call_once(initExceptionBreakpoints, [this]() {
+exception_breakpoints = {};
+if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
+  exception_breakpoints->emplace_back("cpp_catch", "C++ Catch",
+  lldb::eLanguageTypeC_plus_plus);
+  exception_breakpoints->emplace_back("cpp_throw", "C++ Throw",
+  lldb::eLanguageTypeC_plus_plus);
+}
+if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeObjC)) {
+  exception_breakpoints->emplace_back("objc_catch", "Objective-C Catch",
+  lldb::eLanguageTypeObjC);
+  exception_breakpoints->emplace_back("objc_throw", "Objective-C Throw",
+  lldb::eLanguageTypeObjC);
+}
+if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeSwift)) {
+  exception_breakpoints->emplace_back("swift_catch", "Swift Catch",
+

[Lldb-commits] [lldb] Reapply PR/87550 (again) (PR #95571)

2024-06-21 Thread Vy Nguyen via lldb-commits

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

>From 018c7a6052add708e0b0d09b911a904b52199da5 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 11 Jun 2024 14:15:43 -0400
Subject: [PATCH 1/3] Reapply "Reapply PR/87550 (#94625)"

This reverts commit adcf33f8fbcc0f068bd4b8254994b16dda525009.
---
 lldb/include/lldb/API/SBDebugger.h|  2 +
 lldb/include/lldb/Symbol/TypeSystem.h |  1 +
 lldb/source/API/SBDebugger.cpp|  4 ++
 lldb/source/Symbol/TypeSystem.cpp | 11 +
 lldb/tools/lldb-dap/DAP.cpp   | 61 ++-
 lldb/tools/lldb-dap/DAP.h |  5 ++-
 lldb/tools/lldb-dap/lldb-dap.cpp  |  6 ++-
 7 files changed, 77 insertions(+), 13 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index af19b1faf3bf5..84ea9c0f772e1 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -57,6 +57,8 @@ class LLDB_API SBDebugger {
 
   static const char *GetBroadcasterClass();
 
+  static bool SupportsLanguage(lldb::LanguageType language);
+
   lldb::SBBroadcaster GetBroadcaster();
 
   /// Get progress data from a SBEvent whose type is eBroadcastBitProgress.
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index b4025c173a186..7d48f9b316138 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -209,6 +209,7 @@ class TypeSystem : public PluginInterface,
   // TypeSystems can support more than one language
   virtual bool SupportsLanguage(lldb::LanguageType language) = 0;
 
+  static bool SupportsLanguageStatic(lldb::LanguageType language);
   // Type Completion
 
   virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0;
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 7ef0d6efd4aaa..29da7d33dd80b 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1742,3 +1742,7 @@ bool SBDebugger::InterruptRequested()   {
 return m_opaque_sp->InterruptRequested();
   return false;
 }
+
+bool SBDebugger::SupportsLanguage(lldb::LanguageType language) {
+  return TypeSystem::SupportsLanguageStatic(language);
+}
diff --git a/lldb/source/Symbol/TypeSystem.cpp 
b/lldb/source/Symbol/TypeSystem.cpp
index 4956f10a0b0a7..5d56d9b1829da 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -335,3 +335,14 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
   }
   return GetTypeSystemForLanguage(language);
 }
+
+bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) {
+  if (language == eLanguageTypeUnknown)
+return false;
+
+  LanguageSet languages =
+  PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
+  if (languages.Empty())
+return false;
+  return languages[language];
+}
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index d419f821999e6..263e841b7254d 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -32,14 +32,7 @@ namespace lldb_dap {
 DAP g_dap;
 
 DAP::DAP()
-: broadcaster("lldb-dap"),
-  exception_breakpoints(
-  {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
-   {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
-   {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
-   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
-   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
-   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
+: broadcaster("lldb-dap"), exception_breakpoints(),
   focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), 
is_attach(false),
   enable_auto_variable_summaries(false),
   enable_synthetic_child_debugging(false),
@@ -65,8 +58,51 @@ DAP::DAP()
 
 DAP::~DAP() = default;
 
+void DAP::PopulateExceptionBreakpoints() {
+  llvm::call_once(initExceptionBreakpoints, [this]() {
+exception_breakpoints = {};
+if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
+  exception_breakpoints->emplace_back("cpp_catch", "C++ Catch",
+  lldb::eLanguageTypeC_plus_plus);
+  exception_breakpoints->emplace_back("cpp_throw", "C++ Throw",
+  lldb::eLanguageTypeC_plus_plus);
+}
+if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeObjC)) {
+  exception_breakpoints->emplace_back("objc_catch", "Objective-C Catch",
+  lldb::eLanguageTypeObjC);
+  exception_breakpoints->emplace_back("objc_throw", "Objective-C Throw",
+  lldb::eLanguageTypeObjC);
+}
+if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeSwift)) {
+  exception_breakpoints->emplace_back("swift_catch", "Swift Catch",
+

[Lldb-commits] [lldb] Reapply PR/87550 (again) (PR #95571)

2024-06-21 Thread Vy Nguyen via lldb-commits


@@ -65,16 +58,67 @@ DAP::DAP()
 
 DAP::~DAP() = default;
 
+void DAP::PopulateExceptionBreakpoints() {
+  llvm::call_once(initExceptionBreakpoints, [this]() {
+exception_breakpoints = std::vector {};
+
+if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
+  exception_breakpoints->emplace_back("cpp_catch", "C++ Catch",
+  lldb::eLanguageTypeC_plus_plus);
+  exception_breakpoints->emplace_back("cpp_throw", "C++ Throw",
+  lldb::eLanguageTypeC_plus_plus);
+}
+if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeObjC)) {
+  exception_breakpoints->emplace_back("objc_catch", "Objective-C Catch",
+  lldb::eLanguageTypeObjC);
+  exception_breakpoints->emplace_back("objc_throw", "Objective-C Throw",
+  lldb::eLanguageTypeObjC);
+}
+if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeSwift)) {
+  exception_breakpoints->emplace_back("swift_catch", "Swift Catch",
+  lldb::eLanguageTypeSwift);
+  exception_breakpoints->emplace_back("swift_throw", "Swift Throw",
+  lldb::eLanguageTypeSwift);
+}
+assert(exception_breakpoints.has_value() && "should have been initted");
+assert(!exception_breakpoints->empty() && "should not be empty");

oontvoo wrote:

The `exceptions_breakpoints` *could* be empty if for some reason all of the 
if-condition above returns false. That would be unexpected and I think it's 
easier to catch the bug right here rather than later

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


[Lldb-commits] [lldb] Reapply PR/87550 (again) (PR #95571)

2024-06-21 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] Reapply PR/87550 (again) (PR #95571)

2024-06-21 Thread Vy Nguyen via lldb-commits

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

>From 018c7a6052add708e0b0d09b911a904b52199da5 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 11 Jun 2024 14:15:43 -0400
Subject: [PATCH 1/4] Reapply "Reapply PR/87550 (#94625)"

This reverts commit adcf33f8fbcc0f068bd4b8254994b16dda525009.
---
 lldb/include/lldb/API/SBDebugger.h|  2 +
 lldb/include/lldb/Symbol/TypeSystem.h |  1 +
 lldb/source/API/SBDebugger.cpp|  4 ++
 lldb/source/Symbol/TypeSystem.cpp | 11 +
 lldb/tools/lldb-dap/DAP.cpp   | 61 ++-
 lldb/tools/lldb-dap/DAP.h |  5 ++-
 lldb/tools/lldb-dap/lldb-dap.cpp  |  6 ++-
 7 files changed, 77 insertions(+), 13 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index af19b1faf3bf5..84ea9c0f772e1 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -57,6 +57,8 @@ class LLDB_API SBDebugger {
 
   static const char *GetBroadcasterClass();
 
+  static bool SupportsLanguage(lldb::LanguageType language);
+
   lldb::SBBroadcaster GetBroadcaster();
 
   /// Get progress data from a SBEvent whose type is eBroadcastBitProgress.
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index b4025c173a186..7d48f9b316138 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -209,6 +209,7 @@ class TypeSystem : public PluginInterface,
   // TypeSystems can support more than one language
   virtual bool SupportsLanguage(lldb::LanguageType language) = 0;
 
+  static bool SupportsLanguageStatic(lldb::LanguageType language);
   // Type Completion
 
   virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0;
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 7ef0d6efd4aaa..29da7d33dd80b 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1742,3 +1742,7 @@ bool SBDebugger::InterruptRequested()   {
 return m_opaque_sp->InterruptRequested();
   return false;
 }
+
+bool SBDebugger::SupportsLanguage(lldb::LanguageType language) {
+  return TypeSystem::SupportsLanguageStatic(language);
+}
diff --git a/lldb/source/Symbol/TypeSystem.cpp 
b/lldb/source/Symbol/TypeSystem.cpp
index 4956f10a0b0a7..5d56d9b1829da 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -335,3 +335,14 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
   }
   return GetTypeSystemForLanguage(language);
 }
+
+bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) {
+  if (language == eLanguageTypeUnknown)
+return false;
+
+  LanguageSet languages =
+  PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
+  if (languages.Empty())
+return false;
+  return languages[language];
+}
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index d419f821999e6..263e841b7254d 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -32,14 +32,7 @@ namespace lldb_dap {
 DAP g_dap;
 
 DAP::DAP()
-: broadcaster("lldb-dap"),
-  exception_breakpoints(
-  {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
-   {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
-   {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
-   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
-   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
-   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
+: broadcaster("lldb-dap"), exception_breakpoints(),
   focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), 
is_attach(false),
   enable_auto_variable_summaries(false),
   enable_synthetic_child_debugging(false),
@@ -65,8 +58,51 @@ DAP::DAP()
 
 DAP::~DAP() = default;
 
+void DAP::PopulateExceptionBreakpoints() {
+  llvm::call_once(initExceptionBreakpoints, [this]() {
+exception_breakpoints = {};
+if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
+  exception_breakpoints->emplace_back("cpp_catch", "C++ Catch",
+  lldb::eLanguageTypeC_plus_plus);
+  exception_breakpoints->emplace_back("cpp_throw", "C++ Throw",
+  lldb::eLanguageTypeC_plus_plus);
+}
+if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeObjC)) {
+  exception_breakpoints->emplace_back("objc_catch", "Objective-C Catch",
+  lldb::eLanguageTypeObjC);
+  exception_breakpoints->emplace_back("objc_throw", "Objective-C Throw",
+  lldb::eLanguageTypeObjC);
+}
+if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeSwift)) {
+  exception_breakpoints->emplace_back("swift_catch", "Swift Catch",
+

[Lldb-commits] [lldb] Reapply PR/87550 (again) (PR #95571)

2024-06-21 Thread Vy Nguyen via lldb-commits

oontvoo wrote:

Ran all the tests:

```
Unresolved Tests (23):
  lldb-api :: api/multithreaded/TestMultithreaded.py
  lldb-api :: 
commands/expression/multiline-completion/TestMultilineCompletion.py
  lldb-api :: 
commands/expression/multiline-navigation/TestMultilineNavigation.py
  lldb-api :: commands/gui/basic/TestGuiBasic.py
  lldb-api :: commands/gui/breakpoints/TestGuiBreakpoints.py
  lldb-api :: commands/gui/spawn-threads/TestGuiSpawnThreads.py
  lldb-api :: commands/gui/viewlarge/TestGuiViewLarge.py
  lldb-api :: driver/batch_mode/TestBatchMode.py
  lldb-api :: driver/job_control/TestJobControl.py
  lldb-api :: driver/quit_speed/TestQuitWithProcess.py
  lldb-api :: 
functionalities/breakpoint/breakpoint_callback_command_source/TestBreakpointCallbackCommandSource.py
  lldb-api :: functionalities/progress_reporting/TestTrimmedProgressReporting.py
  lldb-api :: iohandler/autosuggestion/TestAutosuggestion.py
  lldb-api :: iohandler/completion/TestIOHandlerCompletion.py
  lldb-api :: iohandler/resize/TestIOHandlerResize.py
  lldb-api :: iohandler/sigint/TestIOHandlerPythonREPLSigint.py
  lldb-api :: iohandler/sigint/TestProcessIOHandlerInterrupt.py
  lldb-api :: iohandler/stdio/TestIOHandlerProcessSTDIO.py
  lldb-api :: iohandler/unicode/TestUnicode.py
  lldb-api :: macosx/nslog/TestDarwinNSLogOutput.py
  lldb-api :: repl/clang/TestClangREPL.py
  lldb-api :: terminal/TestEditline.py
  lldb-api :: terminal/TestSTTYBeforeAndAfter.py


Failed Tests (1):
  lldb-api :: commands/platform/sdk/TestPlatformSDK.py


Testing Time: 11310.46s

Total Discovered Tests: 1183
  Unsupported  : 155 (13.10%)
  Passed   : 988 (83.52%)
  Expectedly Failed:  16 (1.35%)
  Unresolved   :  23 (1.94%)
  Failed   :   1 (0.08%)
```

(Compared to main branch:

```
Unresolved Tests (27):
  lldb-api :: api/multithreaded/TestMultithreaded.py
  lldb-api :: 
commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
  lldb-api :: 
commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py
  lldb-api :: 
commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
  lldb-api :: 
commands/expression/multiline-completion/TestMultilineCompletion.py
  lldb-api :: 
commands/expression/multiline-navigation/TestMultilineNavigation.py
  lldb-api :: commands/gui/basic/TestGuiBasic.py
  lldb-api :: commands/gui/breakpoints/TestGuiBreakpoints.py
  lldb-api :: commands/gui/spawn-threads/TestGuiSpawnThreads.py
  lldb-api :: commands/gui/viewlarge/TestGuiViewLarge.py
  lldb-api :: driver/batch_mode/TestBatchMode.py
  lldb-api :: driver/job_control/TestJobControl.py
  lldb-api :: driver/quit_speed/TestQuitWithProcess.py
  lldb-api :: 
functionalities/breakpoint/breakpoint_callback_command_source/TestBreakpointCallbackCommandSource.py
  lldb-api :: functionalities/progress_reporting/TestTrimmedProgressReporting.py
  lldb-api :: iohandler/autosuggestion/TestAutosuggestion.py
  lldb-api :: iohandler/completion/TestIOHandlerCompletion.py
  lldb-api :: iohandler/resize/TestIOHandlerResize.py
  lldb-api :: iohandler/sigint/TestIOHandlerPythonREPLSigint.py
  lldb-api :: iohandler/sigint/TestProcessIOHandlerInterrupt.py
  lldb-api :: iohandler/stdio/TestIOHandlerProcessSTDIO.py
  lldb-api :: iohandler/unicode/TestUnicode.py
  lldb-api :: macosx/nslog/TestDarwinNSLogOutput.py
  lldb-api :: python_api/thread/TestThreadAPI.py
  lldb-api :: repl/clang/TestClangREPL.py
  lldb-api :: terminal/TestEditline.py
  lldb-api :: terminal/TestSTTYBeforeAndAfter.py


Failed Tests (5):
  lldb-api :: commands/platform/sdk/TestPlatformSDK.py
  lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentBreakpointsDelayedBreakpointOneWatchpoint.py
  lldb-api :: lang/cpp/constructors/TestCppConstructors.py
  lldb-api :: lang/objc/modules-non-objc-target/TestObjCModulesNonObjCTarget.py
  lldb-api :: python_api/lldbutil/iter/TestLLDBIterator.py


Testing Time: 11040.07s

Total Discovered Tests: 1183
  Unsupported  : 155 (13.10%)
  Passed   : 980 (82.84%)
  Expectedly Failed:  16 (1.35%)
  Unresolved   :  27 (2.28%)
  Failed   :   5 (0.42%)
```
)

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


[Lldb-commits] [lldb] Reapply PR/87550 (again) (PR #95571)

2024-06-24 Thread Vy Nguyen via lldb-commits

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

>From 018c7a6052add708e0b0d09b911a904b52199da5 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 11 Jun 2024 14:15:43 -0400
Subject: [PATCH 1/5] Reapply "Reapply PR/87550 (#94625)"

This reverts commit adcf33f8fbcc0f068bd4b8254994b16dda525009.
---
 lldb/include/lldb/API/SBDebugger.h|  2 +
 lldb/include/lldb/Symbol/TypeSystem.h |  1 +
 lldb/source/API/SBDebugger.cpp|  4 ++
 lldb/source/Symbol/TypeSystem.cpp | 11 +
 lldb/tools/lldb-dap/DAP.cpp   | 61 ++-
 lldb/tools/lldb-dap/DAP.h |  5 ++-
 lldb/tools/lldb-dap/lldb-dap.cpp  |  6 ++-
 7 files changed, 77 insertions(+), 13 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index af19b1faf3bf5..84ea9c0f772e1 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -57,6 +57,8 @@ class LLDB_API SBDebugger {
 
   static const char *GetBroadcasterClass();
 
+  static bool SupportsLanguage(lldb::LanguageType language);
+
   lldb::SBBroadcaster GetBroadcaster();
 
   /// Get progress data from a SBEvent whose type is eBroadcastBitProgress.
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index b4025c173a186..7d48f9b316138 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -209,6 +209,7 @@ class TypeSystem : public PluginInterface,
   // TypeSystems can support more than one language
   virtual bool SupportsLanguage(lldb::LanguageType language) = 0;
 
+  static bool SupportsLanguageStatic(lldb::LanguageType language);
   // Type Completion
 
   virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0;
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 7ef0d6efd4aaa..29da7d33dd80b 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1742,3 +1742,7 @@ bool SBDebugger::InterruptRequested()   {
 return m_opaque_sp->InterruptRequested();
   return false;
 }
+
+bool SBDebugger::SupportsLanguage(lldb::LanguageType language) {
+  return TypeSystem::SupportsLanguageStatic(language);
+}
diff --git a/lldb/source/Symbol/TypeSystem.cpp 
b/lldb/source/Symbol/TypeSystem.cpp
index 4956f10a0b0a7..5d56d9b1829da 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -335,3 +335,14 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
   }
   return GetTypeSystemForLanguage(language);
 }
+
+bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) {
+  if (language == eLanguageTypeUnknown)
+return false;
+
+  LanguageSet languages =
+  PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
+  if (languages.Empty())
+return false;
+  return languages[language];
+}
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index d419f821999e6..263e841b7254d 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -32,14 +32,7 @@ namespace lldb_dap {
 DAP g_dap;
 
 DAP::DAP()
-: broadcaster("lldb-dap"),
-  exception_breakpoints(
-  {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
-   {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
-   {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
-   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
-   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
-   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
+: broadcaster("lldb-dap"), exception_breakpoints(),
   focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), 
is_attach(false),
   enable_auto_variable_summaries(false),
   enable_synthetic_child_debugging(false),
@@ -65,8 +58,51 @@ DAP::DAP()
 
 DAP::~DAP() = default;
 
+void DAP::PopulateExceptionBreakpoints() {
+  llvm::call_once(initExceptionBreakpoints, [this]() {
+exception_breakpoints = {};
+if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
+  exception_breakpoints->emplace_back("cpp_catch", "C++ Catch",
+  lldb::eLanguageTypeC_plus_plus);
+  exception_breakpoints->emplace_back("cpp_throw", "C++ Throw",
+  lldb::eLanguageTypeC_plus_plus);
+}
+if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeObjC)) {
+  exception_breakpoints->emplace_back("objc_catch", "Objective-C Catch",
+  lldb::eLanguageTypeObjC);
+  exception_breakpoints->emplace_back("objc_throw", "Objective-C Throw",
+  lldb::eLanguageTypeObjC);
+}
+if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeSwift)) {
+  exception_breakpoints->emplace_back("swift_catch", "Swift Catch",
+

[Lldb-commits] [lldb] Reapply PR/87550 (again) (PR #95571)

2024-06-24 Thread Vy Nguyen via lldb-commits


@@ -65,16 +58,67 @@ DAP::DAP()
 
 DAP::~DAP() = default;
 
+void DAP::PopulateExceptionBreakpoints() {
+  llvm::call_once(initExceptionBreakpoints, [this]() {
+exception_breakpoints = std::vector {};
+
+if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
+  exception_breakpoints->emplace_back("cpp_catch", "C++ Catch",
+  lldb::eLanguageTypeC_plus_plus);
+  exception_breakpoints->emplace_back("cpp_throw", "C++ Throw",
+  lldb::eLanguageTypeC_plus_plus);
+}
+if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeObjC)) {
+  exception_breakpoints->emplace_back("objc_catch", "Objective-C Catch",
+  lldb::eLanguageTypeObjC);
+  exception_breakpoints->emplace_back("objc_throw", "Objective-C Throw",
+  lldb::eLanguageTypeObjC);
+}
+if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeSwift)) {
+  exception_breakpoints->emplace_back("swift_catch", "Swift Catch",
+  lldb::eLanguageTypeSwift);
+  exception_breakpoints->emplace_back("swift_throw", "Swift Throw",
+  lldb::eLanguageTypeSwift);
+}
+assert(exception_breakpoints.has_value() && "should have been initted");
+assert(!exception_breakpoints->empty() && "should not be empty");
+  });
+}
+
 ExceptionBreakpoint *DAP::GetExceptionBreakpoint(const std::string &filter) {
-  for (auto &bp : exception_breakpoints) {
+  // PopulateExceptionBreakpoints() is called after g_dap.debugger is created
+  // in a request-initialize.
+  //
+  // But this GetExceptionBreakpoint() method may be called before attaching, 
in
+  // which case, we may not have populated the filter yet.
+  //
+  // We also cannot call PopulateExceptionBreakpoints() in DAP::DAP() because
+  // we need SBDebugger::Initialize() to have been called before this.
+  //
+  // So just calling PopulateExceptionBreakoints(),which does lazy-populating
+  // seems easiest. Two other options include:
+  //  + call g_dap.PopulateExceptionBreakpoints() in lldb-dap.cpp::main()
+  //right after the call to SBDebugger::Initialize()
+  //  + Just call PopulateExceptionBreakpoints() to get a fresh list  everytime
+  //we query (a bit overkill since it's not likely to change?)
+  PopulateExceptionBreakpoints();
+  assert(exception_breakpoints.has_value() &&
+ "exception_breakpoints must have been populated");

oontvoo wrote:

done - i've removed the unnecessary asserts(but keeping the method name to make 
it clearer that this function's job is to popualte the list)

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


[Lldb-commits] [lldb] Reapply PR/87550 (again) (PR #95571)

2024-06-25 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [lldb]Implement LLDB Telemetry (PR #98528)

2024-09-10 Thread Vy Nguyen via lldb-commits


@@ -754,6 +760,7 @@ class Debugger : public 
std::enable_shared_from_this,
   uint32_t m_interrupt_requested = 0; ///< Tracks interrupt requests
   std::mutex m_interrupt_mutex;
 
+  std::shared_ptr m_telemeter;

oontvoo wrote:

The use of  "shared_ptr" here is to ensure the object can be "shared" with 
different parts of the code - and not so much about the telemter outliving its 
debugger.

But I suppose we can make it a unique_ptr and just share the raw pointer 
around, if you prefer?

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


[Lldb-commits] [lldb] [llvm] [lldb]Implement LLDB Telemetry (PR #98528)

2024-09-12 Thread Vy Nguyen via lldb-commits


@@ -754,6 +760,7 @@ class Debugger : public 
std::enable_shared_from_this,
   uint32_t m_interrupt_requested = 0; ///< Tracks interrupt requests
   std::mutex m_interrupt_mutex;
 
+  std::shared_ptr m_telemeter;

oontvoo wrote:

done

https://github.com/llvm/llvm-project/pull/98528
___
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] Cleanup breakpoint filters. (PR #87550)

2024-04-05 Thread Vy Nguyen via lldb-commits


@@ -36,9 +36,7 @@ DAP::DAP()
   {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
{"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
{"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
-   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
-   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
-   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
+   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}}),

oontvoo wrote:

Thanks for the detailed suggestions! Makes sense!

For ObjC, just to clarify, the intention of hiding the filters was NOT because 
the debugger didn't support it - the intention was to avoid 
clustering/confusing users - that is, if they're not debugging ObjC, there's no 
reason to show the objc filters. (And we infer this by checking if they're 
debugging on a mac - it's theoretically possible they're cross debugging objc 
from a non-mac but in practice I don't think it's likely )
Does this seem reasonable?

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo created 
https://github.com/llvm/llvm-project/pull/87815

Implement telemetry in LLDB.

(See previous discussions at 
https://discourse.llvm.org/t/rfc-lldb-telemetry-metrics/64588)

>From cdee622a6646ba5c16a3c8156a5a50a938a14b57 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Fri, 5 Apr 2024 14:14:30 -0400
Subject: [PATCH 1/2] [lldb]POC implementation for telemetry in LLDB

---
 lldb/include/lldb/API/SBDebugger.h|   4 +
 lldb/include/lldb/Core/Debugger.h |  10 +
 lldb/include/lldb/Core/Telemetry.h| 206 ++
 lldb/include/lldb/Target/Process.h|   3 +
 lldb/source/API/SBDebugger.cpp|   9 +
 lldb/source/Core/CMakeLists.txt   |   1 +
 lldb/source/Core/Debugger.cpp |  32 +-
 lldb/source/Core/Telemetry.cpp| 620 ++
 .../source/Interpreter/CommandInterpreter.cpp |  44 +-
 lldb/source/Target/Process.cpp|   7 +-
 lldb/source/Target/Target.cpp |  17 +-
 lldb/tools/lldb-dap/DAP.cpp   |  18 +-
 12 files changed, 953 insertions(+), 18 deletions(-)
 create mode 100644 lldb/include/lldb/Core/Telemetry.h
 create mode 100644 lldb/source/Core/Telemetry.cpp

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index 62b2f91f5076d5..c4b51fc925f094 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -9,10 +9,12 @@
 #ifndef LLDB_API_SBDEBUGGER_H
 #define LLDB_API_SBDEBUGGER_H
 
+#include 
 #include 
 
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBPlatform.h"
+#include 
"third_party/llvm/llvm-project/lldb/include/lldb/API/SBStructuredData.h"
 
 namespace lldb_private {
 class CommandPluginInterfaceImplementation;
@@ -243,6 +245,8 @@ class LLDB_API SBDebugger {
 
   lldb::SBTarget GetDummyTarget();
 
+  void SendTelemetry(SBStructuredData *entry);
+
   // Return true if target is deleted from the target list of the debugger.
   bool DeleteTarget(lldb::SBTarget &target);
 
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 418c2403d020f4..a3ecb7e4724374 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -19,6 +19,7 @@
 #include "lldb/Core/FormatEntity.h"
 #include "lldb/Core/IOHandler.h"
 #include "lldb/Core/SourceManager.h"
+#include "lldb/Core/Telemetry.h"
 #include "lldb/Core/UserSettingsController.h"
 #include "lldb/Host/HostThread.h"
 #include "lldb/Host/StreamFile.h"
@@ -38,6 +39,7 @@
 #include "lldb/lldb-private-enumerations.h"
 #include "lldb/lldb-private-types.h"
 #include "lldb/lldb-types.h"
+#include 
"third_party/llvm/llvm-project/lldb/include/lldb/Utility/StructuredData.h"
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringMap.h"
@@ -145,6 +147,12 @@ class Debugger : public 
std::enable_shared_from_this,
 
   lldb::StreamFileSP GetErrorStreamSP() { return m_error_stream_sp; }
 
+  std::shared_ptr GetTelemetryLogger() {
+return m_telemetry_logger;
+  }
+
+  void SendClientTelemetry(lldb_private::StructuredData::Object *entry);
+
   File &GetInputFile() { return *m_input_file_sp; }
 
   File &GetOutputFile() { return m_output_stream_sp->GetFile(); }
@@ -737,6 +745,7 @@ class Debugger : public 
std::enable_shared_from_this,
   uint32_t m_interrupt_requested = 0; ///< Tracks interrupt requests
   std::mutex m_interrupt_mutex;
 
+  std::shared_ptr m_telemetry_logger;
   // Events for m_sync_broadcaster
   enum {
 eBroadcastBitEventThreadIsListening = (1 << 0),
@@ -749,6 +758,7 @@ class Debugger : public 
std::enable_shared_from_this,
 
   Debugger(const Debugger &) = delete;
   const Debugger &operator=(const Debugger &) = delete;
+  TelemetryEventStats stats;
 };
 
 } // namespace lldb_private
diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
new file mode 100644
index 00..1c7b030bb2a49c
--- /dev/null
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -0,0 +1,206 @@
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+
+using SteadyTimePoint = std::chrono::time_point;
+
+struct TelemetryEventStats {
+  // REQUIRED: Start time of event
+  SteadyTimePoint m_start;
+  // OPTIONAL: End time of event - may be empty if not meaningful.
+  std::optional m_end;
+
+  // TBD: could add some memory stats here too?
+
+  TelemetryEventStats() = default;
+  TelemetryEventStats(SteadyTimePoint start) : m_start(start) {}
+  TelemetryEventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : m_start(start), m_end(end) {}
+
+  std::optional Duration() const {
+if (m_end.has_value())
+  return *m_end - m_start;
+else
+  retu

[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-04-05 Thread Vy Nguyen via lldb-commits


@@ -36,9 +36,7 @@ DAP::DAP()
   {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
{"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
{"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
-   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
-   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
-   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
+   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}}),

oontvoo wrote:


> The ObjC Language runtime is able to detect whether ObjC is loaded into the 
> program. It runs that detector on each library load, so it keeps an accurate 
> notion of this. Ditto for the swift language runtime. It would be better to 
> consult that than guess based on platform.

This code runs before the runtimes (objc/swift) so it probably won't be able to 
query that, though?


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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-05 Thread Vy Nguyen via lldb-commits


@@ -243,6 +245,8 @@ class LLDB_API SBDebugger {
 
   lldb::SBTarget GetDummyTarget();
 
+  void SendTelemetry(SBStructuredData *entry);

oontvoo wrote:

Can you clarify your privacy model?

We need this  API because we want to be able to collect performance stats for 
our IDE debugging  layer (eg., how long each DAP packet takes, success vs 
failed vs timedout counts, etc).  While it's possible that the clients could 
have their own telemetry  outside of LLDB, it is helpful to be able to combine 
both client(s)' and server's telemetry data for each session 

As for privacy concerns, at least, from our POV, we ensure that the collected 
data is stored with restricted and auditable access. The `Destination` class, 
which takes care of forwarding the collected telemetry entries to its final 
destination, is vendor-specific. So you could choose to ignore client telemetry 
if it does not fit your privacy model. 

https://github.com/llvm/llvm-project/pull/87815
___
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] Cleanup breakpoint filters. (PR #87550)

2024-04-05 Thread Vy Nguyen via lldb-commits


@@ -36,9 +36,7 @@ DAP::DAP()
   {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
{"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
{"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
-   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
-   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
-   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
+   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}}),

oontvoo wrote:

P.S: it was pointed out to me that changed capabilities can be pushed as an 
event. So I guess we could init the list of filters based on whether the 
languages are supported. Then when the runtime(s) become available, we can 
update the list after querying for which language is being debugged. WDYT?

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


[Lldb-commits] [lldb] [RFC][LLDB] Telemetry in LLDB (PR #87815)

2024-04-10 Thread Vy Nguyen via lldb-commits

oontvoo wrote:

> A bunch of time has passed since the original RFC. It would be great, and 
> help with reviewing the PR, to have an overview of the currently proposed 
> architecture, the different pieces and how it all fits together. I left some 
> inline comments, but I'm not sure if it's worth fixing those before we're all 
> on the same page about the higher level stuff.

I've replied to the Discourse thread just now with an [updated doc]( 
(https://discourse.llvm.org/t/rfc-lldb-telemetry-metrics/64588/14?u=oontvoo))

PTAL. Thanks!



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


[Lldb-commits] [lldb] [lldb] fix dead lock in TypeCategoryMap.cpp (PR #87540)

2024-04-12 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [compiler-rt] [libcxx] [llvm] [lldb] [lld] [lld-macho] Find objects in library search path (PR #78628)

2024-01-19 Thread Vy Nguyen via lldb-commits


@@ -0,0 +1,10 @@
+# REQUIRES: x86
+# RUN: mkdir -p %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libhello.s 
-o %t/hello.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/main.o
+# RUN: %lld -L %t %t/main.o %t/hello.o -o %t/a.out

oontvoo wrote:

Should there be some basic verification of the output after the link? 

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


[Lldb-commits] [compiler-rt] [lldb] [llvm] [libcxx] [lld] [lld-macho] Find objects in library search path (PR #78628)

2024-01-19 Thread Vy Nguyen via lldb-commits


@@ -90,6 +90,9 @@ static std::optional findLibrary(StringRef name) {
 return entry->second;
 
   auto doFind = [&] {
+// Special case for Csu support files.

oontvoo wrote:

nit: would be helpful to either expand what Csu are ... (not a very common 
thing - I had  to look it up :) ) 

Thanks!

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


[Lldb-commits] [compiler-rt] [libcxx] [llvm] [lldb] [lld] [lld-macho] Find objects in library search path (PR #78628)

2024-01-19 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [libcxx] [lld] [llvm] [compiler-rt] [lldb] [lld-macho] Find objects in library search path (PR #78628)

2024-01-20 Thread Vy Nguyen via lldb-commits

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

LGTM. Thanks!

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


[Lldb-commits] [llvm] [compiler-rt] [libc] [libcxx] [flang] [clang] [lld] [lldb] [clang-tools-extra] [lld-macho] Find objects in library search path (PR #78628)

2024-01-22 Thread Vy Nguyen via lldb-commits


@@ -0,0 +1,14 @@
+# REQUIRES: x86
+# RUN: mkdir -p %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libhello.s 
-o %t/hello.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/main.o
+# RUN: %lld -L %t %t/main.o %t/hello.o -o %t/a.out

oontvoo wrote:

would you mind putting it in another PR? we can get it merged there. Thanks!

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


[Lldb-commits] [lldb] 83cb212 - [lldb][NFC]Update debug (eh-frame) tests to work with new dwarwin MC changes

2023-06-08 Thread Vy Nguyen via lldb-commits

Author: Vy Nguyen
Date: 2023-06-08T13:11:34-04:00
New Revision: 83cb2123be487302070562c45e6eb4955b22c2b4

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

LOG: [lldb][NFC]Update debug (eh-frame) tests to work with new dwarwin MC 
changes

Details:

D144999 potentially changes the debug format (from compact-unwind to dwarf).
Updated this test to no longer prefer debug-frame over eh-frame to be 
compatible with the new behaviour

Differential Revision: https://reviews.llvm.org/D152449

Added: 


Modified: 
lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test

Removed: 




diff  --git a/lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test 
b/lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
index 19e3ae18c25f3..0d3f34ec86f56 100644
--- a/lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
+++ b/lldb/test/Shell/Unwind/prefer-debug-over-eh-frame.test
@@ -5,7 +5,6 @@
 # be thrown.
 
 # UNSUPPORTED: system-windows
-# XFAIL: system-darwin
 # REQUIRES: target-x86_64, native
 
 # RUN: %clang_host -g %p/Inputs/call-asm.c 
%p/Inputs/prefer-debug-over-eh-frame.s -o %t



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


[Lldb-commits] [lldb] [LLDB]Provide clearer error message for invalid commands. (PR #111891)

2024-10-12 Thread Vy Nguyen via lldb-commits

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

>From 4493bf07c8b18dac39a2a421f97fa34cd15a6031 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Thu, 10 Oct 2024 14:48:08 -0400
Subject: [PATCH 1/3] [LLDB]Provide clearer error message for invalid commands.

Sometimes users (esp. gdb-longtime users) accidentally use GDB syntax, such as 
`breakpoint foo`, and they would get an error message from LLDB saying simply 
`Invalid command "breakpoint foo"`, which is not very helpful.
This change provides additional suggestions to help correcting the mistake.
---
 .../lldb/Interpreter/CommandObjectMultiword.h |  2 +
 .../Commands/CommandObjectMultiword.cpp   | 42 ++-
 .../Commands/command-breakpoint-col.test  |  2 +
 3 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h 
b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
index bceb7f0e51edb6..cee118c3f454b5 100644
--- a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
+++ b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
@@ -70,6 +70,8 @@ class CommandObjectMultiword : public CommandObject {
 return m_subcommand_dict;
   }
 
+  std::string GetTopSubcommands(int count);
+
   CommandObject::CommandMap m_subcommand_dict;
   bool m_can_be_removed;
 };
diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp 
b/lldb/source/Commands/CommandObjectMultiword.cpp
index 4efa5652a71703..f7bb58187895b4 100644
--- a/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -194,28 +194,50 @@ void CommandObjectMultiword::Execute(const char 
*args_string,
 
   std::string error_msg;
   const size_t num_subcmd_matches = matches.GetSize();
-  if (num_subcmd_matches > 0)
+  if (num_subcmd_matches > 0) {
 error_msg.assign("ambiguous command ");
-  else
-error_msg.assign("invalid command ");
-
-  error_msg.append("'");
-  error_msg.append(std::string(GetCommandName()));
-  error_msg.append(" ");
-  error_msg.append(std::string(sub_command));
-  error_msg.append("'.");
+error_msg.append("'");
+error_msg.append(std::string(GetCommandName()));
+error_msg.append(" ");
+error_msg.append(std::string(sub_command));
+error_msg.append("'.");
 
-  if (num_subcmd_matches > 0) {
 error_msg.append(" Possible completions:");
 for (const std::string &match : matches) {
   error_msg.append("\n\t");
   error_msg.append(match);
 }
+  } else {
+// Rather than simply complaining about the invalid (sub) command,
+// try to offer some alternatives.
+// This is especially useful for cases where the user types something
+// seamingly trivial, such as `breakpoint foo`.
+error_msg.assign(
+llvm::Twine("'" + sub_command + "' is not a valid subcommand of \"" +
+GetCommandName() + "\". Valid subcommands are " +
+GetTopSubcommands(/*count=*/5) + ". Use \"help " +
+GetCommandName() + "\" to find out more.")
+.str());
   }
   error_msg.append("\n");
   result.AppendRawError(error_msg.c_str());
 }
 
+std::string CommandObjectMultiword::GetTopSubcommands(int count) {
+  if (m_subcommand_dict.empty())
+return "";
+  std::string buffer = "{";
+  CommandMap::iterator pos;
+  for (pos = m_subcommand_dict.begin();
+   pos != m_subcommand_dict.end() && count > 0; ++pos, --count) {
+buffer.append("'");
+buffer.append(pos->first);
+buffer.append("',");
+  }
+  buffer.append("...}");
+  return buffer;
+}
+
 void CommandObjectMultiword::GenerateHelpText(Stream &output_stream) {
   // First time through here, generate the help text for the object and push it
   // to the return result object as well
diff --git a/lldb/test/Shell/Commands/command-breakpoint-col.test 
b/lldb/test/Shell/Commands/command-breakpoint-col.test
index 65c1e220794303..fecb773d2b4c66 100644
--- a/lldb/test/Shell/Commands/command-breakpoint-col.test
+++ b/lldb/test/Shell/Commands/command-breakpoint-col.test
@@ -3,8 +3,10 @@
 # RUN: %clang_host -g -O0 %S/Inputs/main.c -o %t.out
 # RUN: %lldb -b -o 'help breakpoint set' -o 'breakpoint set -f main.c -l 2 -u 
21' %t.out | FileCheck %s --check-prefix HELP --check-prefix CHECK
 # RUN: %lldb -b -o 'help _regexp-break' -o 'b main.c:2:21' %t.out | FileCheck 
%s --check-prefix HELP-REGEX --check-prefix CHECK
+# RUN: not %lldb -b -o 'breakpoint foo' %t.out -o exit 2>&1 | FileCheck %s 
--check-prefix ERROR-MSG
 # HELP: -u  ( --column  )
 # HELP: Specifies the column number on which to set this breakpoint.
 # HELP-REGEX: _regexp-break ::
 # HELP-REGEX: main.c:12:21{{.*}}Break at line 12 and column 21 of main.c
 # CHECK: at main.c:2:21
+# ERROR-MSG: 'foo' is not a valid subcommand of "breakpoint". Valid 
subcommands are {'clear','command','delete','disable','enable',...}. Use "help 
breakpoint" to find out more.

>From 8dfb266f7eed943f7d9c4bd00e09ef86ae1c5d6e Mon

[Lldb-commits] [lldb] [LLDB]Provide clearer error message for invalid commands. (PR #111891)

2024-10-12 Thread Vy Nguyen via lldb-commits


@@ -3,8 +3,10 @@
 # RUN: %clang_host -g -O0 %S/Inputs/main.c -o %t.out
 # RUN: %lldb -b -o 'help breakpoint set' -o 'breakpoint set -f main.c -l 2 -u 
21' %t.out | FileCheck %s --check-prefix HELP --check-prefix CHECK
 # RUN: %lldb -b -o 'help _regexp-break' -o 'b main.c:2:21' %t.out | FileCheck 
%s --check-prefix HELP-REGEX --check-prefix CHECK
+# RUN: not %lldb -b -o 'breakpoint foo' %t.out -o exit 2>&1 | FileCheck %s 
--check-prefix ERROR-MSG

oontvoo wrote:

done

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


[Lldb-commits] [lldb] [LLDB]Provide clearer error message for invalid commands. (PR #111891)

2024-10-14 Thread Vy Nguyen via lldb-commits

oontvoo wrote:

Can I merge this? Or would anyone else like to have another look/comments? 
Thanks!

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


[Lldb-commits] [lldb] [LLDB]Provide clearer error message for invalid commands. (PR #111891)

2024-10-15 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] [LLDB]Provide clearer error message for invalid commands. (PR #111891)

2024-10-11 Thread Vy Nguyen via lldb-commits


@@ -194,28 +194,50 @@ void CommandObjectMultiword::Execute(const char 
*args_string,
 
   std::string error_msg;
   const size_t num_subcmd_matches = matches.GetSize();
-  if (num_subcmd_matches > 0)
+  if (num_subcmd_matches > 0) {
 error_msg.assign("ambiguous command ");
-  else
-error_msg.assign("invalid command ");
-
-  error_msg.append("'");
-  error_msg.append(std::string(GetCommandName()));
-  error_msg.append(" ");
-  error_msg.append(std::string(sub_command));
-  error_msg.append("'.");
+error_msg.append("'");
+error_msg.append(std::string(GetCommandName()));
+error_msg.append(" ");
+error_msg.append(std::string(sub_command));
+error_msg.append("'.");
 
-  if (num_subcmd_matches > 0) {
 error_msg.append(" Possible completions:");
 for (const std::string &match : matches) {
   error_msg.append("\n\t");
   error_msg.append(match);
 }
+  } else {
+// Rather than simply complaining about the invalid (sub) command,
+// try to offer some alternatives.
+// This is especially useful for cases where the user types something
+// seamingly trivial, such as `breakpoint foo`.
+error_msg.assign(
+llvm::Twine("'" + sub_command + "' is not a valid subcommand of \"" +
+GetCommandName() + "\". Valid subcommands are " +
+GetTopSubcommands(/*count=*/5) + ". Use \"help " +
+GetCommandName() + "\" to find out more.")
+.str());
   }
   error_msg.append("\n");
   result.AppendRawError(error_msg.c_str());
 }
 
+std::string CommandObjectMultiword::GetTopSubcommands(int count) {
+  if (m_subcommand_dict.empty())
+return "";
+  std::string buffer = "{";
+  CommandMap::iterator pos;
+  for (pos = m_subcommand_dict.begin();
+   pos != m_subcommand_dict.end() && count > 0; ++pos, --count) {
+buffer.append("'");
+buffer.append(pos->first);
+buffer.append("',");
+  }
+  buffer.append("...}");

oontvoo wrote:

done

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


[Lldb-commits] [lldb] [LLDB]Provide clearer error message for invalid commands. (PR #111891)

2024-10-11 Thread Vy Nguyen via lldb-commits

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

>From 4493bf07c8b18dac39a2a421f97fa34cd15a6031 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Thu, 10 Oct 2024 14:48:08 -0400
Subject: [PATCH 1/2] [LLDB]Provide clearer error message for invalid commands.

Sometimes users (esp. gdb-longtime users) accidentally use GDB syntax, such as 
`breakpoint foo`, and they would get an error message from LLDB saying simply 
`Invalid command "breakpoint foo"`, which is not very helpful.
This change provides additional suggestions to help correcting the mistake.
---
 .../lldb/Interpreter/CommandObjectMultiword.h |  2 +
 .../Commands/CommandObjectMultiword.cpp   | 42 ++-
 .../Commands/command-breakpoint-col.test  |  2 +
 3 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h 
b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
index bceb7f0e51edb6..cee118c3f454b5 100644
--- a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
+++ b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
@@ -70,6 +70,8 @@ class CommandObjectMultiword : public CommandObject {
 return m_subcommand_dict;
   }
 
+  std::string GetTopSubcommands(int count);
+
   CommandObject::CommandMap m_subcommand_dict;
   bool m_can_be_removed;
 };
diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp 
b/lldb/source/Commands/CommandObjectMultiword.cpp
index 4efa5652a71703..f7bb58187895b4 100644
--- a/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -194,28 +194,50 @@ void CommandObjectMultiword::Execute(const char 
*args_string,
 
   std::string error_msg;
   const size_t num_subcmd_matches = matches.GetSize();
-  if (num_subcmd_matches > 0)
+  if (num_subcmd_matches > 0) {
 error_msg.assign("ambiguous command ");
-  else
-error_msg.assign("invalid command ");
-
-  error_msg.append("'");
-  error_msg.append(std::string(GetCommandName()));
-  error_msg.append(" ");
-  error_msg.append(std::string(sub_command));
-  error_msg.append("'.");
+error_msg.append("'");
+error_msg.append(std::string(GetCommandName()));
+error_msg.append(" ");
+error_msg.append(std::string(sub_command));
+error_msg.append("'.");
 
-  if (num_subcmd_matches > 0) {
 error_msg.append(" Possible completions:");
 for (const std::string &match : matches) {
   error_msg.append("\n\t");
   error_msg.append(match);
 }
+  } else {
+// Rather than simply complaining about the invalid (sub) command,
+// try to offer some alternatives.
+// This is especially useful for cases where the user types something
+// seamingly trivial, such as `breakpoint foo`.
+error_msg.assign(
+llvm::Twine("'" + sub_command + "' is not a valid subcommand of \"" +
+GetCommandName() + "\". Valid subcommands are " +
+GetTopSubcommands(/*count=*/5) + ". Use \"help " +
+GetCommandName() + "\" to find out more.")
+.str());
   }
   error_msg.append("\n");
   result.AppendRawError(error_msg.c_str());
 }
 
+std::string CommandObjectMultiword::GetTopSubcommands(int count) {
+  if (m_subcommand_dict.empty())
+return "";
+  std::string buffer = "{";
+  CommandMap::iterator pos;
+  for (pos = m_subcommand_dict.begin();
+   pos != m_subcommand_dict.end() && count > 0; ++pos, --count) {
+buffer.append("'");
+buffer.append(pos->first);
+buffer.append("',");
+  }
+  buffer.append("...}");
+  return buffer;
+}
+
 void CommandObjectMultiword::GenerateHelpText(Stream &output_stream) {
   // First time through here, generate the help text for the object and push it
   // to the return result object as well
diff --git a/lldb/test/Shell/Commands/command-breakpoint-col.test 
b/lldb/test/Shell/Commands/command-breakpoint-col.test
index 65c1e220794303..fecb773d2b4c66 100644
--- a/lldb/test/Shell/Commands/command-breakpoint-col.test
+++ b/lldb/test/Shell/Commands/command-breakpoint-col.test
@@ -3,8 +3,10 @@
 # RUN: %clang_host -g -O0 %S/Inputs/main.c -o %t.out
 # RUN: %lldb -b -o 'help breakpoint set' -o 'breakpoint set -f main.c -l 2 -u 
21' %t.out | FileCheck %s --check-prefix HELP --check-prefix CHECK
 # RUN: %lldb -b -o 'help _regexp-break' -o 'b main.c:2:21' %t.out | FileCheck 
%s --check-prefix HELP-REGEX --check-prefix CHECK
+# RUN: not %lldb -b -o 'breakpoint foo' %t.out -o exit 2>&1 | FileCheck %s 
--check-prefix ERROR-MSG
 # HELP: -u  ( --column  )
 # HELP: Specifies the column number on which to set this breakpoint.
 # HELP-REGEX: _regexp-break ::
 # HELP-REGEX: main.c:12:21{{.*}}Break at line 12 and column 21 of main.c
 # CHECK: at main.c:2:21
+# ERROR-MSG: 'foo' is not a valid subcommand of "breakpoint". Valid 
subcommands are {'clear','command','delete','disable','enable',...}. Use "help 
breakpoint" to find out more.

>From 8dfb266f7eed943f7d9c4bd00e09ef86ae1c5d6e Mon

[Lldb-commits] [lldb] [LLDB]Provide clearer error message for invalid commands. (PR #111891)

2024-10-11 Thread Vy Nguyen via lldb-commits


@@ -194,28 +194,50 @@ void CommandObjectMultiword::Execute(const char 
*args_string,
 
   std::string error_msg;
   const size_t num_subcmd_matches = matches.GetSize();
-  if (num_subcmd_matches > 0)
+  if (num_subcmd_matches > 0) {
 error_msg.assign("ambiguous command ");
-  else
-error_msg.assign("invalid command ");
-
-  error_msg.append("'");
-  error_msg.append(std::string(GetCommandName()));
-  error_msg.append(" ");
-  error_msg.append(std::string(sub_command));
-  error_msg.append("'.");
+error_msg.append("'");
+error_msg.append(std::string(GetCommandName()));
+error_msg.append(" ");
+error_msg.append(std::string(sub_command));
+error_msg.append("'.");
 
-  if (num_subcmd_matches > 0) {
 error_msg.append(" Possible completions:");
 for (const std::string &match : matches) {
   error_msg.append("\n\t");
   error_msg.append(match);
 }
+  } else {
+// Rather than simply complaining about the invalid (sub) command,
+// try to offer some alternatives.

oontvoo wrote:

done

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


[Lldb-commits] [lldb] [LLDB]Provide clearer error message for invalid commands. (PR #111891)

2024-10-10 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo created 
https://github.com/llvm/llvm-project/pull/111891

Sometimes users (esp. gdb-longtime users) accidentally use GDB syntax, such as 
`breakpoint foo`, and they would get an error message from LLDB saying simply 
`Invalid command "breakpoint foo"`, which is not very helpful. 

This change provides additional suggestions to help correcting the mistake.

>From 70ead3e5d767fa074bcff7e383718c61c0b38612 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Thu, 10 Oct 2024 14:48:08 -0400
Subject: [PATCH] [LLDB]Provide clearer error message for invalid commands.

Sometimes users (esp. gdb-longtime users) accidentally use GDB syntax, such as 
`breakpoint foo`, and they would get an error message from LLDB saying simple 
`Invalid command "breakpoint foo"`, which is not very helpful.
This change provides additional suggestions to help correcting the mistake.
---
 .../lldb/Interpreter/CommandObjectMultiword.h |  2 +
 .../Commands/CommandObjectMultiword.cpp   | 42 ++-
 .../Commands/command-breakpoint-col.test  |  2 +
 3 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h 
b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
index bceb7f0e51edb6..cee118c3f454b5 100644
--- a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
+++ b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
@@ -70,6 +70,8 @@ class CommandObjectMultiword : public CommandObject {
 return m_subcommand_dict;
   }
 
+  std::string GetTopSubcommands(int count);
+
   CommandObject::CommandMap m_subcommand_dict;
   bool m_can_be_removed;
 };
diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp 
b/lldb/source/Commands/CommandObjectMultiword.cpp
index 4efa5652a71703..f7bb58187895b4 100644
--- a/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -194,28 +194,50 @@ void CommandObjectMultiword::Execute(const char 
*args_string,
 
   std::string error_msg;
   const size_t num_subcmd_matches = matches.GetSize();
-  if (num_subcmd_matches > 0)
+  if (num_subcmd_matches > 0) {
 error_msg.assign("ambiguous command ");
-  else
-error_msg.assign("invalid command ");
-
-  error_msg.append("'");
-  error_msg.append(std::string(GetCommandName()));
-  error_msg.append(" ");
-  error_msg.append(std::string(sub_command));
-  error_msg.append("'.");
+error_msg.append("'");
+error_msg.append(std::string(GetCommandName()));
+error_msg.append(" ");
+error_msg.append(std::string(sub_command));
+error_msg.append("'.");
 
-  if (num_subcmd_matches > 0) {
 error_msg.append(" Possible completions:");
 for (const std::string &match : matches) {
   error_msg.append("\n\t");
   error_msg.append(match);
 }
+  } else {
+// Rather than simply complaining about the invalid (sub) command,
+// try to offer some alternatives.
+// This is especially useful for cases where the user types something
+// seamingly trivial, such as `breakpoint foo`.
+error_msg.assign(
+llvm::Twine("'" + sub_command + "' is not a valid subcommand of \"" +
+GetCommandName() + "\". Valid subcommands are " +
+GetTopSubcommands(/*count=*/5) + ". Use \"help " +
+GetCommandName() + "\" to find out more.")
+.str());
   }
   error_msg.append("\n");
   result.AppendRawError(error_msg.c_str());
 }
 
+std::string CommandObjectMultiword::GetTopSubcommands(int count) {
+  if (m_subcommand_dict.empty())
+return "";
+  std::string buffer = "{";
+  CommandMap::iterator pos;
+  for (pos = m_subcommand_dict.begin();
+   pos != m_subcommand_dict.end() && count > 0; ++pos, --count) {
+buffer.append("'");
+buffer.append(pos->first);
+buffer.append("',");
+  }
+  buffer.append("...}");
+  return buffer;
+}
+
 void CommandObjectMultiword::GenerateHelpText(Stream &output_stream) {
   // First time through here, generate the help text for the object and push it
   // to the return result object as well
diff --git a/lldb/test/Shell/Commands/command-breakpoint-col.test 
b/lldb/test/Shell/Commands/command-breakpoint-col.test
index 65c1e220794303..fecb773d2b4c66 100644
--- a/lldb/test/Shell/Commands/command-breakpoint-col.test
+++ b/lldb/test/Shell/Commands/command-breakpoint-col.test
@@ -3,8 +3,10 @@
 # RUN: %clang_host -g -O0 %S/Inputs/main.c -o %t.out
 # RUN: %lldb -b -o 'help breakpoint set' -o 'breakpoint set -f main.c -l 2 -u 
21' %t.out | FileCheck %s --check-prefix HELP --check-prefix CHECK
 # RUN: %lldb -b -o 'help _regexp-break' -o 'b main.c:2:21' %t.out | FileCheck 
%s --check-prefix HELP-REGEX --check-prefix CHECK
+# RUN: not %lldb -b -o 'breakpoint foo' %t.out -o exit 2>&1 | FileCheck %s 
--check-prefix ERROR-MSG
 # HELP: -u  ( --column  )
 # HELP: Specifies the column number on which to set this breakpoint.
 # HELP-REGEX: _regexp-break ::
 # HELP-REGEX: main.c:12:21{{.*}}

[Lldb-commits] [lldb] [LLDB]Provide clearer error message for invalid commands. (PR #111891)

2024-10-11 Thread Vy Nguyen via lldb-commits

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

>From 4493bf07c8b18dac39a2a421f97fa34cd15a6031 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Thu, 10 Oct 2024 14:48:08 -0400
Subject: [PATCH] [LLDB]Provide clearer error message for invalid commands.

Sometimes users (esp. gdb-longtime users) accidentally use GDB syntax, such as 
`breakpoint foo`, and they would get an error message from LLDB saying simply 
`Invalid command "breakpoint foo"`, which is not very helpful.
This change provides additional suggestions to help correcting the mistake.
---
 .../lldb/Interpreter/CommandObjectMultiword.h |  2 +
 .../Commands/CommandObjectMultiword.cpp   | 42 ++-
 .../Commands/command-breakpoint-col.test  |  2 +
 3 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h 
b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
index bceb7f0e51edb6..cee118c3f454b5 100644
--- a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
+++ b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
@@ -70,6 +70,8 @@ class CommandObjectMultiword : public CommandObject {
 return m_subcommand_dict;
   }
 
+  std::string GetTopSubcommands(int count);
+
   CommandObject::CommandMap m_subcommand_dict;
   bool m_can_be_removed;
 };
diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp 
b/lldb/source/Commands/CommandObjectMultiword.cpp
index 4efa5652a71703..f7bb58187895b4 100644
--- a/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -194,28 +194,50 @@ void CommandObjectMultiword::Execute(const char 
*args_string,
 
   std::string error_msg;
   const size_t num_subcmd_matches = matches.GetSize();
-  if (num_subcmd_matches > 0)
+  if (num_subcmd_matches > 0) {
 error_msg.assign("ambiguous command ");
-  else
-error_msg.assign("invalid command ");
-
-  error_msg.append("'");
-  error_msg.append(std::string(GetCommandName()));
-  error_msg.append(" ");
-  error_msg.append(std::string(sub_command));
-  error_msg.append("'.");
+error_msg.append("'");
+error_msg.append(std::string(GetCommandName()));
+error_msg.append(" ");
+error_msg.append(std::string(sub_command));
+error_msg.append("'.");
 
-  if (num_subcmd_matches > 0) {
 error_msg.append(" Possible completions:");
 for (const std::string &match : matches) {
   error_msg.append("\n\t");
   error_msg.append(match);
 }
+  } else {
+// Rather than simply complaining about the invalid (sub) command,
+// try to offer some alternatives.
+// This is especially useful for cases where the user types something
+// seamingly trivial, such as `breakpoint foo`.
+error_msg.assign(
+llvm::Twine("'" + sub_command + "' is not a valid subcommand of \"" +
+GetCommandName() + "\". Valid subcommands are " +
+GetTopSubcommands(/*count=*/5) + ". Use \"help " +
+GetCommandName() + "\" to find out more.")
+.str());
   }
   error_msg.append("\n");
   result.AppendRawError(error_msg.c_str());
 }
 
+std::string CommandObjectMultiword::GetTopSubcommands(int count) {
+  if (m_subcommand_dict.empty())
+return "";
+  std::string buffer = "{";
+  CommandMap::iterator pos;
+  for (pos = m_subcommand_dict.begin();
+   pos != m_subcommand_dict.end() && count > 0; ++pos, --count) {
+buffer.append("'");
+buffer.append(pos->first);
+buffer.append("',");
+  }
+  buffer.append("...}");
+  return buffer;
+}
+
 void CommandObjectMultiword::GenerateHelpText(Stream &output_stream) {
   // First time through here, generate the help text for the object and push it
   // to the return result object as well
diff --git a/lldb/test/Shell/Commands/command-breakpoint-col.test 
b/lldb/test/Shell/Commands/command-breakpoint-col.test
index 65c1e220794303..fecb773d2b4c66 100644
--- a/lldb/test/Shell/Commands/command-breakpoint-col.test
+++ b/lldb/test/Shell/Commands/command-breakpoint-col.test
@@ -3,8 +3,10 @@
 # RUN: %clang_host -g -O0 %S/Inputs/main.c -o %t.out
 # RUN: %lldb -b -o 'help breakpoint set' -o 'breakpoint set -f main.c -l 2 -u 
21' %t.out | FileCheck %s --check-prefix HELP --check-prefix CHECK
 # RUN: %lldb -b -o 'help _regexp-break' -o 'b main.c:2:21' %t.out | FileCheck 
%s --check-prefix HELP-REGEX --check-prefix CHECK
+# RUN: not %lldb -b -o 'breakpoint foo' %t.out -o exit 2>&1 | FileCheck %s 
--check-prefix ERROR-MSG
 # HELP: -u  ( --column  )
 # HELP: Specifies the column number on which to set this breakpoint.
 # HELP-REGEX: _regexp-break ::
 # HELP-REGEX: main.c:12:21{{.*}}Break at line 12 and column 21 of main.c
 # CHECK: at main.c:2:21
+# ERROR-MSG: 'foo' is not a valid subcommand of "breakpoint". Valid 
subcommands are {'clear','command','delete','disable','enable',...}. Use "help 
breakpoint" to find out more.

___
lldb-c

[Lldb-commits] [lldb] [LLDB]Provide clearer error message for invalid commands. (PR #111891)

2024-10-11 Thread Vy Nguyen via lldb-commits


@@ -70,6 +70,8 @@ class CommandObjectMultiword : public CommandObject {
 return m_subcommand_dict;
   }
 
+  std::string GetTopSubcommands(int count);

oontvoo wrote:

Will rename this to Jim's suggestion.
I like Pavel's idea of having this returning the popular ones, but not sure how 
we'd determine that here (other than hard-coding the list somewhere)

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


[Lldb-commits] [lldb] [LLDB]Provide clearer error message for invalid commands. (PR #111891)

2024-10-14 Thread Vy Nguyen via lldb-commits


@@ -0,0 +1,8 @@
+# UNSUPPORTED: system-windows
+#
+# RUN: %clang_host -g -O0 %S/Inputs/main.c -o %t.out
+# RUN: not %lldb -b -o 'breakpoint foo' %t.out -o exit 2>&1 | FileCheck %s 
--check-prefix BP-MSG
+# RUN: not %lldb -b -o 'watchpoint set foo' %t.out -o exit 2>&1 | FileCheck %s 
--check-prefix WP-MSG
+# CHECK: at main.c:2:21
+# BP-MSG: 'foo' is not a valid subcommand of "breakpoint". Valid subcommands 
are: clear, command, delete, disable, enable, and others. Use "help breakpoint" 
to find out more.

oontvoo wrote:

done

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


[Lldb-commits] [lldb] [LLDB]Provide clearer error message for invalid commands. (PR #111891)

2024-10-14 Thread Vy Nguyen via lldb-commits


@@ -194,28 +194,54 @@ void CommandObjectMultiword::Execute(const char 
*args_string,
 
   std::string error_msg;
   const size_t num_subcmd_matches = matches.GetSize();
-  if (num_subcmd_matches > 0)
+  if (num_subcmd_matches > 0) {
 error_msg.assign("ambiguous command ");
-  else
-error_msg.assign("invalid command ");
-
-  error_msg.append("'");
-  error_msg.append(std::string(GetCommandName()));
-  error_msg.append(" ");
-  error_msg.append(std::string(sub_command));
-  error_msg.append("'.");
+error_msg.append("'");
+error_msg.append(std::string(GetCommandName()));
+error_msg.append(" ");
+error_msg.append(std::string(sub_command));
+error_msg.append("'.");
 
-  if (num_subcmd_matches > 0) {
 error_msg.append(" Possible completions:");
 for (const std::string &match : matches) {
   error_msg.append("\n\t");
   error_msg.append(match);
 }
+  } else {
+// Try to offer some alternatives to help correct the command.
+error_msg.assign(
+llvm::Twine("'" + sub_command + "' is not a valid subcommand of \"" +
+GetCommandName() + "\"." + GetSubcommandsHintText() +
+" Use \"help " + GetCommandName() + "\" to find out more.")
+.str());
   }
   error_msg.append("\n");
   result.AppendRawError(error_msg.c_str());
 }
 
+std::string CommandObjectMultiword::GetSubcommandsHintText() {
+  if (m_subcommand_dict.empty())
+return "";
+  const size_t maxCount = 5;
+  size_t i = 0;
+  std::string buffer = " Valid subcommand";
+  buffer.append(m_subcommand_dict.size() > 1 ? "s are:" : "is");

oontvoo wrote:

> You're missing a space before "is"
Done.

> The output will also be garbled for the case of zero subcommands
Which output? the error msg as a whole or just this function's output?

unless i'm missing something, if there are zero subcommands, the function would 
have returned "" on line 223, which means the error message would have been 
something like `"foo" is not a valid subcommand of "breakpoint". Use "help 
breakpoint" to find out more.` (ie., there will be no suggestions on 
subcommands).



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


[Lldb-commits] [lldb] [LLDB]Provide clearer error message for invalid commands. (PR #111891)

2024-10-14 Thread Vy Nguyen via lldb-commits

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

>From 4493bf07c8b18dac39a2a421f97fa34cd15a6031 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Thu, 10 Oct 2024 14:48:08 -0400
Subject: [PATCH 1/4] [LLDB]Provide clearer error message for invalid commands.

Sometimes users (esp. gdb-longtime users) accidentally use GDB syntax, such as 
`breakpoint foo`, and they would get an error message from LLDB saying simply 
`Invalid command "breakpoint foo"`, which is not very helpful.
This change provides additional suggestions to help correcting the mistake.
---
 .../lldb/Interpreter/CommandObjectMultiword.h |  2 +
 .../Commands/CommandObjectMultiword.cpp   | 42 ++-
 .../Commands/command-breakpoint-col.test  |  2 +
 3 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h 
b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
index bceb7f0e51edb6..cee118c3f454b5 100644
--- a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
+++ b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
@@ -70,6 +70,8 @@ class CommandObjectMultiword : public CommandObject {
 return m_subcommand_dict;
   }
 
+  std::string GetTopSubcommands(int count);
+
   CommandObject::CommandMap m_subcommand_dict;
   bool m_can_be_removed;
 };
diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp 
b/lldb/source/Commands/CommandObjectMultiword.cpp
index 4efa5652a71703..f7bb58187895b4 100644
--- a/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -194,28 +194,50 @@ void CommandObjectMultiword::Execute(const char 
*args_string,
 
   std::string error_msg;
   const size_t num_subcmd_matches = matches.GetSize();
-  if (num_subcmd_matches > 0)
+  if (num_subcmd_matches > 0) {
 error_msg.assign("ambiguous command ");
-  else
-error_msg.assign("invalid command ");
-
-  error_msg.append("'");
-  error_msg.append(std::string(GetCommandName()));
-  error_msg.append(" ");
-  error_msg.append(std::string(sub_command));
-  error_msg.append("'.");
+error_msg.append("'");
+error_msg.append(std::string(GetCommandName()));
+error_msg.append(" ");
+error_msg.append(std::string(sub_command));
+error_msg.append("'.");
 
-  if (num_subcmd_matches > 0) {
 error_msg.append(" Possible completions:");
 for (const std::string &match : matches) {
   error_msg.append("\n\t");
   error_msg.append(match);
 }
+  } else {
+// Rather than simply complaining about the invalid (sub) command,
+// try to offer some alternatives.
+// This is especially useful for cases where the user types something
+// seamingly trivial, such as `breakpoint foo`.
+error_msg.assign(
+llvm::Twine("'" + sub_command + "' is not a valid subcommand of \"" +
+GetCommandName() + "\". Valid subcommands are " +
+GetTopSubcommands(/*count=*/5) + ". Use \"help " +
+GetCommandName() + "\" to find out more.")
+.str());
   }
   error_msg.append("\n");
   result.AppendRawError(error_msg.c_str());
 }
 
+std::string CommandObjectMultiword::GetTopSubcommands(int count) {
+  if (m_subcommand_dict.empty())
+return "";
+  std::string buffer = "{";
+  CommandMap::iterator pos;
+  for (pos = m_subcommand_dict.begin();
+   pos != m_subcommand_dict.end() && count > 0; ++pos, --count) {
+buffer.append("'");
+buffer.append(pos->first);
+buffer.append("',");
+  }
+  buffer.append("...}");
+  return buffer;
+}
+
 void CommandObjectMultiword::GenerateHelpText(Stream &output_stream) {
   // First time through here, generate the help text for the object and push it
   // to the return result object as well
diff --git a/lldb/test/Shell/Commands/command-breakpoint-col.test 
b/lldb/test/Shell/Commands/command-breakpoint-col.test
index 65c1e220794303..fecb773d2b4c66 100644
--- a/lldb/test/Shell/Commands/command-breakpoint-col.test
+++ b/lldb/test/Shell/Commands/command-breakpoint-col.test
@@ -3,8 +3,10 @@
 # RUN: %clang_host -g -O0 %S/Inputs/main.c -o %t.out
 # RUN: %lldb -b -o 'help breakpoint set' -o 'breakpoint set -f main.c -l 2 -u 
21' %t.out | FileCheck %s --check-prefix HELP --check-prefix CHECK
 # RUN: %lldb -b -o 'help _regexp-break' -o 'b main.c:2:21' %t.out | FileCheck 
%s --check-prefix HELP-REGEX --check-prefix CHECK
+# RUN: not %lldb -b -o 'breakpoint foo' %t.out -o exit 2>&1 | FileCheck %s 
--check-prefix ERROR-MSG
 # HELP: -u  ( --column  )
 # HELP: Specifies the column number on which to set this breakpoint.
 # HELP-REGEX: _regexp-break ::
 # HELP-REGEX: main.c:12:21{{.*}}Break at line 12 and column 21 of main.c
 # CHECK: at main.c:2:21
+# ERROR-MSG: 'foo' is not a valid subcommand of "breakpoint". Valid 
subcommands are {'clear','command','delete','disable','enable',...}. Use "help 
breakpoint" to find out more.

>From 8dfb266f7eed943f7d9c4bd00e09ef86ae1c5d6e Mon

[Lldb-commits] [lldb] [LLDB]Provide clearer error message for invalid commands. (PR #111891)

2024-10-14 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] [LLDB]Provide clearer error message for invalid commands. (PR #111891)

2024-10-14 Thread Vy Nguyen via lldb-commits


@@ -70,6 +70,8 @@ class CommandObjectMultiword : public CommandObject {
 return m_subcommand_dict;
   }
 
+  std::string GetTopSubcommands(int count);

oontvoo wrote:

P.S: Actually, didn't end up renaming it Jim's suggestion, but to something 
else, hopefully less confusing, which is "GetSubcommandsHint" - whether it 
returns a top 5 sub-commands or whatever order is transparent to caller.
(Then we can change the content in later patch as needed)

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


[Lldb-commits] [lldb] [llvm] [lldb]Implement LLDB Telemetry (PR #98528)

2024-09-17 Thread Vy Nguyen via lldb-commits


@@ -682,17 +683,51 @@ PacketStatus DAP::GetNextObject(llvm::json::Object 
&object) {
 }
 
 bool DAP::HandleObject(const llvm::json::Object &object) {
+  auto start_time = std::chrono::steady_clock::now();
   const auto packet_type = GetString(object, "type");
   if (packet_type == "request") {
 const auto command = GetString(object, "command");
 auto handler_pos = request_handlers.find(std::string(command));
+lldb::SBStructuredData telemetry_entry;
+
+// There does not seem to be a direct way to construct an SBStructuredData.
+// So we first create a json::Array object,
+// then we serialize it to a string,
+// and finally call SBStructuredData::SetFromJSON(string).
+//
+// TODO: This seems unnecessarily complex. Ideally, we should be able to

oontvoo wrote:

@labath Hi Pavel, do you have any suggestion for avoiding this round-about?

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


[Lldb-commits] [lldb] [llvm] [lldb]Implement LLDB Telemetry (PR #98528)

2024-09-24 Thread Vy Nguyen via lldb-commits


@@ -682,17 +683,51 @@ PacketStatus DAP::GetNextObject(llvm::json::Object 
&object) {
 }
 
 bool DAP::HandleObject(const llvm::json::Object &object) {
+  auto start_time = std::chrono::steady_clock::now();
   const auto packet_type = GetString(object, "type");
   if (packet_type == "request") {
 const auto command = GetString(object, "command");
 auto handler_pos = request_handlers.find(std::string(command));
+lldb::SBStructuredData telemetry_entry;
+
+// There does not seem to be a direct way to construct an SBStructuredData.
+// So we first create a json::Array object,
+// then we serialize it to a string,
+// and finally call SBStructuredData::SetFromJSON(string).
+//
+// TODO: This seems unnecessarily complex. Ideally, we should be able to

oontvoo wrote:

Thanks - i'll resolve this for now. we can revisit this later

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


[Lldb-commits] [lldb] [llvm] [lldb]Implement LLDB Telemetry (PR #98528)

2024-09-24 Thread Vy Nguyen via lldb-commits


@@ -0,0 +1,619 @@
+
+//===-- Telemetry.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/Telemetry.h"
+
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBProcess.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Statistics.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/UUID.h"
+#include "lldb/Version/Version.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/LineIterator.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/RandomNumberGenerator.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+#ifdef HAS_VENDOR_TELEMETRY_PLUGINS
+// TODO: could make this path a build-variable rather than hard-coded
+#include "lldb/Core/VendorTelemetryPlugin.h"
+
+// This must include definitions for these functions
+extern void ApplyVendorSpecificConfigs(
+llvm::telemetry::TelemetryConfig *config) /* __attribute__((weak))*/;
+extern std::shared_ptr SanitizeSensitiveFields(
+const llvm::telemetry::TelemetryInfo *entry) /*__attribute__((weak))*/;
+extern std::shared_ptr
+CreateVendorSpecificTelemeter(
+llvm::telemetry::TelemetryConfig *config) /*__attribute__((weak))*/;
+#endif
+
+namespace lldb_private {
+
+static std::string GetDuration(const TelemetryEventStats &stats) {
+  if (stats.m_end.has_value())
+return std::to_string((stats.m_end.value() - stats.m_start).count()) +
+   "(nanosec)";
+  return "";
+}
+
+std::string DebuggerTelemetryInfo::ToString() const {
+  std::string duration_desc =
+  (exit_description.has_value() ? "  lldb session duration: "
+: "  lldb startup duration: ") +
+  std::to_string((stats.m_end.value() - stats.m_start).count()) +
+  "(nanosec)\n";
+
+  return TelemetryInfo::ToString() + "\n" + ("[DebuggerTelemetryInfo]\n") +
+ ("  username: " + username + "\n") +
+ ("  lldb_git_sha: " + lldb_git_sha + "\n") +
+ ("  lldb_path: " + lldb_path + "\n") + ("  cwd: " + cwd + "\n") +
+ duration_desc + "\n";
+}
+
+std::string ClientTelemetryInfo::ToString() const {
+  return TelemetryInfo::ToString() + "\n" + ("[DapRequestInfoEntry]\n") +
+ ("  request_name: " + request_name + "\n") +
+ ("  request_duration: " + GetDuration(stats) + "(nanosec)\n") +
+ ("  error_msg: " + error_msg + "\n");
+}
+
+std::string TargetTelemetryInfo::ToString() const {
+  std::string exit_or_load_desc;
+  if (exit_description.has_value()) {
+// If this entry was emitted for an exit
+exit_or_load_desc = "  process_duration: " + GetDuration(stats) +
+"  exit: " + exit_description->ToString() + "\n";
+  } else {
+// This was emitted for a load event.
+// See if it was the start-load or end-load entry
+if (stats.m_end.has_value()) {
+  exit_or_load_desc =
+  "  startup_init_duration: " + GetDuration(stats) + "\n";
+} else {
+  exit_or_load_desc = " startup_init_start\n";
+}
+  }
+  return TelemetryInfo::ToString() + "\n" + ("[TargetTelemetryInfo]\n") +
+ ("  target_uuid: " + target_uuid + "\n") +
+ ("  file_format: " + file_format + "\n") +
+ ("  binary_path: " + binary_path + "\n") +
+ ("  binary_size: " + std::to_string(binary_size) + "\n") +
+ exit_or_load_desc;
+}
+
+static std::string StatusToString(CommandReturnObject *result) {
+  std::string msg;
+  switch (result->GetStatus()) {
+  case lldb::eReturnStatusInvalid:
+msg = "invalid";
+break;
+  case lldb::eReturnStatusSuccessFinishNoResult:
+msg = "success_finish_no_result";
+break;
+  case lldb::eReturnStatusSuccessFinishResult:
+msg = "success_finish_result";
+break;
+  case lldb::eReturnStatusSuccessContinuingNoResult:
+msg = "success_continuing_no_result";
+break;
+  case lldb::eReturnStatusSuccessContinuingResult:
+msg = "success_continuing_result";
+break;
+  case lldb::eReturnStatusStarted:
+msg = "started";
+break;
+  case lldb::eReturnStatusFailed:
+msg = "failed";
+break;
+  case lldb::eReturnStatusQuit:
+  

[Lldb-commits] [lldb] [llvm] [lldb]Implement LLDB Telemetry (PR #98528)

2024-09-24 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [lldb]Implement LLDB Telemetry (PR #98528)

2024-12-09 Thread Vy Nguyen via lldb-commits


@@ -257,8 +257,8 @@ enum StopReason {
 };
 
 /// Command Return Status Types.
-enum ReturnStatus {
-  eReturnStatusInvalid,
+enum ReturnStatus : int {

oontvoo wrote:

This is needed to serialize the ReturnStatus from a command.

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


[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2024-12-26 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2024-12-26 Thread Vy Nguyen via lldb-commits

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

>From b7216d7c3edd5974d84612586fbabdef19037387 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Thu, 26 Dec 2024 20:50:40 -0500
Subject: [PATCH] Implement LLDB Telemetry (Part 1)

This contains only the concrete implementation of the framework to be used but 
no usages yet.

This is a subset of PR/98528.

I plan to send a few follow-up patches:
part2 : includes changes in the plugin-manager to set up the plugin stuff (ie., 
how to create a default vs vendor impl)
part3 (all of the following can be done in parallel):
* part 3_a: define DebuggerTelemetryInfo and related methods to collect data 
about debugger startup/exit
* part 3_b: define TargetTelemetryInfo and related methods to collect data 
about debug target(s)
* part 3_c: define CommandTelemetryInfo and related methods to collect data 
about debug-commands
* part 3_d: define ClientTelemtryInfo and related methods to collect data about 
lldb-dap/any other client
---
 lldb/include/lldb/Core/Telemetry.h| 101 ++
 lldb/include/lldb/lldb-enumerations.h |   4 +-
 lldb/source/Core/CMakeLists.txt   |   2 +
 lldb/source/Core/Telemetry.cpp|  92 +++
 lldb/test/CMakeLists.txt  |   3 +
 5 files changed, 200 insertions(+), 2 deletions(-)
 create mode 100644 lldb/include/lldb/Core/Telemetry.h
 create mode 100644 lldb/source/Core/Telemetry.cpp

diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
new file mode 100644
index 000..882511efd804d23
--- /dev/null
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -0,0 +1,101 @@
+//===-- Telemetry.h --*- C++
+//-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/JSON.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+namespace lldb_private {
+
+using llvm::telemetry::Destination;
+using llvm::telemetry::KindType;
+using llvm::telemetry::Serializer;
+using llvm::telemetry::TelemetryInfo;
+
+struct LldbEntryKind : public ::llvm::telemetry::EntryKind {
+  static const KindType BaseInfo = 0b11000;
+};
+
+/// Defines a convenient type for timestamp of various events.
+/// This is used by the EventStats below.
+using SteadyTimePoint = std::chrono::time_point;
+
+/// Various time (and possibly memory) statistics of an event.
+struct EventStats {
+  // REQUIRED: Start time of an event
+  SteadyTimePoint start;
+  // OPTIONAL: End time of an event - may be empty if not meaningful.
+  std::optional end;
+  // TBD: could add some memory stats here too?
+
+  EventStats() = default;
+  EventStats(SteadyTimePoint start) : start(start) {}
+  EventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : start(start), end(end) {}
+};
+
+/// Describes the exit signal of an event.
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct LldbBaseTelemetryInfo : public TelemetryInfo {
+  EventStats stats;
+
+  std::optional exit_desc;
+
+  Debugger *debugger;
+
+  // For dyn_cast, isa, etc operations.
+  KindType getKind() const override { return LldbEntryKind::BaseInfo; }
+
+  static bool classof(const TelemetryInfo *t) {
+// Subclasses of this is also acceptable.
+return (t->getKind() & LldbEntryKind::BaseInfo) == LldbEntryKind::BaseInfo;
+  }
+
+  void serialize(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 {
+public:
+  TelemetryManager(std::unique_ptr config);
+
+  llvm::Error dispatch(TelemetryInfo *entry) override;
+
+  void addDestination(std::unique_ptr destination) override;
+
+private:
+  std::unique_ptr m_config;
+  const std::string m_session_uuid;
+  std::vector> m_destinations;
+};
+
+} // namespace lldb_private
+#endif // LLDB_CORE_TELEMETRY_H
diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 0094fcd596fdf70..f63e446b6042f62 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -257,8 +257,8 @@ enum StopReason {
 };
 
 /// Command Return Status Types.
-enum ReturnStatus {
-  eReturnStatusInvalid,
+enum ReturnStatus : int {
+  eReturnStatusInvalid = 

[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2024-12-26 Thread Vy Nguyen via lldb-commits

oontvoo wrote:

(accidentally closed the PR - reopening now)

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


[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2024-12-26 Thread Vy Nguyen via lldb-commits


@@ -0,0 +1,95 @@
+
+//===-- Telemetry.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/Telemetry.h"

oontvoo wrote:

done

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


[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2024-12-26 Thread Vy Nguyen via lldb-commits

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

>From b7216d7c3edd5974d84612586fbabdef19037387 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Thu, 26 Dec 2024 20:50:40 -0500
Subject: [PATCH 1/2] Implement LLDB Telemetry (Part 1)

This contains only the concrete implementation of the framework to be used but 
no usages yet.

This is a subset of PR/98528.

I plan to send a few follow-up patches:
part2 : includes changes in the plugin-manager to set up the plugin stuff (ie., 
how to create a default vs vendor impl)
part3 (all of the following can be done in parallel):
* part 3_a: define DebuggerTelemetryInfo and related methods to collect data 
about debugger startup/exit
* part 3_b: define TargetTelemetryInfo and related methods to collect data 
about debug target(s)
* part 3_c: define CommandTelemetryInfo and related methods to collect data 
about debug-commands
* part 3_d: define ClientTelemtryInfo and related methods to collect data about 
lldb-dap/any other client
---
 lldb/include/lldb/Core/Telemetry.h| 101 ++
 lldb/include/lldb/lldb-enumerations.h |   4 +-
 lldb/source/Core/CMakeLists.txt   |   2 +
 lldb/source/Core/Telemetry.cpp|  92 +++
 lldb/test/CMakeLists.txt  |   3 +
 5 files changed, 200 insertions(+), 2 deletions(-)
 create mode 100644 lldb/include/lldb/Core/Telemetry.h
 create mode 100644 lldb/source/Core/Telemetry.cpp

diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
new file mode 100644
index 000..882511efd804d23
--- /dev/null
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -0,0 +1,101 @@
+//===-- Telemetry.h --*- C++
+//-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/JSON.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+namespace lldb_private {
+
+using llvm::telemetry::Destination;
+using llvm::telemetry::KindType;
+using llvm::telemetry::Serializer;
+using llvm::telemetry::TelemetryInfo;
+
+struct LldbEntryKind : public ::llvm::telemetry::EntryKind {
+  static const KindType BaseInfo = 0b11000;
+};
+
+/// Defines a convenient type for timestamp of various events.
+/// This is used by the EventStats below.
+using SteadyTimePoint = std::chrono::time_point;
+
+/// Various time (and possibly memory) statistics of an event.
+struct EventStats {
+  // REQUIRED: Start time of an event
+  SteadyTimePoint start;
+  // OPTIONAL: End time of an event - may be empty if not meaningful.
+  std::optional end;
+  // TBD: could add some memory stats here too?
+
+  EventStats() = default;
+  EventStats(SteadyTimePoint start) : start(start) {}
+  EventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : start(start), end(end) {}
+};
+
+/// Describes the exit signal of an event.
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct LldbBaseTelemetryInfo : public TelemetryInfo {
+  EventStats stats;
+
+  std::optional exit_desc;
+
+  Debugger *debugger;
+
+  // For dyn_cast, isa, etc operations.
+  KindType getKind() const override { return LldbEntryKind::BaseInfo; }
+
+  static bool classof(const TelemetryInfo *t) {
+// Subclasses of this is also acceptable.
+return (t->getKind() & LldbEntryKind::BaseInfo) == LldbEntryKind::BaseInfo;
+  }
+
+  void serialize(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 {
+public:
+  TelemetryManager(std::unique_ptr config);
+
+  llvm::Error dispatch(TelemetryInfo *entry) override;
+
+  void addDestination(std::unique_ptr destination) override;
+
+private:
+  std::unique_ptr m_config;
+  const std::string m_session_uuid;
+  std::vector> m_destinations;
+};
+
+} // namespace lldb_private
+#endif // LLDB_CORE_TELEMETRY_H
diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 0094fcd596fdf70..f63e446b6042f62 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -257,8 +257,8 @@ enum StopReason {
 };
 
 /// Command Return Status Types.
-enum ReturnStatus {
-  eReturnStatusInvalid,
+enum ReturnStatus : int {
+  eReturnStatusInvali

[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2025-02-04 Thread Vy Nguyen via lldb-commits

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

>From b7216d7c3edd5974d84612586fbabdef19037387 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Thu, 26 Dec 2024 20:50:40 -0500
Subject: [PATCH 1/2] Implement LLDB Telemetry (Part 1)

This contains only the concrete implementation of the framework to be used but 
no usages yet.

This is a subset of PR/98528.

I plan to send a few follow-up patches:
part2 : includes changes in the plugin-manager to set up the plugin stuff (ie., 
how to create a default vs vendor impl)
part3 (all of the following can be done in parallel):
* part 3_a: define DebuggerTelemetryInfo and related methods to collect data 
about debugger startup/exit
* part 3_b: define TargetTelemetryInfo and related methods to collect data 
about debug target(s)
* part 3_c: define CommandTelemetryInfo and related methods to collect data 
about debug-commands
* part 3_d: define ClientTelemtryInfo and related methods to collect data about 
lldb-dap/any other client
---
 lldb/include/lldb/Core/Telemetry.h| 101 ++
 lldb/include/lldb/lldb-enumerations.h |   4 +-
 lldb/source/Core/CMakeLists.txt   |   2 +
 lldb/source/Core/Telemetry.cpp|  92 +++
 lldb/test/CMakeLists.txt  |   3 +
 5 files changed, 200 insertions(+), 2 deletions(-)
 create mode 100644 lldb/include/lldb/Core/Telemetry.h
 create mode 100644 lldb/source/Core/Telemetry.cpp

diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
new file mode 100644
index 00..882511efd804d2
--- /dev/null
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -0,0 +1,101 @@
+//===-- Telemetry.h --*- C++
+//-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/JSON.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+namespace lldb_private {
+
+using llvm::telemetry::Destination;
+using llvm::telemetry::KindType;
+using llvm::telemetry::Serializer;
+using llvm::telemetry::TelemetryInfo;
+
+struct LldbEntryKind : public ::llvm::telemetry::EntryKind {
+  static const KindType BaseInfo = 0b11000;
+};
+
+/// Defines a convenient type for timestamp of various events.
+/// This is used by the EventStats below.
+using SteadyTimePoint = std::chrono::time_point;
+
+/// Various time (and possibly memory) statistics of an event.
+struct EventStats {
+  // REQUIRED: Start time of an event
+  SteadyTimePoint start;
+  // OPTIONAL: End time of an event - may be empty if not meaningful.
+  std::optional end;
+  // TBD: could add some memory stats here too?
+
+  EventStats() = default;
+  EventStats(SteadyTimePoint start) : start(start) {}
+  EventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : start(start), end(end) {}
+};
+
+/// Describes the exit signal of an event.
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct LldbBaseTelemetryInfo : public TelemetryInfo {
+  EventStats stats;
+
+  std::optional exit_desc;
+
+  Debugger *debugger;
+
+  // For dyn_cast, isa, etc operations.
+  KindType getKind() const override { return LldbEntryKind::BaseInfo; }
+
+  static bool classof(const TelemetryInfo *t) {
+// Subclasses of this is also acceptable.
+return (t->getKind() & LldbEntryKind::BaseInfo) == LldbEntryKind::BaseInfo;
+  }
+
+  void serialize(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 {
+public:
+  TelemetryManager(std::unique_ptr config);
+
+  llvm::Error dispatch(TelemetryInfo *entry) override;
+
+  void addDestination(std::unique_ptr destination) override;
+
+private:
+  std::unique_ptr m_config;
+  const std::string m_session_uuid;
+  std::vector> m_destinations;
+};
+
+} // namespace lldb_private
+#endif // LLDB_CORE_TELEMETRY_H
diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 0094fcd596fdf7..f63e446b6042f6 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -257,8 +257,8 @@ enum StopReason {
 };
 
 /// Command Return Status Types.
-enum ReturnStatus {
-  eReturnStatusInvalid,
+enum ReturnStatus : int {
+  eReturnStatusInvalid = 

[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2025-02-04 Thread Vy Nguyen via lldb-commits

oontvoo wrote:

@labath Hi, I've updated the patch to sync up with the changes from 
llvm::Telemetry. (Aslo addressed all the open-questions.) Please have another 
look when you can. Thanks!

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


[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2025-02-04 Thread Vy Nguyen via lldb-commits

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

>From b7216d7c3edd5974d84612586fbabdef19037387 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Thu, 26 Dec 2024 20:50:40 -0500
Subject: [PATCH 1/2] Implement LLDB Telemetry (Part 1)

This contains only the concrete implementation of the framework to be used but 
no usages yet.

This is a subset of PR/98528.

I plan to send a few follow-up patches:
part2 : includes changes in the plugin-manager to set up the plugin stuff (ie., 
how to create a default vs vendor impl)
part3 (all of the following can be done in parallel):
* part 3_a: define DebuggerTelemetryInfo and related methods to collect data 
about debugger startup/exit
* part 3_b: define TargetTelemetryInfo and related methods to collect data 
about debug target(s)
* part 3_c: define CommandTelemetryInfo and related methods to collect data 
about debug-commands
* part 3_d: define ClientTelemtryInfo and related methods to collect data about 
lldb-dap/any other client
---
 lldb/include/lldb/Core/Telemetry.h| 101 ++
 lldb/include/lldb/lldb-enumerations.h |   4 +-
 lldb/source/Core/CMakeLists.txt   |   2 +
 lldb/source/Core/Telemetry.cpp|  92 +++
 lldb/test/CMakeLists.txt  |   3 +
 5 files changed, 200 insertions(+), 2 deletions(-)
 create mode 100644 lldb/include/lldb/Core/Telemetry.h
 create mode 100644 lldb/source/Core/Telemetry.cpp

diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
new file mode 100644
index 000..882511efd804d23
--- /dev/null
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -0,0 +1,101 @@
+//===-- Telemetry.h --*- C++
+//-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/JSON.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+namespace lldb_private {
+
+using llvm::telemetry::Destination;
+using llvm::telemetry::KindType;
+using llvm::telemetry::Serializer;
+using llvm::telemetry::TelemetryInfo;
+
+struct LldbEntryKind : public ::llvm::telemetry::EntryKind {
+  static const KindType BaseInfo = 0b11000;
+};
+
+/// Defines a convenient type for timestamp of various events.
+/// This is used by the EventStats below.
+using SteadyTimePoint = std::chrono::time_point;
+
+/// Various time (and possibly memory) statistics of an event.
+struct EventStats {
+  // REQUIRED: Start time of an event
+  SteadyTimePoint start;
+  // OPTIONAL: End time of an event - may be empty if not meaningful.
+  std::optional end;
+  // TBD: could add some memory stats here too?
+
+  EventStats() = default;
+  EventStats(SteadyTimePoint start) : start(start) {}
+  EventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : start(start), end(end) {}
+};
+
+/// Describes the exit signal of an event.
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct LldbBaseTelemetryInfo : public TelemetryInfo {
+  EventStats stats;
+
+  std::optional exit_desc;
+
+  Debugger *debugger;
+
+  // For dyn_cast, isa, etc operations.
+  KindType getKind() const override { return LldbEntryKind::BaseInfo; }
+
+  static bool classof(const TelemetryInfo *t) {
+// Subclasses of this is also acceptable.
+return (t->getKind() & LldbEntryKind::BaseInfo) == LldbEntryKind::BaseInfo;
+  }
+
+  void serialize(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 {
+public:
+  TelemetryManager(std::unique_ptr config);
+
+  llvm::Error dispatch(TelemetryInfo *entry) override;
+
+  void addDestination(std::unique_ptr destination) override;
+
+private:
+  std::unique_ptr m_config;
+  const std::string m_session_uuid;
+  std::vector> m_destinations;
+};
+
+} // namespace lldb_private
+#endif // LLDB_CORE_TELEMETRY_H
diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 0094fcd596fdf70..f63e446b6042f62 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -257,8 +257,8 @@ enum StopReason {
 };
 
 /// Command Return Status Types.
-enum ReturnStatus {
-  eReturnStatusInvalid,
+enum ReturnStatus : int {
+  eReturnStatusInvali

[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2025-02-04 Thread Vy Nguyen via lldb-commits


@@ -0,0 +1,101 @@
+//===-- Telemetry.h --*- C++
+//-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/JSON.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+namespace lldb_private {
+
+using llvm::telemetry::Destination;
+using llvm::telemetry::KindType;
+using llvm::telemetry::Serializer;
+using llvm::telemetry::TelemetryInfo;
+
+struct LldbEntryKind : public ::llvm::telemetry::EntryKind {
+  static const KindType BaseInfo = 0b11000;
+};
+
+/// Defines a convenient type for timestamp of various events.
+/// This is used by the EventStats below.
+using SteadyTimePoint = std::chrono::time_point;
+
+/// Various time (and possibly memory) statistics of an event.
+struct EventStats {
+  // REQUIRED: Start time of an event
+  SteadyTimePoint start;
+  // OPTIONAL: End time of an event - may be empty if not meaningful.
+  std::optional end;
+  // TBD: could add some memory stats here too?
+
+  EventStats() = default;
+  EventStats(SteadyTimePoint start) : start(start) {}
+  EventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : start(start), end(end) {}
+};
+
+/// Describes the exit signal of an event.
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct LldbBaseTelemetryInfo : public TelemetryInfo {
+  EventStats stats;
+
+  std::optional exit_desc;
+
+  // For dyn_cast, isa, etc operations.
+  KindType getKind() const override { return LldbEntryKind::BaseInfo; }
+
+  static bool classof(const TelemetryInfo *t) {
+// Subclasses of this is also acceptable.
+return (t->getKind() & LldbEntryKind::BaseInfo) == LldbEntryKind::BaseInfo;
+  }
+
+  void serialize(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 {
+public:
+  TelemetryManager(std::unique_ptr config,
+   Debugger *debugger);
+
+  llvm::Error dispatch(TelemetryInfo *entry) override;
+
+  void addDestination(std::unique_ptr destination) override;
+
+private:
+  std::unique_ptr m_config;
+  Debugger *m_debugger;

oontvoo wrote:

(done)

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


[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2025-02-04 Thread Vy Nguyen via lldb-commits


@@ -108,6 +108,9 @@ endfunction(add_lldb_test_dependency)
 add_lldb_test_dependency(lldb)
 add_lldb_test_dependency(lldb-test)
 
+# Enable Telemetry for testing.
+target_compile_definitions(lldb PRIVATE -DTEST_TELEMETRY)
+

oontvoo wrote:

done (removed the macro)

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


[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2025-02-05 Thread Vy Nguyen via lldb-commits


@@ -0,0 +1,100 @@
+//===-- Telemetry.h --*- C++
+//-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.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 
+#include 
+#include 
+
+namespace lldb_private {
+
+using llvm::telemetry::Destination;

oontvoo wrote:

Ok, I'll just use the full name  then - maybe that's better than creating 
aliases ...

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


[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2025-02-05 Thread Vy Nguyen via lldb-commits


@@ -257,8 +257,8 @@ enum StopReason {
 };
 
 /// Command Return Status Types.
-enum ReturnStatus {
-  eReturnStatusInvalid,
+enum ReturnStatus : int {
+  eReturnStatusInvalid = 0,

oontvoo wrote:

when i tried to do `json::Object({"ret_stat", returnStatus})`, I got some build 
error (ambiguous types or sth like that).

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


[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2025-02-05 Thread Vy Nguyen via lldb-commits

oontvoo wrote:

> I think I don't see all of the updates you've made and the PR has the 
> "Processing updates" forever-spinner. The same thing happened to @cmtice's 
> PR, so you may want to check with her how she got the PR back on track.

Seems to be back to normal now! :)

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


[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2025-02-10 Thread Vy Nguyen via lldb-commits

oontvoo wrote:

@JDevlieghere  Hi, do you have any further comment/feedback  on this? If not, I 
plan to merge the PR this afternoon. Thanks!

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


[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2025-02-06 Thread Vy Nguyen via lldb-commits


@@ -257,8 +257,8 @@ enum StopReason {
 };
 
 /// Command Return Status Types.
-enum ReturnStatus {
-  eReturnStatusInvalid,
+enum ReturnStatus : int {
+  eReturnStatusInvalid = 0,

oontvoo wrote:

done

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


[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2025-02-06 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2025-02-06 Thread Vy Nguyen via lldb-commits


@@ -0,0 +1,100 @@
+//===-- Telemetry.h --*- C++
+//-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.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 
+#include 
+#include 
+
+namespace lldb_private {
+
+using llvm::telemetry::Destination;

oontvoo wrote:

So putting everthng under `lldb_private::telemetry`?

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


[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2025-02-06 Thread Vy Nguyen via lldb-commits

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

>From b7216d7c3edd5974d84612586fbabdef19037387 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Thu, 26 Dec 2024 20:50:40 -0500
Subject: [PATCH 1/8] Implement LLDB Telemetry (Part 1)

This contains only the concrete implementation of the framework to be used but 
no usages yet.

This is a subset of PR/98528.

I plan to send a few follow-up patches:
part2 : includes changes in the plugin-manager to set up the plugin stuff (ie., 
how to create a default vs vendor impl)
part3 (all of the following can be done in parallel):
* part 3_a: define DebuggerTelemetryInfo and related methods to collect data 
about debugger startup/exit
* part 3_b: define TargetTelemetryInfo and related methods to collect data 
about debug target(s)
* part 3_c: define CommandTelemetryInfo and related methods to collect data 
about debug-commands
* part 3_d: define ClientTelemtryInfo and related methods to collect data about 
lldb-dap/any other client
---
 lldb/include/lldb/Core/Telemetry.h| 101 ++
 lldb/include/lldb/lldb-enumerations.h |   4 +-
 lldb/source/Core/CMakeLists.txt   |   2 +
 lldb/source/Core/Telemetry.cpp|  92 +++
 lldb/test/CMakeLists.txt  |   3 +
 5 files changed, 200 insertions(+), 2 deletions(-)
 create mode 100644 lldb/include/lldb/Core/Telemetry.h
 create mode 100644 lldb/source/Core/Telemetry.cpp

diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
new file mode 100644
index 000..882511efd804d23
--- /dev/null
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -0,0 +1,101 @@
+//===-- Telemetry.h --*- C++
+//-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/JSON.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+namespace lldb_private {
+
+using llvm::telemetry::Destination;
+using llvm::telemetry::KindType;
+using llvm::telemetry::Serializer;
+using llvm::telemetry::TelemetryInfo;
+
+struct LldbEntryKind : public ::llvm::telemetry::EntryKind {
+  static const KindType BaseInfo = 0b11000;
+};
+
+/// Defines a convenient type for timestamp of various events.
+/// This is used by the EventStats below.
+using SteadyTimePoint = std::chrono::time_point;
+
+/// Various time (and possibly memory) statistics of an event.
+struct EventStats {
+  // REQUIRED: Start time of an event
+  SteadyTimePoint start;
+  // OPTIONAL: End time of an event - may be empty if not meaningful.
+  std::optional end;
+  // TBD: could add some memory stats here too?
+
+  EventStats() = default;
+  EventStats(SteadyTimePoint start) : start(start) {}
+  EventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : start(start), end(end) {}
+};
+
+/// Describes the exit signal of an event.
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct LldbBaseTelemetryInfo : public TelemetryInfo {
+  EventStats stats;
+
+  std::optional exit_desc;
+
+  Debugger *debugger;
+
+  // For dyn_cast, isa, etc operations.
+  KindType getKind() const override { return LldbEntryKind::BaseInfo; }
+
+  static bool classof(const TelemetryInfo *t) {
+// Subclasses of this is also acceptable.
+return (t->getKind() & LldbEntryKind::BaseInfo) == LldbEntryKind::BaseInfo;
+  }
+
+  void serialize(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 {
+public:
+  TelemetryManager(std::unique_ptr config);
+
+  llvm::Error dispatch(TelemetryInfo *entry) override;
+
+  void addDestination(std::unique_ptr destination) override;
+
+private:
+  std::unique_ptr m_config;
+  const std::string m_session_uuid;
+  std::vector> m_destinations;
+};
+
+} // namespace lldb_private
+#endif // LLDB_CORE_TELEMETRY_H
diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 0094fcd596fdf70..f63e446b6042f62 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -257,8 +257,8 @@ enum StopReason {
 };
 
 /// Command Return Status Types.
-enum ReturnStatus {
-  eReturnStatusInvalid,
+enum ReturnStatus : int {
+  eReturnStatusInvali

[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2025-02-06 Thread Vy Nguyen via lldb-commits


@@ -17,6 +17,15 @@ if (LLDB_ENABLE_CURSES)
 endif()
 
 # TODO: Add property `NO_PLUGIN_DEPENDENCIES` to lldbCore
+set(LLDB_CORE_SRCS
+
+)
+

oontvoo wrote:

done

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


[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2025-02-06 Thread Vy Nguyen via lldb-commits

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

>From b7216d7c3edd5974d84612586fbabdef19037387 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Thu, 26 Dec 2024 20:50:40 -0500
Subject: [PATCH 1/9] Implement LLDB Telemetry (Part 1)

This contains only the concrete implementation of the framework to be used but 
no usages yet.

This is a subset of PR/98528.

I plan to send a few follow-up patches:
part2 : includes changes in the plugin-manager to set up the plugin stuff (ie., 
how to create a default vs vendor impl)
part3 (all of the following can be done in parallel):
* part 3_a: define DebuggerTelemetryInfo and related methods to collect data 
about debugger startup/exit
* part 3_b: define TargetTelemetryInfo and related methods to collect data 
about debug target(s)
* part 3_c: define CommandTelemetryInfo and related methods to collect data 
about debug-commands
* part 3_d: define ClientTelemtryInfo and related methods to collect data about 
lldb-dap/any other client
---
 lldb/include/lldb/Core/Telemetry.h| 101 ++
 lldb/include/lldb/lldb-enumerations.h |   4 +-
 lldb/source/Core/CMakeLists.txt   |   2 +
 lldb/source/Core/Telemetry.cpp|  92 +++
 lldb/test/CMakeLists.txt  |   3 +
 5 files changed, 200 insertions(+), 2 deletions(-)
 create mode 100644 lldb/include/lldb/Core/Telemetry.h
 create mode 100644 lldb/source/Core/Telemetry.cpp

diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
new file mode 100644
index 000..882511efd804d23
--- /dev/null
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -0,0 +1,101 @@
+//===-- Telemetry.h --*- C++
+//-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/JSON.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+namespace lldb_private {
+
+using llvm::telemetry::Destination;
+using llvm::telemetry::KindType;
+using llvm::telemetry::Serializer;
+using llvm::telemetry::TelemetryInfo;
+
+struct LldbEntryKind : public ::llvm::telemetry::EntryKind {
+  static const KindType BaseInfo = 0b11000;
+};
+
+/// Defines a convenient type for timestamp of various events.
+/// This is used by the EventStats below.
+using SteadyTimePoint = std::chrono::time_point;
+
+/// Various time (and possibly memory) statistics of an event.
+struct EventStats {
+  // REQUIRED: Start time of an event
+  SteadyTimePoint start;
+  // OPTIONAL: End time of an event - may be empty if not meaningful.
+  std::optional end;
+  // TBD: could add some memory stats here too?
+
+  EventStats() = default;
+  EventStats(SteadyTimePoint start) : start(start) {}
+  EventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : start(start), end(end) {}
+};
+
+/// Describes the exit signal of an event.
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct LldbBaseTelemetryInfo : public TelemetryInfo {
+  EventStats stats;
+
+  std::optional exit_desc;
+
+  Debugger *debugger;
+
+  // For dyn_cast, isa, etc operations.
+  KindType getKind() const override { return LldbEntryKind::BaseInfo; }
+
+  static bool classof(const TelemetryInfo *t) {
+// Subclasses of this is also acceptable.
+return (t->getKind() & LldbEntryKind::BaseInfo) == LldbEntryKind::BaseInfo;
+  }
+
+  void serialize(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 {
+public:
+  TelemetryManager(std::unique_ptr config);
+
+  llvm::Error dispatch(TelemetryInfo *entry) override;
+
+  void addDestination(std::unique_ptr destination) override;
+
+private:
+  std::unique_ptr m_config;
+  const std::string m_session_uuid;
+  std::vector> m_destinations;
+};
+
+} // namespace lldb_private
+#endif // LLDB_CORE_TELEMETRY_H
diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 0094fcd596fdf70..f63e446b6042f62 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -257,8 +257,8 @@ enum StopReason {
 };
 
 /// Command Return Status Types.
-enum ReturnStatus {
-  eReturnStatusInvalid,
+enum ReturnStatus : int {
+  eReturnStatusInvali

[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2025-02-06 Thread Vy Nguyen via lldb-commits

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

>From b7216d7c3edd5974d84612586fbabdef19037387 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Thu, 26 Dec 2024 20:50:40 -0500
Subject: [PATCH 01/10] Implement LLDB Telemetry (Part 1)

This contains only the concrete implementation of the framework to be used but 
no usages yet.

This is a subset of PR/98528.

I plan to send a few follow-up patches:
part2 : includes changes in the plugin-manager to set up the plugin stuff (ie., 
how to create a default vs vendor impl)
part3 (all of the following can be done in parallel):
* part 3_a: define DebuggerTelemetryInfo and related methods to collect data 
about debugger startup/exit
* part 3_b: define TargetTelemetryInfo and related methods to collect data 
about debug target(s)
* part 3_c: define CommandTelemetryInfo and related methods to collect data 
about debug-commands
* part 3_d: define ClientTelemtryInfo and related methods to collect data about 
lldb-dap/any other client
---
 lldb/include/lldb/Core/Telemetry.h| 101 ++
 lldb/include/lldb/lldb-enumerations.h |   4 +-
 lldb/source/Core/CMakeLists.txt   |   2 +
 lldb/source/Core/Telemetry.cpp|  92 +++
 lldb/test/CMakeLists.txt  |   3 +
 5 files changed, 200 insertions(+), 2 deletions(-)
 create mode 100644 lldb/include/lldb/Core/Telemetry.h
 create mode 100644 lldb/source/Core/Telemetry.cpp

diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
new file mode 100644
index 000..882511efd804d23
--- /dev/null
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -0,0 +1,101 @@
+//===-- Telemetry.h --*- C++
+//-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/JSON.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+namespace lldb_private {
+
+using llvm::telemetry::Destination;
+using llvm::telemetry::KindType;
+using llvm::telemetry::Serializer;
+using llvm::telemetry::TelemetryInfo;
+
+struct LldbEntryKind : public ::llvm::telemetry::EntryKind {
+  static const KindType BaseInfo = 0b11000;
+};
+
+/// Defines a convenient type for timestamp of various events.
+/// This is used by the EventStats below.
+using SteadyTimePoint = std::chrono::time_point;
+
+/// Various time (and possibly memory) statistics of an event.
+struct EventStats {
+  // REQUIRED: Start time of an event
+  SteadyTimePoint start;
+  // OPTIONAL: End time of an event - may be empty if not meaningful.
+  std::optional end;
+  // TBD: could add some memory stats here too?
+
+  EventStats() = default;
+  EventStats(SteadyTimePoint start) : start(start) {}
+  EventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : start(start), end(end) {}
+};
+
+/// Describes the exit signal of an event.
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct LldbBaseTelemetryInfo : public TelemetryInfo {
+  EventStats stats;
+
+  std::optional exit_desc;
+
+  Debugger *debugger;
+
+  // For dyn_cast, isa, etc operations.
+  KindType getKind() const override { return LldbEntryKind::BaseInfo; }
+
+  static bool classof(const TelemetryInfo *t) {
+// Subclasses of this is also acceptable.
+return (t->getKind() & LldbEntryKind::BaseInfo) == LldbEntryKind::BaseInfo;
+  }
+
+  void serialize(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 {
+public:
+  TelemetryManager(std::unique_ptr config);
+
+  llvm::Error dispatch(TelemetryInfo *entry) override;
+
+  void addDestination(std::unique_ptr destination) override;
+
+private:
+  std::unique_ptr m_config;
+  const std::string m_session_uuid;
+  std::vector> m_destinations;
+};
+
+} // namespace lldb_private
+#endif // LLDB_CORE_TELEMETRY_H
diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 0094fcd596fdf70..f63e446b6042f62 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -257,8 +257,8 @@ enum StopReason {
 };
 
 /// Command Return Status Types.
-enum ReturnStatus {
-  eReturnStatusInvalid,
+enum ReturnStatus : int {
+  eReturnStatusInva

[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2025-02-06 Thread Vy Nguyen via lldb-commits

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

>From b7216d7c3edd5974d84612586fbabdef19037387 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Thu, 26 Dec 2024 20:50:40 -0500
Subject: [PATCH 01/11] Implement LLDB Telemetry (Part 1)

This contains only the concrete implementation of the framework to be used but 
no usages yet.

This is a subset of PR/98528.

I plan to send a few follow-up patches:
part2 : includes changes in the plugin-manager to set up the plugin stuff (ie., 
how to create a default vs vendor impl)
part3 (all of the following can be done in parallel):
* part 3_a: define DebuggerTelemetryInfo and related methods to collect data 
about debugger startup/exit
* part 3_b: define TargetTelemetryInfo and related methods to collect data 
about debug target(s)
* part 3_c: define CommandTelemetryInfo and related methods to collect data 
about debug-commands
* part 3_d: define ClientTelemtryInfo and related methods to collect data about 
lldb-dap/any other client
---
 lldb/include/lldb/Core/Telemetry.h| 101 ++
 lldb/include/lldb/lldb-enumerations.h |   4 +-
 lldb/source/Core/CMakeLists.txt   |   2 +
 lldb/source/Core/Telemetry.cpp|  92 +++
 lldb/test/CMakeLists.txt  |   3 +
 5 files changed, 200 insertions(+), 2 deletions(-)
 create mode 100644 lldb/include/lldb/Core/Telemetry.h
 create mode 100644 lldb/source/Core/Telemetry.cpp

diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
new file mode 100644
index 000..882511efd804d23
--- /dev/null
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -0,0 +1,101 @@
+//===-- Telemetry.h --*- C++
+//-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/JSON.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+namespace lldb_private {
+
+using llvm::telemetry::Destination;
+using llvm::telemetry::KindType;
+using llvm::telemetry::Serializer;
+using llvm::telemetry::TelemetryInfo;
+
+struct LldbEntryKind : public ::llvm::telemetry::EntryKind {
+  static const KindType BaseInfo = 0b11000;
+};
+
+/// Defines a convenient type for timestamp of various events.
+/// This is used by the EventStats below.
+using SteadyTimePoint = std::chrono::time_point;
+
+/// Various time (and possibly memory) statistics of an event.
+struct EventStats {
+  // REQUIRED: Start time of an event
+  SteadyTimePoint start;
+  // OPTIONAL: End time of an event - may be empty if not meaningful.
+  std::optional end;
+  // TBD: could add some memory stats here too?
+
+  EventStats() = default;
+  EventStats(SteadyTimePoint start) : start(start) {}
+  EventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : start(start), end(end) {}
+};
+
+/// Describes the exit signal of an event.
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct LldbBaseTelemetryInfo : public TelemetryInfo {
+  EventStats stats;
+
+  std::optional exit_desc;
+
+  Debugger *debugger;
+
+  // For dyn_cast, isa, etc operations.
+  KindType getKind() const override { return LldbEntryKind::BaseInfo; }
+
+  static bool classof(const TelemetryInfo *t) {
+// Subclasses of this is also acceptable.
+return (t->getKind() & LldbEntryKind::BaseInfo) == LldbEntryKind::BaseInfo;
+  }
+
+  void serialize(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 {
+public:
+  TelemetryManager(std::unique_ptr config);
+
+  llvm::Error dispatch(TelemetryInfo *entry) override;
+
+  void addDestination(std::unique_ptr destination) override;
+
+private:
+  std::unique_ptr m_config;
+  const std::string m_session_uuid;
+  std::vector> m_destinations;
+};
+
+} // namespace lldb_private
+#endif // LLDB_CORE_TELEMETRY_H
diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 0094fcd596fdf70..f63e446b6042f62 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -257,8 +257,8 @@ enum StopReason {
 };
 
 /// Command Return Status Types.
-enum ReturnStatus {
-  eReturnStatusInvalid,
+enum ReturnStatus : int {
+  eReturnStatusInva

[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2025-02-06 Thread Vy Nguyen via lldb-commits

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

>From b7216d7c3edd5974d84612586fbabdef19037387 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Thu, 26 Dec 2024 20:50:40 -0500
Subject: [PATCH 01/14] Implement LLDB Telemetry (Part 1)

This contains only the concrete implementation of the framework to be used but 
no usages yet.

This is a subset of PR/98528.

I plan to send a few follow-up patches:
part2 : includes changes in the plugin-manager to set up the plugin stuff (ie., 
how to create a default vs vendor impl)
part3 (all of the following can be done in parallel):
* part 3_a: define DebuggerTelemetryInfo and related methods to collect data 
about debugger startup/exit
* part 3_b: define TargetTelemetryInfo and related methods to collect data 
about debug target(s)
* part 3_c: define CommandTelemetryInfo and related methods to collect data 
about debug-commands
* part 3_d: define ClientTelemtryInfo and related methods to collect data about 
lldb-dap/any other client
---
 lldb/include/lldb/Core/Telemetry.h| 101 ++
 lldb/include/lldb/lldb-enumerations.h |   4 +-
 lldb/source/Core/CMakeLists.txt   |   2 +
 lldb/source/Core/Telemetry.cpp|  92 +++
 lldb/test/CMakeLists.txt  |   3 +
 5 files changed, 200 insertions(+), 2 deletions(-)
 create mode 100644 lldb/include/lldb/Core/Telemetry.h
 create mode 100644 lldb/source/Core/Telemetry.cpp

diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
new file mode 100644
index 000..882511efd804d23
--- /dev/null
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -0,0 +1,101 @@
+//===-- Telemetry.h --*- C++
+//-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/JSON.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+namespace lldb_private {
+
+using llvm::telemetry::Destination;
+using llvm::telemetry::KindType;
+using llvm::telemetry::Serializer;
+using llvm::telemetry::TelemetryInfo;
+
+struct LldbEntryKind : public ::llvm::telemetry::EntryKind {
+  static const KindType BaseInfo = 0b11000;
+};
+
+/// Defines a convenient type for timestamp of various events.
+/// This is used by the EventStats below.
+using SteadyTimePoint = std::chrono::time_point;
+
+/// Various time (and possibly memory) statistics of an event.
+struct EventStats {
+  // REQUIRED: Start time of an event
+  SteadyTimePoint start;
+  // OPTIONAL: End time of an event - may be empty if not meaningful.
+  std::optional end;
+  // TBD: could add some memory stats here too?
+
+  EventStats() = default;
+  EventStats(SteadyTimePoint start) : start(start) {}
+  EventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : start(start), end(end) {}
+};
+
+/// Describes the exit signal of an event.
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct LldbBaseTelemetryInfo : public TelemetryInfo {
+  EventStats stats;
+
+  std::optional exit_desc;
+
+  Debugger *debugger;
+
+  // For dyn_cast, isa, etc operations.
+  KindType getKind() const override { return LldbEntryKind::BaseInfo; }
+
+  static bool classof(const TelemetryInfo *t) {
+// Subclasses of this is also acceptable.
+return (t->getKind() & LldbEntryKind::BaseInfo) == LldbEntryKind::BaseInfo;
+  }
+
+  void serialize(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 {
+public:
+  TelemetryManager(std::unique_ptr config);
+
+  llvm::Error dispatch(TelemetryInfo *entry) override;
+
+  void addDestination(std::unique_ptr destination) override;
+
+private:
+  std::unique_ptr m_config;
+  const std::string m_session_uuid;
+  std::vector> m_destinations;
+};
+
+} // namespace lldb_private
+#endif // LLDB_CORE_TELEMETRY_H
diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 0094fcd596fdf70..f63e446b6042f62 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -257,8 +257,8 @@ enum StopReason {
 };
 
 /// Command Return Status Types.
-enum ReturnStatus {
-  eReturnStatusInvalid,
+enum ReturnStatus : int {
+  eReturnStatusInva

[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2025-02-06 Thread Vy Nguyen via lldb-commits


@@ -257,8 +257,8 @@ enum StopReason {
 };
 
 /// Command Return Status Types.
-enum ReturnStatus {
-  eReturnStatusInvalid,
+enum ReturnStatus : int {
+  eReturnStatusInvalid = 0,

oontvoo wrote:

done - removed the `:int` and `=0`

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


[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2025-02-06 Thread Vy Nguyen via lldb-commits


@@ -0,0 +1,93 @@
+//===-- Telemetry.h --*- C++
+//-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.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 
+#include 
+#include 
+
+namespace lldb_private {
+
+struct LldbEntryKind : public ::llvm::telemetry::EntryKind {
+  static const llvm::telemetry::KindType BaseInfo = 0b11000;
+};
+
+/// Defines a convenient type for timestamp of various events.
+/// This is used by the EventStats below.
+using SteadyTimePoint = std::chrono::time_point;
+
+/// Various time (and possibly memory) statistics of an event.
+struct EventStats {
+  // REQUIRED: Start time of an event
+  SteadyTimePoint start;
+  // OPTIONAL: End time of an event - may be empty if not meaningful.
+  std::optional end;
+  // TBD: could add some memory stats here too?
+
+  EventStats() = default;
+  EventStats(SteadyTimePoint start) : start(start) {}
+  EventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : start(start), end(end) {}
+};
+
+/// Describes the exit signal of an event.
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct LldbBaseTelemetryInfo : public llvm::telemetry::TelemetryInfo {
+  EventStats stats;
+
+  std::optional exit_desc;

oontvoo wrote:

We're going to have 5 types of entries.I think the exit status  (or more 
accurately "return status" for the command-info case) is applicable to the 
first 4 entries:
 - debugger-info  (whether LLDB terminates successfully)
 - target-info  (whether the main executable exits successfully)
 - command-info (whether the command executed successfully)
 - client-request-info (whether the request completed successfully)
 - misc-info (optionall)


So that's 4 out of 5, which is why I thought it made sense to hoist it into the 
common class.

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


[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)

2025-02-05 Thread Vy Nguyen via lldb-commits

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

>From b7216d7c3edd5974d84612586fbabdef19037387 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Thu, 26 Dec 2024 20:50:40 -0500
Subject: [PATCH 1/5] Implement LLDB Telemetry (Part 1)

This contains only the concrete implementation of the framework to be used but 
no usages yet.

This is a subset of PR/98528.

I plan to send a few follow-up patches:
part2 : includes changes in the plugin-manager to set up the plugin stuff (ie., 
how to create a default vs vendor impl)
part3 (all of the following can be done in parallel):
* part 3_a: define DebuggerTelemetryInfo and related methods to collect data 
about debugger startup/exit
* part 3_b: define TargetTelemetryInfo and related methods to collect data 
about debug target(s)
* part 3_c: define CommandTelemetryInfo and related methods to collect data 
about debug-commands
* part 3_d: define ClientTelemtryInfo and related methods to collect data about 
lldb-dap/any other client
---
 lldb/include/lldb/Core/Telemetry.h| 101 ++
 lldb/include/lldb/lldb-enumerations.h |   4 +-
 lldb/source/Core/CMakeLists.txt   |   2 +
 lldb/source/Core/Telemetry.cpp|  92 +++
 lldb/test/CMakeLists.txt  |   3 +
 5 files changed, 200 insertions(+), 2 deletions(-)
 create mode 100644 lldb/include/lldb/Core/Telemetry.h
 create mode 100644 lldb/source/Core/Telemetry.cpp

diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
new file mode 100644
index 000..882511efd804d23
--- /dev/null
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -0,0 +1,101 @@
+//===-- Telemetry.h --*- C++
+//-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_CORE_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/JSON.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+namespace lldb_private {
+
+using llvm::telemetry::Destination;
+using llvm::telemetry::KindType;
+using llvm::telemetry::Serializer;
+using llvm::telemetry::TelemetryInfo;
+
+struct LldbEntryKind : public ::llvm::telemetry::EntryKind {
+  static const KindType BaseInfo = 0b11000;
+};
+
+/// Defines a convenient type for timestamp of various events.
+/// This is used by the EventStats below.
+using SteadyTimePoint = std::chrono::time_point;
+
+/// Various time (and possibly memory) statistics of an event.
+struct EventStats {
+  // REQUIRED: Start time of an event
+  SteadyTimePoint start;
+  // OPTIONAL: End time of an event - may be empty if not meaningful.
+  std::optional end;
+  // TBD: could add some memory stats here too?
+
+  EventStats() = default;
+  EventStats(SteadyTimePoint start) : start(start) {}
+  EventStats(SteadyTimePoint start, SteadyTimePoint end)
+  : start(start), end(end) {}
+};
+
+/// Describes the exit signal of an event.
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct LldbBaseTelemetryInfo : public TelemetryInfo {
+  EventStats stats;
+
+  std::optional exit_desc;
+
+  Debugger *debugger;
+
+  // For dyn_cast, isa, etc operations.
+  KindType getKind() const override { return LldbEntryKind::BaseInfo; }
+
+  static bool classof(const TelemetryInfo *t) {
+// Subclasses of this is also acceptable.
+return (t->getKind() & LldbEntryKind::BaseInfo) == LldbEntryKind::BaseInfo;
+  }
+
+  void serialize(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 {
+public:
+  TelemetryManager(std::unique_ptr config);
+
+  llvm::Error dispatch(TelemetryInfo *entry) override;
+
+  void addDestination(std::unique_ptr destination) override;
+
+private:
+  std::unique_ptr m_config;
+  const std::string m_session_uuid;
+  std::vector> m_destinations;
+};
+
+} // namespace lldb_private
+#endif // LLDB_CORE_TELEMETRY_H
diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 0094fcd596fdf70..f63e446b6042f62 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -257,8 +257,8 @@ enum StopReason {
 };
 
 /// Command Return Status Types.
-enum ReturnStatus {
-  eReturnStatusInvalid,
+enum ReturnStatus : int {
+  eReturnStatusInvali

  1   2   3   4   5   >