LLDB mainline
TraceIntelPTJSONStructs.h
Go to the documentation of this file.
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
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;
26 std::optional<std::string> uuid;
27};
28
29struct JSONThread {
30 uint64_t tid;
31 std::optional<std::string> ipt_trace;
32};
33
35 uint64_t pid;
36 std::optional<std::string> triple;
37 std::vector<JSONThread> threads;
38 std::vector<JSONModule> modules;
39};
40
41struct JSONCpu {
43 std::string ipt_trace;
45};
46
47struct JSONKernel {
48 std::optional<JSONUINT64> load_address;
49 std::string file;
50};
51
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_pt
99} // namespace lldb_private
100
101#endif // LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTJSONSTRUCTS_H
bool fromJSON(const json::Value &value, JSONModule &module, Path path)
json::Value toJSON(const JSONModule &module)
A class that represents a running process on the host machine.
uint32_t cpu_id_t
Definition: lldb-types.h:91
Helper structure to help parse long numbers that can't be easily represented by a JSON number that is...
std::optional< std::vector< lldb::cpu_id_t > > GetCpuIds()
std::optional< LinuxPerfZeroTscConversion > tsc_perf_zero_conversion
std::optional< std::vector< JSONProcess > > processes