================
@@ -148,13 +149,33 @@ void DynamicLoaderWindowsDYLD::DidAttach() {
   // Try to fetch the load address of the file from the process, since there
   // could be randomization of the load address.
   lldb::addr_t load_addr = GetLoadAddress(executable);
-  if (load_addr == LLDB_INVALID_ADDRESS)
-    return;
+  if (load_addr == LLDB_INVALID_ADDRESS) {
+    // If the load address couldn't be determined (e.g. for a remote gdbstub
+    // target), fall back to the preferred load address/image base from the
+    // file if the process is live.
+    // This is a best-effort guess, if the image isn't loaded there the
+    // sections will have incorrect addresses and the slide will have to be
+    // specified manually.
+
+    if (!m_process->IsLiveDebugSession())
+      return;
 
-  // Request the process base address.
-  lldb::addr_t image_base = m_process->GetImageInfoAddress();
-  if (image_base == load_addr)
-    return;
+    ObjectFile *object_file = executable->GetObjectFile();
+    if (!object_file)
+      return;
+
+    load_addr = object_file->GetBaseAddress().GetFileAddress();
+    if (load_addr == LLDB_INVALID_ADDRESS)
+      return;
+
+    executable->ReportWarning(
+        "Failed to get load address, assuming image base ({0:x})", load_addr);
----------------
Nerixyz wrote:

```suggestion
        "failed to get load address, assuming image base at {0:x}", load_addr);
```
See [Error and Warning 
Messages](https://llvm.org/docs/CodingStandards.html#error-and-warning-messages).



https://github.com/llvm/llvm-project/pull/214023
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to