[Lldb-commits] [lldb] [lldb-server] Add breakpoint support to accelerator plugin protocol (PR #200584)

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Mon Jun 1 10:48:09 PDT 2026


================
@@ -11,10 +11,92 @@
 
 #include "llvm/Support/JSON.h"
 #include <cstdint>
+#include <optional>
 #include <string>
+#include <vector>
 
 namespace lldb_private {
 
+struct SymbolValue {
+  /// Symbol name as requested in AcceleratorBreakpointInfo::symbol_names.
+  std::string name;
+  /// Load address of the symbol in the native process, or nullopt if not found.
+  std::optional<uint64_t> value;
+};
+
+bool fromJSON(const llvm::json::Value &value, SymbolValue &data,
+              llvm::json::Path path);
+llvm::json::Value toJSON(const SymbolValue &data);
+
+struct AcceleratorBreakpointByName {
+  /// Optional shared library name to limit the breakpoint scope.
+  std::optional<std::string> shlib;
+  /// Function name to set a breakpoint at.
+  std::string function_name;
+};
+
+bool fromJSON(const llvm::json::Value &value, AcceleratorBreakpointByName &data,
+              llvm::json::Path path);
+llvm::json::Value toJSON(const AcceleratorBreakpointByName &data);
+
+struct AcceleratorBreakpointByAddress {
+  /// Load address in the native debug target.
+  uint64_t load_address = 0;
+};
+
+bool fromJSON(const llvm::json::Value &value,
+              AcceleratorBreakpointByAddress &data, llvm::json::Path path);
+llvm::json::Value toJSON(const AcceleratorBreakpointByAddress &data);
+
+/// A breakpoint definition. Clients fill in either \a by_name or
+/// \a by_address. If the breakpoint callback needs symbol values from
+/// the native process, fill in \a symbol_names — those values will be
+/// delivered in the breakpoint hit callback.
+struct AcceleratorBreakpointInfo {
+  /// Unique breakpoint ID used to identify this breakpoint in the
+  /// BreakpointWasHit callback.
+  int64_t identifier = 0;
+  /// Breakpoint by function name.
+  std::optional<AcceleratorBreakpointByName> by_name;
+  /// Breakpoint by load address.
+  std::optional<AcceleratorBreakpointByAddress> by_address;
+  /// Symbol names whose values should be supplied when the breakpoint is hit.
+  std::vector<std::string> symbol_names;
+};
+
+bool fromJSON(const llvm::json::Value &value, AcceleratorBreakpointInfo &data,
+              llvm::json::Path path);
+llvm::json::Value toJSON(const AcceleratorBreakpointInfo &data);
+
+/// Sent by the client when a plugin-requested breakpoint is hit.
+struct AcceleratorBreakpointHitArgs {
+  AcceleratorBreakpointHitArgs() = default;
+  AcceleratorBreakpointHitArgs(llvm::StringRef plugin_name)
+      : plugin_name(plugin_name) {}
+
+  std::string plugin_name;
+  AcceleratorBreakpointInfo breakpoint;
+  std::vector<SymbolValue> symbol_values;
+
+  std::optional<uint64_t> GetSymbolValue(llvm::StringRef symbol_name) const;
+};
+
+bool fromJSON(const llvm::json::Value &value,
+              AcceleratorBreakpointHitArgs &data, llvm::json::Path path);
+llvm::json::Value toJSON(const AcceleratorBreakpointHitArgs &data);
+
+/// Response from the plugin when a breakpoint is hit.
+struct AcceleratorBreakpointHitResponse {
+  /// Set to true if this breakpoint should be disabled.
+  bool disable_bp = false;
+  /// Set to true if the native process should automatically resume.
+  bool auto_resume_native = true;
+};
+
+bool fromJSON(const llvm::json::Value &value,
+              AcceleratorBreakpointHitResponse &data, llvm::json::Path path);
+llvm::json::Value toJSON(const AcceleratorBreakpointHitResponse &data);
+
 struct AcceleratorActions {
----------------
clayborg wrote:

It would be a good idea to add comments here explaining how and where AcceleratorActions are used. See https://github.com/clayborg/llvm-project/blob/llvm-server-plugins/lldb/include/lldb/Utility/GPUGDBRemotePackets.h#L183 for full details.

https://github.com/llvm/llvm-project/pull/200584


More information about the lldb-commits mailing list