blob: a041f740bc039a4bfbe052594a03a6a81ca192a4 [file] [log] [blame]
Ravitheja Addepallyd5d8d912017-04-26 08:48:50 +00001//===-- SBTraceOptions.cpp --------------------------------------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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 Addepallyd5d8d912017-04-26 08:48:50 +00006//
7//===----------------------------------------------------------------------===//
8
9#include "lldb/API/SBTraceOptions.h"
10#include "lldb/API/SBError.h"
11#include "lldb/API/SBStructuredData.h"
Ravitheja Addepallyd5d8d912017-04-26 08:48:50 +000012#include "lldb/Core/StructuredDataImpl.h"
Pavel Labath38d06322017-06-29 14:32:17 +000013#include "lldb/Utility/Log.h"
14#include "lldb/Utility/TraceOptions.h"
Ravitheja Addepallyd5d8d912017-04-26 08:48:50 +000015
16using namespace lldb;
17using namespace lldb_private;
18
19SBTraceOptions::SBTraceOptions() {
20 m_traceoptions_sp.reset(new TraceOptions());
21}
22
23lldb::TraceType SBTraceOptions::getType() const {
24 if (m_traceoptions_sp)
25 return m_traceoptions_sp->getType();
26 return lldb::TraceType::eTraceTypeNone;
27}
28
29uint64_t SBTraceOptions::getTraceBufferSize() const {
30 if (m_traceoptions_sp)
31 return m_traceoptions_sp->getTraceBufferSize();
32 return 0;
33}
34
35lldb::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
47uint64_t SBTraceOptions::getMetaDataBufferSize() const {
48 if (m_traceoptions_sp)
49 return m_traceoptions_sp->getTraceBufferSize();
50 return 0;
51}
52
53void SBTraceOptions::setTraceParams(lldb::SBStructuredData &params) {
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
63void SBTraceOptions::setType(lldb::TraceType type) {
64 if (m_traceoptions_sp)
65 m_traceoptions_sp->setType(type);
66}
67
68void SBTraceOptions::setTraceBufferSize(uint64_t size) {
69 if (m_traceoptions_sp)
70 m_traceoptions_sp->setTraceBufferSize(size);
71}
72
73void SBTraceOptions::setMetaDataBufferSize(uint64_t size) {
74 if (m_traceoptions_sp)
75 m_traceoptions_sp->setMetaDataBufferSize(size);
76}
77
78bool SBTraceOptions::IsValid() {
79 if (m_traceoptions_sp)
80 return true;
81 return false;
82}
83
84void SBTraceOptions::setThreadID(lldb::tid_t thread_id) {
85 if (m_traceoptions_sp)
86 m_traceoptions_sp->setThreadID(thread_id);
87}
88
89lldb::tid_t SBTraceOptions::getThreadID() {
90 if (m_traceoptions_sp)
91 return m_traceoptions_sp->getThreadID();
92 return LLDB_INVALID_THREAD_ID;
93}