Skip to content
Merged
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
21 changes: 17 additions & 4 deletions lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,11 @@ bool ProcessGDBRemote::GPUBreakpointHit(void *baton,
if (bp_sp)
bp_sp->SetEnabled(false);
}
HandleGPUActions(response->actions);
if (Status err = HandleGPUActions(response->actions); err.Fail()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL about "if with initializer syntax" that was added in c++17. Cool feature and keeps the error nicely scoped.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it's very useful, especially when everything fits in one line

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might consider simplifying this to:

Status err = HandleGPUActions(response->actions); 
if (err.Fail()) {

for clarity

Debugger::ReportError(
llvm::formatv("HandleGPUActions failed. Error: {0}\nActions:\n{1}\n",
err.AsCString(), toJSON(response->actions)));
}
}
return false; // Don't stop, auto continue.
}
Expand Down Expand Up @@ -1062,8 +1066,13 @@ Status ProcessGDBRemote::ConnectToDebugserver(llvm::StringRef connect_url) {
m_gdb_comm.GetVAttachOrWaitSupported();
m_gdb_comm.EnableErrorStringInPacket();
if (auto init_actions = m_gdb_comm.GetGPUInitializeActions()) {
for (const auto &init_action: *init_actions)
HandleGPUActions(init_action);
for (const auto &init_action : *init_actions) {
if (Status err = HandleGPUActions(init_action); err.Fail()) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Debugger::ReportError(llvm::formatv(
"HandleGPUActions failed. Error: {0}\nActions:\n{1}\n",
err.AsCString(), toJSON(init_action)));
}
}
}
// First dispatch any commands from the platform:
auto handle_cmds = [&] (const Args &args) -> void {
Expand Down Expand Up @@ -2611,7 +2620,11 @@ StateType ProcessGDBRemote::SetThreadStopInfo(StringExtractor &stop_packet) {
StringExtractorGDBRemote extractor(value);
if (std::optional<GPUActions> gpu_actions =
extractor.GetFromJSONHexASCII<GPUActions>()) {
HandleGPUActions(*gpu_actions);
if (Status err = HandleGPUActions(*gpu_actions); err.Fail()) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initializer syntax should be fine on MSCV. That has been around for many years already.
And this pattern is actually used in a few places in LLDB and LLVM already, so it should be fine.

Debugger::ReportError(llvm::formatv(
"HandleGPUActions failed. Error: {0}\nActions:\n{1}\n",
err.AsCString(), toJSON(*gpu_actions)));
}
}
} else if (key.size() == 2 && ::isxdigit(key[0]) && ::isxdigit(key[1])) {
uint32_t reg = UINT32_MAX;
Expand Down