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, TraceCpuState &packet,
128  llvm::json::Path path);
129 
130 llvm::json::Value toJSON(const TraceCpuState &packet);
131 
133  std::vector<TraceThreadState> traced_threads;
134  std::vector<TraceBinaryData> process_binary_data;
135  llvm::Optional<std::vector<TraceCpuState>> cpus;
136  llvm::Optional<std::vector<std::string>> warnings;
137 
138  void AddWarning(llvm::StringRef warning);
139 };
140 
141 bool fromJSON(const llvm::json::Value &value, TraceGetStateResponse &packet,
142  llvm::json::Path path);
143 
144 llvm::json::Value toJSON(const TraceGetStateResponse &packet);
145 /// \}
146 
147 /// jLLDBTraceGetBinaryData gdb-remote packet
148 /// \{
150  /// Tracing technology name, e.g. intel-pt, arm-coresight.
152  /// Identifier for the data.
154  /// Optional tid if the data is related to a thread.
155  llvm::Optional<lldb::tid_t> tid;
156  /// Optional core id if the data is related to a cpu core.
157  llvm::Optional<lldb::cpu_id_t> cpu_id;
158 };
159 
160 bool fromJSON(const llvm::json::Value &value,
162  llvm::json::Path path);
163 
164 llvm::json::Value toJSON(const lldb_private::TraceGetBinaryDataRequest &packet);
165 /// \}
166 
167 } // namespace lldb_private
168 
169 #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::TraceCpuState
Definition: TraceGDBRemotePackets.h:121
lldb_private::TraceGetStateResponse::traced_threads
std::vector< TraceThreadState > traced_threads
Definition: TraceGDBRemotePackets.h:133
lldb_private::TraceGetBinaryDataRequest::kind
std::string kind
Identifier for the data.
Definition: TraceGDBRemotePackets.h:153
lldb_private::TraceGetBinaryDataRequest
jLLDBTraceGetBinaryData gdb-remote packet
Definition: TraceGDBRemotePackets.h:149
lldb_private::TraceGetStateResponse
Definition: TraceGDBRemotePackets.h:132
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::TraceCpuState::id
lldb::cpu_id_t id
Definition: TraceGDBRemotePackets.h:122
lldb_private::TraceGetStateRequest
}
Definition: TraceGDBRemotePackets.h:88
lldb_private::TraceGetStateResponse::process_binary_data
std::vector< TraceBinaryData > process_binary_data
Definition: TraceGDBRemotePackets.h:134
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::TraceGetStateResponse::cpus
llvm::Optional< std::vector< TraceCpuState > > cpus
Definition: TraceGDBRemotePackets.h:135
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::TraceBinaryData::kind
std::string kind
Identifier of data to fetch with jLLDBTraceGetBinaryData.
Definition: TraceGDBRemotePackets.h:100
lldb_private::TraceGetStateResponse::AddWarning
void AddWarning(llvm::StringRef warning)
Definition: TraceGDBRemotePackets.cpp:113
lldb-enumerations.h
lldb_private::TraceStopRequest::TraceStopRequest
TraceStopRequest()=default
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
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
warning
static llvm::raw_ostream & warning(Stream &strm)
Definition: CommandReturnObject.cpp:23
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::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:155
lldb_private::TraceGetBinaryDataRequest::type
std::string type
Tracing technology name, e.g. intel-pt, arm-coresight.
Definition: TraceGDBRemotePackets.h:151
lldb_private::TraceCpuState::binary_data
std::vector< TraceBinaryData > binary_data
List of binary data objects for this core.
Definition: TraceGDBRemotePackets.h:124
lldb_private::TraceGetBinaryDataRequest::cpu_id
llvm::Optional< lldb::cpu_id_t > cpu_id
Optional core id if the data is related to a cpu core.
Definition: TraceGDBRemotePackets.h:157
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::TraceGetStateResponse::warnings
llvm::Optional< std::vector< std::string > > warnings
Definition: TraceGDBRemotePackets.h:136
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