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

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

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


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

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


@@ -371,6 +372,7 @@ LLVM `_):
   -C /path/to/llvm-project/lldb/cmake/caches/Apple-lldb-macOS.cmake \
   -DLLVM_ENABLE_PROJECTS="clang;lldb" \
   -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
+  -DLLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=ON \

wizardengineer wrote:

Ah I see, that makes sense. The idea behind adding the 
`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS` in `build.rst` was to help subside 
issues with certain test suites. After reading what you said, I think it might 
be beneficial to at least add it as an option? Rather than making it a default 
like you said.

I'll make sure to remove it.

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


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

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

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

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

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

cc @adrian-prantl

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

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

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

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


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

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

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


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

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

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

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

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

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

>From 85c9e877d3b03bf6f2d0bdd159aaf871f98e6965 Mon Sep 17 00:00:00 2001
From: medievalghoul <61852278+medievalgh...@users.noreply.github.com>
Date: Sat, 8 Mar 2025 16:17:55 -0500
Subject: [PATCH 2/2] fix placement and text

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

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

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


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

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


@@ -340,7 +340,8 @@ On macOS the LLDB test suite requires libc++. Either add
   code-signed with identity ``lldb_codesign`` (see :ref:`CodeSigning`).
 * ``LLDB_USE_SYSTEM_DEBUGSERVER:BOOL``: Use the system's debugserver, so lldb 
is
   functional without setting up code-signing.
-
+* ``LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS:BOOL``: This helps with determining 
missing
+  packages or modules at configuration time.

wizardengineer wrote:

done :)

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


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

2025-03-10 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/6] 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 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] draft: [lldb] Upgrade ValueObject::GetData to return llvm::Expected (PR #130516)

2025-03-10 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/5] 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-10 Thread Julius Alexandre via lldb-commits

wizardengineer wrote:

I added another wave of refactors, I'll add more changes, once this current 
wave(commit) is approved. And I'll continue to incrementally add changes to 
make it easier to manage.

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


@@ -46,19 +46,27 @@ bool TypeFormatImpl_Format::FormatObject(ValueObject 
*valobj,
 Value &value(valobj->GetValue());
 const Value::ContextType context_type = value.GetContextType();
 ExecutionContext exe_ctx(valobj->GetExecutionContextRef());
-DataExtractor data;
 
+auto data_or_err = valobj->GetData();

wizardengineer wrote:

I think this is a practical approach?

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 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] draft: [lldb] Upgrade ValueObject::GetData to return llvm::Expected (PR #130516)

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


@@ -68,11 +68,9 @@ static bool CharStringSummaryProvider(ValueObject &valobj, 
Stream &stream) {
 
 template 
 static bool CharSummaryProvider(ValueObject &valobj, Stream &stream) {
-  DataExtractor data;
-  Status error;
-  valobj.GetData(data, error);
+  auto data_or_err = valobj.GetData();
 
-  if (error.Fail())
+  if (!data_or_err)

wizardengineer wrote:

Okay that makes sense, I was aware of the assertion of `llvm::Error`. I'll make 
sure to fix that and resort to handling the Errors if needed so. Otherwise, 
I'll use `llvm::expectedToOptional()`. Just to be sure, in what case would I 
know if a error doesn't really matter? 

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-11 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/7] 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-15 Thread Julius Alexandre via lldb-commits


@@ -46,19 +46,27 @@ bool TypeFormatImpl_Format::FormatObject(ValueObject 
*valobj,
 Value &value(valobj->GetValue());
 const Value::ContextType context_type = value.GetContextType();
 ExecutionContext exe_ctx(valobj->GetExecutionContextRef());
-DataExtractor data;
 
+auto data_or_err = valobj->GetData();

wizardengineer wrote:

Yeah, it seems to be fine. I don't think there should be any side-effects from 
this refactor.

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


@@ -523,13 +522,11 @@ class EntityVariableBase : public Materializer::Entity {
   return;
 }
   } else {
-DataExtractor data;
-Status extract_error;
-valobj_sp->GetData(data, extract_error);
-if (!extract_error.Success()) {
+auto data_or_err = valobj_sp->GetData();
+if (auto error = data_or_err.takeError()) {
   err = Status::FromErrorStringWithFormat(
   "couldn't get the value of %s: %s", GetName().AsCString(),
-  extract_error.AsCString());
+  llvm::toString(std::move(error)).c_str());

wizardengineer wrote:

understood, there's some case where I get an error like 

```cpp
error: calling a protected constructor of class 'lldb_private::Status'
1854 |   return llvm::joinErrors(llvm::createStringError(
```

I did something like this (in the case of getting that error):
```cpp
if (auto error = data_or_err.takeError()) {
  auto combined_err = llvm::joinErrors(llvm::createStringError(
  "Couldn't convert return value to raw data"),
  std::move(error));
  return 
Status::FromErrorString(llvm::toString(std::move(combined_err)).c_str());
}
```

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

wizardengineer wrote:

This is taking longer than expected, I'm encountering a lot of linker bugs 
unrelated the patches I've made. Even after create a fresh clone of llvm 
without the patches. I'm still encountering issues. 

One them being 
https://github.com/llvm/llvm-project/issues/132845#issuecomment-2749669663

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-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] 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] 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] 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] 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/10] 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-15 Thread Julius Alexandre via lldb-commits

wizardengineer wrote:

Hey @adrian-prantl, if you can and when you have time. I was wondering if it'd 
be okay if you can review this and just so i can make sure it aligns with the 
standards for this PR.

I was also curious to know if I'd have to change any test code too, I've tried 
to unit test but got error relating to "expected" values. Would I need to 
change something in `DumpValueObjectOptionsTests.cpp`?

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


@@ -483,19 +483,18 @@ class EntityVariableBase : public Materializer::Entity {
 }
 
 if (m_is_reference) {
-  DataExtractor valobj_extractor;
-  Status extract_error;
-  valobj_sp->GetData(valobj_extractor, extract_error);
+  auto valobj_extractor_or_err = valobj_sp->GetData();
 
-  if (!extract_error.Success()) {
+  if (auto error = valobj_extractor_or_err.takeError()) {
 err = Status::FromErrorStringWithFormat(
 "couldn't read contents of reference variable %s: %s",
-GetName().AsCString(), extract_error.AsCString());
+GetName().AsCString(), llvm::toString(std::move(error)).c_str());
 return;

wizardengineer wrote:

shouldn't we just do this from now on?

```suggestion
return Status::FromErrorStringWithFormat(
"couldn't read contents of reference variable %s: %s",
GetName().AsCString(), extract_error.AsCString());
GetName().AsCString(), llvm::toString(std::move(error)).c_str());
```

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

https://github.com/wizardengineer edited 
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-22 Thread Julius Alexandre via lldb-commits


@@ -523,13 +522,11 @@ class EntityVariableBase : public Materializer::Entity {
   return;
 }
   } else {
-DataExtractor data;
-Status extract_error;
-valobj_sp->GetData(data, extract_error);
-if (!extract_error.Success()) {
+auto data_or_err = valobj_sp->GetData();
+if (auto error = data_or_err.takeError()) {
   err = Status::FromErrorStringWithFormat(
   "couldn't get the value of %s: %s", GetName().AsCString(),
-  extract_error.AsCString());
+  llvm::toString(std::move(error)).c_str());

wizardengineer wrote:

is that above solution good good? or should i just let it stay as 
`Status::FromErrorStringWithFormat(...)`

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


@@ -523,13 +522,11 @@ class EntityVariableBase : public Materializer::Entity {
   return;
 }
   } else {
-DataExtractor data;
-Status extract_error;
-valobj_sp->GetData(data, extract_error);
-if (!extract_error.Success()) {
+auto data_or_err = valobj_sp->GetData();
+if (auto error = data_or_err.takeError()) {
   err = Status::FromErrorStringWithFormat(
   "couldn't get the value of %s: %s", GetName().AsCString(),
-  extract_error.AsCString());
+  llvm::toString(std::move(error)).c_str());

wizardengineer wrote:

I don't seem as if I can directly just do a `llvm::joinErrors`, `err` argument 
is a `lldb_private::Status`. I don't think there's any conversions from 
`Status` to `llvm::Errors`. I could be wrong.

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


@@ -436,13 +436,15 @@ Status 
ABISysV_ppc::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
   compiler_type.IsPointerType()) {
 const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName("r3", 0);
 
-DataExtractor data;
-Status data_error;
-size_t num_bytes = new_value_sp->GetData(data, data_error);
-if (data_error.Fail())
-  return Status::FromErrorStringWithFormat(
-  "Couldn't convert return value to raw data: %s",
-  data_error.AsCString());
+auto data_or_err = new_value_sp->GetData();
+if (auto err = data_or_err.takeError())
+  return Status::FromError(llvm::joinErrors(
+  llvm::createStringError("Couldn't convert return value to raw data"),

wizardengineer wrote:

I think it should be this instead?

```suggestion
  llvm::createStringError("Couldn't convert return value to raw data: 
"),
```

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

https://github.com/wizardengineer edited 
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