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"
18
19/// See docs/lldb-gdb-remote.txt for more information.
20namespace 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.
30 std::string name;
31 /// The description for the technology.
32 std::string description;
33};
34
35bool fromJSON(const llvm::json::Value &value, TraceSupportedResponse &info,
36 llvm::json::Path path);
37
38llvm::json::Value toJSON(const TraceSupportedResponse &packet);
39/// \}
40
41/// jLLDBTraceStart gdb-remote packet
42/// \{
44 /// Tracing technology name, e.g. intel-pt, arm-coresight.
45 std::string type;
46
47 /// If \a std::nullopt, then this starts tracing the whole process. Otherwise,
48 /// only tracing for the specified threads is enabled.
49 std::optional<std::vector<lldb::tid_t>> tids;
50
51 /// \return
52 /// \b true if \a tids is \a std::nullopt, i.e. whole process tracing.
53 bool IsProcessTracing() const;
54};
55
56bool fromJSON(const llvm::json::Value &value, TraceStartRequest &packet,
57 llvm::json::Path path);
58
59llvm::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.
74 std::string type;
75 /// If \a std::nullopt, then this stops tracing the whole process. Otherwise,
76 /// only tracing for the specified threads is stopped.
77 std::optional<std::vector<lldb::tid_t>> tids;
78};
79
80bool fromJSON(const llvm::json::Value &value, TraceStopRequest &packet,
81 llvm::json::Path path);
82
83llvm::json::Value toJSON(const TraceStopRequest &packet);
84///}
85
86/// jLLDBTraceGetState gdb-remote packet
87/// \{
89 /// Tracing technology name, e.g. intel-pt, arm-coresight.
90 std::string type;
91};
92
93bool fromJSON(const llvm::json::Value &value, TraceGetStateRequest &packet,
94 llvm::json::Path path);
95
96llvm::json::Value toJSON(const TraceGetStateRequest &packet);
97
99 /// Identifier of data to fetch with jLLDBTraceGetBinaryData.
100 std::string kind;
101 /// Size in bytes for this data.
102 uint64_t size;
103};
104
105bool fromJSON(const llvm::json::Value &value, TraceBinaryData &packet,
106 llvm::json::Path path);
107
108llvm::json::Value toJSON(const TraceBinaryData &packet);
109
112 /// List of binary data objects for this thread.
113 std::vector<TraceBinaryData> binary_data;
114};
115
116bool fromJSON(const llvm::json::Value &value, TraceThreadState &packet,
117 llvm::json::Path path);
118
119llvm::json::Value toJSON(const TraceThreadState &packet);
120
123 /// List of binary data objects for this core.
124 std::vector<TraceBinaryData> binary_data;
125};
126
127bool fromJSON(const llvm::json::Value &value, TraceCpuState &packet,
128 llvm::json::Path path);
129
130llvm::json::Value toJSON(const TraceCpuState &packet);
131
133 std::vector<TraceThreadState> traced_threads;
134 std::vector<TraceBinaryData> process_binary_data;
135 std::optional<std::vector<TraceCpuState>> cpus;
136 std::optional<std::vector<std::string>> warnings;
137
138 void AddWarning(llvm::StringRef warning);
139};
140
141bool fromJSON(const llvm::json::Value &value, TraceGetStateResponse &packet,
142 llvm::json::Path path);
143
144llvm::json::Value toJSON(const TraceGetStateResponse &packet);
145/// \}
146
147/// jLLDBTraceGetBinaryData gdb-remote packet
148/// \{
150 /// Tracing technology name, e.g. intel-pt, arm-coresight.
151 std::string type;
152 /// Identifier for the data.
153 std::string kind;
154 /// Optional tid if the data is related to a thread.
155 std::optional<lldb::tid_t> tid;
156 /// Optional core id if the data is related to a cpu core.
157 std::optional<lldb::cpu_id_t> cpu_id;
158};
159
160bool fromJSON(const llvm::json::Value &value,
162 llvm::json::Path path);
163
164llvm::json::Value toJSON(const lldb_private::TraceGetBinaryDataRequest &packet);
165/// \}
166
167} // namespace lldb_private
168
169#endif // LLDB_UTILITY_TRACEGDBREMOTEPACKETS_H
static llvm::raw_ostream & warning(Stream &strm)
A class that represents a running process on the host machine.
bool fromJSON(const llvm::json::Value &value, TraceSupportedResponse &info, llvm::json::Path path)
llvm::json::Value toJSON(const TraceSupportedResponse &packet)
uint64_t tid_t
Definition: lldb-types.h:86
std::string kind
Identifier of data to fetch with jLLDBTraceGetBinaryData.
uint64_t size
Size in bytes for this data.
std::vector< TraceBinaryData > binary_data
List of binary data objects for this core.
jLLDBTraceGetBinaryData gdb-remote packet
std::optional< lldb::cpu_id_t > cpu_id
Optional core id if the data is related to a cpu core.
std::optional< lldb::tid_t > tid
Optional tid if the data is related to a thread.
std::string kind
Identifier for the data.
std::string type
Tracing technology name, e.g. intel-pt, arm-coresight.
std::string type
Tracing technology name, e.g. intel-pt, arm-coresight.
std::optional< std::vector< std::string > > warnings
std::optional< std::vector< TraceCpuState > > cpus
std::vector< TraceThreadState > traced_threads
std::vector< TraceBinaryData > process_binary_data
void AddWarning(llvm::StringRef warning)
jLLDBTraceStart gdb-remote packet
bool IsProcessTracing() const
jLLDBTraceStart
std::optional< std::vector< lldb::tid_t > > tids
If std::nullopt, then this starts tracing the whole process.
std::string type
Tracing technology name, e.g. intel-pt, arm-coresight.
jLLDBTraceStop gdb-remote packet
std::string type
Tracing technology name, e.g. intel-pt, arm-coresight.
TraceStopRequest(llvm::StringRef type)
std::optional< std::vector< lldb::tid_t > > tids
If std::nullopt, then this stops tracing the whole process.
jLLDBTraceSupported gdb-remote packet
std::string name
The name of the technology, e.g.
std::string description
The description for the technology.
std::vector< TraceBinaryData > binary_data
List of binary data objects for this thread.