1*f6aab3d8Srobert //===-- TraceIntelPTJSONStructs.h -----------------------------*- C++ //-*-===// 2*f6aab3d8Srobert // 3*f6aab3d8Srobert // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*f6aab3d8Srobert // See https://llvm.org/LICENSE.txt for license information. 5*f6aab3d8Srobert // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*f6aab3d8Srobert // 7*f6aab3d8Srobert //===----------------------------------------------------------------------===// 8*f6aab3d8Srobert 9*f6aab3d8Srobert #ifndef LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTJSONSTRUCTS_H 10*f6aab3d8Srobert #define LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTJSONSTRUCTS_H 11*f6aab3d8Srobert 12*f6aab3d8Srobert #include "lldb/Utility/TraceIntelPTGDBRemotePackets.h" 13*f6aab3d8Srobert #include "lldb/lldb-types.h" 14*f6aab3d8Srobert #include "llvm/Support/JSON.h" 15*f6aab3d8Srobert #include <intel-pt.h> 16*f6aab3d8Srobert #include <optional> 17*f6aab3d8Srobert #include <vector> 18*f6aab3d8Srobert 19*f6aab3d8Srobert namespace lldb_private { 20*f6aab3d8Srobert namespace trace_intel_pt { 21*f6aab3d8Srobert 22*f6aab3d8Srobert struct JSONModule { 23*f6aab3d8Srobert std::string system_path; 24*f6aab3d8Srobert std::optional<std::string> file; 25*f6aab3d8Srobert JSONUINT64 load_address; 26*f6aab3d8Srobert std::optional<std::string> uuid; 27*f6aab3d8Srobert }; 28*f6aab3d8Srobert 29*f6aab3d8Srobert struct JSONThread { 30*f6aab3d8Srobert uint64_t tid; 31*f6aab3d8Srobert std::optional<std::string> ipt_trace; 32*f6aab3d8Srobert }; 33*f6aab3d8Srobert 34*f6aab3d8Srobert struct JSONProcess { 35*f6aab3d8Srobert uint64_t pid; 36*f6aab3d8Srobert std::optional<std::string> triple; 37*f6aab3d8Srobert std::vector<JSONThread> threads; 38*f6aab3d8Srobert std::vector<JSONModule> modules; 39*f6aab3d8Srobert }; 40*f6aab3d8Srobert 41*f6aab3d8Srobert struct JSONCpu { 42*f6aab3d8Srobert lldb::cpu_id_t id; 43*f6aab3d8Srobert std::string ipt_trace; 44*f6aab3d8Srobert std::string context_switch_trace; 45*f6aab3d8Srobert }; 46*f6aab3d8Srobert 47*f6aab3d8Srobert struct JSONKernel { 48*f6aab3d8Srobert std::optional<JSONUINT64> load_address; 49*f6aab3d8Srobert std::string file; 50*f6aab3d8Srobert }; 51*f6aab3d8Srobert 52*f6aab3d8Srobert struct JSONTraceBundleDescription { 53*f6aab3d8Srobert std::string type; 54*f6aab3d8Srobert pt_cpu cpu_info; 55*f6aab3d8Srobert std::optional<std::vector<JSONProcess>> processes; 56*f6aab3d8Srobert std::optional<std::vector<JSONCpu>> cpus; 57*f6aab3d8Srobert std::optional<LinuxPerfZeroTscConversion> tsc_perf_zero_conversion; 58*f6aab3d8Srobert std::optional<JSONKernel> kernel; 59*f6aab3d8Srobert 60*f6aab3d8Srobert std::optional<std::vector<lldb::cpu_id_t>> GetCpuIds(); 61*f6aab3d8Srobert }; 62*f6aab3d8Srobert 63*f6aab3d8Srobert llvm::json::Value toJSON(const JSONModule &module); 64*f6aab3d8Srobert 65*f6aab3d8Srobert llvm::json::Value toJSON(const JSONThread &thread); 66*f6aab3d8Srobert 67*f6aab3d8Srobert llvm::json::Value toJSON(const JSONProcess &process); 68*f6aab3d8Srobert 69*f6aab3d8Srobert llvm::json::Value toJSON(const JSONCpu &cpu); 70*f6aab3d8Srobert 71*f6aab3d8Srobert llvm::json::Value toJSON(const pt_cpu &cpu_info); 72*f6aab3d8Srobert 73*f6aab3d8Srobert llvm::json::Value toJSON(const JSONKernel &kernel); 74*f6aab3d8Srobert 75*f6aab3d8Srobert llvm::json::Value toJSON(const JSONTraceBundleDescription &bundle_description); 76*f6aab3d8Srobert 77*f6aab3d8Srobert bool fromJSON(const llvm::json::Value &value, JSONModule &module, 78*f6aab3d8Srobert llvm::json::Path path); 79*f6aab3d8Srobert 80*f6aab3d8Srobert bool fromJSON(const llvm::json::Value &value, JSONThread &thread, 81*f6aab3d8Srobert llvm::json::Path path); 82*f6aab3d8Srobert 83*f6aab3d8Srobert bool fromJSON(const llvm::json::Value &value, JSONProcess &process, 84*f6aab3d8Srobert llvm::json::Path path); 85*f6aab3d8Srobert 86*f6aab3d8Srobert bool fromJSON(const llvm::json::Value &value, JSONCpu &cpu, 87*f6aab3d8Srobert llvm::json::Path path); 88*f6aab3d8Srobert 89*f6aab3d8Srobert bool fromJSON(const llvm::json::Value &value, pt_cpu &cpu_info, 90*f6aab3d8Srobert llvm::json::Path path); 91*f6aab3d8Srobert 92*f6aab3d8Srobert bool fromJSON(const llvm::json::Value &value, JSONModule &kernel, 93*f6aab3d8Srobert llvm::json::Path path); 94*f6aab3d8Srobert 95*f6aab3d8Srobert bool fromJSON(const llvm::json::Value &value, 96*f6aab3d8Srobert JSONTraceBundleDescription &bundle_description, 97*f6aab3d8Srobert llvm::json::Path path); 98*f6aab3d8Srobert } // namespace trace_intel_pt 99*f6aab3d8Srobert } // namespace lldb_private 100*f6aab3d8Srobert 101*f6aab3d8Srobert #endif // LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTJSONSTRUCTS_H 102