LLDB mainline
AcceleratorGDBRemotePackets.cpp
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
10
11using namespace llvm;
12using namespace llvm::json;
13
14namespace lldb_private {
15
16bool fromJSON(const Value &value, SymbolValue &data, Path path) {
17 ObjectMapper o(value, path);
18 return o && o.map("name", data.name) && o.map("value", data.value);
19}
20
21json::Value toJSON(const SymbolValue &data) {
22 return Object{{"name", data.name}, {"value", data.value}};
23}
24
26 Path path) {
27 ObjectMapper o(value, path);
28 return o && o.mapOptional("shlib", data.shlib) &&
29 o.map("function_name", data.function_name);
30}
31
32json::Value toJSON(const AcceleratorBreakpointByName &data) {
33 return Object{{"shlib", data.shlib}, {"function_name", data.function_name}};
34}
35
37 Path path) {
38 ObjectMapper o(value, path);
39 return o && o.map("load_address", data.load_address);
40}
41
42json::Value toJSON(const AcceleratorBreakpointByAddress &data) {
43 return Object{{"load_address", static_cast<int64_t>(data.load_address)}};
44}
45
46bool fromJSON(const Value &value, AcceleratorBreakpointInfo &data, Path path) {
47 ObjectMapper o(value, path);
48 return o && o.map("identifier", data.identifier) &&
49 o.mapOptional("by_name", data.by_name) &&
50 o.mapOptional("by_address", data.by_address) &&
51 o.map("symbol_names", data.symbol_names);
52}
53
54json::Value toJSON(const AcceleratorBreakpointInfo &data) {
55 return Object{
56 {"identifier", data.identifier},
57 {"by_name", data.by_name},
58 {"by_address", data.by_address},
59 {"symbol_names", data.symbol_names},
60 };
61}
62
64 Path path) {
65 ObjectMapper o(value, path);
66 return o && o.map("plugin_name", data.plugin_name) &&
67 o.map("breakpoint", data.breakpoint) &&
68 o.map("symbol_values", data.symbol_values);
69}
70
71json::Value toJSON(const AcceleratorBreakpointHitArgs &data) {
72 return Object{
73 {"plugin_name", data.plugin_name},
74 {"breakpoint", data.breakpoint},
75 {"symbol_values", data.symbol_values},
76 };
77}
78
79std::optional<uint64_t>
81 auto it = llvm::find_if(symbol_values, [&](const SymbolValue &symbol) {
82 return symbol.name == symbol_name;
83 });
84 if (it != symbol_values.end())
85 return it->value;
86 return std::nullopt;
87}
88
89bool fromJSON(const Value &value, AcceleratorConnectionInfo &data, Path path) {
90 ObjectMapper o(value, path);
91 return o && o.map("connect_url", data.connect_url) &&
92 o.map("platform_name", data.platform_name) &&
93 o.map("triple", data.triple) &&
94 o.mapOptional("exe_path", data.exe_path) &&
95 o.map("synchronous", data.synchronous);
96}
97
98json::Value toJSON(const AcceleratorConnectionInfo &data) {
99 return Object{
100 {"connect_url", data.connect_url}, {"platform_name", data.platform_name},
101 {"triple", data.triple}, {"exe_path", data.exe_path},
102 {"synchronous", data.synchronous},
103 };
104}
105
106bool fromJSON(const Value &value, AcceleratorActions &data, Path path) {
107 ObjectMapper o(value, path);
108 return o && o.map("plugin_name", data.plugin_name) &&
109 o.map("session_name", data.session_name) &&
110 o.map("identifier", data.identifier) &&
111 o.map("breakpoints", data.breakpoints) &&
112 o.mapOptional("connect_info", data.connect_info);
113}
114
115json::Value toJSON(const AcceleratorActions &data) {
116 Object obj{
117 {"plugin_name", data.plugin_name},
118 {"session_name", data.session_name},
119 {"identifier", data.identifier},
120 {"breakpoints", data.breakpoints},
121 };
122 if (data.connect_info)
123 obj["connect_info"] = *data.connect_info;
124 return obj;
125}
126
128 Path path) {
129 ObjectMapper o(value, path);
130 return o && o.map("disable_bp", data.disable_bp) &&
131 o.map("auto_resume_native", data.auto_resume_native) &&
132 o.mapOptional("actions", data.actions);
133}
134
135json::Value toJSON(const AcceleratorBreakpointHitResponse &data) {
136 Object obj{
137 {"disable_bp", data.disable_bp},
138 {"auto_resume_native", data.auto_resume_native},
139 };
140 if (data.actions)
141 obj["actions"] = *data.actions;
142 return obj;
143}
144
145} // namespace lldb_private
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.
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.