================
@@ -254,13 +254,17 @@ bool 
lldb_private::formatters::LibStdcppStringSummaryProvider(
   } else
     addr_of_string =
         valobj.GetAddressOf(scalar_is_load_addr, &addr_type);
-  if (addr_of_string != LLDB_INVALID_ADDRESS) {
+
+  // We have to check for host address here
+  // because GetAddressOf returns INVALID for all non load addresses.
+  // But we can still format strings in host memory.
+  if (addr_of_string != LLDB_INVALID_ADDRESS ||
+        addr_type == eAddressTypeHost) {
----------------
jimingham wrote:

I think we need to be more careful here.  GetAddressOf is really meant to do 
"can you find an address in the target for this object".  We use it that way in 
a whole bunch of places, e.g.:

```
      cstr_address = GetAddressOf(true, &cstr_address_type);
    } else {
      // We have a pointer
      cstr_address = GetPointerValue(&cstr_address_type);
    }

    if (cstr_address == 0 || cstr_address == LLDB_INVALID_ADDRESS) {
      if (cstr_address_type == eAddressTypeHost && is_array) {
        const char *cstr = GetDataExtractor().PeekCStr(0);

```

So in that case we are expecting a host address type to return an invalid 
address from GetAddressOf.

This change worries me, I don't think it will be what other code expects?  
Maybe you can get the value you need like the code above does instead?

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

Reply via email to