1 //===-- TraceIntelPTSessionFileParser.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_TRACEINTELPTSESSIONFILEPARSER_H 10 #define LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTSESSIONFILEPARSER_H 11 12 #include "TraceIntelPT.h" 13 14 #include "../common/TraceSessionFileParser.h" 15 16 namespace lldb_private { 17 namespace trace_intel_pt { 18 19 class TraceIntelPT; 20 21 class TraceIntelPTSessionFileParser : public TraceSessionFileParser { 22 public: 23 struct JSONTraceIntelPTCPUInfo { 24 int64_t family; 25 int64_t model; 26 int64_t stepping; 27 std::string vendor; 28 }; 29 30 struct JSONTraceIntelPTSettings 31 : TraceSessionFileParser::JSONTracePluginSettings { 32 JSONTraceIntelPTCPUInfo cpuInfo; 33 }; 34 35 /// See \a TraceSessionFileParser::TraceSessionFileParser for the description 36 /// of these fields. TraceIntelPTSessionFileParser(Debugger & debugger,const llvm::json::Value & trace_session_file,llvm::StringRef session_file_dir)37 TraceIntelPTSessionFileParser(Debugger &debugger, 38 const llvm::json::Value &trace_session_file, 39 llvm::StringRef session_file_dir) 40 : TraceSessionFileParser(debugger, session_file_dir, GetSchema()), 41 m_trace_session_file(trace_session_file) {} 42 43 /// \return 44 /// The JSON schema for the session data. 45 static llvm::StringRef GetSchema(); 46 47 /// Parse the structured data trace session and create the corresponding \a 48 /// Target objects. In case of an error, no targets are created. 49 /// 50 /// \return 51 /// A \a lldb::TraceSP instance with the trace session data. In case of 52 /// errors, return a null pointer. 53 llvm::Expected<lldb::TraceSP> Parse(); 54 55 lldb::TraceSP 56 CreateTraceIntelPTInstance(const pt_cpu &cpu_info, 57 std::vector<ParsedProcess> &parsed_processes); 58 59 private: 60 static pt_cpu ParsePTCPU(const JSONTraceIntelPTCPUInfo &cpu_info); 61 62 const llvm::json::Value &m_trace_session_file; 63 }; 64 65 } // namespace trace_intel_pt 66 } // namespace lldb_private 67 68 namespace llvm { 69 namespace json { 70 71 bool fromJSON(const Value &value, 72 lldb_private::trace_intel_pt::TraceIntelPTSessionFileParser:: 73 JSONTraceIntelPTSettings &plugin_settings, 74 Path path); 75 76 bool fromJSON(const llvm::json::Value &value, 77 lldb_private::trace_intel_pt::TraceIntelPTSessionFileParser:: 78 JSONTraceIntelPTCPUInfo &packet, 79 llvm::json::Path path); 80 81 llvm::json::Value 82 toJSON(const lldb_private::trace_intel_pt::TraceIntelPTSessionFileParser:: 83 JSONTraceIntelPTCPUInfo &packet); 84 85 } // namespace json 86 } // namespace llvm 87 88 #endif // LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTSESSIONFILEPARSER_H 89