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, AcceleratorActions &data, Path path) {
90 ObjectMapper o(value, path);
91 return o && o.map("plugin_name", data.plugin_name) &&
92 o.map("session_name", data.session_name) &&
93 o.map("identifier", data.identifier) &&
94 o.map("breakpoints", data.breakpoints);
95}
96
97json::Value toJSON(const AcceleratorActions &data) {
98 return Object{
99 {"plugin_name", data.plugin_name},
100 {"session_name", data.session_name},
101 {"identifier", data.identifier},
102 {"breakpoints", data.breakpoints},
103 };
104}
105
107 Path path) {
108 ObjectMapper o(value, path);
109 return o && o.map("disable_bp", data.disable_bp) &&
110 o.map("auto_resume_native", data.auto_resume_native) &&
111 o.mapOptional("actions", data.actions);
112}
113
114json::Value toJSON(const AcceleratorBreakpointHitResponse &data) {
115 Object obj{
116 {"disable_bp", data.disable_bp},
117 {"auto_resume_native", data.auto_resume_native},
118 };
119 if (data.actions)
120 obj["actions"] = *data.actions;
121 return obj;
122}
123
124} // namespace lldb_private
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.
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.