LLDB mainline
AcceleratorGDBRemotePackets.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_UTILITY_ACCELERATORGDBREMOTEPACKETS_H
10#define LLDB_UTILITY_ACCELERATORGDBREMOTEPACKETS_H
11
12#include "llvm/Support/JSON.h"
13#include <cstdint>
14#include <optional>
15#include <string>
16#include <vector>
17
18namespace lldb_private {
19
21 /// Symbol name as requested in AcceleratorBreakpointInfo::symbol_names.
22 std::string name;
23 /// Load address of the symbol in the native process, or nullopt if not found.
24 std::optional<uint64_t> value;
25};
26
27bool fromJSON(const llvm::json::Value &value, SymbolValue &data,
28 llvm::json::Path path);
29llvm::json::Value toJSON(const SymbolValue &data);
30
32 /// Optional shared library name to limit the breakpoint scope.
33 std::optional<std::string> shlib;
34 /// Function name to set a breakpoint at.
35 std::string function_name;
36};
37
38bool fromJSON(const llvm::json::Value &value, AcceleratorBreakpointByName &data,
39 llvm::json::Path path);
40llvm::json::Value toJSON(const AcceleratorBreakpointByName &data);
41
43 /// Load address in the native debug target.
44 uint64_t load_address = 0;
45};
46
47bool fromJSON(const llvm::json::Value &value,
48 AcceleratorBreakpointByAddress &data, llvm::json::Path path);
49llvm::json::Value toJSON(const AcceleratorBreakpointByAddress &data);
50
51/// A breakpoint definition. Clients fill in either \a by_name or
52/// \a by_address. If the breakpoint callback needs symbol values from
53/// the native process, fill in \a symbol_names — those values will be
54/// delivered in the breakpoint hit callback.
56 /// Unique breakpoint ID used to identify this breakpoint in the
57 /// BreakpointWasHit callback.
58 int64_t identifier = 0;
59 /// Breakpoint by function name.
60 std::optional<AcceleratorBreakpointByName> by_name;
61 /// Breakpoint by load address.
62 std::optional<AcceleratorBreakpointByAddress> by_address;
63 /// Symbol names whose values should be supplied when the breakpoint is hit.
64 std::vector<std::string> symbol_names;
65};
66
67bool fromJSON(const llvm::json::Value &value, AcceleratorBreakpointInfo &data,
68 llvm::json::Path path);
69llvm::json::Value toJSON(const AcceleratorBreakpointInfo &data);
70
71/// Sent by the client when a plugin-requested breakpoint is hit.
76
77 std::string plugin_name;
79 std::vector<SymbolValue> symbol_values;
80
81 std::optional<uint64_t> GetSymbolValue(llvm::StringRef symbol_name) const;
82};
83
84bool fromJSON(const llvm::json::Value &value,
85 AcceleratorBreakpointHitArgs &data, llvm::json::Path path);
86llvm::json::Value toJSON(const AcceleratorBreakpointHitArgs &data);
87
88/// Actions to be performed in the native process on behalf of an accelerator
89/// plugin. AcceleratorActions are returned in the following contexts:
90///
91/// - Initialization: in response to the "jAcceleratorPluginInitialize" packet,
92/// each plugin returns an AcceleratorActions describing initial breakpoints
93/// and other setup needed in the native process.
94///
95/// - Breakpoint hits: when a native breakpoint requested by a plugin is hit,
96/// the AcceleratorBreakpointHitResponse contains an AcceleratorActions that
97/// can request additional breakpoints or other actions.
98///
99/// In future patches, AcceleratorActions will also be returned:
100/// - When the native process stops (via NativeProcessIsStopping), allowing
101/// plugins to react to arbitrary stop events.
102/// - Via accelerator stop reply packets, enabling plugins to inject actions
103/// into the native process asynchronously.
106 AcceleratorActions(llvm::StringRef plugin_name, int64_t action_id)
107 : plugin_name(plugin_name), identifier(action_id) {}
108
109 /// Unique name identifying the accelerator plugin.
110 std::string plugin_name;
111 /// Human-readable label for the accelerator target.
112 std::string session_name;
113 /// Unique identifier for this action within the plugin.
114 int64_t identifier = 0;
115 /// New breakpoints to set. Nothing to set if this is empty.
116 std::vector<AcceleratorBreakpointInfo> breakpoints;
117};
118
119bool fromJSON(const llvm::json::Value &value, AcceleratorActions &data,
120 llvm::json::Path path);
121llvm::json::Value toJSON(const AcceleratorActions &data);
122
123/// Response from the plugin when a breakpoint is hit.
125 /// Set to true if this breakpoint should be disabled.
126 bool disable_bp = false;
127 /// Set to true if the native process should automatically resume after
128 /// the breakpoint is hit. When false, the native process will stop and
129 /// wait for user interaction.
131 /// Optional new actions to perform (e.g. set additional breakpoints).
132 std::optional<AcceleratorActions> actions;
133};
134
135bool fromJSON(const llvm::json::Value &value,
136 AcceleratorBreakpointHitResponse &data, llvm::json::Path path);
137llvm::json::Value toJSON(const AcceleratorBreakpointHitResponse &data);
138
139} // namespace lldb_private
140
141#endif // LLDB_UTILITY_ACCELERATORGDBREMOTEPACKETS_H
A class that represents a running process on the host machine.
bool fromJSON(const llvm::json::Value &value, SymbolValue &data, llvm::json::Path path)
llvm::json::Value toJSON(const SymbolValue &data)
Actions to be performed in the native process on behalf of an accelerator plugin.
std::vector< AcceleratorBreakpointInfo > breakpoints
New breakpoints to set. Nothing to set if this is empty.
AcceleratorActions(llvm::StringRef plugin_name, int64_t action_id)
int64_t identifier
Unique identifier for this action within the plugin.
std::string plugin_name
Unique name identifying the accelerator plugin.
std::string session_name
Human-readable label for the accelerator target.
uint64_t load_address
Load address in the native debug target.
std::string function_name
Function name to set a breakpoint at.
std::optional< std::string > shlib
Optional shared library name to limit the breakpoint scope.
Sent by the client when a plugin-requested breakpoint is hit.
std::optional< uint64_t > GetSymbolValue(llvm::StringRef symbol_name) const
Response from the plugin when a breakpoint is hit.
bool disable_bp
Set to true if this breakpoint should be disabled.
std::optional< AcceleratorActions > actions
Optional new actions to perform (e.g. set additional breakpoints).
bool auto_resume_native
Set to true if the native process should automatically resume after the breakpoint is hit.
int64_t identifier
Unique breakpoint ID used to identify this breakpoint in the BreakpointWasHit callback.
std::vector< std::string > symbol_names
Symbol names whose values should be supplied when the breakpoint is hit.
std::optional< AcceleratorBreakpointByAddress > by_address
Breakpoint by load address.
std::optional< AcceleratorBreakpointByName > by_name
Breakpoint by function name.
std::string name
Symbol name as requested in AcceleratorBreakpointInfo::symbol_names.
std::optional< uint64_t > value
Load address of the symbol in the native process, or nullopt if not found.