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