================
@@ -223,6 +225,79 @@ bool 
GDBRemoteCommunicationClient::GetMultiBreakpointSupported() {
   return m_supports_multi_breakpoint == eLazyBoolYes;
 }
 
+bool GDBRemoteCommunicationClient::GetAcceleratorPluginsSupported() {
+  if (m_supports_accelerator_plugins == eLazyBoolCalculate)
+    GetRemoteQSupported();
+  return m_supports_accelerator_plugins == eLazyBoolYes;
+}
+
+std::optional<std::vector<AcceleratorActions>>
+GDBRemoteCommunicationClient::GetAcceleratorInitializeActions() {
+  // Get the initial actions (e.g. breakpoints to set) requested by any
+  // accelerator plugins using the "jAcceleratorPluginInitialize" packet. This
+  // is sent once when a native process is launched or attached.
+  if (!GetAcceleratorPluginsSupported())
+    return std::nullopt;
+
+  StringExtractorGDBRemote response;
+  response.SetResponseValidatorToJSON();
+  if (SendPacketAndWaitForResponse("jAcceleratorPluginInitialize", response) !=
+      PacketResult::Success)
+    return std::nullopt;
+
+  if (response.IsUnsupportedResponse())
+    return std::nullopt;
+
+  if (response.IsErrorResponse()) {
+    Debugger::ReportError(response.GetStatus().AsCString());
+    return std::nullopt;
+  }
+
+  llvm::Expected<std::vector<AcceleratorActions>> actions =
+      llvm::json::parse<std::vector<AcceleratorActions>>(response.Peek(),
+                                                         "AcceleratorActions");
+  if (actions)
+    return std::move(*actions);
+
+  // JSON parsing errors won't make sense to the user, so don't show them.
----------------
DavidSpickett wrote:

I had to read this a few times to understand it. I think you mean that showing 
the user "missing comma at line 4" is useless without showing them all the 
lines, right?

So show them the response in full and they can throw it at whatever json parser 
they want, or likely, spot it by eye.

Which is great, but you could also present both the error and the response? 
Assuming it has some form of line number that matches up. If not, the response 
only is fine.

Then make the comment clearer, for instance:
```
// JSON parsing errors won't make sense to the user, even if we include the 
response as well. So just print the whole response and let the user spot the 
problem.
```

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

Reply via email to