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