1 //===-- SBCommandInterpreterRunOptions.cpp --------------------------------===//
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 
9 #include "lldb/lldb-types.h"
10 
11 #include "SBReproducerPrivate.h"
12 
13 #include "lldb/API/SBCommandInterpreterRunOptions.h"
14 #include "lldb/Interpreter/CommandInterpreter.h"
15 
16 #include <memory>
17 
18 using namespace lldb;
19 using namespace lldb_private;
20 
21 SBCommandInterpreterRunOptions::SBCommandInterpreterRunOptions() {
22   LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommandInterpreterRunOptions);
23 
24   m_opaque_up = std::make_unique<CommandInterpreterRunOptions>();
25 }
26 
27 SBCommandInterpreterRunOptions::SBCommandInterpreterRunOptions(
28     const SBCommandInterpreterRunOptions &rhs)
29     : m_opaque_up() {
30   LLDB_RECORD_CONSTRUCTOR(SBCommandInterpreterRunOptions,
31                           (const lldb::SBCommandInterpreterRunOptions &), rhs);
32 
33   m_opaque_up = std::make_unique<CommandInterpreterRunOptions>(rhs.ref());
34 }
35 
36 SBCommandInterpreterRunOptions::~SBCommandInterpreterRunOptions() = default;
37 
38 SBCommandInterpreterRunOptions &SBCommandInterpreterRunOptions::operator=(
39     const SBCommandInterpreterRunOptions &rhs) {
40   LLDB_RECORD_METHOD(lldb::SBCommandInterpreterRunOptions &,
41                      SBCommandInterpreterRunOptions, operator=,
42                      (const lldb::SBCommandInterpreterRunOptions &), rhs);
43 
44   if (this == &rhs)
45     return LLDB_RECORD_RESULT(*this);
46   *m_opaque_up = *rhs.m_opaque_up;
47   return LLDB_RECORD_RESULT(*this);
48 }
49 
50 bool SBCommandInterpreterRunOptions::GetStopOnContinue() const {
51   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
52                                    GetStopOnContinue);
53 
54   return m_opaque_up->GetStopOnContinue();
55 }
56 
57 void SBCommandInterpreterRunOptions::SetStopOnContinue(bool stop_on_continue) {
58   LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnContinue,
59                      (bool), stop_on_continue);
60 
61   m_opaque_up->SetStopOnContinue(stop_on_continue);
62 }
63 
64 bool SBCommandInterpreterRunOptions::GetStopOnError() const {
65   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
66                                    GetStopOnError);
67 
68   return m_opaque_up->GetStopOnError();
69 }
70 
71 void SBCommandInterpreterRunOptions::SetStopOnError(bool stop_on_error) {
72   LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnError,
73                      (bool), stop_on_error);
74 
75   m_opaque_up->SetStopOnError(stop_on_error);
76 }
77 
78 bool SBCommandInterpreterRunOptions::GetStopOnCrash() const {
79   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
80                                    GetStopOnCrash);
81 
82   return m_opaque_up->GetStopOnCrash();
83 }
84 
85 void SBCommandInterpreterRunOptions::SetStopOnCrash(bool stop_on_crash) {
86   LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnCrash,
87                      (bool), stop_on_crash);
88 
89   m_opaque_up->SetStopOnCrash(stop_on_crash);
90 }
91 
92 bool SBCommandInterpreterRunOptions::GetEchoCommands() const {
93   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
94                                    GetEchoCommands);
95 
96   return m_opaque_up->GetEchoCommands();
97 }
98 
99 void SBCommandInterpreterRunOptions::SetEchoCommands(bool echo_commands) {
100   LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetEchoCommands,
101                      (bool), echo_commands);
102 
103   m_opaque_up->SetEchoCommands(echo_commands);
104 }
105 
106 bool SBCommandInterpreterRunOptions::GetEchoCommentCommands() const {
107   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
108                                    GetEchoCommentCommands);
109 
110   return m_opaque_up->GetEchoCommentCommands();
111 }
112 
113 void SBCommandInterpreterRunOptions::SetEchoCommentCommands(bool echo) {
114   LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions,
115                      SetEchoCommentCommands, (bool), echo);
116 
117   m_opaque_up->SetEchoCommentCommands(echo);
118 }
119 
120 bool SBCommandInterpreterRunOptions::GetPrintResults() const {
121   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
122                                    GetPrintResults);
123 
124   return m_opaque_up->GetPrintResults();
125 }
126 
127 void SBCommandInterpreterRunOptions::SetPrintResults(bool print_results) {
128   LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetPrintResults,
129                      (bool), print_results);
130 
131   m_opaque_up->SetPrintResults(print_results);
132 }
133 
134 bool SBCommandInterpreterRunOptions::GetAddToHistory() const {
135   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
136                                    GetAddToHistory);
137 
138   return m_opaque_up->GetAddToHistory();
139 }
140 
141 void SBCommandInterpreterRunOptions::SetAddToHistory(bool add_to_history) {
142   LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetAddToHistory,
143                      (bool), add_to_history);
144 
145   m_opaque_up->SetAddToHistory(add_to_history);
146 }
147 
148 bool SBCommandInterpreterRunOptions::GetAutoHandleEvents() const {
149   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
150                                    GetAutoHandleEvents);
151 
152   return m_opaque_up->GetAutoHandleEvents();
153 }
154 
155 void SBCommandInterpreterRunOptions::SetAutoHandleEvents(
156     bool auto_handle_events) {
157   LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetAutoHandleEvents,
158                      (bool), auto_handle_events);
159 
160   m_opaque_up->SetAutoHandleEvents(auto_handle_events);
161 }
162 
163 bool SBCommandInterpreterRunOptions::GetSpawnThread() const {
164   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
165                                    GetSpawnThread);
166 
167   return m_opaque_up->GetSpawnThread();
168 }
169 
170 void SBCommandInterpreterRunOptions::SetSpawnThread(bool spawn_thread) {
171   LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetSpawnThread,
172                      (bool), spawn_thread);
173 
174   m_opaque_up->SetSpawnThread(spawn_thread);
175 }
176 
177 lldb_private::CommandInterpreterRunOptions *
178 SBCommandInterpreterRunOptions::get() const {
179   return m_opaque_up.get();
180 }
181 
182 lldb_private::CommandInterpreterRunOptions &
183 SBCommandInterpreterRunOptions::ref() const {
184   return *m_opaque_up;
185 }
186 
187 SBCommandInterpreterRunResult::SBCommandInterpreterRunResult()
188     : m_opaque_up(new CommandInterpreterRunResult())
189 
190 {
191   LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommandInterpreterRunResult);
192 }
193 
194 SBCommandInterpreterRunResult::SBCommandInterpreterRunResult(
195     const SBCommandInterpreterRunResult &rhs)
196     : m_opaque_up(new CommandInterpreterRunResult()) {
197   LLDB_RECORD_CONSTRUCTOR(SBCommandInterpreterRunResult,
198                           (const lldb::SBCommandInterpreterRunResult &), rhs);
199 
200   *m_opaque_up = *rhs.m_opaque_up;
201 }
202 
203 SBCommandInterpreterRunResult::SBCommandInterpreterRunResult(
204     const CommandInterpreterRunResult &rhs)
205     : m_opaque_up() {
206   m_opaque_up = std::make_unique<CommandInterpreterRunResult>(rhs);
207 }
208 
209 SBCommandInterpreterRunResult::~SBCommandInterpreterRunResult() = default;
210 
211 SBCommandInterpreterRunResult &SBCommandInterpreterRunResult::operator=(
212     const SBCommandInterpreterRunResult &rhs) {
213   LLDB_RECORD_METHOD(lldb::SBCommandInterpreterRunResult &,
214                      SBCommandInterpreterRunResult, operator=,
215                      (const lldb::SBCommandInterpreterRunResult &), rhs);
216 
217   if (this == &rhs)
218     return LLDB_RECORD_RESULT(*this);
219   *m_opaque_up = *rhs.m_opaque_up;
220   return LLDB_RECORD_RESULT(*this);
221 }
222 
223 int SBCommandInterpreterRunResult::GetNumberOfErrors() const {
224   LLDB_RECORD_METHOD_CONST_NO_ARGS(int, SBCommandInterpreterRunResult,
225                                    GetNumberOfErrors);
226 
227   return m_opaque_up->GetNumErrors();
228 }
229 
230 lldb::CommandInterpreterResult
231 SBCommandInterpreterRunResult::GetResult() const {
232   LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::CommandInterpreterResult,
233                                    SBCommandInterpreterRunResult, GetResult);
234 
235   return m_opaque_up->GetResult();
236 }
237 
238 namespace lldb_private {
239 namespace repro {
240 
241 template <> void RegisterMethods<SBCommandInterpreterRunOptions>(Registry &R) {
242   LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreterRunOptions, ());
243   LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreterRunOptions,
244                             (const lldb::SBCommandInterpreterRunOptions &));
245   LLDB_REGISTER_METHOD(lldb::SBCommandInterpreterRunOptions &,
246                        SBCommandInterpreterRunOptions, operator=,
247                        (const lldb::SBCommandInterpreterRunOptions &));
248   LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
249                              GetStopOnContinue, ());
250   LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnContinue,
251                        (bool));
252   LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
253                              GetStopOnError, ());
254   LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnError,
255                        (bool));
256   LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
257                              GetStopOnCrash, ());
258   LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnCrash,
259                        (bool));
260   LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
261                              GetEchoCommands, ());
262   LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetEchoCommands,
263                        (bool));
264   LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
265                              GetEchoCommentCommands, ());
266   LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions,
267                        SetEchoCommentCommands, (bool));
268   LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
269                              GetPrintResults, ());
270   LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetPrintResults,
271                        (bool));
272   LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
273                              GetAddToHistory, ());
274   LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetAddToHistory,
275                        (bool));
276   LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
277                              GetAutoHandleEvents, ());
278   LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions,
279                        SetAutoHandleEvents, (bool));
280   LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
281                              GetSpawnThread, ());
282   LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetSpawnThread,
283                        (bool));
284   LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreterRunResult, ());
285   LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreterRunResult,
286                             (const lldb::SBCommandInterpreterRunResult &));
287   LLDB_REGISTER_METHOD(lldb::SBCommandInterpreterRunResult &,
288                        SBCommandInterpreterRunResult, operator=,
289                        (const lldb::SBCommandInterpreterRunResult &));
290   LLDB_REGISTER_METHOD_CONST(int, SBCommandInterpreterRunResult,
291                              GetNumberOfErrors, ());
292   LLDB_REGISTER_METHOD_CONST(lldb::CommandInterpreterResult,
293                              SBCommandInterpreterRunResult, GetResult, ());
294 }
295 
296 } // namespace repro
297 } // namespace lldb_private
298