LLDB  mainline
TraceGDBRemotePackets.h
Go to the documentation of this file.
1 //===-- TraceGDBRemotePackets.h ---------------------------------*- 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 
9 #ifndef LLDB_UTILITY_TRACEGDBREMOTEPACKETS_H
10 #define LLDB_UTILITY_TRACEGDBREMOTEPACKETS_H
11 
12 #include "llvm/Support/JSON.h"
13 
14 #include <chrono>
15 
16 #include "lldb/lldb-defines.h"
17 #include "lldb/lldb-enumerations.h"
18 
19 /// See docs/lldb-gdb-remote.txt for more information.
20 namespace lldb_private {
21 
22 /// jLLDBTraceSupported gdb-remote packet
23 /// \{
25  /// The name of the technology, e.g. intel-pt or arm-coresight.
26  ///
27  /// In order for a Trace plug-in (see \a lldb_private::Trace.h) to support the
28  /// trace technology given by this struct, it should match its name with this
29  /// field.
31  /// The description for the technology.
33 };
34 
35 bool fromJSON(const llvm::json::Value &value, TraceSupportedResponse &info,
36  llvm::json::Path path);
37 
38 llvm::json::Value toJSON(const TraceSupportedResponse &packet);
39 /// \}
40 
41 /// jLLDBTraceStart gdb-remote packet
42 /// \{
44  /// Tracing technology name, e.g. intel-pt, arm-coresight.
46 
47  /// If \a llvm::None, then this starts tracing the whole process. Otherwise,
48  /// only tracing for the specified threads is enabled.
49  llvm::Optional<std::vector<lldb::tid_t>> tids;
50 
51  /// \return
52  /// \b true if \a tids is \a None, i.e. whole process tracing.
53  bool IsProcessTracing() const;
54 };
55 
56 bool fromJSON(const llvm::json::Value &value, TraceStartRequest &packet,
57  llvm::json::Path path);
58 
59 llvm::json::Value toJSON(const TraceStartRequest &packet);
60 /// \}
61 
62 /// jLLDBTraceStop gdb-remote packet
63 /// \{
65  TraceStopRequest() = default;
66 
67  TraceStopRequest(llvm::StringRef type, const std::vector<lldb::tid_t> &tids);
68 
69  TraceStopRequest(llvm::StringRef type) : type(type){};
70 
71  bool IsProcessTracing() const;
72 
73  /// Tracing technology name, e.g. intel-pt, arm-coresight.
75  /// If \a llvm::None, then this stops tracing the whole process. Otherwise,
76  /// only tracing for the specified threads is stopped.
77  llvm::Optional<std::vector<lldb::tid_t>> tids;
78 };
79 
80 bool fromJSON(const llvm::json::Value &value, TraceStopRequest &packet,
81  llvm::json::Path path);
82 
83 llvm::json::Value toJSON(const TraceStopRequest &packet);
84 ///}
85 
86 /// jLLDBTraceGetState gdb-remote packet
87 /// \{
89  /// Tracing technology name, e.g. intel-pt, arm-coresight.
91 };
92 
93 bool fromJSON(const llvm::json::Value &value, TraceGetStateRequest &packet,
94  llvm::json::Path path);
95 
96 llvm::json::Value toJSON(const TraceGetStateRequest &packet);
97 
99  /// Identifier of data to fetch with jLLDBTraceGetBinaryData.
101  /// Size in bytes for this data.
102  uint64_t size;
103 };
104 
105 bool fromJSON(const llvm::json::Value &value, TraceBinaryData &packet,
106  llvm::json::Path path);
107 
108 llvm::json::Value toJSON(const TraceBinaryData &packet);
109 
112  /// List of binary data objects for this thread.
113  std::vector<TraceBinaryData> binary_data;
114 };
115 
116 bool fromJSON(const llvm::json::Value &value, TraceThreadState &packet,
117  llvm::json::Path path);
118 
119 llvm::json::Value toJSON(const TraceThreadState &packet);
120 
123  /// List of binary data objects for this core.
124  std::vector<TraceBinaryData> binary_data;
125 };
126 
127 bool fromJSON(const llvm::json::Value &value, TraceCoreState &packet,
128  llvm::json::Path path);
129 
130 llvm::json::Value toJSON(const TraceCoreState &packet);
131 
132 /// Interface for different algorithms used to convert trace
133 /// counters into different units.
134 template <typename ToType> class TraceCounterConversion {
135 public:
136  virtual ~TraceCounterConversion() = default;
137 
138  /// Convert from raw counter value to the target type.
139  ///
140  /// \param[in] raw_counter_value
141  /// The raw counter value to be converted.
142  ///
143  /// \return
144  /// The converted counter value.
145  virtual ToType Convert(uint64_t raw_counter_value) = 0;
146 
147  /// Serialize trace counter conversion values to JSON.
148  ///
149  /// \return
150  /// \a llvm::json::Value representing the trace counter conversion object.
151  virtual llvm::json::Value toJSON() = 0;
152 };
153 
154 using TraceTscConversionUP =
155  std::unique_ptr<TraceCounterConversion<std::chrono::nanoseconds>>;
156 
158  std::vector<TraceThreadState> traced_threads;
159  std::vector<TraceBinaryData> process_binary_data;
160  llvm::Optional<std::vector<TraceCoreState>> cores;
161 };
162 
163 bool fromJSON(const llvm::json::Value &value, TraceGetStateResponse &packet,
164  llvm::json::Path path);
165 
166 llvm::json::Value toJSON(const TraceGetStateResponse &packet);
167 /// \}
168 
169 /// jLLDBTraceGetBinaryData gdb-remote packet
170 /// \{
172  /// Tracing technology name, e.g. intel-pt, arm-coresight.
174  /// Identifier for the data.
176  /// Optional tid if the data is related to a thread.
177  llvm::Optional<lldb::tid_t> tid;
178  /// Offset in bytes from where to start reading the data.
179  uint64_t offset;
180  /// Number of bytes to read.
181  uint64_t size;
182 };
183 
184 bool fromJSON(const llvm::json::Value &value,
186  llvm::json::Path path);
187 
188 llvm::json::Value toJSON(const lldb_private::TraceGetBinaryDataRequest &packet);
189 /// \}
190 
191 } // namespace lldb_private
192 
193 #endif // LLDB_UTILITY_TRACEGDBREMOTEPACKETS_H
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::TraceGetStateResponse::traced_threads
std::vector< TraceThreadState > traced_threads
Definition: TraceGDBRemotePackets.h:158
lldb_private::TraceCounterConversion::~TraceCounterConversion
virtual ~TraceCounterConversion()=default
lldb_private::TraceGetBinaryDataRequest::kind
std::string kind
Identifier for the data.
Definition: TraceGDBRemotePackets.h:175
lldb_private::TraceGetBinaryDataRequest
jLLDBTraceGetBinaryData gdb-remote packet
Definition: TraceGDBRemotePackets.h:171
lldb_private::TraceGetStateResponse
Definition: TraceGDBRemotePackets.h:157
lldb_private::TraceStartRequest::type
std::string type
Tracing technology name, e.g. intel-pt, arm-coresight.
Definition: TraceGDBRemotePackets.h:45
lldb_private::TraceSupportedResponse::description
std::string description
The description for the technology.
Definition: TraceGDBRemotePackets.h:32
lldb_private::TraceSupportedResponse
jLLDBTraceSupported gdb-remote packet
Definition: TraceGDBRemotePackets.h:24
lldb-defines.h
lldb_private::TraceStopRequest::tids
llvm::Optional< std::vector< lldb::tid_t > > tids
If llvm::None, then this stops tracing the whole process.
Definition: TraceGDBRemotePackets.h:77
lldb_private::TraceSupportedResponse::name
std::string name
The name of the technology, e.g.
Definition: TraceGDBRemotePackets.h:30
lldb_private::TraceGetStateRequest
}
Definition: TraceGDBRemotePackets.h:88
lldb_private::TraceGetStateResponse::cores
llvm::Optional< std::vector< TraceCoreState > > cores
Definition: TraceGDBRemotePackets.h:160
lldb_private::TraceGetStateResponse::process_binary_data
std::vector< TraceBinaryData > process_binary_data
Definition: TraceGDBRemotePackets.h:159
lldb_private::TraceStartRequest::tids
llvm::Optional< std::vector< lldb::tid_t > > tids
If llvm::None, then this starts tracing the whole process.
Definition: TraceGDBRemotePackets.h:49
lldb_private::TraceGetBinaryDataRequest::offset
uint64_t offset
Offset in bytes from where to start reading the data.
Definition: TraceGDBRemotePackets.h:179
lldb_private::TraceTscConversionUP
std::unique_ptr< TraceCounterConversion< std::chrono::nanoseconds > > TraceTscConversionUP
Definition: TraceGDBRemotePackets.h:155
lldb_private::TraceStartRequest::IsProcessTracing
bool IsProcessTracing() const
jLLDBTraceStart
Definition: TraceGDBRemotePackets.cpp:32
lldb_private::TraceThreadState::tid
lldb::tid_t tid
Definition: TraceGDBRemotePackets.h:111
lldb_private::TraceCounterConversion::Convert
virtual ToType Convert(uint64_t raw_counter_value)=0
Convert from raw counter value to the target type.
lldb_private::TraceCounterConversion
Interface for different algorithms used to convert trace counters into different units.
Definition: TraceGDBRemotePackets.h:134
lldb_private::TraceBinaryData::kind
std::string kind
Identifier of data to fetch with jLLDBTraceGetBinaryData.
Definition: TraceGDBRemotePackets.h:100
lldb_private::TraceCoreState::binary_data
std::vector< TraceBinaryData > binary_data
List of binary data objects for this core.
Definition: TraceGDBRemotePackets.h:124
lldb-enumerations.h
lldb_private::TraceCoreState::core_id
lldb::core_id_t core_id
Definition: TraceGDBRemotePackets.h:122
lldb_private::TraceStopRequest::TraceStopRequest
TraceStopRequest()=default
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::TraceCounterConversion::toJSON
virtual llvm::json::Value toJSON()=0
Serialize trace counter conversion values to JSON.
lldb_private::TraceStopRequest::TraceStopRequest
TraceStopRequest(llvm::StringRef type)
Definition: TraceGDBRemotePackets.h:69
lldb_private::fromJSON
bool fromJSON(const llvm::json::Value &value, TraceSupportedResponse &info, llvm::json::Path path)
lldb_private::TraceBinaryData::size
uint64_t size
Size in bytes for this data.
Definition: TraceGDBRemotePackets.h:102
lldb_private::TraceStopRequest
jLLDBTraceStop gdb-remote packet
Definition: TraceGDBRemotePackets.h:64
lldb_private::TraceStartRequest
jLLDBTraceStart gdb-remote packet
Definition: TraceGDBRemotePackets.h:43
lldb_private::TraceThreadState::binary_data
std::vector< TraceBinaryData > binary_data
List of binary data objects for this thread.
Definition: TraceGDBRemotePackets.h:113
uint32_t
lldb_private::TraceGetBinaryDataRequest::size
uint64_t size
Number of bytes to read.
Definition: TraceGDBRemotePackets.h:181
lldb_private::TraceCoreState
Definition: TraceGDBRemotePackets.h:121
lldb_private::TraceGetStateRequest::type
std::string type
Tracing technology name, e.g. intel-pt, arm-coresight.
Definition: TraceGDBRemotePackets.h:90
lldb_private::TraceGetBinaryDataRequest::tid
llvm::Optional< lldb::tid_t > tid
Optional tid if the data is related to a thread.
Definition: TraceGDBRemotePackets.h:177
lldb_private::TraceGetBinaryDataRequest::type
std::string type
Tracing technology name, e.g. intel-pt, arm-coresight.
Definition: TraceGDBRemotePackets.h:173
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::TraceBinaryData
Definition: TraceGDBRemotePackets.h:98
lldb_private::TraceStopRequest::type
std::string type
Tracing technology name, e.g. intel-pt, arm-coresight.
Definition: TraceGDBRemotePackets.h:74
lldb::tid_t
uint64_t tid_t
Definition: lldb-types.h:86
lldb_private::TraceThreadState
Definition: TraceGDBRemotePackets.h:110