blob: f125f55e7a0e1619c2b0fb66d4363a8ef8c50be1 [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- SBCommandInterpreter.cpp --------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "lldb/lldb-types.h"
Chris Lattner24943d22010-06-08 16:52:24 +000011#include "lldb/Core/SourceManager.h"
12#include "lldb/Core/Listener.h"
13#include "lldb/Interpreter/CommandInterpreter.h"
Enrico Granata6d101882012-09-28 23:57:51 +000014#include "lldb/Interpreter/CommandObjectMultiword.h"
Chris Lattner24943d22010-06-08 16:52:24 +000015#include "lldb/Interpreter/CommandReturnObject.h"
16#include "lldb/Target/Target.h"
17
Eli Friedmand6ec8aa2010-06-09 07:37:52 +000018#include "lldb/API/SBBroadcaster.h"
Eli Friedmand6ec8aa2010-06-09 07:37:52 +000019#include "lldb/API/SBCommandReturnObject.h"
Eli Friedmand6ec8aa2010-06-09 07:37:52 +000020#include "lldb/API/SBCommandInterpreter.h"
21#include "lldb/API/SBProcess.h"
22#include "lldb/API/SBTarget.h"
23#include "lldb/API/SBListener.h"
Caroline Tice7826c882010-10-26 03:11:13 +000024#include "lldb/API/SBStream.h"
Eli Friedmand6ec8aa2010-06-09 07:37:52 +000025#include "lldb/API/SBStringList.h"
Chris Lattner24943d22010-06-08 16:52:24 +000026
27using namespace lldb;
28using namespace lldb_private;
29
Enrico Granata6d101882012-09-28 23:57:51 +000030class CommandPluginInterfaceImplementation : public CommandObjectParsed
31{
32public:
33 CommandPluginInterfaceImplementation (CommandInterpreter &interpreter,
34 const char *name,
35 lldb::SBCommandPluginInterface* backend,
36 const char *help = NULL,
37 const char *syntax = NULL,
38 uint32_t flags = 0) :
39 CommandObjectParsed (interpreter, name, help, syntax, flags),
40 m_backend(backend) {}
41
42 virtual bool
43 IsRemovable() { return true; }
44
45protected:
46 virtual bool
47 DoExecute (Args& command, CommandReturnObject &result)
48 {
49 SBCommandReturnObject sb_return(&result);
50 SBCommandInterpreter sb_interpreter(&m_interpreter);
51 SBDebugger debugger_sb(m_interpreter.GetDebugger().shared_from_this());
52 bool ret = m_backend->DoExecute (debugger_sb,(char**)command.GetArgumentVector(), sb_return);
53 sb_return.Release();
54 return ret;
55 }
56 lldb::SBCommandPluginInterface* m_backend;
57};
Chris Lattner24943d22010-06-08 16:52:24 +000058
Greg Clayton63094e02010-06-23 01:19:29 +000059SBCommandInterpreter::SBCommandInterpreter (CommandInterpreter *interpreter) :
60 m_opaque_ptr (interpreter)
Chris Lattner24943d22010-06-08 16:52:24 +000061{
Greg Claytone005f2c2010-11-06 01:53:30 +000062 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +000063
64 if (log)
Greg Claytona66ba462010-10-30 04:51:46 +000065 log->Printf ("SBCommandInterpreter::SBCommandInterpreter (interpreter=%p)"
66 " => SBCommandInterpreter(%p)", interpreter, m_opaque_ptr);
Chris Lattner24943d22010-06-08 16:52:24 +000067}
68
Greg Clayton538eb822010-11-05 23:17:00 +000069SBCommandInterpreter::SBCommandInterpreter(const SBCommandInterpreter &rhs) :
70 m_opaque_ptr (rhs.m_opaque_ptr)
71{
72}
73
74const SBCommandInterpreter &
75SBCommandInterpreter::operator = (const SBCommandInterpreter &rhs)
76{
77 m_opaque_ptr = rhs.m_opaque_ptr;
78 return *this;
79}
80
Chris Lattner24943d22010-06-08 16:52:24 +000081SBCommandInterpreter::~SBCommandInterpreter ()
82{
83}
84
85bool
Greg Clayton63094e02010-06-23 01:19:29 +000086SBCommandInterpreter::IsValid() const
87{
88 return m_opaque_ptr != NULL;
89}
90
91
92bool
Chris Lattner24943d22010-06-08 16:52:24 +000093SBCommandInterpreter::CommandExists (const char *cmd)
94{
Johnny Chenbab8cc92011-12-19 21:16:29 +000095 if (cmd && m_opaque_ptr)
Greg Clayton63094e02010-06-23 01:19:29 +000096 return m_opaque_ptr->CommandExists (cmd);
97 return false;
Chris Lattner24943d22010-06-08 16:52:24 +000098}
99
100bool
101SBCommandInterpreter::AliasExists (const char *cmd)
102{
Johnny Chenbab8cc92011-12-19 21:16:29 +0000103 if (cmd && m_opaque_ptr)
Greg Clayton63094e02010-06-23 01:19:29 +0000104 return m_opaque_ptr->AliasExists (cmd);
105 return false;
Chris Lattner24943d22010-06-08 16:52:24 +0000106}
107
Chris Lattner24943d22010-06-08 16:52:24 +0000108lldb::ReturnStatus
109SBCommandInterpreter::HandleCommand (const char *command_line, SBCommandReturnObject &result, bool add_to_history)
110{
Greg Claytone005f2c2010-11-06 01:53:30 +0000111 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000112
113 if (log)
Greg Clayton49ce6822010-10-31 03:01:06 +0000114 log->Printf ("SBCommandInterpreter(%p)::HandleCommand (command=\"%s\", SBCommandReturnObject(%p), add_to_history=%i)",
115 m_opaque_ptr, command_line, result.get(), add_to_history);
Caroline Tice7826c882010-10-26 03:11:13 +0000116
Chris Lattner24943d22010-06-08 16:52:24 +0000117 result.Clear();
Johnny Chenbab8cc92011-12-19 21:16:29 +0000118 if (command_line && m_opaque_ptr)
Greg Clayton63094e02010-06-23 01:19:29 +0000119 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000120 TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
121 Mutex::Locker api_locker;
122 if (target_sp)
Jim Ingham1b584eb2012-05-04 23:02:50 +0000123 api_locker.Lock(target_sp->GetAPIMutex());
Enrico Granata01bc2d42012-05-31 01:09:06 +0000124 m_opaque_ptr->HandleCommand (command_line, add_to_history ? eLazyBoolYes : eLazyBoolNo, result.ref());
Greg Clayton63094e02010-06-23 01:19:29 +0000125 }
126 else
127 {
Johnny Chenbab8cc92011-12-19 21:16:29 +0000128 result->AppendError ("SBCommandInterpreter or the command line is not valid");
Greg Clayton63094e02010-06-23 01:19:29 +0000129 result->SetStatus (eReturnStatusFailed);
130 }
Caroline Tice7826c882010-10-26 03:11:13 +0000131
Caroline Tice7de24cc2010-10-27 21:23:37 +0000132 // We need to get the value again, in case the command disabled the log!
133 log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
Caroline Tice7826c882010-10-26 03:11:13 +0000134 if (log)
135 {
136 SBStream sstr;
137 result.GetDescription (sstr);
Greg Clayton49ce6822010-10-31 03:01:06 +0000138 log->Printf ("SBCommandInterpreter(%p)::HandleCommand (command=\"%s\", SBCommandReturnObject(%p): %s, add_to_history=%i) => %i",
139 m_opaque_ptr, command_line, result.get(), sstr.GetData(), add_to_history, result.GetStatus());
Caroline Tice7826c882010-10-26 03:11:13 +0000140 }
141
Chris Lattner24943d22010-06-08 16:52:24 +0000142 return result.GetStatus();
143}
144
145int
146SBCommandInterpreter::HandleCompletion (const char *current_line,
147 const char *cursor,
148 const char *last_char,
149 int match_start_point,
150 int max_return_elements,
151 SBStringList &matches)
152{
Jim Inghambc8c4992012-06-26 01:21:59 +0000153 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton63094e02010-06-23 01:19:29 +0000154 int num_completions = 0;
Jim Ingham3cbf8482011-12-05 19:24:15 +0000155
156 // Sanity check the arguments that are passed in:
157 // cursor & last_char have to be within the current_line.
158 if (current_line == NULL || cursor == NULL || last_char == NULL)
159 return 0;
160
161 if (cursor < current_line || last_char < current_line)
162 return 0;
163
164 size_t current_line_size = strlen (current_line);
165 if (cursor - current_line > current_line_size || last_char - current_line > current_line_size)
166 return 0;
167
Jim Inghambc8c4992012-06-26 01:21:59 +0000168 if (log)
Jason Molendaa092d902012-07-17 01:57:24 +0000169 log->Printf ("SBCommandInterpreter(%p)::HandleCompletion (current_line=\"%s\", cursor at: %lld, last char at: %lld, match_start_point: %d, max_return_elements: %d)",
170 m_opaque_ptr, current_line, (uint64_t) (cursor - current_line), (uint64_t) (last_char - current_line), match_start_point, max_return_elements);
Jim Inghambc8c4992012-06-26 01:21:59 +0000171
Greg Clayton63094e02010-06-23 01:19:29 +0000172 if (m_opaque_ptr)
173 {
174 lldb_private::StringList lldb_matches;
175 num_completions = m_opaque_ptr->HandleCompletion (current_line, cursor, last_char, match_start_point,
176 max_return_elements, lldb_matches);
Chris Lattner24943d22010-06-08 16:52:24 +0000177
Greg Clayton63094e02010-06-23 01:19:29 +0000178 SBStringList temp_list (&lldb_matches);
179 matches.AppendList (temp_list);
180 }
Jim Inghambc8c4992012-06-26 01:21:59 +0000181 if (log)
182 log->Printf ("SBCommandInterpreter(%p)::HandleCompletion - Found %d completions.", m_opaque_ptr, num_completions);
183
Chris Lattner24943d22010-06-08 16:52:24 +0000184 return num_completions;
185}
186
Jim Ingham03c8ee52011-09-21 01:17:13 +0000187int
188SBCommandInterpreter::HandleCompletion (const char *current_line,
189 uint32_t cursor_pos,
190 int match_start_point,
191 int max_return_elements,
192 lldb::SBStringList &matches)
193{
194 const char *cursor = current_line + cursor_pos;
195 const char *last_char = current_line + strlen (current_line);
196 return HandleCompletion (current_line, cursor, last_char, match_start_point, max_return_elements, matches);
197}
198
Chris Lattner24943d22010-06-08 16:52:24 +0000199bool
200SBCommandInterpreter::HasCommands ()
201{
Greg Clayton63094e02010-06-23 01:19:29 +0000202 if (m_opaque_ptr)
203 return m_opaque_ptr->HasCommands();
204 return false;
Chris Lattner24943d22010-06-08 16:52:24 +0000205}
206
207bool
208SBCommandInterpreter::HasAliases ()
209{
Greg Clayton63094e02010-06-23 01:19:29 +0000210 if (m_opaque_ptr)
211 return m_opaque_ptr->HasAliases();
212 return false;
Chris Lattner24943d22010-06-08 16:52:24 +0000213}
214
215bool
Chris Lattner24943d22010-06-08 16:52:24 +0000216SBCommandInterpreter::HasAliasOptions ()
217{
Greg Clayton63094e02010-06-23 01:19:29 +0000218 if (m_opaque_ptr)
219 return m_opaque_ptr->HasAliasOptions ();
220 return false;
Chris Lattner24943d22010-06-08 16:52:24 +0000221}
222
Chris Lattner24943d22010-06-08 16:52:24 +0000223SBProcess
224SBCommandInterpreter::GetProcess ()
225{
Greg Clayton334d33a2012-01-30 07:41:31 +0000226 SBProcess sb_process;
227 ProcessSP process_sp;
Greg Clayton63094e02010-06-23 01:19:29 +0000228 if (m_opaque_ptr)
Chris Lattner24943d22010-06-08 16:52:24 +0000229 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000230 TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
231 if (target_sp)
232 {
233 Mutex::Locker api_locker(target_sp->GetAPIMutex());
Greg Clayton334d33a2012-01-30 07:41:31 +0000234 process_sp = target_sp->GetProcessSP();
235 sb_process.SetSP(process_sp);
Greg Claytonbdcda462010-12-20 20:49:23 +0000236 }
Chris Lattner24943d22010-06-08 16:52:24 +0000237 }
Greg Claytone005f2c2010-11-06 01:53:30 +0000238 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytona66ba462010-10-30 04:51:46 +0000239
240 if (log)
241 log->Printf ("SBCommandInterpreter(%p)::GetProcess () => SBProcess(%p)",
Greg Clayton334d33a2012-01-30 07:41:31 +0000242 m_opaque_ptr, process_sp.get());
Greg Claytona66ba462010-10-30 04:51:46 +0000243
244
Greg Clayton334d33a2012-01-30 07:41:31 +0000245 return sb_process;
Chris Lattner24943d22010-06-08 16:52:24 +0000246}
247
Enrico Granata6d101882012-09-28 23:57:51 +0000248SBDebugger
249SBCommandInterpreter::GetDebugger ()
250{
251 SBDebugger sb_debugger;
252 if (m_opaque_ptr)
253 sb_debugger.reset(m_opaque_ptr->GetDebugger().shared_from_this());
254 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
255
256 if (log)
257 log->Printf ("SBCommandInterpreter(%p)::GetDebugger () => SBDebugger(%p)",
258 m_opaque_ptr, sb_debugger.get());
259
260
261 return sb_debugger;
262}
263
Chris Lattner24943d22010-06-08 16:52:24 +0000264CommandInterpreter *
Greg Clayton63094e02010-06-23 01:19:29 +0000265SBCommandInterpreter::get ()
Chris Lattner24943d22010-06-08 16:52:24 +0000266{
Greg Clayton63094e02010-06-23 01:19:29 +0000267 return m_opaque_ptr;
Chris Lattner24943d22010-06-08 16:52:24 +0000268}
269
270CommandInterpreter &
Greg Clayton63094e02010-06-23 01:19:29 +0000271SBCommandInterpreter::ref ()
Chris Lattner24943d22010-06-08 16:52:24 +0000272{
Greg Clayton63094e02010-06-23 01:19:29 +0000273 assert (m_opaque_ptr);
274 return *m_opaque_ptr;
275}
276
277void
278SBCommandInterpreter::reset (lldb_private::CommandInterpreter *interpreter)
279{
280 m_opaque_ptr = interpreter;
Chris Lattner24943d22010-06-08 16:52:24 +0000281}
282
283void
284SBCommandInterpreter::SourceInitFileInHomeDirectory (SBCommandReturnObject &result)
285{
286 result.Clear();
Greg Clayton63094e02010-06-23 01:19:29 +0000287 if (m_opaque_ptr)
288 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000289 TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
290 Mutex::Locker api_locker;
291 if (target_sp)
Jim Ingham1b584eb2012-05-04 23:02:50 +0000292 api_locker.Lock(target_sp->GetAPIMutex());
Greg Clayton63094e02010-06-23 01:19:29 +0000293 m_opaque_ptr->SourceInitFile (false, result.ref());
294 }
295 else
296 {
297 result->AppendError ("SBCommandInterpreter is not valid");
298 result->SetStatus (eReturnStatusFailed);
299 }
Greg Claytone005f2c2010-11-06 01:53:30 +0000300 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytona66ba462010-10-30 04:51:46 +0000301
302 if (log)
303 log->Printf ("SBCommandInterpreter(%p)::SourceInitFileInHomeDirectory (&SBCommandReturnObject(%p))",
304 m_opaque_ptr, result.get());
305
Chris Lattner24943d22010-06-08 16:52:24 +0000306}
307
308void
309SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory (SBCommandReturnObject &result)
310{
311 result.Clear();
Greg Clayton63094e02010-06-23 01:19:29 +0000312 if (m_opaque_ptr)
313 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000314 TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
315 Mutex::Locker api_locker;
316 if (target_sp)
Jim Ingham1b584eb2012-05-04 23:02:50 +0000317 api_locker.Lock(target_sp->GetAPIMutex());
Greg Clayton63094e02010-06-23 01:19:29 +0000318 m_opaque_ptr->SourceInitFile (true, result.ref());
319 }
320 else
321 {
322 result->AppendError ("SBCommandInterpreter is not valid");
323 result->SetStatus (eReturnStatusFailed);
324 }
Greg Claytone005f2c2010-11-06 01:53:30 +0000325 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytona66ba462010-10-30 04:51:46 +0000326
327 if (log)
328 log->Printf ("SBCommandInterpreter(%p)::SourceInitFileInCurrentWorkingDirectory (&SBCommandReturnObject(%p))",
329 m_opaque_ptr, result.get());
Chris Lattner24943d22010-06-08 16:52:24 +0000330}
331
332SBBroadcaster
333SBCommandInterpreter::GetBroadcaster ()
334{
Greg Claytone005f2c2010-11-06 01:53:30 +0000335 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000336
Greg Clayton63094e02010-06-23 01:19:29 +0000337 SBBroadcaster broadcaster (m_opaque_ptr, false);
Caroline Tice7826c882010-10-26 03:11:13 +0000338
339 if (log)
Greg Claytona66ba462010-10-30 04:51:46 +0000340 log->Printf ("SBCommandInterpreter(%p)::GetBroadcaster() => SBBroadcaster(%p)",
Caroline Tice61ba7ec2010-10-26 23:49:36 +0000341 m_opaque_ptr, broadcaster.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000342
Chris Lattner24943d22010-06-08 16:52:24 +0000343 return broadcaster;
344}
345
Jim Ingham5a15e692012-02-16 06:50:00 +0000346const char *
347SBCommandInterpreter::GetBroadcasterClass ()
348{
349 return Communication::GetStaticBroadcasterClass().AsCString();
350}
351
Greg Claytonaa378b12011-02-20 02:15:07 +0000352const char *
353SBCommandInterpreter::GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type)
354{
355 return CommandObject::GetArgumentTypeAsCString (arg_type);
356}
357
358const char *
359SBCommandInterpreter::GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type)
360{
361 return CommandObject::GetArgumentDescriptionAsCString (arg_type);
362}
363
Greg Claytonf1252502012-02-29 04:21:24 +0000364bool
365SBCommandInterpreter::SetCommandOverrideCallback (const char *command_name,
366 lldb::CommandOverrideCallback callback,
367 void *baton)
368{
369 if (command_name && command_name[0] && m_opaque_ptr)
370 {
Greg Clayton5f2b9262012-05-08 04:29:20 +0000371 std::string command_name_str (command_name);
372 CommandObject *cmd_obj = m_opaque_ptr->GetCommandObjectForCommand(command_name_str);
Greg Claytonf1252502012-02-29 04:21:24 +0000373 if (cmd_obj)
374 {
Greg Clayton5f2b9262012-05-08 04:29:20 +0000375 assert(command_name_str.empty());
Greg Claytonf1252502012-02-29 04:21:24 +0000376 cmd_obj->SetOverrideCallback (callback, baton);
377 return true;
378 }
379 }
380 return false;
381}
Greg Claytonaa378b12011-02-20 02:15:07 +0000382
Greg Clayton3e4238d2011-11-04 03:34:56 +0000383#ifndef LLDB_DISABLE_PYTHON
Enrico Granatac2a28252011-08-16 16:49:25 +0000384
Greg Clayton3e4238d2011-11-04 03:34:56 +0000385// Defined in the SWIG source file
386extern "C" void
387init_lldb(void);
388
Greg Clayton3e4238d2011-11-04 03:34:56 +0000389#else
Enrico Granatac2a28252011-08-16 16:49:25 +0000390
Greg Claytone86cbb92011-03-22 01:14:58 +0000391extern "C" void init_lldb(void);
392
Greg Clayton3e4238d2011-11-04 03:34:56 +0000393// Usually defined in the SWIG source file, but we have sripting disabled
394extern "C" void
395init_lldb(void)
396{
397}
398
399#endif
400
Greg Claytone86cbb92011-03-22 01:14:58 +0000401void
402SBCommandInterpreter::InitializeSWIG ()
403{
404 static bool g_initialized = false;
405 if (!g_initialized)
406 {
407 g_initialized = true;
Greg Clayton3e4238d2011-11-04 03:34:56 +0000408#ifndef LLDB_DISABLE_PYTHON
Enrico Granata1328b142012-02-29 03:28:49 +0000409 ScriptInterpreter::InitializeInterpreter (init_lldb);
Greg Clayton3e4238d2011-11-04 03:34:56 +0000410#endif
Greg Claytone86cbb92011-03-22 01:14:58 +0000411 }
412}
Greg Claytonf1252502012-02-29 04:21:24 +0000413
Enrico Granata6d101882012-09-28 23:57:51 +0000414lldb::SBCommand
415SBCommandInterpreter::AddMultiwordCommand (const char* name, const char* help)
416{
417 CommandObjectMultiword *new_command = new CommandObjectMultiword(*m_opaque_ptr,name,help);
418 new_command->SetRemovable (true);
419 lldb::CommandObjectSP new_command_sp(new_command);
420 if (new_command_sp && m_opaque_ptr->AddUserCommand(name, new_command_sp, true))
421 return lldb::SBCommand(new_command_sp);
422 return lldb::SBCommand();
423}
424
425lldb::SBCommand
426SBCommandInterpreter::AddCommand (const char* name, lldb::SBCommandPluginInterface* impl, const char* help)
427{
428 lldb::CommandObjectSP new_command_sp;
429 new_command_sp.reset(new CommandPluginInterfaceImplementation(*m_opaque_ptr,name,impl,help));
430
431 if (new_command_sp && m_opaque_ptr->AddUserCommand(name, new_command_sp, true))
432 return lldb::SBCommand(new_command_sp);
433 return lldb::SBCommand();
434}
435
436SBCommand::SBCommand ()
437{}
438
439SBCommand::SBCommand (lldb::CommandObjectSP cmd_sp) : m_opaque_sp (cmd_sp)
440{}
441
442bool
443SBCommand::IsValid ()
444{
445 return (bool)m_opaque_sp;
446}
447
448const char*
449SBCommand::GetName ()
450{
451 if (IsValid ())
452 return m_opaque_sp->GetCommandName ();
453 return NULL;
454}
455
456const char*
457SBCommand::GetHelp ()
458{
459 if (IsValid ())
460 return m_opaque_sp->GetHelp ();
461 return NULL;
462}
463
464lldb::SBCommand
465SBCommand::AddMultiwordCommand (const char* name, const char* help)
466{
467 if (!IsValid ())
468 return lldb::SBCommand();
469 if (m_opaque_sp->IsMultiwordObject() == false)
470 return lldb::SBCommand();
471 CommandObjectMultiword *new_command = new CommandObjectMultiword(m_opaque_sp->GetCommandInterpreter(),name,help);
472 new_command->SetRemovable (true);
473 lldb::CommandObjectSP new_command_sp(new_command);
474 if (new_command_sp && m_opaque_sp->LoadSubCommand(name,new_command_sp))
475 return lldb::SBCommand(new_command_sp);
476 return lldb::SBCommand();
477}
478
479lldb::SBCommand
480SBCommand::AddCommand (const char* name, lldb::SBCommandPluginInterface *impl, const char* help)
481{
482 if (!IsValid ())
483 return lldb::SBCommand();
484 if (m_opaque_sp->IsMultiwordObject() == false)
485 return lldb::SBCommand();
486 lldb::CommandObjectSP new_command_sp;
487 new_command_sp.reset(new CommandPluginInterfaceImplementation(m_opaque_sp->GetCommandInterpreter(),name,impl,help));
488 if (new_command_sp && m_opaque_sp->LoadSubCommand(name,new_command_sp))
489 return lldb::SBCommand(new_command_sp);
490 return lldb::SBCommand();
491}
492