Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:58

0001 //===-- TraceGDBRemotePackets.h ---------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_UTILITY_TRACEGDBREMOTEPACKETS_H
0010 #define LLDB_UTILITY_TRACEGDBREMOTEPACKETS_H
0011 
0012 #include "llvm/Support/JSON.h"
0013 
0014 #include <chrono>
0015 
0016 #include "lldb/lldb-defines.h"
0017 #include "lldb/lldb-enumerations.h"
0018 
0019 /// See docs/lldb-gdb-remote.txt for more information.
0020 namespace lldb_private {
0021 
0022 /// jLLDBTraceSupported gdb-remote packet
0023 /// \{
0024 struct TraceSupportedResponse {
0025   /// The name of the technology, e.g. intel-pt or arm-coresight.
0026   ///
0027   /// In order for a Trace plug-in (see \a lldb_private::Trace.h) to support the
0028   /// trace technology given by this struct, it should match its name with this
0029   /// field.
0030   std::string name;
0031   /// The description for the technology.
0032   std::string description;
0033 };
0034 
0035 bool fromJSON(const llvm::json::Value &value, TraceSupportedResponse &info,
0036               llvm::json::Path path);
0037 
0038 llvm::json::Value toJSON(const TraceSupportedResponse &packet);
0039 /// \}
0040 
0041 /// jLLDBTraceStart gdb-remote packet
0042 /// \{
0043 struct TraceStartRequest {
0044   /// Tracing technology name, e.g. intel-pt, arm-coresight.
0045   std::string type;
0046 
0047   /// If \a std::nullopt, then this starts tracing the whole process. Otherwise,
0048   /// only tracing for the specified threads is enabled.
0049   std::optional<std::vector<lldb::tid_t>> tids;
0050 
0051   /// \return
0052   ///     \b true if \a tids is \a std::nullopt, i.e. whole process tracing.
0053   bool IsProcessTracing() const;
0054 };
0055 
0056 bool fromJSON(const llvm::json::Value &value, TraceStartRequest &packet,
0057               llvm::json::Path path);
0058 
0059 llvm::json::Value toJSON(const TraceStartRequest &packet);
0060 /// \}
0061 
0062 /// jLLDBTraceStop gdb-remote packet
0063 /// \{
0064 struct TraceStopRequest {
0065   TraceStopRequest() = default;
0066 
0067   TraceStopRequest(llvm::StringRef type, const std::vector<lldb::tid_t> &tids);
0068 
0069   TraceStopRequest(llvm::StringRef type) : type(type){};
0070 
0071   bool IsProcessTracing() const;
0072 
0073   /// Tracing technology name, e.g. intel-pt, arm-coresight.
0074   std::string type;
0075   /// If \a std::nullopt, then this stops tracing the whole process. Otherwise,
0076   /// only tracing for the specified threads is stopped.
0077   std::optional<std::vector<lldb::tid_t>> tids;
0078 };
0079 
0080 bool fromJSON(const llvm::json::Value &value, TraceStopRequest &packet,
0081               llvm::json::Path path);
0082 
0083 llvm::json::Value toJSON(const TraceStopRequest &packet);
0084 ///}
0085 
0086 /// jLLDBTraceGetState gdb-remote packet
0087 /// \{
0088 struct TraceGetStateRequest {
0089   /// Tracing technology name, e.g. intel-pt, arm-coresight.
0090   std::string type;
0091 };
0092 
0093 bool fromJSON(const llvm::json::Value &value, TraceGetStateRequest &packet,
0094               llvm::json::Path path);
0095 
0096 llvm::json::Value toJSON(const TraceGetStateRequest &packet);
0097 
0098 struct TraceBinaryData {
0099   /// Identifier of data to fetch with jLLDBTraceGetBinaryData.
0100   std::string kind;
0101   /// Size in bytes for this data.
0102   uint64_t size;
0103 };
0104 
0105 bool fromJSON(const llvm::json::Value &value, TraceBinaryData &packet,
0106               llvm::json::Path path);
0107 
0108 llvm::json::Value toJSON(const TraceBinaryData &packet);
0109 
0110 struct TraceThreadState {
0111   lldb::tid_t tid;
0112   /// List of binary data objects for this thread.
0113   std::vector<TraceBinaryData> binary_data;
0114 };
0115 
0116 bool fromJSON(const llvm::json::Value &value, TraceThreadState &packet,
0117               llvm::json::Path path);
0118 
0119 llvm::json::Value toJSON(const TraceThreadState &packet);
0120 
0121 struct TraceCpuState {
0122   lldb::cpu_id_t id;
0123   /// List of binary data objects for this core.
0124   std::vector<TraceBinaryData> binary_data;
0125 };
0126 
0127 bool fromJSON(const llvm::json::Value &value, TraceCpuState &packet,
0128               llvm::json::Path path);
0129 
0130 llvm::json::Value toJSON(const TraceCpuState &packet);
0131 
0132 struct TraceGetStateResponse {
0133   std::vector<TraceThreadState> traced_threads;
0134   std::vector<TraceBinaryData> process_binary_data;
0135   std::optional<std::vector<TraceCpuState>> cpus;
0136   std::optional<std::vector<std::string>> warnings;
0137 
0138   void AddWarning(llvm::StringRef warning);
0139 };
0140 
0141 bool fromJSON(const llvm::json::Value &value, TraceGetStateResponse &packet,
0142               llvm::json::Path path);
0143 
0144 llvm::json::Value toJSON(const TraceGetStateResponse &packet);
0145 /// \}
0146 
0147 /// jLLDBTraceGetBinaryData gdb-remote packet
0148 /// \{
0149 struct TraceGetBinaryDataRequest {
0150   /// Tracing technology name, e.g. intel-pt, arm-coresight.
0151   std::string type;
0152   /// Identifier for the data.
0153   std::string kind;
0154   /// Optional tid if the data is related to a thread.
0155   std::optional<lldb::tid_t> tid;
0156   /// Optional core id if the data is related to a cpu core.
0157   std::optional<lldb::cpu_id_t> cpu_id;
0158 };
0159 
0160 bool fromJSON(const llvm::json::Value &value,
0161               lldb_private::TraceGetBinaryDataRequest &packet,
0162               llvm::json::Path path);
0163 
0164 llvm::json::Value toJSON(const lldb_private::TraceGetBinaryDataRequest &packet);
0165 /// \}
0166 
0167 } // namespace lldb_private
0168 
0169 #endif // LLDB_UTILITY_TRACEGDBREMOTEPACKETS_H