LLDB  mainline
TraceGDBRemotePackets.cpp
Go to the documentation of this file.
1 //===-- TraceGDBRemotePackets.cpp -------------------------------*- C++ -*-===//
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 
11 using namespace llvm;
12 using namespace llvm::json;
13 
14 namespace lldb_private {
15 /// jLLDBTraceSupported
16 /// \{
17 bool fromJSON(const json::Value &value, TraceSupportedResponse &packet,
18  Path path) {
19  ObjectMapper o(value, path);
20  return o && o.map("description", packet.description) &&
21  o.map("name", packet.name);
22 }
23 
24 json::Value toJSON(const TraceSupportedResponse &packet) {
25  return json::Value(
26  Object{{"description", packet.description}, {"name", packet.name}});
27 }
28 /// \}
29 
30 /// jLLDBTraceStart
31 /// \{
32 bool TraceStartRequest::IsProcessTracing() const { return !(bool)tids; }
33 
34 bool fromJSON(const json::Value &value, TraceStartRequest &packet, Path path) {
35  ObjectMapper o(value, path);
36  return o && o.map("type", packet.type) && o.map("tids", packet.tids);
37 }
38 
39 json::Value toJSON(const TraceStartRequest &packet) {
40  return json::Value(Object{{"tids", packet.tids}, {"type", packet.type}});
41 }
42 /// \}
43 
44 /// jLLDBTraceStop
45 /// \{
46 TraceStopRequest::TraceStopRequest(llvm::StringRef type,
47  const std::vector<lldb::tid_t> &tids_)
48  : type(type) {
49  tids.emplace();
50  for (lldb::tid_t tid : tids_)
51  tids->push_back(static_cast<int64_t>(tid));
52 }
53 
54 bool TraceStopRequest::IsProcessTracing() const { return !(bool)tids; }
55 
56 bool fromJSON(const json::Value &value, TraceStopRequest &packet, Path path) {
57  ObjectMapper o(value, path);
58  return o && o.map("type", packet.type) && o.map("tids", packet.tids);
59 }
60 
61 json::Value toJSON(const TraceStopRequest &packet) {
62  return json::Value(Object{{"type", packet.type}, {"tids", packet.tids}});
63 }
64 /// \}
65 
66 /// jLLDBTraceGetState
67 /// \{
68 bool fromJSON(const json::Value &value, TraceGetStateRequest &packet,
69  Path path) {
70  ObjectMapper o(value, path);
71  return o && o.map("type", packet.type);
72 }
73 
74 json::Value toJSON(const TraceGetStateRequest &packet) {
75  return json::Value(Object{{"type", packet.type}});
76 }
77 
78 bool fromJSON(const json::Value &value, TraceBinaryData &packet, Path path) {
79  ObjectMapper o(value, path);
80  return o && o.map("kind", packet.kind) && o.map("size", packet.size);
81 }
82 
83 json::Value toJSON(const TraceBinaryData &packet) {
84  return json::Value(Object{{"kind", packet.kind}, {"size", packet.size}});
85 }
86 
87 bool fromJSON(const json::Value &value, TraceThreadState &packet, Path path) {
88  ObjectMapper o(value, path);
89  return o && o.map("tid", packet.tid) &&
90  o.map("binaryData", packet.binaryData);
91 }
92 
93 json::Value toJSON(const TraceThreadState &packet) {
94  return json::Value(
95  Object{{"tid", packet.tid}, {"binaryData", packet.binaryData}});
96 }
97 
98 bool fromJSON(const json::Value &value, TraceGetStateResponse &packet,
99  Path path) {
100  ObjectMapper o(value, path);
101  return o && o.map("tracedThreads", packet.tracedThreads) &&
102  o.map("processBinaryData", packet.processBinaryData);
103 }
104 
105 json::Value toJSON(const TraceGetStateResponse &packet) {
106  return json::Value(Object{{"tracedThreads", packet.tracedThreads},
107  {"processBinaryData", packet.processBinaryData}});
108 }
109 /// \}
110 
111 /// jLLDBTraceGetBinaryData
112 /// \{
113 json::Value toJSON(const TraceGetBinaryDataRequest &packet) {
114  return json::Value(Object{{"type", packet.type},
115  {"kind", packet.kind},
116  {"offset", packet.offset},
117  {"tid", packet.tid},
118  {"size", packet.size}});
119 }
120 
121 bool fromJSON(const json::Value &value, TraceGetBinaryDataRequest &packet,
122  Path path) {
123  ObjectMapper o(value, path);
124  return o && o.map("type", packet.type) && o.map("kind", packet.kind) &&
125  o.map("tid", packet.tid) && o.map("offset", packet.offset) &&
126  o.map("size", packet.size);
127 }
128 /// \}
129 
130 } // namespace lldb_private
lldb_private::toJSON
llvm::json::Value toJSON(const TraceSupportedResponse &packet)
Definition: TraceGDBRemotePackets.cpp:24
lldb_private::TraceStopRequest::IsProcessTracing
bool IsProcessTracing() const
Definition: TraceGDBRemotePackets.cpp:54
lldb_private::TraceGetBinaryDataRequest::kind
std::string kind
Identifier for the data.
Definition: TraceGDBRemotePackets.h:136
llvm
Definition: Debugger.h:49
lldb_private::TraceGetBinaryDataRequest::size
int64_t size
Number of bytes to read.
Definition: TraceGDBRemotePackets.h:142
lldb_private::TraceGetBinaryDataRequest
jLLDBTraceGetBinaryData gdb-remote packet
Definition: TraceGDBRemotePackets.h:132
lldb_private::TraceGetStateResponse
Definition: TraceGDBRemotePackets.h:119
lldb_private::TraceStartRequest::type
std::string type
Tracing technology name, e.g. intel-pt, arm-coresight.
Definition: TraceGDBRemotePackets.h:43
lldb_private::TraceSupportedResponse::description
std::string description
The description for the technology.
Definition: TraceGDBRemotePackets.h:30
lldb_private::TraceSupportedResponse
jLLDBTraceSupported gdb-remote packet
Definition: TraceGDBRemotePackets.h:22
lldb_private::TraceThreadState::tid
int64_t tid
Definition: TraceGDBRemotePackets.h:109
lldb_private::TraceSupportedResponse::name
std::string name
The name of the technology, e.g.
Definition: TraceGDBRemotePackets.h:28
lldb_private::TraceGetStateResponse::processBinaryData
std::vector< TraceBinaryData > processBinaryData
Definition: TraceGDBRemotePackets.h:121
lldb_private::TraceGetStateRequest
}
Definition: TraceGDBRemotePackets.h:86
lldb_private::TraceGetBinaryDataRequest::tid
llvm::Optional< int64_t > tid
Optional tid if the data is related to a thread.
Definition: TraceGDBRemotePackets.h:138
llvm::json
Definition: TraceJSONStructs.cpp:19
lldb_private::TraceBinaryData::size
int64_t size
Size in bytes for this data.
Definition: TraceGDBRemotePackets.h:100
lldb_private::TraceBinaryData::kind
std::string kind
Identifier of data to fetch with jLLDBTraceGetBinaryData.
Definition: TraceGDBRemotePackets.h:98
lldb_private::TraceGetStateResponse::tracedThreads
std::vector< TraceThreadState > tracedThreads
Definition: TraceGDBRemotePackets.h:120
lldb_private::TraceGetBinaryDataRequest::offset
int64_t offset
Offset in bytes from where to start reading the data.
Definition: TraceGDBRemotePackets.h:140
lldb_private::fromJSON
bool fromJSON(const llvm::json::Value &value, TraceSupportedResponse &info, llvm::json::Path path)
lldb_private::TraceStopRequest
jLLDBTraceStop gdb-remote packet
Definition: TraceGDBRemotePackets.h:62
lldb_private::TraceStartRequest
jLLDBTraceStart gdb-remote packet
Definition: TraceGDBRemotePackets.h:41
lldb_private::TraceThreadState::binaryData
std::vector< TraceBinaryData > binaryData
List of binary data objects for this thread.
Definition: TraceGDBRemotePackets.h:111
lldb_private::TraceGetStateRequest::type
std::string type
Tracing technology name, e.g. intel-pt, arm-coresight.
Definition: TraceGDBRemotePackets.h:88
lldb_private::TraceStopRequest::tids
llvm::Optional< std::vector< int64_t > > tids
If llvm::None, then this stops tracing the whole process.
Definition: TraceGDBRemotePackets.h:75
lldb_private::TraceGetBinaryDataRequest::type
std::string type
Tracing technology name, e.g. intel-pt, arm-coresight.
Definition: TraceGDBRemotePackets.h:134
llvm::json::fromJSON
bool fromJSON(const Value &value, JSONAddress &address, Path path)
Definition: TraceJSONStructs.cpp:66
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::TraceBinaryData
Definition: TraceGDBRemotePackets.h:96
lldb_private::TraceStartRequest::tids
llvm::Optional< std::vector< int64_t > > tids
If llvm::None, then this starts tracing the whole process.
Definition: TraceGDBRemotePackets.h:47
lldb_private::TraceStopRequest::type
std::string type
Tracing technology name, e.g. intel-pt, arm-coresight.
Definition: TraceGDBRemotePackets.h:72
TraceGDBRemotePackets.h
llvm::json::toJSON
llvm::json::Value toJSON(const JSONModule &module)
Definition: TraceJSONStructs.cpp:21
lldb::tid_t
uint64_t tid_t
Definition: lldb-types.h:86
lldb_private::TraceThreadState
Definition: TraceGDBRemotePackets.h:108