[Lldb-commits] [lldb] [LLDB] Support transfer in local machine (PR #235512)

via lldb-commits lldb-commits at lists.llvm.org
Sun Oct 25 12:18:00 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: aokblast

<details>
<summary>Changes</summary>

A trasnfer can also happen in local machine if the src and dest are not the same. Support local machine transfer for this case. In Linux, we never hits this as they don't support coredump and will be bailed out eariler.

---
Full diff: https://github.com/llvm/llvm-project/pull/235512.diff


2 Files Affected:

- (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (+10-8) 
- (modified) lldb/source/Target/Platform.cpp (+5) 


``````````diff
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 540f620be4c957..947119fcde756e 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -6630,17 +6630,19 @@ llvm::Expected<bool> ProcessGDBRemote::SaveCore(llvm::StringRef outfile) {
       return llvm::createStringError(llvm::inconvertibleErrorCode(),
                                      "qSaveCore returned no core path");
 
-    // now transfer the core file
     FileSpec remote_core{llvm::StringRef(path)};
+    FileSpec local_core{outfile};
     Platform &platform = *GetTarget().GetPlatform();
-    Status error = platform.GetFile(remote_core, FileSpec(outfile));
 
-    if (platform.IsRemote()) {
-      // NB: we unlink the file on error too
-      platform.Unlink(remote_core);
-      if (error.Fail())
-        return error.ToError();
-    }
+    if (!platform.IsRemote() && remote_core == local_core)
+      return true;
+
+    // now transfer the core file
+    Status error = platform.GetFile(remote_core, local_core);
+    // NB: we unlink the file on error too
+    platform.Unlink(remote_core);
+    if (error.Fail())
+      return error.ToError();
 
     return true;
   }
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index e05f0a8124257d..f133a2b575da8f 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -1301,6 +1301,11 @@ Status Platform::PutFile(const FileSpec &source, const FileSpec &destination,
 }
 
 Status Platform::GetFile(const FileSpec &source, const FileSpec &destination) {
+  if (IsHost()) {
+    if (llvm::sys::fs::equivalent(source.GetPath(), destination.GetPath()))
+      return Status();
+    return llvm::sys::fs::copy_file(source.GetPath(), destination.GetPath());
+  }
   return Status::FromErrorString("unimplemented");
 }
 

``````````

</details>


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


More information about the lldb-commits mailing list