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 "../common/TraceJSONStructs.h"
13 #include <intel-pt.h>
14 
15 namespace lldb_private {
16 namespace trace_intel_pt {
17 
18 struct JSONTraceIntelPTCPUInfo {
19   JSONTraceIntelPTCPUInfo() = default;
20 
21   JSONTraceIntelPTCPUInfo(pt_cpu cpu_info) {
22     family = static_cast<int64_t>(cpu_info.family);
23     model = static_cast<int64_t>(cpu_info.model);
24     stepping = static_cast<int64_t>(cpu_info.stepping);
25     vendor = cpu_info.vendor == pcv_intel ? "intel" : "Unknown";
26   }
27 
28   int64_t family;
29   int64_t model;
30   int64_t stepping;
31   std::string vendor;
32 };
33 
34 struct JSONTraceIntelPTTrace {
35   std::string type;
36   JSONTraceIntelPTCPUInfo cpuInfo;
37 };
38 
39 struct JSONTraceIntelPTSession {
40   JSONTraceIntelPTTrace ipt_trace;
41   JSONTraceSessionBase session_base;
42 };
43 
44 struct JSONTraceIntelPTSettings : JSONTracePluginSettings {
45   JSONTraceIntelPTCPUInfo cpuInfo;
46 };
47 
48 } // namespace trace_intel_pt
49 } // namespace lldb_private
50 
51 namespace llvm {
52 namespace json {
53 
54 bool fromJSON(
55     const Value &value,
56     lldb_private::trace_intel_pt::JSONTraceIntelPTSettings &plugin_settings,
57     Path path);
58 
59 bool fromJSON(const llvm::json::Value &value,
60               lldb_private::trace_intel_pt::JSONTraceIntelPTCPUInfo &packet,
61               llvm::json::Path path);
62 
63 llvm::json::Value
64 toJSON(const lldb_private::trace_intel_pt::JSONTraceIntelPTCPUInfo &cpu_info);
65 
66 llvm::json::Value
67 toJSON(const lldb_private::trace_intel_pt::JSONTraceIntelPTTrace &trace);
68 
69 llvm::json::Value
70 toJSON(const lldb_private::trace_intel_pt::JSONTraceIntelPTSession &session);
71 
72 } // namespace json
73 } // namespace llvm
74 
75 #endif // LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTJSONSTRUCTS_H
76