151690af2SDimitry Andric //===-- SBTraceOptions.cpp --------------------------------------*- C++ -*-===// 251690af2SDimitry Andric // 351690af2SDimitry Andric // The LLVM Compiler Infrastructure 451690af2SDimitry Andric // 551690af2SDimitry Andric // This file is distributed under the University of Illinois Open Source 651690af2SDimitry Andric // License. See LICENSE.TXT for details. 751690af2SDimitry Andric // 851690af2SDimitry Andric //===----------------------------------------------------------------------===// 951690af2SDimitry Andric 1051690af2SDimitry Andric #include "lldb/API/SBTraceOptions.h" 1151690af2SDimitry Andric #include "lldb/API/SBError.h" 1251690af2SDimitry Andric #include "lldb/API/SBStructuredData.h" 1351690af2SDimitry Andric #include "lldb/Core/StructuredDataImpl.h" 14*a580b014SDimitry Andric #include "lldb/Utility/Log.h" 15*a580b014SDimitry Andric #include "lldb/Utility/TraceOptions.h" 1651690af2SDimitry Andric 1751690af2SDimitry Andric using namespace lldb; 1851690af2SDimitry Andric using namespace lldb_private; 1951690af2SDimitry Andric SBTraceOptions()2051690af2SDimitry AndricSBTraceOptions::SBTraceOptions() { 2151690af2SDimitry Andric m_traceoptions_sp.reset(new TraceOptions()); 2251690af2SDimitry Andric } 2351690af2SDimitry Andric getType() const2451690af2SDimitry Andriclldb::TraceType SBTraceOptions::getType() const { 2551690af2SDimitry Andric if (m_traceoptions_sp) 2651690af2SDimitry Andric return m_traceoptions_sp->getType(); 2751690af2SDimitry Andric return lldb::TraceType::eTraceTypeNone; 2851690af2SDimitry Andric } 2951690af2SDimitry Andric getTraceBufferSize() const3051690af2SDimitry Andricuint64_t SBTraceOptions::getTraceBufferSize() const { 3151690af2SDimitry Andric if (m_traceoptions_sp) 3251690af2SDimitry Andric return m_traceoptions_sp->getTraceBufferSize(); 3351690af2SDimitry Andric return 0; 3451690af2SDimitry Andric } 3551690af2SDimitry Andric getTraceParams(lldb::SBError & error)3651690af2SDimitry Andriclldb::SBStructuredData SBTraceOptions::getTraceParams(lldb::SBError &error) { 3751690af2SDimitry Andric error.Clear(); 3851690af2SDimitry Andric const lldb_private::StructuredData::DictionarySP dict_obj = 3951690af2SDimitry Andric m_traceoptions_sp->getTraceParams(); 4051690af2SDimitry Andric lldb::SBStructuredData structData; 4151690af2SDimitry Andric if (dict_obj && structData.m_impl_up) 4251690af2SDimitry Andric structData.m_impl_up->SetObjectSP(dict_obj->shared_from_this()); 4351690af2SDimitry Andric else 4451690af2SDimitry Andric error.SetErrorString("Empty trace params"); 4551690af2SDimitry Andric return structData; 4651690af2SDimitry Andric } 4751690af2SDimitry Andric getMetaDataBufferSize() const4851690af2SDimitry Andricuint64_t SBTraceOptions::getMetaDataBufferSize() const { 4951690af2SDimitry Andric if (m_traceoptions_sp) 5051690af2SDimitry Andric return m_traceoptions_sp->getTraceBufferSize(); 5151690af2SDimitry Andric return 0; 5251690af2SDimitry Andric } 5351690af2SDimitry Andric setTraceParams(lldb::SBStructuredData & params)5451690af2SDimitry Andricvoid SBTraceOptions::setTraceParams(lldb::SBStructuredData ¶ms) { 5551690af2SDimitry Andric if (m_traceoptions_sp && params.m_impl_up) { 5651690af2SDimitry Andric StructuredData::ObjectSP obj_sp = params.m_impl_up->GetObjectSP(); 5751690af2SDimitry Andric if (obj_sp && obj_sp->GetAsDictionary() != nullptr) 5851690af2SDimitry Andric m_traceoptions_sp->setTraceParams( 5951690af2SDimitry Andric std::static_pointer_cast<StructuredData::Dictionary>(obj_sp)); 6051690af2SDimitry Andric } 6151690af2SDimitry Andric return; 6251690af2SDimitry Andric } 6351690af2SDimitry Andric setType(lldb::TraceType type)6451690af2SDimitry Andricvoid SBTraceOptions::setType(lldb::TraceType type) { 6551690af2SDimitry Andric if (m_traceoptions_sp) 6651690af2SDimitry Andric m_traceoptions_sp->setType(type); 6751690af2SDimitry Andric } 6851690af2SDimitry Andric setTraceBufferSize(uint64_t size)6951690af2SDimitry Andricvoid SBTraceOptions::setTraceBufferSize(uint64_t size) { 7051690af2SDimitry Andric if (m_traceoptions_sp) 7151690af2SDimitry Andric m_traceoptions_sp->setTraceBufferSize(size); 7251690af2SDimitry Andric } 7351690af2SDimitry Andric setMetaDataBufferSize(uint64_t size)7451690af2SDimitry Andricvoid SBTraceOptions::setMetaDataBufferSize(uint64_t size) { 7551690af2SDimitry Andric if (m_traceoptions_sp) 7651690af2SDimitry Andric m_traceoptions_sp->setMetaDataBufferSize(size); 7751690af2SDimitry Andric } 7851690af2SDimitry Andric IsValid()7951690af2SDimitry Andricbool SBTraceOptions::IsValid() { 8051690af2SDimitry Andric if (m_traceoptions_sp) 8151690af2SDimitry Andric return true; 8251690af2SDimitry Andric return false; 8351690af2SDimitry Andric } 8451690af2SDimitry Andric setThreadID(lldb::tid_t thread_id)8551690af2SDimitry Andricvoid SBTraceOptions::setThreadID(lldb::tid_t thread_id) { 8651690af2SDimitry Andric if (m_traceoptions_sp) 8751690af2SDimitry Andric m_traceoptions_sp->setThreadID(thread_id); 8851690af2SDimitry Andric } 8951690af2SDimitry Andric getThreadID()9051690af2SDimitry Andriclldb::tid_t SBTraceOptions::getThreadID() { 9151690af2SDimitry Andric if (m_traceoptions_sp) 9251690af2SDimitry Andric return m_traceoptions_sp->getThreadID(); 9351690af2SDimitry Andric return LLDB_INVALID_THREAD_ID; 9451690af2SDimitry Andric } 95