Ravitheja Addepally | d5d8d91 | 2017-04-26 08:48:50 +0000 | [diff] [blame] | 1 | //===-- SBTraceOptions.cpp --------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "lldb/API/SBTraceOptions.h" |
| 11 | #include "lldb/API/SBError.h" |
| 12 | #include "lldb/API/SBStructuredData.h" |
| 13 | #include "lldb/Utility/Log.h" |
| 14 | #include "lldb/Core/StructuredDataImpl.h" |
| 15 | #include "lldb/Core/TraceOptions.h" |
| 16 | |
| 17 | using namespace lldb; |
| 18 | using namespace lldb_private; |
| 19 | |
| 20 | SBTraceOptions::SBTraceOptions() { |
| 21 | m_traceoptions_sp.reset(new TraceOptions()); |
| 22 | } |
| 23 | |
| 24 | lldb::TraceType SBTraceOptions::getType() const { |
| 25 | if (m_traceoptions_sp) |
| 26 | return m_traceoptions_sp->getType(); |
| 27 | return lldb::TraceType::eTraceTypeNone; |
| 28 | } |
| 29 | |
| 30 | uint64_t SBTraceOptions::getTraceBufferSize() const { |
| 31 | if (m_traceoptions_sp) |
| 32 | return m_traceoptions_sp->getTraceBufferSize(); |
| 33 | return 0; |
| 34 | } |
| 35 | |
| 36 | lldb::SBStructuredData SBTraceOptions::getTraceParams(lldb::SBError &error) { |
| 37 | error.Clear(); |
| 38 | const lldb_private::StructuredData::DictionarySP dict_obj = |
| 39 | m_traceoptions_sp->getTraceParams(); |
| 40 | lldb::SBStructuredData structData; |
| 41 | if (dict_obj && structData.m_impl_up) |
| 42 | structData.m_impl_up->SetObjectSP(dict_obj->shared_from_this()); |
| 43 | else |
| 44 | error.SetErrorString("Empty trace params"); |
| 45 | return structData; |
| 46 | } |
| 47 | |
| 48 | uint64_t SBTraceOptions::getMetaDataBufferSize() const { |
| 49 | if (m_traceoptions_sp) |
| 50 | return m_traceoptions_sp->getTraceBufferSize(); |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | void SBTraceOptions::setTraceParams(lldb::SBStructuredData ¶ms) { |
| 55 | if (m_traceoptions_sp && params.m_impl_up) { |
| 56 | StructuredData::ObjectSP obj_sp = params.m_impl_up->GetObjectSP(); |
| 57 | if (obj_sp && obj_sp->GetAsDictionary() != nullptr) |
| 58 | m_traceoptions_sp->setTraceParams( |
| 59 | std::static_pointer_cast<StructuredData::Dictionary>(obj_sp)); |
| 60 | } |
| 61 | return; |
| 62 | } |
| 63 | |
| 64 | void SBTraceOptions::setType(lldb::TraceType type) { |
| 65 | if (m_traceoptions_sp) |
| 66 | m_traceoptions_sp->setType(type); |
| 67 | } |
| 68 | |
| 69 | void SBTraceOptions::setTraceBufferSize(uint64_t size) { |
| 70 | if (m_traceoptions_sp) |
| 71 | m_traceoptions_sp->setTraceBufferSize(size); |
| 72 | } |
| 73 | |
| 74 | void SBTraceOptions::setMetaDataBufferSize(uint64_t size) { |
| 75 | if (m_traceoptions_sp) |
| 76 | m_traceoptions_sp->setMetaDataBufferSize(size); |
| 77 | } |
| 78 | |
| 79 | bool SBTraceOptions::IsValid() { |
| 80 | if (m_traceoptions_sp) |
| 81 | return true; |
| 82 | return false; |
| 83 | } |
| 84 | |
| 85 | void SBTraceOptions::setThreadID(lldb::tid_t thread_id) { |
| 86 | if (m_traceoptions_sp) |
| 87 | m_traceoptions_sp->setThreadID(thread_id); |
| 88 | } |
| 89 | |
| 90 | lldb::tid_t SBTraceOptions::getThreadID() { |
| 91 | if (m_traceoptions_sp) |
| 92 | return m_traceoptions_sp->getThreadID(); |
| 93 | return LLDB_INVALID_THREAD_ID; |
| 94 | } |