brintos

brintos / llvm-project-archived public Read only

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