================
@@ -4223,6 +4197,61 @@ ProcessGDBRemote::HandleAcceleratorActions(const 
AcceleratorActions &actions) {
       return error;
   }
 
+  if (actions.connect_info) {
+    if (llvm::Error error = HandleAcceleratorConnection(actions))
+      return error;
+  }
+
+  return llvm::Error::success();
+}
+
+llvm::Error ProcessGDBRemote::HandleAcceleratorConnection(
+    const AcceleratorActions &actions) {
+  const AcceleratorConnectionInfo &connect_info = *actions.connect_info;
+  Debugger &debugger = GetTarget().GetDebugger();
+
+  // Create a new (empty) target for the accelerator and connect to the GDB
+  // server the plugin is serving.
+  llvm::StringRef exe_path =
+      connect_info.exe_path ? *connect_info.exe_path : llvm::StringRef();
+  llvm::StringRef triple =
+      connect_info.triple ? *connect_info.triple : llvm::StringRef();
+  TargetSP accelerator_target_sp;
+  Status error = debugger.GetTargetList().CreateTarget(
+      debugger, exe_path, triple, eLoadDependentsNo,
+      /*platform_options=*/nullptr, accelerator_target_sp);
+  if (error.Fail())
+    return error.takeError();
+  if (!accelerator_target_sp)
+    return llvm::createStringError("failed to create accelerator target");
+
+  PlatformSP platform_sp = accelerator_target_sp->GetPlatform();
+  if (!platform_sp)
+    return llvm::createStringError(
+        "no platform for the accelerator target connection");
----------------
clayborg wrote:

If we don't require a triple and don't have an executable specified, then the 
platform that this target has might not be what we expect and might change once 
the GPU target sets a new executable. So I am not sure we can infer anything 
about the platform here. It will probably just default to the host platform.

If we want to make sure we get the right platform right away, we need to 
specify a target triple, or have a valid executable when creating the target.

So we probably don't need to verify that the platform is here, or we need to 
ensure we give the target enough info (exe or triple) to make sure it selects 
the right platform and verify the platform is correct.

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

Reply via email to