LLDB  mainline
SBTraceOptions.cpp
Go to the documentation of this file.
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 //===----------------------------------------------------------------------===//
8 
10 #include "SBReproducerPrivate.h"
11 #include "lldb/API/SBError.h"
14 #include "lldb/Utility/Log.h"
16 
17 #include <memory>
18 
19 using namespace lldb;
20 using namespace lldb_private;
21 
24 
25  m_traceoptions_sp = std::make_shared<TraceOptions>();
26 }
27 
30 
31  if (m_traceoptions_sp)
32  return m_traceoptions_sp->getType();
34 }
35 
38  getTraceBufferSize);
39 
40  if (m_traceoptions_sp)
41  return m_traceoptions_sp->getTraceBufferSize();
42  return 0;
43 }
44 
47  (lldb::SBError &), error);
48 
49  error.Clear();
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);
58 }
59 
62  getMetaDataBufferSize);
63 
64  if (m_traceoptions_sp)
65  return m_traceoptions_sp->getTraceBufferSize();
66  return 0;
67 }
68 
70  LLDB_RECORD_METHOD(void, SBTraceOptions, setTraceParams,
71  (lldb::SBStructuredData &), params);
72 
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));
78  }
79  return;
80 }
81 
83  LLDB_RECORD_METHOD(void, SBTraceOptions, setType, (lldb::TraceType), type);
84 
85  if (m_traceoptions_sp)
86  m_traceoptions_sp->setType(type);
87 }
88 
90  LLDB_RECORD_METHOD(void, SBTraceOptions, setTraceBufferSize, (uint64_t),
91  size);
92 
93  if (m_traceoptions_sp)
94  m_traceoptions_sp->setTraceBufferSize(size);
95 }
96 
98  LLDB_RECORD_METHOD(void, SBTraceOptions, setMetaDataBufferSize, (uint64_t),
99  size);
100 
101  if (m_traceoptions_sp)
102  m_traceoptions_sp->setMetaDataBufferSize(size);
103 }
104 
107  return this->operator bool();
108 }
109 SBTraceOptions::operator bool() const {
110  LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTraceOptions, operator bool);
111 
112  if (m_traceoptions_sp)
113  return true;
114  return false;
115 }
116 
118  LLDB_RECORD_METHOD(void, SBTraceOptions, setThreadID, (lldb::tid_t),
119  thread_id);
120 
121  if (m_traceoptions_sp)
122  m_traceoptions_sp->setThreadID(thread_id);
123 }
124 
127 
128  if (m_traceoptions_sp)
129  return m_traceoptions_sp->getThreadID();
130  return LLDB_INVALID_THREAD_ID;
131 }
132 
133 namespace lldb_private {
134 namespace repro {
135 
136 template <>
140  LLDB_REGISTER_METHOD_CONST(uint64_t, SBTraceOptions, getTraceBufferSize,
141  ());
143  (lldb::SBError &));
144  LLDB_REGISTER_METHOD_CONST(uint64_t, SBTraceOptions, getMetaDataBufferSize,
145  ());
146  LLDB_REGISTER_METHOD(void, SBTraceOptions, setTraceParams,
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));
156 }
157 
158 }
159 }
The registry contains a unique mapping between functions and their ID.
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class)
void setType(lldb::TraceType type)
uint64_t getMetaDataBufferSize() const
lldb::tid_t getThreadID()
void Clear()
Definition: SBError.cpp:47
void SetErrorString(const char *err_str)
Definition: SBError.cpp:124
std::shared_ptr< Dictionary > DictionarySP
lldb::SBStructuredData getTraceParams(lldb::SBError &error)
The trace parameters consist of any custom parameters apart from the generic parameters such as Trace...
void setTraceBufferSize(uint64_t size)
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method)
uint64_t tid_t
Definition: lldb-types.h:86
#define LLDB_RECORD_METHOD(Result, Class, Method, Signature,...)
void setThreadID(lldb::tid_t thread_id)
void RegisterMethods< SBTraceOptions >(Registry &R)
StructuredDataImplUP m_impl_up
#define LLDB_INVALID_THREAD_ID
Definition: lldb-defines.h:93
Definition: SBAddress.h:15
void setTraceParams(lldb::SBStructuredData &params)
SBStructuredData is meant to hold any custom parameters apart from meta buffer size and trace size...
lldb::TraceType getType() const
std::shared_ptr< Object > ObjectSP
#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature)
#define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method)
uint64_t getTraceBufferSize() const
#define LLDB_RECORD_RESULT(Result)
#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)
void setMetaDataBufferSize(uint64_t size)