[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / lldb / source / API / SBTraceOptions.cpp
bloba24cdd59af0bf09ab81aef9d19f1e693bf7b479a
1 //===-- SBTraceOptions.cpp --------------------------------------*- 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 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBTraceOptions.h"
10 #include "SBReproducerPrivate.h"
11 #include "lldb/API/SBError.h"
12 #include "lldb/API/SBStructuredData.h"
13 #include "lldb/Core/StructuredDataImpl.h"
14 #include "lldb/Utility/Log.h"
15 #include "lldb/Utility/TraceOptions.h"
17 #include <memory>
19 using namespace lldb;
20 using namespace lldb_private;
22 SBTraceOptions::SBTraceOptions() {
23 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTraceOptions);
25 m_traceoptions_sp = std::make_shared<TraceOptions>();
28 lldb::TraceType SBTraceOptions::getType() const {
29 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::TraceType, SBTraceOptions, getType);
31 if (m_traceoptions_sp)
32 return m_traceoptions_sp->getType();
33 return lldb::TraceType::eTraceTypeNone;
36 uint64_t SBTraceOptions::getTraceBufferSize() const {
37 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint64_t, SBTraceOptions,
38 getTraceBufferSize);
40 if (m_traceoptions_sp)
41 return m_traceoptions_sp->getTraceBufferSize();
42 return 0;
45 lldb::SBStructuredData SBTraceOptions::getTraceParams(lldb::SBError &error) {
46 LLDB_RECORD_METHOD(lldb::SBStructuredData, SBTraceOptions, getTraceParams,
47 (lldb::SBError &), error);
49 error.Clear();
50 const lldb_private::StructuredData::DictionarySP dict_obj =
51 m_traceoptions_sp->getTraceParams();
52 lldb::SBStructuredData structData;
53 if (dict_obj && structData.m_impl_up)
54 structData.m_impl_up->SetObjectSP(dict_obj->shared_from_this());
55 else
56 error.SetErrorString("Empty trace params");
57 return LLDB_RECORD_RESULT(structData);
60 uint64_t SBTraceOptions::getMetaDataBufferSize() const {
61 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint64_t, SBTraceOptions,
62 getMetaDataBufferSize);
64 if (m_traceoptions_sp)
65 return m_traceoptions_sp->getTraceBufferSize();
66 return 0;
69 void SBTraceOptions::setTraceParams(lldb::SBStructuredData &params) {
70 LLDB_RECORD_METHOD(void, SBTraceOptions, setTraceParams,
71 (lldb::SBStructuredData &), params);
73 if (m_traceoptions_sp && params.m_impl_up) {
74 StructuredData::ObjectSP obj_sp = params.m_impl_up->GetObjectSP();
75 if (obj_sp && obj_sp->GetAsDictionary() != nullptr)
76 m_traceoptions_sp->setTraceParams(
77 std::static_pointer_cast<StructuredData::Dictionary>(obj_sp));
79 return;
82 void SBTraceOptions::setType(lldb::TraceType type) {
83 LLDB_RECORD_METHOD(void, SBTraceOptions, setType, (lldb::TraceType), type);
85 if (m_traceoptions_sp)
86 m_traceoptions_sp->setType(type);
89 void SBTraceOptions::setTraceBufferSize(uint64_t size) {
90 LLDB_RECORD_METHOD(void, SBTraceOptions, setTraceBufferSize, (uint64_t),
91 size);
93 if (m_traceoptions_sp)
94 m_traceoptions_sp->setTraceBufferSize(size);
97 void SBTraceOptions::setMetaDataBufferSize(uint64_t size) {
98 LLDB_RECORD_METHOD(void, SBTraceOptions, setMetaDataBufferSize, (uint64_t),
99 size);
101 if (m_traceoptions_sp)
102 m_traceoptions_sp->setMetaDataBufferSize(size);
105 bool SBTraceOptions::IsValid() {
106 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTraceOptions, IsValid);
107 return this->operator bool();
109 SBTraceOptions::operator bool() const {
110 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTraceOptions, operator bool);
112 if (m_traceoptions_sp)
113 return true;
114 return false;
117 void SBTraceOptions::setThreadID(lldb::tid_t thread_id) {
118 LLDB_RECORD_METHOD(void, SBTraceOptions, setThreadID, (lldb::tid_t),
119 thread_id);
121 if (m_traceoptions_sp)
122 m_traceoptions_sp->setThreadID(thread_id);
125 lldb::tid_t SBTraceOptions::getThreadID() {
126 LLDB_RECORD_METHOD_NO_ARGS(lldb::tid_t, SBTraceOptions, getThreadID);
128 if (m_traceoptions_sp)
129 return m_traceoptions_sp->getThreadID();
130 return LLDB_INVALID_THREAD_ID;
133 namespace lldb_private {
134 namespace repro {
136 template <>
137 void RegisterMethods<SBTraceOptions>(Registry &R) {
138 LLDB_REGISTER_CONSTRUCTOR(SBTraceOptions, ());
139 LLDB_REGISTER_METHOD_CONST(lldb::TraceType, SBTraceOptions, getType, ());
140 LLDB_REGISTER_METHOD_CONST(uint64_t, SBTraceOptions, getTraceBufferSize,
141 ());
142 LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBTraceOptions, getTraceParams,
143 (lldb::SBError &));
144 LLDB_REGISTER_METHOD_CONST(uint64_t, SBTraceOptions, getMetaDataBufferSize,
145 ());
146 LLDB_REGISTER_METHOD(void, SBTraceOptions, setTraceParams,
147 (lldb::SBStructuredData &));
148 LLDB_REGISTER_METHOD(void, SBTraceOptions, setType, (lldb::TraceType));
149 LLDB_REGISTER_METHOD(void, SBTraceOptions, setTraceBufferSize, (uint64_t));
150 LLDB_REGISTER_METHOD(void, SBTraceOptions, setMetaDataBufferSize,
151 (uint64_t));
152 LLDB_REGISTER_METHOD(bool, SBTraceOptions, IsValid, ());
153 LLDB_REGISTER_METHOD_CONST(bool, SBTraceOptions, operator bool, ());
154 LLDB_REGISTER_METHOD(void, SBTraceOptions, setThreadID, (lldb::tid_t));
155 LLDB_REGISTER_METHOD(lldb::tid_t, SBTraceOptions, getThreadID, ());