https://github.com/kuilpd created 
https://github.com/llvm/llvm-project/pull/137688

`ValueObject::AddressOf()` used to return address as a value which has it's own 
address, allowing to do `value.AddressOf().AddressOf()`.
This patch makes the return address a simple const value.

>From 510815468288c9ddf9a9b7da4e6e6271e06c3d20 Mon Sep 17 00:00:00 2001
From: Ilia Kuklin <ikuk...@accesssoftek.com>
Date: Mon, 28 Apr 2025 23:33:42 +0500
Subject: [PATCH] [LLDB] Fix `ValueObject::AddressOf()` return value

---
 lldb/source/ValueObject/ValueObject.cpp                | 7 +++++--
 lldb/test/API/python_api/sbvalue_const_addrof/main.cpp | 2 ++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/lldb/source/ValueObject/ValueObject.cpp 
b/lldb/source/ValueObject/ValueObject.cpp
index 8741cb7343166..1d8d112ccb0f4 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -2966,10 +2966,13 @@ ValueObjectSP ValueObject::AddressOf(Status &error) {
         std::string name(1, '&');
         name.append(m_name.AsCString(""));
         ExecutionContext exe_ctx(GetExecutionContextRef());
+
+        lldb::DataBufferSP buffer(
+            new lldb_private::DataBufferHeap(&addr, sizeof(lldb::addr_t)));
         m_addr_of_valobj_sp = ValueObjectConstResult::Create(
             exe_ctx.GetBestExecutionContextScope(),
-            compiler_type.GetPointerType(), ConstString(name.c_str()), addr,
-            eAddressTypeInvalid, m_data.GetAddressByteSize());
+            compiler_type.GetPointerType(), ConstString(name.c_str()), buffer,
+            endian::InlHostByteOrder(), exe_ctx.GetAddressByteSize());
       }
     } break;
     default:
diff --git a/lldb/test/API/python_api/sbvalue_const_addrof/main.cpp 
b/lldb/test/API/python_api/sbvalue_const_addrof/main.cpp
index 318a45bc21a85..6a24c32eae7e5 100644
--- a/lldb/test/API/python_api/sbvalue_const_addrof/main.cpp
+++ b/lldb/test/API/python_api/sbvalue_const_addrof/main.cpp
@@ -29,6 +29,8 @@ int main (int argc, char const *argv[], char const *envp[])
 {
     printf ("g_thread_list is %p\n", g_thread_list_ptr);
     return 0; //% v = 
self.dbg.GetSelectedTarget().FindFirstGlobalVariable('g_thread_list_ptr')
+    //% self.assertTrue(v.AddressOf().IsValid())
+    //% self.assertFalse(v.AddressOf().AddressOf().IsValid())
     //% v_gla = v.GetChildMemberWithName('regs').GetLoadAddress()
     //% v_aof = 
v.GetChildMemberWithName('regs').AddressOf().GetValueAsUnsigned(lldb.LLDB_INVALID_ADDRESS)
     //% expr = '(%s)0x%x' % (v.GetType().GetName(), v.GetValueAsUnsigned(0))

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

Reply via email to