1 //===-- TraceIntelPTJSONStructs.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_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTJSONSTRUCTS_H 10 #define LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTJSONSTRUCTS_H 11 12 #include "lldb/lldb-types.h" 13 14 #include "lldb/Utility/TraceIntelPTGDBRemotePackets.h" 15 16 #include "llvm/ADT/Optional.h" 17 #include "llvm/Support/JSON.h" 18 19 #include <intel-pt.h> 20 #include <vector> 21 22 namespace lldb_private { 23 namespace trace_intel_pt { 24 25 struct JSONModule { 26 std::string system_path; 27 llvm::Optional<std::string> file; 28 JSONUINT64 load_address; 29 llvm::Optional<std::string> uuid; 30 }; 31 32 struct JSONThread { 33 uint64_t tid; 34 llvm::Optional<std::string> ipt_trace; 35 }; 36 37 struct JSONProcess { 38 uint64_t pid; 39 llvm::Optional<std::string> triple; 40 std::vector<JSONThread> threads; 41 std::vector<JSONModule> modules; 42 }; 43 44 struct JSONCpu { 45 lldb::cpu_id_t id; 46 std::string ipt_trace; 47 std::string context_switch_trace; 48 }; 49 50 struct JSONTraceBundleDescription { 51 std::string type; 52 pt_cpu cpu_info; 53 std::vector<JSONProcess> processes; 54 llvm::Optional<std::vector<JSONCpu>> cpus; 55 llvm::Optional<LinuxPerfZeroTscConversion> tsc_perf_zero_conversion; 56 57 llvm::Optional<std::vector<lldb::cpu_id_t>> GetCpuIds(); 58 }; 59 60 llvm::json::Value toJSON(const JSONModule &module); 61 62 llvm::json::Value toJSON(const JSONThread &thread); 63 64 llvm::json::Value toJSON(const JSONProcess &process); 65 66 llvm::json::Value toJSON(const JSONCpu &cpu); 67 68 llvm::json::Value toJSON(const pt_cpu &cpu_info); 69 70 llvm::json::Value toJSON(const JSONTraceBundleDescription &bundle_description); 71 72 bool fromJSON(const llvm::json::Value &value, JSONModule &module, 73 llvm::json::Path path); 74 75 bool fromJSON(const llvm::json::Value &value, JSONThread &thread, 76 llvm::json::Path path); 77 78 bool fromJSON(const llvm::json::Value &value, JSONProcess &process, 79 llvm::json::Path path); 80 81 bool fromJSON(const llvm::json::Value &value, JSONCpu &cpu, 82 llvm::json::Path path); 83 84 bool fromJSON(const llvm::json::Value &value, pt_cpu &cpu_info, 85 llvm::json::Path path); 86 87 bool fromJSON(const llvm::json::Value &value, JSONTraceBundleDescription &bundle_description, 88 llvm::json::Path path); 89 } // namespace trace_intel_pt 90 } // namespace lldb_private 91 92 #endif // LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTJSONSTRUCTS_H 93