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 
12 #include "lldb/lldb-types.h"
13 
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 {
27  llvm::Optional<std::string> file;
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 {
48 };
49 
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
lldb_private::trace_intel_pt::JSONTraceBundleDescription::cpu_info
pt_cpu cpu_info
Definition: TraceIntelPTJSONStructs.h:52
lldb_private::trace_intel_pt::fromJSON
bool fromJSON(const json::Value &value, JSONModule &module, Path path)
Definition: TraceIntelPTJSONStructs.cpp:43
lldb_private::trace_intel_pt::JSONProcess::pid
uint64_t pid
Definition: TraceIntelPTJSONStructs.h:38
lldb_private::trace_intel_pt::toJSON
json::Value toJSON(const JSONModule &module)
Definition: TraceIntelPTJSONStructs.cpp:32
lldb_private::trace_intel_pt::JSONModule
Definition: TraceIntelPTJSONStructs.h:25
lldb_private::trace_intel_pt::JSONProcess::threads
std::vector< JSONThread > threads
Definition: TraceIntelPTJSONStructs.h:40
lldb_private::trace_intel_pt::JSONTraceBundleDescription::cpus
llvm::Optional< std::vector< JSONCpu > > cpus
Definition: TraceIntelPTJSONStructs.h:54
lldb_private::trace_intel_pt::JSONThread::tid
uint64_t tid
Definition: TraceIntelPTJSONStructs.h:33
TraceIntelPTGDBRemotePackets.h
lldb_private::trace_intel_pt::JSONModule::file
llvm::Optional< std::string > file
Definition: TraceIntelPTJSONStructs.h:27
lldb_private::trace_intel_pt::JSONThread
Definition: TraceIntelPTJSONStructs.h:32
lldb_private::trace_intel_pt::JSONModule::load_address
JSONUINT64 load_address
Definition: TraceIntelPTJSONStructs.h:28
lldb_private::trace_intel_pt::JSONCpu::ipt_trace
std::string ipt_trace
Definition: TraceIntelPTJSONStructs.h:46
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::trace_intel_pt::JSONTraceBundleDescription::processes
std::vector< JSONProcess > processes
Definition: TraceIntelPTJSONStructs.h:53
lldb-types.h
lldb_private::trace_intel_pt::JSONCpu
Definition: TraceIntelPTJSONStructs.h:44
lldb_private::trace_intel_pt::JSONCpu::context_switch_trace
std::string context_switch_trace
Definition: TraceIntelPTJSONStructs.h:47
lldb_private::trace_intel_pt::JSONThread::ipt_trace
llvm::Optional< std::string > ipt_trace
Definition: TraceIntelPTJSONStructs.h:34
uint32_t
lldb_private::trace_intel_pt::JSONProcess::triple
llvm::Optional< std::string > triple
Definition: TraceIntelPTJSONStructs.h:39
lldb_private::trace_intel_pt::JSONTraceBundleDescription
Definition: TraceIntelPTJSONStructs.h:50
lldb_private::trace_intel_pt::JSONModule::uuid
llvm::Optional< std::string > uuid
Definition: TraceIntelPTJSONStructs.h:29
lldb_private::trace_intel_pt::JSONTraceBundleDescription::type
std::string type
Definition: TraceIntelPTJSONStructs.h:51
lldb_private::trace_intel_pt::JSONTraceBundleDescription::tsc_perf_zero_conversion
llvm::Optional< LinuxPerfZeroTscConversion > tsc_perf_zero_conversion
Definition: TraceIntelPTJSONStructs.h:55
lldb_private::trace_intel_pt::JSONTraceBundleDescription::GetCpuIds
llvm::Optional< std::vector< lldb::cpu_id_t > > GetCpuIds()
Definition: TraceIntelPTJSONStructs.cpp:23
lldb_private::trace_intel_pt::JSONProcess::modules
std::vector< JSONModule > modules
Definition: TraceIntelPTJSONStructs.h:41
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::trace_intel_pt::JSONCpu::id
lldb::cpu_id_t id
Definition: TraceIntelPTJSONStructs.h:45
lldb_private::JSONUINT64
Helper structure to help parse long numbers that can't be easily represented by a JSON number that is...
Definition: TraceIntelPTGDBRemotePackets.h:67
lldb_private::trace_intel_pt::JSONModule::system_path
std::string system_path
Definition: TraceIntelPTJSONStructs.h:26
lldb_private::trace_intel_pt::JSONProcess
Definition: TraceIntelPTJSONStructs.h:37