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

2025-03-09 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Ebuka Ezike (da-viper)


Changes

Fixes #109335

Depends on #130435


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


13 Files Affected:

- (modified) lldb/cmake/modules/LLDBConfig.cmake (+1-1) 
- (modified) lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
(+27) 
- (added) lldb/test/API/tools/lldb-dap/gotoTarget/Makefile (+3) 
- (added) lldb/test/API/tools/lldb-dap/gotoTarget/TestDAP_gotoTarget.py (+60) 
- (added) lldb/test/API/tools/lldb-dap/gotoTarget/main.c (+11) 
- (modified) lldb/tools/lldb-dap/CMakeLists.txt (+2) 
- (modified) lldb/tools/lldb-dap/DAP.cpp (+22-1) 
- (modified) lldb/tools/lldb-dap/DAP.h (+26-1) 
- (added) lldb/tools/lldb-dap/Handler/GoToRequestHandler.cpp (+103) 
- (added) lldb/tools/lldb-dap/Handler/GoToTargetsRequestHandler.cpp (+120) 
- (modified) lldb/tools/lldb-dap/Handler/InitializeRequestHandler.cpp (+1-1) 
- (modified) lldb/tools/lldb-dap/Handler/RequestHandler.h (+14) 
- (modified) lldb/tools/lldb-dap/lldb-dap.cpp (+2) 


``diff
diff --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 747f7e6038181..8d02088548634 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/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index 9471594b66012..d6c3bd0551cd7 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -753,6 +753,33 @@ def request_exceptionInfo(self, threadId=None):
 }
 return self.send_recv(command_dict)
 
+def request_goto(self, threadId: int, targetId: int):
+command_dict = {
+"command": "goto",
+"type": "request",
+"arguments": {
+"threadId": threadId,
+"targetId": targetId,
+},
+}
+return self.send_recv(command_dict)
+
+def request_gotoTargets(self, filename: str, path: str, line: int, column: 
int):
+arguments = {
+"source": {
+"name": filename,
+"path": path,
+},
+"line": line,
+"column": column,
+}
+command_dict = {
+"command": "gotoTargets",
+"type": "request",
+"arguments": arguments,
+}
+return self.send_recv(command_dict)
+
 def request_initialize(self, sourceInitFile):
 command_dict = {
 "command": "initialize",
diff --git a/lldb/test/API/tools/lldb-dap/gotoTarget/Makefile 
b/lldb/test/API/tools/lldb-dap/gotoTarget/Makefile
new file mode 100644
index 0..10495940055b6
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/gotoTarget/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git a/lldb/test/API/tools/lldb-dap/gotoTarget/TestDAP_gotoTarget.py 
b/lldb/test/API/tools/lldb-dap/gotoTarget/TestDAP_gotoTarget.py
new file mode 100644
index 0..6d0f9ae478f33
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/gotoTarget/TestDAP_gotoTarget.py
@@ -0,0 +1,60 @@
+"""
+Test lldb-dap gotoTarget request
+"""
+
+from lldbsuite.test.lldbtest import line_number
+import lldbdap_testcase
+import os
+
+
+class TestDAP_gotoTarget(lldbdap_testcase.DAPTestCaseBase):
+
+def test_default(self):
+"""
+Tests the jump to cursor of a simple program. No arguments,
+environment, or anything else is specified.
+This does not run any statement between the current breakpoint
+and the jump line location.
+"""
+program = self.getBuildArtifact("a.out")
+self.build_and_launch(program)
+
+source_file = "main.c"
+self.source_path = os.path.join(os.getcwd(), source_file)
+self.set_source_breakpoints(
+source_file, [line_number(source_file, "// breakpoint 1")]
+)
+self.continue_to_next_stop()
+
+first_var_1_

[Lldb-commits] [lldb] 2317a72 - [lldb] Add missing converstion to optional

2025-03-09 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2025-03-09T12:04:22-07:00
New Revision: 2317a72489145f582ac1f01bc8c4f3b6bb5abb44

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

LOG: [lldb] Add missing converstion to optional

Added: 


Modified: 
lldb/source/ValueObject/ValueObjectChild.cpp

Removed: 




diff  --git a/lldb/source/ValueObject/ValueObjectChild.cpp 
b/lldb/source/ValueObject/ValueObjectChild.cpp
index ea211530591cf..d7f1ad08415e3 100644
--- a/lldb/source/ValueObject/ValueObjectChild.cpp
+++ b/lldb/source/ValueObject/ValueObjectChild.cpp
@@ -164,8 +164,9 @@ bool ValueObjectChild::UpdateValue() {
 const bool thread_and_frame_only_if_stopped = true;
 ExecutionContext exe_ctx(GetExecutionContextRef().Lock(
 thread_and_frame_only_if_stopped));
-if (auto type_bit_size = GetCompilerType().GetBitSize(
-exe_ctx.GetBestExecutionContextScope())) {
+if (auto type_bit_size =
+llvm::expectedToOptional(GetCompilerType().GetBitSize(
+exe_ctx.GetBestExecutionContextScope( {
   uint64_t bitfield_end =
   m_bitfield_bit_size + m_bitfield_bit_offset;
   if (bitfield_end > *type_bit_size) {



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


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

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

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

Fixes #109335

Depends on #130435


>From bed28f5e22dd3c8c2bb3204aa41a9a71b49b63f9 Mon Sep 17 00:00:00 2001
From: Ezike Ebuka 
Date: Sun, 9 Mar 2025 12:46:54 +
Subject: [PATCH 1/2] [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 ++
 .../Handler/InitializeRequestHandler.cpp  |   2 +-
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  14 ++
 lldb/tools/lldb-dap/lldb-dap.cpp  |   2 +
 9 files changed, 291 insertions(+), 4 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 747f7e6038181..8d02088548634 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 9a2d604f4d573..ff7e413c4bb1c 100644
--- a/lldb/tools/lldb-dap/CMakeLists.txt
+++ b/lldb/tools/lldb-dap/CMakeLists.txt
@@ -50,6 +50,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 1f7b25e7c5bcc..f72bc34d52b53 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -76,7 +76,7 @@ DAP::DAP(std::string name, llvm::StringRef path, 
std::ofstream *log,
   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(repl_mode) {}
+  reverse_request_seq(0), repl_mode(repl_mode), goto_id_map() {}
 
 DAP::~DAP() = default;
 
@@ -899,6 +899,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 8b2e498a28c95..693908016fdc9 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -79,6 +79,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);
@@ -209,6 +230,7 @@ struct DAP {
   // empty; if t

[Lldb-commits] [lldb] [lldb-dap] Adding support for well typed events. (PR #130104)

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

https://github.com/vogelsgesang edited 
https://github.com/llvm/llvm-project/pull/130104
___
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 terminated statistics to the event body. (PR #130454)

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

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


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


[Lldb-commits] [lldb] [lldb] fix set SBLineEntryColumn (PR #130435)

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

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

>From 02c34e87db59a0b87887aba479afbab70925241b Mon Sep 17 00:00:00 2001
From: Ezike Ebuka 
Date: Sat, 8 Mar 2025 19:47:17 +
Subject: [PATCH 1/2] [lldb] fix set SBLineEntryColumn

---
 lldb/source/API/SBLineEntry.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/API/SBLineEntry.cpp b/lldb/source/API/SBLineEntry.cpp
index 216ea6d18eab8..0f4936f32a074 100644
--- a/lldb/source/API/SBLineEntry.cpp
+++ b/lldb/source/API/SBLineEntry.cpp
@@ -137,7 +137,7 @@ void SBLineEntry::SetLine(uint32_t line) {
 void SBLineEntry::SetColumn(uint32_t column) {
   LLDB_INSTRUMENT_VA(this, column);
 
-  ref().line = column;
+  ref().column = column;
 }
 
 bool SBLineEntry::operator==(const SBLineEntry &rhs) const {

>From fa4a3cef8d299adfecdfe846620ed9257bbbf0b8 Mon Sep 17 00:00:00 2001
From: Ezike Ebuka 
Date: Sun, 9 Mar 2025 14:02:38 +
Subject: [PATCH 2/2] [lldb] add unittest for SBLineEntry

---
 lldb/unittests/API/CMakeLists.txt  |  1 +
 lldb/unittests/API/SBLineEntryTest.cpp | 26 ++
 2 files changed, 27 insertions(+)
 create mode 100644 lldb/unittests/API/SBLineEntryTest.cpp

diff --git a/lldb/unittests/API/CMakeLists.txt 
b/lldb/unittests/API/CMakeLists.txt
index 52e9a5e991515..0cdadd1d40aee 100644
--- a/lldb/unittests/API/CMakeLists.txt
+++ b/lldb/unittests/API/CMakeLists.txt
@@ -1,5 +1,6 @@
 add_lldb_unittest(APITests
   SBCommandInterpreterTest.cpp
+SBLineEntryTest.cpp
 
   LINK_LIBS
 liblldb
diff --git a/lldb/unittests/API/SBLineEntryTest.cpp 
b/lldb/unittests/API/SBLineEntryTest.cpp
new file mode 100644
index 0..518893b554bd1
--- /dev/null
+++ b/lldb/unittests/API/SBLineEntryTest.cpp
@@ -0,0 +1,26 @@
+//===-- SBLineEntryTest.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 "gtest/gtest.h"
+
+#include "lldb/API/LLDB.h"
+
+TEST(SBLineEntryTest, SetLineAndColumn) {
+  constexpr uint32_t expected_line_no = 40;
+  constexpr uint32_t expected_column_no = 20;
+
+  lldb::SBLineEntry line_entry{};
+  line_entry.SetLine(expected_line_no);
+  line_entry.SetColumn(expected_column_no);
+
+  const uint32_t line_no = line_entry.GetLine();
+  const uint32_t column_no = line_entry.GetColumn();
+
+  EXPECT_EQ(line_no, line_no);
+  EXPECT_EQ(column_no, expected_column_no);
+}

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


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

2025-03-09 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
darker --check --diff -r 
c4ed0ad1f52a7bec7377bbaf75f812527ec739bd...6ab9291ef8a378c70ced67dc362aba424ecf56aa
 lldb/test/API/tools/lldb-dap/gotoTarget/TestDAP_gotoTarget.py 
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
``





View the diff from darker here.


``diff
--- test/API/tools/lldb-dap/gotoTarget/TestDAP_gotoTarget.py2025-03-09 
18:30:24.00 +
+++ test/API/tools/lldb-dap/gotoTarget/TestDAP_gotoTarget.py2025-03-09 
18:51:24.096062 +
@@ -6,11 +6,10 @@
 import lldbdap_testcase
 import os
 
 
 class TestDAP_gotoTarget(lldbdap_testcase.DAPTestCaseBase):
-
 def test_default(self):
 """
 Tests the jump to cursor of a simple program. No arguments,
 environment, or anything else is specified.
 This does not run any statement between the current breakpoint

``




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-09 Thread Julius Alexandre via lldb-commits

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

Original mentioned here: 
[Discourse](https://discourse.llvm.org/t/rich-disassembler-for-lldb/76952/20?u=wizardengineer)

This patch consist of changing GetData method in the ValueObject to return a 
llvm::Expected in order to have more meaningful error messages.

cc: @adrian-prantl 

>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/2] 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())

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

2025-03-09 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/3] 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] Implement jump to cursor (PR #130503)

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

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

>From bed28f5e22dd3c8c2bb3204aa41a9a71b49b63f9 Mon Sep 17 00:00:00 2001
From: Ezike Ebuka 
Date: Sun, 9 Mar 2025 12:46:54 +
Subject: [PATCH 1/4] [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 ++
 .../Handler/InitializeRequestHandler.cpp  |   2 +-
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  14 ++
 lldb/tools/lldb-dap/lldb-dap.cpp  |   2 +
 9 files changed, 291 insertions(+), 4 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 747f7e6038181..8d02088548634 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 9a2d604f4d573..ff7e413c4bb1c 100644
--- a/lldb/tools/lldb-dap/CMakeLists.txt
+++ b/lldb/tools/lldb-dap/CMakeLists.txt
@@ -50,6 +50,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 1f7b25e7c5bcc..f72bc34d52b53 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -76,7 +76,7 @@ DAP::DAP(std::string name, llvm::StringRef path, 
std::ofstream *log,
   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(repl_mode) {}
+  reverse_request_seq(0), repl_mode(repl_mode), goto_id_map() {}
 
 DAP::~DAP() = default;
 
@@ -899,6 +899,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 8b2e498a28c95..693908016fdc9 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -79,6 +79,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);
@@ -209,6 +230,7 @@ struct DAP {
   // empty; if the previous expression was a variabl

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

2025-03-09 Thread via lldb-commits

github-actions[bot] wrote:

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

https://github.com/llvm/llvm-project/pull/130516
___
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-09 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/4] 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] draft: [lldb] Upgrade ValueObject::GetData to return llvm::Expected (PR #130516)

2025-03-09 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 a7d5b3f711b7c852aa1337e329661dd36025865a 
c6d271b8b3e966c3a0f8548b2362668b05fc6f33 --extensions cpp,h -- 
lldb/include/lldb/ValueObject/ValueObject.h 
lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp 
lldb/source/Plugins/Language/ObjC/Cocoa.cpp 
lldb/source/Plugins/Language/ObjC/NSString.cpp 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
lldb/source/ValueObject/ValueObject.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
index 12a5ff3938..4e2775c5ca 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
@@ -277,9 +277,9 @@ ValueObjectSP ForwardListFrontEnd::GetChildAtIndex(uint32_t 
idx) {
   if (!data_or_err)
 return nullptr;
 
-  return CreateValueObjectFromData(llvm::formatv("[{0}]", idx).str(), 
*data_or_err,
-   m_backend.GetExecutionContextRef(),
-   m_element_type);
+  return CreateValueObjectFromData(
+  llvm::formatv("[{0}]", idx).str(), *data_or_err,
+  m_backend.GetExecutionContextRef(), m_element_type);
 }
 
 lldb::ChildCacheState ForwardListFrontEnd::Update() {
diff --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp 
b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
index 8c2582355e..ebb36b52af 100644
--- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
+++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -1208,8 +1208,8 @@ bool lldb_private::formatters::ObjCSELSummaryProvider(
 auto data_or_err = valobj.GetData();
 if (!data_or_err)
   return false;
-valobj_sp =
-ValueObject::CreateValueObjectFromData("text", *data_or_err, exe_ctx, 
charstar);
+valobj_sp = ValueObject::CreateValueObjectFromData("text", *data_or_err,
+   exe_ctx, charstar);
   }
 
   if (!valobj_sp)
diff --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
index b82bdf52e1..c35e29773e 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -552,7 +552,8 @@ ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException(
 auto data_or_err = dict_entry->GetData();
 if (!data_or_err)
   return ThreadSP();
-
data_or_err->SetAddressByteSize(dict_entry->GetProcessSP()->GetAddressByteSize());
+data_or_err->SetAddressByteSize(
+dict_entry->GetProcessSP()->GetAddressByteSize());
 
 lldb::offset_t data_offset = 0;
 auto dict_entry_key = data_or_err->GetAddress(&data_offset);

``




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][lldb-dap] Return optional from json utils (PR #129919)

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


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

da-viper wrote:

I did try that before, but I doesn't work because at the position the compiler 
sees it as an initializer list. and `llvm::StringRef` does not have an 
initializer-list constructor. 

in the previous fuction 
`GetString(. llvm::StringRef default_value = { } )` here it is treated as 
llvm::StringRef{} and can infer it.   



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


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

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

wizardengineer wrote:

This isn't finish of course, I'm not to sure on the changes so far and wanted 
to know if I was going toward the right path in terms what's being change.

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] Implement jump to cursor (PR #130503)

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

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

>From bed28f5e22dd3c8c2bb3204aa41a9a71b49b63f9 Mon Sep 17 00:00:00 2001
From: Ezike Ebuka 
Date: Sun, 9 Mar 2025 12:46:54 +
Subject: [PATCH 1/3] [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 ++
 .../Handler/InitializeRequestHandler.cpp  |   2 +-
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  14 ++
 lldb/tools/lldb-dap/lldb-dap.cpp  |   2 +
 9 files changed, 291 insertions(+), 4 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 747f7e6038181..8d02088548634 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 9a2d604f4d573..ff7e413c4bb1c 100644
--- a/lldb/tools/lldb-dap/CMakeLists.txt
+++ b/lldb/tools/lldb-dap/CMakeLists.txt
@@ -50,6 +50,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 1f7b25e7c5bcc..f72bc34d52b53 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -76,7 +76,7 @@ DAP::DAP(std::string name, llvm::StringRef path, 
std::ofstream *log,
   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(repl_mode) {}
+  reverse_request_seq(0), repl_mode(repl_mode), goto_id_map() {}
 
 DAP::~DAP() = default;
 
@@ -899,6 +899,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 8b2e498a28c95..693908016fdc9 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -79,6 +79,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);
@@ -209,6 +230,7 @@ struct DAP {
   // empty; if the previous expression was a variabl