[Lldb-commits] [lldb] [LLDB][MIPS] Fix signal number of SIGBUS on mips (PR #132688)

2025-03-26 Thread Pavel Labath via lldb-commits

labath wrote:

> If it is, then we may just want to make this build in that configuration, but 
> not actually claim to support mips debugging (in theory, you should still be 
> able to debug e.g. x86 core files with a mips build of lldb)

One way to do that would be to change `#ifdef __linux__` on line 11 to `#if 
defined(__linux__) && !defined(__mips__)` and add a comment to say that this is 
because we don't support mips debugging.

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


[Lldb-commits] [lldb] [lldb] Use correct path for lldb-server executable (PR #131519)

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

DavidSpickett wrote:

I think this https://github.com/llvm/llvm-project/issues/63468 is the same sort 
of issue. Not sure if it's the same though.

As you can tell from me saying "I will get back to this" 2 years ago, the 
knowledge of any of that has left my head by now, but thank you for looking 
into this. I know it's not easy to unpick.

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


[Lldb-commits] [lldb] [LLDB][Telemetry] Collect telemetry from client when allowed. (PR #129728)

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

oontvoo wrote:

> It might be a good idea to include something like "client_name" field so you 
> can differentiate (assuming people don't lie) messages coming from lldb-dap 
> from other lldb "clients".

done

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


[Lldb-commits] [lldb] [lldb][Instrumentation] Set selected frame to outside sanitizer libraries (PR #133079)

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

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

>From 2314f9e584d736ce2093cc196c7c57c2087cde42 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 26 Mar 2025 12:54:36 +
Subject: [PATCH 1/2] [lldb][Instrumentation] Set selected frame to outside
 sanitizer libraries

---
 .../Target/InstrumentationRuntimeStopInfo.h   |  3 ++
 lldb/include/lldb/Target/StackFrameList.h |  2 +
 lldb/include/lldb/Target/Thread.h |  4 ++
 .../Target/InstrumentationRuntimeStopInfo.cpp | 42 +++
 lldb/source/Target/Process.cpp|  2 +
 5 files changed, 53 insertions(+)

diff --git a/lldb/include/lldb/Target/InstrumentationRuntimeStopInfo.h 
b/lldb/include/lldb/Target/InstrumentationRuntimeStopInfo.h
index 5345160850914..dafa41c11327a 100644
--- a/lldb/include/lldb/Target/InstrumentationRuntimeStopInfo.h
+++ b/lldb/include/lldb/Target/InstrumentationRuntimeStopInfo.h
@@ -24,6 +24,9 @@ class InstrumentationRuntimeStopInfo : public StopInfo {
 return lldb::eStopReasonInstrumentation;
   }
 
+  std::optional
+  GetSuggestedStackFrameIndex(bool inlined_stack) override;
+
   const char *GetDescription() override;
 
   bool DoShouldNotify(Event *event_ptr) override { return true; }
diff --git a/lldb/include/lldb/Target/StackFrameList.h 
b/lldb/include/lldb/Target/StackFrameList.h
index 8a66296346f2d..be6ec3b09d8aa 100644
--- a/lldb/include/lldb/Target/StackFrameList.h
+++ b/lldb/include/lldb/Target/StackFrameList.h
@@ -36,6 +36,8 @@ class StackFrameList {
   /// Get the frame at index \p idx. Invisible frames cannot be indexed.
   lldb::StackFrameSP GetFrameAtIndex(uint32_t idx);
 
+  void ResetSuggestedStackFrameIndex() { m_selected_frame_idx.reset(); }
+
   /// Get the first concrete frame with index greater than or equal to \p idx.
   /// Unlike \ref GetFrameAtIndex, this cannot return a synthetic frame.
   lldb::StackFrameSP GetFrameWithConcreteFrameIndex(uint32_t unwind_idx);
diff --git a/lldb/include/lldb/Target/Thread.h 
b/lldb/include/lldb/Target/Thread.h
index 1d1e3dcfc1dc6..747d7299025f8 100644
--- a/lldb/include/lldb/Target/Thread.h
+++ b/lldb/include/lldb/Target/Thread.h
@@ -433,6 +433,10 @@ class Thread : public std::enable_shared_from_this,
 return GetStackFrameList()->GetFrameAtIndex(idx);
   }
 
+  virtual void ResetSuggestedStackFrameIndex() {
+return GetStackFrameList()->ResetSuggestedStackFrameIndex();
+  }
+
   virtual lldb::StackFrameSP
   GetFrameWithConcreteFrameIndex(uint32_t unwind_idx);
 
diff --git a/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp 
b/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp
index 7f82581cc601e..1daeebdbaf9c7 100644
--- a/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp
+++ b/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp
@@ -8,13 +8,20 @@
 
 #include "lldb/Target/InstrumentationRuntimeStopInfo.h"
 
+#include "lldb/Core/Module.h"
 #include "lldb/Target/InstrumentationRuntime.h"
 #include "lldb/Target/Process.h"
+#include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-private.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
+static bool IsStoppedInDarwinSanitizer(Thread &thread, Module &module) {
+  return module.GetFileSpec().GetFilename().GetStringRef().starts_with(
+  "libclang_rt.");
+}
+
 InstrumentationRuntimeStopInfo::InstrumentationRuntimeStopInfo(
 Thread &thread, std::string description,
 StructuredData::ObjectSP additional_data)
@@ -34,3 +41,38 @@ 
InstrumentationRuntimeStopInfo::CreateStopReasonWithInstrumentationData(
   return StopInfoSP(
   new InstrumentationRuntimeStopInfo(thread, description, additionalData));
 }
+
+std::optional
+InstrumentationRuntimeStopInfo::GetSuggestedStackFrameIndex(
+bool inlined_stack) {
+  auto thread_sp = GetThread();
+  if (!thread_sp)
+return std::nullopt;
+
+  // Defensive upper-bound of when we stop walking up the frames in
+  // case we somehow ended up looking at an infinite recursion.
+  const size_t max_stack_depth = 128;
+
+  // Start at parent frame.
+  size_t stack_idx = 1;
+  StackFrameSP most_relevant_frame_sp =
+  thread_sp->GetStackFrameAtIndex(stack_idx);
+
+  while (most_relevant_frame_sp && stack_idx <= max_stack_depth) {
+auto const &sc =
+most_relevant_frame_sp->GetSymbolContext(lldb::eSymbolContextModule);
+
+if (!sc.module_sp)
+  return std::nullopt;
+
+// Found a frame outside of the sanitizer runtime libraries.
+// That's the one we want to display.
+if (!IsStoppedInDarwinSanitizer(*thread_sp, *sc.module_sp))
+  return stack_idx;
+
+++stack_idx;
+most_relevant_frame_sp = thread_sp->GetStackFrameAtIndex(stack_idx);
+  }
+
+  return stack_idx;
+}
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index f2f5598f0ab53..f82cea2d668ed 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -4257,6 +4257,8 @@ bool Process::ProcessEventData::ShouldStop(Event 
*eve

[Lldb-commits] [lldb] [lldb][Target] Clear selected frame index after a StopInfo::PerformAction (PR #133078)

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

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


[Lldb-commits] [lldb] [LLDB][Telemetry] Collect telemetry from client when allowed. (PR #129728)

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

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

>From 21103adacdf9c08cee4065f8a6b90ff812fefbb3 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 4 Mar 2025 11:01:46 -0500
Subject: [PATCH 01/16] [LLDB][Telemetry] Collect telemetry from client when
 allowed.

This patch is slightly different from other impl in that we dispatch 
client-telemetry via a different helper method.
This is to make it easier for vendor to opt-out (simply by overriding the 
method to do nothing).
There is also a configuration option to disallow collecting client telemetry.
---
 lldb/include/lldb/API/SBDebugger.h|  3 +
 lldb/include/lldb/Core/Debugger.h |  5 ++
 lldb/include/lldb/Core/Telemetry.h| 89 +---
 lldb/source/API/SBDebugger.cpp| 11 +++
 lldb/source/Core/Debugger.cpp |  6 ++
 lldb/source/Core/Telemetry.cpp| 99 +++
 lldb/tools/lldb-dap/DAP.cpp   |  5 +-
 lldb/tools/lldb-dap/LLDBUtils.h   | 34 +
 lldb/unittests/Core/TelemetryTest.cpp |  2 +-
 9 files changed, 214 insertions(+), 40 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index e0819f1684f8b..28f92f2095951 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -13,6 +13,7 @@
 
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBPlatform.h"
+#include "lldb/API/SBStructuredData.h"
 
 namespace lldb_private {
 class CommandPluginInterfaceImplementation;
@@ -249,6 +250,8 @@ class LLDB_API SBDebugger {
 
   lldb::SBTarget GetDummyTarget();
 
+  void DispatchClientTelemetry(const lldb::SBStructuredData &data);
+
   // Return true if target is deleted from the target list of the debugger.
   bool DeleteTarget(lldb::SBTarget &target);
 
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ebc6147800e1..e40666d5ceec7 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -19,6 +19,8 @@
 #include "lldb/Core/FormatEntity.h"
 #include "lldb/Core/IOHandler.h"
 #include "lldb/Core/SourceManager.h"
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Core/Telemetry.h"
 #include "lldb/Core/UserSettingsController.h"
 #include "lldb/Host/HostThread.h"
 #include "lldb/Host/StreamFile.h"
@@ -31,6 +33,7 @@
 #include "lldb/Utility/Diagnostics.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
+#include "lldb/Utility/StructuredData.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-enumerations.h"
@@ -127,6 +130,8 @@ class Debugger : public 
std::enable_shared_from_this,
 
   void Clear();
 
+  void DispatchClientTelemetry(const lldb_private::StructuredDataImpl &entry);
+
   bool GetAsyncExecution();
 
   void SetAsyncExecution(bool async);
diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
index 7d8716f1659b5..cad4a4a6c9048 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -19,6 +19,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Telemetry/Telemetry.h"
+#include 
 #include 
 #include 
 #include 
@@ -28,6 +29,23 @@
 namespace lldb_private {
 namespace telemetry {
 
+struct LLDBConfig : public ::llvm::telemetry::Config {
+  // If true, we will collect full details about a debug command (eg., args and
+  // original command). Note: This may contain PII, hence can only be enabled 
by
+  // the vendor while creating the Manager.
+  const bool m_detailed_command_telemetry;
+  // If true, we will collect telemetry from LLDB's clients (eg., lldb-dap) via
+  // the SB interface. Must also be enabled by the vendor while creating the
+  // manager.
+  const bool m_enable_client_telemetry;
+
+  explicit LLDBConfig(bool enable_telemetry, bool detailed_command_telemetry,
+  bool enable_client_telemetry)
+  : ::llvm::telemetry::Config(enable_telemetry),
+m_detailed_command_telemetry(detailed_command_telemetry),
+m_enable_client_telemetry(enable_client_telemetry) {}
+};
+
 // We expect each (direct) subclass of LLDBTelemetryInfo to
 // have an LLDBEntryKind in the form 0b11
 // Specifically:
@@ -37,6 +55,7 @@ namespace telemetry {
 // must have their LLDBEntryKind in the similar form (ie., share common prefix)
 struct LLDBEntryKind : public ::llvm::telemetry::EntryKind {
   static const llvm::telemetry::KindType BaseInfo = 0b1100;
+  static const llvm::telemetry::KindType ClientInfo = 0b1110;
   static const llvm::telemetry::KindType DebuggerInfo = 0b11000100;
 };
 
@@ -86,6 +105,11 @@ struct DebuggerInfo : public LLDBBaseTelemetryInfo {
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 };
 
+struct ClientInfo : public LLDBBaseTelemetryInfo {
+  std::string request_name;
+  std::optional error_msg;
+};
+
 /// The base Telemetry manager instance in LL

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

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

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

LGTM

Could you append to the PR description a list of known issues e.g. the redraw 
on tab complete?

It's discussed here in comments already but it's good to have a record of what 
state we are at and what you have promised to address (not that I doubt your 
sincerity there).

And maybe some brave soul daily driving a `main` build will know what to expect 
if they see it in the commit message.

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


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

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


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

DavidSpickett wrote:

Not a blocker, but still curious about this.

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


[Lldb-commits] [lldb] [lldb][Target] Clear selected frame index after a StopInfo::PerformAction (PR #133078)

2025-03-26 Thread via lldb-commits


@@ -936,3 +936,7 @@ size_t StackFrameList::GetStatus(Stream &strm, uint32_t 
first_frame,
   strm.IndentLess();
   return num_frames_displayed;
 }
+
+void StackFrameList::ClearSelectedFrameIndex() {

jimingham wrote:

In StackFrameList::Clear we take the m_list_mutex before clearing the selected 
frame (among other things).  Should we also do that here?

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


[Lldb-commits] [lldb] [lldb][Instrumentation] Set selected frame to outside sanitizer libraries (PR #133079)

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

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

None

>From 2314f9e584d736ce2093cc196c7c57c2087cde42 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 26 Mar 2025 12:54:36 +
Subject: [PATCH] [lldb][Instrumentation] Set selected frame to outside
 sanitizer libraries

---
 .../Target/InstrumentationRuntimeStopInfo.h   |  3 ++
 lldb/include/lldb/Target/StackFrameList.h |  2 +
 lldb/include/lldb/Target/Thread.h |  4 ++
 .../Target/InstrumentationRuntimeStopInfo.cpp | 42 +++
 lldb/source/Target/Process.cpp|  2 +
 5 files changed, 53 insertions(+)

diff --git a/lldb/include/lldb/Target/InstrumentationRuntimeStopInfo.h 
b/lldb/include/lldb/Target/InstrumentationRuntimeStopInfo.h
index 5345160850914..dafa41c11327a 100644
--- a/lldb/include/lldb/Target/InstrumentationRuntimeStopInfo.h
+++ b/lldb/include/lldb/Target/InstrumentationRuntimeStopInfo.h
@@ -24,6 +24,9 @@ class InstrumentationRuntimeStopInfo : public StopInfo {
 return lldb::eStopReasonInstrumentation;
   }
 
+  std::optional
+  GetSuggestedStackFrameIndex(bool inlined_stack) override;
+
   const char *GetDescription() override;
 
   bool DoShouldNotify(Event *event_ptr) override { return true; }
diff --git a/lldb/include/lldb/Target/StackFrameList.h 
b/lldb/include/lldb/Target/StackFrameList.h
index 8a66296346f2d..be6ec3b09d8aa 100644
--- a/lldb/include/lldb/Target/StackFrameList.h
+++ b/lldb/include/lldb/Target/StackFrameList.h
@@ -36,6 +36,8 @@ class StackFrameList {
   /// Get the frame at index \p idx. Invisible frames cannot be indexed.
   lldb::StackFrameSP GetFrameAtIndex(uint32_t idx);
 
+  void ResetSuggestedStackFrameIndex() { m_selected_frame_idx.reset(); }
+
   /// Get the first concrete frame with index greater than or equal to \p idx.
   /// Unlike \ref GetFrameAtIndex, this cannot return a synthetic frame.
   lldb::StackFrameSP GetFrameWithConcreteFrameIndex(uint32_t unwind_idx);
diff --git a/lldb/include/lldb/Target/Thread.h 
b/lldb/include/lldb/Target/Thread.h
index 1d1e3dcfc1dc6..747d7299025f8 100644
--- a/lldb/include/lldb/Target/Thread.h
+++ b/lldb/include/lldb/Target/Thread.h
@@ -433,6 +433,10 @@ class Thread : public std::enable_shared_from_this,
 return GetStackFrameList()->GetFrameAtIndex(idx);
   }
 
+  virtual void ResetSuggestedStackFrameIndex() {
+return GetStackFrameList()->ResetSuggestedStackFrameIndex();
+  }
+
   virtual lldb::StackFrameSP
   GetFrameWithConcreteFrameIndex(uint32_t unwind_idx);
 
diff --git a/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp 
b/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp
index 7f82581cc601e..1daeebdbaf9c7 100644
--- a/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp
+++ b/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp
@@ -8,13 +8,20 @@
 
 #include "lldb/Target/InstrumentationRuntimeStopInfo.h"
 
+#include "lldb/Core/Module.h"
 #include "lldb/Target/InstrumentationRuntime.h"
 #include "lldb/Target/Process.h"
+#include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-private.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
+static bool IsStoppedInDarwinSanitizer(Thread &thread, Module &module) {
+  return module.GetFileSpec().GetFilename().GetStringRef().starts_with(
+  "libclang_rt.");
+}
+
 InstrumentationRuntimeStopInfo::InstrumentationRuntimeStopInfo(
 Thread &thread, std::string description,
 StructuredData::ObjectSP additional_data)
@@ -34,3 +41,38 @@ 
InstrumentationRuntimeStopInfo::CreateStopReasonWithInstrumentationData(
   return StopInfoSP(
   new InstrumentationRuntimeStopInfo(thread, description, additionalData));
 }
+
+std::optional
+InstrumentationRuntimeStopInfo::GetSuggestedStackFrameIndex(
+bool inlined_stack) {
+  auto thread_sp = GetThread();
+  if (!thread_sp)
+return std::nullopt;
+
+  // Defensive upper-bound of when we stop walking up the frames in
+  // case we somehow ended up looking at an infinite recursion.
+  const size_t max_stack_depth = 128;
+
+  // Start at parent frame.
+  size_t stack_idx = 1;
+  StackFrameSP most_relevant_frame_sp =
+  thread_sp->GetStackFrameAtIndex(stack_idx);
+
+  while (most_relevant_frame_sp && stack_idx <= max_stack_depth) {
+auto const &sc =
+most_relevant_frame_sp->GetSymbolContext(lldb::eSymbolContextModule);
+
+if (!sc.module_sp)
+  return std::nullopt;
+
+// Found a frame outside of the sanitizer runtime libraries.
+// That's the one we want to display.
+if (!IsStoppedInDarwinSanitizer(*thread_sp, *sc.module_sp))
+  return stack_idx;
+
+++stack_idx;
+most_relevant_frame_sp = thread_sp->GetStackFrameAtIndex(stack_idx);
+  }
+
+  return stack_idx;
+}
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index f2f5598f0ab53..f82cea2d668ed 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -4257,6 +4257,8 @@ bool Process::ProcessEventData::ShouldStop(Event 
*e

[Lldb-commits] [lldb] [lldb] Use correct path for lldb-server executable (PR #131519)

2025-03-26 Thread Pavel Labath via lldb-commits

labath wrote:

Sorry about the delay. I wasn't quite happy with the hedging in the 
implementation, and I also wanted to write a test for it, but I figured it 
would be easier if I did it myself. I now have #133093. You can  rebase your 
patch on top of that when it lands.

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


[Lldb-commits] [lldb] [LLDB][NFC] Move CPlusPlusLanguage methods used in Core/Module.cpp to a separated module to break lldb-server dependencies (PR #132274)

2025-03-26 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

> I don't see a reason for an function-local static to be a gc root.

I don't know how to check it. lld has parameters `--why-extract=` and 
`--print-gc-sections`, but they are useless for this investigation. 
Maybe lambdas become gc roots?

Anyway, how will this affect the acceptance of this patch?
Or do you prefer to finish https://github.com/swiftlang/llvm-project/pull/3240 
instead?

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


[Lldb-commits] [lldb] [lldb][Target] Clear selected frame index after a StopInfo::PerformAction (PR #133078)

2025-03-26 Thread via lldb-commits

jimingham wrote:

Other than the question about mutexes, this looks good to me.

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


[Lldb-commits] [lldb] [lldb][Target] Clear selected frame index after a StopInfo::PerformAction (PR #133078)

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


@@ -936,3 +936,7 @@ size_t StackFrameList::GetStatus(Stream &strm, uint32_t 
first_frame,
   strm.IndentLess();
   return num_frames_displayed;
 }
+
+void StackFrameList::ClearSelectedFrameIndex() {

Michael137 wrote:

`GetSelectedFrameIndex` modifies `m_selected_frame_idx`. So concurrent access 
would already be an issue there. Maybe we're just getting away with it now 
(because it just doesn't happen much in practice)?

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


[Lldb-commits] [lldb] [lldb][Target] Clear selected frame index after a StopInfo::PerformAction (PR #133078)

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


@@ -936,3 +936,7 @@ size_t StackFrameList::GetStatus(Stream &strm, uint32_t 
first_frame,
   strm.IndentLess();
   return num_frames_displayed;
 }
+
+void StackFrameList::ClearSelectedFrameIndex() {

Michael137 wrote:

h good question. `GetSelectedFrameIndex` is not taking the mutex either. On 
first glance I would've thought the mutex is there to just protect the 
`m_frames`. There's a separate `m_inlined_depth_mutex` that protects the 
corresponding member (for performance reason based on the comment next to it).

But if `ClearSelectedFrameIndex` and `GetSelectedFrameIndex` they should be 
protected against concurrent access. Do we have concerns with using the list 
mutex for that?

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


[Lldb-commits] [lldb] [lldb] Teach FuncUnwinders about discontinuous functions (PR #133072)

2025-03-26 Thread Pavel Labath via lldb-commits

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/133072

The main change here is that we're now able to correctly look up plans for 
these functions. Previously, due to caching, we could end up with one entry 
covering most of the address space (because part of the function was at the 
beginning and one at the end). Now, we can correctly recognise that the part in 
between does not belong to that function, and we can create a different 
FuncUnwinders instance for it. It doesn't help the discontinuous function much 
(it's plan will still be garbled), but we can at least properly unwind out of 
the simple functions in between.

Fixing the unwind plans for discontinuous functions requires handling each 
unwind source specially, and this setup allows us to make the transition 
incrementally.

>From b68ee05934778f77bf27f8b6716e1db564bd4f98 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Wed, 26 Mar 2025 12:46:28 +0100
Subject: [PATCH] [lldb] Teach FuncUnwinders about discontinuous functions

The main change here is that we're now able to correctly look up plans
for these functions. Previously, due to caching, we could end up with
one entry covering most of the address space (because part of the
function was at the beginning and one at the end). Now, we can correctly
recognise that the part in between does not belong to that function, and
we can create a different FuncUnwinders instance for it. It doesn't
help the discontinuous function much (it's plan will still be garbled),
but we can at least properly unwind out of the simple functions in
between.

Fixing the unwind plans for discontinuous functions requires handling
each unwind source specially, and this setup allows us to make the
transition incrementally.
---
 lldb/include/lldb/Symbol/FuncUnwinders.h  |  20 +-
 lldb/include/lldb/Symbol/UnwindTable.h|   3 +-
 lldb/source/Symbol/FuncUnwinders.cpp  |  36 ++-
 lldb/source/Symbol/UnwindTable.cpp|  43 +--
 .../Inputs/basic-block-sections-with-dwarf.s  | 256 ++
 .../Shell/Unwind/Inputs/linux-x86_64.yaml |  26 ++
 ...asic-block-sections-with-dwarf-static.test |  39 +++
 .../basic-block-sections-with-dwarf.test  |  23 ++
 8 files changed, 409 insertions(+), 37 deletions(-)
 create mode 100644 
lldb/test/Shell/Unwind/Inputs/basic-block-sections-with-dwarf.s
 create mode 100644 lldb/test/Shell/Unwind/Inputs/linux-x86_64.yaml
 create mode 100644 
lldb/test/Shell/Unwind/basic-block-sections-with-dwarf-static.test
 create mode 100644 lldb/test/Shell/Unwind/basic-block-sections-with-dwarf.test

diff --git a/lldb/include/lldb/Symbol/FuncUnwinders.h 
b/lldb/include/lldb/Symbol/FuncUnwinders.h
index 2e841b3b34bd6..1d4c28324e90f 100644
--- a/lldb/include/lldb/Symbol/FuncUnwinders.h
+++ b/lldb/include/lldb/Symbol/FuncUnwinders.h
@@ -13,9 +13,9 @@ class UnwindTable;
 class FuncUnwinders {
 public:
   // FuncUnwinders objects are used to track UnwindPlans for a function (named
-  // or not - really just an address range)
+  // or not - really just a set of address ranges)
 
-  // We'll record four different UnwindPlans for each address range:
+  // We'll record four different UnwindPlans for each function:
   //
   //   1. Unwinding from a call site (a valid exception throw location)
   //  This is often sourced from the eh_frame exception handling info
@@ -31,7 +31,8 @@ class FuncUnwinders {
   // instructions are finished for migrating breakpoints past the stack frame
   // setup instructions when we don't have line table information.
 
-  FuncUnwinders(lldb_private::UnwindTable &unwind_table, AddressRange range);
+  FuncUnwinders(lldb_private::UnwindTable &unwind_table, Address addr,
+AddressRanges ranges);
 
   ~FuncUnwinders();
 
@@ -54,7 +55,9 @@ class FuncUnwinders {
   const Address &GetFunctionStartAddress() const;
 
   bool ContainsAddress(const Address &addr) const {
-return m_range.ContainsFileAddress(addr);
+return llvm::any_of(m_ranges, [&](const AddressRange range) {
+  return range.ContainsFileAddress(addr);
+});
   }
 
   // A function may have a Language Specific Data Area specified -- a block of
@@ -113,6 +116,15 @@ class FuncUnwinders {
   Thread &thread, const lldb::UnwindPlanSP &a, const lldb::UnwindPlanSP 
&b);
 
   UnwindTable &m_unwind_table;
+
+  /// Start address of the function described by this object.
+  Address m_addr;
+
+  /// The address ranges of the function.
+  AddressRanges m_ranges;
+
+  /// The smallest address range covering the entire function.
+  /// DEPRECATED: Use m_ranges instead.
   AddressRange m_range;
 
   std::recursive_mutex m_mutex;
diff --git a/lldb/include/lldb/Symbol/UnwindTable.h 
b/lldb/include/lldb/Symbol/UnwindTable.h
index 3166fdec6ebaa..1cc718efb28d6 100644
--- a/lldb/include/lldb/Symbol/UnwindTable.h
+++ b/lldb/include/lldb/Symbol/UnwindTable.h
@@ -66,8 +66,7 @@ class UnwindTable {
   void Dump(Stream &s);
 
   void Initialize();
-  std::opt

[Lldb-commits] [lldb] [lldb] Remove UnwindPlan::Row shared_ptrs (PR #132370)

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

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


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


[Lldb-commits] [lldb] [lldb] Remove (deprecated) Function::GetAddressRange (PR #132923)

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

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

Congrats! 🥳

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


[Lldb-commits] [lldb] [lldb][Target] Clear selected frame index after a StopInfo::PerformAction (PR #133078)

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

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


[Lldb-commits] [lldb] [lldb][Target] Clear selected frame index after a StopInfo::PerformAction (PR #133078)

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

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

The motivation for this patch is that `StopInfo::GetSuggestedStackFrameIndex` 
would not take effect for `InstrumentationRuntimeStopInfo` (which we plan to 
implement in TBD). This was happening because the instrumentation runtime 
plugins would run utility expressions as part of the stop that would set the 
`m_selected_frame_idx`. This means `SelectMostRelevantFrame` was never called, 
and we would not be able to report the selected frame via the `StopInfo` object.

This patch makes sure we clear the `m_selected_frame_idx` to allow 
`GetSuggestedStackFrameIndex` to take effect, regardless of what the frame 
recognizers choose to do.

>From 91110b85aab9ddf41d1b52b9fc23d68883966b93 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 26 Mar 2025 13:20:24 +
Subject: [PATCH] [lldb][Target] Clear selected frame index after a
 StopInfo::PerformAction

---
 lldb/include/lldb/Target/StackFrameList.h | 3 +++
 lldb/include/lldb/Target/Thread.h | 5 +
 lldb/source/Target/Process.cpp| 2 ++
 lldb/source/Target/StackFrameList.cpp | 4 
 4 files changed, 14 insertions(+)

diff --git a/lldb/include/lldb/Target/StackFrameList.h 
b/lldb/include/lldb/Target/StackFrameList.h
index 8a66296346f2d..d805b644b0b31 100644
--- a/lldb/include/lldb/Target/StackFrameList.h
+++ b/lldb/include/lldb/Target/StackFrameList.h
@@ -46,6 +46,9 @@ class StackFrameList {
   /// Mark a stack frame as the currently selected frame and return its index.
   uint32_t SetSelectedFrame(lldb_private::StackFrame *frame);
 
+  /// Resets the selected frame index of this object.
+  void ClearSelectedFrameIndex();
+
   /// Get the currently selected frame index.
   /// We should only call SelectMostRelevantFrame if (a) the user hasn't 
already
   /// selected a frame, and (b) if this really is a user facing
diff --git a/lldb/include/lldb/Target/Thread.h 
b/lldb/include/lldb/Target/Thread.h
index 1d1e3dcfc1dc6..9eb9cda983c4a 100644
--- a/lldb/include/lldb/Target/Thread.h
+++ b/lldb/include/lldb/Target/Thread.h
@@ -480,6 +480,11 @@ class Thread : public std::enable_shared_from_this,
   bool SetSelectedFrameByIndexNoisily(uint32_t frame_idx,
   Stream &output_stream);
 
+  /// Resets the selected frame index of this object.
+  void ClearSelectedFrameIndex() {
+return GetStackFrameList()->ClearSelectedFrameIndex();
+  }
+
   void SetDefaultFileAndLineToSelectedFrame() {
 GetStackFrameList()->SetDefaultFileAndLineToSelectedFrame();
   }
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index f2f5598f0ab53..6843d5b220742 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -4257,6 +4257,8 @@ bool Process::ProcessEventData::ShouldStop(Event 
*event_ptr,
 // appropriately. We also need to stop processing actions, since they
 // aren't expecting the target to be running.
 
+thread_sp->ClearSelectedFrameIndex();
+
 // FIXME: we might have run.
 if (stop_info_sp->HasTargetRunSinceMe()) {
   SetRestarted(true);
diff --git a/lldb/source/Target/StackFrameList.cpp 
b/lldb/source/Target/StackFrameList.cpp
index 9c6208e9e0a65..3592c3c03db74 100644
--- a/lldb/source/Target/StackFrameList.cpp
+++ b/lldb/source/Target/StackFrameList.cpp
@@ -936,3 +936,7 @@ size_t StackFrameList::GetStatus(Stream &strm, uint32_t 
first_frame,
   strm.IndentLess();
   return num_frames_displayed;
 }
+
+void StackFrameList::ClearSelectedFrameIndex() {
+  m_selected_frame_idx.reset();
+}

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


[Lldb-commits] [lldb] [lldb][Instrumentation] Set selected frame to outside sanitizer libraries (PR #133079)

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

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


[Lldb-commits] [lldb] [lldb][Target] Clear selected frame index after a StopInfo::PerformAction (PR #133078)

2025-03-26 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

The motivation for this patch is that `StopInfo::GetSuggestedStackFrameIndex` 
would not take effect for `InstrumentationRuntimeStopInfo` (which we plan to 
implement in https://github.com/llvm/llvm-project/pull/133079). This was 
happening because the instrumentation runtime plugins would run utility 
expressions as part of the stop that would set the `m_selected_frame_idx`. This 
means `SelectMostRelevantFrame` was never called, and we would not be able to 
report the selected frame via the `StopInfo` object.

This patch makes sure we clear the `m_selected_frame_idx` to allow 
`GetSuggestedStackFrameIndex` to take effect, regardless of what the frame 
recognizers choose to do.

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


4 Files Affected:

- (modified) lldb/include/lldb/Target/StackFrameList.h (+3) 
- (modified) lldb/include/lldb/Target/Thread.h (+5) 
- (modified) lldb/source/Target/Process.cpp (+2) 
- (modified) lldb/source/Target/StackFrameList.cpp (+4) 


``diff
diff --git a/lldb/include/lldb/Target/StackFrameList.h 
b/lldb/include/lldb/Target/StackFrameList.h
index 8a66296346f2d..d805b644b0b31 100644
--- a/lldb/include/lldb/Target/StackFrameList.h
+++ b/lldb/include/lldb/Target/StackFrameList.h
@@ -46,6 +46,9 @@ class StackFrameList {
   /// Mark a stack frame as the currently selected frame and return its index.
   uint32_t SetSelectedFrame(lldb_private::StackFrame *frame);
 
+  /// Resets the selected frame index of this object.
+  void ClearSelectedFrameIndex();
+
   /// Get the currently selected frame index.
   /// We should only call SelectMostRelevantFrame if (a) the user hasn't 
already
   /// selected a frame, and (b) if this really is a user facing
diff --git a/lldb/include/lldb/Target/Thread.h 
b/lldb/include/lldb/Target/Thread.h
index 1d1e3dcfc1dc6..9eb9cda983c4a 100644
--- a/lldb/include/lldb/Target/Thread.h
+++ b/lldb/include/lldb/Target/Thread.h
@@ -480,6 +480,11 @@ class Thread : public std::enable_shared_from_this,
   bool SetSelectedFrameByIndexNoisily(uint32_t frame_idx,
   Stream &output_stream);
 
+  /// Resets the selected frame index of this object.
+  void ClearSelectedFrameIndex() {
+return GetStackFrameList()->ClearSelectedFrameIndex();
+  }
+
   void SetDefaultFileAndLineToSelectedFrame() {
 GetStackFrameList()->SetDefaultFileAndLineToSelectedFrame();
   }
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index f2f5598f0ab53..6843d5b220742 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -4257,6 +4257,8 @@ bool Process::ProcessEventData::ShouldStop(Event 
*event_ptr,
 // appropriately. We also need to stop processing actions, since they
 // aren't expecting the target to be running.
 
+thread_sp->ClearSelectedFrameIndex();
+
 // FIXME: we might have run.
 if (stop_info_sp->HasTargetRunSinceMe()) {
   SetRestarted(true);
diff --git a/lldb/source/Target/StackFrameList.cpp 
b/lldb/source/Target/StackFrameList.cpp
index 9c6208e9e0a65..3592c3c03db74 100644
--- a/lldb/source/Target/StackFrameList.cpp
+++ b/lldb/source/Target/StackFrameList.cpp
@@ -936,3 +936,7 @@ size_t StackFrameList::GetStatus(Stream &strm, uint32_t 
first_frame,
   strm.IndentLess();
   return num_frames_displayed;
 }
+
+void StackFrameList::ClearSelectedFrameIndex() {
+  m_selected_frame_idx.reset();
+}

``




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


[Lldb-commits] [lldb] [lldb] Handle improperly nested blocks differently (PR #117725)

2025-03-26 Thread Pavel Labath via lldb-commits


@@ -333,38 +333,11 @@ void Block::FinalizeRanges() {
 void Block::AddRange(const Range &range) {
   Block *parent_block = GetParent();
   if (parent_block && !parent_block->Contains(range)) {
-Log *log = GetLog(LLDBLog::Symbols);
-if (log) {
-  ModuleSP module_sp(m_parent_scope.CalculateSymbolContextModule());
-  Function *function = m_parent_scope.CalculateSymbolContextFunction();
-  const addr_t function_file_addr = 
function->GetAddress().GetFileAddress();
-  const addr_t block_start_addr = function_file_addr + 
range.GetRangeBase();
-  const addr_t block_end_addr = function_file_addr + range.GetRangeEnd();
-  Type *func_type = function->GetType();
-
-  const Declaration &func_decl = func_type->GetDeclaration();
-  if (func_decl.GetLine()) {
-LLDB_LOGF(log,
-  "warning: %s:%u block {0x%8.8" PRIx64
-  "} has range[%u] [0x%" PRIx64 " - 0x%" PRIx64
-  ") which is not contained in parent block {0x%8.8" PRIx64
-  "} in function {0x%8.8" PRIx64 "} from %s",
-  func_decl.GetFile().GetPath().c_str(), func_decl.GetLine(),
-  GetID(), (uint32_t)m_ranges.GetSize(), block_start_addr,
-  block_end_addr, parent_block->GetID(), function->GetID(),
-  module_sp->GetFileSpec().GetPath().c_str());
-  } else {
-LLDB_LOGF(log,
-  "warning: block {0x%8.8" PRIx64 "} has range[%u] [0x%" PRIx64
-  " - 0x%" PRIx64
-  ") which is not contained in parent block {0x%8.8" PRIx64
-  "} in function {0x%8.8" PRIx64 "} from %s",
-  GetID(), (uint32_t)m_ranges.GetSize(), block_start_addr,
-  block_end_addr, parent_block->GetID(), function->GetID(),
-  module_sp->GetFileSpec().GetPath().c_str());
-  }
-}
-parent_block->AddRange(range);
+m_parent_scope.CalculateSymbolContextModule()->ReportWarning(
+"block {0:x} has a range [{1:x}, {2:x}) which is not contained in the "
+"parent block {3:x}",

labath wrote:

It makes the block longer than what I was hoping for, but yeah, I guess you're 
right. (When I get errors like these I usually turn to dwarfdump, because at 
that point, I don't trust anything lldb tells me.)

A block can have multiple ranges so the "a" is deliberate -- we're saying that 
one of those ranges is bad.

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


[Lldb-commits] [lldb] [lldb] Handle improperly nested blocks differently (PR #117725)

2025-03-26 Thread Pavel Labath via lldb-commits

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

>From a2fe723ccfce64c3ccef67bbc75deba050d8dcc2 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Tue, 26 Nov 2024 16:12:40 +0100
Subject: [PATCH 1/2] [lldb] Handle improperly nested blocks differently

In 6c7f56192fa6e689ef14d32e43a785de5692e9c0 (Sep 2011) we added code to
extend the range of the parent block if the child block is not contained
within it.  Currently, this code doesn't work for (at least) two
reasons:
- we don't re-sort the ranges of the parent block, which means that the
  lookup may not find the range we added (and possibly other ranges as
  well)
- The main address lookup mechanism
  (SymbolFileDWARF::ResolveSymbolContext(Address)) performs the lookup
  using DWARF DIE information, which doesn't contain this extra range.

The motivation for the change was bad compiler output. The commit
message does not go into details, so it's hard to say if this has been
fixed, but given that was 13 years ago, I think we can assume that to be
the case. In fact, as far as I can tell (I haven't tried building an
lldb this old) this code stopped working in
ea3e7d5ccf4f00741e4b106978bd8dab5cece3a1 (~two weeks later), when we
added the requirement for the ranges to be sorted.

Given that this isn't working, and that not changing the ranges of other
blocks has other nice properties (the ranges can be immutable after
construction), I'm removing the parent range changing code. I'm adding a
test case that makes sure we don't do something egregious (e.g., crash)
in this case. Having a child block not be a subset of the parent block
doesn't seem to cause problems now, but if that ever turns out to be an
issue, we can always intersect the child range with that of the parent.

I'm also upgrading this message to a proper warning so we can see if
this ever occurs in practice, and simplifying it so it doesn't get in
the way of understanding the function.
---
 lldb/source/Symbol/Block.cpp  |  37 +--
 .../DWARF/x86/improperly_nested_blocks.s  | 100 ++
 2 files changed, 105 insertions(+), 32 deletions(-)
 create mode 100644 
lldb/test/Shell/SymbolFile/DWARF/x86/improperly_nested_blocks.s

diff --git a/lldb/source/Symbol/Block.cpp b/lldb/source/Symbol/Block.cpp
index 6ecc988d7a5a9..2626361e6b7fb 100644
--- a/lldb/source/Symbol/Block.cpp
+++ b/lldb/source/Symbol/Block.cpp
@@ -333,38 +333,11 @@ void Block::FinalizeRanges() {
 void Block::AddRange(const Range &range) {
   Block *parent_block = GetParent();
   if (parent_block && !parent_block->Contains(range)) {
-Log *log = GetLog(LLDBLog::Symbols);
-if (log) {
-  ModuleSP module_sp(m_parent_scope.CalculateSymbolContextModule());
-  Function *function = m_parent_scope.CalculateSymbolContextFunction();
-  const addr_t function_file_addr = 
function->GetAddress().GetFileAddress();
-  const addr_t block_start_addr = function_file_addr + 
range.GetRangeBase();
-  const addr_t block_end_addr = function_file_addr + range.GetRangeEnd();
-  Type *func_type = function->GetType();
-
-  const Declaration &func_decl = func_type->GetDeclaration();
-  if (func_decl.GetLine()) {
-LLDB_LOGF(log,
-  "warning: %s:%u block {0x%8.8" PRIx64
-  "} has range[%u] [0x%" PRIx64 " - 0x%" PRIx64
-  ") which is not contained in parent block {0x%8.8" PRIx64
-  "} in function {0x%8.8" PRIx64 "} from %s",
-  func_decl.GetFile().GetPath().c_str(), func_decl.GetLine(),
-  GetID(), (uint32_t)m_ranges.GetSize(), block_start_addr,
-  block_end_addr, parent_block->GetID(), function->GetID(),
-  module_sp->GetFileSpec().GetPath().c_str());
-  } else {
-LLDB_LOGF(log,
-  "warning: block {0x%8.8" PRIx64 "} has range[%u] [0x%" PRIx64
-  " - 0x%" PRIx64
-  ") which is not contained in parent block {0x%8.8" PRIx64
-  "} in function {0x%8.8" PRIx64 "} from %s",
-  GetID(), (uint32_t)m_ranges.GetSize(), block_start_addr,
-  block_end_addr, parent_block->GetID(), function->GetID(),
-  module_sp->GetFileSpec().GetPath().c_str());
-  }
-}
-parent_block->AddRange(range);
+m_parent_scope.CalculateSymbolContextModule()->ReportWarning(
+"block {0:x} has a range [{1:x}, {2:x}) which is not contained in the "
+"parent block {3:x}",
+GetID(), range.GetRangeBase(), range.GetRangeEnd(),
+parent_block->GetID());
   }
   m_ranges.Append(range);
 }
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/improperly_nested_blocks.s 
b/lldb/test/Shell/SymbolFile/DWARF/x86/improperly_nested_blocks.s
new file mode 100644
index 0..af744385993f2
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/improperly_nested_blocks.s
@@ -0,0 +1,100 @@
+## This test checks tha

[Lldb-commits] [lldb] [lldb][Target] Clear selected frame index after a StopInfo::PerformAction (PR #133078)

2025-03-26 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 976e41302411e511ab0e99922288185b5939bf54 
91110b85aab9ddf41d1b52b9fc23d68883966b93 --extensions cpp,h -- 
lldb/include/lldb/Target/StackFrameList.h lldb/include/lldb/Target/Thread.h 
lldb/source/Target/Process.cpp lldb/source/Target/StackFrameList.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Target/StackFrameList.cpp 
b/lldb/source/Target/StackFrameList.cpp
index 3592c3c03d..5292618ac8 100644
--- a/lldb/source/Target/StackFrameList.cpp
+++ b/lldb/source/Target/StackFrameList.cpp
@@ -937,6 +937,4 @@ size_t StackFrameList::GetStatus(Stream &strm, uint32_t 
first_frame,
   return num_frames_displayed;
 }
 
-void StackFrameList::ClearSelectedFrameIndex() {
-  m_selected_frame_idx.reset();
-}
+void StackFrameList::ClearSelectedFrameIndex() { m_selected_frame_idx.reset(); 
}

``




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


[Lldb-commits] [lldb] [LLDB][NFC] Move CPlusPlusLanguage methods used in Core/Module.cpp to a separated module to break lldb-server dependencies (PR #132274)

2025-03-26 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

> Global variables are 
> [banned](https://llvm.org/docs/CodingStandards.html#do-not-use-static-constructors)
>  by the coding standards, but I wouldn't be surprised if there were still 
> some around that cause this.

TypeSystemClang.cpp contains global `char TypeSystemClang::ID;` and its 
constructor is GC root.

The dependencies chain looks like Module.cpp -> 
CPlusPlusLanguage::ExtractContextAndIdentifier() -> CPlusPlusLanguage.cpp -> 
CPlusPlusLanguage::GetHardcodedSynthetics() -> 
BlockPointerSyntheticFrontEndCreator -> BlockPointer.cpp -> TypeSystemClang::ID

GC can remove unused CPlusPlusLanguage::GetHardcodedSynthetics(), but 
TypeSystemClang and its dependencies will be kept.

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


[Lldb-commits] [clang] [clang-tools-extra] [lldb] Reland: [clang] preserve class type sugar when taking pointer to member (PR #132401)

2025-03-26 Thread Matheus Izvekov via lldb-commits

mizvekov wrote:

Thanks, this will be fixed here: 
https://github.com/llvm/llvm-project/pull/133113

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


[Lldb-commits] [lldb] [LLDB][Telemetry] Collect telemetry from client when allowed. (PR #129728)

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

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

>From 21103adacdf9c08cee4065f8a6b90ff812fefbb3 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 4 Mar 2025 11:01:46 -0500
Subject: [PATCH 01/17] [LLDB][Telemetry] Collect telemetry from client when
 allowed.

This patch is slightly different from other impl in that we dispatch 
client-telemetry via a different helper method.
This is to make it easier for vendor to opt-out (simply by overriding the 
method to do nothing).
There is also a configuration option to disallow collecting client telemetry.
---
 lldb/include/lldb/API/SBDebugger.h|  3 +
 lldb/include/lldb/Core/Debugger.h |  5 ++
 lldb/include/lldb/Core/Telemetry.h| 89 +---
 lldb/source/API/SBDebugger.cpp| 11 +++
 lldb/source/Core/Debugger.cpp |  6 ++
 lldb/source/Core/Telemetry.cpp| 99 +++
 lldb/tools/lldb-dap/DAP.cpp   |  5 +-
 lldb/tools/lldb-dap/LLDBUtils.h   | 34 +
 lldb/unittests/Core/TelemetryTest.cpp |  2 +-
 9 files changed, 214 insertions(+), 40 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index e0819f1684f8b..28f92f2095951 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -13,6 +13,7 @@
 
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBPlatform.h"
+#include "lldb/API/SBStructuredData.h"
 
 namespace lldb_private {
 class CommandPluginInterfaceImplementation;
@@ -249,6 +250,8 @@ class LLDB_API SBDebugger {
 
   lldb::SBTarget GetDummyTarget();
 
+  void DispatchClientTelemetry(const lldb::SBStructuredData &data);
+
   // Return true if target is deleted from the target list of the debugger.
   bool DeleteTarget(lldb::SBTarget &target);
 
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ebc6147800e1..e40666d5ceec7 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -19,6 +19,8 @@
 #include "lldb/Core/FormatEntity.h"
 #include "lldb/Core/IOHandler.h"
 #include "lldb/Core/SourceManager.h"
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Core/Telemetry.h"
 #include "lldb/Core/UserSettingsController.h"
 #include "lldb/Host/HostThread.h"
 #include "lldb/Host/StreamFile.h"
@@ -31,6 +33,7 @@
 #include "lldb/Utility/Diagnostics.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
+#include "lldb/Utility/StructuredData.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-enumerations.h"
@@ -127,6 +130,8 @@ class Debugger : public 
std::enable_shared_from_this,
 
   void Clear();
 
+  void DispatchClientTelemetry(const lldb_private::StructuredDataImpl &entry);
+
   bool GetAsyncExecution();
 
   void SetAsyncExecution(bool async);
diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
index 7d8716f1659b5..cad4a4a6c9048 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -19,6 +19,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Telemetry/Telemetry.h"
+#include 
 #include 
 #include 
 #include 
@@ -28,6 +29,23 @@
 namespace lldb_private {
 namespace telemetry {
 
+struct LLDBConfig : public ::llvm::telemetry::Config {
+  // If true, we will collect full details about a debug command (eg., args and
+  // original command). Note: This may contain PII, hence can only be enabled 
by
+  // the vendor while creating the Manager.
+  const bool m_detailed_command_telemetry;
+  // If true, we will collect telemetry from LLDB's clients (eg., lldb-dap) via
+  // the SB interface. Must also be enabled by the vendor while creating the
+  // manager.
+  const bool m_enable_client_telemetry;
+
+  explicit LLDBConfig(bool enable_telemetry, bool detailed_command_telemetry,
+  bool enable_client_telemetry)
+  : ::llvm::telemetry::Config(enable_telemetry),
+m_detailed_command_telemetry(detailed_command_telemetry),
+m_enable_client_telemetry(enable_client_telemetry) {}
+};
+
 // We expect each (direct) subclass of LLDBTelemetryInfo to
 // have an LLDBEntryKind in the form 0b11
 // Specifically:
@@ -37,6 +55,7 @@ namespace telemetry {
 // must have their LLDBEntryKind in the similar form (ie., share common prefix)
 struct LLDBEntryKind : public ::llvm::telemetry::EntryKind {
   static const llvm::telemetry::KindType BaseInfo = 0b1100;
+  static const llvm::telemetry::KindType ClientInfo = 0b1110;
   static const llvm::telemetry::KindType DebuggerInfo = 0b11000100;
 };
 
@@ -86,6 +105,11 @@ struct DebuggerInfo : public LLDBBaseTelemetryInfo {
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 };
 
+struct ClientInfo : public LLDBBaseTelemetryInfo {
+  std::string request_name;
+  std::optional error_msg;
+};
+
 /// The base Telemetry manager instance in LL

[Lldb-commits] [lldb] [llvm] [lldb][lldb-dap] Implement jump to cursor (PR #130503)

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


@@ -0,0 +1,165 @@
+//===-- GoToTargetsRequestHandler.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 "DAP.h"
+
+#include "JSONUtils.h"
+
+#include 
+#include 
+#include 
+
+namespace lldb_dap {
+
+static llvm::SmallVector
+GetLineValidEntry(DAP &dap, const lldb::SBFileSpec &file_spec, uint32_t line) {
+  // disable breakpoint listeners so they do not send events to the DAP client.
+  lldb::SBListener listener = dap.debugger.GetListener();
+  lldb::SBBroadcaster broadcaster = dap.target.GetBroadcaster();
+  constexpr auto event_mask = lldb::SBTarget::eBroadcastBitBreakpointChanged;
+  listener.StopListeningForEvents(broadcaster, event_mask);

clayborg wrote:

Seems like we are using the breakpoint API just so we can answer the questions 
"tell me all of the locations that map to source file and line". I would prefer 
to expose the source file + line resolving code in a `SBTarget` API so we can 
avoid having to use breakpoints just so we can get all of the locations. The 
API I am thinking would be:
```
lldb::SBSymbolContextList lldb::SBTarget::ResolveContexts(lldb::SBFileSpec 
&file_spec, uint32_t line);
```
And this returns the same info as the breakpoint location contexts. LLDB 
breakpoint code uses address resolvers and search filters, and we can just use 
the same APIs as the breakpoints. 


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


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

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

JDevlieghere wrote:

> Could you append to the PR description a list of known issues e.g. the redraw 
> on tab complete?
> 
> It's discussed here in comments already but it's good to have a record of 
> what state we are at and what you have promised to address (not that I doubt 
> your sincerity there).
> 
> And maybe some brave soul daily driving a `main` build will know what to 
> expect if they see it in the commit message.

Things have changed since I wrote the description so I'll update it to reflect 
that. As far as I know there are no known issues (that I've encountered). The 
tab complete issue is (should be?) fixed with the current state of this PR. Are 
you still experiencing that behavior? 


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


[Lldb-commits] [lldb] [lldb] Respect LaunchInfo::SetExecutable in ProcessLauncherPosixFork (PR #133093)

2025-03-26 Thread Pavel Labath via lldb-commits


@@ -94,6 +94,7 @@ struct ForkLaunchInfo {
   bool debug;
   bool disable_aslr;
   std::string wd;
+  std::string executable;

labath wrote:

They are accessed from the forked process (line 34 in this file), so they need 
to be async-signal safe  (nothing really guarantees std::string is that, but 
it's pretty hard to write a `c_str` implementation that isn't).

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


[Lldb-commits] [lldb] [lldb] Respect LaunchInfo::SetExecutable in ProcessLauncherPosixFork (PR #133093)

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


@@ -94,6 +94,7 @@ struct ForkLaunchInfo {
   bool debug;
   bool disable_aslr;
   std::string wd;
+  std::string executable;

JDevlieghere wrote:

Makes sense, thanks for explaining! 

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


[Lldb-commits] [lldb] [LLDB][Telemetry] Collect telemetry from client when allowed. (PR #129728)

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

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

>From 21103adacdf9c08cee4065f8a6b90ff812fefbb3 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Tue, 4 Mar 2025 11:01:46 -0500
Subject: [PATCH 01/18] [LLDB][Telemetry] Collect telemetry from client when
 allowed.

This patch is slightly different from other impl in that we dispatch 
client-telemetry via a different helper method.
This is to make it easier for vendor to opt-out (simply by overriding the 
method to do nothing).
There is also a configuration option to disallow collecting client telemetry.
---
 lldb/include/lldb/API/SBDebugger.h|  3 +
 lldb/include/lldb/Core/Debugger.h |  5 ++
 lldb/include/lldb/Core/Telemetry.h| 89 +---
 lldb/source/API/SBDebugger.cpp| 11 +++
 lldb/source/Core/Debugger.cpp |  6 ++
 lldb/source/Core/Telemetry.cpp| 99 +++
 lldb/tools/lldb-dap/DAP.cpp   |  5 +-
 lldb/tools/lldb-dap/LLDBUtils.h   | 34 +
 lldb/unittests/Core/TelemetryTest.cpp |  2 +-
 9 files changed, 214 insertions(+), 40 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index e0819f1684f8b..28f92f2095951 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -13,6 +13,7 @@
 
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBPlatform.h"
+#include "lldb/API/SBStructuredData.h"
 
 namespace lldb_private {
 class CommandPluginInterfaceImplementation;
@@ -249,6 +250,8 @@ class LLDB_API SBDebugger {
 
   lldb::SBTarget GetDummyTarget();
 
+  void DispatchClientTelemetry(const lldb::SBStructuredData &data);
+
   // Return true if target is deleted from the target list of the debugger.
   bool DeleteTarget(lldb::SBTarget &target);
 
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ebc6147800e1..e40666d5ceec7 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -19,6 +19,8 @@
 #include "lldb/Core/FormatEntity.h"
 #include "lldb/Core/IOHandler.h"
 #include "lldb/Core/SourceManager.h"
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Core/Telemetry.h"
 #include "lldb/Core/UserSettingsController.h"
 #include "lldb/Host/HostThread.h"
 #include "lldb/Host/StreamFile.h"
@@ -31,6 +33,7 @@
 #include "lldb/Utility/Diagnostics.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
+#include "lldb/Utility/StructuredData.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-enumerations.h"
@@ -127,6 +130,8 @@ class Debugger : public 
std::enable_shared_from_this,
 
   void Clear();
 
+  void DispatchClientTelemetry(const lldb_private::StructuredDataImpl &entry);
+
   bool GetAsyncExecution();
 
   void SetAsyncExecution(bool async);
diff --git a/lldb/include/lldb/Core/Telemetry.h 
b/lldb/include/lldb/Core/Telemetry.h
index 7d8716f1659b5..cad4a4a6c9048 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -19,6 +19,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Telemetry/Telemetry.h"
+#include 
 #include 
 #include 
 #include 
@@ -28,6 +29,23 @@
 namespace lldb_private {
 namespace telemetry {
 
+struct LLDBConfig : public ::llvm::telemetry::Config {
+  // If true, we will collect full details about a debug command (eg., args and
+  // original command). Note: This may contain PII, hence can only be enabled 
by
+  // the vendor while creating the Manager.
+  const bool m_detailed_command_telemetry;
+  // If true, we will collect telemetry from LLDB's clients (eg., lldb-dap) via
+  // the SB interface. Must also be enabled by the vendor while creating the
+  // manager.
+  const bool m_enable_client_telemetry;
+
+  explicit LLDBConfig(bool enable_telemetry, bool detailed_command_telemetry,
+  bool enable_client_telemetry)
+  : ::llvm::telemetry::Config(enable_telemetry),
+m_detailed_command_telemetry(detailed_command_telemetry),
+m_enable_client_telemetry(enable_client_telemetry) {}
+};
+
 // We expect each (direct) subclass of LLDBTelemetryInfo to
 // have an LLDBEntryKind in the form 0b11
 // Specifically:
@@ -37,6 +55,7 @@ namespace telemetry {
 // must have their LLDBEntryKind in the similar form (ie., share common prefix)
 struct LLDBEntryKind : public ::llvm::telemetry::EntryKind {
   static const llvm::telemetry::KindType BaseInfo = 0b1100;
+  static const llvm::telemetry::KindType ClientInfo = 0b1110;
   static const llvm::telemetry::KindType DebuggerInfo = 0b11000100;
 };
 
@@ -86,6 +105,11 @@ struct DebuggerInfo : public LLDBBaseTelemetryInfo {
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 };
 
+struct ClientInfo : public LLDBBaseTelemetryInfo {
+  std::string request_name;
+  std::optional error_msg;
+};
+
 /// The base Telemetry manager instance in LL

[Lldb-commits] [lldb] [lldb][lldb-dap] Added support for "WriteMemory" request. (PR #131820)

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




vogelsgesang wrote:

This is probably worth mentioning in the release notes, in 
`llvm/docs/ReleaseNotes.md`

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


[Lldb-commits] [lldb] [llvm] [lldb][lldb-dap] Implement jump to cursor (PR #130503)

2025-03-26 Thread Ebuka Ezike via lldb-commits

https://github.com/da-viper updated 
https://github.com/llvm/llvm-project/pull/130503

>From 7bad765585b2ae96faf2d2558b099f4b965d2791 Mon Sep 17 00:00:00 2001
From: Ezike Ebuka 
Date: Sun, 9 Mar 2025 12:46:54 +
Subject: [PATCH 01/24] [lldb-dap] implement jump to cursor.

---
 lldb/cmake/modules/LLDBConfig.cmake   |   2 +-
 lldb/tools/lldb-dap/CMakeLists.txt|   2 +
 lldb/tools/lldb-dap/DAP.cpp   |  23 +++-
 lldb/tools/lldb-dap/DAP.h |  27 +++-
 .../lldb-dap/Handler/GoToRequestHandler.cpp   | 103 +++
 .../Handler/GoToTargetsRequestHandler.cpp | 120 ++
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  14 ++
 lldb/tools/lldb-dap/lldb-dap.cpp  |   2 +
 8 files changed, 290 insertions(+), 3 deletions(-)
 create mode 100644 lldb/tools/lldb-dap/Handler/GoToRequestHandler.cpp
 create mode 100644 lldb/tools/lldb-dap/Handler/GoToTargetsRequestHandler.cpp

diff --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 9df71edd8b359..a2f9a29b6d5d5 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -57,7 +57,7 @@ add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses 
support in LLDB" Curse
 add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support in 
LLDB" LibLZMA LIBLZMA_FOUND)
 add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support in LLDB" 
LuaAndSwig LUAANDSWIG_FOUND)
 add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in 
LLDB" PythonAndSwig PYTHONANDSWIG_FOUND)
-add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" 
LibXml2 LIBXML2_FOUND VERSION 2.8)
+add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" 
LibXml2 LIBXML2_FOUND VERSION)
 add_optional_dependency(LLDB_ENABLE_FBSDVMCORE "Enable libfbsdvmcore support 
in LLDB" FBSDVMCore FBSDVMCore_FOUND QUIET)
 
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" 
ON)
diff --git a/lldb/tools/lldb-dap/CMakeLists.txt 
b/lldb/tools/lldb-dap/CMakeLists.txt
index 93c5ee4426783..0709b2b2dc699 100644
--- a/lldb/tools/lldb-dap/CMakeLists.txt
+++ b/lldb/tools/lldb-dap/CMakeLists.txt
@@ -45,6 +45,8 @@ add_lldb_tool(lldb-dap
   Handler/DisconnectRequestHandler.cpp
   Handler/EvaluateRequestHandler.cpp
   Handler/ExceptionInfoRequestHandler.cpp
+Handler/GoToRequestHandler.cpp
+Handler/GoToTargetsRequestHandler.cpp
   Handler/InitializeRequestHandler.cpp
   Handler/LaunchRequestHandler.cpp
   Handler/LocationsRequestHandler.cpp
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 65de0488729e5..986ac5c3bb408 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -81,7 +81,7 @@ DAP::DAP(llvm::StringRef path, Log *log, const ReplMode 
default_repl_mode,
   configuration_done_sent(false), waiting_for_run_in_terminal(false),
   progress_event_reporter(
   [&](const ProgressEvent &event) { SendJSON(event.ToJSON()); }),
-  reverse_request_seq(0), repl_mode(default_repl_mode) {}
+  reverse_request_seq(0), repl_mode(default_repl_mode), goto_id_map() {}
 
 DAP::~DAP() = default;
 
@@ -841,6 +841,27 @@ lldb::SBError DAP::WaitForProcessToStop(uint32_t seconds) {
   return error;
 }
 
+std::optional Gotos::GetLineEntry(uint64_t id) const {
+  const auto iter = line_entries.find(id);
+  if (iter != line_entries.end())
+return iter->second;
+
+  return std::nullopt;
+}
+
+uint64_t Gotos::InsertLineEntry(lldb::SBLineEntry line_entry) {
+  const auto spec_id = this->NewSpecId();
+  line_entries.insert(std::make_pair(spec_id, line_entry));
+  return spec_id;
+}
+
+void Gotos::Clear() {
+  new_id = 0UL;
+  line_entries.clear();
+}
+
+uint64_t Gotos::NewSpecId() { return new_id++; }
+
 void Variables::Clear() {
   locals.Clear();
   globals.Clear();
diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index 4b4d471161137..c280adb57d0c5 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -77,6 +77,27 @@ enum class PacketStatus {
 
 enum class ReplMode { Variable = 0, Command, Auto };
 
+class Gotos {
+public:
+  /// \return the line_entry corresponding with \p id
+  ///
+  /// If \p id is invalid std::nullopt is returned.
+  std::optional GetLineEntry(uint64_t id) const;
+
+  /// Insert a new \p line_entry.
+  /// \return id assigned to this line_entry.
+  uint64_t InsertLineEntry(lldb::SBLineEntry line_entry);
+
+  /// clears all line entries and reset the generated ids.
+  void Clear();
+
+private:
+  uint64_t NewSpecId();
+
+  llvm::DenseMap line_entries;
+  uint64_t new_id = 0ul;
+};
+
 struct Variables {
   /// Variable_reference start index of permanent expandable variable.
   static constexpr int64_t PermanentVariableStartIndex = (1ll << 32);
@@ -205,6 +226,7 @@ struct DAP {
   // empty; if the previous expression was a variable expression, this string
   // 

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

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

DavidSpickett wrote:

> The tab complete issue is (should be?) fixed with the current state of this 
> PR. 

Cool! I did not check it again locally. If you're reasonably sure you've fixed 
it then I trust you there :)

Go ahead and land this and I'll try my best to break it again at some point.

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


[Lldb-commits] [lldb] [lldb][Target] Clear selected frame index after a StopInfo::PerformAction (PR #133078)

2025-03-26 Thread via lldb-commits


@@ -936,3 +936,7 @@ size_t StackFrameList::GetStatus(Stream &strm, uint32_t 
first_frame,
   strm.IndentLess();
   return num_frames_displayed;
 }
+
+void StackFrameList::ClearSelectedFrameIndex() {

jimingham wrote:

This is a shared mutex so it can't be recursive, so we'd need to watch out for 
that.

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


[Lldb-commits] [lldb] [llvm] [lldb][lldb-dap] Implement jump to cursor (PR #130503)

2025-03-26 Thread Ebuka Ezike via lldb-commits

https://github.com/da-viper updated 
https://github.com/llvm/llvm-project/pull/130503

>From 7bad765585b2ae96faf2d2558b099f4b965d2791 Mon Sep 17 00:00:00 2001
From: Ezike Ebuka 
Date: Sun, 9 Mar 2025 12:46:54 +
Subject: [PATCH 01/24] [lldb-dap] implement jump to cursor.

---
 lldb/cmake/modules/LLDBConfig.cmake   |   2 +-
 lldb/tools/lldb-dap/CMakeLists.txt|   2 +
 lldb/tools/lldb-dap/DAP.cpp   |  23 +++-
 lldb/tools/lldb-dap/DAP.h |  27 +++-
 .../lldb-dap/Handler/GoToRequestHandler.cpp   | 103 +++
 .../Handler/GoToTargetsRequestHandler.cpp | 120 ++
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  14 ++
 lldb/tools/lldb-dap/lldb-dap.cpp  |   2 +
 8 files changed, 290 insertions(+), 3 deletions(-)
 create mode 100644 lldb/tools/lldb-dap/Handler/GoToRequestHandler.cpp
 create mode 100644 lldb/tools/lldb-dap/Handler/GoToTargetsRequestHandler.cpp

diff --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 9df71edd8b359..a2f9a29b6d5d5 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -57,7 +57,7 @@ add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses 
support in LLDB" Curse
 add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support in 
LLDB" LibLZMA LIBLZMA_FOUND)
 add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support in LLDB" 
LuaAndSwig LUAANDSWIG_FOUND)
 add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in 
LLDB" PythonAndSwig PYTHONANDSWIG_FOUND)
-add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" 
LibXml2 LIBXML2_FOUND VERSION 2.8)
+add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" 
LibXml2 LIBXML2_FOUND VERSION)
 add_optional_dependency(LLDB_ENABLE_FBSDVMCORE "Enable libfbsdvmcore support 
in LLDB" FBSDVMCore FBSDVMCore_FOUND QUIET)
 
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" 
ON)
diff --git a/lldb/tools/lldb-dap/CMakeLists.txt 
b/lldb/tools/lldb-dap/CMakeLists.txt
index 93c5ee4426783..0709b2b2dc699 100644
--- a/lldb/tools/lldb-dap/CMakeLists.txt
+++ b/lldb/tools/lldb-dap/CMakeLists.txt
@@ -45,6 +45,8 @@ add_lldb_tool(lldb-dap
   Handler/DisconnectRequestHandler.cpp
   Handler/EvaluateRequestHandler.cpp
   Handler/ExceptionInfoRequestHandler.cpp
+Handler/GoToRequestHandler.cpp
+Handler/GoToTargetsRequestHandler.cpp
   Handler/InitializeRequestHandler.cpp
   Handler/LaunchRequestHandler.cpp
   Handler/LocationsRequestHandler.cpp
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 65de0488729e5..986ac5c3bb408 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -81,7 +81,7 @@ DAP::DAP(llvm::StringRef path, Log *log, const ReplMode 
default_repl_mode,
   configuration_done_sent(false), waiting_for_run_in_terminal(false),
   progress_event_reporter(
   [&](const ProgressEvent &event) { SendJSON(event.ToJSON()); }),
-  reverse_request_seq(0), repl_mode(default_repl_mode) {}
+  reverse_request_seq(0), repl_mode(default_repl_mode), goto_id_map() {}
 
 DAP::~DAP() = default;
 
@@ -841,6 +841,27 @@ lldb::SBError DAP::WaitForProcessToStop(uint32_t seconds) {
   return error;
 }
 
+std::optional Gotos::GetLineEntry(uint64_t id) const {
+  const auto iter = line_entries.find(id);
+  if (iter != line_entries.end())
+return iter->second;
+
+  return std::nullopt;
+}
+
+uint64_t Gotos::InsertLineEntry(lldb::SBLineEntry line_entry) {
+  const auto spec_id = this->NewSpecId();
+  line_entries.insert(std::make_pair(spec_id, line_entry));
+  return spec_id;
+}
+
+void Gotos::Clear() {
+  new_id = 0UL;
+  line_entries.clear();
+}
+
+uint64_t Gotos::NewSpecId() { return new_id++; }
+
 void Variables::Clear() {
   locals.Clear();
   globals.Clear();
diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index 4b4d471161137..c280adb57d0c5 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -77,6 +77,27 @@ enum class PacketStatus {
 
 enum class ReplMode { Variable = 0, Command, Auto };
 
+class Gotos {
+public:
+  /// \return the line_entry corresponding with \p id
+  ///
+  /// If \p id is invalid std::nullopt is returned.
+  std::optional GetLineEntry(uint64_t id) const;
+
+  /// Insert a new \p line_entry.
+  /// \return id assigned to this line_entry.
+  uint64_t InsertLineEntry(lldb::SBLineEntry line_entry);
+
+  /// clears all line entries and reset the generated ids.
+  void Clear();
+
+private:
+  uint64_t NewSpecId();
+
+  llvm::DenseMap line_entries;
+  uint64_t new_id = 0ul;
+};
+
 struct Variables {
   /// Variable_reference start index of permanent expandable variable.
   static constexpr int64_t PermanentVariableStartIndex = (1ll << 32);
@@ -205,6 +226,7 @@ struct DAP {
   // empty; if the previous expression was a variable expression, this string
   // 

[Lldb-commits] [lldb] [lldb] Respect LaunchInfo::SetExecutable in ProcessLauncherPosixFork (PR #133093)

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

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


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


[Lldb-commits] [lldb] [lldb] Respect LaunchInfo::SetExecutable in ProcessLauncherPosixFork (PR #133093)

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


@@ -94,6 +94,7 @@ struct ForkLaunchInfo {
   bool debug;
   bool disable_aslr;
   std::string wd;
+  std::string executable;

JDevlieghere wrote:

This is consistent with the rest of the file, but any reason these are 
`std::string`s and not `FileSpec`s?

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


[Lldb-commits] [lldb] [lldb][lldb-dap] Added support for "WriteMemory" request. (PR #131820)

2025-03-26 Thread Santhosh Kumar Ellendula via lldb-commits


@@ -0,0 +1,147 @@
+//===-- WriteMemoryRequestHandler.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 "DAP.h"
+#include "EventHelper.h"
+#include "JSONUtils.h"
+#include "RequestHandler.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Base64.h"
+
+namespace lldb_dap {
+
+// "WriteMemoryRequest": {
+//   "allOf": [ { "$ref": "#/definitions/Request" }, {
+// "type": "object",
+// "description": "Writes bytes to memory at the provided location.\n
+// Clients should only call this request if the corresponding
+// capability `supportsWriteMemoryRequest` is true.",
+// "properties": {
+//   "command": {
+// "type": "string",
+// "enum": [ "writeMemory" ]
+//   },
+//   "arguments": {
+// "$ref": "#/definitions/WriteMemoryArguments"
+//   }
+// },
+// "required": [ "command", "arguments" ]
+//   }]
+// },
+// "WriteMemoryArguments": {
+//   "type": "object",
+//   "description": "Arguments for `writeMemory` request.",
+//   "properties": {
+// "memoryReference": {
+//   "type": "string",
+//   "description": "Memory reference to the base location to which
+//   data should be written."
+// },
+// "offset": {
+//   "type": "integer",
+//   "description": "Offset (in bytes) to be applied to the reference
+//   location before writing data. Can be negative."
+// },
+// "allowPartial": {
+//   "type": "boolean",
+//   "description": "Property to control partial writes. If true, the
+//   debug adapter should attempt to write memory even if the entire
+//   memory region is not writable. In such a case the debug adapter
+//   should stop after hitting the first byte of memory that cannot be
+//   written and return the number of bytes written in the response
+//   via the `offset` and `bytesWritten` properties.\nIf false or
+//   missing, a debug adapter should attempt to verify the region is
+//   writable before writing, and fail the response if it is not."
+// },
+// "data": {
+//   "type": "string",
+//   "description": "Bytes to write, encoded using base64."
+// }
+//   },
+//   "required": [ "memoryReference", "data" ]
+// },
+// "WriteMemoryResponse": {
+//   "allOf": [ { "$ref": "#/definitions/Response" }, {
+// "type": "object",
+// "description": "Response to `writeMemory` request.",
+// "properties": {
+//   "body": {
+// "type": "object",
+// "properties": {
+//   "offset": {
+// "type": "integer",
+// "description": "Property that should be returned when
+// `allowPartial` is true to indicate the offset of the first
+// byte of data successfully written. Can be negative."
+//   },
+//   "bytesWritten": {
+// "type": "integer",
+// "description": "Property that should be returned when
+// `allowPartial` is true to indicate the number of bytes
+// starting from address that were successfully written."
+//   }
+// }
+//   }
+// }
+//   }]
+// },
+void WriteMemoryRequestHandler::operator()(
+const llvm::json::Object &request) const {
+  llvm::json::Object response;
+  llvm::json::Array response_writeMemory;
+  llvm::json::Object body;
+  FillResponse(request, response);
+
+  auto arguments = request.getObject("arguments");
+  llvm::StringRef memoryReference =
+  GetString(arguments, "memoryReference").value_or("");
+
+  auto addr_opt = DecodeMemoryReference(memoryReference);
+  if (!addr_opt.has_value()) {
+response["success"] = false;
+response["message"] =
+"Malformed memory reference: " + memoryReference.str();
+dap.SendJSON(llvm::json::Value(std::move(response)));
+return;
+  }
+
+  lldb::addr_t address = *addr_opt;
+  lldb::addr_t address_offset =
+  address + GetInteger(arguments, "offset").value_or(0);
+
+  llvm::StringRef data64 = GetString(arguments, "data").value_or("");
+
+  std::string output;
+  lldb::SBError writeError;
+  int64_t countWrite = 0;
+
+  output = llvm::encodeBase64(data64);
+
+  // write the memory
+  if (!output.empty()) {

santhoshe447 wrote:

> > [...] how I'm supposed to set something to null or empty or nil.
> 
> Not sure I understand the question. But maybe this 

[Lldb-commits] [lldb] [lldb] Remove raw access to PluginInstances vector (PR #132884)

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

JDevlieghere wrote:

I follow the argument about a custom iterator likely being more complicated, 
but the callbacks aren't much better in that regard. Did you consider having 
something like `GetEnabledInstances` that returns a vector with just the 
enabled instances? It seems like that would be a lot less intrusive and I'd be 
surprised if this code is hot enough that the overhead of creating a new vector 
instead of returning a reference makes a difference. 

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


[Lldb-commits] [clang] [clang-tools-extra] [lldb] Reland: [clang] preserve class type sugar when taking pointer to member (PR #132401)

2025-03-26 Thread Nico Weber via lldb-commits

nico wrote:

> Thanks, this will be fixed here: #133113

That also fixes an `Assertion `!isNull() && "Cannot retrieve a NULL type 
pointer"' failed.` we started seeing after this here landed (repro: 
https://issues.chromium.org/issues/406497227#comment3)

It'd be good if we could either land that soon or revert this here until the 
follow-up is ready, to keep HEAD green. (#133113 looks kind of involved, so 
maybe reverting first is safer? You'll need:

```
% git revert 960615954e4cb3150ae4a479fa7f9d0d17035eea
% git revert 5999be0f4770e9dd0f88ee9051a37119c8f5a1e4
% git revert 45270853192db53022ccadf4767999af4fe4e332
% git revert 14f7bd63b95d0f61a6f47119ac66398ca230559a
```

to also revert the existing 3 follow-ups, else you'll get conflicts.)

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


[Lldb-commits] [lldb] [llvm] [lldb][lldb-dap] Implement jump to cursor (PR #130503)

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


@@ -0,0 +1,91 @@
+//===-- GoToTargetsRequestHandler.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 "DAP.h"
+
+#include "JSONUtils.h"
+#include "Protocol/ProtocolRequests.h"
+#include "RequestHandler.h"
+
+#include 
+#include 
+#include 
+
+namespace lldb_dap {
+
+static llvm::SmallVector
+GetLineValidEntry(DAP &dap, const lldb::SBFileSpec &file_spec, uint32_t line) {
+  // Disable breakpoint listeners so they do not send events to the DAP client.
+  lldb::SBListener listener = dap.debugger.GetListener();
+  const lldb::SBBroadcaster broadcaster = dap.target.GetBroadcaster();
+  constexpr auto event_mask = lldb::SBTarget::eBroadcastBitBreakpointChanged;
+  listener.StopListeningForEvents(broadcaster, event_mask);
+
+  // Create a breakpoint to resolve the line if it is on an empty line.
+  lldb::SBBreakpoint goto_bp =
+  dap.target.BreakpointCreateByLocation(file_spec, line);
+  if (!goto_bp.IsValid())
+return {};
+
+  llvm::SmallVector entry_locations{};
+  const size_t resolved_count = goto_bp.GetNumResolvedLocations();
+  for (size_t idx = 0; idx < resolved_count; ++idx) {
+lldb::SBBreakpointLocation location = goto_bp.GetLocationAtIndex(idx);
+if (!location.IsValid())
+  continue;
+
+lldb::SBAddress addr = location.GetAddress();
+if (!addr.IsValid())
+  continue;
+
+lldb::SBLineEntry line_entry = addr.GetLineEntry();
+if (!line_entry.IsValid())
+  continue;
+
+entry_locations.push_back(line_entry);
+  }
+
+  // clean up;
+  dap.target.BreakpointDelete(goto_bp.GetID());
+  listener.StartListeningForEvents(broadcaster, event_mask);

ashgti wrote:

Won't we miss this cleanup if we return on line 33?

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


[Lldb-commits] [lldb] [llvm] [lldb][lldb-dap] Implement jump to cursor (PR #130503)

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


@@ -0,0 +1,165 @@
+//===-- GoToTargetsRequestHandler.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 "DAP.h"
+
+#include "JSONUtils.h"
+
+#include 
+#include 
+#include 
+
+namespace lldb_dap {
+
+static llvm::SmallVector
+GetLineValidEntry(DAP &dap, const lldb::SBFileSpec &file_spec, uint32_t line) {
+  // disable breakpoint listeners so they do not send events to the DAP client.
+  lldb::SBListener listener = dap.debugger.GetListener();
+  lldb::SBBroadcaster broadcaster = dap.target.GetBroadcaster();
+  constexpr auto event_mask = lldb::SBTarget::eBroadcastBitBreakpointChanged;
+  listener.StopListeningForEvents(broadcaster, event_mask);

ashgti wrote:

I think we can use the `lldb.target.modules[0].FindCompileUnits()` to find this 
information without using a breakpoint.

Trying this out on the stepInTargets binary:

```
$ lldb lldb-dap/stepInTargets/TestDAP_stepInTargets.test_basic/a.out
(lldb) script
>>>[line_entry for line_entry in 
>>>lldb.target.modules[0].FindCompileUnits(lldb.SBFileSpec("lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp"))[0].compile_unit]
[
  lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp:2, 
  lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp:2:38,
  lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp:2:44,
  lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp:2:42,
  lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp:2:31,
  lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp:4:15,
  lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp:6:15,
  lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp:8,
  lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp:9:7,
  lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp:9:16,
  lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp:9:3,
  lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp:10:3,
]
```

I'm not sure how we should scope those. We could use the block to scope the 
targets to the same block as the requested file:line:column.

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


[Lldb-commits] [lldb] [llvm] [lldb][lldb-dap] Implement jump to cursor (PR #130503)

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

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


[Lldb-commits] [lld] [lldb] [llvm] [openmp] [doc] Use ISO nomenclature for 1024 byte units (PR #133148)

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

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

The comments/LLDB changes LGTM. You might want someone from OpenMP sign off on 
that change as this is output someone might be relying on.  

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


[Lldb-commits] [lldb] [lldb-dap] Migrating DAP 'initialize' to new typed RequestHandler. (PR #133007)

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


@@ -23,10 +23,240 @@
 #include "llvm/Support/JSON.h"
 #include 
 #include 
+#include 
 #include 
 
 namespace lldb_dap::protocol {
 
+/// An `ExceptionBreakpointsFilter` is shown in the UI as an filter option for
+/// configuring how exceptions are dealt with.
+struct ExceptionBreakpointsFilter {
+  /// The internal ID of the filter option. This value is passed to the
+  /// `setExceptionBreakpoints` request.
+  std::string filter;
+
+  /// The name of the filter option. This is shown in the UI.
+  std::string label;
+
+  /// A help text providing additional information about the exception filter.
+  /// This string is typically shown as a hover and can be translated.
+  std::optional description;
+
+  /// Initial value of the filter option. If not specified a value false is
+  /// assumed.
+  std::optional defaultState;
+
+  /// Controls whether a condition can be specified for this filter option. If
+  /// false or missing, a condition can not be set.
+  std::optional supportsCondition;
+
+  /// A help text providing information about the condition. This string is
+  /// shown as the placeholder text for a text box and can be translated.
+  std::optional conditionDescription;
+};
+llvm::json::Value toJSON(const ExceptionBreakpointsFilter &);
+
+/// A ColumnDescriptor specifies what module attribute to show in a column of
+/// the modules view, how to format it, and what the column’s label should be.
+///
+/// It is only used if the underlying UI actually supports this level of
+/// customization.
+struct ColumnDescriptor {
+  /// Name of the attribute rendered in this column.
+  std::string attributeName;
+
+  /// Header UI label of column.
+  std::string label;
+
+  /// Format to use for the rendered values in this column. TBD how the format
+  /// strings looks like.
+  std::optional format;
+
+  enum class Type { String, Number, Boolean, Timestamp };
+
+  /// Datatype of values in this column. Defaults to `string` if not specified.
+  /// Values: 'string', 'number', 'boolean', 'unixTimestampUTC'.
+  std::optional type;
+
+  /// Width of this column in characters (hint only).
+  std::optional width;
+};
+llvm::json::Value toJSON(const ColumnDescriptor &);
+
+/// Names of checksum algorithms that may be supported by a debug adapter.
+/// Values: ‘MD5’, ‘SHA1’, ‘SHA256’, ‘timestamp’.
+enum class ChecksumAlgorithm { md5, sha1, sha256, timestamp };

JDevlieghere wrote:

Shouldn't these match the spec? 
```suggestion
enum class ChecksumAlgorithm { MD5, SHA1, SHA256, timestamp };
```

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


[Lldb-commits] [lldb] [lldb-dap] Migrating DAP 'initialize' to new typed RequestHandler. (PR #133007)

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


@@ -44,4 +44,223 @@ bool fromJSON(const json::Value &Params, Source &S, 
json::Path P) {
  O.mapOptional("sourceReference", S.sourceReference);
 }
 
+json::Value toJSON(const ExceptionBreakpointsFilter &EBF) {
+  json::Object result{{"filter", EBF.filter}, {"label", EBF.label}};
+
+  if (EBF.description)
+result.insert({"description", *EBF.description});
+  if (EBF.defaultState)
+result.insert({"default", *EBF.defaultState});
+  if (EBF.supportsCondition)
+result.insert({"supportsCondition", *EBF.supportsCondition});
+  if (EBF.conditionDescription)
+result.insert({"conditionDescription", *EBF.conditionDescription});
+
+  return result;
+}
+
+json::Value toJSON(const ColumnDescriptor::Type &T) {
+  switch (T) {
+  case ColumnDescriptor::Type::String:
+return "string";
+  case ColumnDescriptor::Type::Number:
+return "number";
+  case ColumnDescriptor::Type::Boolean:
+return "boolean";
+  case ColumnDescriptor::Type::Timestamp:
+return "unixTimestampUTC";
+  }
+}
+
+json::Value toJSON(const ColumnDescriptor &CD) {
+  json::Object result{{"attributeName", CD.attributeName}, {"label", 
CD.label}};
+
+  if (CD.format)
+result.insert({"format", *CD.format});
+  if (CD.type)
+result.insert({"type", *CD.type});
+  if (CD.width)
+result.insert({"width", *CD.width});
+
+  return result;
+}
+
+json::Value toJSON(const ChecksumAlgorithm &CA) {
+  switch (CA) {
+  case ChecksumAlgorithm::md5:
+return "MD5";
+  case ChecksumAlgorithm::sha1:
+return "SHA1";
+  case ChecksumAlgorithm::sha256:
+return "SHA256";
+  case ChecksumAlgorithm::timestamp:
+return "timestamp";
+  }
+}
+
+json::Value toJSON(const BreakpointModeApplicability &BMA) {
+  switch (BMA) {
+  case BreakpointModeApplicability::source:
+return "source";
+  case BreakpointModeApplicability::exception:
+return "exception";
+  case BreakpointModeApplicability::data:
+return "data";
+  case BreakpointModeApplicability::instruction:
+return "instruction";
+  }
+}
+
+json::Value toJSON(const BreakpointMode &BM) {
+  json::Object result{
+  {"mode", BM.mode},
+  {"label", BM.label},
+  {"appliesTo", BM.appliesTo},
+  };
+
+  if (BM.description)
+result.insert({"description", *BM.description});
+
+  return result;
+}
+
+json::Value toJSON(const Capabilities &C) {
+  json::Object result;
+
+  for (const auto &feature : C.supportedFeatures)
+switch (feature) {
+case Capabilities::Feature::supportsANSIStyling:
+  result.insert({"supportsANSIStyling", true});
+  break;

JDevlieghere wrote:

I would create a (static) helper that converts the enum values to strings and 
then do 
```result.insert({GetFeatureAsString(feature), true})';```

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


[Lldb-commits] [lldb] [lldb-dap] Migrating DAP 'initialize' to new typed RequestHandler. (PR #133007)

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


@@ -54,6 +54,79 @@ bool fromJSON(const llvm::json::Value &, DisconnectArguments 
&,
 /// body field is required.
 using DisconnectResponse = VoidResponse;
 
+/// Arguments for `initialize` request.
+struct InitializeRequestArguments {
+  /// The ID of the debug adapter.
+  std::string adatperID;
+
+  /// The ID of the client using this adapter.
+  std::optional clientID;
+
+  /// The human-readable name of the client using this adapter.
+  std::optional clientName;
+
+  /// The ISO-639 locale of the client using this adapter, e.g. en-US or de-CH.
+  std::optional locale;
+
+  enum class PathFormat { path, uri };
+
+  /// Determines in what format paths are specified. The default is `path`,
+  /// which is the native format.
+  std::optional pathFormat = PathFormat::path;
+
+  /// If true all line numbers are 1-based (default).
+  std::optional linesStartAt1;
+
+  /// If true all column numbers are 1-based (default).
+  std::optional columnsStartAt1;
+
+  enum class Feature {
+/// Client supports the `type` attribute for variables.
+supportsVariableType,
+/// Client supports the paging of variables.
+supportsVariablePaging,
+/// Client supports the `runInTerminal` request.
+supportsRunInTerminalRequest,
+/// Client supports memory references.
+supportsMemoryReferences,
+/// Client supports progress reporting.
+supportsProgressReporting,
+/// Client supports the `invalidated` event.
+supportsInvalidatedEvent,
+/// Client supports the `memory` event.
+supportsMemoryEvent,
+/// Client supports the `argsCanBeInterpretedByShell` attribute on the
+/// `runInTerminal` request.
+supportsArgsCanBeInterpretedByShell,
+/// Client supports the `startDebugging` request.
+supportsStartDebuggingRequest,
+/// The client will interpret ANSI escape sequences in the display of
+/// `OutputEvent.output` and `Variable.value` fields when
+/// `Capabilities.supportsANSIStyling` is also enabled.
+supportsANSIStyling,
+  };

JDevlieghere wrote:

I know this is matching the spec, but I think this looks really weird and the 
more we move in the protocol class, the more inconsistent the code becomes and 
that's a bad thing. It stands out but not in a good way as the casing of the 
spec isn't meaningful. IMHO we shouldn't match the casing of the spec and 
remained consistent with LLDB. 

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


[Lldb-commits] [lldb] [lldb-dap] Migrating DAP 'initialize' to new typed RequestHandler. (PR #133007)

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


@@ -54,6 +54,79 @@ bool fromJSON(const llvm::json::Value &, DisconnectArguments 
&,
 /// body field is required.
 using DisconnectResponse = VoidResponse;
 
+/// Arguments for `initialize` request.
+struct InitializeRequestArguments {
+  /// The ID of the debug adapter.
+  std::string adatperID;
+
+  /// The ID of the client using this adapter.
+  std::optional clientID;
+
+  /// The human-readable name of the client using this adapter.
+  std::optional clientName;
+
+  /// The ISO-639 locale of the client using this adapter, e.g. en-US or de-CH.
+  std::optional locale;
+
+  enum class PathFormat { path, uri };
+
+  /// Determines in what format paths are specified. The default is `path`,
+  /// which is the native format.
+  std::optional pathFormat = PathFormat::path;
+
+  /// If true all line numbers are 1-based (default).
+  std::optional linesStartAt1;
+
+  /// If true all column numbers are 1-based (default).
+  std::optional columnsStartAt1;
+
+  enum class Feature {
+/// Client supports the `type` attribute for variables.
+supportsVariableType,
+/// Client supports the paging of variables.
+supportsVariablePaging,
+/// Client supports the `runInTerminal` request.
+supportsRunInTerminalRequest,
+/// Client supports memory references.
+supportsMemoryReferences,
+/// Client supports progress reporting.
+supportsProgressReporting,
+/// Client supports the `invalidated` event.
+supportsInvalidatedEvent,
+/// Client supports the `memory` event.

JDevlieghere wrote:

I don't mind re-adding those comments, but I omitted them in my earlier patch 
because they're pretty much adding no value. I think `supportsMemoryEvent` and 
`supportsANSIStyling` are the only two that deserve a comment. 

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


[Lldb-commits] [lldb] [lldb-dap] Migrating DAP 'initialize' to new typed RequestHandler. (PR #133007)

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


@@ -23,6 +24,75 @@ bool fromJSON(const json::Value &Params, DisconnectArguments 
&DA,
  O.mapOptional("suspendDebuggee", DA.suspendDebuggee);
 }
 
+bool fromJSON(const llvm::json::Value &Params,
+  InitializeRequestArguments::PathFormat &PF, llvm::json::Path P) {
+  auto rawPathFormat = Params.getAsString();
+  if (!rawPathFormat) {
+P.report("expected a string");
+return false;
+  }
+
+  std::optional pathFormat =
+  StringSwitch>(
+  *rawPathFormat)
+  .Case("path", InitializeRequestArguments::PathFormat::path)
+  .Case("uri", InitializeRequestArguments::PathFormat::uri)
+  .Default(std::nullopt);
+  if (!pathFormat) {
+P.report("unexpected value, expected 'path' or 'uri'");
+return false;
+  }
+
+  PF = *pathFormat;
+  return true;
+}
+
+bool fromJSON(const llvm::json::Value &Params, InitializeRequestArguments &IRA,
+  llvm::json::Path P) {
+  json::ObjectMapper OM(Params, P);
+  if (!OM)
+return false;
+
+  const json::Object *O = Params.getAsObject();
+  if (std::optional v = O->getBoolean("supportsVariableType"); v && *v)
+IRA.supportedFeatures.insert(ClientFeature::supportsVariableType);

JDevlieghere wrote:

This seems like an opportunity for a for-loop that iterates over a 
`std::pair`. 

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


[Lldb-commits] [lldb] [lldb-dap] Migrating DAP 'initialize' to new typed RequestHandler. (PR #133007)

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


@@ -47,7 +48,7 @@ class BaseRequestHandler {
 
   virtual void operator()(const protocol::Request &request) const = 0;
 
-  virtual llvm::StringMap GetCapabilities() const { return {}; }
+  virtual std::set GetSupportedFeatures() const { return {}; }

JDevlieghere wrote:

Should this return an `llvm::SmallSet?`? And then merge them 
into a `llvm::DenseSet`? 

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


[Lldb-commits] [lldb] [llvm] [lldb][lldb-dap] Implement jump to cursor (PR #130503)

2025-03-26 Thread via lldb-commits


@@ -0,0 +1,165 @@
+//===-- GoToTargetsRequestHandler.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 "DAP.h"
+
+#include "JSONUtils.h"
+
+#include 
+#include 
+#include 
+
+namespace lldb_dap {
+
+static llvm::SmallVector
+GetLineValidEntry(DAP &dap, const lldb::SBFileSpec &file_spec, uint32_t line) {
+  // disable breakpoint listeners so they do not send events to the DAP client.
+  lldb::SBListener listener = dap.debugger.GetListener();
+  lldb::SBBroadcaster broadcaster = dap.target.GetBroadcaster();
+  constexpr auto event_mask = lldb::SBTarget::eBroadcastBitBreakpointChanged;
+  listener.StopListeningForEvents(broadcaster, event_mask);

jimingham wrote:

This seems generally useful, and it is silly to have to actually set 
breakpoints to do this kind of symbol search.

I think at this point we should always allow column information when we do file 
& line type queries along with the file & line.  I almost wonder if we should 
have an SBLineEntrySpec to use for these sorts of queries so we don't have to 
repeat all the parameters.  But regardless, we should allow users to also pass 
in column info here.

In the case of breakpoints we will allow inexact matches if the user asks for 
them.  That's useful for setting breakpoints, but I'm not sure it's all that 
useful for a "ResolveContexts" type API.  So I don't think you need to add a 
`bool exact_match` but you should document the behavior since people might be 
surprised if it doesn't match what `break set` of the same file & line returns.

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


[Lldb-commits] [lldb] [llvm] [lldb][lldb-dap] Implement jump to cursor (PR #130503)

2025-03-26 Thread via lldb-commits


@@ -0,0 +1,165 @@
+//===-- GoToTargetsRequestHandler.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 "DAP.h"
+
+#include "JSONUtils.h"
+
+#include 
+#include 
+#include 
+
+namespace lldb_dap {
+
+static llvm::SmallVector
+GetLineValidEntry(DAP &dap, const lldb::SBFileSpec &file_spec, uint32_t line) {
+  // disable breakpoint listeners so they do not send events to the DAP client.
+  lldb::SBListener listener = dap.debugger.GetListener();
+  lldb::SBBroadcaster broadcaster = dap.target.GetBroadcaster();
+  constexpr auto event_mask = lldb::SBTarget::eBroadcastBitBreakpointChanged;
+  listener.StopListeningForEvents(broadcaster, event_mask);

jimingham wrote:

There are other types of queries that might be interesting here, like "file and 
line contained in another file or function" - when you're looking for inlining 
that's handy.  I'm not saying that we should support those up front, but if we 
can think of a couple more things like that that we'd want to do, it might be 
worth coming up with a container (like SBLineEntrySpec) that we can then add to 
as we go w/o having to change the API's.


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


[Lldb-commits] [lldb] [lldb] Remove raw access to PluginInstances vector (PR #132884)

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

JDevlieghere wrote:

> We did consider this approach. There are some drawbacks beyond the 
> performance issue, but the tradeoff may be worth it.
> 
> If we define the method like: `std::vector 
> GetEnabledInstances()` then we are returning copies of the PluginInstance. 
> Anything that modifies the internal state of the `PluginInstance` will be 
> lost since it is operating on a copy (e.g. 
> `GetEnabledInstances().front().DoSomethingToModifyInternalState()`).

Is that a theoretical concern or actually something that happens (or will 
happen with your patches)? Looking at the existing code, it doesn't look like 
anyone is modifying the instance and I can remove the non-const overload and we 
still compile. If anything, we probably don't want anyone to change these 
things as we're iterating over them.

> We could also return pointers to the plugin instances 
> like`std::vector GetEnabledInstances()`. But these would be 
> pointers to the locations in the vector stored in the `PluginInstance` class. 
> So if a new plugin is added to the PluginInstances list the pointers could be 
> invalidated. Probably not an issue with the current code, but could be unsafe 
> to hand out those references in general.

While definitely unsafe an something I think we shouldn't do, that's a problem 
today too if someone were to modify the instance list from another thread or 
take the address of one of its elements. 

> I suppose another way would be to keep a 
> `std::vector>` and then creating a copy would not 
> be an issue since any updates would also modify the original object.

I'd like to avoid shared_pointers if possible, but we could achieve the same 
thing by storing unique pointers in the vector and handing out raw points like 
you suggested above. 

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


[Lldb-commits] [lldb] draft: [lldb] Upgrade ValueObject::GetData to return llvm::Expected (PR #130516)

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

https://github.com/wizardengineer updated 
https://github.com/llvm/llvm-project/pull/130516

>From 161bdb32b284d2370b138e72a8a1ad560b258ba9 Mon Sep 17 00:00:00 2001
From: medievalghoul <61852278+medievalgh...@users.noreply.github.com>
Date: Sun, 9 Mar 2025 16:20:47 -0400
Subject: [PATCH 01/15] Change ValueObject::GetData to return llvm::Expected

---
 lldb/include/lldb/ValueObject/ValueObject.h   |  2 +-
 .../AppleObjCRuntime/AppleObjCRuntime.cpp |  5 ++--
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 12 
 lldb/source/ValueObject/ValueObject.cpp   | 28 +--
 4 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/lldb/include/lldb/ValueObject/ValueObject.h 
b/lldb/include/lldb/ValueObject/ValueObject.h
index 06d2589002ed0..2ee7f99718416 100644
--- a/lldb/include/lldb/ValueObject/ValueObject.h
+++ b/lldb/include/lldb/ValueObject/ValueObject.h
@@ -757,7 +757,7 @@ class ValueObject {
   virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
 uint32_t item_count = 1);
 
-  virtual uint64_t GetData(DataExtractor &data, Status &error);
+  virtual llvm::Expected GetData();
 
   virtual bool SetData(DataExtractor &data, Status &error);
 
diff --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
index ad60290382c02..69856d4592843 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -551,9 +551,8 @@ ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException(
 
 DataExtractor data;
 data.SetAddressByteSize(dict_entry->GetProcessSP()->GetAddressByteSize());
-Status error;
-dict_entry->GetData(data, error);
-if (error.Fail()) return ThreadSP();
+auto data_or_err = dict_entry->GetData();
+if (!data_or_err) return ThreadSP();
 
 lldb::offset_t data_offset = 0;
 auto dict_entry_key = data.GetAddress(&data_offset);
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 4ca4752310868..763a80faa914a 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -247,13 +247,15 @@ static lldb::addr_t GetVTableAddress(Process &process,
   // We have an object already read from process memory,
   // so just extract VTable pointer from it
 
-  DataExtractor data;
-  Status err;
-  auto size = valobj.GetData(data, err);
-  if (err.Fail() || vbtable_ptr_offset + data.GetAddressByteSize() > size)
+  auto data_or_err = valobj.GetData();
+  if (!data_or_err)
+return LLDB_INVALID_ADDRESS;
+
+  auto size = data_or_err->GetByteSize();
+  if (vbtable_ptr_offset + data_or_err->GetAddressByteSize() > size)
 return LLDB_INVALID_ADDRESS;
 
-  return data.GetAddress(&vbtable_ptr_offset);
+  return data_or_err->GetAddress(&vbtable_ptr_offset);
 }
 
 static int64_t ReadVBaseOffsetFromVTable(Process &process,
diff --git a/lldb/source/ValueObject/ValueObject.cpp 
b/lldb/source/ValueObject/ValueObject.cpp
index eac24353de90b..05cbc5489d25e 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -691,13 +691,20 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, 
uint32_t item_idx,
   ValueObjectSP pointee_sp = Dereference(error);
   if (error.Fail() || pointee_sp.get() == nullptr)
 return 0;
-  return pointee_sp->GetData(data, error);
+  auto data_or_err = pointee_sp->GetData();
+  if (!data_or_err)
+return 0;
+  data = *data_or_err;
+  return data.GetByteSize();
 } else {
   ValueObjectSP child_sp = GetChildAtIndex(0);
   if (child_sp.get() == nullptr)
 return 0;
-  Status error;
-  return child_sp->GetData(data, error);
+  auto data_or_err = child_sp->GetData();
+  if (!data_or_err)
+return 0;
+  data = *data_or_err;
+  return data.GetByteSize();
 }
 return true;
   } else /* (items > 1) */
@@ -764,22 +771,27 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, 
uint32_t item_idx,
   return 0;
 }
 
-uint64_t ValueObject::GetData(DataExtractor &data, Status &error) {
+llvm::Expected ValueObject::GetData() {
   UpdateValueIfNeeded(false);
   ExecutionContext exe_ctx(GetExecutionContextRef());
-  error = m_value.GetValueAsData(&exe_ctx, data, GetModule().get());
+  DataExtractor data;
+  Status error = m_value.GetValueAsData(&exe_ctx, data, GetModule().get());
   if (error.Fail()) {
 if (m_data.GetByteSize()) {
   data = m_data;
   error.Clear();
-  return data.GetByteSize();
+  data.SetAddressByteSize(m_data.GetAddressByteSize());
+  data.SetByteOrder(m_data.GetByteOrder());
+  return data;
 } else {
-  return 0;
+  re

[Lldb-commits] [lldb] [lldb][debugserver][MacOSX] Work around sanitizer misaligned address errors when reading exception data (PR #132193)

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

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

>From 223d85c6b2f5509f704d598bae974a98e5bf6bcb Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Thu, 20 Mar 2025 11:46:45 +
Subject: [PATCH 1/2] [lldb][debugserver][MacOSX] Work around sanitizer
 misaligned address errors when reading exception data

We've been dealing with UBSAN issues around this code for some time now
(see `9c36859b33b386fbfa9599646de1e2ae01158180` and
`1a2122e9e9d1d495fdf337a4a9445b61ca56df6f`). On recent macOS versions, a
UBSAN-enabled debugserver will crash when performing a `memcpy` of the
input `mach_exception_data_t`. The pointer to the beginning of the
exception data may not be aligned on a doubleword boundary, leading to
UBSAN failures such as:
```
$ ./bin/debugserver 0.0.0.0: 
/Volumes/SSD/llvm-builds/llvm-worktrees/clang-work/build-sanitized-release/tools/lldb/test/Shell/Recognizer/Output/verbose_trap.test.tmp.out
/Volumes/SSD/llvm-builds/llvm-worktrees/clang-work/lldb/tools/debugserver/source/MacOSX/MachException.cpp:35:12:
 runtime error: store to misaligned address 0x00016ddfa634 for type 
'mach_exception_data_type_t *' (aka 'long long *'), which requires 8 byte 
alignment
0x00016ddfa634: note: pointer points here
  02 00 00 00 03 00 01 00  00 00 00 00 11 00 00 00  00 00 00 00 00 00 00 00  08 
00 00 00 00 00 00 00
  ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior 
/Volumes/SSD/llvm-builds/llvm-worktrees/clang-work/lldb/tools/debugserver/source/MacOSX/MachException.cpp:35:12
```

Work around these failures by pretending the input data is a `char*` buffer.

Drive-by changes:
* I factored out some duplicated code into a static `AppendExceptionData` and 
made the types consistent
---
 .../source/MacOSX/MachException.cpp   | 38 ---
 .../debugserver/source/MacOSX/MachException.h |  9 -
 2 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/lldb/tools/debugserver/source/MacOSX/MachException.cpp 
b/lldb/tools/debugserver/source/MacOSX/MachException.cpp
index 659fb2ff8186d..d05b47cd9b590 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachException.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachException.cpp
@@ -20,6 +20,23 @@
 #include 
 #include 
 #include 
+#include 
+
+static void AppendExceptionData(
+std::vector &out,
+mach_exception_data_t Data, mach_msg_type_number_t Count) {
+  mach_exception_data_type_t Buf;
+  for (mach_msg_type_number_t i = 0; i < Count; ++i) {
+// The input Data we receive need not be aligned correctly.
+// Perform an unaligned copy by pretending we're dealing with
+// a char* buffer. This is required to work around UBSAN/ASAN
+// "misaligned address" errors.
+auto * src = reinterpret_cast(&Buf);
+auto * dst = reinterpret_cast(Data + i);
+memcpy(dst, src, sizeof(mach_exception_data_type_t));
+out.push_back(Buf);
+  }
+}
 
 // Routine mach_exception_raise
 extern "C" kern_return_t
@@ -95,20 +112,15 @@ catch_mach_exception_raise(mach_port_t exc_port, 
mach_port_t thread_port,
mach_exception_data_t exc_data,
mach_msg_type_number_t exc_data_count) {
   if (DNBLogCheckLogBit(LOG_EXCEPTIONS)) {
-std::vector exc_datas;
-uint64_t tmp;
-for (unsigned i = 0; i < exc_data_count; ++i) {
-  // Perform an unaligned copy.
-  memcpy(&tmp, &exc_data[i], sizeof(uint64_t));
-  exc_datas.push_back(tmp);
-}
+std::vector exc_datas;
+AppendExceptionData(exc_datas, exc_data, exc_data_count);
 DNBLogThreaded("::%s ( exc_port = 0x%4.4x, thd_port = 0x%4.4x, tsk_port = "
-   "0x%4.4x, exc_type = %d ( %s ), exc_data[%d] = { 0x%llx, "
-   "0x%llx })",
+   "0x%4.4x, exc_type = %d ( %s ), exc_data[%d] = { 0x%" 
PRIx64 ", "
+   "0x%" PRIx64 " })",
__FUNCTION__, exc_port, thread_port, task_port, exc_type,
MachException::Name(exc_type), exc_data_count,
-   (uint64_t)(exc_data_count > 0 ? exc_datas[0] : 0xBADDBADD),
-   (uint64_t)(exc_data_count > 1 ? exc_datas[1] : 0xBADDBADD));
+   (exc_data_count > 0 ? exc_datas[0] : 0xBADDBADD),
+   (exc_data_count > 1 ? exc_datas[1] : 0xBADDBADD));
   }
   g_message->exc_type = 0;
   g_message->exc_data.clear();
@@ -117,7 +129,7 @@ catch_mach_exception_raise(mach_port_t exc_port, 
mach_port_t thread_port,
 g_message->task_port = task_port;
 g_message->thread_port = thread_port;
 g_message->exc_type = exc_type;
-g_message->AppendExceptionData(exc_data, exc_data_count);
+AppendExceptionData(g_message->exc_data, exc_data, exc_data_count);
 return KERN_SUCCESS;
   } else if (!MachTask::IsValid(g_message->task_port)) {
 // Our original exception port isn't valid anymore check for a SIGTRAP
@@ -129,7 +141,7 @@ catch_mach_exception_raise(mach_port_t exc_port, 

[Lldb-commits] [lldb] [lldb-dap] Migrating DAP 'initialize' to new typed RequestHandler. (PR #133007)

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

ashgti wrote:

> This code seems quite repetitive. Would it be possible to have a 
> `Capabilities` enum and then representing the actual values by something like 
> `map` (with std::nullopt replaced by removing the 
> capability from the map). Or even `map` if you don't need to 
> access the capabilities individually (very often)? And maybe the handlers 
> don't even need to return the map, but just a list/vector of "new" 
> capabilities that they enable?

Done. Converted these into `std::set<(Adapter|Client)Feature>` sets for the 
`Capabilities` type and for the `InitializeRequestArguments`. I adjusted the 
RequestHandler classes to return a `std::set` now as well.

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


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

2025-03-26 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2025-03-26T14:41:05-07:00
New Revision: 9c18edc62123e778d1d713df44aa05c91e7bbbae

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

LOG: [lldb] Implement a statusline in LLDB (#121860)

Add a statusline to command-line LLDB to display information about the
current state of the debugger. The statusline is a dedicated area
displayed at the bottom of the screen. The information displayed is
configurable through a setting consisting of LLDB’s format strings.

Enablement
--

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

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

Configuration
-

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

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

The statusline supersedes the current progress reporting implementation.
Consequently, the following settings no longer have any effect (but
continue to exist to not break anyone's `.lldbinit`):

```
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.
```

Format Strings
--

LLDB's format strings are documented in the LLDB documentation and on
the website: https://lldb.llvm.org/use/formatting.html#format-strings.
The current implementation is relatively limited but various
improvements have been discussed in the RFC.

One such improvement is being to display a string when a format string
is empty. Right now, when launching LLDB without a target, the
statusline will be empty, which is expected, but looks rather odd.

RFC
---

The full RFC can be found on Discourse:
https://discourse.llvm.org/t/rfc-lldb-statusline/83948

Added: 
lldb/include/lldb/Core/Statusline.h
lldb/source/Core/Statusline.cpp
lldb/test/API/functionalities/statusline/Makefile
lldb/test/API/functionalities/statusline/TestStatusline.py
lldb/test/API/functionalities/statusline/main.c

Modified: 
lldb/include/lldb/Core/Debugger.h
lldb/include/lldb/Core/FormatEntity.h
lldb/include/lldb/Core/IOHandler.h
lldb/include/lldb/Host/Editline.h
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/source/Core/CMakeLists.txt
lldb/source/Core/CoreProperties.td
lldb/source/Core/Debugger.cpp
lldb/source/Core/FormatEntity.cpp
lldb/source/Core/IOHandler.cpp
lldb/source/Host/common/Editline.cpp

Removed: 

lldb/test/API/functionalities/progress_reporting/TestTrimmedProgressReporting.py



diff  --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ebc6147800e1..c79a75ab61564 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;
@@ -412,6 +417,9 @@ class Debugger : public 
std::enable_shared_from_this,
   /// Decrement the "interrupt requested" counter.
   void CancelInterruptRequest();
 
+  /// Redraw the statusline if enabled.
+  void RedrawStatusline(bool update = true);
+
   /// This is the correct way to query the state of Interruption.
   /// If you are on the RunCommandInterpreter thread, it will check the
   /// command interpreter state, and if it is on another thread it will
@@ -599,11 +607,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 GetCurrentProgressRepor

[Lldb-commits] [lldb] [llvm] [lldb][lldb-dap] Implement jump to cursor (PR #130503)

2025-03-26 Thread Ebuka Ezike via lldb-commits


@@ -0,0 +1,165 @@
+//===-- GoToTargetsRequestHandler.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 "DAP.h"
+
+#include "JSONUtils.h"
+
+#include 
+#include 
+#include 
+
+namespace lldb_dap {
+
+static llvm::SmallVector
+GetLineValidEntry(DAP &dap, const lldb::SBFileSpec &file_spec, uint32_t line) {
+  // disable breakpoint listeners so they do not send events to the DAP client.
+  lldb::SBListener listener = dap.debugger.GetListener();
+  lldb::SBBroadcaster broadcaster = dap.target.GetBroadcaster();
+  constexpr auto event_mask = lldb::SBTarget::eBroadcastBitBreakpointChanged;
+  listener.StopListeningForEvents(broadcaster, event_mask);

da-viper wrote:

Is there like a procedure in adding new SB Public API ? 

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


[Lldb-commits] [lldb] [llvm] [lldb][lldb-dap] Implement jump to cursor (PR #130503)

2025-03-26 Thread Ebuka Ezike via lldb-commits


@@ -0,0 +1,118 @@
+//===-- GoToRequestHandler.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 "DAP.h"
+#include "EventHelper.h"
+#include "JSONUtils.h"
+
+namespace lldb_dap {
+
+/// Creates an \p StoppedEvent with the reason \a goto
+static void SendThreadGotoEvent(DAP &dap, lldb::tid_t thread_id) {
+  llvm::json::Object event(CreateEventObject("stopped"));
+  llvm::json::Object body;
+  body.try_emplace("reason", "goto");
+  body.try_emplace("description", "Paused on Jump To Cursor");
+  body.try_emplace("threadId", thread_id);
+  body.try_emplace("preserveFocusHint", false);
+  body.try_emplace("allThreadsStopped", true);
+
+  event.try_emplace("body", std::move(body));
+  dap.SendJSON(llvm::json::Value(std::move(event)));
+}
+
+// "GotoRequest": {
+//   "allOf": [ { "$ref": "#/definitions/Request" }, {
+// "type": "object",
+// "description": "The request sets the location where the debuggee will
+// continue to run.\nThis makes it possible to skip the execution of code 
or
+// to execute code again.\nThe code between the current location and the
+// goto target is not executed but skipped.\nThe debug adapter first sends
+// the response and then a `stopped` event with reason `goto`.\nClients
+// should only call this request if the corresponding capability
+// `supportsGotoTargetsRequest` is true (because only then goto targets
+// exist that can be passed as arguments).",
+//."properties": {
+//   "command": {
+// "type": "string",
+// "enum": [ "goto" ]
+//   },
+//   "arguments": {
+// "$ref": "#/definitions/GotoArguments"
+//   }
+// },
+// "required": [ "command", "arguments"  ]
+//   }]
+// }
+// "GotoArguments": {
+//   "type": "object",
+//   "description": "Arguments for `goto` request.",
+//   "properties": {
+// "threadId": {
+//   "type": "integer",
+//   "description": "Set the goto target for this thread."
+// },
+// "targetId": {
+//   "type": "integer",
+//   "description": "The location where the debuggee will continue to run."
+// }
+//   },
+//   "required": [ "threadId", "targetId" ]
+// }
+// "GotoResponse": {
+//   "allOf": [ { "$ref": "#/definitions/Response" }, {
+// "type": "object",
+// "description": "Response to `goto` request. This is just an
+// acknowledgement, so no body field is required."
+//   }]
+// }
+void GoToRequestHandler::operator()(const llvm::json::Object &request) const {
+  llvm::json::Object response;
+  FillResponse(request, response);
+
+  auto SendError = [&](auto &&message) {
+response["success"] = false;
+response["message"] = message;
+dap.SendJSON(llvm::json::Value(std::move(response)));
+  };

da-viper wrote:

The new protocol currently does not implement  StoppedEvent. Not sure If I 
should implement it in this PR also. 

It may take longer since @clayborg  is proposing adding a new SB Public API 
function. 

Also the current new protocol does not take into account if we need to send an 
event after sending a response. Currently it will require repeating the  
`operator()(const protocol::Request &request)` code for any request that needs 
to send an event after a response such as stepIn, StepOut and Next  

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


[Lldb-commits] [lldb] [llvm] [lldb][lldb-dap] Implement jump to cursor (PR #130503)

2025-03-26 Thread Ebuka Ezike via lldb-commits

https://github.com/da-viper updated 
https://github.com/llvm/llvm-project/pull/130503

>From aa8ce4da16b9cf31974eb32ecefdeab403f3a497 Mon Sep 17 00:00:00 2001
From: Ezike Ebuka 
Date: Sun, 9 Mar 2025 12:46:54 +
Subject: [PATCH 01/25] [lldb-dap] implement jump to cursor.

---
 lldb/cmake/modules/LLDBConfig.cmake   |   2 +-
 lldb/tools/lldb-dap/CMakeLists.txt|   2 +
 lldb/tools/lldb-dap/DAP.cpp   |  23 +++-
 lldb/tools/lldb-dap/DAP.h |  27 +++-
 .../lldb-dap/Handler/GoToRequestHandler.cpp   | 103 +++
 .../Handler/GoToTargetsRequestHandler.cpp | 120 ++
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  14 ++
 lldb/tools/lldb-dap/lldb-dap.cpp  |   2 +
 8 files changed, 290 insertions(+), 3 deletions(-)
 create mode 100644 lldb/tools/lldb-dap/Handler/GoToRequestHandler.cpp
 create mode 100644 lldb/tools/lldb-dap/Handler/GoToTargetsRequestHandler.cpp

diff --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 9df71edd8b359..a2f9a29b6d5d5 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -57,7 +57,7 @@ add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses 
support in LLDB" Curse
 add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support in 
LLDB" LibLZMA LIBLZMA_FOUND)
 add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support in LLDB" 
LuaAndSwig LUAANDSWIG_FOUND)
 add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in 
LLDB" PythonAndSwig PYTHONANDSWIG_FOUND)
-add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" 
LibXml2 LIBXML2_FOUND VERSION 2.8)
+add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" 
LibXml2 LIBXML2_FOUND VERSION)
 add_optional_dependency(LLDB_ENABLE_FBSDVMCORE "Enable libfbsdvmcore support 
in LLDB" FBSDVMCore FBSDVMCore_FOUND QUIET)
 
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" 
ON)
diff --git a/lldb/tools/lldb-dap/CMakeLists.txt 
b/lldb/tools/lldb-dap/CMakeLists.txt
index e9773db7586e6..5169a1bb91ab8 100644
--- a/lldb/tools/lldb-dap/CMakeLists.txt
+++ b/lldb/tools/lldb-dap/CMakeLists.txt
@@ -46,6 +46,8 @@ add_lldb_tool(lldb-dap
   Handler/DisconnectRequestHandler.cpp
   Handler/EvaluateRequestHandler.cpp
   Handler/ExceptionInfoRequestHandler.cpp
+Handler/GoToRequestHandler.cpp
+Handler/GoToTargetsRequestHandler.cpp
   Handler/InitializeRequestHandler.cpp
   Handler/LaunchRequestHandler.cpp
   Handler/LocationsRequestHandler.cpp
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 65de0488729e5..986ac5c3bb408 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -81,7 +81,7 @@ DAP::DAP(llvm::StringRef path, Log *log, const ReplMode 
default_repl_mode,
   configuration_done_sent(false), waiting_for_run_in_terminal(false),
   progress_event_reporter(
   [&](const ProgressEvent &event) { SendJSON(event.ToJSON()); }),
-  reverse_request_seq(0), repl_mode(default_repl_mode) {}
+  reverse_request_seq(0), repl_mode(default_repl_mode), goto_id_map() {}
 
 DAP::~DAP() = default;
 
@@ -841,6 +841,27 @@ lldb::SBError DAP::WaitForProcessToStop(uint32_t seconds) {
   return error;
 }
 
+std::optional Gotos::GetLineEntry(uint64_t id) const {
+  const auto iter = line_entries.find(id);
+  if (iter != line_entries.end())
+return iter->second;
+
+  return std::nullopt;
+}
+
+uint64_t Gotos::InsertLineEntry(lldb::SBLineEntry line_entry) {
+  const auto spec_id = this->NewSpecId();
+  line_entries.insert(std::make_pair(spec_id, line_entry));
+  return spec_id;
+}
+
+void Gotos::Clear() {
+  new_id = 0UL;
+  line_entries.clear();
+}
+
+uint64_t Gotos::NewSpecId() { return new_id++; }
+
 void Variables::Clear() {
   locals.Clear();
   globals.Clear();
diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index 4b4d471161137..c280adb57d0c5 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -77,6 +77,27 @@ enum class PacketStatus {
 
 enum class ReplMode { Variable = 0, Command, Auto };
 
+class Gotos {
+public:
+  /// \return the line_entry corresponding with \p id
+  ///
+  /// If \p id is invalid std::nullopt is returned.
+  std::optional GetLineEntry(uint64_t id) const;
+
+  /// Insert a new \p line_entry.
+  /// \return id assigned to this line_entry.
+  uint64_t InsertLineEntry(lldb::SBLineEntry line_entry);
+
+  /// clears all line entries and reset the generated ids.
+  void Clear();
+
+private:
+  uint64_t NewSpecId();
+
+  llvm::DenseMap line_entries;
+  uint64_t new_id = 0ul;
+};
+
 struct Variables {
   /// Variable_reference start index of permanent expandable variable.
   static constexpr int64_t PermanentVariableStartIndex = (1ll << 32);
@@ -205,6 +226,7 @@ struct DAP {
   // empty; if the previous expression was a variable expression, this string
   // 

[Lldb-commits] [lldb] [llvm] [lldb][lldb-dap] Implement jump to cursor (PR #130503)

2025-03-26 Thread Ebuka Ezike via lldb-commits

https://github.com/da-viper updated 
https://github.com/llvm/llvm-project/pull/130503

>From aa8ce4da16b9cf31974eb32ecefdeab403f3a497 Mon Sep 17 00:00:00 2001
From: Ezike Ebuka 
Date: Sun, 9 Mar 2025 12:46:54 +
Subject: [PATCH 01/26] [lldb-dap] implement jump to cursor.

---
 lldb/cmake/modules/LLDBConfig.cmake   |   2 +-
 lldb/tools/lldb-dap/CMakeLists.txt|   2 +
 lldb/tools/lldb-dap/DAP.cpp   |  23 +++-
 lldb/tools/lldb-dap/DAP.h |  27 +++-
 .../lldb-dap/Handler/GoToRequestHandler.cpp   | 103 +++
 .../Handler/GoToTargetsRequestHandler.cpp | 120 ++
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  14 ++
 lldb/tools/lldb-dap/lldb-dap.cpp  |   2 +
 8 files changed, 290 insertions(+), 3 deletions(-)
 create mode 100644 lldb/tools/lldb-dap/Handler/GoToRequestHandler.cpp
 create mode 100644 lldb/tools/lldb-dap/Handler/GoToTargetsRequestHandler.cpp

diff --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 9df71edd8b359..a2f9a29b6d5d5 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -57,7 +57,7 @@ add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses 
support in LLDB" Curse
 add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support in 
LLDB" LibLZMA LIBLZMA_FOUND)
 add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support in LLDB" 
LuaAndSwig LUAANDSWIG_FOUND)
 add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in 
LLDB" PythonAndSwig PYTHONANDSWIG_FOUND)
-add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" 
LibXml2 LIBXML2_FOUND VERSION 2.8)
+add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" 
LibXml2 LIBXML2_FOUND VERSION)
 add_optional_dependency(LLDB_ENABLE_FBSDVMCORE "Enable libfbsdvmcore support 
in LLDB" FBSDVMCore FBSDVMCore_FOUND QUIET)
 
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" 
ON)
diff --git a/lldb/tools/lldb-dap/CMakeLists.txt 
b/lldb/tools/lldb-dap/CMakeLists.txt
index e9773db7586e6..5169a1bb91ab8 100644
--- a/lldb/tools/lldb-dap/CMakeLists.txt
+++ b/lldb/tools/lldb-dap/CMakeLists.txt
@@ -46,6 +46,8 @@ add_lldb_tool(lldb-dap
   Handler/DisconnectRequestHandler.cpp
   Handler/EvaluateRequestHandler.cpp
   Handler/ExceptionInfoRequestHandler.cpp
+Handler/GoToRequestHandler.cpp
+Handler/GoToTargetsRequestHandler.cpp
   Handler/InitializeRequestHandler.cpp
   Handler/LaunchRequestHandler.cpp
   Handler/LocationsRequestHandler.cpp
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 65de0488729e5..986ac5c3bb408 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -81,7 +81,7 @@ DAP::DAP(llvm::StringRef path, Log *log, const ReplMode 
default_repl_mode,
   configuration_done_sent(false), waiting_for_run_in_terminal(false),
   progress_event_reporter(
   [&](const ProgressEvent &event) { SendJSON(event.ToJSON()); }),
-  reverse_request_seq(0), repl_mode(default_repl_mode) {}
+  reverse_request_seq(0), repl_mode(default_repl_mode), goto_id_map() {}
 
 DAP::~DAP() = default;
 
@@ -841,6 +841,27 @@ lldb::SBError DAP::WaitForProcessToStop(uint32_t seconds) {
   return error;
 }
 
+std::optional Gotos::GetLineEntry(uint64_t id) const {
+  const auto iter = line_entries.find(id);
+  if (iter != line_entries.end())
+return iter->second;
+
+  return std::nullopt;
+}
+
+uint64_t Gotos::InsertLineEntry(lldb::SBLineEntry line_entry) {
+  const auto spec_id = this->NewSpecId();
+  line_entries.insert(std::make_pair(spec_id, line_entry));
+  return spec_id;
+}
+
+void Gotos::Clear() {
+  new_id = 0UL;
+  line_entries.clear();
+}
+
+uint64_t Gotos::NewSpecId() { return new_id++; }
+
 void Variables::Clear() {
   locals.Clear();
   globals.Clear();
diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index 4b4d471161137..c280adb57d0c5 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -77,6 +77,27 @@ enum class PacketStatus {
 
 enum class ReplMode { Variable = 0, Command, Auto };
 
+class Gotos {
+public:
+  /// \return the line_entry corresponding with \p id
+  ///
+  /// If \p id is invalid std::nullopt is returned.
+  std::optional GetLineEntry(uint64_t id) const;
+
+  /// Insert a new \p line_entry.
+  /// \return id assigned to this line_entry.
+  uint64_t InsertLineEntry(lldb::SBLineEntry line_entry);
+
+  /// clears all line entries and reset the generated ids.
+  void Clear();
+
+private:
+  uint64_t NewSpecId();
+
+  llvm::DenseMap line_entries;
+  uint64_t new_id = 0ul;
+};
+
 struct Variables {
   /// Variable_reference start index of permanent expandable variable.
   static constexpr int64_t PermanentVariableStartIndex = (1ll << 32);
@@ -205,6 +226,7 @@ struct DAP {
   // empty; if the previous expression was a variable expression, this string
   // 

[Lldb-commits] [lld] [lldb] [llvm] [openmp] [doc] Use ISO nomenclature for 1024 byte units (PR #133148)

2025-03-26 Thread via lldb-commits

github-actions[bot] wrote:



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

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

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

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

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

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

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

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


[Lldb-commits] [lld] [lldb] [llvm] [openmp] [doc] Use ISO nomenclature for 1024 byte units (PR #133148)

2025-03-26 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-x86

Author: Alexander Ziaee (concussious)


Changes

Increase specificity by using the correct unit sizes. KBytes is an abbreviation 
for kB, 1000 bytes, and the hardware industry as well as several operating 
systems have now switched to using 1000 byte kBs.

If this change is acceptable, sometimes GitHub mangles merges to use the 
original email of the account. $dayjob asks contributions have my work email. 
Thanks!

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


5 Files Affected:

- (modified) lld/ELF/Relocations.cpp (+1-1) 
- (modified) 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp 
(+1-1) 
- (modified) lldb/tools/debugserver/source/RNBRemote.cpp (+1-1) 
- (modified) llvm/lib/Target/X86/X86TargetTransformInfo.cpp (+2-2) 
- (modified) openmp/tools/archer/ompt-tsan.cpp (+1-1) 


``diff
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 629702b45965b..0653f79890646 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -162,7 +162,7 @@ static RelType getMipsPairType(RelType type, bool isLocal) {
 // symbol, the R_MIPS_GOT16 relocation creates a GOT entry to hold
 // the high 16 bits of the symbol's value. A paired R_MIPS_LO16
 // relocations handle low 16 bits of the address. That allows
-// to allocate only one GOT entry for every 64 KBytes of local data.
+// to allocate only one GOT entry for every 64 KiB of local data.
 return isLocal ? R_MIPS_LO16 : R_MIPS_NONE;
   case R_MICROMIPS_GOT16:
 return isLocal ? R_MICROMIPS_LO16 : R_MIPS_NONE;
diff --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
index 67ba42f33d1dd..4a1117222f34c 100644
--- 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -1377,7 +1377,7 @@ 
GDBRemoteCommunicationServerCommon::GetModuleInfo(llvm::StringRef module_path,
 
 std::vector GDBRemoteCommunicationServerCommon::HandleFeatures(
 const llvm::ArrayRef client_features) {
-  // 128KBytes is a reasonable max packet size--debugger can always use less.
+  // 128 KiB is a reasonable max packet size--debugger can always use less.
   constexpr uint32_t max_packet_size = 128 * 1024;
 
   // Features common to platform server and llgs.
diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp 
b/lldb/tools/debugserver/source/RNBRemote.cpp
index eb7c5ca32c02a..2ff4f29101f44 100644
--- a/lldb/tools/debugserver/source/RNBRemote.cpp
+++ b/lldb/tools/debugserver/source/RNBRemote.cpp
@@ -3477,7 +3477,7 @@ static bool GetProcessNameFrom_vAttach(const char *&p,
 }
 
 rnb_err_t RNBRemote::HandlePacket_qSupported(const char *p) {
-  uint32_t max_packet_size = 128 * 1024; // 128KBytes is a reasonable max 
packet
+  uint32_t max_packet_size = 128 * 1024; // 128 KiB is a reasonable max packet
  // size--debugger can always use less
   std::stringstream reply;
   reply << "qXfer:features:read+;PacketSize=" << std::hex << max_packet_size
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp 
b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
index 8bee87a22db16..fb91884d40132 100644
--- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
+++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
@@ -122,7 +122,7 @@ std::optional X86TTIImpl::getCacheSize(
 //   - Broadwell
 //   - Skylake
 //   - Kabylake
-return 32 * 1024;  //  32 KByte
+return 32 * 1024;  //  32 KiB
   case TargetTransformInfo::CacheLevel::L2D:
 //   - Penryn
 //   - Nehalem
@@ -133,7 +133,7 @@ std::optional X86TTIImpl::getCacheSize(
 //   - Broadwell
 //   - Skylake
 //   - Kabylake
-return 256 * 1024; // 256 KByte
+return 256 * 1024; // 256 KiB
   }
 
   llvm_unreachable("Unknown TargetTransformInfo::CacheLevel");
diff --git a/openmp/tools/archer/ompt-tsan.cpp 
b/openmp/tools/archer/ompt-tsan.cpp
index bb60fc6b603f4..c315999af4328 100644
--- a/openmp/tools/archer/ompt-tsan.cpp
+++ b/openmp/tools/archer/ompt-tsan.cpp
@@ -1224,7 +1224,7 @@ static void ompt_tsan_finalize(ompt_data_t *tool_data) {
   if (archer_flags->print_max_rss) {
 struct rusage end;
 getrusage(RUSAGE_SELF, &end);
-printf("MAX RSS[KBytes] during execution: %ld\n", end.ru_maxrss);
+printf("MAX RSS[KiB] during execution: %ld\n", end.ru_maxrss);
   }
 
   if (archer_flags)

``




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


[Lldb-commits] [lldb] draft: [lldb] Upgrade ValueObject::GetData to return llvm::Expected (PR #130516)

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

https://github.com/wizardengineer updated 
https://github.com/llvm/llvm-project/pull/130516

>From 161bdb32b284d2370b138e72a8a1ad560b258ba9 Mon Sep 17 00:00:00 2001
From: medievalghoul <61852278+medievalgh...@users.noreply.github.com>
Date: Sun, 9 Mar 2025 16:20:47 -0400
Subject: [PATCH 01/13] Change ValueObject::GetData to return llvm::Expected

---
 lldb/include/lldb/ValueObject/ValueObject.h   |  2 +-
 .../AppleObjCRuntime/AppleObjCRuntime.cpp |  5 ++--
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 12 
 lldb/source/ValueObject/ValueObject.cpp   | 28 +--
 4 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/lldb/include/lldb/ValueObject/ValueObject.h 
b/lldb/include/lldb/ValueObject/ValueObject.h
index 06d2589002ed0..2ee7f99718416 100644
--- a/lldb/include/lldb/ValueObject/ValueObject.h
+++ b/lldb/include/lldb/ValueObject/ValueObject.h
@@ -757,7 +757,7 @@ class ValueObject {
   virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
 uint32_t item_count = 1);
 
-  virtual uint64_t GetData(DataExtractor &data, Status &error);
+  virtual llvm::Expected GetData();
 
   virtual bool SetData(DataExtractor &data, Status &error);
 
diff --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
index ad60290382c02..69856d4592843 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -551,9 +551,8 @@ ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException(
 
 DataExtractor data;
 data.SetAddressByteSize(dict_entry->GetProcessSP()->GetAddressByteSize());
-Status error;
-dict_entry->GetData(data, error);
-if (error.Fail()) return ThreadSP();
+auto data_or_err = dict_entry->GetData();
+if (!data_or_err) return ThreadSP();
 
 lldb::offset_t data_offset = 0;
 auto dict_entry_key = data.GetAddress(&data_offset);
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 4ca4752310868..763a80faa914a 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -247,13 +247,15 @@ static lldb::addr_t GetVTableAddress(Process &process,
   // We have an object already read from process memory,
   // so just extract VTable pointer from it
 
-  DataExtractor data;
-  Status err;
-  auto size = valobj.GetData(data, err);
-  if (err.Fail() || vbtable_ptr_offset + data.GetAddressByteSize() > size)
+  auto data_or_err = valobj.GetData();
+  if (!data_or_err)
+return LLDB_INVALID_ADDRESS;
+
+  auto size = data_or_err->GetByteSize();
+  if (vbtable_ptr_offset + data_or_err->GetAddressByteSize() > size)
 return LLDB_INVALID_ADDRESS;
 
-  return data.GetAddress(&vbtable_ptr_offset);
+  return data_or_err->GetAddress(&vbtable_ptr_offset);
 }
 
 static int64_t ReadVBaseOffsetFromVTable(Process &process,
diff --git a/lldb/source/ValueObject/ValueObject.cpp 
b/lldb/source/ValueObject/ValueObject.cpp
index eac24353de90b..05cbc5489d25e 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -691,13 +691,20 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, 
uint32_t item_idx,
   ValueObjectSP pointee_sp = Dereference(error);
   if (error.Fail() || pointee_sp.get() == nullptr)
 return 0;
-  return pointee_sp->GetData(data, error);
+  auto data_or_err = pointee_sp->GetData();
+  if (!data_or_err)
+return 0;
+  data = *data_or_err;
+  return data.GetByteSize();
 } else {
   ValueObjectSP child_sp = GetChildAtIndex(0);
   if (child_sp.get() == nullptr)
 return 0;
-  Status error;
-  return child_sp->GetData(data, error);
+  auto data_or_err = child_sp->GetData();
+  if (!data_or_err)
+return 0;
+  data = *data_or_err;
+  return data.GetByteSize();
 }
 return true;
   } else /* (items > 1) */
@@ -764,22 +771,27 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, 
uint32_t item_idx,
   return 0;
 }
 
-uint64_t ValueObject::GetData(DataExtractor &data, Status &error) {
+llvm::Expected ValueObject::GetData() {
   UpdateValueIfNeeded(false);
   ExecutionContext exe_ctx(GetExecutionContextRef());
-  error = m_value.GetValueAsData(&exe_ctx, data, GetModule().get());
+  DataExtractor data;
+  Status error = m_value.GetValueAsData(&exe_ctx, data, GetModule().get());
   if (error.Fail()) {
 if (m_data.GetByteSize()) {
   data = m_data;
   error.Clear();
-  return data.GetByteSize();
+  data.SetAddressByteSize(m_data.GetAddressByteSize());
+  data.SetByteOrder(m_data.GetByteOrder());
+  return data;
 } else {
-  return 0;
+  re

[Lldb-commits] [lldb] draft: [lldb] Upgrade ValueObject::GetData to return llvm::Expected (PR #130516)

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

https://github.com/wizardengineer updated 
https://github.com/llvm/llvm-project/pull/130516

>From 161bdb32b284d2370b138e72a8a1ad560b258ba9 Mon Sep 17 00:00:00 2001
From: medievalghoul <61852278+medievalgh...@users.noreply.github.com>
Date: Sun, 9 Mar 2025 16:20:47 -0400
Subject: [PATCH 01/14] Change ValueObject::GetData to return llvm::Expected

---
 lldb/include/lldb/ValueObject/ValueObject.h   |  2 +-
 .../AppleObjCRuntime/AppleObjCRuntime.cpp |  5 ++--
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 12 
 lldb/source/ValueObject/ValueObject.cpp   | 28 +--
 4 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/lldb/include/lldb/ValueObject/ValueObject.h 
b/lldb/include/lldb/ValueObject/ValueObject.h
index 06d2589002ed0..2ee7f99718416 100644
--- a/lldb/include/lldb/ValueObject/ValueObject.h
+++ b/lldb/include/lldb/ValueObject/ValueObject.h
@@ -757,7 +757,7 @@ class ValueObject {
   virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
 uint32_t item_count = 1);
 
-  virtual uint64_t GetData(DataExtractor &data, Status &error);
+  virtual llvm::Expected GetData();
 
   virtual bool SetData(DataExtractor &data, Status &error);
 
diff --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
index ad60290382c02..69856d4592843 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -551,9 +551,8 @@ ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException(
 
 DataExtractor data;
 data.SetAddressByteSize(dict_entry->GetProcessSP()->GetAddressByteSize());
-Status error;
-dict_entry->GetData(data, error);
-if (error.Fail()) return ThreadSP();
+auto data_or_err = dict_entry->GetData();
+if (!data_or_err) return ThreadSP();
 
 lldb::offset_t data_offset = 0;
 auto dict_entry_key = data.GetAddress(&data_offset);
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 4ca4752310868..763a80faa914a 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -247,13 +247,15 @@ static lldb::addr_t GetVTableAddress(Process &process,
   // We have an object already read from process memory,
   // so just extract VTable pointer from it
 
-  DataExtractor data;
-  Status err;
-  auto size = valobj.GetData(data, err);
-  if (err.Fail() || vbtable_ptr_offset + data.GetAddressByteSize() > size)
+  auto data_or_err = valobj.GetData();
+  if (!data_or_err)
+return LLDB_INVALID_ADDRESS;
+
+  auto size = data_or_err->GetByteSize();
+  if (vbtable_ptr_offset + data_or_err->GetAddressByteSize() > size)
 return LLDB_INVALID_ADDRESS;
 
-  return data.GetAddress(&vbtable_ptr_offset);
+  return data_or_err->GetAddress(&vbtable_ptr_offset);
 }
 
 static int64_t ReadVBaseOffsetFromVTable(Process &process,
diff --git a/lldb/source/ValueObject/ValueObject.cpp 
b/lldb/source/ValueObject/ValueObject.cpp
index eac24353de90b..05cbc5489d25e 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -691,13 +691,20 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, 
uint32_t item_idx,
   ValueObjectSP pointee_sp = Dereference(error);
   if (error.Fail() || pointee_sp.get() == nullptr)
 return 0;
-  return pointee_sp->GetData(data, error);
+  auto data_or_err = pointee_sp->GetData();
+  if (!data_or_err)
+return 0;
+  data = *data_or_err;
+  return data.GetByteSize();
 } else {
   ValueObjectSP child_sp = GetChildAtIndex(0);
   if (child_sp.get() == nullptr)
 return 0;
-  Status error;
-  return child_sp->GetData(data, error);
+  auto data_or_err = child_sp->GetData();
+  if (!data_or_err)
+return 0;
+  data = *data_or_err;
+  return data.GetByteSize();
 }
 return true;
   } else /* (items > 1) */
@@ -764,22 +771,27 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, 
uint32_t item_idx,
   return 0;
 }
 
-uint64_t ValueObject::GetData(DataExtractor &data, Status &error) {
+llvm::Expected ValueObject::GetData() {
   UpdateValueIfNeeded(false);
   ExecutionContext exe_ctx(GetExecutionContextRef());
-  error = m_value.GetValueAsData(&exe_ctx, data, GetModule().get());
+  DataExtractor data;
+  Status error = m_value.GetValueAsData(&exe_ctx, data, GetModule().get());
   if (error.Fail()) {
 if (m_data.GetByteSize()) {
   data = m_data;
   error.Clear();
-  return data.GetByteSize();
+  data.SetAddressByteSize(m_data.GetAddressByteSize());
+  data.SetByteOrder(m_data.GetByteOrder());
+  return data;
 } else {
-  return 0;
+  re

[Lldb-commits] [lldb] draft: [lldb] Upgrade ValueObject::GetData to return llvm::Expected (PR #130516)

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

wizardengineer wrote:

> You could even write a wrapper for that test that creates a Status from the 
> error and imitates the old API, just inside the unit tests.

how would i go about doing that?


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


[Lldb-commits] [lldb] [lldb] Teach FuncUnwinders about discontinuous functions (PR #133072)

2025-03-26 Thread Jason Molenda via lldb-commits

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

LGTM.

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


[Lldb-commits] [lldb] draft: [lldb] Upgrade ValueObject::GetData to return llvm::Expected (PR #130516)

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

https://github.com/wizardengineer updated 
https://github.com/llvm/llvm-project/pull/130516

>From 161bdb32b284d2370b138e72a8a1ad560b258ba9 Mon Sep 17 00:00:00 2001
From: medievalghoul <61852278+medievalgh...@users.noreply.github.com>
Date: Sun, 9 Mar 2025 16:20:47 -0400
Subject: [PATCH 1/9] Change ValueObject::GetData to return llvm::Expected

---
 lldb/include/lldb/ValueObject/ValueObject.h   |  2 +-
 .../AppleObjCRuntime/AppleObjCRuntime.cpp |  5 ++--
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 12 
 lldb/source/ValueObject/ValueObject.cpp   | 28 +--
 4 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/lldb/include/lldb/ValueObject/ValueObject.h 
b/lldb/include/lldb/ValueObject/ValueObject.h
index 06d2589002ed0..2ee7f99718416 100644
--- a/lldb/include/lldb/ValueObject/ValueObject.h
+++ b/lldb/include/lldb/ValueObject/ValueObject.h
@@ -757,7 +757,7 @@ class ValueObject {
   virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
 uint32_t item_count = 1);
 
-  virtual uint64_t GetData(DataExtractor &data, Status &error);
+  virtual llvm::Expected GetData();
 
   virtual bool SetData(DataExtractor &data, Status &error);
 
diff --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
index ad60290382c02..69856d4592843 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -551,9 +551,8 @@ ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException(
 
 DataExtractor data;
 data.SetAddressByteSize(dict_entry->GetProcessSP()->GetAddressByteSize());
-Status error;
-dict_entry->GetData(data, error);
-if (error.Fail()) return ThreadSP();
+auto data_or_err = dict_entry->GetData();
+if (!data_or_err) return ThreadSP();
 
 lldb::offset_t data_offset = 0;
 auto dict_entry_key = data.GetAddress(&data_offset);
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 4ca4752310868..763a80faa914a 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -247,13 +247,15 @@ static lldb::addr_t GetVTableAddress(Process &process,
   // We have an object already read from process memory,
   // so just extract VTable pointer from it
 
-  DataExtractor data;
-  Status err;
-  auto size = valobj.GetData(data, err);
-  if (err.Fail() || vbtable_ptr_offset + data.GetAddressByteSize() > size)
+  auto data_or_err = valobj.GetData();
+  if (!data_or_err)
+return LLDB_INVALID_ADDRESS;
+
+  auto size = data_or_err->GetByteSize();
+  if (vbtable_ptr_offset + data_or_err->GetAddressByteSize() > size)
 return LLDB_INVALID_ADDRESS;
 
-  return data.GetAddress(&vbtable_ptr_offset);
+  return data_or_err->GetAddress(&vbtable_ptr_offset);
 }
 
 static int64_t ReadVBaseOffsetFromVTable(Process &process,
diff --git a/lldb/source/ValueObject/ValueObject.cpp 
b/lldb/source/ValueObject/ValueObject.cpp
index eac24353de90b..05cbc5489d25e 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -691,13 +691,20 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, 
uint32_t item_idx,
   ValueObjectSP pointee_sp = Dereference(error);
   if (error.Fail() || pointee_sp.get() == nullptr)
 return 0;
-  return pointee_sp->GetData(data, error);
+  auto data_or_err = pointee_sp->GetData();
+  if (!data_or_err)
+return 0;
+  data = *data_or_err;
+  return data.GetByteSize();
 } else {
   ValueObjectSP child_sp = GetChildAtIndex(0);
   if (child_sp.get() == nullptr)
 return 0;
-  Status error;
-  return child_sp->GetData(data, error);
+  auto data_or_err = child_sp->GetData();
+  if (!data_or_err)
+return 0;
+  data = *data_or_err;
+  return data.GetByteSize();
 }
 return true;
   } else /* (items > 1) */
@@ -764,22 +771,27 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, 
uint32_t item_idx,
   return 0;
 }
 
-uint64_t ValueObject::GetData(DataExtractor &data, Status &error) {
+llvm::Expected ValueObject::GetData() {
   UpdateValueIfNeeded(false);
   ExecutionContext exe_ctx(GetExecutionContextRef());
-  error = m_value.GetValueAsData(&exe_ctx, data, GetModule().get());
+  DataExtractor data;
+  Status error = m_value.GetValueAsData(&exe_ctx, data, GetModule().get());
   if (error.Fail()) {
 if (m_data.GetByteSize()) {
   data = m_data;
   error.Clear();
-  return data.GetByteSize();
+  data.SetAddressByteSize(m_data.GetAddressByteSize());
+  data.SetByteOrder(m_data.GetByteOrder());
+  return data;
 } else {
-  return 0;
+  retu

[Lldb-commits] [lldb] Reapply "[lldb] Implement basic support for reverse-continue (#125242)" (again) (PR #128156)

2025-03-26 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

Sorry for not commenting last week when this issue was live, but with regards 
to Apple silicon macs, there was a kernel behavior where watchpoints and 
hardware breakpoints were disabled by the kernel when it was single instruction 
stepping.  I believe this was fixed in macOS 14.4, released March 2024.  The 
fix was definitely in place by macOS 15.

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


[Lldb-commits] [lldb] Make breakpoint stop reason more accurate for function breakpoints (PR #130841)

2025-03-26 Thread via lldb-commits

https://github.com/satyajanga updated 
https://github.com/llvm/llvm-project/pull/130841

>From e949d2ee19408c43d9067075d2436f8549132830 Mon Sep 17 00:00:00 2001
From: satya janga 
Date: Tue, 11 Mar 2025 13:39:08 -0700
Subject: [PATCH 1/4] Make breakpoint stop reason more accurate

---
 .../test/tools/lldb-dap/lldbdap_testcase.py   |  3 ++-
 lldb/tools/lldb-dap/DAP.cpp   | 26 +++
 lldb/tools/lldb-dap/DAP.h | 14 +-
 lldb/tools/lldb-dap/JSONUtils.cpp | 12 ++---
 4 files changed, 45 insertions(+), 10 deletions(-)

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index 70b04b051e0ec..5faf83ca826a0 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -86,6 +86,7 @@ def verify_breakpoint_hit(self, breakpoint_ids):
 if (
 body["reason"] != "breakpoint"
 and body["reason"] != "instruction breakpoint"
+and body["reason"] != "function breakpoint"
 ):
 continue
 if "description" not in body:
@@ -100,7 +101,7 @@ def verify_breakpoint_hit(self, breakpoint_ids):
 # location.
 description = body["description"]
 for breakpoint_id in breakpoint_ids:
-match_desc = "breakpoint %s." % (breakpoint_id)
+match_desc = "%s %s." % (body["reason"], breakpoint_id)
 if match_desc in description:
 return
 self.assertTrue(False, "breakpoint not hit")
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 4080e2c211035..7baf858011362 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -1074,6 +1074,32 @@ DAP::GetInstructionBPFromStopReason(lldb::SBThread 
&thread) {
   return inst_bp;
 }
 
+FunctionBreakpoint *DAP::GetFunctionBPFromStopReason(lldb::SBThread &thread) {
+  const auto num = thread.GetStopReasonDataCount();
+  FunctionBreakpoint *func_bp = nullptr;
+  for (size_t i = 0; i < num; i += 2) {
+// thread.GetStopReasonDataAtIndex(i) will return the bp ID and
+// thread.GetStopReasonDataAtIndex(i+1) will return the location
+// within that breakpoint. We only care about the bp ID so we can
+// see if this is an function breakpoint that is getting hit.
+lldb::break_id_t bp_id = thread.GetStopReasonDataAtIndex(i);
+func_bp = GetFunctionBreakPoint(bp_id);
+// If any breakpoint is not an function breakpoint, then stop and
+// report this as a normal breakpoint
+if (func_bp == nullptr)
+  return nullptr;
+  }
+  return func_bp;
+}
+
+FunctionBreakpoint *DAP::GetFunctionBreakPoint(const lldb::break_id_t bp_id) {
+  for (auto &bp : function_breakpoints) {
+if (bp.second.bp.GetID() == bp_id)
+  return &bp.second;
+  }
+  return nullptr;
+}
+
 lldb::SBValueList *Variables::GetTopLevelScope(int64_t variablesReference) {
   switch (variablesReference) {
   case VARREF_LOCALS:
diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index db3473b7c7027..3913d7bc40978 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -125,21 +125,21 @@ struct Variables {
 
 struct StartDebuggingRequestHandler : public lldb::SBCommandPluginInterface {
   DAP &dap;
-  explicit StartDebuggingRequestHandler(DAP &d) : dap(d) {};
+  explicit StartDebuggingRequestHandler(DAP &d) : dap(d){};
   bool DoExecute(lldb::SBDebugger debugger, char **command,
  lldb::SBCommandReturnObject &result) override;
 };
 
 struct ReplModeRequestHandler : public lldb::SBCommandPluginInterface {
   DAP &dap;
-  explicit ReplModeRequestHandler(DAP &d) : dap(d) {};
+  explicit ReplModeRequestHandler(DAP &d) : dap(d){};
   bool DoExecute(lldb::SBDebugger debugger, char **command,
  lldb::SBCommandReturnObject &result) override;
 };
 
 struct SendEventRequestHandler : public lldb::SBCommandPluginInterface {
   DAP &dap;
-  explicit SendEventRequestHandler(DAP &d) : dap(d) {};
+  explicit SendEventRequestHandler(DAP &d) : dap(d){};
   bool DoExecute(lldb::SBDebugger debugger, char **command,
  lldb::SBCommandReturnObject &result) override;
 };
@@ -392,9 +392,11 @@ struct DAP {
 
   void SetThreadFormat(llvm::StringRef format);
 
-  InstructionBreakpoint *GetInstructionBreakpoint(const lldb::break_id_t 
bp_id);
-
-  InstructionBreakpoint *GetInstructionBPFromStopReason(lldb::SBThread 
&thread);
+private:
+  // Send the JSON in "json_str" to the "out" stream. Correctly send the
+  // "Content-Length:" field followed by the length, followed by the raw
+  // JSON bytes.
+  void SendJSON(const std::string &json_str);
 };
 
 } // namespace lldb_dap
diff --git a/lldb/too

[Lldb-commits] [lld] [lldb] [llvm] [openmp] [doc] Use ISO nomenclature for 1024 byte units (PR #133148)

2025-03-26 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lld-elf

Author: Alexander Ziaee (concussious)


Changes

Increase specificity by using the correct unit sizes. KBytes is an abbreviation 
for kB, 1000 bytes, and the hardware industry as well as several operating 
systems have now switched to using 1000 byte kBs.

If this change is acceptable, sometimes GitHub mangles merges to use the 
original email of the account. $dayjob asks contributions have my work email. 
Thanks!

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


5 Files Affected:

- (modified) lld/ELF/Relocations.cpp (+1-1) 
- (modified) 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp 
(+1-1) 
- (modified) lldb/tools/debugserver/source/RNBRemote.cpp (+1-1) 
- (modified) llvm/lib/Target/X86/X86TargetTransformInfo.cpp (+2-2) 
- (modified) openmp/tools/archer/ompt-tsan.cpp (+1-1) 


``diff
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 629702b45965b..0653f79890646 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -162,7 +162,7 @@ static RelType getMipsPairType(RelType type, bool isLocal) {
 // symbol, the R_MIPS_GOT16 relocation creates a GOT entry to hold
 // the high 16 bits of the symbol's value. A paired R_MIPS_LO16
 // relocations handle low 16 bits of the address. That allows
-// to allocate only one GOT entry for every 64 KBytes of local data.
+// to allocate only one GOT entry for every 64 KiB of local data.
 return isLocal ? R_MIPS_LO16 : R_MIPS_NONE;
   case R_MICROMIPS_GOT16:
 return isLocal ? R_MICROMIPS_LO16 : R_MIPS_NONE;
diff --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
index 67ba42f33d1dd..4a1117222f34c 100644
--- 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -1377,7 +1377,7 @@ 
GDBRemoteCommunicationServerCommon::GetModuleInfo(llvm::StringRef module_path,
 
 std::vector GDBRemoteCommunicationServerCommon::HandleFeatures(
 const llvm::ArrayRef client_features) {
-  // 128KBytes is a reasonable max packet size--debugger can always use less.
+  // 128 KiB is a reasonable max packet size--debugger can always use less.
   constexpr uint32_t max_packet_size = 128 * 1024;
 
   // Features common to platform server and llgs.
diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp 
b/lldb/tools/debugserver/source/RNBRemote.cpp
index eb7c5ca32c02a..2ff4f29101f44 100644
--- a/lldb/tools/debugserver/source/RNBRemote.cpp
+++ b/lldb/tools/debugserver/source/RNBRemote.cpp
@@ -3477,7 +3477,7 @@ static bool GetProcessNameFrom_vAttach(const char *&p,
 }
 
 rnb_err_t RNBRemote::HandlePacket_qSupported(const char *p) {
-  uint32_t max_packet_size = 128 * 1024; // 128KBytes is a reasonable max 
packet
+  uint32_t max_packet_size = 128 * 1024; // 128 KiB is a reasonable max packet
  // size--debugger can always use less
   std::stringstream reply;
   reply << "qXfer:features:read+;PacketSize=" << std::hex << max_packet_size
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp 
b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
index 8bee87a22db16..fb91884d40132 100644
--- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
+++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
@@ -122,7 +122,7 @@ std::optional X86TTIImpl::getCacheSize(
 //   - Broadwell
 //   - Skylake
 //   - Kabylake
-return 32 * 1024;  //  32 KByte
+return 32 * 1024;  //  32 KiB
   case TargetTransformInfo::CacheLevel::L2D:
 //   - Penryn
 //   - Nehalem
@@ -133,7 +133,7 @@ std::optional X86TTIImpl::getCacheSize(
 //   - Broadwell
 //   - Skylake
 //   - Kabylake
-return 256 * 1024; // 256 KByte
+return 256 * 1024; // 256 KiB
   }
 
   llvm_unreachable("Unknown TargetTransformInfo::CacheLevel");
diff --git a/openmp/tools/archer/ompt-tsan.cpp 
b/openmp/tools/archer/ompt-tsan.cpp
index bb60fc6b603f4..c315999af4328 100644
--- a/openmp/tools/archer/ompt-tsan.cpp
+++ b/openmp/tools/archer/ompt-tsan.cpp
@@ -1224,7 +1224,7 @@ static void ompt_tsan_finalize(ompt_data_t *tool_data) {
   if (archer_flags->print_max_rss) {
 struct rusage end;
 getrusage(RUSAGE_SELF, &end);
-printf("MAX RSS[KBytes] during execution: %ld\n", end.ru_maxrss);
+printf("MAX RSS[KiB] during execution: %ld\n", end.ru_maxrss);
   }
 
   if (archer_flags)

``




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


[Lldb-commits] [lld] [lldb] [llvm] [openmp] [doc] Use ISO nomenclature for 1024 byte units (PR #133148)

2025-03-26 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lld

Author: Alexander Ziaee (concussious)


Changes

Increase specificity by using the correct unit sizes. KBytes is an abbreviation 
for kB, 1000 bytes, and the hardware industry as well as several operating 
systems have now switched to using 1000 byte kBs.

If this change is acceptable, sometimes GitHub mangles merges to use the 
original email of the account. $dayjob asks contributions have my work email. 
Thanks!

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


5 Files Affected:

- (modified) lld/ELF/Relocations.cpp (+1-1) 
- (modified) 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp 
(+1-1) 
- (modified) lldb/tools/debugserver/source/RNBRemote.cpp (+1-1) 
- (modified) llvm/lib/Target/X86/X86TargetTransformInfo.cpp (+2-2) 
- (modified) openmp/tools/archer/ompt-tsan.cpp (+1-1) 


``diff
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 629702b45965b..0653f79890646 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -162,7 +162,7 @@ static RelType getMipsPairType(RelType type, bool isLocal) {
 // symbol, the R_MIPS_GOT16 relocation creates a GOT entry to hold
 // the high 16 bits of the symbol's value. A paired R_MIPS_LO16
 // relocations handle low 16 bits of the address. That allows
-// to allocate only one GOT entry for every 64 KBytes of local data.
+// to allocate only one GOT entry for every 64 KiB of local data.
 return isLocal ? R_MIPS_LO16 : R_MIPS_NONE;
   case R_MICROMIPS_GOT16:
 return isLocal ? R_MICROMIPS_LO16 : R_MIPS_NONE;
diff --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
index 67ba42f33d1dd..4a1117222f34c 100644
--- 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -1377,7 +1377,7 @@ 
GDBRemoteCommunicationServerCommon::GetModuleInfo(llvm::StringRef module_path,
 
 std::vector GDBRemoteCommunicationServerCommon::HandleFeatures(
 const llvm::ArrayRef client_features) {
-  // 128KBytes is a reasonable max packet size--debugger can always use less.
+  // 128 KiB is a reasonable max packet size--debugger can always use less.
   constexpr uint32_t max_packet_size = 128 * 1024;
 
   // Features common to platform server and llgs.
diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp 
b/lldb/tools/debugserver/source/RNBRemote.cpp
index eb7c5ca32c02a..2ff4f29101f44 100644
--- a/lldb/tools/debugserver/source/RNBRemote.cpp
+++ b/lldb/tools/debugserver/source/RNBRemote.cpp
@@ -3477,7 +3477,7 @@ static bool GetProcessNameFrom_vAttach(const char *&p,
 }
 
 rnb_err_t RNBRemote::HandlePacket_qSupported(const char *p) {
-  uint32_t max_packet_size = 128 * 1024; // 128KBytes is a reasonable max 
packet
+  uint32_t max_packet_size = 128 * 1024; // 128 KiB is a reasonable max packet
  // size--debugger can always use less
   std::stringstream reply;
   reply << "qXfer:features:read+;PacketSize=" << std::hex << max_packet_size
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp 
b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
index 8bee87a22db16..fb91884d40132 100644
--- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
+++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
@@ -122,7 +122,7 @@ std::optional X86TTIImpl::getCacheSize(
 //   - Broadwell
 //   - Skylake
 //   - Kabylake
-return 32 * 1024;  //  32 KByte
+return 32 * 1024;  //  32 KiB
   case TargetTransformInfo::CacheLevel::L2D:
 //   - Penryn
 //   - Nehalem
@@ -133,7 +133,7 @@ std::optional X86TTIImpl::getCacheSize(
 //   - Broadwell
 //   - Skylake
 //   - Kabylake
-return 256 * 1024; // 256 KByte
+return 256 * 1024; // 256 KiB
   }
 
   llvm_unreachable("Unknown TargetTransformInfo::CacheLevel");
diff --git a/openmp/tools/archer/ompt-tsan.cpp 
b/openmp/tools/archer/ompt-tsan.cpp
index bb60fc6b603f4..c315999af4328 100644
--- a/openmp/tools/archer/ompt-tsan.cpp
+++ b/openmp/tools/archer/ompt-tsan.cpp
@@ -1224,7 +1224,7 @@ static void ompt_tsan_finalize(ompt_data_t *tool_data) {
   if (archer_flags->print_max_rss) {
 struct rusage end;
 getrusage(RUSAGE_SELF, &end);
-printf("MAX RSS[KBytes] during execution: %ld\n", end.ru_maxrss);
+printf("MAX RSS[KiB] during execution: %ld\n", end.ru_maxrss);
   }
 
   if (archer_flags)

``




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


[Lldb-commits] [lld] [lldb] [llvm] [openmp] [doc] Use ISO nomenclature for 1024 byte units (PR #133148)

2025-03-26 Thread Alexander Ziaee via lldb-commits

https://github.com/concussious created 
https://github.com/llvm/llvm-project/pull/133148

Increase specificity by using the correct unit sizes. KBytes is an abbreviation 
for kB, 1000 bytes, and the hardware industry as well as several operating 
systems have now switched to using 1000 byte kBs.

If this change is acceptable, sometimes GitHub mangles merges to use the 
original email of the account. $dayjob asks contributions have my work email. 
Thanks!

>From 613f4c354335131bc9dd9adf2464edbe0d0abd04 Mon Sep 17 00:00:00 2001
From: Alexander Ziaee 
Date: Wed, 26 Mar 2025 15:51:38 -0400
Subject: [PATCH] [doc] Use ISO nomenclature for 1024 byte units

---
 lld/ELF/Relocations.cpp   | 2 +-
 .../Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp | 2 +-
 lldb/tools/debugserver/source/RNBRemote.cpp   | 2 +-
 llvm/lib/Target/X86/X86TargetTransformInfo.cpp| 4 ++--
 openmp/tools/archer/ompt-tsan.cpp | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 629702b45965b..0653f79890646 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -162,7 +162,7 @@ static RelType getMipsPairType(RelType type, bool isLocal) {
 // symbol, the R_MIPS_GOT16 relocation creates a GOT entry to hold
 // the high 16 bits of the symbol's value. A paired R_MIPS_LO16
 // relocations handle low 16 bits of the address. That allows
-// to allocate only one GOT entry for every 64 KBytes of local data.
+// to allocate only one GOT entry for every 64 KiB of local data.
 return isLocal ? R_MIPS_LO16 : R_MIPS_NONE;
   case R_MICROMIPS_GOT16:
 return isLocal ? R_MICROMIPS_LO16 : R_MIPS_NONE;
diff --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
index 67ba42f33d1dd..4a1117222f34c 100644
--- 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -1377,7 +1377,7 @@ 
GDBRemoteCommunicationServerCommon::GetModuleInfo(llvm::StringRef module_path,
 
 std::vector GDBRemoteCommunicationServerCommon::HandleFeatures(
 const llvm::ArrayRef client_features) {
-  // 128KBytes is a reasonable max packet size--debugger can always use less.
+  // 128 KiB is a reasonable max packet size--debugger can always use less.
   constexpr uint32_t max_packet_size = 128 * 1024;
 
   // Features common to platform server and llgs.
diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp 
b/lldb/tools/debugserver/source/RNBRemote.cpp
index eb7c5ca32c02a..2ff4f29101f44 100644
--- a/lldb/tools/debugserver/source/RNBRemote.cpp
+++ b/lldb/tools/debugserver/source/RNBRemote.cpp
@@ -3477,7 +3477,7 @@ static bool GetProcessNameFrom_vAttach(const char *&p,
 }
 
 rnb_err_t RNBRemote::HandlePacket_qSupported(const char *p) {
-  uint32_t max_packet_size = 128 * 1024; // 128KBytes is a reasonable max 
packet
+  uint32_t max_packet_size = 128 * 1024; // 128 KiB is a reasonable max packet
  // size--debugger can always use less
   std::stringstream reply;
   reply << "qXfer:features:read+;PacketSize=" << std::hex << max_packet_size
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp 
b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
index 8bee87a22db16..fb91884d40132 100644
--- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
+++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
@@ -122,7 +122,7 @@ std::optional X86TTIImpl::getCacheSize(
 //   - Broadwell
 //   - Skylake
 //   - Kabylake
-return 32 * 1024;  //  32 KByte
+return 32 * 1024;  //  32 KiB
   case TargetTransformInfo::CacheLevel::L2D:
 //   - Penryn
 //   - Nehalem
@@ -133,7 +133,7 @@ std::optional X86TTIImpl::getCacheSize(
 //   - Broadwell
 //   - Skylake
 //   - Kabylake
-return 256 * 1024; // 256 KByte
+return 256 * 1024; // 256 KiB
   }
 
   llvm_unreachable("Unknown TargetTransformInfo::CacheLevel");
diff --git a/openmp/tools/archer/ompt-tsan.cpp 
b/openmp/tools/archer/ompt-tsan.cpp
index bb60fc6b603f4..c315999af4328 100644
--- a/openmp/tools/archer/ompt-tsan.cpp
+++ b/openmp/tools/archer/ompt-tsan.cpp
@@ -1224,7 +1224,7 @@ static void ompt_tsan_finalize(ompt_data_t *tool_data) {
   if (archer_flags->print_max_rss) {
 struct rusage end;
 getrusage(RUSAGE_SELF, &end);
-printf("MAX RSS[KBytes] during execution: %ld\n", end.ru_maxrss);
+printf("MAX RSS[KiB] during execution: %ld\n", end.ru_maxrss);
   }
 
   if (archer_flags)

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


[Lldb-commits] [lldb] [lldb-dap] Migrating DAP 'initialize' to new typed RequestHandler. (PR #133007)

2025-03-26 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 8f863fcd77e15caf3b7fde089adc223b0c4fb103 
7ebfa965e0210a95f3fa65e1fc373a98d350a8a8 --extensions h,cpp -- 
lldb/tools/lldb-dap/DAP.cpp lldb/tools/lldb-dap/DAP.h 
lldb/tools/lldb-dap/Handler/InitializeRequestHandler.cpp 
lldb/tools/lldb-dap/Handler/RequestHandler.cpp 
lldb/tools/lldb-dap/Handler/RequestHandler.h lldb/tools/lldb-dap/JSONUtils.cpp 
lldb/tools/lldb-dap/JSONUtils.h 
lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp 
lldb/tools/lldb-dap/Protocol/ProtocolRequests.h 
lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp 
lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
``





View the diff from clang-format here.


``diff
diff --git a/lldb/tools/lldb-dap/Handler/InitializeRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/InitializeRequestHandler.cpp
index 84753b0e10..373876ba2e 100644
--- a/lldb/tools/lldb-dap/Handler/InitializeRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/InitializeRequestHandler.cpp
@@ -251,8 +251,9 @@ llvm::Expected 
InitializeRequestHandler::Run(
 
   auto interp = dap.debugger.GetCommandInterpreter();
 
-  // The sourceInitFile option is not part of the DAP specification. It is an 
extension
-  // used by the test suite to prevent sourcing `.lldbinit` and changing its 
behavior .
+  // The sourceInitFile option is not part of the DAP specification. It is an
+  // extension used by the test suite to prevent sourcing `.lldbinit` and
+  // changing its behavior .
   if (arguments.lldbExtSourceInitFile.value_or(true)) {
 dap.debugger.SkipLLDBInitFiles(false);
 dap.debugger.SkipAppInitFiles(false);

``




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


[Lldb-commits] [lldb] [llvm] [lldb][lldb-dap] Implement jump to cursor (PR #130503)

2025-03-26 Thread Ebuka Ezike via lldb-commits

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


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

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

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


[Lldb-commits] [lldb] [lldb] Respect LaunchInfo::SetExecutable in ProcessLauncherPosixFork (PR #133093)

2025-03-26 Thread Pavel Labath via lldb-commits

labath wrote:

@yuvald-sweet-security

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


[Lldb-commits] [lldb] [lldb] Remove raw access to PluginInstances vector (PR #132884)

2025-03-26 Thread David Peixotto via lldb-commits

dmpots wrote:

> Did you consider having something like `GetEnabledInstances` that returns a 
> vector with just the enabled instances? It seems like that would be a lot 
> less intrusive and I'd be surprised if this code is hot enough that the 
> overhead of creating a new vector instead of returning a reference makes a 
> difference.

We did consider this approach. There are some drawbacks beyond the performance 
issue, but the tradeoff may be worth it.

If we define the method like: `std::vector 
GetEnabledInstances()` then we are returning copies of the PluginInstance. 
Anything that modifies the internal state of the `PluginInstance` will be lost 
since it is operating on a copy (e.g. 
`GetEnabledInstances().front().DoSomethingToModifyInternalState()`).

We could also return pointers to the plugin instances 
like`std::vector GetEnabledInstances()`. But these would be 
pointers to the locations in the vector stored in the `PluginInstance` class. 
So if a new plugin is added to the PluginInstances list the pointers could be 
invalidated. Probably not an issue with the current code, but could be unsafe 
to hand out those references in general.

I suppose another way would be to keep a 
`std::vector>` and then creating a copy would not be 
an issue since any updates would also modify the original object.

Let me know what you think.

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


[Lldb-commits] [lldb] [llvm] [lldb][lldb-dap] Implement jump to cursor (PR #130503)

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


@@ -0,0 +1,165 @@
+//===-- GoToTargetsRequestHandler.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 "DAP.h"
+
+#include "JSONUtils.h"
+
+#include 
+#include 
+#include 
+
+namespace lldb_dap {
+
+static llvm::SmallVector
+GetLineValidEntry(DAP &dap, const lldb::SBFileSpec &file_spec, uint32_t line) {
+  // disable breakpoint listeners so they do not send events to the DAP client.
+  lldb::SBListener listener = dap.debugger.GetListener();
+  lldb::SBBroadcaster broadcaster = dap.target.GetBroadcaster();
+  constexpr auto event_mask = lldb::SBTarget::eBroadcastBitBreakpointChanged;
+  listener.StopListeningForEvents(broadcaster, event_mask);

clayborg wrote:

A patch that adds the above APIs could be done in a separate patch. It can 
easily to unit tested.

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


[Lldb-commits] [lldb] [llvm] [lldb][lldb-dap] Implement jump to cursor (PR #130503)

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


@@ -0,0 +1,165 @@
+//===-- GoToTargetsRequestHandler.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 "DAP.h"
+
+#include "JSONUtils.h"
+
+#include 
+#include 
+#include 
+
+namespace lldb_dap {
+
+static llvm::SmallVector
+GetLineValidEntry(DAP &dap, const lldb::SBFileSpec &file_spec, uint32_t line) {
+  // disable breakpoint listeners so they do not send events to the DAP client.
+  lldb::SBListener listener = dap.debugger.GetListener();
+  lldb::SBBroadcaster broadcaster = dap.target.GetBroadcaster();
+  constexpr auto event_mask = lldb::SBTarget::eBroadcastBitBreakpointChanged;
+  listener.StopListeningForEvents(broadcaster, event_mask);

clayborg wrote:

This will work for code in the current source file when the source file itself 
matchs the name of a compile unit, but it won't work for inline functions. The 
line table above could easily contain entryes for "/.../stl/vector:123" where 
this is the `vector` header file from the STL. There will be no top level 
compile unit for this. 

So we really should add the new API so that it can use the same source file 
searching code that the breakpoints use.

It is easy to add things to the public API by following the API rules and 
making sure people agree on the signature and function location. Typically for 
things that want to search for things in a `lldb::SBModule`, we can add a 
`lldb::SBModule` API, but we might also want to add an API at the 
`lldb::SBTarget` so that it can search all modules so we might want the 
following APIs:

```
/// Find all locations for a file and line in this lldb::SBModule
lldb::SBSymbolContextList lldb::SBModule::ResolveContexts(lldb::SBFileSpec 
&file_spec, uint32_t line);
/// Find all locations for a file and line in all lldb::SBModule in the 
lldb::SBTarget
lldb::SBSymbolContextList lldb::SBTarget::ResolveContexts(lldb::SBFileSpec 
&file_spec, uint32_t line);
```


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


[Lldb-commits] [lldb] [llvm] [lldb][lldb-dap] Implement jump to cursor (PR #130503)

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


@@ -0,0 +1,165 @@
+//===-- GoToTargetsRequestHandler.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 "DAP.h"
+
+#include "JSONUtils.h"
+
+#include 
+#include 
+#include 
+
+namespace lldb_dap {
+
+static llvm::SmallVector
+GetLineValidEntry(DAP &dap, const lldb::SBFileSpec &file_spec, uint32_t line) {
+  // disable breakpoint listeners so they do not send events to the DAP client.
+  lldb::SBListener listener = dap.debugger.GetListener();
+  lldb::SBBroadcaster broadcaster = dap.target.GetBroadcaster();
+  constexpr auto event_mask = lldb::SBTarget::eBroadcastBitBreakpointChanged;
+  listener.StopListeningForEvents(broadcaster, event_mask);

clayborg wrote:

We might also want to add a parameter that specifies if we want to catch inline 
line entries, or just match line entries for compile units:

```
/// Find all locations for a file and line in this lldb::SBModule
lldb::SBSymbolContextList lldb::SBModule::ResolveContexts(lldb::SBFileSpec 
&file_spec, uint32_t line, bool find_inlines);
/// Find all locations for a file and line in all lldb::SBModule in the 
lldb::SBTarget
lldb::SBSymbolContextList lldb::SBTarget::ResolveContexts(lldb::SBFileSpec 
&file_spec, uint32_t line, bool find_inlines);
```

@JDevlieghere @jimingham let me know what you think of the above APIs? I think 
it would be very useful to expose the breakpoint location search features as an 
API. 

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


[Lldb-commits] [lldb] draft: [lldb] Upgrade ValueObject::GetData to return llvm::Expected (PR #130516)

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

https://github.com/wizardengineer updated 
https://github.com/llvm/llvm-project/pull/130516

>From 161bdb32b284d2370b138e72a8a1ad560b258ba9 Mon Sep 17 00:00:00 2001
From: medievalghoul <61852278+medievalgh...@users.noreply.github.com>
Date: Sun, 9 Mar 2025 16:20:47 -0400
Subject: [PATCH 01/18] Change ValueObject::GetData to return llvm::Expected

---
 lldb/include/lldb/ValueObject/ValueObject.h   |  2 +-
 .../AppleObjCRuntime/AppleObjCRuntime.cpp |  5 ++--
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 12 
 lldb/source/ValueObject/ValueObject.cpp   | 28 +--
 4 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/lldb/include/lldb/ValueObject/ValueObject.h 
b/lldb/include/lldb/ValueObject/ValueObject.h
index 06d2589002ed0..2ee7f99718416 100644
--- a/lldb/include/lldb/ValueObject/ValueObject.h
+++ b/lldb/include/lldb/ValueObject/ValueObject.h
@@ -757,7 +757,7 @@ class ValueObject {
   virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
 uint32_t item_count = 1);
 
-  virtual uint64_t GetData(DataExtractor &data, Status &error);
+  virtual llvm::Expected GetData();
 
   virtual bool SetData(DataExtractor &data, Status &error);
 
diff --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
index ad60290382c02..69856d4592843 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -551,9 +551,8 @@ ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException(
 
 DataExtractor data;
 data.SetAddressByteSize(dict_entry->GetProcessSP()->GetAddressByteSize());
-Status error;
-dict_entry->GetData(data, error);
-if (error.Fail()) return ThreadSP();
+auto data_or_err = dict_entry->GetData();
+if (!data_or_err) return ThreadSP();
 
 lldb::offset_t data_offset = 0;
 auto dict_entry_key = data.GetAddress(&data_offset);
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 4ca4752310868..763a80faa914a 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -247,13 +247,15 @@ static lldb::addr_t GetVTableAddress(Process &process,
   // We have an object already read from process memory,
   // so just extract VTable pointer from it
 
-  DataExtractor data;
-  Status err;
-  auto size = valobj.GetData(data, err);
-  if (err.Fail() || vbtable_ptr_offset + data.GetAddressByteSize() > size)
+  auto data_or_err = valobj.GetData();
+  if (!data_or_err)
+return LLDB_INVALID_ADDRESS;
+
+  auto size = data_or_err->GetByteSize();
+  if (vbtable_ptr_offset + data_or_err->GetAddressByteSize() > size)
 return LLDB_INVALID_ADDRESS;
 
-  return data.GetAddress(&vbtable_ptr_offset);
+  return data_or_err->GetAddress(&vbtable_ptr_offset);
 }
 
 static int64_t ReadVBaseOffsetFromVTable(Process &process,
diff --git a/lldb/source/ValueObject/ValueObject.cpp 
b/lldb/source/ValueObject/ValueObject.cpp
index eac24353de90b..05cbc5489d25e 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -691,13 +691,20 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, 
uint32_t item_idx,
   ValueObjectSP pointee_sp = Dereference(error);
   if (error.Fail() || pointee_sp.get() == nullptr)
 return 0;
-  return pointee_sp->GetData(data, error);
+  auto data_or_err = pointee_sp->GetData();
+  if (!data_or_err)
+return 0;
+  data = *data_or_err;
+  return data.GetByteSize();
 } else {
   ValueObjectSP child_sp = GetChildAtIndex(0);
   if (child_sp.get() == nullptr)
 return 0;
-  Status error;
-  return child_sp->GetData(data, error);
+  auto data_or_err = child_sp->GetData();
+  if (!data_or_err)
+return 0;
+  data = *data_or_err;
+  return data.GetByteSize();
 }
 return true;
   } else /* (items > 1) */
@@ -764,22 +771,27 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, 
uint32_t item_idx,
   return 0;
 }
 
-uint64_t ValueObject::GetData(DataExtractor &data, Status &error) {
+llvm::Expected ValueObject::GetData() {
   UpdateValueIfNeeded(false);
   ExecutionContext exe_ctx(GetExecutionContextRef());
-  error = m_value.GetValueAsData(&exe_ctx, data, GetModule().get());
+  DataExtractor data;
+  Status error = m_value.GetValueAsData(&exe_ctx, data, GetModule().get());
   if (error.Fail()) {
 if (m_data.GetByteSize()) {
   data = m_data;
   error.Clear();
-  return data.GetByteSize();
+  data.SetAddressByteSize(m_data.GetAddressByteSize());
+  data.SetByteOrder(m_data.GetByteOrder());
+  return data;
 } else {
-  return 0;
+  re

[Lldb-commits] [lldb] draft: [lldb] Upgrade ValueObject::GetData to return llvm::Expected (PR #130516)

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

https://github.com/wizardengineer updated 
https://github.com/llvm/llvm-project/pull/130516

>From 161bdb32b284d2370b138e72a8a1ad560b258ba9 Mon Sep 17 00:00:00 2001
From: medievalghoul <61852278+medievalgh...@users.noreply.github.com>
Date: Sun, 9 Mar 2025 16:20:47 -0400
Subject: [PATCH 01/19] Change ValueObject::GetData to return llvm::Expected

---
 lldb/include/lldb/ValueObject/ValueObject.h   |  2 +-
 .../AppleObjCRuntime/AppleObjCRuntime.cpp |  5 ++--
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 12 
 lldb/source/ValueObject/ValueObject.cpp   | 28 +--
 4 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/lldb/include/lldb/ValueObject/ValueObject.h 
b/lldb/include/lldb/ValueObject/ValueObject.h
index 06d2589002ed0..2ee7f99718416 100644
--- a/lldb/include/lldb/ValueObject/ValueObject.h
+++ b/lldb/include/lldb/ValueObject/ValueObject.h
@@ -757,7 +757,7 @@ class ValueObject {
   virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
 uint32_t item_count = 1);
 
-  virtual uint64_t GetData(DataExtractor &data, Status &error);
+  virtual llvm::Expected GetData();
 
   virtual bool SetData(DataExtractor &data, Status &error);
 
diff --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
index ad60290382c02..69856d4592843 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -551,9 +551,8 @@ ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException(
 
 DataExtractor data;
 data.SetAddressByteSize(dict_entry->GetProcessSP()->GetAddressByteSize());
-Status error;
-dict_entry->GetData(data, error);
-if (error.Fail()) return ThreadSP();
+auto data_or_err = dict_entry->GetData();
+if (!data_or_err) return ThreadSP();
 
 lldb::offset_t data_offset = 0;
 auto dict_entry_key = data.GetAddress(&data_offset);
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 4ca4752310868..763a80faa914a 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -247,13 +247,15 @@ static lldb::addr_t GetVTableAddress(Process &process,
   // We have an object already read from process memory,
   // so just extract VTable pointer from it
 
-  DataExtractor data;
-  Status err;
-  auto size = valobj.GetData(data, err);
-  if (err.Fail() || vbtable_ptr_offset + data.GetAddressByteSize() > size)
+  auto data_or_err = valobj.GetData();
+  if (!data_or_err)
+return LLDB_INVALID_ADDRESS;
+
+  auto size = data_or_err->GetByteSize();
+  if (vbtable_ptr_offset + data_or_err->GetAddressByteSize() > size)
 return LLDB_INVALID_ADDRESS;
 
-  return data.GetAddress(&vbtable_ptr_offset);
+  return data_or_err->GetAddress(&vbtable_ptr_offset);
 }
 
 static int64_t ReadVBaseOffsetFromVTable(Process &process,
diff --git a/lldb/source/ValueObject/ValueObject.cpp 
b/lldb/source/ValueObject/ValueObject.cpp
index eac24353de90b..05cbc5489d25e 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -691,13 +691,20 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, 
uint32_t item_idx,
   ValueObjectSP pointee_sp = Dereference(error);
   if (error.Fail() || pointee_sp.get() == nullptr)
 return 0;
-  return pointee_sp->GetData(data, error);
+  auto data_or_err = pointee_sp->GetData();
+  if (!data_or_err)
+return 0;
+  data = *data_or_err;
+  return data.GetByteSize();
 } else {
   ValueObjectSP child_sp = GetChildAtIndex(0);
   if (child_sp.get() == nullptr)
 return 0;
-  Status error;
-  return child_sp->GetData(data, error);
+  auto data_or_err = child_sp->GetData();
+  if (!data_or_err)
+return 0;
+  data = *data_or_err;
+  return data.GetByteSize();
 }
 return true;
   } else /* (items > 1) */
@@ -764,22 +771,27 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, 
uint32_t item_idx,
   return 0;
 }
 
-uint64_t ValueObject::GetData(DataExtractor &data, Status &error) {
+llvm::Expected ValueObject::GetData() {
   UpdateValueIfNeeded(false);
   ExecutionContext exe_ctx(GetExecutionContextRef());
-  error = m_value.GetValueAsData(&exe_ctx, data, GetModule().get());
+  DataExtractor data;
+  Status error = m_value.GetValueAsData(&exe_ctx, data, GetModule().get());
   if (error.Fail()) {
 if (m_data.GetByteSize()) {
   data = m_data;
   error.Clear();
-  return data.GetByteSize();
+  data.SetAddressByteSize(m_data.GetAddressByteSize());
+  data.SetByteOrder(m_data.GetByteOrder());
+  return data;
 } else {
-  return 0;
+  re

[Lldb-commits] [lldb] [LLDB] Add DIL code for handling plain variable names. (PR #120971)

2025-03-26 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,104 @@
+//===-- DILParser.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_VALUEOBJECT_DILPARSER_H
+#define LLDB_VALUEOBJECT_DILPARSER_H
+
+#include "lldb/Target/ExecutionContextScope.h"
+#include "lldb/Utility/Status.h"
+#include "lldb/ValueObject/DILAST.h"
+#include "lldb/ValueObject/DILLexer.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace lldb_private::dil {
+
+enum class ErrorCode : unsigned char {
+  kOk = 0,
+  kInvalidExpressionSyntax,
+  kUndeclaredIdentifier,
+  kUnknown,
+};
+
+std::string FormatDiagnostics(llvm::StringRef input_expr,
+  const std::string &message, uint32_t loc,
+  uint16_t err_len);
+
+/// Pure recursive descent parser for C++ like expressions.
+/// EBNF grammar for the parser is described in lldb/docs/dil-expr-lang.ebnf
+class DILParser {
+public:
+  static llvm::Expected Parse(llvm::StringRef dil_input_expr,
+ DILLexer lexer,
+ std::shared_ptr frame_sp,
+ lldb::DynamicValueType use_dynamic,
+ bool use_synthetic, bool fragile_ivar,
+ bool check_ptr_vs_member);
+
+  ~DILParser() = default;
+
+  bool UseSynthetic() { return m_use_synthetic; }
+
+  lldb::DynamicValueType UseDynamic() { return m_use_dynamic; }
+
+  using PtrOperator = std::tuple;
+
+private:
+  explicit DILParser(llvm::StringRef dil_input_expr, DILLexer lexer,
+ std::shared_ptr frame_sp,
+ lldb::DynamicValueType use_dynamic, bool use_synthetic,
+ bool fragile_ivar, bool check_ptr_vs_member,
+ Status &error);
+
+  llvm::Expected Run();
+
+  ASTNodeUP ParseExpression();
+  ASTNodeUP ParsePrimaryExpression();
+
+  std::string ParseNestedNameSpecifier();
+
+  std::string ParseIdExpression();
+  std::string ParseUnqualifiedId();
+
+  void BailOut(ErrorCode error_code, const std::string &error, uint32_t loc);
+
+  void BailOut(Status error);
+
+  void Expect(Token::Kind kind);
+
+  void TentativeParsingRollback(uint32_t saved_idx) {
+m_error.Clear();
+m_dil_lexer.ResetTokenIdx(saved_idx);
+  }
+
+  Token CurToken() { return m_dil_lexer.GetCurrentToken(); }
+
+  // Parser doesn't own the evaluation context. The produced AST may depend on
+  // it (for example, for source locations), so it's expected that expression
+  // context will outlive the parser.
+  std::shared_ptr m_ctx_scope;
+
+  llvm::StringRef m_input_expr;
+
+  DILLexer m_dil_lexer;
+
+  // Holds an error if it occures during parsing.
+  Status &m_error;

labath wrote:

such as this

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


[Lldb-commits] [lldb] [LLDB] Add DIL code for handling plain variable names. (PR #120971)

2025-03-26 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,238 @@
+//===-- DILEval.cpp 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/ValueObject/DILEval.h"
+#include "lldb/Symbol/VariableList.h"
+#include "lldb/Target/RegisterContext.h"
+#include "lldb/ValueObject/DILAST.h"
+#include "lldb/ValueObject/ValueObject.h"
+#include "lldb/ValueObject/ValueObjectRegister.h"
+#include "lldb/ValueObject/ValueObjectVariable.h"
+#include "llvm/Support/FormatAdapters.h"
+#include 
+
+namespace lldb_private::dil {
+
+static lldb::ValueObjectSP LookupStaticIdentifier(
+VariableList &variable_list, std::shared_ptr exe_scope,
+llvm::StringRef name_ref, llvm::StringRef unqualified_name) {
+  // First look for an exact match to the (possibly) qualified name.
+  for (const lldb::VariableSP &var_sp : variable_list) {
+lldb::ValueObjectSP valobj_sp(
+ValueObjectVariable::Create(exe_scope.get(), var_sp));
+if (valobj_sp && valobj_sp->GetVariable() &&
+(valobj_sp->GetVariable()->NameMatches(ConstString(name_ref
+  return valobj_sp;
+  }
+
+  // If the qualified name is the same as the unqualfied name, there's nothing
+  // more to be done.
+  if (name_ref == unqualified_name)
+return nullptr;
+
+  // We didn't match the qualified name; try to match the unqualified name.
+  for (const lldb::VariableSP &var_sp : variable_list) {
+lldb::ValueObjectSP valobj_sp(
+ValueObjectVariable::Create(exe_scope.get(), var_sp));
+if (valobj_sp && valobj_sp->GetVariable() &&
+(valobj_sp->GetVariable()->NameMatches(ConstString(unqualified_name
+  return valobj_sp;
+  }
+
+  return nullptr;
+}
+
+static lldb::VariableSP DILFindVariable(ConstString name,
+lldb::VariableListSP variable_list) {
+  lldb::VariableSP exact_match;
+  std::vector possible_matches;
+
+  for (lldb::VariableSP var_sp : *variable_list) {
+llvm::StringRef str_ref_name = var_sp->GetName().GetStringRef();
+// Check for global vars, which might start with '::'.
+str_ref_name.consume_front("::");
+
+if (str_ref_name == name.GetStringRef())
+  possible_matches.push_back(var_sp);
+else if (var_sp->NameMatches(name))
+  possible_matches.push_back(var_sp);
+  }
+
+  // Look for exact matches (favors local vars over global vars)
+  auto exact_match_it =
+  llvm::find_if(possible_matches, [&](lldb::VariableSP var_sp) {
+return var_sp->GetName() == name;
+  });
+
+  if (exact_match_it != possible_matches.end())
+return *exact_match_it;
+
+  // Look for a global var exact match.
+  for (auto var_sp : possible_matches) {
+llvm::StringRef str_ref_name = var_sp->GetName().GetStringRef();
+str_ref_name.consume_front("::");
+if (str_ref_name == name.GetStringRef())
+  return var_sp;
+  }
+
+  // If there's a single non-exact match, take it.
+  if (possible_matches.size() == 1)
+return possible_matches[0];
+
+  return nullptr;
+}
+
+lldb::ValueObjectSP LookupGlobalIdentifier(
+llvm::StringRef name_ref, std::shared_ptr stack_frame,
+lldb::TargetSP target_sp, lldb::DynamicValueType use_dynamic,
+CompilerType *scope_ptr) {
+  // First look for match in "local" global variables.
+  lldb::VariableListSP 
variable_list(stack_frame->GetInScopeVariableList(true));
+  name_ref.consume_front("::");
+
+  lldb::ValueObjectSP value_sp;
+  if (variable_list) {
+lldb::VariableSP var_sp =
+DILFindVariable(ConstString(name_ref), variable_list);
+if (var_sp)
+  value_sp =
+  stack_frame->GetValueObjectForFrameVariable(var_sp, use_dynamic);
+  }
+
+  if (value_sp)
+return value_sp;
+
+  // Also check for static global vars.
+  if (variable_list) {
+const char *type_name = "";
+if (scope_ptr)
+  type_name = scope_ptr->GetCanonicalType().GetTypeName().AsCString();
+std::string name_with_type_prefix =
+llvm::formatv("{0}::{1}", type_name, name_ref).str();
+value_sp = LookupStaticIdentifier(*variable_list, stack_frame,
+  name_with_type_prefix, name_ref);
+if (!value_sp)
+  value_sp = LookupStaticIdentifier(*variable_list, stack_frame, name_ref,
+name_ref);
+  }
+
+  if (value_sp)
+return value_sp;
+
+  // Check for match in modules global variables.
+  VariableList modules_var_list;
+  target_sp->GetImages().FindGlobalVariables(
+  ConstString(name_ref), std::numeric_limits::max(),
+  modules_var_list);
+  if (modules_var_list.Empty())
+return nullptr;
+
+  for (const lldb::VariableSP &var_sp : modules_var_list) {
+std::string qualified_name = llvm::formatv("::{0}", name

[Lldb-commits] [lldb] [lldb] Teach FuncUnwinders about discontinuous functions (PR #133072)

2025-03-26 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

The main change here is that we're now able to correctly look up plans for 
these functions. Previously, due to caching, we could end up with one entry 
covering most of the address space (because part of the function was at the 
beginning and one at the end). Now, we can correctly recognise that the part in 
between does not belong to that function, and we can create a different 
FuncUnwinders instance for it. It doesn't help the discontinuous function much 
(it's plan will still be garbled), but we can at least properly unwind out of 
the simple functions in between.

Fixing the unwind plans for discontinuous functions requires handling each 
unwind source specially, and this setup allows us to make the transition 
incrementally.

---

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


8 Files Affected:

- (modified) lldb/include/lldb/Symbol/FuncUnwinders.h (+16-4) 
- (modified) lldb/include/lldb/Symbol/UnwindTable.h (+1-2) 
- (modified) lldb/source/Symbol/FuncUnwinders.cpp (+24-12) 
- (modified) lldb/source/Symbol/UnwindTable.cpp (+24-19) 
- (added) lldb/test/Shell/Unwind/Inputs/basic-block-sections-with-dwarf.s 
(+256) 
- (added) lldb/test/Shell/Unwind/Inputs/linux-x86_64.yaml (+26) 
- (added) lldb/test/Shell/Unwind/basic-block-sections-with-dwarf-static.test 
(+39) 
- (added) lldb/test/Shell/Unwind/basic-block-sections-with-dwarf.test (+23) 


``diff
diff --git a/lldb/include/lldb/Symbol/FuncUnwinders.h 
b/lldb/include/lldb/Symbol/FuncUnwinders.h
index 2e841b3b34bd6..1d4c28324e90f 100644
--- a/lldb/include/lldb/Symbol/FuncUnwinders.h
+++ b/lldb/include/lldb/Symbol/FuncUnwinders.h
@@ -13,9 +13,9 @@ class UnwindTable;
 class FuncUnwinders {
 public:
   // FuncUnwinders objects are used to track UnwindPlans for a function (named
-  // or not - really just an address range)
+  // or not - really just a set of address ranges)
 
-  // We'll record four different UnwindPlans for each address range:
+  // We'll record four different UnwindPlans for each function:
   //
   //   1. Unwinding from a call site (a valid exception throw location)
   //  This is often sourced from the eh_frame exception handling info
@@ -31,7 +31,8 @@ class FuncUnwinders {
   // instructions are finished for migrating breakpoints past the stack frame
   // setup instructions when we don't have line table information.
 
-  FuncUnwinders(lldb_private::UnwindTable &unwind_table, AddressRange range);
+  FuncUnwinders(lldb_private::UnwindTable &unwind_table, Address addr,
+AddressRanges ranges);
 
   ~FuncUnwinders();
 
@@ -54,7 +55,9 @@ class FuncUnwinders {
   const Address &GetFunctionStartAddress() const;
 
   bool ContainsAddress(const Address &addr) const {
-return m_range.ContainsFileAddress(addr);
+return llvm::any_of(m_ranges, [&](const AddressRange range) {
+  return range.ContainsFileAddress(addr);
+});
   }
 
   // A function may have a Language Specific Data Area specified -- a block of
@@ -113,6 +116,15 @@ class FuncUnwinders {
   Thread &thread, const lldb::UnwindPlanSP &a, const lldb::UnwindPlanSP 
&b);
 
   UnwindTable &m_unwind_table;
+
+  /// Start address of the function described by this object.
+  Address m_addr;
+
+  /// The address ranges of the function.
+  AddressRanges m_ranges;
+
+  /// The smallest address range covering the entire function.
+  /// DEPRECATED: Use m_ranges instead.
   AddressRange m_range;
 
   std::recursive_mutex m_mutex;
diff --git a/lldb/include/lldb/Symbol/UnwindTable.h 
b/lldb/include/lldb/Symbol/UnwindTable.h
index 3166fdec6ebaa..1cc718efb28d6 100644
--- a/lldb/include/lldb/Symbol/UnwindTable.h
+++ b/lldb/include/lldb/Symbol/UnwindTable.h
@@ -66,8 +66,7 @@ class UnwindTable {
   void Dump(Stream &s);
 
   void Initialize();
-  std::optional GetAddressRange(const Address &addr,
-  const SymbolContext &sc);
+  AddressRanges GetAddressRanges(const Address &addr, const SymbolContext &sc);
 
   typedef std::map collection;
   typedef collection::iterator iterator;
diff --git a/lldb/source/Symbol/FuncUnwinders.cpp 
b/lldb/source/Symbol/FuncUnwinders.cpp
index 2449c82812696..a5ca7b094c949 100644
--- a/lldb/source/Symbol/FuncUnwinders.cpp
+++ b/lldb/source/Symbol/FuncUnwinders.cpp
@@ -31,15 +31,29 @@
 using namespace lldb;
 using namespace lldb_private;
 
-/// constructor
-
-FuncUnwinders::FuncUnwinders(UnwindTable &unwind_table, AddressRange range)
-: m_unwind_table(unwind_table), m_range(range), m_mutex(),
-  m_unwind_plan_assembly_sp(), m_unwind_plan_eh_frame_sp(),
-  m_unwind_plan_eh_frame_augmented_sp(), m_unwind_plan_compact_unwind(),
-  m_unwind_plan_arm_unwind_sp(), m_unwind_plan_fast_sp(),
-  m_unwind_plan_arch_default_sp(),
-  m_unwind_plan_arch_default_at_func_entry_sp(),
+static AddressRange CollapseRanges(llvm::

[Lldb-commits] [lldb] [lldb] Teach FuncUnwinders about discontinuous functions (PR #133072)

2025-03-26 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 1a7402d3d831940fc04cc0fb5731239744ce5435 
b68ee05934778f77bf27f8b6716e1db564bd4f98 --extensions cpp,h -- 
lldb/include/lldb/Symbol/FuncUnwinders.h lldb/include/lldb/Symbol/UnwindTable.h 
lldb/source/Symbol/FuncUnwinders.cpp lldb/source/Symbol/UnwindTable.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Symbol/UnwindTable.cpp 
b/lldb/source/Symbol/UnwindTable.cpp
index e62ea7b571..21ecd434d7 100644
--- a/lldb/source/Symbol/UnwindTable.cpp
+++ b/lldb/source/Symbol/UnwindTable.cpp
@@ -150,7 +150,7 @@ UnwindTable::GetFuncUnwindersContainingAddress(const 
Address &addr,
 return nullptr;
 
   auto func_unwinder_sp = std::make_shared(*this, addr, ranges);
-  for (const AddressRange &range: ranges)
+  for (const AddressRange &range : ranges)
 m_unwinds.emplace_hint(insert_pos, range.GetBaseAddress().GetFileAddress(),
func_unwinder_sp);
   return func_unwinder_sp;

``




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


[Lldb-commits] [lldb] [lldb] Teach FuncUnwinders about discontinuous functions (PR #133072)

2025-03-26 Thread Pavel Labath via lldb-commits

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

>From 3bc6ae141f31a1e09e45c648464e3804a7734a2c Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Wed, 26 Mar 2025 12:46:28 +0100
Subject: [PATCH] [lldb] Teach FuncUnwinders about discontinuous functions

The main change here is that we're now able to correctly look up plans
for these functions. Previously, due to caching, we could end up with
one entry covering most of the address space (because part of the
function was at the beginning and one at the end). Now, we can correctly
recognise that the part in between does not belong to that function, and
we can create a different FuncUnwinders instance for it. It doesn't
help the discontinuous function much (it's plan will still be garbled),
but we can at least properly unwind out of the simple functions in
between.

Fixing the unwind plans for discontinuous functions requires handling
each unwind source specially, and this setup allows us to make the
transition incrementally.
---
 lldb/include/lldb/Symbol/FuncUnwinders.h  |  20 +-
 lldb/include/lldb/Symbol/UnwindTable.h|   3 +-
 lldb/source/Symbol/FuncUnwinders.cpp  |  36 ++-
 lldb/source/Symbol/UnwindTable.cpp|  43 +--
 .../Inputs/basic-block-sections-with-dwarf.s  | 256 ++
 .../Shell/Unwind/Inputs/linux-x86_64.yaml |  26 ++
 ...asic-block-sections-with-dwarf-static.test |  39 +++
 .../basic-block-sections-with-dwarf.test  |  23 ++
 8 files changed, 409 insertions(+), 37 deletions(-)
 create mode 100644 
lldb/test/Shell/Unwind/Inputs/basic-block-sections-with-dwarf.s
 create mode 100644 lldb/test/Shell/Unwind/Inputs/linux-x86_64.yaml
 create mode 100644 
lldb/test/Shell/Unwind/basic-block-sections-with-dwarf-static.test
 create mode 100644 lldb/test/Shell/Unwind/basic-block-sections-with-dwarf.test

diff --git a/lldb/include/lldb/Symbol/FuncUnwinders.h 
b/lldb/include/lldb/Symbol/FuncUnwinders.h
index 2e841b3b34bd6..1d4c28324e90f 100644
--- a/lldb/include/lldb/Symbol/FuncUnwinders.h
+++ b/lldb/include/lldb/Symbol/FuncUnwinders.h
@@ -13,9 +13,9 @@ class UnwindTable;
 class FuncUnwinders {
 public:
   // FuncUnwinders objects are used to track UnwindPlans for a function (named
-  // or not - really just an address range)
+  // or not - really just a set of address ranges)
 
-  // We'll record four different UnwindPlans for each address range:
+  // We'll record four different UnwindPlans for each function:
   //
   //   1. Unwinding from a call site (a valid exception throw location)
   //  This is often sourced from the eh_frame exception handling info
@@ -31,7 +31,8 @@ class FuncUnwinders {
   // instructions are finished for migrating breakpoints past the stack frame
   // setup instructions when we don't have line table information.
 
-  FuncUnwinders(lldb_private::UnwindTable &unwind_table, AddressRange range);
+  FuncUnwinders(lldb_private::UnwindTable &unwind_table, Address addr,
+AddressRanges ranges);
 
   ~FuncUnwinders();
 
@@ -54,7 +55,9 @@ class FuncUnwinders {
   const Address &GetFunctionStartAddress() const;
 
   bool ContainsAddress(const Address &addr) const {
-return m_range.ContainsFileAddress(addr);
+return llvm::any_of(m_ranges, [&](const AddressRange range) {
+  return range.ContainsFileAddress(addr);
+});
   }
 
   // A function may have a Language Specific Data Area specified -- a block of
@@ -113,6 +116,15 @@ class FuncUnwinders {
   Thread &thread, const lldb::UnwindPlanSP &a, const lldb::UnwindPlanSP 
&b);
 
   UnwindTable &m_unwind_table;
+
+  /// Start address of the function described by this object.
+  Address m_addr;
+
+  /// The address ranges of the function.
+  AddressRanges m_ranges;
+
+  /// The smallest address range covering the entire function.
+  /// DEPRECATED: Use m_ranges instead.
   AddressRange m_range;
 
   std::recursive_mutex m_mutex;
diff --git a/lldb/include/lldb/Symbol/UnwindTable.h 
b/lldb/include/lldb/Symbol/UnwindTable.h
index 3166fdec6ebaa..1cc718efb28d6 100644
--- a/lldb/include/lldb/Symbol/UnwindTable.h
+++ b/lldb/include/lldb/Symbol/UnwindTable.h
@@ -66,8 +66,7 @@ class UnwindTable {
   void Dump(Stream &s);
 
   void Initialize();
-  std::optional GetAddressRange(const Address &addr,
-  const SymbolContext &sc);
+  AddressRanges GetAddressRanges(const Address &addr, const SymbolContext &sc);
 
   typedef std::map collection;
   typedef collection::iterator iterator;
diff --git a/lldb/source/Symbol/FuncUnwinders.cpp 
b/lldb/source/Symbol/FuncUnwinders.cpp
index 2449c82812696..a5ca7b094c949 100644
--- a/lldb/source/Symbol/FuncUnwinders.cpp
+++ b/lldb/source/Symbol/FuncUnwinders.cpp
@@ -31,15 +31,29 @@
 using namespace lldb;
 using namespace lldb_private;
 
-/// constructor
-
-FuncUnwinders::FuncUnwinders(UnwindTable &unwind_table, AddressRange range)
-: m_unwind_table(unwind_table), m_range(range), m_mutex(),
-  m_unwind_

[Lldb-commits] [lldb] [LLDB][NFC] Added the interface DWARFExpression::Delegate to break dependencies and reduce lldb-server size (PR #131645)

2025-03-26 Thread Pavel Labath via lldb-commits

labath wrote:

> This type of patch also slightly worries me in that it could make it harder 
> to unify the LLDB dwarf data structures with the LLVM ones

That is something I considered, but I think this might actually help with that. 
At this point the LLDB and llvm dwarf classes are so different, that the only 
way I see to unify them is to do it piecemeal, and this kind of decoupling 
helps with that. So, if you wanted to replace LLDB DWARFUnit with llvm's, you 
could do that without touching DWARFExpression. It's true lldb's DWARFUnit now 
inherits from some DWARFExpression thingy, but that's easy to replace with 
composition. I alluded to that in the earlier comments, but in the end I didn't 
insist on it. Maybe I should have. If you think it's better to do that now, I'd 
be certainly fine with that.

This doesn't help with replacing LLDB's DWARFExpression with the llvm version, 
but I don't think it makes it worse either. I see a couple of possible ways 
forwards there:
- introduce a similar abstraction to llvm DWARFExpression. I think that would 
make sense since dwarf expressions are used in contexts (eh_frame) where there 
is no DWARFUnit to speak of.
- replace (non-unwinding) uses of DWARF Expression with a higher level 
abstraction. It's use in Function and Variable classes is breaking 
abstractions, and the PDB plugin has to jump through hoops to create DWARF 
expressions for these objects. That would leave DWARFExpression only used for 
unwinding in the core code, where it would be easier to replace this with 
llvm::DWARFExpression (and at that point, it may not matter that it depends on 
llvm::DWARFUnit, since this class -- unlike the lldb counterpart -- does not 
depend on the whole world)

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


[Lldb-commits] [lldb] [LLDB] Add DIL code for handling plain variable names. (PR #120971)

2025-03-26 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,273 @@
+//===-- DILParser.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
+//
+// This implements the recursive descent parser for the Data Inspection
+// Language (DIL), and its helper functions, which will eventually underlie the
+// 'frame variable' command. The language that this parser recognizes is
+// described in lldb/docs/dil-expr-lang.ebnf
+//
+//===--===//
+
+#include "lldb/ValueObject/DILParser.h"
+#include "lldb/Target/ExecutionContextScope.h"
+#include "lldb/Utility/DiagnosticsRendering.h"
+#include "lldb/ValueObject/DILAST.h"
+#include "lldb/ValueObject/DILEval.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FormatAdapters.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace lldb_private::dil {
+
+std::string FormatDiagnostics(llvm::StringRef text, const std::string &message,
+  uint32_t loc, uint16_t err_len) {
+  DiagnosticDetail::SourceLocation sloc = {
+  FileSpec{}, /*line=*/1, static_cast(loc + 1),
+  err_len,false,  /*in_user_input=*/true};
+  std::string arrow_str = "^";
+  std::string rendered_msg =
+  llvm::formatv(":1:{0}: {1}\n1 | {2}\n | ^",
+loc + 1, message, text);
+  DiagnosticDetail detail;
+  detail.source_location = sloc;
+  detail.severity = lldb::eSeverityError;
+  detail.message = message;
+  detail.rendered = rendered_msg;
+  std::vector diagnostics;
+  diagnostics.push_back(detail);
+  StreamString diag_stream(true);
+  RenderDiagnosticDetails(diag_stream, 7, true, diagnostics);
+  std::string ret_str = text.str() + "\n" + diag_stream.GetString().str();
+  return ret_str;
+}
+
+llvm::Expected
+DILParser::Parse(llvm::StringRef dil_input_expr, DILLexer lexer,
+ std::shared_ptr frame_sp,
+ lldb::DynamicValueType use_dynamic, bool use_synthetic,
+ bool fragile_ivar, bool check_ptr_vs_member) {
+  Status error;
+  DILParser parser(dil_input_expr, lexer, frame_sp, use_dynamic, use_synthetic,
+   fragile_ivar, check_ptr_vs_member, error);
+  return parser.Run();

labath wrote:

and this

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


[Lldb-commits] [lldb] [LLDB] Add DIL code for handling plain variable names. (PR #120971)

2025-03-26 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,276 @@
+//===-- DILParser.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
+//
+// This implements the recursive descent parser for the Data Inspection
+// Language (DIL), and its helper functions, which will eventually underlie the
+// 'frame variable' command. The language that this parser recognizes is
+// described in lldb/docs/dil-expr-lang.ebnf
+//
+//===--===//
+
+#include "lldb/ValueObject/DILParser.h"
+#include "lldb/Target/ExecutionContextScope.h"
+#include "lldb/Utility/DiagnosticsRendering.h"
+#include "lldb/ValueObject/DILAST.h"
+#include "lldb/ValueObject/DILEval.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FormatAdapters.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace lldb_private::dil {
+
+DILDiagnosticError::DILDiagnosticError(ErrorCode ec, llvm::StringRef expr,
+   const std::string &message, uint32_t 
loc,
+   uint16_t err_len)
+: // ErrorInfo(ec) {
+  ErrorInfo(std::error_code(EINVAL, std::generic_category())) {
+  DiagnosticDetail::SourceLocation sloc = {
+  FileSpec{}, /*line=*/1, static_cast(loc + 1),
+  err_len,false,  /*in_user_input=*/true};
+  std::string rendered_msg =
+  llvm::formatv(":1:{0}: {1}\n1 | {2}\n | ^",
+loc + 1, message, expr);
+  DiagnosticDetail detail;
+  detail.source_location = sloc;
+  detail.severity = lldb::eSeverityError;
+  detail.message = message;
+  detail.rendered = rendered_msg;
+  m_details.push_back(detail);
+}
+
+llvm::Expected
+DILParser::Parse(llvm::StringRef dil_input_expr, DILLexer lexer,
+ std::shared_ptr frame_sp,
+ lldb::DynamicValueType use_dynamic, bool use_synthetic,
+ bool fragile_ivar, bool check_ptr_vs_member) {
+  Status error;
+  DILParser parser(dil_input_expr, lexer, frame_sp, use_dynamic, use_synthetic,
+   fragile_ivar, check_ptr_vs_member, error);
+  return parser.Run();
+}
+
+DILParser::DILParser(llvm::StringRef dil_input_expr, DILLexer lexer,
+ std::shared_ptr frame_sp,
+ lldb::DynamicValueType use_dynamic, bool use_synthetic,
+ bool fragile_ivar, bool check_ptr_vs_member, Status 
&error)
+: m_ctx_scope(frame_sp), m_input_expr(dil_input_expr), m_dil_lexer(lexer),
+  m_error(error), m_use_dynamic(use_dynamic),
+  m_use_synthetic(use_synthetic), m_fragile_ivar(fragile_ivar),
+  m_check_ptr_vs_member(check_ptr_vs_member) {}
+
+llvm::Expected DILParser::Run() {
+  ASTNodeUP expr = ParseExpression();
+
+  Expect(Token::Kind::eof);
+
+  if (m_error.Fail())
+return m_error.ToError();
+
+  return expr;
+}
+
+// Parse an expression.
+//
+//  expression:
+//primary_expression
+//
+ASTNodeUP DILParser::ParseExpression() { return ParsePrimaryExpression(); }
+
+// Parse a primary_expression.
+//
+//  primary_expression:
+//id_expression
+//"(" expression ")"
+//
+ASTNodeUP DILParser::ParsePrimaryExpression() {
+  if (CurToken().IsOneOf({Token::coloncolon, Token::identifier})) {
+// Save the source location for the diagnostics message.
+uint32_t loc = CurToken().GetLocation();
+auto identifier = ParseIdExpression();
+
+return std::make_unique(loc, identifier, m_use_dynamic,
+m_ctx_scope);
+  } else if (CurToken().Is(Token::l_paren)) {
+m_dil_lexer.Advance();
+auto expr = ParseExpression();
+Expect(Token::r_paren);
+m_dil_lexer.Advance();
+return expr;
+  }
+
+  BailOut(ErrorCode::kInvalidExpressionSyntax,
+  llvm::formatv("Unexpected token: {0}", CurToken()),
+  CurToken().GetLocation());
+  return std::make_unique();
+}
+
+// Parse nested_name_specifier.
+//
+//  nested_name_specifier:
+//type_name "::"
+//namespace_name "::"
+//nested_name_specifier identifier "::"
+//
+std::string DILParser::ParseNestedNameSpecifier() {
+  // The first token in nested_name_specifier is always an identifier, or
+  // '(anonymous namespace)'.
+  if (CurToken().IsNot(Token::identifier) && CurToken().IsNot(Token::l_paren)) 
{
+return "";
+  }
+
+  // Anonymous namespaces need to be treated specially: They are represented
+  // the the string '(anonymous namespace)', which has a space in it (throwing
+  // off normal parsing) and is not actually proper C++> Check to see if we're
+  // looking at '(anonymous namespace)::...'
+  if (CurToken().Is(Token::l_paren)) {
+// Look for all the pieces, in order:
+// l_paren 'anonymous' 'namespace' r_paren coloncolon
+if (m_dil_lexer.LookAhead(1).Is(Token::identifier) 

[Lldb-commits] [lldb] [LLDB] Add DIL code for handling plain variable names. (PR #120971)

2025-03-26 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Add DIL code for handling plain variable names. (PR #120971)

2025-03-26 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,131 @@
+//===-- DILParser.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_VALUEOBJECT_DILPARSER_H
+#define LLDB_VALUEOBJECT_DILPARSER_H
+
+#include "lldb/Target/ExecutionContextScope.h"
+#include "lldb/Utility/DiagnosticsRendering.h"
+#include "lldb/Utility/Status.h"
+#include "lldb/ValueObject/DILAST.h"
+#include "lldb/ValueObject/DILLexer.h"
+#include "llvm/Support/Error.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace lldb_private::dil {
+
+enum class ErrorCode : unsigned char {
+  kOk = 0,
+  kInvalidExpressionSyntax,
+  kUndeclaredIdentifier,
+  kUnknown,
+};
+
+// The following is modeled on class OptionParseError.
+class DILDiagnosticError
+: public llvm::ErrorInfo {
+  std::vector m_details;
+
+public:
+  using llvm::ErrorInfo::ErrorInfo;
+  DILDiagnosticError(DiagnosticDetail detail)
+  : ErrorInfo(std::error_code(EINVAL, std::generic_category())),
+m_details({detail}) {}
+
+  DILDiagnosticError(ErrorCode ec, llvm::StringRef expr,

labath wrote:

Do you plan to use the error code for something? If yes, it should be stored 
somewhere. Otherwise -- delete it?

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


[Lldb-commits] [lldb] [LLDB] Add DIL code for handling plain variable names. (PR #120971)

2025-03-26 Thread Pavel Labath via lldb-commits

https://github.com/labath commented:

> * Based on the way DiagnosticError is use, I've created a new error 
> class, DILDiagnosticError, patterned after the OptionParserError clas, which 
> DOES make use of DiagnosticError.

The class implementation looks okay for the most part.

> * I have not been able to discover any way of converting 
> DILDiagnosticError or DiagnosticDetail into an llvm::Error at all.

You construct these via `llvm::make_error`, see inline suggestions.

> * The only way I could find to convert a DILDiagnosticError into an 
> LLDB::Status, was to extract the DiagnosticDetail message and create the 
> LLDB::Status around that.

That shouldn't be necessary given that I'd like to work with llvm::Errors 
primarily (see other inline comment). At the API boundary (where this error 
goes outside of the DIL implementation, it can be converted to a Status using 
`Status::FromError`.
> 
> * We currently still have to leave the errors as LLDB::Status errors, 
> because the calls into & out of GetVariableValueForExpressionPath have no way 
> (at the moment) of handling structured errors (i.e. DiagnosticDetails or 
> DILDiagnosticErrors).  We should probably change that in the future, but I 
> would prefer to do that in a different PR.

Definitely.


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


[Lldb-commits] [lldb] [lldb] Handle improperly nested blocks differently (PR #117725)

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

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


[Lldb-commits] [lldb] [lldb] Handle improperly nested blocks differently (PR #117725)

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


@@ -0,0 +1,100 @@
+## This test checks that lldb handles (corrupt?) debug info which has 
improperly
+## nested blocks. The behavior here is not prescriptive. We only want to check
+## that we do something "reasonable".
+
+
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t
+# RUN: %lldb %t -o "image lookup -v -s look_me_up1" \
+# RUN:   -o "image lookup -v -s look_me_up2" -o exit 2>&1 | FileCheck %s
+
+# CHECK-LABEL: image lookup -v -s look_me_up1
+# CHECK: warning: {{.*}} block 0x55 has a range [0x2, 0x4) which is not 
contained in the parent block 0x44
+# CHECK:Function: id = {0x0030}, name = "fn", range = 
[0x-0x0005)
+# CHECK:  Blocks: id = {0x0030}, range = [0x-0x0005)
+# CHECK-NEXT: id = {0x0044}, range = [0x0001-0x0003)
+# CHECK-NEXT: id = {0x0055}, range = [0x0002-0x0004)
+# CHECK-NEXT: Symbol:
+
+# CHECK-LABEL: image lookup -v -s look_me_up2
+# CHECK:Function: id = {0x0030}, name = "fn", range = 
[0x-0x0005)
+# CHECK:  Blocks: id = {0x0030}, range = [0x-0x0005)
+# CHECK-NEXT: Symbol:
+
+.text
+.p2align 12
+fn:
+nop
+.Lblock1_begin:
+nop
+.Lblock2_begin:
+look_me_up1:
+nop
+.Lblock1_end:
+look_me_up2:
+nop
+.Lblock2_end:
+nop
+.Lfn_end:
+
+
+.section.debug_abbrev,"",@progbits

DavidSpickett wrote:

Add a comment that this DWARF is correctly representing the function above, but 
the function itself is the source of the problem we're handling.

Or if it is in the DWARF, the opposite comment.

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


[Lldb-commits] [lldb] [lldb] Handle improperly nested blocks differently (PR #117725)

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


@@ -0,0 +1,100 @@
+## This test checks that lldb handles (corrupt?) debug info which has 
improperly
+## nested blocks. The behavior here is not prescriptive. We only want to check

DavidSpickett wrote:

Could you add comments somewhere in this file that note where the "improper" 
bits are?

Somewhere in the block where you use the `.L` is probably best.

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


  1   2   >