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/// Response from the plugin when a breakpoint is hit.
155 /// Set to true if this breakpoint should be disabled.
156 bool disable_bp = false;
157 /// Set to true if the native process should automatically resume after
158 /// the breakpoint is hit. When false, the native process will stop and
159 /// wait for user interaction.
161 /// Optional new actions to perform (e.g. set additional breakpoints).
162 std::optional<AcceleratorActions> actions;
163};
164
165bool fromJSON(const llvm::json::Value &value,
166 AcceleratorBreakpointHitResponse &data, llvm::json::Path path);
167llvm::json::Value toJSON(const AcceleratorBreakpointHitResponse &data);
168
169} // namespace lldb_private
170
171#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.
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.