[Lldb-commits] [lldb] [lldb] Track CPU and accelerator target relationships (PR #232906)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Oct 16 14:53:23 PDT 2026
================
@@ -4383,12 +4385,49 @@ llvm::Error ProcessGDBRemote::HandleAcceleratorConnection(
if (!accelerator_target_sp)
return llvm::createStringError("failed to create accelerator target");
+ llvm::scope_exit delete_accelerator_target([&] {
+ debugger.GetTargetList().DeleteTarget(accelerator_target_sp);
+ accelerator_target_sp->Destroy();
+ });
+
PlatformSP platform_sp = accelerator_target_sp->GetPlatform();
if (!platform_sp)
return llvm::createStringErrorV(
"no platform '{0}' compatible with triple '{1}' for the accelerator "
"target",
connect_info.platform_name, connect_info.triple);
+
+ TargetSP native_target_sp = GetTarget().shared_from_this();
+ std::vector<TargetGroupSP> cpu_groups =
+ native_target_sp->GetTargetGroups(TargetGroup::Role::CPU);
+ // A native target may have at most one CPU-role group, which is reused for
+ // every accelerator target discovered by this process.
+ if (cpu_groups.size() > 1)
----------------
jimingham wrote:
If you want to do that you might consider adding a validator to the TargetGroup, that TargetGroup::AddTarget calls. Might be nice, since the elements in the TargetGroup have an index, to do:
llvm::Expected<lldb::target_group_id> TargetGroup::AddTarget(TargetSP new_target_sp)
that would return either the ID of the newly added target, or an error about why the validator rejected it.
https://github.com/llvm/llvm-project/pull/232906
More information about the lldb-commits
mailing list