[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Mon Apr 1 12:59:47 PDT 2024


================
@@ -2809,6 +2919,243 @@ ValueObjectSP ValueObject::CastPointerType(const char *name, TypeSP &type_sp) {
   return valobj_sp;
 }
 
+lldb::addr_t ValueObject::GetLoadAddress() {
+  lldb::addr_t addr_value = LLDB_INVALID_ADDRESS;
+  lldb::TargetSP target_sp = GetTargetSP();
+  if (target_sp) {
+    const bool scalar_is_load_address = true;
+    AddressType addr_type;
+    addr_value = GetAddressOf(scalar_is_load_address, &addr_type);
+    if (addr_type == eAddressTypeFile) {
+      lldb::ModuleSP module_sp(GetModule());
+      if (!module_sp)
+        addr_value = LLDB_INVALID_ADDRESS;
+      else {
+        Address tmp_addr;
+        module_sp->ResolveFileAddress(addr_value, tmp_addr);
+        addr_value = tmp_addr.GetLoadAddress(target_sp.get());
+      }
+    } else if (addr_type == eAddressTypeHost || addr_type == eAddressTypeHost)
----------------
clayborg wrote:

Double check for `eAddressTypeHost`, I am guessing the second one was meant to be `eAddressTypeInvalid`. We should also change `lldb::addr_t SBValue::GetLoadAddress()` to call this function

https://github.com/llvm/llvm-project/pull/87197


More information about the lldb-commits mailing list