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/// Information the client needs to connect to an accelerator GDB server. When
89/// an AcceleratorActions carries this, the client creates a new target and
90/// connects to \a connect_url.
92 /// Connection URL the client should connect to (as in "process connect
93 /// <url>").
94 std::string connect_url;
95 /// Name of the platform to select when creating the accelerator target. The
96 /// platform must be able to handle \a triple and is used to connect to the
97 /// accelerator's GDB server.
98 std::string platform_name;
99 /// Target triple for the accelerator target. Used to ensure the architecture
100 /// is compatible with \a platform_name.
101 std::string triple;
102 /// Path to the executable to use when creating the accelerator target. If
103 /// not set, an empty target is created.
104 std::optional<std::string> exe_path;
105 /// If true, connect synchronously: the client blocks until the accelerator
106 /// process is connected and stopped before continuing. If false, the
107 /// connection is made asynchronously.
108 bool synchronous = false;
109};
110
111bool fromJSON(const llvm::json::Value &value, AcceleratorConnectionInfo &data,
112 llvm::json::Path path);
113llvm::json::Value toJSON(const AcceleratorConnectionInfo &data);
114
115/// Actions to be performed in the native process on behalf of an accelerator
116/// plugin. AcceleratorActions are returned in the following contexts:
117///
118/// - Initialization: in response to the "jAcceleratorPluginInitialize" packet,
119/// each plugin returns an AcceleratorActions describing initial breakpoints
120/// and other setup needed in the native process.
121///
122/// - Breakpoint hits: when a native breakpoint requested by a plugin is hit,
123/// the AcceleratorBreakpointHitResponse contains an AcceleratorActions that
124/// can request additional breakpoints or other actions.
125///
126/// In future patches, AcceleratorActions will also be returned:
127/// - When the native process stops (via NativeProcessIsStopping), allowing
128/// plugins to react to arbitrary stop events.
129/// - Via accelerator stop reply packets, enabling plugins to inject actions
130/// into the native process asynchronously.
133 AcceleratorActions(llvm::StringRef plugin_name, int64_t action_id)
134 : plugin_name(plugin_name), identifier(action_id) {}
135
136 /// Unique name identifying the accelerator plugin.
137 std::string plugin_name;
138 /// Human-readable label for the accelerator target.
139 std::string session_name;
140 /// Unique identifier for this action within the plugin.
141 int64_t identifier = 0;
142 /// New breakpoints to set. Nothing to set if this is empty.
143 std::vector<AcceleratorBreakpointInfo> breakpoints;
144 /// If set, the client should create a new target and connect to the
145 /// accelerator GDB server described here.
146 std::optional<AcceleratorConnectionInfo> connect_info;
147};
148
149bool fromJSON(const llvm::json::Value &value, AcceleratorActions &data,
150 llvm::json::Path path);
151llvm::json::Value toJSON(const AcceleratorActions &data);
152
153/// LLDB-specific settings for a process debugged over GDB-remote.
155 /// The name of the DynamicLoader plugin to use. If empty, LLDB selects the
156 /// plugin automatically from the target triple.
157 std::string dyld_plugin_name;
158 /// The server-side accelerator plugin associated with this process, if any.
159 /// This is only needed when send_dyld_packet_to_accelerator is false.
161 /// Send the dynamic-loader packet to the accelerator connection when true,
162 /// or the native process's connection when false.
164};
165
166bool fromJSON(const llvm::json::Value &value, LLDBSettings &data,
167 llvm::json::Path path);
168llvm::json::Value toJSON(const LLDBSettings &data);
169
170/// Response from the plugin when a breakpoint is hit.
172 /// Set to true if this breakpoint should be disabled.
173 bool disable_bp = false;
174 /// Set to true if the native process should automatically resume after
175 /// the breakpoint is hit. When false, the native process will stop and
176 /// wait for user interaction.
178 /// Optional new actions to perform (e.g. set additional breakpoints).
179 std::optional<AcceleratorActions> actions;
180};
181
182bool fromJSON(const llvm::json::Value &value,
183 AcceleratorBreakpointHitResponse &data, llvm::json::Path path);
184llvm::json::Value toJSON(const AcceleratorBreakpointHitResponse &data);
185
187 /// A list of section names. The first name is located in the module's
188 /// section list at the root level, and each name after it is found as a
189 /// child section of the previous one. The final section is the one that gets
190 /// loaded, e.g. ["PT_LOAD[0]", ".text"].
191 std::vector<std::string> names;
192 /// Address the section named by \a names is loaded at.
193 uint64_t load_address = 0;
194};
195
196bool fromJSON(const llvm::json::Value &value, AcceleratorSectionInfo &data,
197 llvm::json::Path path);
198llvm::json::Value toJSON(const AcceleratorSectionInfo &data);
199
201 /// Path to the object file, or a unique name identifying the module in the
202 /// target when it has no file on disk.
203 std::string pathname;
204 /// UUID of the object file, when the plugin knows it.
205 std::optional<std::string> uuid_str;
206 /// False means unload.
207 bool load = true;
208 /// Slides the whole object file. If unset, use \a loaded_sections or the
209 /// file addresses.
210 std::optional<uint64_t> load_address;
211 /// Used when sections load at independent addresses. Absent and empty mean
212 /// the same thing: no per-section addresses were supplied.
213 std::vector<AcceleratorSectionInfo> loaded_sections;
214 /// Where the image can be read in the native process, meaning the host
215 /// process driving the accelerator, not the accelerator itself. Set for a
216 /// library that only exists in memory.
217 std::optional<uint64_t> native_memory_address;
218 std::optional<uint64_t> native_memory_size;
219 /// Slice of \a pathname holding the object file, when embedded in a
220 /// container.
221 std::optional<uint64_t> file_offset;
222 std::optional<uint64_t> file_size;
223};
224
225bool fromJSON(const llvm::json::Value &value,
226 AcceleratorDynamicLoaderLibraryInfo &data, llvm::json::Path path);
227llvm::json::Value toJSON(const AcceleratorDynamicLoaderLibraryInfo &data);
228
229/// Arguments for the jAcceleratorPluginGetDynamicLoaderLibraryInfo packet.
231 std::string plugin_name;
232 /// If false, return only what changed since the last query. That state lives
233 /// in the plugin rather than per-client, so the first query of a session
234 /// must use true.
235 bool full = true;
236};
237
238bool fromJSON(const llvm::json::Value &value,
239 AcceleratorDynamicLoaderArgs &data, llvm::json::Path path);
240llvm::json::Value toJSON(const AcceleratorDynamicLoaderArgs &data);
241
242/// Response from the jAcceleratorPluginGetDynamicLoaderLibraryInfo packet.
244 std::vector<AcceleratorDynamicLoaderLibraryInfo> library_infos;
245};
246
247bool fromJSON(const llvm::json::Value &value,
248 AcceleratorDynamicLoaderResponse &data, llvm::json::Path path);
249llvm::json::Value toJSON(const AcceleratorDynamicLoaderResponse &data);
250
251} // namespace lldb_private
252
253#endif // LLDB_UTILITY_ACCELERATORGDBREMOTEPACKETS_H
A class that represents a running process on the host machine.
llvm::json::Value toJSON(const Diagnostics::Report &report)
Render a diagnostics report as JSON, for diagnostics dump's terminal output.
bool fromJSON(const llvm::json::Value &value, SymbolValue &data, llvm::json::Path path)
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::optional< AcceleratorConnectionInfo > connect_info
If set, the client should create a new target and connect to the accelerator GDB server described her...
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.
Information the client needs to connect to an accelerator GDB server.
std::string triple
Target triple for the accelerator target.
bool synchronous
If true, connect synchronously: the client blocks until the accelerator process is connected and stop...
std::optional< std::string > exe_path
Path to the executable to use when creating the accelerator target.
std::string connect_url
Connection URL the client should connect to (as in "process connect<url>").
std::string platform_name
Name of the platform to select when creating the accelerator target.
Arguments for the jAcceleratorPluginGetDynamicLoaderLibraryInfo packet.
bool full
If false, return only what changed since the last query.
std::string pathname
Path to the object file, or a unique name identifying the module in the target when it has no file on...
std::optional< std::string > uuid_str
UUID of the object file, when the plugin knows it.
std::optional< uint64_t > native_memory_address
Where the image can be read in the native process, meaning the host process driving the accelerator,...
std::vector< AcceleratorSectionInfo > loaded_sections
Used when sections load at independent addresses.
std::optional< uint64_t > file_offset
Slice of pathname holding the object file, when embedded in a container.
std::optional< uint64_t > load_address
Slides the whole object file.
Response from the jAcceleratorPluginGetDynamicLoaderLibraryInfo packet.
std::vector< AcceleratorDynamicLoaderLibraryInfo > library_infos
std::vector< std::string > names
A list of section names.
uint64_t load_address
Address the section named by names is loaded at.
LLDB-specific settings for a process debugged over GDB-remote.
std::string accelerator_plugin_name
The server-side accelerator plugin associated with this process, if any.
bool send_dyld_packet_to_accelerator
Send the dynamic-loader packet to the accelerator connection when true, or the native process's conne...
std::string dyld_plugin_name
The name of the DynamicLoader plugin to use.
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.