[Lldb-commits] [lldb] Reland "[lldb] Implement basic support for reverse-continue" (#123906)" (PR #123945)

2025-02-20 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

In any case, I think it might be useful to remand the patch once, so we can 
inspect the failure log on the bot, since the bot logs have been recycled since 
the last time this landed.

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


[Lldb-commits] [lldb] [LLDB][Telemetry]Define DebuggerTelemetryInfo and related methods (PR #127696)

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


@@ -56,13 +60,83 @@ struct LLDBBaseTelemetryInfo : public 
llvm::telemetry::TelemetryInfo {
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 };
 
+/// Describes the exit status of a debugger.
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct DebuggerTelemetryInfo : public LLDBBaseTelemetryInfo {

oontvoo wrote:

P.S: updated the method to not collect any of the username, cwd, lldb_path 
(just leaving the fields empty).
(vendors can override the AtDebuggerStart() to collect those if they want to)


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


[Lldb-commits] [lldb] [lldb][AIX] Added PlatformAIX plugin (PR #121273)

2025-02-20 Thread Dhruv Srivastava via lldb-commits


@@ -8,3 +8,4 @@ add_subdirectory(OpenBSD)
 add_subdirectory(POSIX)
 add_subdirectory(QemuUser)
 add_subdirectory(Windows)
+add_subdirectory(AIX)

DhruvSrivastavaX wrote:

Yeay! 🙂 

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


[Lldb-commits] [lldb] [lldb][AIX] Added PlatformAIX plugin (PR #121273)

2025-02-20 Thread Dhruv Srivastava via lldb-commits


@@ -0,0 +1,193 @@
+//===-- PlatformAIX.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 "PlatformAIX.h"
+#include "lldb/Host/Config.h"
+#include 
+#if LLDB_ENABLE_POSIX
+#include 
+#endif
+#include "Utility/ARM64_DWARF_Registers.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/UnwindPlan.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/State.h"
+#include "lldb/Utility/Status.h"
+#include "lldb/Utility/StreamString.h"
+
+// Use defined constants from AIX mman.h for use when targeting remote aix
+// systems even when host has different values.
+
+#if defined(_AIX)
+#include 
+#else // For remotely cross debugging aix
+#define MAP_VARIABLE 0x0
+#define MAP_PRIVATE 0x2
+#define MAP_ANONYMOUS 0x10
+#endif
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::platform_aix;
+
+LLDB_PLUGIN_DEFINE(PlatformAIX)
+
+static uint32_t g_initialize_count = 0;
+
+PlatformSP PlatformAIX::CreateInstance(bool force, const ArchSpec *arch) {
+  Log *log = GetLog(LLDBLog::Platform);
+  LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force,
+   arch ? arch->GetArchitectureName() : "",
+   arch ? arch->GetTriple().getTriple() : "");
+
+  bool create = force;
+  if (!create && arch && arch->IsValid()) {
+const llvm::Triple &triple = arch->GetTriple();
+switch (triple.getOS()) {
+case llvm::Triple::AIX:
+  create = true;
+  break;
+
+default:
+  break;
+}
+  }
+
+  LLDB_LOG(log, "create = {0}", create);
+  if (create) {
+return PlatformSP(new PlatformAIX(false));
+  }
+  return PlatformSP();
+}
+
+llvm::StringRef PlatformAIX::GetPluginDescriptionStatic(bool is_host) {
+  if (is_host)
+return "Local AIX user platform plug-in.";
+  return "Remote AIX user platform plug-in.";
+}
+
+void PlatformAIX::Initialize() {
+  PlatformPOSIX::Initialize();
+
+  if (g_initialize_count++ == 0) {
+#ifdef _AIX
+PlatformSP default_platform_sp(new PlatformAIX(true));
+default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
+Platform::SetHostPlatform(default_platform_sp);
+#endif
+PluginManager::RegisterPlugin(
+PlatformAIX::GetPluginNameStatic(false),
+PlatformAIX::GetPluginDescriptionStatic(false),
+PlatformAIX::CreateInstance, nullptr);
+  }
+}
+
+void PlatformAIX::Terminate() {
+  if (g_initialize_count > 0) {
+if (--g_initialize_count == 0) {
+  PluginManager::UnregisterPlugin(PlatformAIX::CreateInstance);
+}
+  }
+
+  PlatformPOSIX::Terminate();
+}
+
+/// Default Constructor
+PlatformAIX::PlatformAIX(bool is_host)
+: PlatformPOSIX(is_host) // This is the local host platform

DhruvSrivastavaX wrote:

Yes, it just remains as a residual from other file.

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


[Lldb-commits] [lldb] [lldb][AIX] Added PlatformAIX plugin (PR #121273)

2025-02-20 Thread Dhruv Srivastava via lldb-commits


@@ -0,0 +1,72 @@
+//===-- PlatformAIX.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_SOURCE_PLUGINS_PLATFORM_AIX_PLATFORMAIX_H
+#define LLDB_SOURCE_PLUGINS_PLATFORM_AIX_PLATFORMAIX_H
+
+#include "Plugins/Platform/POSIX/PlatformPOSIX.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+
+namespace lldb_private {
+namespace platform_aix {
+
+class PlatformAIX : public PlatformPOSIX {
+public:
+  PlatformAIX(bool is_host);
+
+  static void Initialize();
+
+  static void Terminate();
+
+  // lldb_private::PluginInterface functions
+  static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch);
+
+  static llvm::StringRef GetPluginNameStatic(bool is_host) {
+return is_host ? Platform::GetHostPlatformName() : "remote-AIX";
+  }
+
+  static llvm::StringRef GetPluginDescriptionStatic(bool is_host);
+
+  llvm::StringRef GetPluginName() override {
+return GetPluginNameStatic(IsHost());
+  }
+
+  // lldb_private::Platform functions
+  llvm::StringRef GetDescription() override {
+return GetPluginDescriptionStatic(IsHost());
+  }
+
+  void GetStatus(Stream &strm) override;
+
+  std::vector
+  GetSupportedArchitectures(const ArchSpec &process_host_arch) override;
+
+  bool CanDebugProcess() override;

DhruvSrivastavaX wrote:

This one is not present in PlatformPOSIX, but is rather present in Platform.h 
and always returns true, 
in that case, we can have this moved to PlatformPOSIX instead if that is 
better? All other platforms which do use it do the same thing except:
OpenBSD always returns false and Windows always returns true. 

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


[Lldb-commits] [lldb] [lldb][AIX] Added PlatformAIX plugin (PR #121273)

2025-02-20 Thread Dhruv Srivastava via lldb-commits


@@ -0,0 +1,193 @@
+//===-- PlatformAIX.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 "PlatformAIX.h"
+#include "lldb/Host/Config.h"
+#include 
+#if LLDB_ENABLE_POSIX
+#include 
+#endif
+#include "Utility/ARM64_DWARF_Registers.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/UnwindPlan.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/State.h"
+#include "lldb/Utility/Status.h"
+#include "lldb/Utility/StreamString.h"
+
+// Use defined constants from AIX mman.h for use when targeting remote aix
+// systems even when host has different values.
+
+#if defined(_AIX)
+#include 
+#else // For remotely cross debugging aix
+#define MAP_VARIABLE 0x0
+#define MAP_PRIVATE 0x2
+#define MAP_ANONYMOUS 0x10
+#endif
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::platform_aix;
+
+LLDB_PLUGIN_DEFINE(PlatformAIX)
+
+static uint32_t g_initialize_count = 0;
+
+PlatformSP PlatformAIX::CreateInstance(bool force, const ArchSpec *arch) {
+  Log *log = GetLog(LLDBLog::Platform);
+  LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force,
+   arch ? arch->GetArchitectureName() : "",
+   arch ? arch->GetTriple().getTriple() : "");
+
+  bool create = force;
+  if (!create && arch && arch->IsValid()) {
+const llvm::Triple &triple = arch->GetTriple();
+switch (triple.getOS()) {
+case llvm::Triple::AIX:
+  create = true;
+  break;
+
+default:
+  break;
+}
+  }
+
+  LLDB_LOG(log, "create = {0}", create);
+  if (create) {
+return PlatformSP(new PlatformAIX(false));
+  }
+  return PlatformSP();
+}
+
+llvm::StringRef PlatformAIX::GetPluginDescriptionStatic(bool is_host) {
+  if (is_host)
+return "Local AIX user platform plug-in.";
+  return "Remote AIX user platform plug-in.";
+}
+
+void PlatformAIX::Initialize() {
+  PlatformPOSIX::Initialize();
+
+  if (g_initialize_count++ == 0) {
+#ifdef _AIX
+PlatformSP default_platform_sp(new PlatformAIX(true));
+default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
+Platform::SetHostPlatform(default_platform_sp);
+#endif
+PluginManager::RegisterPlugin(
+PlatformAIX::GetPluginNameStatic(false),
+PlatformAIX::GetPluginDescriptionStatic(false),
+PlatformAIX::CreateInstance, nullptr);
+  }
+}
+
+void PlatformAIX::Terminate() {
+  if (g_initialize_count > 0) {
+if (--g_initialize_count == 0) {
+  PluginManager::UnregisterPlugin(PlatformAIX::CreateInstance);
+}
+  }
+
+  PlatformPOSIX::Terminate();
+}
+
+/// Default Constructor
+PlatformAIX::PlatformAIX(bool is_host)
+: PlatformPOSIX(is_host) // This is the local host platform
+{
+  if (is_host) {
+ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
+m_supported_architectures.push_back(hostArch);
+if (hostArch.GetTriple().isArch64Bit()) {
+  m_supported_architectures.push_back(
+  HostInfo::GetArchitecture(HostInfo::eArchKind32));

DhruvSrivastavaX wrote:

This is just one of those errors which have been copied from parent file. 
Even linux has this typo, we might need to change there as well?

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


[Lldb-commits] [lldb] [lldb] Store StreamAsynchronousIO in a unique_ptr (NFC) (PR #127961)

2025-02-20 Thread Pavel Labath via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Fix GCC's `-Wreturn-type` warnings (PR #127974)

2025-02-20 Thread via lldb-commits

https://github.com/foxtran updated 
https://github.com/llvm/llvm-project/pull/127974

>From d36ed841386fbc0662d120eefca076df16bdd880 Mon Sep 17 00:00:00 2001
From: "Igor S. Gerasimov" 
Date: Thu, 20 Feb 2025 10:04:13 +0100
Subject: [PATCH] Fix GCC's -Wreturn-type warning

---
 lldb/source/DataFormatters/TypeSummary.cpp | 2 ++
 lldb/source/ValueObject/DILLexer.cpp   | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/lldb/source/DataFormatters/TypeSummary.cpp 
b/lldb/source/DataFormatters/TypeSummary.cpp
index 2c863b364538f..fa6953a2ee14c 100644
--- a/lldb/source/DataFormatters/TypeSummary.cpp
+++ b/lldb/source/DataFormatters/TypeSummary.cpp
@@ -58,6 +58,8 @@ std::string TypeSummaryImpl::GetSummaryKindName() {
 return "c++";
   case Kind::eBytecode:
 return "bytecode";
+  default:
+llvm_unreachable("Unknown type kind name");
   }
 }
 
diff --git a/lldb/source/ValueObject/DILLexer.cpp 
b/lldb/source/ValueObject/DILLexer.cpp
index c7acfec347af4..bbb5fafdacbe5 100644
--- a/lldb/source/ValueObject/DILLexer.cpp
+++ b/lldb/source/ValueObject/DILLexer.cpp
@@ -29,6 +29,8 @@ llvm::StringRef Token::GetTokenName(Kind kind) {
 return "l_paren";
   case Kind::r_paren:
 return "r_paren";
+  default:
+llvm_unreachable("Unknown token name");
   }
 }
 

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


[Lldb-commits] [lldb] [lldb] Fix GCC's `-Wreturn-type` warnings (PR #127974)

2025-02-20 Thread Pavel Labath via lldb-commits

https://github.com/labath commented:

The default clause prevents the "uncovered enumerator" from firing is a new 
value is added to the enum (and it's actually against the [coding 
standards](https://llvm.org/docs/CodingStandards.html#don-t-use-default-labels-in-fully-covered-switches-over-enumerations)).
 The recommended solution is to place llvm_unreachable after the switch [like 
so](https://github.com/llvm/llvm-project/blob/6e047a5ab42698165a4746ef681396fab1698327/llvm/include/llvm/IR/GlobalValue.h#L160)

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


[Lldb-commits] [lldb] [lldb] Renaissance LineTable sequences (PR #127800)

2025-02-20 Thread Pavel Labath via lldb-commits

https://github.com/labath updated 
https://github.com/llvm/llvm-project/pull/127800

>From b82a233736efc391aaa408513cbea257871ab7b5 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Wed, 19 Feb 2025 15:03:40 +0100
Subject: [PATCH] [lldb] Renaissance LineTable sequences

LineSeqeunce is basically a vector, except that users aren't supposed to
know that. This implements the same concept in a slightly simpler
fashion.
---
 lldb/include/lldb/Symbol/LineTable.h  | 89 ---
 .../Breakpad/SymbolFileBreakpad.cpp   | 12 ++-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  7 +-
 .../NativePDB/SymbolFileNativePDB.cpp | 11 ++-
 .../Plugins/SymbolFile/PDB/SymbolFilePDB.cpp  | 26 +++---
 lldb/source/Symbol/LineTable.cpp  | 74 ++-
 lldb/unittests/Symbol/LineTableTest.cpp   | 19 ++--
 7 files changed, 95 insertions(+), 143 deletions(-)

diff --git a/lldb/include/lldb/Symbol/LineTable.h 
b/lldb/include/lldb/Symbol/LineTable.h
index f66081b6ee110..2ce5d8cee6e95 100644
--- a/lldb/include/lldb/Symbol/LineTable.h
+++ b/lldb/include/lldb/Symbol/LineTable.h
@@ -20,25 +20,11 @@
 
 namespace lldb_private {
 
-/// \class LineSequence LineTable.h "lldb/Symbol/LineTable.h" An abstract base
-/// class used during symbol table creation.
-class LineSequence {
-public:
-  LineSequence();
-
-  virtual ~LineSequence() = default;
-
-  virtual void Clear() = 0;
-
-private:
-  LineSequence(const LineSequence &) = delete;
-  const LineSequence &operator=(const LineSequence &) = delete;
-};
-
 /// \class LineTable LineTable.h "lldb/Symbol/LineTable.h"
 /// A line table class.
 class LineTable {
 public:
+  class Sequence;
   /// Construct with compile unit.
   ///
   /// \param[in] comp_unit
@@ -49,8 +35,7 @@ class LineTable {
   ///
   /// \param[in] sequences
   /// Unsorted list of line sequences.
-  LineTable(CompileUnit *comp_unit,
-std::vector> &&sequences);
+  LineTable(CompileUnit *comp_unit, std::vector &&sequences);
 
   /// Destructor.
   ~LineTable();
@@ -73,20 +58,17 @@ class LineTable {
bool is_start_of_basic_block, bool is_prologue_end,
bool is_epilogue_begin, bool is_terminal_entry);
 
-  // Used to instantiate the LineSequence helper class
-  static std::unique_ptr CreateLineSequenceContainer();
-
   // Append an entry to a caller-provided collection that will later be
   // inserted in this line table.
-  static void AppendLineEntryToSequence(LineSequence *sequence, lldb::addr_t 
file_addr,
- uint32_t line, uint16_t column,
- uint16_t file_idx, bool is_start_of_statement,
- bool is_start_of_basic_block,
- bool is_prologue_end, bool is_epilogue_begin,
- bool is_terminal_entry);
+  static void
+  AppendLineEntryToSequence(Sequence &sequence, lldb::addr_t file_addr,
+uint32_t line, uint16_t column, uint16_t file_idx,
+bool is_start_of_statement,
+bool is_start_of_basic_block, bool is_prologue_end,
+bool is_epilogue_begin, bool is_terminal_entry);
 
   // Insert a sequence of entries into this line table.
-  void InsertSequence(LineSequence *sequence);
+  void InsertSequence(Sequence sequence);
 
   /// Dump all line entries in this line table to the stream \a s.
   ///
@@ -273,17 +255,6 @@ class LineTable {
   return 0;
 }
 
-class LessThanBinaryPredicate {
-public:
-  LessThanBinaryPredicate(LineTable *line_table);
-  bool operator()(const LineTable::Entry &, const LineTable::Entry &) 
const;
-  bool operator()(const std::unique_ptr &,
-  const std::unique_ptr &) const;
-
-protected:
-  LineTable *m_line_table;
-};
-
 static bool EntryAddressLessThan(const Entry &lhs, const Entry &rhs) {
   return lhs.file_addr < rhs.file_addr;
 }
@@ -315,6 +286,35 @@ class LineTable {
 uint16_t file_idx = 0;
   };
 
+  class Sequence {
+  public:
+Sequence() = default;
+// Moving clears moved-from object so it can be used anew. Copying is
+// generally an error. C++ doesn't guarantee that a moved-from vector is
+// empty(), so we clear it explicitly.
+Sequence(Sequence &&rhs) : m_entries(std::exchange(rhs.m_entries, {})) {}
+Sequence &operator=(Sequence &&rhs) {
+  m_entries = std::exchange(rhs.m_entries, {});
+  return *this;
+}
+Sequence(const Sequence &) = delete;
+Sequence &operator=(const Sequence &) = delete;
+
+  private:
+std::vector m_entries;
+friend class LineTable;
+  };
+
+  class LessThanBinaryPredicate {
+  public:
+LessThanBinaryPredicate(LineTable *line_table) : m_line_table(line_table) 
{}
+bool operator()(const LineTable::Entry &, const LineTable::Entry &) const;
+bool operator()(const Seque

[Lldb-commits] [lldb] [llvm] [lldb][RISC-V] Extended if conditions to support alias names for registers (PR #124475)

2025-02-20 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [lldb] Extended if conditions to support alias names for registers (PR #124475)

2025-02-20 Thread David Spickett via lldb-commits


@@ -652,6 +652,153 @@ def haltReason(self):
 )
 self.match("register read s31", ["s31 = 128"])
 
+@skipIfXmlSupportMissing
+@skipIfRemote
+@skipIfLLVMTargetMissing("RISCV")
+def test_riscv64_regs(self):
+"""Test grabbing various riscv64 registers from gdbserver."""
+
+class MyResponder(MockGDBServerResponder):
+reg_data = (
+"0102030405060708"  # zero
+"0102030405060708"  # ra
+"0102030405060708"  # sp
+"0102030405060708"  # gp
+"0102030405060708"  # tp
+"0102030405060708"  # t0
+"0102030405060708"  # t1
+"0102030405060708"  # t2
+"0102030405060708"  # fp
+"0102030405060708"  # s1
+"0102030405060708"  # a0
+"0102030405060708"  # a1
+"0102030405060708"  # a2
+"0102030405060708"  # a3
+"0102030405060708"  # a4
+"0102030405060708"  # a5
+"0102030405060708"  # a6
+"0102030405060708"  # a7
+"0102030405060708"  # s2
+"0102030405060708"  # s3
+"0102030405060708"  # s4
+"0102030405060708"  # s5
+"0102030405060708"  # s6
+"0102030405060708"  # s7
+"0102030405060708"  # s8
+"0102030405060708"  # s9
+"0102030405060708"  # s10
+"0102030405060708"  # s11
+"0102030405060708"  # t3
+"0102030405060708"  # t4
+"0102030405060708"  # t5
+"0102030405060708"  # t6
+)
+
+def qXferRead(self, obj, annex, offset, length):
+if annex == "target.xml":
+# Note that this XML does not include any aliases, LLDB 
must generate them itself.
+return (
+"""
+
+
+riscv
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+""",
+False,
+)
+else:
+return None, False
+
+def readRegister(self, regnum):
+return ""
+
+def readRegisters(self):
+return self.reg_data
+
+def writeRegisters(self, reg_hex):
+self.reg_data = reg_hex
+return "OK"
+
+def haltReason(self):
+return 
"T02thread:1ff0d;threads:1ff0d;thread-pcs:00010001bc00;07:0102030405060708;10:1112131415161718;"
+
+self.server.responder = MyResponder()
+
+target = self.createTarget("basic_eh_frame-riscv64.yaml")
+process = self.connect(target)
+lldbutil.expect_state_changes(
+self, self.dbg.GetListener(), process, [lldb.eStateStopped]
+)
+
+# test generic aliases
+self.match("register read x0", ["zero = 0x0807060504030201"])
+self.match("register read x1", ["ra = 0x0807060504030201"])
+self.match("register read x2", ["sp = 0x0807060504030201"])
+self.match("register read x3", ["gp = 0x0807060504030201"])
+self.match("register read x4", ["tp = 0x0807060504030201"])
+self.match("register read x5", ["t0 = 0x0807060504030201"])
+self.match("register read x6", ["t1 = 0x0807060504030201"])
+self.match("register read x7", ["t2 = 0x0807060504030201"])
+# Register x8 is probably not working because it has two aliases fp, s0
+# self.match("register read x8", ["fp = 0x0807060504030201"])

DavidSpickett wrote:

I should have been more specific, the issue is p

[Lldb-commits] [lldb] [llvm] [lldb] Extended if conditions to support alias names for registers (PR #124475)

2025-02-20 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett commented:

Address the two new comments and this'll be good to go.

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


[Lldb-commits] [lldb] [llvm] [lldb] Extended if conditions to support alias names for registers (PR #124475)

2025-02-20 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [lldb] Extended if conditions to support alias names for registers (PR #124475)

2025-02-20 Thread David Spickett via lldb-commits


@@ -0,0 +1,37 @@
+# REQUIRES: native && target-riscv64
+# RUN: %clangxx_host %p/Inputs/riscv64-gp-read.cpp -o %t
+# RUN: %lldb -b -s %s %t | FileCheck %s
+process launch
+
+register read --all
+# CHECK-DAG: ra = 0x1
+# CHECK-DAG: sp = 0x2
+# CHECK-DAG: gp = 0x3
+# CHECK-DAG: tp = 0x4
+# CHECK-DAG: t0 = 0x5
+# CHECK-DAG: t1 = 0x6
+# CHECK-DAG: t2 = 0x7
+# CHECK-DAG: s1 = 0x9
+# CHECK-DAG: a0 = 0xa
+# CHECK-DAG: a1 = 0xb
+# CHECK-DAG: a2 = 0xc
+# CHECK-DAG: a3 = 0xd
+# CHECK-DAG: a4 = 0xe
+# CHECK-DAG: a5 = 0xf
+# CHECK-DAG: a6 = 0x10
+# CHECK-DAG: a7 = 0x11
+# CHECK-DAG: s2 = 0x12
+# CHECK-DAG: s3 = 0x13
+# CHECK-DAG: s4 = 0x14
+# CHECK-DAG: s5 = 0x15
+# CHECK-DAG: s6 = 0x16
+# CHECK-DAG: s7 = 0x17
+# CHECK-DAG: s8 = 0x18
+# CHECK-DAG: s9 = 0x19
+# CHECK-DAG: s10 = 0x1a
+# CHECK-DAG: s11 = 0x1b
+# CHECK-DAG: t3 = 0x1c
+# CHECK-DAG: t4 = 0x1d
+# CHECK-DAG: t5 = 0x1e
+# CHECK-DAG: t6 = 0x1f
+# CHECK-DAG: zero = 0x0

DavidSpickett wrote:

This test needs to be reading the default names and the aliases. So I assume 
this first part is all the defaults, then you should add something like 
`register read `.

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


[Lldb-commits] [lldb] [lldb] Fix GCC's `-Wreturn-type` warnings (PR #127974)

2025-02-20 Thread via lldb-commits

https://github.com/foxtran updated 
https://github.com/llvm/llvm-project/pull/127974

>From d36ed841386fbc0662d120eefca076df16bdd880 Mon Sep 17 00:00:00 2001
From: "Igor S. Gerasimov" 
Date: Thu, 20 Feb 2025 10:04:13 +0100
Subject: [PATCH 1/2] Fix GCC's -Wreturn-type warning

---
 lldb/source/DataFormatters/TypeSummary.cpp | 2 ++
 lldb/source/ValueObject/DILLexer.cpp   | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/lldb/source/DataFormatters/TypeSummary.cpp 
b/lldb/source/DataFormatters/TypeSummary.cpp
index 2c863b364538f..fa6953a2ee14c 100644
--- a/lldb/source/DataFormatters/TypeSummary.cpp
+++ b/lldb/source/DataFormatters/TypeSummary.cpp
@@ -58,6 +58,8 @@ std::string TypeSummaryImpl::GetSummaryKindName() {
 return "c++";
   case Kind::eBytecode:
 return "bytecode";
+  default:
+llvm_unreachable("Unknown type kind name");
   }
 }
 
diff --git a/lldb/source/ValueObject/DILLexer.cpp 
b/lldb/source/ValueObject/DILLexer.cpp
index c7acfec347af4..bbb5fafdacbe5 100644
--- a/lldb/source/ValueObject/DILLexer.cpp
+++ b/lldb/source/ValueObject/DILLexer.cpp
@@ -29,6 +29,8 @@ llvm::StringRef Token::GetTokenName(Kind kind) {
 return "l_paren";
   case Kind::r_paren:
 return "r_paren";
+  default:
+llvm_unreachable("Unknown token name");
   }
 }
 

>From 59d7da74b543744c045f41f7d1dd42cd16b08805 Mon Sep 17 00:00:00 2001
From: "Igor S. Gerasimov" 
Date: Thu, 20 Feb 2025 11:19:16 +0100
Subject: [PATCH 2/2] Follow LLVM coding standard

---
 lldb/source/DataFormatters/TypeSummary.cpp | 3 +--
 lldb/source/ValueObject/DILLexer.cpp   | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/lldb/source/DataFormatters/TypeSummary.cpp 
b/lldb/source/DataFormatters/TypeSummary.cpp
index fa6953a2ee14c..18bf81aedf2cb 100644
--- a/lldb/source/DataFormatters/TypeSummary.cpp
+++ b/lldb/source/DataFormatters/TypeSummary.cpp
@@ -58,9 +58,8 @@ std::string TypeSummaryImpl::GetSummaryKindName() {
 return "c++";
   case Kind::eBytecode:
 return "bytecode";
-  default:
-llvm_unreachable("Unknown type kind name");
   }
+  llvm_unreachable("Unknown type kind name");
 }
 
 StringSummaryFormat::StringSummaryFormat(const TypeSummaryImpl::Flags &flags,
diff --git a/lldb/source/ValueObject/DILLexer.cpp 
b/lldb/source/ValueObject/DILLexer.cpp
index bbb5fafdacbe5..1f013288c839b 100644
--- a/lldb/source/ValueObject/DILLexer.cpp
+++ b/lldb/source/ValueObject/DILLexer.cpp
@@ -29,9 +29,8 @@ llvm::StringRef Token::GetTokenName(Kind kind) {
 return "l_paren";
   case Kind::r_paren:
 return "r_paren";
-  default:
-llvm_unreachable("Unknown token name");
   }
+  llvm_unreachable("Unknown token name");
 }
 
 static bool IsLetter(char c) {

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


[Lldb-commits] [lldb] [WIP] [lldb][TypeSystemClang] Create clang::SourceLocation from DWARF and attach to AST (PR #127829)

2025-02-20 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [LLDB][Telemetry]Define DebuggerTelemetryInfo and related methods (PR #127696)

2025-02-20 Thread Pavel Labath via lldb-commits


@@ -761,12 +767,29 @@ void Debugger::InstanceInitialize() {
 
 DebuggerSP Debugger::CreateInstance(lldb::LogOutputCallback log_callback,
 void *baton) {
+#ifdef LLVM_BUILD_TELEMETRY
+  lldb_private::telemetry::SteadyTimePoint start_time =
+  std::chrono::steady_clock::now();
+#endif
   DebuggerSP debugger_sp(new Debugger(log_callback, baton));
   if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) {
 std::lock_guard guard(*g_debugger_list_mutex_ptr);
 g_debugger_list_ptr->push_back(debugger_sp);
   }
   debugger_sp->InstanceInitialize();
+
+#ifdef LLVM_BUILD_TELEMETRY
+  if (auto *telemetry_manager = telemetry::TelemetryManager::getInstance()) {
+if (telemetry_manager->getConfig()->EnableTelemetry) {
+  lldb_private::telemetry::DebuggerTelemetryInfo entry;
+  entry.start_time = start_time;
+  entry.end_time = std::chrono::steady_clock::now();
+  entry.debugger = debugger_sp.get();
+  telemetry_manager->atDebuggerStartup(&entry);
+}
+  }
+#endif

labath wrote:

I would actually argue that the telemetry library (before the cmake flag) was 
very similar to the signposts setup (and all of the other cases where we have 
an external dependency), with the library *itself* being the wrapper: it 
exists, and can be used unconditionally, but unless some other component is 
also available, then it amounts to a slightly sophisticated noop.

Sure, in this case the subject matter is a lot more sensitive, and there are 
some differences in how it works. For example, that this "other component" 
takes the form of a subclass, and that no support for an actual implementation 
exists in this repo, but is rather meant to be added downstream. However, I 
think the principle is the same.

The last point (no actual concrete implementation) also makes me feel like any 
cmake flag would be mostly a placebo (as the only way to make this do something 
is to do it downstream, and at that point, you can always disable/override any 
protections we add here), but if that's what it takes, then that's fine. I 
think anything would be better than `#ifdef`ing everything out, or building 
another wrapper on top of that. I just don't know what kind of a form should 
that take. For example would something like
```
TelemetryManager* getInstance() {
#ifdef TELEMETRY
  return g_instance;
#else
  return nullptr;
#endif
}
```
be sufficient? (if we put that in a header, we should also have a decent chance 
of the compiler dead-stripping all the code which depends on this)

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


[Lldb-commits] [lldb] [LLDB][Telemetry]Define DebuggerTelemetryInfo and related methods (PR #127696)

2025-02-20 Thread Pavel Labath via lldb-commits

labath wrote:

>  I'm trying to figure out how to get that linked only when tests are running 
> and not to the LLDB binary all the time.

I don't think you can do that without building another lldb binary. We actually 
have something like that in the form of the [lldb-test 
binary](https://github.com/llvm/llvm-project/tree/main/lldb/tools/lldb-test). 
It's not an actual lldb, but it links all of the same components, and it 
shouldn't be a big problem to add a new component that's only used in 
lldb-test. I think it would be reasonable to add a new lldb-test sub-command 
which is designed to be used for testing the telemetry backend.

However, it's use tends to be somewhat cumbersome because you have to write 
some code do something, and then also drive that code from the command line. I 
would recommend trying to test as much as possible via the unit tests (which 
are basically can do anything that  lldb-test can, but you don't have to drive 
them from the command line), and use only when you really need an end-to-end 
experience.

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


[Lldb-commits] [lldb] [lldb] Store the return SBValueList in the CommandReturnObject (PR #127566)

2025-02-20 Thread Pavel Labath via lldb-commits

labath wrote:

> > That sort of makes sense, but it doesn't sound like you're planning to do 
> > that soon, so I'm asking about what should we do until (and if) that 
> > happens. The reason I suggested stderr is because that made sense for the 
> > commands I'm thinking of. For example, the expression command can produce a 
> > result and some warnings and fixit-applied notes. I don't know if these 
> > currently go to stderr, but I think it would be okay if they did...
> 
> I don't think it's a good idea for commands to put any of their output 
> anywhere but the command result. Anything that goes to stderr is lost, and 
> particularly if is trying to run their own command loop, so that they are by 
> hand printing the command result, there will be no way to associate that 
> output with the command that produced it.

I see that there's been a misunderstanding. By "stderr" I meant the "stderr 
*of* the CommandReturnObject" (i.e., `CommandReturnObject::m_err_stream`, 
returned by `SBCommandReturnObject::GetError`), not the actual stderr of the 
debugger. So the convention would be that if CommandReturnObject contains a 
variable, then its output (`GetOutput`) would contain a rendering of rendering 
of that variable (and it can be ignored when doing your own printing), but the 
error output (`GetError`) would contain any additional data (like the fixits) 
that can/should be anyway.

I'm sorry about the confusion. Does that sound better?

> We don't dump warnings on successful expression evaluation, though we do 
> print fixits. I would suggest for the near term that if a command that 
> produces a ValueObject returns successfully but with "notes" we should put 
> those notes in the Error object - but still have the state be Success. That 
> would make sense for the warnings and fixits since Adrian has been working on 
> getting the error output into a structured form to better hold compiler 
> warnings and errors.

I sort of like that, particularly as it lets you obtain the diagnostics in a 
structured form, but it also feels kinda wrong because -- if I'm not mistaken 
-- we are currently only setting the error field if we failed to retrieve the 
value. It sounds like it could confuse some code which is not expecting it.

I should also add that I don't really have a horse in this race. I have no plan 
on using this feature any time soon. I'm just thinking about the questions I 
would have if I was trying to implement it (either from the consumer or 
producer end). So it's possible this isn't something that's going to matter in 
practice...

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


[Lldb-commits] [lldb] 2c022e3 - [lldb] Replace LineTable::upper_bound with GetLineEntryIndexRange (#127806)

2025-02-20 Thread via lldb-commits

Author: Pavel Labath
Date: 2025-02-20T10:17:44+01:00
New Revision: 2c022e3617ec9bab3c9ab17464610843563ed9ed

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

LOG: [lldb] Replace LineTable::upper_bound with GetLineEntryIndexRange (#127806)

After (too) much deliberation, I came to the conclusion that this isn't
the right abstraction, as it doesn't behave completely like the standard
upper_bound method. What I really wanted was to get the range of line
entries for a given address range -- so I implement just that.

lower_bound is still useful as a primitive for building other kinds of
lookups.

Added: 


Modified: 
lldb/include/lldb/Symbol/LineTable.h
lldb/source/Symbol/LineTable.cpp
lldb/unittests/Symbol/LineTableTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/LineTable.h 
b/lldb/include/lldb/Symbol/LineTable.h
index f66081b6ee110..c1a973635cdd4 100644
--- a/lldb/include/lldb/Symbol/LineTable.h
+++ b/lldb/include/lldb/Symbol/LineTable.h
@@ -102,18 +102,19 @@ class LineTable {
 
   void GetDescription(Stream *s, Target *target, lldb::DescriptionLevel level);
 
-  /// Helper function for line table iteration. \c lower_bound returns the 
index
-  /// of the first line entry which ends after the given address (i.e., the
-  /// first entry which contains the given address or it comes after it).
-  /// \c upper_bound returns the index of the first line entry which begins on
-  /// or after the given address (i.e., the entry which would come after the
-  /// entry containing the given address, if such an entry exists). Functions
-  /// return GetSize() if there is no such entry. The functions are
-  /// most useful in combination: iterating from lower_bound(a) to
-  /// upper_bound(b) returns all line tables which intersect the half-open
-  /// range [a,b).
+  /// Returns the index of the first line entry which ends after the given
+  /// address (i.e., the first entry which contains the given address or it
+  /// comes after it). Returns GetSize() if there is no such entry.
   uint32_t lower_bound(const Address &so_addr) const;
-  uint32_t upper_bound(const Address &so_addr) const;
+
+  /// Returns the (half-open) range of line entry indexes which overlap the
+  /// given address range. Line entries partially overlapping the range (on
+  /// either side) are included as well. Returns an empty range
+  /// (first==second) pointing to the "right" place in the list if
+  /// there are no such line entries. Empty input ranges always result in an
+  /// empty output range.
+  std::pair
+  GetLineEntryIndexRange(const AddressRange &range) const;
 
   /// Find a line entry that contains the section offset address \a so_addr.
   ///

diff  --git a/lldb/source/Symbol/LineTable.cpp 
b/lldb/source/Symbol/LineTable.cpp
index aae4ab59ff156..c5914a2719cc9 100644
--- a/lldb/source/Symbol/LineTable.cpp
+++ b/lldb/source/Symbol/LineTable.cpp
@@ -206,25 +206,27 @@ uint32_t LineTable::lower_bound(const Address &so_addr) 
const {
   return std::distance(m_entries.begin(), pos);
 }
 
-uint32_t LineTable::upper_bound(const Address &so_addr) const {
-  if (so_addr.GetModule() != m_comp_unit->GetModule())
-return GetSize();
+std::pair
+LineTable::GetLineEntryIndexRange(const AddressRange &range) const {
+  uint32_t first = lower_bound(range.GetBaseAddress());
+  if (first >= GetSize() || range.GetByteSize() == 0)
+return {first, first};
 
   Entry search_entry;
-  search_entry.file_addr = so_addr.GetFileAddress();
-  if (search_entry.file_addr == LLDB_INVALID_ADDRESS)
-return GetSize();
+  search_entry.file_addr =
+  range.GetBaseAddress().GetFileAddress() + range.GetByteSize();
 
-  // This is not a typo. lower_bound returns the first entry which starts on or
-  // after the given address, which is exactly what we want -- *except* if the
-  // entry is a termination entry (in that case, we want the one after it).
+  // lower_bound returns the first entry which starts on or after the given
+  // address, which is exactly what we want -- *except* if the entry is a
+  // termination entry (in that case, we want the one after it).
   auto pos =
-  llvm::lower_bound(m_entries, search_entry, Entry::EntryAddressLessThan);
+  std::lower_bound(std::next(m_entries.begin(), first), m_entries.end(),
+   search_entry, Entry::EntryAddressLessThan);
   if (pos != m_entries.end() && pos->file_addr == search_entry.file_addr &&
   pos->is_terminal_entry)
 ++pos;
 
-  return std::distance(m_entries.begin(), pos);
+  return {first, std::distance(m_entries.begin(), pos)};
 }
 
 bool LineTable::FindLineEntryByAddress(const Address &so_addr,

diff  --git a/lldb/unittests/Symbol/LineTableTest.cpp 
b/lldb/unittests/Symbol/LineTableTest.cpp
index 2fa2913f67f9

[Lldb-commits] [lldb] [lldb] Fix GCC's `-Wreturn-type` warnings (PR #127974)

2025-02-20 Thread Michael Buch via lldb-commits


@@ -58,6 +58,8 @@ std::string TypeSummaryImpl::GetSummaryKindName() {
 return "c++";
   case Kind::eBytecode:
 return "bytecode";
+  case default:
+return "unknown";

Michael137 wrote:

this (and the other case) should probably be `__llvm_unreachable()`?

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


[Lldb-commits] [lldb] [lldb] Replace LineTable::upper_bound with GetLineEntryIndexRange (PR #127806)

2025-02-20 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix GCC's `-Wreturn-type` warnings (PR #127974)

2025-02-20 Thread via lldb-commits

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


[Lldb-commits] [lldb] e264317 - [lldb] Fix RangeDataVector::CombineConsecutiveEntriesWithEqualData (#127059)

2025-02-20 Thread via lldb-commits

Author: Pavel Labath
Date: 2025-02-20T10:25:59+01:00
New Revision: e264317b45163f5c3ba7fc5375dcdecd827fce95

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

LOG: [lldb] Fix RangeDataVector::CombineConsecutiveEntriesWithEqualData 
(#127059)

Function was merging equal data even if they weren't adjecant. This
caused a problem in command-disassemble.s test because the two ranges
describing the function would be merged and "swallow" the function
between them.

This PR copies/adapts the algorithm from
RangeVector::CombineConsecutiveEntries (which does not have the same
problem) and also adds a call to ComputeUpperBounds as moving entries
around invalidates the binary tree. (The lack of this call wasn't
noticed until now either because we were not calling methods which rely
on upper bounds (right now, it's only the ill-named FindEntryIndexes
method), or because we weren't merging anything.

Added: 


Modified: 
lldb/include/lldb/Utility/RangeMap.h
lldb/test/Shell/Commands/command-disassemble.s
lldb/unittests/Utility/RangeMapTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/RangeMap.h 
b/lldb/include/lldb/Utility/RangeMap.h
index 433466eebced8..8af690e813c4a 100644
--- a/lldb/include/lldb/Utility/RangeMap.h
+++ b/lldb/include/lldb/Utility/RangeMap.h
@@ -493,36 +493,27 @@ class RangeDataVector {
 #ifdef ASSERT_RANGEMAP_ARE_SORTED
 assert(IsSorted());
 #endif
-typename Collection::iterator pos;
-typename Collection::iterator end;
-typename Collection::iterator prev;
-bool can_combine = false;
-// First we determine if we can combine any of the Entry objects so we
-// don't end up allocating and making a new collection for no reason
-for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != 
end;
- prev = pos++) {
-  if (prev != end && prev->data == pos->data) {
-can_combine = true;
-break;
-  }
-}
+auto first_intersect = std::adjacent_find(
+m_entries.begin(), m_entries.end(), [](const Entry &a, const Entry &b) 
{
+  return a.DoesAdjoinOrIntersect(b) && a.data == b.data;
+});
 
-// We can combine at least one entry, then we make a new collection and
-// populate it accordingly, and then swap it into place.
-if (can_combine) {
-  Collection minimal_ranges;
-  for (pos = m_entries.begin(), end = m_entries.end(), prev = end;
-   pos != end; prev = pos++) {
-if (prev != end && prev->data == pos->data)
-  minimal_ranges.back().SetRangeEnd(pos->GetRangeEnd());
-else
-  minimal_ranges.push_back(*pos);
-  }
-  // Use the swap technique in case our new vector is much smaller. We must
-  // swap when using the STL because std::vector objects never release or
-  // reduce the memory once it has been allocated/reserved.
-  m_entries.swap(minimal_ranges);
+if (first_intersect == m_entries.end())
+  return;
+
+// We can combine at least one entry. Make a new collection and populate it
+// accordingly, and then swap it into place.
+auto pos = std::next(first_intersect);
+Collection minimal_ranges(m_entries.begin(), pos);
+for (; pos != m_entries.end(); ++pos) {
+  Entry &back = minimal_ranges.back();
+  if (back.DoesAdjoinOrIntersect(*pos) && back.data == pos->data)
+back.SetRangeEnd(std::max(back.GetRangeEnd(), pos->GetRangeEnd()));
+  else
+minimal_ranges.push_back(*pos);
 }
+m_entries.swap(minimal_ranges);
+ComputeUpperBounds(0, m_entries.size());
   }
 
   void Clear() { m_entries.clear(); }

diff  --git a/lldb/test/Shell/Commands/command-disassemble.s 
b/lldb/test/Shell/Commands/command-disassemble.s
index eb84a9ce39d4a..14f416d221231 100644
--- a/lldb/test/Shell/Commands/command-disassemble.s
+++ b/lldb/test/Shell/Commands/command-disassemble.s
@@ -94,8 +94,7 @@
 # CHECK-EMPTY:
 # CHECK-NEXT: command-disassemble.s.tmp`n2::case3:
 # CHECK-NEXT: command-disassemble.s.tmp[0x9046] <+0>: jmp 0x6046 ; <-12288>
-## FIXME: This should resolve to `middle_of_case3`
-# CHECK-NEXT: command-disassemble.s.tmp[0x904b] <+5>: jmp 0x7046 ; n2::case3 - 
8192
+# CHECK-NEXT: command-disassemble.s.tmp[0x904b] <+5>: jmp 0x7046 ; 
middle_of_case3
 # CHECK-NEXT: command-disassemble.s.tmp[0x9050] <+10>: int$0x2a
 # CHECK-EMPTY:
 # CHECK-NEXT: command-disassemble.s.tmp`n1::case3:

diff  --git a/lldb/unittests/Utility/RangeMapTest.cpp 
b/lldb/unittests/Utility/RangeMapTest.cpp
index 981fa2a7d1c34..2022a2374fb8d 100644
--- a/lldb/unittests/Utility/RangeMapTest.cpp
+++ b/lldb/unittests/Utility/RangeMapTest.cpp
@@ -238,3 +238,24 @@ TEST(RangeDataVector, FindEntryIndexesThatContain_Overlap) 
{
   EXPECT_THAT(FindEntryIndexes(39, Map), testing::Ele

[Lldb-commits] [lldb] [lldb] Fix RangeDataVector::CombineConsecutiveEntriesWithEqualData (PR #127059)

2025-02-20 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix GCC's `-Wreturn-type` warnings (PR #127974)

2025-02-20 Thread via lldb-commits

https://github.com/foxtran updated 
https://github.com/llvm/llvm-project/pull/127974

>From c51a54691108320a41037c12473ad2b5c2a7be34 Mon Sep 17 00:00:00 2001
From: "Igor S. Gerasimov" 
Date: Thu, 20 Feb 2025 10:04:13 +0100
Subject: [PATCH] Fix GCC's -Wreturn-type warning

---
 lldb/source/DataFormatters/TypeSummary.cpp | 2 ++
 lldb/source/ValueObject/DILLexer.cpp   | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/lldb/source/DataFormatters/TypeSummary.cpp 
b/lldb/source/DataFormatters/TypeSummary.cpp
index 2c863b364538f..d18fca12fcdff 100644
--- a/lldb/source/DataFormatters/TypeSummary.cpp
+++ b/lldb/source/DataFormatters/TypeSummary.cpp
@@ -58,6 +58,8 @@ std::string TypeSummaryImpl::GetSummaryKindName() {
 return "c++";
   case Kind::eBytecode:
 return "bytecode";
+  case default:
+llvm_unreachable("Unknown type kind name");
   }
 }
 
diff --git a/lldb/source/ValueObject/DILLexer.cpp 
b/lldb/source/ValueObject/DILLexer.cpp
index c7acfec347af4..bbb5fafdacbe5 100644
--- a/lldb/source/ValueObject/DILLexer.cpp
+++ b/lldb/source/ValueObject/DILLexer.cpp
@@ -29,6 +29,8 @@ llvm::StringRef Token::GetTokenName(Kind kind) {
 return "l_paren";
   case Kind::r_paren:
 return "r_paren";
+  default:
+llvm_unreachable("Unknown token name");
   }
 }
 

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


[Lldb-commits] [lldb] [lldb] Fix GCC's `-Wreturn-type` warnings (PR #127974)

2025-02-20 Thread via lldb-commits


@@ -58,6 +58,8 @@ std::string TypeSummaryImpl::GetSummaryKindName() {
 return "c++";
   case Kind::eBytecode:
 return "bytecode";
+  case default:
+return "unknown";

foxtran wrote:

Wow! Thank you! It is much better :-)

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


[Lldb-commits] [lldb] [LLDB-DAP] SBDebugger don't prefix title on progress updates (PR #124648)

2025-02-20 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
darker --check --diff -r 
5ecce45ea2980aff35d1283d4dd3feb8f74de16c...02dcf893c3b777acc3b5989c421fda0df3596bba
 lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py 
lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
``





View the diff from darker here.


``diff
--- Progress_emitter.py 2025-02-20 22:47:09.00 +
+++ Progress_emitter.py 2025-02-20 22:51:29.744012 +
@@ -83,11 +83,13 @@
 if total is None:
 progress = lldb.SBProgress(
 "Progress tester", "Initial Indeterminate Detail", debugger
 )
 else:
-progress = lldb.SBProgress("Progress tester", "Initial Detail", 
total, debugger)
+progress = lldb.SBProgress(
+"Progress tester", "Initial Detail", total, debugger
+)
 
 # Check to see if total is set to None to indicate an indeterminate 
progress
 # then default to 10 steps.
 if total is None:
 total = 10

``




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


[Lldb-commits] [lldb] Reland "[lldb] Implement basic support for reverse-continue" (#123906)" (PR #123945)

2025-02-20 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

> greendragon probably does build debugserver, but tests use Xcode's 
> debugserver for proper codesigning, not the built debugserver.

Are you sure? My recollection is that we went out of our way to make code 
signing work on those bots.

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


[Lldb-commits] [lldb] [llvm] [lldb][LoongArch] Complete register alias name in `AugmentRegisterInfo` (PR #124059)

2025-02-20 Thread via lldb-commits

https://github.com/wangleiat updated 
https://github.com/llvm/llvm-project/pull/124059

>From f404df6b2ac7b7ab33e3baadd3830154904a Mon Sep 17 00:00:00 2001
From: Ray Wang 
Date: Thu, 23 Jan 2025 12:13:32 +0800
Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.5-bogner
---
 .../ABI/LoongArch/ABISysV_loongarch.cpp   | 38 +++
 1 file changed, 14 insertions(+), 24 deletions(-)

diff --git a/lldb/source/Plugins/ABI/LoongArch/ABISysV_loongarch.cpp 
b/lldb/source/Plugins/ABI/LoongArch/ABISysV_loongarch.cpp
index dc7e9bba00067..272c6a6be529f 100644
--- a/lldb/source/Plugins/ABI/LoongArch/ABISysV_loongarch.cpp
+++ b/lldb/source/Plugins/ABI/LoongArch/ABISysV_loongarch.cpp
@@ -644,32 +644,22 @@ void ABISysV_loongarch::AugmentRegisterInfo(
 std::vector ®s) {
   lldb_private::RegInfoBasedABI::AugmentRegisterInfo(regs);
 
+  static const std::unordered_map reg_aliases = {
+  {"r0", "zero"}, {"r1", "ra"},  {"r2", "tp"},  {"r3", "sp"},
+  {"r4", "a0"},   {"r5", "a1"},  {"r6", "a2"},  {"r7", "a3"},
+  {"r8", "a4"},   {"r9", "a5"},  {"r10", "a6"}, {"r11", "a7"},
+  {"r12", "t0"},  {"r13", "t1"}, {"r14", "t2"}, {"r15", "t3"},
+  {"r16", "t4"},  {"r17", "t5"}, {"r18", "t6"}, {"r19", "t7"},
+  {"r20", "t8"},  {"r22", "fp"}, {"r23", "s0"}, {"r24", "s1"},
+  {"r25", "s2"},  {"r26", "s3"}, {"r27", "s4"}, {"r28", "s5"},
+  {"r29", "s6"},  {"r30", "s7"}, {"r31", "s8"}};
+
   for (auto it : llvm::enumerate(regs)) {
 // Set alt name for certain registers for convenience
-if (it.value().name == "r0")
-  it.value().alt_name.SetCString("zero");
-else if (it.value().name == "r1")
-  it.value().alt_name.SetCString("ra");
-else if (it.value().name == "r3")
-  it.value().alt_name.SetCString("sp");
-else if (it.value().name == "r22")
-  it.value().alt_name.SetCString("fp");
-else if (it.value().name == "r4")
-  it.value().alt_name.SetCString("a0");
-else if (it.value().name == "r5")
-  it.value().alt_name.SetCString("a1");
-else if (it.value().name == "r6")
-  it.value().alt_name.SetCString("a2");
-else if (it.value().name == "r7")
-  it.value().alt_name.SetCString("a3");
-else if (it.value().name == "r8")
-  it.value().alt_name.SetCString("a4");
-else if (it.value().name == "r9")
-  it.value().alt_name.SetCString("a5");
-else if (it.value().name == "r10")
-  it.value().alt_name.SetCString("a6");
-else if (it.value().name == "r11")
-  it.value().alt_name.SetCString("a7");
+std::string reg_name = it.value().name.GetStringRef().str();
+if (auto alias = reg_aliases.find(reg_name); alias != reg_aliases.end()) {
+  it.value().alt_name.SetCString(alias->second.c_str());
+}
 
 // Set generic regnum so lldb knows what the PC, etc is
 it.value().regnum_generic = GetGenericNum(it.value().name.GetStringRef());

>From d03f4f2b191c09d6492249aa5e0d50fc62a5a434 Mon Sep 17 00:00:00 2001
From: Ray Wang 
Date: Wed, 5 Feb 2025 17:58:09 +0800
Subject: [PATCH 2/3] add test

Created using spr 1.3.5-bogner
---
 .../postmortem/elf-core/TestLinuxCore.py  | 82 ++-
 1 file changed, 44 insertions(+), 38 deletions(-)

diff --git a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py 
b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
index 376d6492d83b6..adabac106f3e3 100644
--- a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
+++ b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
@@ -642,8 +642,7 @@ def test_aarch64_sve_regs_full(self):
 )
 # RMode should have enumerator descriptions.
 self.expect(
-"register info fpcr",
-substrs=["RMode: 0 = RN, 1 = RP, 2 = RM, 3 = RZ"],
+"register info fpcr", substrs=["RMode: 0 = RN, 1 = RP, 2 = RM, 3 = 
RZ"]
 )
 
 @skipIfLLVMTargetMissing("AArch64")
@@ -852,41 +851,42 @@ def test_loongarch64_regs(self):
 self.assertTrue(target, VALID_TARGET)
 process = target.LoadCore("linux-loongarch64.core")
 
-values = {}
-values["r0"] = "0x"
-values["r1"] = "0x0001216c"
-values["r2"] = "0x"
-values["r3"] = "0x7b8249e0"
-values["r4"] = "0x"
-values["r5"] = "0x0001210c"
-values["r6"] = "0x"
-values["r7"] = "0x"
-values["r8"] = "0x"
-values["r9"] = "0x"
-values["r10"] = "0x"
-values["r11"] = "0x00dd"
-values["r12"] = "0x"
-values["r13"] = "0x002f"
-values["r14"] = "0x"
-values["r15"] = "0x

[Lldb-commits] [lldb] [llvm] [lldb][LoongArch] Complete register alias name in `AugmentRegisterInfo` (PR #124059)

2025-02-20 Thread via lldb-commits


@@ -0,0 +1,35 @@
+int main() {
+  asm volatile("li.w $r1, 1\n\t"

wangleiat wrote:

Thanks.

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


[Lldb-commits] [lldb] [LLDB-DAP] SBDebugger don't prefix title on progress updates (PR #124648)

2025-02-20 Thread Jacob Lalonde via lldb-commits

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

>From 12ff645735c1dbf51e58b9f80d4e3e13a0babdf5 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Mon, 27 Jan 2025 13:41:58 -0800
Subject: [PATCH 1/9] Only include title on the first message

---
 lldb/include/lldb/Core/DebuggerEvents.h | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/lldb/include/lldb/Core/DebuggerEvents.h 
b/lldb/include/lldb/Core/DebuggerEvents.h
index 49a4ecf8e537e..52e4f77d7637d 100644
--- a/lldb/include/lldb/Core/DebuggerEvents.h
+++ b/lldb/include/lldb/Core/DebuggerEvents.h
@@ -44,12 +44,15 @@ class ProgressEventData : public EventData {
   uint64_t GetCompleted() const { return m_completed; }
   uint64_t GetTotal() const { return m_total; }
   std::string GetMessage() const {
-std::string message = m_title;
-if (!m_details.empty()) {
-  message.append(": ");
-  message.append(m_details);
-}
-return message;
+if (m_completed == 0) {
+  std::string message = m_title;
+  if (!m_details.empty()) {
+message.append(": ");
+message.append(m_details);
+  }
+  return message;
+} else
+  return !m_details.empty() ? m_details : std::string();
   }
   const std::string &GetTitle() const { return m_title; }
   const std::string &GetDetails() const { return m_details; }

>From 82ed76ae3b6bef176bf54dd1031f0cb9c95081c1 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Mon, 27 Jan 2025 14:48:01 -0800
Subject: [PATCH 2/9] Add comment explaining if and add a test

---
 lldb/include/lldb/Core/DebuggerEvents.h   | 1 +
 lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py | 5 +
 2 files changed, 6 insertions(+)

diff --git a/lldb/include/lldb/Core/DebuggerEvents.h 
b/lldb/include/lldb/Core/DebuggerEvents.h
index 52e4f77d7637d..ca06ee835fde3 100644
--- a/lldb/include/lldb/Core/DebuggerEvents.h
+++ b/lldb/include/lldb/Core/DebuggerEvents.h
@@ -44,6 +44,7 @@ class ProgressEventData : public EventData {
   uint64_t GetCompleted() const { return m_completed; }
   uint64_t GetTotal() const { return m_total; }
   std::string GetMessage() const {
+// Only put the title in the message of the progress create event.
 if (m_completed == 0) {
   std::string message = m_title;
   if (!m_details.empty()) {
diff --git a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py 
b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
index 36c0cef9c4714..945c3f7633364 100755
--- a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
+++ b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
@@ -41,8 +41,13 @@ def test_output(self):
 for event in self.dap_server.progress_events:
 event_type = event["event"]
 if "progressStart" in event_type:
+title = event["body"]["title"]
+self.assertIn("Progress tester", title)
 start_found = True
 if "progressUpdate" in event_type:
+message = event["body"]["message"]
+print(f"Progress update: {message}")
+self.assertNotIn("Progres tester", message)
 update_found = True
 
 self.assertTrue(start_found)

>From e15090782a93e07e8a260a0594ca02430e68e09f Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Thu, 30 Jan 2025 10:04:04 -0800
Subject: [PATCH 3/9] Migrate to structured data

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:


Differential Revision: https://phabricator.intern.facebook.com/D68927453
---
 lldb/include/lldb/Core/DebuggerEvents.h | 16 +++-
 lldb/tools/lldb-dap/lldb-dap.cpp| 54 +
 2 files changed, 52 insertions(+), 18 deletions(-)

diff --git a/lldb/include/lldb/Core/DebuggerEvents.h 
b/lldb/include/lldb/Core/DebuggerEvents.h
index ca06ee835fde3..49a4ecf8e537e 100644
--- a/lldb/include/lldb/Core/DebuggerEvents.h
+++ b/lldb/include/lldb/Core/DebuggerEvents.h
@@ -44,16 +44,12 @@ class ProgressEventData : public EventData {
   uint64_t GetCompleted() const { return m_completed; }
   uint64_t GetTotal() const { return m_total; }
   std::string GetMessage() const {
-// Only put the title in the message of the progress create event.
-if (m_completed == 0) {
-  std::string message = m_title;
-  if (!m_details.empty()) {
-message.append(": ");
-message.append(m_details);
-  }
-  return message;
-} else
-  return !m_details.empty() ? m_details : std::string();
+std::string message = m_title;
+if (!m_details.empty()) {
+  message.append(": ");
+  message.append(m_details);
+}
+return message;
   }
   const std::string &GetTitle() const { return m_title; }
   const std::string &GetDetails() const { return m_details; }
diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp
index e323990d8b6ed..4b3460190a7c9 100644
--- a/lldb/tools/lldb

[Lldb-commits] [lldb] [LLDB][Telemetry]Define DebuggerTelemetryInfo and related methods (PR #127696)

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


@@ -761,12 +767,29 @@ void Debugger::InstanceInitialize() {
 
 DebuggerSP Debugger::CreateInstance(lldb::LogOutputCallback log_callback,
 void *baton) {
+#ifdef LLVM_BUILD_TELEMETRY
+  lldb_private::telemetry::SteadyTimePoint start_time =
+  std::chrono::steady_clock::now();
+#endif

oontvoo wrote:

(NOT done - this is pending the result of whether we'd revert the ifdef 
approach and instead just make the cmake variable control 
llvm::telemetry::Config::EnableTelemetry)

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


[Lldb-commits] [lldb] 89e80ab - [lldb][LoongArch] Complete register alias name in `AugmentRegisterInfo`

2025-02-20 Thread via lldb-commits

Author: wanglei
Date: 2025-02-21T10:59:27+08:00
New Revision: 89e80abbc58b5d92f3a0eaa393a0b095aac11ec2

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

LOG: [lldb][LoongArch] Complete register alias name in `AugmentRegisterInfo`

Fixes: https://github.com/llvm/llvm-project/issues/123903

Reviewed By: DavidSpickett, SixWeining

Pull Request: https://github.com/llvm/llvm-project/pull/124059

Added: 
lldb/test/Shell/Register/Inputs/loongarch64-gp-read.cpp
lldb/test/Shell/Register/loongarch64-gp-read.test

Modified: 
lldb/source/Plugins/ABI/LoongArch/ABISysV_loongarch.cpp
lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
llvm/utils/lit/lit/llvm/config.py

Removed: 




diff  --git a/lldb/source/Plugins/ABI/LoongArch/ABISysV_loongarch.cpp 
b/lldb/source/Plugins/ABI/LoongArch/ABISysV_loongarch.cpp
index dc7e9bba00067..b8d40501ec13a 100644
--- a/lldb/source/Plugins/ABI/LoongArch/ABISysV_loongarch.cpp
+++ b/lldb/source/Plugins/ABI/LoongArch/ABISysV_loongarch.cpp
@@ -12,6 +12,7 @@
 #include 
 #include 
 
+#include "llvm/ADT/StringRef.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/Support/MathExtras.h"
 
@@ -644,34 +645,25 @@ void ABISysV_loongarch::AugmentRegisterInfo(
 std::vector ®s) {
   lldb_private::RegInfoBasedABI::AugmentRegisterInfo(regs);
 
+  static const llvm::StringMap isa_to_abi_alias_map = {
+  {"r0", "zero"}, {"r1", "ra"},  {"r2", "tp"},  {"r3", "sp"},
+  {"r4", "a0"},   {"r5", "a1"},  {"r6", "a2"},  {"r7", "a3"},
+  {"r8", "a4"},   {"r9", "a5"},  {"r10", "a6"}, {"r11", "a7"},
+  {"r12", "t0"},  {"r13", "t1"}, {"r14", "t2"}, {"r15", "t3"},
+  {"r16", "t4"},  {"r17", "t5"}, {"r18", "t6"}, {"r19", "t7"},
+  {"r20", "t8"},  {"r22", "fp"}, {"r23", "s0"}, {"r24", "s1"},
+  {"r25", "s2"},  {"r26", "s3"}, {"r27", "s4"}, {"r28", "s5"},
+  {"r29", "s6"},  {"r30", "s7"}, {"r31", "s8"}};
+
   for (auto it : llvm::enumerate(regs)) {
+llvm::StringRef reg_name = it.value().name.GetStringRef();
+
 // Set alt name for certain registers for convenience
-if (it.value().name == "r0")
-  it.value().alt_name.SetCString("zero");
-else if (it.value().name == "r1")
-  it.value().alt_name.SetCString("ra");
-else if (it.value().name == "r3")
-  it.value().alt_name.SetCString("sp");
-else if (it.value().name == "r22")
-  it.value().alt_name.SetCString("fp");
-else if (it.value().name == "r4")
-  it.value().alt_name.SetCString("a0");
-else if (it.value().name == "r5")
-  it.value().alt_name.SetCString("a1");
-else if (it.value().name == "r6")
-  it.value().alt_name.SetCString("a2");
-else if (it.value().name == "r7")
-  it.value().alt_name.SetCString("a3");
-else if (it.value().name == "r8")
-  it.value().alt_name.SetCString("a4");
-else if (it.value().name == "r9")
-  it.value().alt_name.SetCString("a5");
-else if (it.value().name == "r10")
-  it.value().alt_name.SetCString("a6");
-else if (it.value().name == "r11")
-  it.value().alt_name.SetCString("a7");
+llvm::StringRef alias_name = isa_to_abi_alias_map.lookup(reg_name);
+if (!alias_name.empty())
+  it.value().alt_name.SetString(alias_name);
 
 // Set generic regnum so lldb knows what the PC, etc is
-it.value().regnum_generic = GetGenericNum(it.value().name.GetStringRef());
+it.value().regnum_generic = GetGenericNum(reg_name);
   }
 }

diff  --git 
a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py 
b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
index 60caedf4737da..a287fd19ba352 100644
--- a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
+++ b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
@@ -866,41 +866,42 @@ def test_loongarch64_regs(self):
 self.assertTrue(target, VALID_TARGET)
 process = target.LoadCore("linux-loongarch64.core")
 
-values = {}
-values["r0"] = "0x"
-values["r1"] = "0x0001216c"
-values["r2"] = "0x"
-values["r3"] = "0x7b8249e0"
-values["r4"] = "0x"
-values["r5"] = "0x0001210c"
-values["r6"] = "0x"
-values["r7"] = "0x"
-values["r8"] = "0x"
-values["r9"] = "0x"
-values["r10"] = "0x"
-values["r11"] = "0x00dd"
-values["r12"] = "0x"
-values["r13"] = "0x002f"
-values["r14"] = "0x"
-values["r15"] = "0x"
-values["r16"] = "0x"
-values["r17"] = "0x

[Lldb-commits] [lldb] [llvm] [lldb][LoongArch] Complete register alias name in `AugmentRegisterInfo` (PR #124059)

2025-02-20 Thread via lldb-commits

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


[Lldb-commits] [lldb] [LLDB-DAP] SBDebugger don't prefix title on progress updates (PR #124648)

2025-02-20 Thread Jacob Lalonde via lldb-commits

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

>From 12ff645735c1dbf51e58b9f80d4e3e13a0babdf5 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Mon, 27 Jan 2025 13:41:58 -0800
Subject: [PATCH 1/8] Only include title on the first message

---
 lldb/include/lldb/Core/DebuggerEvents.h | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/lldb/include/lldb/Core/DebuggerEvents.h 
b/lldb/include/lldb/Core/DebuggerEvents.h
index 49a4ecf8e537e..52e4f77d7637d 100644
--- a/lldb/include/lldb/Core/DebuggerEvents.h
+++ b/lldb/include/lldb/Core/DebuggerEvents.h
@@ -44,12 +44,15 @@ class ProgressEventData : public EventData {
   uint64_t GetCompleted() const { return m_completed; }
   uint64_t GetTotal() const { return m_total; }
   std::string GetMessage() const {
-std::string message = m_title;
-if (!m_details.empty()) {
-  message.append(": ");
-  message.append(m_details);
-}
-return message;
+if (m_completed == 0) {
+  std::string message = m_title;
+  if (!m_details.empty()) {
+message.append(": ");
+message.append(m_details);
+  }
+  return message;
+} else
+  return !m_details.empty() ? m_details : std::string();
   }
   const std::string &GetTitle() const { return m_title; }
   const std::string &GetDetails() const { return m_details; }

>From 82ed76ae3b6bef176bf54dd1031f0cb9c95081c1 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Mon, 27 Jan 2025 14:48:01 -0800
Subject: [PATCH 2/8] Add comment explaining if and add a test

---
 lldb/include/lldb/Core/DebuggerEvents.h   | 1 +
 lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py | 5 +
 2 files changed, 6 insertions(+)

diff --git a/lldb/include/lldb/Core/DebuggerEvents.h 
b/lldb/include/lldb/Core/DebuggerEvents.h
index 52e4f77d7637d..ca06ee835fde3 100644
--- a/lldb/include/lldb/Core/DebuggerEvents.h
+++ b/lldb/include/lldb/Core/DebuggerEvents.h
@@ -44,6 +44,7 @@ class ProgressEventData : public EventData {
   uint64_t GetCompleted() const { return m_completed; }
   uint64_t GetTotal() const { return m_total; }
   std::string GetMessage() const {
+// Only put the title in the message of the progress create event.
 if (m_completed == 0) {
   std::string message = m_title;
   if (!m_details.empty()) {
diff --git a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py 
b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
index 36c0cef9c4714..945c3f7633364 100755
--- a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
+++ b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
@@ -41,8 +41,13 @@ def test_output(self):
 for event in self.dap_server.progress_events:
 event_type = event["event"]
 if "progressStart" in event_type:
+title = event["body"]["title"]
+self.assertIn("Progress tester", title)
 start_found = True
 if "progressUpdate" in event_type:
+message = event["body"]["message"]
+print(f"Progress update: {message}")
+self.assertNotIn("Progres tester", message)
 update_found = True
 
 self.assertTrue(start_found)

>From e15090782a93e07e8a260a0594ca02430e68e09f Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Thu, 30 Jan 2025 10:04:04 -0800
Subject: [PATCH 3/8] Migrate to structured data

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:


Differential Revision: https://phabricator.intern.facebook.com/D68927453
---
 lldb/include/lldb/Core/DebuggerEvents.h | 16 +++-
 lldb/tools/lldb-dap/lldb-dap.cpp| 54 +
 2 files changed, 52 insertions(+), 18 deletions(-)

diff --git a/lldb/include/lldb/Core/DebuggerEvents.h 
b/lldb/include/lldb/Core/DebuggerEvents.h
index ca06ee835fde3..49a4ecf8e537e 100644
--- a/lldb/include/lldb/Core/DebuggerEvents.h
+++ b/lldb/include/lldb/Core/DebuggerEvents.h
@@ -44,16 +44,12 @@ class ProgressEventData : public EventData {
   uint64_t GetCompleted() const { return m_completed; }
   uint64_t GetTotal() const { return m_total; }
   std::string GetMessage() const {
-// Only put the title in the message of the progress create event.
-if (m_completed == 0) {
-  std::string message = m_title;
-  if (!m_details.empty()) {
-message.append(": ");
-message.append(m_details);
-  }
-  return message;
-} else
-  return !m_details.empty() ? m_details : std::string();
+std::string message = m_title;
+if (!m_details.empty()) {
+  message.append(": ");
+  message.append(m_details);
+}
+return message;
   }
   const std::string &GetTitle() const { return m_title; }
   const std::string &GetDetails() const { return m_details; }
diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp
index e323990d8b6ed..4b3460190a7c9 100644
--- a/lldb/tools/lldb

[Lldb-commits] [lldb] Allow option to ignore module load errors in ScriptedProcess (PR #127153)

2025-02-20 Thread via lldb-commits


@@ -46,22 +46,82 @@ def __init__(self, exe_ctx: lldb.SBExecutionContext, args: 
lldb.SBStructuredData
 if len(self.threads) == 2:
 self.threads[len(self.threads) - 1].is_stopped = True
 
-corefile_module = self.get_module_with_name(
-self.corefile_target, "libbaz.dylib"
-)
-if not corefile_module or not corefile_module.IsValid():
-return
-module_path = os.path.join(
-corefile_module.GetFileSpec().GetDirectory(),
-corefile_module.GetFileSpec().GetFilename(),
-)
-if not os.path.exists(module_path):
-return
-module_load_addr = 
corefile_module.GetObjectFileHeaderAddress().GetLoadAddress(
-self.corefile_target
-)
+custom_modules = args.GetValueForKey("custom_modules")
+if custom_modules.GetType() == lldb.eStructuredDataTypeArray:
+for id in range(custom_modules.GetSize()):
+
+custom_module = custom_modules.GetItemAtIndex(id)
+if (
+not custom_module
+or not custom_module.IsValid()
+or not custom_module.GetType() == 
lldb.eStructuredDataTypeDictionary
+):
+continue
+
+# Get custom module path from args
+module_path_arg = custom_module.GetValueForKey("path")
+module_path = None
+if (
+not module_path_arg
+or not module_path_arg.IsValid()
+or not module_path_arg.GetType() == 
lldb.eStructuredDataTypeString
+):
+return
+
+module_path = module_path_arg.GetStringValue(100)
+module_name = os.path.basename(module_path)
+
+# Get ignore_module_load_error boolean from args
+ignore_module_load_error = False
+ignore_module_load_error_arg = custom_module.GetValueForKey(
+"ignore_module_load_error"
+)
+if (
+ignore_module_load_error_arg
+and ignore_module_load_error_arg.IsValid()
+and ignore_module_load_error_arg.GetType()
+== lldb.eStructuredDataTypeBoolean
+):
+ignore_module_load_error = (
+ignore_module_load_error_arg.GetBooleanValue()
+)
 
-self.loaded_images.append({"path": module_path, "load_addr": 
module_load_addr})
+if not os.path.exists(module_path) and not 
ignore_module_load_error:
+return
+
+# Get custom module load address from args
+module_load_addr = None
+module_load_addr_arg = 
custom_module.GetValueForKey("load_addr")
+if (
+module_load_addr_arg
+and module_load_addr_arg.IsValid()
+and module_load_addr_arg.GetType()
+== lldb.eStructuredDataTypeInteger
+):
+module_load_addr = module_load_addr_arg.GetIntegerValue()
+
+# If module load address is not specified/valid, try to find 
it from corefile module
+if module_load_addr is None:
+corefile_module = self.get_module_with_name(
+self.corefile_target, module_name
+)
+
+if not corefile_module or not corefile_module.IsValid():
+return
+
+module_load_addr = (
+
corefile_module.GetObjectFileHeaderAddress().GetLoadAddress(
+self.corefile_target
+)
+)

rchamala wrote:

 The current test logic is hardcoded to find a single module named 
"libbaz.dylib" and get load address from corefile_module. I was hoping to have 
a test that accepts different modules given module path and module load address 
from the caller. If it is not given, I was planning to get the load address 
from `corefile_module` similar to how the current test is doing. Lmk if that 
sounds fine

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


[Lldb-commits] [lldb] Allow option to ignore module load errors in ScriptedProcess (PR #127153)

2025-02-20 Thread via lldb-commits


@@ -165,7 +165,7 @@ Status ScriptedProcess::DoLoadCore() {
 Status ScriptedProcess::DoLaunch(Module *exe_module,
  ProcessLaunchInfo &launch_info) {
   LLDB_LOGF(GetLog(LLDBLog::Process), "ScriptedProcess::%s launching process", 
__FUNCTION__);
-  
+

rchamala wrote:

For some reason, `git clang` showed this. Not sure if the previous change was 
submitted with the whitespace, I have just let it be for now

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


[Lldb-commits] [lldb] Allow option to ignore module load errors in ScriptedProcess (PR #127153)

2025-02-20 Thread via lldb-commits


@@ -46,22 +46,82 @@ def __init__(self, exe_ctx: lldb.SBExecutionContext, args: 
lldb.SBStructuredData
 if len(self.threads) == 2:
 self.threads[len(self.threads) - 1].is_stopped = True
 
-corefile_module = self.get_module_with_name(
-self.corefile_target, "libbaz.dylib"
-)
-if not corefile_module or not corefile_module.IsValid():
-return
-module_path = os.path.join(
-corefile_module.GetFileSpec().GetDirectory(),
-corefile_module.GetFileSpec().GetFilename(),
-)
-if not os.path.exists(module_path):
-return
-module_load_addr = 
corefile_module.GetObjectFileHeaderAddress().GetLoadAddress(
-self.corefile_target
-)
+custom_modules = args.GetValueForKey("custom_modules")
+if custom_modules.GetType() == lldb.eStructuredDataTypeArray:
+for id in range(custom_modules.GetSize()):
+
+custom_module = custom_modules.GetItemAtIndex(id)
+if (
+not custom_module
+or not custom_module.IsValid()
+or not custom_module.GetType() == 
lldb.eStructuredDataTypeDictionary
+):
+continue
+
+# Get custom module path from args
+module_path_arg = custom_module.GetValueForKey("path")
+module_path = None
+if (
+not module_path_arg
+or not module_path_arg.IsValid()
+or not module_path_arg.GetType() == 
lldb.eStructuredDataTypeString
+):
+return
+
+module_path = module_path_arg.GetStringValue(100)
+module_name = os.path.basename(module_path)
+
+# Get ignore_module_load_error boolean from args
+ignore_module_load_error = False
+ignore_module_load_error_arg = custom_module.GetValueForKey(
+"ignore_module_load_error"
+)
+if (
+ignore_module_load_error_arg
+and ignore_module_load_error_arg.IsValid()
+and ignore_module_load_error_arg.GetType()
+== lldb.eStructuredDataTypeBoolean
+):
+ignore_module_load_error = (
+ignore_module_load_error_arg.GetBooleanValue()
+)

rchamala wrote:

Yes, will remove it

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


[Lldb-commits] [lldb] Allow option to ignore module load errors in ScriptedProcess (PR #127153)

2025-02-20 Thread Med Ismail Bennani via lldb-commits


@@ -46,22 +46,82 @@ def __init__(self, exe_ctx: lldb.SBExecutionContext, args: 
lldb.SBStructuredData
 if len(self.threads) == 2:
 self.threads[len(self.threads) - 1].is_stopped = True
 
-corefile_module = self.get_module_with_name(
-self.corefile_target, "libbaz.dylib"
-)
-if not corefile_module or not corefile_module.IsValid():
-return
-module_path = os.path.join(
-corefile_module.GetFileSpec().GetDirectory(),
-corefile_module.GetFileSpec().GetFilename(),
-)
-if not os.path.exists(module_path):
-return
-module_load_addr = 
corefile_module.GetObjectFileHeaderAddress().GetLoadAddress(
-self.corefile_target
-)
+custom_modules = args.GetValueForKey("custom_modules")
+if custom_modules.GetType() == lldb.eStructuredDataTypeArray:
+for id in range(custom_modules.GetSize()):
+
+custom_module = custom_modules.GetItemAtIndex(id)
+if (
+not custom_module
+or not custom_module.IsValid()
+or not custom_module.GetType() == 
lldb.eStructuredDataTypeDictionary
+):
+continue
+
+# Get custom module path from args
+module_path_arg = custom_module.GetValueForKey("path")
+module_path = None
+if (
+not module_path_arg
+or not module_path_arg.IsValid()
+or not module_path_arg.GetType() == 
lldb.eStructuredDataTypeString
+):
+return
+
+module_path = module_path_arg.GetStringValue(100)
+module_name = os.path.basename(module_path)
+
+# Get ignore_module_load_error boolean from args
+ignore_module_load_error = False
+ignore_module_load_error_arg = custom_module.GetValueForKey(
+"ignore_module_load_error"
+)
+if (
+ignore_module_load_error_arg
+and ignore_module_load_error_arg.IsValid()
+and ignore_module_load_error_arg.GetType()
+== lldb.eStructuredDataTypeBoolean
+):
+ignore_module_load_error = (
+ignore_module_load_error_arg.GetBooleanValue()
+)
 
-self.loaded_images.append({"path": module_path, "load_addr": 
module_load_addr})
+if not os.path.exists(module_path) and not 
ignore_module_load_error:
+return
+
+# Get custom module load address from args
+module_load_addr = None
+module_load_addr_arg = 
custom_module.GetValueForKey("load_addr")
+if (
+module_load_addr_arg
+and module_load_addr_arg.IsValid()
+and module_load_addr_arg.GetType()
+== lldb.eStructuredDataTypeInteger
+):
+module_load_addr = module_load_addr_arg.GetIntegerValue()
+
+# If module load address is not specified/valid, try to find 
it from corefile module
+if module_load_addr is None:
+corefile_module = self.get_module_with_name(
+self.corefile_target, module_name
+)
+
+if not corefile_module or not corefile_module.IsValid():
+return
+
+module_load_addr = (
+
corefile_module.GetObjectFileHeaderAddress().GetLoadAddress(
+self.corefile_target
+)
+)

medismailben wrote:

Fair, the reason I mentioned this is because I wanted to exercise the error 
handling code path in C++ rather than do in python

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


[Lldb-commits] [lldb] [lldb] Fix GCC's `-Wreturn-type` warnings (PR #127974)

2025-02-20 Thread Pavel Labath via lldb-commits

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

Thanks.

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


[Lldb-commits] [lldb] [LLDB][Telemetry]Define DebuggerTelemetryInfo and related methods (PR #127696)

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

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


[Lldb-commits] [lldb] [LLDB][Telemetry]Define DebuggerTelemetryInfo and related methods (PR #127696)

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

oontvoo wrote:


> However, it's use tends to be somewhat cumbersome because you have to write 
> some code do something, and then also drive that code from the command line. 
> I would recommend trying to test as much as possible via the unit tests 
> (which are basically can do anything that lldb-test can, but you don't have 
> to drive them from the command line), and use only when you really need an 
> end-to-end experience.

Ok - thanks for the details! That makes it a lot easier :)

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


[Lldb-commits] [lldb] [llvm] [lldb][RISC-V] Extended if conditions to support alias names for registers (PR #124475)

2025-02-20 Thread via lldb-commits

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


[Lldb-commits] [lldb] Reland "[lldb] Implement basic support for reverse-continue" (#123906)" (PR #123945)

2025-02-20 Thread Pavel Labath via lldb-commits

labath wrote:

@adrian-prantl, any chance you or someone could take a look at this? The 
problem really appears to be specific to that buildbot (my guess: something 
about the debugserver version on that bot), as I've run the tests locally both 
with arm64 and x86_64-via-rosetta, both with the system and locally build debug 
server, and they all work fine.

The only other thing we can do is disable those tests on macs, but I'd really 
like to avoid that since that means the reverse debugging code path will get 
zero coverage on a mac.

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


[Lldb-commits] [lldb] [llvm] [lldb][RISC-V] Extended if conditions to support alias names for registers (PR #124475)

2025-02-20 Thread via lldb-commits


@@ -652,6 +652,153 @@ def haltReason(self):
 )
 self.match("register read s31", ["s31 = 128"])
 
+@skipIfXmlSupportMissing
+@skipIfRemote
+@skipIfLLVMTargetMissing("RISCV")
+def test_riscv64_regs(self):
+"""Test grabbing various riscv64 registers from gdbserver."""
+
+class MyResponder(MockGDBServerResponder):
+reg_data = (
+"0102030405060708"  # zero
+"0102030405060708"  # ra
+"0102030405060708"  # sp
+"0102030405060708"  # gp
+"0102030405060708"  # tp
+"0102030405060708"  # t0
+"0102030405060708"  # t1
+"0102030405060708"  # t2
+"0102030405060708"  # fp
+"0102030405060708"  # s1
+"0102030405060708"  # a0
+"0102030405060708"  # a1
+"0102030405060708"  # a2
+"0102030405060708"  # a3
+"0102030405060708"  # a4
+"0102030405060708"  # a5
+"0102030405060708"  # a6
+"0102030405060708"  # a7
+"0102030405060708"  # s2
+"0102030405060708"  # s3
+"0102030405060708"  # s4
+"0102030405060708"  # s5
+"0102030405060708"  # s6
+"0102030405060708"  # s7
+"0102030405060708"  # s8
+"0102030405060708"  # s9
+"0102030405060708"  # s10
+"0102030405060708"  # s11
+"0102030405060708"  # t3
+"0102030405060708"  # t4
+"0102030405060708"  # t5
+"0102030405060708"  # t6
+)
+
+def qXferRead(self, obj, annex, offset, length):
+if annex == "target.xml":
+# Note that this XML does not include any aliases, LLDB 
must generate them itself.
+return (
+"""
+
+
+riscv
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+""",
+False,
+)
+else:
+return None, False
+
+def readRegister(self, regnum):
+return ""
+
+def readRegisters(self):
+return self.reg_data
+
+def writeRegisters(self, reg_hex):
+self.reg_data = reg_hex
+return "OK"
+
+def haltReason(self):
+return 
"T02thread:1ff0d;threads:1ff0d;thread-pcs:00010001bc00;07:0102030405060708;10:1112131415161718;"
+
+self.server.responder = MyResponder()
+
+target = self.createTarget("basic_eh_frame-riscv64.yaml")
+process = self.connect(target)
+lldbutil.expect_state_changes(
+self, self.dbg.GetListener(), process, [lldb.eStateStopped]
+)
+
+# test generic aliases
+self.match("register read x0", ["zero = 0x0807060504030201"])
+self.match("register read x1", ["ra = 0x0807060504030201"])
+self.match("register read x2", ["sp = 0x0807060504030201"])
+self.match("register read x3", ["gp = 0x0807060504030201"])
+self.match("register read x4", ["tp = 0x0807060504030201"])
+self.match("register read x5", ["t0 = 0x0807060504030201"])
+self.match("register read x6", ["t1 = 0x0807060504030201"])
+self.match("register read x7", ["t2 = 0x0807060504030201"])
+# Register x8 is probably not working because it has two aliases fp, s0
+# self.match("register read x8", ["fp = 0x0807060504030201"])

kper wrote:

oh sorry how stupid of me :)

https://github.com/llvm/llv

[Lldb-commits] [lldb] [lldb] Fixing edge cases in "source list" (PR #126526)

2025-02-20 Thread Pavel Labath via lldb-commits

https://github.com/labath updated 
https://github.com/llvm/llvm-project/pull/126526

>From fda9035cddce78e2109462c9cec176bcb96392d8 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Mon, 10 Feb 2025 15:20:05 +0100
Subject: [PATCH 1/3] [lldb] Fixing edge cases in "command source"

While looking at how to make Function::GetEndLineSourceInfo (which is
only used in "command source") work with discontinuous functions, I
realized there are other corner cases that this function doesn't handle.

The code assumed that the last line entry in the function will also
correspond to the last source line. This is probably true for
unoptimized code, but I don't think we can rely on the optimizer to
preserve this property. What's worse, the code didn't check that the
last line entry belonged to the same file as the first one, so if this
line entry was the result of inlining, we could end up using a line from
a completely different file.

To fix this, I change the algorithm to iterate over all line entries in
the function (which belong to the same file) and find the max line
number out of those. This way we can naturally handle the discontinuous
case as well.

This implementations is going to be slower than the previous one, but I
don't think that matters, because:
- this command is only used rarely, and interactively
- we have plenty of other code which iterates through the line table

I added some basic tests for the function operation. I don't claim the
tests to be comprehensive, or that the function handles all edge cases,
but test framework created here could be used for testing other
fixes/edge cases as well.
---
 lldb/include/lldb/Symbol/Function.h   |  15 +-
 lldb/source/Commands/CommandObjectSource.cpp  |  14 +-
 lldb/source/Symbol/Function.cpp   |  44 +--
 .../test/Shell/Commands/command-source-list.s | 265 ++
 4 files changed, 304 insertions(+), 34 deletions(-)
 create mode 100644 lldb/test/Shell/Commands/command-source-list.s

diff --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index f3b956139f3c5..ee3a8304fc5b3 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -15,6 +15,7 @@
 #include "lldb/Expression/DWARFExpressionList.h"
 #include "lldb/Symbol/Block.h"
 #include "lldb/Utility/UserID.h"
+#include "lldb/lldb-forward.h"
 #include "llvm/ADT/ArrayRef.h"
 
 #include 
@@ -460,6 +461,7 @@ class Function : public UserID, public SymbolContextScope {
   }
 
   lldb::LanguageType GetLanguage() const;
+
   /// Find the file and line number of the source location of the start of the
   /// function.  This will use the declaration if present and fall back on the
   /// line table if that fails.  So there may NOT be a line table entry for
@@ -473,16 +475,9 @@ class Function : public UserID, public SymbolContextScope {
   void GetStartLineSourceInfo(lldb::SupportFileSP &source_file_sp,
   uint32_t &line_no);
 
-  /// Find the file and line number of the source location of the end of the
-  /// function.
-  ///
-  ///
-  /// \param[out] source_file
-  /// The source file.
-  ///
-  /// \param[out] line_no
-  /// The line number.
-  void GetEndLineSourceInfo(FileSpec &source_file, uint32_t &line_no);
+  using SourceRange = Range;
+  /// Find the file and line number range of the function.
+  llvm::Expected> GetSourceInfo();
 
   /// Get the outgoing call edges from this function, sorted by their return
   /// PC addresses (in increasing order).
diff --git a/lldb/source/Commands/CommandObjectSource.cpp 
b/lldb/source/Commands/CommandObjectSource.cpp
index 936783216f6ff..81bf1769808ba 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -784,14 +784,12 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
 
   if (sc.block == nullptr) {
 // Not an inlined function
-sc.function->GetStartLineSourceInfo(start_file, start_line);
-if (start_line == 0) {
-  result.AppendErrorWithFormat("Could not find line information for "
-   "start of function: \"%s\".\n",
-   source_info.function.GetCString());
-  return 0;
-}
-sc.function->GetEndLineSourceInfo(end_file, end_line);
+auto expected_info = sc.function->GetSourceInfo();
+if (!expected_info)
+  result.AppendError(llvm::toString(expected_info.takeError()));
+start_file = expected_info->first;
+start_line = expected_info->second.GetRangeBase();
+end_line = expected_info->second.GetRangeEnd();
   } else {
 // We have an inlined function
 start_file = source_info.line_entry.file_sp;
diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp
index 11a43a9172ea6..9fbda97b7cc48 100644
--- a/lldb/source/Symbol/Function.cpp
+++ b/lldb/source/Symbol/Function.cp

[Lldb-commits] [lldb] [llvm] [lldb][RISC-V] Extended if conditions to support alias names for registers (PR #124475)

2025-02-20 Thread David Spickett via lldb-commits


@@ -0,0 +1,141 @@
+# REQUIRES: native && target-riscv64
+# RUN: %clangxx_host %p/Inputs/riscv64-gp-read.cpp -o %t
+# RUN: %lldb -b -s %s %t | FileCheck %s
+process launch
+
+register read --all
+# CHECK-DAG: ra = 0x1
+# CHECK-DAG: sp = 0x2
+# CHECK-DAG: gp = 0x3
+# CHECK-DAG: tp = 0x4
+# CHECK-DAG: t0 = 0x5
+# CHECK-DAG: t1 = 0x6
+# CHECK-DAG: t2 = 0x7
+# CHECK-DAG: fp = 0x7c60
+# CHECK-DAG: s1 = 0x9
+# CHECK-DAG: a0 = 0xa
+# CHECK-DAG: a1 = 0xb
+# CHECK-DAG: a2 = 0xc
+# CHECK-DAG: a3 = 0xd
+# CHECK-DAG: a4 = 0xe
+# CHECK-DAG: a5 = 0xf
+# CHECK-DAG: a6 = 0x10
+# CHECK-DAG: a7 = 0x11
+# CHECK-DAG: s2 = 0x12
+# CHECK-DAG: s3 = 0x13
+# CHECK-DAG: s4 = 0x14
+# CHECK-DAG: s5 = 0x15
+# CHECK-DAG: s6 = 0x16
+# CHECK-DAG: s7 = 0x17
+# CHECK-DAG: s8 = 0x18
+# CHECK-DAG: s9 = 0x19
+# CHECK-DAG: s10 = 0x1a
+# CHECK-DAG: s11 = 0x1b
+# CHECK-DAG: t3 = 0x1c
+# CHECK-DAG: t4 = 0x1d
+# CHECK-DAG: t5 = 0x1e
+# CHECK-DAG: t6 = 0x1f
+# CHECK-DAG: zero = 0x0
+
+register read zero ra sp gp tp t0 t1 t2 s0 fp s1 a0 a1 a2 a3 a4 a5 a6 a7 s2 s3 
s4 s5 s6 s7 s8 s9 s10 s11 t3 t4 t5 t6
+# CHECK-DAG: zero = 0x0
+# CHECK-DAG: ra = 0x1
+# CHECK-DAG: sp = 0x2
+# CHECK-DAG: gp = 0x3
+# CHECK-DAG: tp = 0x4
+# CHECK-DAG: t0 = 0x5
+# CHECK-DAG: t1 = 0x6
+# CHECK-DAG: t2 = 0x7
+# CHECK-DAG: fp = 0x7c60
+# CHECK-DAG: fp = 0x7c60
+# CHECK-DAG: s1 = 0x9
+# CHECK-DAG: a0 = 0xa
+# CHECK-DAG: a1 = 0xb
+# CHECK-DAG: a2 = 0xc
+# CHECK-DAG: a3 = 0xd
+# CHECK-DAG: a4 = 0xe
+# CHECK-DAG: a5 = 0xf
+# CHECK-DAG: a6 = 0x10
+# CHECK-DAG: a7 = 0x11
+# CHECK-DAG: s2 = 0x12
+# CHECK-DAG: s3 = 0x13
+# CHECK-DAG: s4 = 0x14
+# CHECK-DAG: s5 = 0x15
+# CHECK-DAG: s6 = 0x16
+# CHECK-DAG: s7 = 0x17
+# CHECK-DAG: s8 = 0x18
+# CHECK-DAG: s9 = 0x19
+# CHECK-DAG: s10 = 0x1a
+# CHECK-DAG: s11 = 0x1b
+# CHECK-DAG: t3 = 0x1c
+# CHECK-DAG: t4 = 0x1d
+# CHECK-DAG: t5 = 0x1e
+# CHECK-DAG: t6 = 0x1f
+
+register read zero ra sp gp tp t0 t1 t2 s0 fp s1 a0 a1 a2 a3 a4 a5 a6 a7 s2 s3 
s4 s5 s6 s7 s8 s9 s10 s11 t3 t4 t5 t6
+# CHECK-DAG: zero = 0x0
+# CHECK-DAG: ra = 0x1
+# CHECK-DAG: sp = 0x2
+# CHECK-DAG: gp = 0x3
+# CHECK-DAG: tp = 0x4
+# CHECK-DAG: t0 = 0x5
+# CHECK-DAG: t1 = 0x6
+# CHECK-DAG: t2 = 0x7
+# CHECK-DAG: fp = 0x7c60
+# CHECK-DAG: fp = 0x7c60
+# CHECK-DAG: s1 = 0x9
+# CHECK-DAG: a0 = 0xa
+# CHECK-DAG: a1 = 0xb
+# CHECK-DAG: a2 = 0xc
+# CHECK-DAG: a3 = 0xd
+# CHECK-DAG: a4 = 0xe
+# CHECK-DAG: a5 = 0xf
+# CHECK-DAG: a6 = 0x10
+# CHECK-DAG: a7 = 0x11
+# CHECK-DAG: s2 = 0x12
+# CHECK-DAG: s3 = 0x13
+# CHECK-DAG: s4 = 0x14
+# CHECK-DAG: s5 = 0x15
+# CHECK-DAG: s6 = 0x16
+# CHECK-DAG: s7 = 0x17
+# CHECK-DAG: s8 = 0x18
+# CHECK-DAG: s9 = 0x19
+# CHECK-DAG: s10 = 0x1a
+# CHECK-DAG: s11 = 0x1b
+# CHECK-DAG: t3 = 0x1c
+# CHECK-DAG: t4 = 0x1d
+# CHECK-DAG: t5 = 0x1e
+# CHECK-DAG: t6 = 0x1f
+
+register read x0 x1 x2 x3 x4 x5 x6 x7 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 
x19 x20 x21 x22 x23 x24 x25 x26 x27 x28 x29 x30 x31

DavidSpickett wrote:

Add a comment linking to the x8 issue here too.

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


[Lldb-commits] [lldb] [lldb] Fixing edge cases in "source list" (PR #126526)

2025-02-20 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff d7784a649e80d346ba57ccc39f5e2a3e2f7e0a51 
27d7bedee0de54abb9ec900c4d21eff6a8e7084a --extensions h,cpp -- 
lldb/include/lldb/Symbol/Function.h 
lldb/source/Commands/CommandObjectSource.cpp lldb/source/Symbol/Function.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp
index bcee29b8ad..c80f37ae68 100644
--- a/lldb/source/Symbol/Function.cpp
+++ b/lldb/source/Symbol/Function.cpp
@@ -336,7 +336,7 @@ Function::GetSourceInfo() {
 for (auto [idx, end] = line_table->GetLineEntryIndexRange(range); idx < 
end;
  ++idx) {
   LineEntry entry;
-// Ignore entries belonging to inlined functions or #included files.
+  // Ignore entries belonging to inlined functions or #included files.
   if (line_table->GetLineEntryAtIndex(idx, entry) &&
   source_file_sp->Equal(*entry.file_sp,
 SupportFile::eEqualFileSpecAndChecksumIfSet))

``




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


[Lldb-commits] [lldb] [llvm] [lldb][RISC-V] Extended if conditions to support alias names for registers (PR #124475)

2025-02-20 Thread David Spickett via lldb-commits

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

LGTM thanks for fixing this and doing all the leg work to verify it.

I will merge once the CI passes, or anyone else can if they have the rights to.

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


[Lldb-commits] [lldb] [llvm] [lldb][RISC-V] Extended if conditions to support alias names for registers (PR #124475)

2025-02-20 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Well, those BOLT failures are unrelated. So if Windows shows the same ones, 
this can be merged.

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


[Lldb-commits] [lldb] [llvm] [lldb][RISC-V] Extended if conditions to support alias names for registers (PR #124475)

2025-02-20 Thread via lldb-commits

kper wrote:

@DavidSpickett thank you for your patience with me :)

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


[Lldb-commits] [lldb] [llvm] [lldb][RISC-V] Extended if conditions to support alias names for registers (PR #124475)

2025-02-20 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Np.

Strangely no BOLT failures on Windows perhaps it doesn't run there, one other 
lld test but unrelated to this.

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


[Lldb-commits] [lldb] [llvm] [lldb][RISC-V] Extended if conditions to support alias names for registers (PR #124475)

2025-02-20 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] c48e0c1 - [lldb][RISC-V] Extended if conditions to support alias names for registers (#124475)

2025-02-20 Thread via lldb-commits

Author: kper
Date: 2025-02-20T16:23:53Z
New Revision: c48e0c182c5a9e19062677cbca17c89ea586e033

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

LOG: [lldb][RISC-V] Extended if conditions to support alias names for registers 
(#124475)

Extending the conditionals in `AugmentRegisterInfo` to support
alternative names for lldb.

Fixes #124023

There is an exception with register `X8` which is not covered here but
more details can be found in the issue
https://github.com/llvm/llvm-project/issues/127900.

Added: 
lldb/test/API/functionalities/gdb_remote_client/basic_eh_frame-riscv64.yaml
lldb/test/Shell/Register/Inputs/riscv64-gp-read.cpp
lldb/test/Shell/Register/riscv64-gp-read.test

Modified: 
lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
llvm/utils/lit/lit/llvm/config.py

Removed: 




diff  --git a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp 
b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
index 8412991933d27..c463bd006b3db 100644
--- a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
+++ b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
@@ -850,8 +850,62 @@ void ABISysV_riscv::AugmentRegisterInfo(
   it.value().alt_name.SetCString("x3");
 else if (it.value().name == "fp")
   it.value().alt_name.SetCString("s0");
+else if (it.value().name == "tp")
+  it.value().alt_name.SetCString("x4");
 else if (it.value().name == "s0")
   it.value().alt_name.SetCString("x8");
+else if (it.value().name == "s1")
+  it.value().alt_name.SetCString("x9");
+else if (it.value().name == "t0")
+  it.value().alt_name.SetCString("x5");
+else if (it.value().name == "t1")
+  it.value().alt_name.SetCString("x6");
+else if (it.value().name == "t2")
+  it.value().alt_name.SetCString("x7");
+else if (it.value().name == "a0")
+  it.value().alt_name.SetCString("x10");
+else if (it.value().name == "a1")
+  it.value().alt_name.SetCString("x11");
+else if (it.value().name == "a2")
+  it.value().alt_name.SetCString("x12");
+else if (it.value().name == "a3")
+  it.value().alt_name.SetCString("x13");
+else if (it.value().name == "a4")
+  it.value().alt_name.SetCString("x14");
+else if (it.value().name == "a5")
+  it.value().alt_name.SetCString("x15");
+else if (it.value().name == "a6")
+  it.value().alt_name.SetCString("x16");
+else if (it.value().name == "a7")
+  it.value().alt_name.SetCString("x17");
+else if (it.value().name == "s2")
+  it.value().alt_name.SetCString("x18");
+else if (it.value().name == "s3")
+  it.value().alt_name.SetCString("x19");
+else if (it.value().name == "s4")
+  it.value().alt_name.SetCString("x20");
+else if (it.value().name == "s5")
+  it.value().alt_name.SetCString("x21");
+else if (it.value().name == "s6")
+  it.value().alt_name.SetCString("x22");
+else if (it.value().name == "s7")
+  it.value().alt_name.SetCString("x23");
+else if (it.value().name == "s8")
+  it.value().alt_name.SetCString("x24");
+else if (it.value().name == "s9")
+  it.value().alt_name.SetCString("x25");
+else if (it.value().name == "s10")
+  it.value().alt_name.SetCString("x26");
+else if (it.value().name == "s11")
+  it.value().alt_name.SetCString("x27");
+else if (it.value().name == "t3")
+  it.value().alt_name.SetCString("x28");
+else if (it.value().name == "t4")
+  it.value().alt_name.SetCString("x29");
+else if (it.value().name == "t5")
+  it.value().alt_name.SetCString("x30");
+else if (it.value().name == "t6")
+  it.value().alt_name.SetCString("x31");
 
 // Set generic regnum so lldb knows what the PC, etc is
 it.value().regnum_generic = GetGenericNum(it.value().name.GetStringRef());

diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
index 22f5553e40802..9a70f67b264ce 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -652,6 +652,154 @@ def haltReason(self):
 )
 self.match("register read s31", ["s31 = 128"])
 
+@skipIfXmlSupportMissing
+@skipIfRemote
+@skipIfLLVMTargetMissing("RISCV")
+def test_riscv64_regs(self):
+"""Test grabbing various riscv64 registers from gdbserver."""
+
+class MyResponder(MockGDBServerResponder):
+reg_data = (
+"0102030405060708"  # zero
+"0102030405060708"

[Lldb-commits] [lldb] 81bc28d - [lldb] Update PlatformDarwin list of libraries with thread functions (#127922)

2025-02-20 Thread via lldb-commits

Author: Felipe de Azevedo Piovezan
Date: 2025-02-20T08:26:47-08:00
New Revision: 81bc28d0bcaca3e7386ced2138566e4d0a838ad5

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

LOG: [lldb] Update PlatformDarwin list of libraries with thread functions 
(#127922)

Recent versions of the system changed where these functions live.

Added: 
lldb/test/API/macosx/thread_start_bps/Makefile
lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py
lldb/test/API/macosx/thread_start_bps/main.c

Modified: 
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 51e9a6d81b839..665500f23e95d 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -651,8 +651,8 @@ BreakpointSP 
PlatformDarwin::SetThreadCreationBreakpoint(Target &target) {
   "start_wqthread", "_pthread_wqthread", "_pthread_start",
   };
 
-  static const char *g_bp_modules[] = {"libsystem_c.dylib",
-   "libSystem.B.dylib"};
+  static const char *g_bp_modules[] = {"libsystem_c.dylib", 
"libSystem.B.dylib",
+   "libsystem_pthread.dylib"};
 
   FileSpecList bp_modules;
   for (size_t i = 0; i < std::size(g_bp_modules); i++) {

diff  --git a/lldb/test/API/macosx/thread_start_bps/Makefile 
b/lldb/test/API/macosx/thread_start_bps/Makefile
new file mode 100644
index 0..10495940055b6
--- /dev/null
+++ b/lldb/test/API/macosx/thread_start_bps/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules

diff  --git 
a/lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py 
b/lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py
new file mode 100644
index 0..1c6fd4f91c73e
--- /dev/null
+++ b/lldb/test/API/macosx/thread_start_bps/TestBreakpointsThreadInit.py
@@ -0,0 +1,37 @@
+"""Test that we get thread names when interrupting a process."""
+
+import time
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestInterruptThreadNames(TestBase):
+@skipUnlessDarwin
+def test_internal_bps_resolved(self):
+self.build()
+
+source_file = lldb.SBFileSpec("main.c")
+target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
+self, "initial hello", source_file
+)
+
+thread_start_func_names = [
+"start_wqthread",
+"_pthread_wqthread",
+"_pthread_start",
+]
+known_module_names = [
+"libsystem_c.dylib",
+"libSystem.B.dylib",
+"libsystem_pthread.dylib",
+]
+bps = []
+for func in thread_start_func_names:
+for module in known_module_names:
+bps.append(target.BreakpointCreateByName(func, module))
+num_resolved = 0
+for bp in bps:
+num_resolved += bp.GetNumResolvedLocations()
+self.assertGreater(num_resolved, 0)

diff  --git a/lldb/test/API/macosx/thread_start_bps/main.c 
b/lldb/test/API/macosx/thread_start_bps/main.c
new file mode 100644
index 0..1a0af000b5b04
--- /dev/null
+++ b/lldb/test/API/macosx/thread_start_bps/main.c
@@ -0,0 +1,5 @@
+#include 
+int main() {
+  puts("initial hello");
+  puts("hello from the other side");
+}



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


[Lldb-commits] [lldb] [lldb] Update PlatformDarwin list of libraries with thread functions (PR #127922)

2025-02-20 Thread Felipe de Azevedo Piovezan via lldb-commits

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


[Lldb-commits] [lldb] Allow option to ignore module load errors in ScriptedProcess (PR #127153)

2025-02-20 Thread via lldb-commits

rchamala wrote:

@jimingham @medismailben Can you please let me know if you have more questions 
regarding the problem and solution ? Right now, I have conditionally ignored 
the modules which are not created and only loaded the successful ones, if 
needed I can always load the successfully created modules in scripted process

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


[Lldb-commits] [lldb] [llvm] [lldb][RISC-V] Extended if conditions to support alias names for registers (PR #124475)

2025-02-20 Thread via lldb-commits

https://github.com/kper updated https://github.com/llvm/llvm-project/pull/124475

>From 4feaf723ff8f879bd82bb82108d9e6bac4b90026 Mon Sep 17 00:00:00 2001
From: Kevin Per 
Date: Sun, 26 Jan 2025 17:34:17 +
Subject: [PATCH] [lldb] Extended if conditions to support alias names for
 registers

---
 .../Plugins/ABI/RISCV/ABISysV_riscv.cpp   |  54 ++
 .../TestGDBServerTargetXML.py | 148 
 .../basic_eh_frame-riscv64.yaml   |  20 +++
 .../postmortem/elf-core/TestLinuxCore.py  | 158 ++
 .../Shell/Register/Inputs/riscv64-gp-read.cpp |  36 
 lldb/test/Shell/Register/riscv64-gp-read.test | 141 
 llvm/utils/lit/lit/llvm/config.py |   8 +-
 7 files changed, 491 insertions(+), 74 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/gdb_remote_client/basic_eh_frame-riscv64.yaml
 create mode 100644 lldb/test/Shell/Register/Inputs/riscv64-gp-read.cpp
 create mode 100644 lldb/test/Shell/Register/riscv64-gp-read.test

diff --git a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp 
b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
index 8412991933d27..c463bd006b3db 100644
--- a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
+++ b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
@@ -850,8 +850,62 @@ void ABISysV_riscv::AugmentRegisterInfo(
   it.value().alt_name.SetCString("x3");
 else if (it.value().name == "fp")
   it.value().alt_name.SetCString("s0");
+else if (it.value().name == "tp")
+  it.value().alt_name.SetCString("x4");
 else if (it.value().name == "s0")
   it.value().alt_name.SetCString("x8");
+else if (it.value().name == "s1")
+  it.value().alt_name.SetCString("x9");
+else if (it.value().name == "t0")
+  it.value().alt_name.SetCString("x5");
+else if (it.value().name == "t1")
+  it.value().alt_name.SetCString("x6");
+else if (it.value().name == "t2")
+  it.value().alt_name.SetCString("x7");
+else if (it.value().name == "a0")
+  it.value().alt_name.SetCString("x10");
+else if (it.value().name == "a1")
+  it.value().alt_name.SetCString("x11");
+else if (it.value().name == "a2")
+  it.value().alt_name.SetCString("x12");
+else if (it.value().name == "a3")
+  it.value().alt_name.SetCString("x13");
+else if (it.value().name == "a4")
+  it.value().alt_name.SetCString("x14");
+else if (it.value().name == "a5")
+  it.value().alt_name.SetCString("x15");
+else if (it.value().name == "a6")
+  it.value().alt_name.SetCString("x16");
+else if (it.value().name == "a7")
+  it.value().alt_name.SetCString("x17");
+else if (it.value().name == "s2")
+  it.value().alt_name.SetCString("x18");
+else if (it.value().name == "s3")
+  it.value().alt_name.SetCString("x19");
+else if (it.value().name == "s4")
+  it.value().alt_name.SetCString("x20");
+else if (it.value().name == "s5")
+  it.value().alt_name.SetCString("x21");
+else if (it.value().name == "s6")
+  it.value().alt_name.SetCString("x22");
+else if (it.value().name == "s7")
+  it.value().alt_name.SetCString("x23");
+else if (it.value().name == "s8")
+  it.value().alt_name.SetCString("x24");
+else if (it.value().name == "s9")
+  it.value().alt_name.SetCString("x25");
+else if (it.value().name == "s10")
+  it.value().alt_name.SetCString("x26");
+else if (it.value().name == "s11")
+  it.value().alt_name.SetCString("x27");
+else if (it.value().name == "t3")
+  it.value().alt_name.SetCString("x28");
+else if (it.value().name == "t4")
+  it.value().alt_name.SetCString("x29");
+else if (it.value().name == "t5")
+  it.value().alt_name.SetCString("x30");
+else if (it.value().name == "t6")
+  it.value().alt_name.SetCString("x31");
 
 // Set generic regnum so lldb knows what the PC, etc is
 it.value().regnum_generic = GetGenericNum(it.value().name.GetStringRef());
diff --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
index 22f5553e40802..9a70f67b264ce 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -652,6 +652,154 @@ def haltReason(self):
 )
 self.match("register read s31", ["s31 = 128"])
 
+@skipIfXmlSupportMissing
+@skipIfRemote
+@skipIfLLVMTargetMissing("RISCV")
+def test_riscv64_regs(self):
+"""Test grabbing various riscv64 registers from gdbserver."""
+
+class MyResponder(MockGDBServerResponder):
+reg_data = (
+"0102030405060708"  # zero
+"0102030405060708"  # ra
+"0102030405060708"  # sp
+"0102030405060708"  # gp
+"0102030405060708"  # tp
+"010203040506

[Lldb-commits] [lldb] [lldb] Store StreamAsynchronousIO in a unique_ptr (NFC) (PR #127961)

2025-02-20 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere updated 
https://github.com/llvm/llvm-project/pull/127961

>From d8c91ab0d401384f2724a8c2c67c12e9c9446af7 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Wed, 19 Feb 2025 21:24:29 -0800
Subject: [PATCH 1/2] [lldb] Store StreamAsynchronousIO in a unique_ptr (NFC)

Make StreamAsynchronousIO an unique_ptr instead of a shared_ptr. I tried
passing the class by value, but the llvm::raw_ostream forwarded stored
in the Stream parent class isn't movable and I don't think it's worth
changing that. Additionally, there's a few places that expect a
StreamSP, which are easily created from a StreamUP.
---
 lldb/include/lldb/Core/Debugger.h |  4 +-
 lldb/include/lldb/lldb-forward.h  |  1 +
 lldb/source/Breakpoint/BreakpointOptions.cpp  |  6 +-
 .../source/Commands/CommandObjectCommands.cpp |  7 +-
 .../CommandObjectWatchpointCommand.cpp|  6 +-
 lldb/source/Core/Debugger.cpp | 85 +--
 lldb/source/Core/DynamicLoader.cpp|  2 +-
 .../DynamicLoaderDarwinKernel.cpp |  6 +-
 .../DynamicLoaderFreeBSDKernel.cpp| 10 +--
 .../Process/MacOSX-Kernel/ProcessKDP.cpp  | 18 +---
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |  3 +-
 lldb/source/Target/Process.cpp| 14 ++-
 lldb/source/Target/StopInfo.cpp   |  8 +-
 lldb/source/Target/Target.cpp |  2 +-
 14 files changed, 72 insertions(+), 100 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 9c8a9623fe689..6ebc6147800e1 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -156,9 +156,9 @@ class Debugger : public 
std::enable_shared_from_this,
 
   void RestoreInputTerminalState();
 
-  lldb::StreamSP GetAsyncOutputStream();
+  lldb::StreamUP GetAsyncOutputStream();
 
-  lldb::StreamSP GetAsyncErrorStream();
+  lldb::StreamUP GetAsyncErrorStream();
 
   CommandInterpreter &GetCommandInterpreter() {
 assert(m_command_interpreter_up.get());
diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h
index cda55ef06e549..c664d1398f74d 100644
--- a/lldb/include/lldb/lldb-forward.h
+++ b/lldb/include/lldb/lldb-forward.h
@@ -432,6 +432,7 @@ typedef 
std::unique_ptr
 StackFrameRecognizerManagerUP;
 typedef std::shared_ptr StopInfoSP;
 typedef std::shared_ptr StreamSP;
+typedef std::unique_ptr StreamUP;
 typedef std::shared_ptr StreamFileSP;
 typedef std::shared_ptr LockableStreamFileSP;
 typedef std::shared_ptr
diff --git a/lldb/source/Breakpoint/BreakpointOptions.cpp 
b/lldb/source/Breakpoint/BreakpointOptions.cpp
index 09abcf5e081d2..242b5b30168c5 100644
--- a/lldb/source/Breakpoint/BreakpointOptions.cpp
+++ b/lldb/source/Breakpoint/BreakpointOptions.cpp
@@ -620,10 +620,8 @@ bool BreakpointOptions::BreakpointOptionsCallbackFunction(
 
   // Rig up the results secondary output stream to the debugger's, so the
   // output will come out synchronously if the debugger is set up that way.
-  StreamSP output_stream(debugger.GetAsyncOutputStream());
-  StreamSP error_stream(debugger.GetAsyncErrorStream());
-  result.SetImmediateOutputStream(output_stream);
-  result.SetImmediateErrorStream(error_stream);
+  result.SetImmediateOutputStream(debugger.GetAsyncOutputStream());
+  result.SetImmediateErrorStream(debugger.GetAsyncErrorStream());
 
   CommandInterpreterRunOptions options;
   options.SetStopOnContinue(true);
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp 
b/lldb/source/Commands/CommandObjectCommands.cpp
index dd841cb5cb4cc..9510cf4d14467 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -815,10 +815,9 @@ a number follows 'f':"
 for (const std::string &line : lines) {
   Status error = AppendRegexSubstitution(line, check_only);
   if (error.Fail()) {
-if (!GetDebugger().GetCommandInterpreter().GetBatchCommandMode()) {
-  StreamSP out_stream = GetDebugger().GetAsyncOutputStream();
-  out_stream->Printf("error: %s\n", error.AsCString());
-}
+if (!GetDebugger().GetCommandInterpreter().GetBatchCommandMode())
+  GetDebugger().GetAsyncOutputStream()->Printf("error: %s\n",
+   error.AsCString());
   }
 }
   }
diff --git a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp 
b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
index 507ef3fbe4759..32cb80b421fd6 100644
--- a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
@@ -252,10 +252,8 @@ are no syntax errors may indicate that a function was 
declared but never called.
 // Rig up the results secondary output stream to the debugger's, so the
 // output will come out syn

[Lldb-commits] [lldb] [LLDB-DAP] SBDebugger don't prefix title on progress updates (PR #124648)

2025-02-20 Thread Jacob Lalonde via lldb-commits


@@ -428,14 +453,35 @@ void ProgressEventThreadFunction(DAP &dap) {
   done = true;
 }
   } else {
-uint64_t progress_id = 0;
-uint64_t completed = 0;
-uint64_t total = 0;
-bool is_debugger_specific = false;
-const char *message = lldb::SBDebugger::GetProgressFromEvent(
-event, progress_id, completed, total, is_debugger_specific);
-if (message)
-  dap.SendProgressEvent(progress_id, message, completed, total);
+lldb::SBStructuredData data =
+lldb::SBDebugger::GetProgressDataFromEvent(event);
+
+const uint64_t progress_id =
+GetUintFromStructuredData(data, "progress_id");
+const uint64_t completed = GetUintFromStructuredData(data, 
"completed");
+const uint64_t total = GetUintFromStructuredData(data, "total");
+const std::string details =
+GetStringFromStructuredData(data, "details");
+
+// If we're only creating and sending on progress event, we send
+// the title and the detail as a single message.
+if (completed == 0 && total == 1) {
+  const std::string message =
+  GetStringFromStructuredData(data, "message");

Jlalond wrote:

Yes, message is title and detail

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


[Lldb-commits] [lldb] [LLDB-DAP] SBDebugger don't prefix title on progress updates (PR #124648)

2025-02-20 Thread Jacob Lalonde via lldb-commits

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

>From 12ff645735c1dbf51e58b9f80d4e3e13a0babdf5 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Mon, 27 Jan 2025 13:41:58 -0800
Subject: [PATCH 1/7] Only include title on the first message

---
 lldb/include/lldb/Core/DebuggerEvents.h | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/lldb/include/lldb/Core/DebuggerEvents.h 
b/lldb/include/lldb/Core/DebuggerEvents.h
index 49a4ecf8e537e..52e4f77d7637d 100644
--- a/lldb/include/lldb/Core/DebuggerEvents.h
+++ b/lldb/include/lldb/Core/DebuggerEvents.h
@@ -44,12 +44,15 @@ class ProgressEventData : public EventData {
   uint64_t GetCompleted() const { return m_completed; }
   uint64_t GetTotal() const { return m_total; }
   std::string GetMessage() const {
-std::string message = m_title;
-if (!m_details.empty()) {
-  message.append(": ");
-  message.append(m_details);
-}
-return message;
+if (m_completed == 0) {
+  std::string message = m_title;
+  if (!m_details.empty()) {
+message.append(": ");
+message.append(m_details);
+  }
+  return message;
+} else
+  return !m_details.empty() ? m_details : std::string();
   }
   const std::string &GetTitle() const { return m_title; }
   const std::string &GetDetails() const { return m_details; }

>From 82ed76ae3b6bef176bf54dd1031f0cb9c95081c1 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Mon, 27 Jan 2025 14:48:01 -0800
Subject: [PATCH 2/7] Add comment explaining if and add a test

---
 lldb/include/lldb/Core/DebuggerEvents.h   | 1 +
 lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py | 5 +
 2 files changed, 6 insertions(+)

diff --git a/lldb/include/lldb/Core/DebuggerEvents.h 
b/lldb/include/lldb/Core/DebuggerEvents.h
index 52e4f77d7637d..ca06ee835fde3 100644
--- a/lldb/include/lldb/Core/DebuggerEvents.h
+++ b/lldb/include/lldb/Core/DebuggerEvents.h
@@ -44,6 +44,7 @@ class ProgressEventData : public EventData {
   uint64_t GetCompleted() const { return m_completed; }
   uint64_t GetTotal() const { return m_total; }
   std::string GetMessage() const {
+// Only put the title in the message of the progress create event.
 if (m_completed == 0) {
   std::string message = m_title;
   if (!m_details.empty()) {
diff --git a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py 
b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
index 36c0cef9c4714..945c3f7633364 100755
--- a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
+++ b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
@@ -41,8 +41,13 @@ def test_output(self):
 for event in self.dap_server.progress_events:
 event_type = event["event"]
 if "progressStart" in event_type:
+title = event["body"]["title"]
+self.assertIn("Progress tester", title)
 start_found = True
 if "progressUpdate" in event_type:
+message = event["body"]["message"]
+print(f"Progress update: {message}")
+self.assertNotIn("Progres tester", message)
 update_found = True
 
 self.assertTrue(start_found)

>From e15090782a93e07e8a260a0594ca02430e68e09f Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Thu, 30 Jan 2025 10:04:04 -0800
Subject: [PATCH 3/7] Migrate to structured data

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:


Differential Revision: https://phabricator.intern.facebook.com/D68927453
---
 lldb/include/lldb/Core/DebuggerEvents.h | 16 +++-
 lldb/tools/lldb-dap/lldb-dap.cpp| 54 +
 2 files changed, 52 insertions(+), 18 deletions(-)

diff --git a/lldb/include/lldb/Core/DebuggerEvents.h 
b/lldb/include/lldb/Core/DebuggerEvents.h
index ca06ee835fde3..49a4ecf8e537e 100644
--- a/lldb/include/lldb/Core/DebuggerEvents.h
+++ b/lldb/include/lldb/Core/DebuggerEvents.h
@@ -44,16 +44,12 @@ class ProgressEventData : public EventData {
   uint64_t GetCompleted() const { return m_completed; }
   uint64_t GetTotal() const { return m_total; }
   std::string GetMessage() const {
-// Only put the title in the message of the progress create event.
-if (m_completed == 0) {
-  std::string message = m_title;
-  if (!m_details.empty()) {
-message.append(": ");
-message.append(m_details);
-  }
-  return message;
-} else
-  return !m_details.empty() ? m_details : std::string();
+std::string message = m_title;
+if (!m_details.empty()) {
+  message.append(": ");
+  message.append(m_details);
+}
+return message;
   }
   const std::string &GetTitle() const { return m_title; }
   const std::string &GetDetails() const { return m_details; }
diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp
index e323990d8b6ed..4b3460190a7c9 100644
--- a/lldb/tools/lldb

[Lldb-commits] [lldb] [llvm] [lldb][RISC-V] Extended if conditions to support alias names for registers (PR #124475)

2025-02-20 Thread David Spickett via lldb-commits


@@ -0,0 +1,141 @@
+# REQUIRES: native && target-riscv64
+# RUN: %clangxx_host %p/Inputs/riscv64-gp-read.cpp -o %t
+# RUN: %lldb -b -s %s %t | FileCheck %s
+process launch
+
+register read --all
+# CHECK-DAG: ra = 0x1
+# CHECK-DAG: sp = 0x2
+# CHECK-DAG: gp = 0x3
+# CHECK-DAG: tp = 0x4
+# CHECK-DAG: t0 = 0x5
+# CHECK-DAG: t1 = 0x6
+# CHECK-DAG: t2 = 0x7
+# CHECK-DAG: fp = 0x7c60
+# CHECK-DAG: s1 = 0x9
+# CHECK-DAG: a0 = 0xa
+# CHECK-DAG: a1 = 0xb
+# CHECK-DAG: a2 = 0xc
+# CHECK-DAG: a3 = 0xd
+# CHECK-DAG: a4 = 0xe
+# CHECK-DAG: a5 = 0xf
+# CHECK-DAG: a6 = 0x10
+# CHECK-DAG: a7 = 0x11
+# CHECK-DAG: s2 = 0x12
+# CHECK-DAG: s3 = 0x13
+# CHECK-DAG: s4 = 0x14
+# CHECK-DAG: s5 = 0x15
+# CHECK-DAG: s6 = 0x16
+# CHECK-DAG: s7 = 0x17
+# CHECK-DAG: s8 = 0x18
+# CHECK-DAG: s9 = 0x19
+# CHECK-DAG: s10 = 0x1a
+# CHECK-DAG: s11 = 0x1b
+# CHECK-DAG: t3 = 0x1c
+# CHECK-DAG: t4 = 0x1d
+# CHECK-DAG: t5 = 0x1e
+# CHECK-DAG: t6 = 0x1f
+# CHECK-DAG: zero = 0x0
+
+register read zero ra sp gp tp t0 t1 t2 s0 fp s1 a0 a1 a2 a3 a4 a5 a6 a7 s2 s3 
s4 s5 s6 s7 s8 s9 s10 s11 t3 t4 t5 t6
+# CHECK-DAG: zero = 0x0
+# CHECK-DAG: ra = 0x1
+# CHECK-DAG: sp = 0x2
+# CHECK-DAG: gp = 0x3
+# CHECK-DAG: tp = 0x4
+# CHECK-DAG: t0 = 0x5
+# CHECK-DAG: t1 = 0x6
+# CHECK-DAG: t2 = 0x7
+# CHECK-DAG: fp = 0x7c60
+# CHECK-DAG: fp = 0x7c60
+# CHECK-DAG: s1 = 0x9
+# CHECK-DAG: a0 = 0xa
+# CHECK-DAG: a1 = 0xb
+# CHECK-DAG: a2 = 0xc
+# CHECK-DAG: a3 = 0xd
+# CHECK-DAG: a4 = 0xe
+# CHECK-DAG: a5 = 0xf
+# CHECK-DAG: a6 = 0x10
+# CHECK-DAG: a7 = 0x11
+# CHECK-DAG: s2 = 0x12
+# CHECK-DAG: s3 = 0x13
+# CHECK-DAG: s4 = 0x14
+# CHECK-DAG: s5 = 0x15
+# CHECK-DAG: s6 = 0x16
+# CHECK-DAG: s7 = 0x17
+# CHECK-DAG: s8 = 0x18
+# CHECK-DAG: s9 = 0x19
+# CHECK-DAG: s10 = 0x1a
+# CHECK-DAG: s11 = 0x1b
+# CHECK-DAG: t3 = 0x1c
+# CHECK-DAG: t4 = 0x1d
+# CHECK-DAG: t5 = 0x1e
+# CHECK-DAG: t6 = 0x1f
+
+register read zero ra sp gp tp t0 t1 t2 s0 fp s1 a0 a1 a2 a3 a4 a5 a6 a7 s2 s3 
s4 s5 s6 s7 s8 s9 s10 s11 t3 t4 t5 t6
+# CHECK-DAG: zero = 0x0
+# CHECK-DAG: ra = 0x1
+# CHECK-DAG: sp = 0x2
+# CHECK-DAG: gp = 0x3
+# CHECK-DAG: tp = 0x4
+# CHECK-DAG: t0 = 0x5
+# CHECK-DAG: t1 = 0x6
+# CHECK-DAG: t2 = 0x7
+# CHECK-DAG: fp = 0x7c60
+# CHECK-DAG: fp = 0x7c60
+# CHECK-DAG: s1 = 0x9
+# CHECK-DAG: a0 = 0xa
+# CHECK-DAG: a1 = 0xb
+# CHECK-DAG: a2 = 0xc
+# CHECK-DAG: a3 = 0xd
+# CHECK-DAG: a4 = 0xe
+# CHECK-DAG: a5 = 0xf
+# CHECK-DAG: a6 = 0x10
+# CHECK-DAG: a7 = 0x11
+# CHECK-DAG: s2 = 0x12
+# CHECK-DAG: s3 = 0x13
+# CHECK-DAG: s4 = 0x14
+# CHECK-DAG: s5 = 0x15
+# CHECK-DAG: s6 = 0x16
+# CHECK-DAG: s7 = 0x17
+# CHECK-DAG: s8 = 0x18
+# CHECK-DAG: s9 = 0x19
+# CHECK-DAG: s10 = 0x1a
+# CHECK-DAG: s11 = 0x1b
+# CHECK-DAG: t3 = 0x1c
+# CHECK-DAG: t4 = 0x1d
+# CHECK-DAG: t5 = 0x1e
+# CHECK-DAG: t6 = 0x1f

DavidSpickett wrote:

I think this block has been put in twice.

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


[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. (PR #116392)

2025-02-20 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. (PR #116392)

2025-02-20 Thread Jonas Devlieghere via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. (PR #116392)

2025-02-20 Thread Jonas Devlieghere via lldb-commits


@@ -58,12 +58,13 @@ const char DEV_NULL[] = "/dev/null";
 
 namespace lldb_dap {
 
-DAP::DAP(llvm::StringRef path, std::ofstream *log, ReplMode repl_mode,
- StreamDescriptor input, StreamDescriptor output)
-: debug_adaptor_path(path), log(log), input(std::move(input)),
+DAP::DAP(std::string name, llvm::StringRef path, std::ofstream *log,
+ StreamDescriptor input, StreamDescriptor output, ReplMode repl_mode,
+ std::vector pre_init_commands)
+: name(name), debug_adaptor_path(path), log(log), input(std::move(input)),

JDevlieghere wrote:

```suggestion
: name(std::move(name)), debug_adaptor_path(path), log(log), 
input(std::move(input)),
```

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


[Lldb-commits] [lldb] [lldb] Fix GCC's `-Wreturn-type` warnings (PR #127974)

2025-02-20 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [LLDB-DAP] SBDebugger don't prefix title on progress updates (PR #124648)

2025-02-20 Thread Jacob Lalonde via lldb-commits

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

>From 12ff645735c1dbf51e58b9f80d4e3e13a0babdf5 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Mon, 27 Jan 2025 13:41:58 -0800
Subject: [PATCH 1/7] Only include title on the first message

---
 lldb/include/lldb/Core/DebuggerEvents.h | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/lldb/include/lldb/Core/DebuggerEvents.h 
b/lldb/include/lldb/Core/DebuggerEvents.h
index 49a4ecf8e537e..52e4f77d7637d 100644
--- a/lldb/include/lldb/Core/DebuggerEvents.h
+++ b/lldb/include/lldb/Core/DebuggerEvents.h
@@ -44,12 +44,15 @@ class ProgressEventData : public EventData {
   uint64_t GetCompleted() const { return m_completed; }
   uint64_t GetTotal() const { return m_total; }
   std::string GetMessage() const {
-std::string message = m_title;
-if (!m_details.empty()) {
-  message.append(": ");
-  message.append(m_details);
-}
-return message;
+if (m_completed == 0) {
+  std::string message = m_title;
+  if (!m_details.empty()) {
+message.append(": ");
+message.append(m_details);
+  }
+  return message;
+} else
+  return !m_details.empty() ? m_details : std::string();
   }
   const std::string &GetTitle() const { return m_title; }
   const std::string &GetDetails() const { return m_details; }

>From 82ed76ae3b6bef176bf54dd1031f0cb9c95081c1 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Mon, 27 Jan 2025 14:48:01 -0800
Subject: [PATCH 2/7] Add comment explaining if and add a test

---
 lldb/include/lldb/Core/DebuggerEvents.h   | 1 +
 lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py | 5 +
 2 files changed, 6 insertions(+)

diff --git a/lldb/include/lldb/Core/DebuggerEvents.h 
b/lldb/include/lldb/Core/DebuggerEvents.h
index 52e4f77d7637d..ca06ee835fde3 100644
--- a/lldb/include/lldb/Core/DebuggerEvents.h
+++ b/lldb/include/lldb/Core/DebuggerEvents.h
@@ -44,6 +44,7 @@ class ProgressEventData : public EventData {
   uint64_t GetCompleted() const { return m_completed; }
   uint64_t GetTotal() const { return m_total; }
   std::string GetMessage() const {
+// Only put the title in the message of the progress create event.
 if (m_completed == 0) {
   std::string message = m_title;
   if (!m_details.empty()) {
diff --git a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py 
b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
index 36c0cef9c4714..945c3f7633364 100755
--- a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
+++ b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
@@ -41,8 +41,13 @@ def test_output(self):
 for event in self.dap_server.progress_events:
 event_type = event["event"]
 if "progressStart" in event_type:
+title = event["body"]["title"]
+self.assertIn("Progress tester", title)
 start_found = True
 if "progressUpdate" in event_type:
+message = event["body"]["message"]
+print(f"Progress update: {message}")
+self.assertNotIn("Progres tester", message)
 update_found = True
 
 self.assertTrue(start_found)

>From e15090782a93e07e8a260a0594ca02430e68e09f Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Thu, 30 Jan 2025 10:04:04 -0800
Subject: [PATCH 3/7] Migrate to structured data

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:


Differential Revision: https://phabricator.intern.facebook.com/D68927453
---
 lldb/include/lldb/Core/DebuggerEvents.h | 16 +++-
 lldb/tools/lldb-dap/lldb-dap.cpp| 54 +
 2 files changed, 52 insertions(+), 18 deletions(-)

diff --git a/lldb/include/lldb/Core/DebuggerEvents.h 
b/lldb/include/lldb/Core/DebuggerEvents.h
index ca06ee835fde3..49a4ecf8e537e 100644
--- a/lldb/include/lldb/Core/DebuggerEvents.h
+++ b/lldb/include/lldb/Core/DebuggerEvents.h
@@ -44,16 +44,12 @@ class ProgressEventData : public EventData {
   uint64_t GetCompleted() const { return m_completed; }
   uint64_t GetTotal() const { return m_total; }
   std::string GetMessage() const {
-// Only put the title in the message of the progress create event.
-if (m_completed == 0) {
-  std::string message = m_title;
-  if (!m_details.empty()) {
-message.append(": ");
-message.append(m_details);
-  }
-  return message;
-} else
-  return !m_details.empty() ? m_details : std::string();
+std::string message = m_title;
+if (!m_details.empty()) {
+  message.append(": ");
+  message.append(m_details);
+}
+return message;
   }
   const std::string &GetTitle() const { return m_title; }
   const std::string &GetDetails() const { return m_details; }
diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp
index e323990d8b6ed..4b3460190a7c9 100644
--- a/lldb/tools/lldb

[Lldb-commits] [lldb] [WIP] [lldb][TypeSystemClang] Create clang::SourceLocation from DWARF and attach to AST (PR #127829)

2025-02-20 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/127829

>From 1aabc8a93ffac06755cbaf5e6c1fa8913cd63729 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 19 Feb 2025 12:47:30 +
Subject: [PATCH 1/3] [lldb][TypeSystemClang] Create MainFileID for
 TypeSystemClang ASTContexts

---
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 39 +++
 1 file changed, 39 insertions(+)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 1e0c7f0514941..563961b9a4971 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -13,6 +13,7 @@
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/FormatAdapters.h"
 #include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/SmallVectorMemoryBuffer.h"
 
 #include 
 #include 
@@ -361,6 +362,39 @@ static void SetMemberOwningModule(clang::Decl *member,
 }
 }
 
+/// Creates a dummy main file for the given SourceManager.
+/// This file only serves as a container for include locations to other
+/// FileIDs that are put into this type system (either by the ASTImporter
+/// or when TypeSystemClang generates source locations for declarations).
+/// This file is not reflected to disk.
+static clang::FileID CreateDummyMainFile(clang::SourceManager &sm,
+ clang::FileManager &fm) {
+  llvm::StringRef main_file_path = "";
+  // The file contents are empty and should never be seen by the user. The new
+  // line is just there to not throw off any line counting logic that might
+  // expect files to end with a newline.
+  llvm::StringRef main_file_contents = "\n";
+  const time_t mod_time = 0;
+  const off_t file_size = static_cast(main_file_contents.size());
+
+  // Create a virtual FileEntry for our dummy file.
+  auto fe = fm.getVirtualFileRef(main_file_path, file_size, mod_time);
+
+  // Overwrite the file buffer with our empty file contents.
+  llvm::SmallVector buffer;
+  buffer.append(main_file_contents.begin(), main_file_contents.end());
+  auto file_contents = std::make_unique(
+  std::move(buffer), main_file_path);
+  sm.overrideFileContents(fe, std::move(file_contents));
+
+  // Create the actual file id for the FileEntry and set it as the main file.
+  clang::FileID fid =
+  sm.createFileID(fe, SourceLocation(), clang::SrcMgr::C_User);
+  sm.setMainFileID(fid);
+
+  return fid;
+}
+
 char TypeSystemClang::ID;
 
 bool TypeSystemClang::IsOperator(llvm::StringRef name,
@@ -692,6 +726,11 @@ void TypeSystemClang::CreateASTContext() {
   m_diagnostic_consumer_up = std::make_unique();
   m_ast_up->getDiagnostics().setClient(m_diagnostic_consumer_up.get(), false);
 
+  // Set up the MainFileID of this ASTContext. All other FileIDs created
+  // by this TypeSystem will act as-if included into this dummy main file.
+  auto fid = CreateDummyMainFile(*m_source_manager_up, *m_file_manager_up);
+  assert(m_ast_up->getSourceManager().getMainFileID() == fid);
+
   // This can be NULL if we don't know anything about the architecture or if
   // the target for an architecture isn't enabled in the llvm/clang that we
   // built

>From 5d4cbd3e306f02eee80b4fd614b9e155f75d3d1d Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 19 Feb 2025 13:37:01 +
Subject: [PATCH 2/3] [lldb][TypeSystemClang] Set location on functions,
 parameters, enums and structures

---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  | 10 ++--
 .../SymbolFile/NativePDB/PdbAstBuilder.cpp|  2 +-
 .../Plugins/SymbolFile/PDB/PDBASTParser.cpp   |  3 +-
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 48 ++-
 .../TypeSystem/Clang/TypeSystemClang.h| 46 +++---
 lldb/unittests/Symbol/TestTypeSystemClang.cpp |  7 +--
 6 files changed, 78 insertions(+), 38 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 2d4d22559963f..abf3b22b0ae15 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1372,7 +1372,7 @@ DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die,
 ignore_containing_context ? m_ast.GetTranslationUnitDecl()
   : containing_decl_ctx,
 GetOwningClangModule(die), name, clang_type, attrs.storage,
-attrs.is_inline);
+attrs.is_inline, attrs.decl);
 std::free(name_buf);
 
 if (has_template_params) {
@@ -1382,11 +1382,11 @@ DWARFASTParserClang::ParseSubroutine(const DWARFDIE 
&die,
   ignore_containing_context ? m_ast.GetTranslationUnitDecl()
 : containing_decl_ctx,
   GetOwningClangModule(die), attrs.name.GetStringRef(), clang_type,
-  attrs.storage

[Lldb-commits] [lldb] [WIP] [lldb][TypeSystemClang] Create clang::SourceLocation from DWARF and attach to AST (PR #127829)

2025-02-20 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff 1c6cecdbdd2470292ce0b508922d807e3100f85c 
a05a2ca8f8bcf3fb9017d54248fbd32b2e4797b3 --extensions h,cpp -- 
lldb/unittests/Symbol/Inputs/dummy.cpp 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp 
lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h 
lldb/test/API/commands/expression/diagnostics/main.cpp 
lldb/test/Shell/SymbolFile/DWARF/clang-ast-from-dwarf-unamed-and-anon-structs.cpp
 lldb/unittests/Symbol/TestTypeSystemClang.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/unittests/Symbol/Inputs/dummy.cpp 
b/lldb/unittests/Symbol/Inputs/dummy.cpp
index 86a157931b..b47b4a57f6 100644
--- a/lldb/unittests/Symbol/Inputs/dummy.cpp
+++ b/lldb/unittests/Symbol/Inputs/dummy.cpp
@@ -2,8 +2,6 @@
 
 #include "dummy_header1.h"
 
-int main() {
-  return 0;
-}
+int main() { return 0; }
 
 // Some comment at the end

``




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


[Lldb-commits] [lldb] 78d82d3 - [lldb] Store StreamAsynchronousIO in a unique_ptr (NFC) (#127961)

2025-02-20 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2025-02-20T11:13:46-08:00
New Revision: 78d82d3ae7ac99833e1b9c0b529c256f90b6c6cc

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

LOG: [lldb] Store StreamAsynchronousIO in a unique_ptr (NFC) (#127961)

Make StreamAsynchronousIO an unique_ptr instead of a shared_ptr. I tried
passing the class by value, but the llvm::raw_ostream forwarder stored
in the Stream parent class isn't movable and I don't think it's worth
changing that. Additionally, there's a few places that expect a
StreamSP, which are easily created from a StreamUP.

Added: 


Modified: 
lldb/include/lldb/Core/Debugger.h
lldb/include/lldb/lldb-forward.h
lldb/source/Breakpoint/BreakpointOptions.cpp
lldb/source/Commands/CommandObjectCommands.cpp
lldb/source/Commands/CommandObjectWatchpointCommand.cpp
lldb/source/Core/Debugger.cpp
lldb/source/Core/DynamicLoader.cpp

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp

lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Target/Process.cpp
lldb/source/Target/StopInfo.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 9c8a9623fe689..6ebc6147800e1 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -156,9 +156,9 @@ class Debugger : public 
std::enable_shared_from_this,
 
   void RestoreInputTerminalState();
 
-  lldb::StreamSP GetAsyncOutputStream();
+  lldb::StreamUP GetAsyncOutputStream();
 
-  lldb::StreamSP GetAsyncErrorStream();
+  lldb::StreamUP GetAsyncErrorStream();
 
   CommandInterpreter &GetCommandInterpreter() {
 assert(m_command_interpreter_up.get());

diff  --git a/lldb/include/lldb/lldb-forward.h 
b/lldb/include/lldb/lldb-forward.h
index cda55ef06e549..c664d1398f74d 100644
--- a/lldb/include/lldb/lldb-forward.h
+++ b/lldb/include/lldb/lldb-forward.h
@@ -432,6 +432,7 @@ typedef 
std::unique_ptr
 StackFrameRecognizerManagerUP;
 typedef std::shared_ptr StopInfoSP;
 typedef std::shared_ptr StreamSP;
+typedef std::unique_ptr StreamUP;
 typedef std::shared_ptr StreamFileSP;
 typedef std::shared_ptr LockableStreamFileSP;
 typedef std::shared_ptr

diff  --git a/lldb/source/Breakpoint/BreakpointOptions.cpp 
b/lldb/source/Breakpoint/BreakpointOptions.cpp
index 09abcf5e081d2..242b5b30168c5 100644
--- a/lldb/source/Breakpoint/BreakpointOptions.cpp
+++ b/lldb/source/Breakpoint/BreakpointOptions.cpp
@@ -620,10 +620,8 @@ bool BreakpointOptions::BreakpointOptionsCallbackFunction(
 
   // Rig up the results secondary output stream to the debugger's, so the
   // output will come out synchronously if the debugger is set up that way.
-  StreamSP output_stream(debugger.GetAsyncOutputStream());
-  StreamSP error_stream(debugger.GetAsyncErrorStream());
-  result.SetImmediateOutputStream(output_stream);
-  result.SetImmediateErrorStream(error_stream);
+  result.SetImmediateOutputStream(debugger.GetAsyncOutputStream());
+  result.SetImmediateErrorStream(debugger.GetAsyncErrorStream());
 
   CommandInterpreterRunOptions options;
   options.SetStopOnContinue(true);

diff  --git a/lldb/source/Commands/CommandObjectCommands.cpp 
b/lldb/source/Commands/CommandObjectCommands.cpp
index dd841cb5cb4cc..9510cf4d14467 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -815,10 +815,9 @@ a number follows 'f':"
 for (const std::string &line : lines) {
   Status error = AppendRegexSubstitution(line, check_only);
   if (error.Fail()) {
-if (!GetDebugger().GetCommandInterpreter().GetBatchCommandMode()) {
-  StreamSP out_stream = GetDebugger().GetAsyncOutputStream();
-  out_stream->Printf("error: %s\n", error.AsCString());
-}
+if (!GetDebugger().GetCommandInterpreter().GetBatchCommandMode())
+  GetDebugger().GetAsyncOutputStream()->Printf("error: %s\n",
+   error.AsCString());
   }
 }
   }

diff  --git a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp 
b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
index 507ef3fbe4759..32cb80b421fd6 100644
--- a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
@@ -252,10 +252,8 @@ are no syntax errors may indicate that a function was 
declared but never called.
 // Rig up the results secondary output stream to the debugger's, so the
   

[Lldb-commits] [lldb] [lldb] Store StreamAsynchronousIO in a unique_ptr (NFC) (PR #127961)

2025-02-20 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [lldb-dap] Add: show return value on step out (PR #106907)

2025-02-20 Thread via lldb-commits

Da-Viper wrote:

Is there any that needs to be done one the PR?

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


[Lldb-commits] [lldb] Reland "[lldb] Implement basic support for reverse-continue" (#123906)" (PR #123945)

2025-02-20 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:


>From a quick check of the logs, green dragon seems to be set up to build 
>debugserver, too.



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


[Lldb-commits] [lldb] [lldb] Store the return SBValueList in the CommandReturnObject (PR #127566)

2025-02-20 Thread via lldb-commits

jimingham wrote:



> On Feb 20, 2025, at 1:52 AM, Pavel Labath ***@***.***> wrote:
> 
> 
> labath
>  left a comment 
> (llvm/llvm-project#127566)
> That sort of makes sense, but it doesn't sound like you're planning to do 
> that soon, so I'm asking about what should we do until (and if) that happens. 
> The reason I suggested stderr is because that made sense for the commands I'm 
> thinking of. For example, the expression command can produce a result and 
> some warnings and fixit-applied notes. I don't know if these currently go to 
> stderr, but I think it would be okay if they did...
> 
> I don't think it's a good idea for commands to put any of their output 
> anywhere but the command result. Anything that goes to stderr is lost, and 
> particularly if is trying to run their own command loop, so that they are by 
> hand printing the command result, there will be no way to associate that 
> output with the command that produced it.
> 
> I see that there's been a misunderstanding. By "stderr" I meant the "stderr 
> of the CommandReturnObject" (i.e., CommandReturnObject::m_err_stream, 
> returned by SBCommandReturnObject::GetError), not the actual stderr of the 
> debugger. So the convention would be that if CommandReturnObject contains a 
> variable, then its output (GetOutput) would contain a rendering of rendering 
> of that variable (and it can be ignored when doing your own printing), but 
> the error output (GetError) would contain any additional data (like the 
> fixits) that can/should be anyway.
> 
>   
> 
> 
> labath
>  left a comment 
> (llvm/llvm-project#127566)
>  
> That sort of makes sense, but it doesn't sound like you're planning to do 
> that soon, so I'm asking about what should we do until (and if) that happens. 
> The reason I suggested stderr is because that made sense for the commands I'm 
> thinking of. For example, the expression command can produce a result and 
> some warnings and fixit-applied notes. I don't know if these currently go to 
> stderr, but I think it would be okay if they did...
> 
> I don't think it's a good idea for commands to put any of their output 
> anywhere but the command result. Anything that goes to stderr is lost, and 
> particularly if is trying to run their own command loop, so that they are by 
> hand printing the command result, there will be no way to associate that 
> output with the command that produced it.
> 
> I see that there's been a misunderstanding. By "stderr" I meant the "stderr 
> of the CommandReturnObject" (i.e., CommandReturnObject::m_err_stream, 
> returned by SBCommandReturnObject::GetError), not the actual stderr of the 
> debugger. So the convention would be that if CommandReturnObject contains a 
> variable, then its output (GetOutput) would contain a rendering of rendering 
> of that variable (and it can be ignored when doing your own printing), but 
> the error output (GetError) would contain any additional data (like the 
> fixits) that can/should be anyway.
> 
> I'm sorry about the confusion. Does that sound better?
> 
That would work.
> We don't dump warnings on successful expression evaluation, though we do 
> print fixits. I would suggest for the near term that if a command that 
> produces a ValueObject returns successfully but with "notes" we should put 
> those notes in the Error object - but still have the state be Success. That 
> would make sense for the warnings and fixits since Adrian has been working on 
> getting the error output into a structured form to better hold compiler 
> warnings and errors.
> 
> I sort of like that, particularly as it lets you obtain the diagnostics in a 
> structured form, but it also feels kinda wrong because -- if I'm not mistaken 
> -- we are currently only setting the error field if we failed to retrieve the 
> value. It sounds like it could confuse some code which is not expecting it.
> 
We always have a Status object in the ValueObject.  Up to now, if the Status 
object is in a Success state, then the contents of the Status object is 
undefined.  So I was suggesting giving a meaning to when the Status object is 
in a "Success" state for a ValueObject that is retrieved from a 
CommandReturnObject.  This shouldn't cause problems with other clients.  No one 
should be checking whether the current command returned an error by checking 
whether the status object has text in it or not, you should be calling 
Success() and seeing whether it is true or false.  After all, a failing command 
is not obligated to put error text in the Status.

OTOH, SBError (lldb_private::Status) doesn't have a "set text w/o setting the 
error state" method, so maybe it's better not to add that for just 

[Lldb-commits] [lldb] [LLDB][Telemetry]Define DebuggerTelemetryInfo and related methods (PR #127696)

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


@@ -56,13 +60,83 @@ struct LLDBBaseTelemetryInfo : public 
llvm::telemetry::TelemetryInfo {
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 };
 
+/// Describes the exit status of a debugger.
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct DebuggerTelemetryInfo : public LLDBBaseTelemetryInfo {
+  std::string username;
+  std::string lldb_git_sha;
+  std::string lldb_path;
+  std::string cwd;
+  std::optional exit_desc;
+
+  DebuggerTelemetryInfo() = default;
+
+  // Provide a copy ctor because we may need to make a copy before
+  // sanitizing the data.
+  // (The sanitization might differ between different Destination classes).

oontvoo wrote:

I've removed the copy ctor - agreed that it could be an impl detail. no need to 
spell it out here.

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


[Lldb-commits] [lldb] [LLDB][Telemetry]Define DebuggerTelemetryInfo and related methods (PR #127696)

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


@@ -73,6 +147,10 @@ class TelemetryManager : public llvm::telemetry::Manager {
 
 private:
   std::unique_ptr m_config;
+  // Each debugger is assigned a unique ID (session_id).
+  // All TelemetryInfo entries emitted for the same debugger instance
+  // will get the same session_id.
+  llvm::DenseMap session_ids;

oontvoo wrote:

done

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


[Lldb-commits] [lldb] [LLDB][Telemetry]Define DebuggerTelemetryInfo and related methods (PR #127696)

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

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

>From 24e9f78744f98ecf3ac01f1f719f1eac9b3479f0 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 18 Feb 2025 15:58:08 -0500
Subject: [PATCH 1/4] [LLDB][Telemetry]Define DebuggerTelemetryInfo and related
 methods

- This type of entry is used to collect data about the debugger startup/exit
- Tests will be added (They may need to be shell test with a "test-only" 
TelemetryManager plugin defined. I'm trying to figure out how to get that 
linked only when tests are running and not to the LLDB binary all the time.
---
 lldb/include/lldb/Core/Telemetry.h |  78 +++
 lldb/source/Core/Debugger.cpp  |  40 ++
 lldb/source/Core/Telemetry.cpp | 115 +
 3 files changed, 220 insertions(+), 13 deletions(-)

diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
index b72556ecaf3c9..d6eec5dc687be 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -13,6 +13,7 @@
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Utility/StructuredData.h"
 #include "lldb/lldb-forward.h"
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
@@ -29,6 +30,9 @@ namespace telemetry {
 
 struct LLDBEntryKind : public ::llvm::telemetry::EntryKind {
   static const llvm::telemetry::KindType BaseInfo = 0b11000;
+  static const llvm::telemetry::KindType DebuggerInfo = 0b11001;
+  // There are other entries in between (added in separate PRs)
+  static const llvm::telemetry::KindType MiscInfo = 0b0;
 };
 
 /// Defines a convenient type for timestamp of various events.
@@ -56,6 +60,71 @@ struct LLDBBaseTelemetryInfo : public 
llvm::telemetry::TelemetryInfo {
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 };
 
+/// Describes the exit status of a debugger.
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct DebuggerTelemetryInfo : public LLDBBaseTelemetryInfo {
+  std::string username;
+  std::string lldb_git_sha;
+  std::string lldb_path;
+  std::string cwd;
+  std::optional exit_desc;
+
+  DebuggerTelemetryInfo() = default;
+
+  // Provide a copy ctor because we may need to make a copy before
+  // sanitizing the data.
+  // (The sanitization might differ between different Destination classes).
+  DebuggerTelemetryInfo(const DebuggerTelemetryInfo &other) {
+username = other.username;
+lldb_git_sha = other.lldb_git_sha;
+lldb_path = other.lldb_path;
+cwd = other.cwd;
+  };
+
+  llvm::telemetry::KindType getKind() const override {
+return LLDBEntryKind::DebuggerInfo;
+  }
+
+  static bool classof(const llvm::telemetry::TelemetryInfo *T) {
+return T->getKind() == LLDBEntryKind::DebuggerInfo;
+  }
+
+  void serialize(llvm::telemetry::Serializer &serializer) const override;
+};
+
+/// The "catch-all" entry to store a set of non-standard data, such as
+/// error-messages, etc.
+struct MiscTelemetryInfo : public LLDBBaseTelemetryInfo {
+  /// If the event is/can be associated with a target entry,
+  /// this field contains that target's UUID.
+  ///  otherwise.
+  std::string target_uuid;
+
+  /// Set of key-value pairs for any optional (or impl-specific) data
+  std::map meta_data;
+
+  MiscTelemetryInfo() = default;
+
+  MiscTelemetryInfo(const MiscTelemetryInfo &other) {
+target_uuid = other.target_uuid;
+meta_data = other.meta_data;
+  }
+
+  llvm::telemetry::KindType getKind() const override {
+return LLDBEntryKind::MiscInfo;
+  }
+
+  static bool classof(const llvm::telemetry::TelemetryInfo *T) {
+return T->getKind() == LLDBEntryKind::MiscInfo;
+  }
+
+  void serialize(llvm::telemetry::Serializer &serializer) const override;
+};
+
 /// The base Telemetry manager instance in LLDB.
 /// This class declares additional instrumentation points
 /// applicable to LLDB.
@@ -63,6 +132,11 @@ class TelemetryManager : public llvm::telemetry::Manager {
 public:
   llvm::Error preDispatch(llvm::telemetry::TelemetryInfo *entry) override;
 
+  const llvm::telemetry::Config *getConfig();
+
+  void atDebuggerStartup(DebuggerTelemetryInfo *entry);
+  void atDebuggerExit(DebuggerTelemetryInfo *entry);
+
   virtual llvm::StringRef GetInstanceName() const = 0;
   static TelemetryManager *getInstance();
 
@@ -73,6 +147,10 @@ class TelemetryManager : public llvm::telemetry::Manager {
 
 private:
   std::unique_ptr m_config;
+  // Each debugger is assigned a unique ID (session_id).
+  // All TelemetryInfo entries emitted for the same debugger instance
+  // will get the same session_id.
+  llvm::DenseMap session_ids;
   static std::unique_ptr g_instance;
 };
 
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 18569e155b517..b458abc798a9e 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -62,6 +62,7 @@
 

[Lldb-commits] [lldb] Reland "[lldb] Implement basic support for reverse-continue" (#123906)" (PR #123945)

2025-02-20 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

> From a quick check of the logs, green dragon seems to be set up to build 
> debugserver, too.

greendragon probably does build debugserver, but tests use Xcode's debugserver 
for proper codesigning, not the built debugserver.

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


[Lldb-commits] [lldb] [LLDB][Telemetry]Define DebuggerTelemetryInfo and related methods (PR #127696)

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


@@ -56,13 +60,83 @@ struct LLDBBaseTelemetryInfo : public 
llvm::telemetry::TelemetryInfo {
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 };
 
+/// Describes the exit status of a debugger.
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct DebuggerTelemetryInfo : public LLDBBaseTelemetryInfo {
+  std::string username;
+  std::string lldb_git_sha;
+  std::string lldb_path;
+  std::string cwd;
+  std::optional exit_desc;
+
+  DebuggerTelemetryInfo() = default;
+
+  // Provide a copy ctor because we may need to make a copy before
+  // sanitizing the data.
+  // (The sanitization might differ between different Destination classes).
+  DebuggerTelemetryInfo(const DebuggerTelemetryInfo &other) {
+username = other.username;
+lldb_git_sha = other.lldb_git_sha;
+lldb_path = other.lldb_path;
+cwd = other.cwd;
+  };
+
+  llvm::telemetry::KindType getKind() const override {
+return LLDBEntryKind::DebuggerInfo;
+  }
+
+  static bool classof(const llvm::telemetry::TelemetryInfo *T) {
+return T->getKind() == LLDBEntryKind::DebuggerInfo;
+  }
+
+  void serialize(llvm::telemetry::Serializer &serializer) const override;
+};
+
+/// The "catch-all" entry to store a set of non-standard data, such as
+/// error-messages, etc.
+struct MiscTelemetryInfo : public LLDBBaseTelemetryInfo {
+  /// If the event is/can be associated with a target entry,
+  /// this field contains that target's UUID.
+  ///  otherwise.
+  std::string target_uuid;
+
+  /// Set of key-value pairs for any optional (or impl-specific) data
+  std::map meta_data;
+
+  MiscTelemetryInfo() = default;
+
+  MiscTelemetryInfo(const MiscTelemetryInfo &other) {
+target_uuid = other.target_uuid;
+meta_data = other.meta_data;
+  }
+
+  llvm::telemetry::KindType getKind() const override {
+return LLDBEntryKind::MiscInfo;
+  }
+
+  static bool classof(const llvm::telemetry::TelemetryInfo *T) {
+return T->getKind() == LLDBEntryKind::MiscInfo;
+  }
+
+  void serialize(llvm::telemetry::Serializer &serializer) const override;
+};
+
 /// The base Telemetry manager instance in LLDB.
 /// This class declares additional instrumentation points
 /// applicable to LLDB.
 class TelemetryManager : public llvm::telemetry::Manager {
 public:
   llvm::Error preDispatch(llvm::telemetry::TelemetryInfo *entry) override;
 
+  const llvm::telemetry::Config *getConfig();
+
+  void atDebuggerStartup(DebuggerTelemetryInfo *entry);
+  void atDebuggerExit(DebuggerTelemetryInfo *entry);

oontvoo wrote:

done

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


[Lldb-commits] [lldb] Allow option to ignore module load errors in ScriptedProcess (PR #127153)

2025-02-20 Thread Med Ismail Bennani via lldb-commits

medismailben wrote:

> @jimingham @medismailben Can you please let me know if you have more 
> questions regarding the problem and solution ? Right now, I have 
> conditionally ignored the modules which are not created and only loaded the 
> successful ones, if needed I can always load the successfully created modules 
> in scripted process

So we've talked offline with @jimingham and there are 2 things we things should 
change here:
- ScriptedProcess module loading is too strict (compared to non-ScriptedProcess 
approach). I don't think having a variable in the ScriptedProcess to skip 
loading error per module is a good way to address this issue. Instead I'd just 
make the `ForEach` call not return and log loading errors in the lambda.
> a. Sample Image List of child elf-core target. Note the * at the end, which 
> indicates placeholder object
>
> [0]  0x1234455 [vdso]   /path/to/a.out
> [1] 0x1234566  /path/to/libc.so(*)
> [2] ...
- Is this behavior something that's specific to ElfCore or is that generic to 
any process plugin ? If it's the former, I really think this should become an 
lldb-wide thing. This can be done as a follow-up.

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


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

2025-02-20 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere updated 
https://github.com/llvm/llvm-project/pull/121860

>From e3df7eb885bc27464f6ba3cddd47147fa48f60f8 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 17 Jan 2025 17:10:36 -0800
Subject: [PATCH] [lldb] Implement a statusline in LLDB
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Add a statusline to command-line LLDB to display progress events and
other information related to the current state of the debugger. The
statusline is a dedicated area displayed the bottom of the screen. The
contents of the status line are configurable through a setting
consisting of LLDB’s format strings.

The statusline is configurable through the `statusline-format` setting.
The default configuration shows the target name, the current file, the
stop reason and the current progress event.

```
(lldb) settings show statusline-format
statusline-format (format-string) = 
"${ansi.bg.cyan}${ansi.fg.black}{${target.file.basename}}{ | 
${line.file.basename}:${line.number}:${line.column}}{ | ${thread.stop-reason}}{ 
| {${progress.count} }${progress.message}}"
```

The statusline is enabled by default, but can be disabled with the
following setting:

```
(lldb) settings set show-statusline false
```

The statusline supersedes the current progress reporting implementation.
Consequently, the following settings no longer have any effect (but
continue to exist):

```
show-progress -- Whether to show progress or not if the debugger's 
output is an interactive color-enabled terminal.
show-progress-ansi-prefix -- When displaying progress in a color-enabled 
terminal, use the ANSI terminal code specified in this format immediately 
before the progress message.
show-progress-ansi-suffix -- When displaying progress in a color-enabled 
terminal, use the ANSI terminal code specified in this format immediately after 
the progress message.
```

RFC: https://discourse.llvm.org/t/rfc-lldb-statusline/83948
---
 lldb/include/lldb/Core/Debugger.h |  24 ++-
 lldb/include/lldb/Core/FormatEntity.h |   4 +-
 lldb/include/lldb/Core/Statusline.h   |  58 ++
 .../Python/lldbsuite/test/lldbtest.py |   2 +
 lldb/source/Core/CMakeLists.txt   |   1 +
 lldb/source/Core/CoreProperties.td|   8 +
 lldb/source/Core/Debugger.cpp | 159 
 lldb/source/Core/FormatEntity.cpp |  44 -
 lldb/source/Core/Statusline.cpp   | 171 ++
 .../TestTrimmedProgressReporting.py   |  51 --
 .../API/functionalities/statusline/Makefile   |   3 +
 .../statusline/TestStatusline.py  |  46 +
 .../API/functionalities/statusline/main.c |  11 ++
 13 files changed, 447 insertions(+), 135 deletions(-)
 create mode 100644 lldb/include/lldb/Core/Statusline.h
 create mode 100644 lldb/source/Core/Statusline.cpp
 delete mode 100644 
lldb/test/API/functionalities/progress_reporting/TestTrimmedProgressReporting.py
 create mode 100644 lldb/test/API/functionalities/statusline/Makefile
 create mode 100644 lldb/test/API/functionalities/statusline/TestStatusline.py
 create mode 100644 lldb/test/API/functionalities/statusline/main.c

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ebc6147800e1..9e2100662c6de 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/Statusline.h"
 #include "lldb/Core/UserSettingsController.h"
 #include "lldb/Host/HostThread.h"
 #include "lldb/Host/StreamFile.h"
@@ -303,6 +304,10 @@ class Debugger : public 
std::enable_shared_from_this,
 
   bool SetShowProgress(bool show_progress);
 
+  bool GetShowStatusline() const;
+
+  const FormatEntity::Entry *GetStatuslineFormat() const;
+
   llvm::StringRef GetShowProgressAnsiPrefix() const;
 
   llvm::StringRef GetShowProgressAnsiSuffix() const;
@@ -599,11 +604,20 @@ class Debugger : public 
std::enable_shared_from_this,
 return m_source_file_cache;
   }
 
+  struct ProgressReport {
+uint64_t id;
+uint64_t completed;
+uint64_t total;
+std::string message;
+  };
+  std::optional GetCurrentProgressReport() const;
+
 protected:
   friend class CommandInterpreter;
   friend class REPL;
   friend class Progress;
   friend class ProgressManager;
+  friend class Statusline;
 
   /// Report progress events.
   ///
@@ -656,6 +670,8 @@ class Debugger : public 
std::enable_shared_from_this,
   lldb::LockableStreamFileSP GetErrorStreamSP() { return m_error_stream_sp; }
   /// @}
 
+  bool StatuslineSupported();
+
   void PushIOHandler(const lldb::IOHandlerSP &reader_sp,
  bool cancel_top_handler = true);
 
@@ -732,7 +748,7 @@ class Debugger : public 
std::enable_shared_from_this,
   IOHandlerStack m_io_handler_stack;
   std::recur

[Lldb-commits] [lldb] 58571c8 - [lldb] Un-XFAIL TestDeadStrip.py on windows

2025-02-20 Thread via lldb-commits

Author: Pavel Labath
Date: 2025-02-20T13:23:03+01:00
New Revision: 58571c82ef93b32cd0ea757e23ec4ff83f8fc3c0

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

LOG: [lldb] Un-XFAIL TestDeadStrip.py on windows

I suspect it was fixed by #127059. aarch64 is the only windows bot we have now, 
so it's can't be certain it's fixed everywhere, but also I have no reason to 
believe otherwise.

Fixes #43774.

Added: 


Modified: 
lldb/test/API/functionalities/dead-strip/TestDeadStrip.py

Removed: 




diff  --git a/lldb/test/API/functionalities/dead-strip/TestDeadStrip.py 
b/lldb/test/API/functionalities/dead-strip/TestDeadStrip.py
index edaf609e98618..ef3b00d75b599 100644
--- a/lldb/test/API/functionalities/dead-strip/TestDeadStrip.py
+++ b/lldb/test/API/functionalities/dead-strip/TestDeadStrip.py
@@ -10,7 +10,6 @@
 
 
 class DeadStripTestCase(TestBase):
-@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr44429")
 def test(self):
 """Test breakpoint works correctly with dead-code stripping."""
 self.build()



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


[Lldb-commits] [lldb] [llvm] [lldb][LoongArch] Complete register alias name in `AugmentRegisterInfo` (PR #124059)

2025-02-20 Thread via lldb-commits

https://github.com/wangleiat updated 
https://github.com/llvm/llvm-project/pull/124059

>From f404df6b2ac7b7ab33e3baadd3830154904a Mon Sep 17 00:00:00 2001
From: Ray Wang 
Date: Thu, 23 Jan 2025 12:13:32 +0800
Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.5-bogner
---
 .../ABI/LoongArch/ABISysV_loongarch.cpp   | 38 +++
 1 file changed, 14 insertions(+), 24 deletions(-)

diff --git a/lldb/source/Plugins/ABI/LoongArch/ABISysV_loongarch.cpp 
b/lldb/source/Plugins/ABI/LoongArch/ABISysV_loongarch.cpp
index dc7e9bba00067..272c6a6be529f 100644
--- a/lldb/source/Plugins/ABI/LoongArch/ABISysV_loongarch.cpp
+++ b/lldb/source/Plugins/ABI/LoongArch/ABISysV_loongarch.cpp
@@ -644,32 +644,22 @@ void ABISysV_loongarch::AugmentRegisterInfo(
 std::vector ®s) {
   lldb_private::RegInfoBasedABI::AugmentRegisterInfo(regs);
 
+  static const std::unordered_map reg_aliases = {
+  {"r0", "zero"}, {"r1", "ra"},  {"r2", "tp"},  {"r3", "sp"},
+  {"r4", "a0"},   {"r5", "a1"},  {"r6", "a2"},  {"r7", "a3"},
+  {"r8", "a4"},   {"r9", "a5"},  {"r10", "a6"}, {"r11", "a7"},
+  {"r12", "t0"},  {"r13", "t1"}, {"r14", "t2"}, {"r15", "t3"},
+  {"r16", "t4"},  {"r17", "t5"}, {"r18", "t6"}, {"r19", "t7"},
+  {"r20", "t8"},  {"r22", "fp"}, {"r23", "s0"}, {"r24", "s1"},
+  {"r25", "s2"},  {"r26", "s3"}, {"r27", "s4"}, {"r28", "s5"},
+  {"r29", "s6"},  {"r30", "s7"}, {"r31", "s8"}};
+
   for (auto it : llvm::enumerate(regs)) {
 // Set alt name for certain registers for convenience
-if (it.value().name == "r0")
-  it.value().alt_name.SetCString("zero");
-else if (it.value().name == "r1")
-  it.value().alt_name.SetCString("ra");
-else if (it.value().name == "r3")
-  it.value().alt_name.SetCString("sp");
-else if (it.value().name == "r22")
-  it.value().alt_name.SetCString("fp");
-else if (it.value().name == "r4")
-  it.value().alt_name.SetCString("a0");
-else if (it.value().name == "r5")
-  it.value().alt_name.SetCString("a1");
-else if (it.value().name == "r6")
-  it.value().alt_name.SetCString("a2");
-else if (it.value().name == "r7")
-  it.value().alt_name.SetCString("a3");
-else if (it.value().name == "r8")
-  it.value().alt_name.SetCString("a4");
-else if (it.value().name == "r9")
-  it.value().alt_name.SetCString("a5");
-else if (it.value().name == "r10")
-  it.value().alt_name.SetCString("a6");
-else if (it.value().name == "r11")
-  it.value().alt_name.SetCString("a7");
+std::string reg_name = it.value().name.GetStringRef().str();
+if (auto alias = reg_aliases.find(reg_name); alias != reg_aliases.end()) {
+  it.value().alt_name.SetCString(alias->second.c_str());
+}
 
 // Set generic regnum so lldb knows what the PC, etc is
 it.value().regnum_generic = GetGenericNum(it.value().name.GetStringRef());

>From d03f4f2b191c09d6492249aa5e0d50fc62a5a434 Mon Sep 17 00:00:00 2001
From: Ray Wang 
Date: Wed, 5 Feb 2025 17:58:09 +0800
Subject: [PATCH 2/3] add test

Created using spr 1.3.5-bogner
---
 .../postmortem/elf-core/TestLinuxCore.py  | 82 ++-
 1 file changed, 44 insertions(+), 38 deletions(-)

diff --git a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py 
b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
index 376d6492d83b6..adabac106f3e3 100644
--- a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
+++ b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
@@ -642,8 +642,7 @@ def test_aarch64_sve_regs_full(self):
 )
 # RMode should have enumerator descriptions.
 self.expect(
-"register info fpcr",
-substrs=["RMode: 0 = RN, 1 = RP, 2 = RM, 3 = RZ"],
+"register info fpcr", substrs=["RMode: 0 = RN, 1 = RP, 2 = RM, 3 = 
RZ"]
 )
 
 @skipIfLLVMTargetMissing("AArch64")
@@ -852,41 +851,42 @@ def test_loongarch64_regs(self):
 self.assertTrue(target, VALID_TARGET)
 process = target.LoadCore("linux-loongarch64.core")
 
-values = {}
-values["r0"] = "0x"
-values["r1"] = "0x0001216c"
-values["r2"] = "0x"
-values["r3"] = "0x7b8249e0"
-values["r4"] = "0x"
-values["r5"] = "0x0001210c"
-values["r6"] = "0x"
-values["r7"] = "0x"
-values["r8"] = "0x"
-values["r9"] = "0x"
-values["r10"] = "0x"
-values["r11"] = "0x00dd"
-values["r12"] = "0x"
-values["r13"] = "0x002f"
-values["r14"] = "0x"
-values["r15"] = "0x

[Lldb-commits] [lldb] [llvm] [lldb][LoongArch] Complete register alias name in `AugmentRegisterInfo` (PR #124059)

2025-02-20 Thread via lldb-commits

wangleiat wrote:

> Please add a test like `lldb/test/Shell/Register/aarch64-gp-read.test` which 
> tests the normal and alias names using a live process.
> 
> Note that the main "trick" of that test is to manually insert a breakpoint 
> instruction:
> 
> ```
>   asm volatile(
> "ldp  x0,  x1,  [%0]\n\t"
> <...>
> "brk  #0\n\t"
> <...>
>   );
> ```
> 
> Then lldb will stop there, before the compiler restores anything.
> 
> The usual way to do these tests is set each register to its number plus some 
> offset. x0 = 1, x1 = 2, etc.
> 
> One is being added for RISC-V in #124475, so you can use that as an example.

Thank you, the test case has been added.

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


[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. (PR #116392)

2025-02-20 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

sorry for the late review, this LGTM
I suggested refactoring main a bit. If you can do it, it would be great, but 
all good if you don't. But next time we add more stuff to main, it would be 
good simplify that function a bit

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


[Lldb-commits] [lldb] [lldb] Fix GCC's `-Wreturn-type` warnings (PR #127974)

2025-02-20 Thread via lldb-commits

https://github.com/foxtran created 
https://github.com/llvm/llvm-project/pull/127974

This patch fixes `-Wreturn-type` warnings which happens if LLVM is built with 
GCC compiler (14.1 is used for detecting)

Warnings:
```
llvm-project/lldb/source/ValueObject/DILLexer.cpp: In static member function 
‘static llvm::StringRef lldb_private::dil::Token::GetTokenName(Kind)’:
llvm-project/lldb/source/ValueObject/DILLexer.cpp:33:1: warning: control 
reaches end of non-void function [-Wreturn-type]
   33 | }
  | ^
```
and:
```
llvm-project/lldb/source/DataFormatters/TypeSummary.cpp: In member function 
‘virtual std::string lldb_private::TypeSummaryImpl::GetSummaryKindName()’:
llvm-project/lldb/source/DataFormatters/TypeSummary.cpp:62:1: warning: control 
reaches end of non-void function [-Wreturn-type]
   62 | }
  | ^
```

Technically, it is a bug in GCC (see #115345), however, UBSan with Clang should 
detect these places, therefore it would be nice to provide a return statement 
for all possible inputs (even invalid). 

>From 5d5aea82763f32445ae5ef86927fff5032f29786 Mon Sep 17 00:00:00 2001
From: "Igor S. Gerasimov" 
Date: Thu, 20 Feb 2025 10:04:13 +0100
Subject: [PATCH] Fix GCC's -Wreturn-type warning

---
 lldb/source/DataFormatters/TypeSummary.cpp | 2 ++
 lldb/source/ValueObject/DILLexer.cpp   | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/lldb/source/DataFormatters/TypeSummary.cpp 
b/lldb/source/DataFormatters/TypeSummary.cpp
index 2c863b364538f..1b73efa398d43 100644
--- a/lldb/source/DataFormatters/TypeSummary.cpp
+++ b/lldb/source/DataFormatters/TypeSummary.cpp
@@ -58,6 +58,8 @@ std::string TypeSummaryImpl::GetSummaryKindName() {
 return "c++";
   case Kind::eBytecode:
 return "bytecode";
+  case default:
+return "unknown";
   }
 }
 
diff --git a/lldb/source/ValueObject/DILLexer.cpp 
b/lldb/source/ValueObject/DILLexer.cpp
index c7acfec347af4..a637fc1c978c7 100644
--- a/lldb/source/ValueObject/DILLexer.cpp
+++ b/lldb/source/ValueObject/DILLexer.cpp
@@ -29,6 +29,8 @@ llvm::StringRef Token::GetTokenName(Kind kind) {
 return "l_paren";
   case Kind::r_paren:
 return "r_paren";
+  case default:
+return "unknown";
   }
 }
 

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


[Lldb-commits] [lldb] [lldb] Fix GCC's `-Wreturn-type` warnings (PR #127974)

2025-02-20 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (foxtran)


Changes

This patch fixes `-Wreturn-type` warnings which happens if LLVM is built with 
GCC compiler (14.1 is used for detecting)

Warnings:
```
llvm-project/lldb/source/ValueObject/DILLexer.cpp: In static member function 
‘static llvm::StringRef lldb_private::dil::Token::GetTokenName(Kind)’:
llvm-project/lldb/source/ValueObject/DILLexer.cpp:33:1: warning: control 
reaches end of non-void function [-Wreturn-type]
   33 | }
  | ^
```
and:
```
llvm-project/lldb/source/DataFormatters/TypeSummary.cpp: In member function 
‘virtual std::string lldb_private::TypeSummaryImpl::GetSummaryKindName()’:
llvm-project/lldb/source/DataFormatters/TypeSummary.cpp:62:1: warning: control 
reaches end of non-void function [-Wreturn-type]
   62 | }
  | ^
```

Technically, it is a bug in GCC (see #115345), however, UBSan with 
Clang should detect these places, therefore it would be nice to provide a 
return statement for all possible inputs (even invalid). 

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


2 Files Affected:

- (modified) lldb/source/DataFormatters/TypeSummary.cpp (+2) 
- (modified) lldb/source/ValueObject/DILLexer.cpp (+2) 


``diff
diff --git a/lldb/source/DataFormatters/TypeSummary.cpp 
b/lldb/source/DataFormatters/TypeSummary.cpp
index 2c863b364538f..1b73efa398d43 100644
--- a/lldb/source/DataFormatters/TypeSummary.cpp
+++ b/lldb/source/DataFormatters/TypeSummary.cpp
@@ -58,6 +58,8 @@ std::string TypeSummaryImpl::GetSummaryKindName() {
 return "c++";
   case Kind::eBytecode:
 return "bytecode";
+  case default:
+return "unknown";
   }
 }
 
diff --git a/lldb/source/ValueObject/DILLexer.cpp 
b/lldb/source/ValueObject/DILLexer.cpp
index c7acfec347af4..a637fc1c978c7 100644
--- a/lldb/source/ValueObject/DILLexer.cpp
+++ b/lldb/source/ValueObject/DILLexer.cpp
@@ -29,6 +29,8 @@ llvm::StringRef Token::GetTokenName(Kind kind) {
 return "l_paren";
   case Kind::r_paren:
 return "r_paren";
+  case default:
+return "unknown";
   }
 }
 

``




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


[Lldb-commits] [lldb] 367ecc6 - [lldb] Renaissance LineTable sequences (#127800)

2025-02-20 Thread via lldb-commits

Author: Pavel Labath
Date: 2025-02-20T12:17:11+01:00
New Revision: 367ecc63338da1ff98d63a41bafc9b54d5c3eb6d

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

LOG: [lldb] Renaissance LineTable sequences (#127800)

LineSeqeunce is basically a vector, except that users aren't supposed to
know that. This implements the same concept in a slightly simpler
fashion.

Added: 


Modified: 
lldb/include/lldb/Symbol/LineTable.h
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/source/Symbol/LineTable.cpp
lldb/unittests/Symbol/LineTableTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/LineTable.h 
b/lldb/include/lldb/Symbol/LineTable.h
index c1a973635cdd4..8dda9c7362f12 100644
--- a/lldb/include/lldb/Symbol/LineTable.h
+++ b/lldb/include/lldb/Symbol/LineTable.h
@@ -20,25 +20,11 @@
 
 namespace lldb_private {
 
-/// \class LineSequence LineTable.h "lldb/Symbol/LineTable.h" An abstract base
-/// class used during symbol table creation.
-class LineSequence {
-public:
-  LineSequence();
-
-  virtual ~LineSequence() = default;
-
-  virtual void Clear() = 0;
-
-private:
-  LineSequence(const LineSequence &) = delete;
-  const LineSequence &operator=(const LineSequence &) = delete;
-};
-
 /// \class LineTable LineTable.h "lldb/Symbol/LineTable.h"
 /// A line table class.
 class LineTable {
 public:
+  class Sequence;
   /// Construct with compile unit.
   ///
   /// \param[in] comp_unit
@@ -49,8 +35,7 @@ class LineTable {
   ///
   /// \param[in] sequences
   /// Unsorted list of line sequences.
-  LineTable(CompileUnit *comp_unit,
-std::vector> &&sequences);
+  LineTable(CompileUnit *comp_unit, std::vector &&sequences);
 
   /// Destructor.
   ~LineTable();
@@ -73,20 +58,17 @@ class LineTable {
bool is_start_of_basic_block, bool is_prologue_end,
bool is_epilogue_begin, bool is_terminal_entry);
 
-  // Used to instantiate the LineSequence helper class
-  static std::unique_ptr CreateLineSequenceContainer();
-
   // Append an entry to a caller-provided collection that will later be
   // inserted in this line table.
-  static void AppendLineEntryToSequence(LineSequence *sequence, lldb::addr_t 
file_addr,
- uint32_t line, uint16_t column,
- uint16_t file_idx, bool is_start_of_statement,
- bool is_start_of_basic_block,
- bool is_prologue_end, bool is_epilogue_begin,
- bool is_terminal_entry);
+  static void
+  AppendLineEntryToSequence(Sequence &sequence, lldb::addr_t file_addr,
+uint32_t line, uint16_t column, uint16_t file_idx,
+bool is_start_of_statement,
+bool is_start_of_basic_block, bool is_prologue_end,
+bool is_epilogue_begin, bool is_terminal_entry);
 
   // Insert a sequence of entries into this line table.
-  void InsertSequence(LineSequence *sequence);
+  void InsertSequence(Sequence sequence);
 
   /// Dump all line entries in this line table to the stream \a s.
   ///
@@ -274,17 +256,6 @@ class LineTable {
   return 0;
 }
 
-class LessThanBinaryPredicate {
-public:
-  LessThanBinaryPredicate(LineTable *line_table);
-  bool operator()(const LineTable::Entry &, const LineTable::Entry &) 
const;
-  bool operator()(const std::unique_ptr &,
-  const std::unique_ptr &) const;
-
-protected:
-  LineTable *m_line_table;
-};
-
 static bool EntryAddressLessThan(const Entry &lhs, const Entry &rhs) {
   return lhs.file_addr < rhs.file_addr;
 }
@@ -316,6 +287,35 @@ class LineTable {
 uint16_t file_idx = 0;
   };
 
+  class Sequence {
+  public:
+Sequence() = default;
+// Moving clears moved-from object so it can be used anew. Copying is
+// generally an error. C++ doesn't guarantee that a moved-from vector is
+// empty(), so we clear it explicitly.
+Sequence(Sequence &&rhs) : m_entries(std::exchange(rhs.m_entries, {})) {}
+Sequence &operator=(Sequence &&rhs) {
+  m_entries = std::exchange(rhs.m_entries, {});
+  return *this;
+}
+Sequence(const Sequence &) = delete;
+Sequence &operator=(const Sequence &) = delete;
+
+  private:
+std::vector m_entries;
+friend class LineTable;
+  };
+
+  class LessThanBinaryPredicate {
+  public:
+LessThanBinaryPredicate(LineTable *line_table) : m_line_table(line_table) 
{}
+bool 

[Lldb-commits] [lldb] [lldb] Renaissance LineTable sequences (PR #127800)

2025-02-20 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [LLDB][Telemetry]Define DebuggerTelemetryInfo and related methods (PR #127696)

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


@@ -56,13 +60,83 @@ struct LLDBBaseTelemetryInfo : public 
llvm::telemetry::TelemetryInfo {
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 };
 
+/// Describes the exit status of a debugger.
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct DebuggerTelemetryInfo : public LLDBBaseTelemetryInfo {

oontvoo wrote:

Ah, actually, we could make all the `atDebuggerStartup`,`atDebuggerExit`, etc 
methods virtual.

The upstream can collect a minimal set of common data.
Then the downstream's impl can override it to collect more (or less) data as 
needed.
Would that be an acceptable approach?

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


[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. (PR #116392)

2025-02-20 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. (PR #116392)

2025-02-20 Thread Walter Erquinigo via lldb-commits


@@ -4952,6 +4895,29 @@ static int DuplicateFileDescriptor(int fd) {
 #endif
 }
 
+static llvm::Expected>
+validateConnection(llvm::StringRef conn) {
+  auto uri = lldb_private::URI::Parse(conn);
+
+  if (uri && (uri->scheme == "tcp" || uri->scheme == "connect" ||
+  !uri->hostname.empty() || uri->port)) {
+return std::make_pair(
+Socket::ProtocolTcp,
+formatv("[{0}]:{1}", uri->hostname.empty() ? "0.0.0.0" : uri->hostname,
+uri->port.value_or(0)));
+  }
+
+  if (uri && (uri->scheme == "unix" || uri->scheme == "unix-connect" ||
+  uri->path != "/")) {
+return std::make_pair(Socket::ProtocolUnixDomain, uri->path.str());
+  }
+
+  return llvm::createStringError(
+  "Unsupported connection specifier, expected 'unix-connect:///path' or "
+  "'connect://[host]:port', got '%s'.",
+  conn.str().c_str());
+}
+
 int main(int argc, char *argv[]) {

walter-erquinigo wrote:

the newly added logic seems correct, but would it be possible to extract out 
some of code into other functions? I'm afraid main is starting to get too big 
to be easily readable

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


[Lldb-commits] [lldb] [LLDB][Telemetry]Define DebuggerTelemetryInfo and related methods (PR #127696)

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


@@ -761,12 +767,29 @@ void Debugger::InstanceInitialize() {
 
 DebuggerSP Debugger::CreateInstance(lldb::LogOutputCallback log_callback,
 void *baton) {
+#ifdef LLVM_BUILD_TELEMETRY
+  lldb_private::telemetry::SteadyTimePoint start_time =
+  std::chrono::steady_clock::now();
+#endif
   DebuggerSP debugger_sp(new Debugger(log_callback, baton));
   if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) {
 std::lock_guard guard(*g_debugger_list_mutex_ptr);
 g_debugger_list_ptr->push_back(debugger_sp);
   }
   debugger_sp->InstanceInitialize();
+
+#ifdef LLVM_BUILD_TELEMETRY
+  if (auto *telemetry_manager = telemetry::TelemetryManager::getInstance()) {
+if (telemetry_manager->getConfig()->EnableTelemetry) {
+  lldb_private::telemetry::DebuggerTelemetryInfo entry;
+  entry.start_time = start_time;
+  entry.end_time = std::chrono::steady_clock::now();
+  entry.debugger = debugger_sp.get();
+  telemetry_manager->atDebuggerStartup(&entry);
+}
+  }
+#endif

oontvoo wrote:

> be sufficient? (if we put that in a header, we should also have a decent 
> chance of the compiler dead-stripping all the code which depends on this)

It could be a bit more complicated because the callers/users have to reference 
the structs/classes defined in the telemetry library. (The library itself is 
not actually 100% abstract classes. All of the TelemetryInfo* are concretely 
defined upstream.)

So I would argue for reverting the current if-def approach.
Specifically, 
 - Rename BUILD_LLVM_TELEMETRY => ENABLE_LLVM_TELEMETRY (which is set to TRUE 
by default)
 - In the base Config class:
 
 struct Config {
 public:
 const bool EnableTelemetry;
 
// Telemetry can only be enabled at runtime if both the build-flag and the 
runtime condition is TRUE
 Config(bool Enable) : EnableTelemetry(Enable && ENABLE_TELEMETRY) {}

}
```


```

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