1 //===-- TraceOptions.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_UTILITY_TRACEOPTIONS_H 10 #define LLDB_UTILITY_TRACEOPTIONS_H 11 12 #include "lldb/lldb-defines.h" 13 #include "lldb/lldb-enumerations.h" 14 15 #include "lldb/Utility/StructuredData.h" 16 17 namespace lldb_private { 18 19 /// This struct represents a tracing technology. 20 struct TraceTypeInfo { 21 /// The name of the technology, e.g. intel-pt or arm-coresight. 22 /// 23 /// In order for a Trace plug-in (see \a lldb_private::Trace.h) to support the 24 /// trace technology given by this struct, it should match its name with this 25 /// field. 26 std::string name; 27 /// A description for the technology. 28 std::string description; 29 }; 30 31 class TraceOptions { 32 public: TraceOptions()33 TraceOptions() : m_trace_params(new StructuredData::Dictionary()) {} 34 getTraceParams()35 const StructuredData::DictionarySP &getTraceParams() const { 36 return m_trace_params; 37 } 38 getType()39 lldb::TraceType getType() const { return m_type; } 40 getTraceBufferSize()41 uint64_t getTraceBufferSize() const { return m_trace_buffer_size; } 42 getMetaDataBufferSize()43 uint64_t getMetaDataBufferSize() const { return m_meta_data_buffer_size; } 44 setTraceParams(const StructuredData::DictionarySP & dict_obj)45 void setTraceParams(const StructuredData::DictionarySP &dict_obj) { 46 m_trace_params = dict_obj; 47 } 48 setType(lldb::TraceType type)49 void setType(lldb::TraceType type) { m_type = type; } 50 setTraceBufferSize(uint64_t size)51 void setTraceBufferSize(uint64_t size) { m_trace_buffer_size = size; } 52 setMetaDataBufferSize(uint64_t size)53 void setMetaDataBufferSize(uint64_t size) { m_meta_data_buffer_size = size; } 54 setThreadID(lldb::tid_t thread_id)55 void setThreadID(lldb::tid_t thread_id) { m_thread_id = thread_id; } 56 getThreadID()57 lldb::tid_t getThreadID() const { return m_thread_id; } 58 59 private: 60 lldb::TraceType m_type; 61 uint64_t m_trace_buffer_size; 62 uint64_t m_meta_data_buffer_size; 63 lldb::tid_t m_thread_id; 64 65 /// m_trace_params is meant to hold any custom parameters 66 /// apart from meta buffer size and trace size. 67 /// The interpretation of such parameters is left to 68 /// the lldb-server. 69 StructuredData::DictionarySP m_trace_params; 70 }; 71 } 72 73 namespace llvm { 74 namespace json { 75 76 bool fromJSON(const Value &value, lldb_private::TraceTypeInfo &info, Path path); 77 78 } // namespace json 79 } // namespace llvm 80 81 #endif // LLDB_UTILITY_TRACEOPTIONS_H 82