Skip to content

[LLDB][GPU] Add a GPUActions option for sync initialization #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lldb/include/lldb/Utility/GPUGDBRemotePackets.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ struct GPUPluginConnectionInfo {
std::optional<std::string> triple;
/// The connection URL to use with "process connect <url>".
std::string connect_url;
/// Synchronously wait for the GPU to initialize when connecting.
bool synchronous = false;
};

bool fromJSON(const llvm::json::Value &value, GPUPluginConnectionInfo &data,
Expand Down
13 changes: 8 additions & 5 deletions lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -976,11 +976,14 @@ Status ProcessGDBRemote::HandleConnectionRequest(const GPUActions &gpu_action) {
return Status::FromErrorString("invalid platform for target needed for "
"connecting to process");

// We wait for the process to fully stop before we can query or alter it via
// GPUActions.
ProcessSP process_sp = platform_sp->ConnectProcessSynchronous(
connection_info.connect_url, GetPluginNameStatic(), debugger,
*debugger.GetAsyncOutputStream(), gpu_target_sp.get(), error);
ProcessSP process_sp =
gpu_action.connect_info->synchronous
? platform_sp->ConnectProcessSynchronous(
connection_info.connect_url, GetPluginNameStatic(), debugger,
*debugger.GetAsyncOutputStream(), gpu_target_sp.get(), error)
: platform_sp->ConnectProcess(connection_info.connect_url,
GetPluginNameStatic(), debugger,
gpu_target_sp.get(), error);
if (error.Fail())
return error;
if (!process_sp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ std::optional<GPUActions> LLDBServerPluginAMDGPU::NativeProcessIsStopping() {
"launched successfully");
}
actions.connect_info = CreateConnection();
actions.connect_info->synchronous = true;
}
return actions;
} else {
Expand Down