summaryrefslogtreecommitdiffstats
path: root/lldb/source/Commands
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Commands')
-rw-r--r--lldb/source/Commands/CommandCompletions.cpp414
-rw-r--r--lldb/source/Commands/CommandObjectCrossref.cpp92
-rw-r--r--lldb/source/Commands/CommandObjectMultiword.cpp263
-rw-r--r--lldb/source/Commands/CommandObjectScript.cpp149
-rw-r--r--lldb/source/Commands/CommandObjectScript.h58
5 files changed, 769 insertions, 207 deletions
diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp
new file mode 100644
index 00000000000..a299ffb098f
--- /dev/null
+++ b/lldb/source/Commands/CommandCompletions.cpp
@@ -0,0 +1,414 @@
+//===-- CommandCompletions.cpp ----------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/Args.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Core/FileSpecList.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Interpreter/CommandCompletions.h"
+
+
+using namespace lldb_private;
+
+CommandCompletions::CommonCompletionElement
+CommandCompletions::g_common_completions[] =
+{
+ {eCustomCompletion, NULL},
+ {eSourceFileCompletion, CommandCompletions::SourceFiles},
+ {eDiskFileCompletion, NULL},
+ {eSymbolCompletion, CommandCompletions::Symbols},
+ {eModuleCompletion, CommandCompletions::Modules},
+ {eNoCompletion, NULL} // This one has to be last in the list.
+};
+
+bool
+CommandCompletions::InvokeCommonCompletionCallbacks (uint32_t completion_mask,
+ const char *completion_str,
+ int match_start_point,
+ int max_return_elements,
+ lldb_private::CommandInterpreter *interpreter,
+ SearchFilter *searcher,
+ lldb_private::StringList &matches)
+{
+ bool handled = false;
+
+ if (completion_mask & eCustomCompletion)
+ return false;
+
+ for (int i = 0; ; i++)
+ {
+ if (g_common_completions[i].type == eNoCompletion)
+ break;
+ else if ((g_common_completions[i].type & completion_mask) == g_common_completions[i].type
+ && g_common_completions[i].callback != NULL)
+ {
+ handled = true;
+ g_common_completions[i].callback (completion_str,
+ match_start_point,
+ max_return_elements,
+ interpreter,
+ searcher,
+ matches);
+ }
+ }
+ return handled;
+}
+
+int
+CommandCompletions::SourceFiles (const char *partial_file_name,
+ int match_start_point,
+ int max_return_elements,
+ lldb_private::CommandInterpreter *interpreter,
+ SearchFilter *searcher,
+ lldb_private::StringList &matches)
+{
+ // Find some way to switch "include support files..."
+ SourceFileCompleter completer (false, partial_file_name, match_start_point, max_return_elements, interpreter,
+ matches);
+
+ if (searcher == NULL)
+ {
+ lldb::TargetSP target_sp = interpreter->Context()->GetTarget()->GetSP();
+ SearchFilter null_searcher (target_sp);
+ completer.DoCompletion (&null_searcher);
+ }
+ else
+ {
+ completer.DoCompletion (searcher);
+ }
+ return matches.GetSize();
+}
+
+int
+CommandCompletions::Modules (const char *partial_file_name,
+ int match_start_point,
+ int max_return_elements,
+ lldb_private::CommandInterpreter *interpreter,
+ SearchFilter *searcher,
+ lldb_private::StringList &matches)
+{
+ ModuleCompleter completer(partial_file_name, match_start_point, max_return_elements, interpreter, matches);
+
+ if (searcher == NULL)
+ {
+ lldb::TargetSP target_sp = interpreter->Context()->GetTarget()->GetSP();
+ SearchFilter null_searcher (target_sp);
+ completer.DoCompletion (&null_searcher);
+ }
+ else
+ {
+ completer.DoCompletion (searcher);
+ }
+ return matches.GetSize();
+}
+
+int
+CommandCompletions::Symbols (const char *partial_file_name,
+ int match_start_point,
+ int max_return_elements,
+ lldb_private::CommandInterpreter *interpreter,
+ SearchFilter *searcher,
+ lldb_private::StringList &matches)
+{
+ SymbolCompleter completer(partial_file_name, match_start_point, max_return_elements, interpreter, matches);
+
+ if (searcher == NULL)
+ {
+ lldb::TargetSP target_sp = interpreter->Context()->GetTarget()->GetSP();
+ SearchFilter null_searcher (target_sp);
+ completer.DoCompletion (&null_searcher);
+ }
+ else
+ {
+ completer.DoCompletion (searcher);
+ }
+ return matches.GetSize();
+}
+
+CommandCompletions::Completer::Completer (
+ const char *completion_str,
+ int match_start_point,
+ int max_return_elements,
+ CommandInterpreter *interpreter,
+ StringList &matches
+) :
+ m_completion_str (completion_str),
+ m_match_start_point (match_start_point),
+ m_max_return_elements (max_return_elements),
+ m_interpreter (interpreter),
+ m_matches (matches)
+{
+}
+
+CommandCompletions::Completer::~Completer ()
+{
+
+}
+
+//----------------------------------------------------------------------
+// SourceFileCompleter
+//----------------------------------------------------------------------
+
+CommandCompletions::SourceFileCompleter::SourceFileCompleter (
+ bool include_support_files,
+ const char *completion_str,
+ int match_start_point,
+ int max_return_elements,
+ CommandInterpreter *interpreter,
+ StringList &matches
+) :
+ CommandCompletions::Completer (completion_str, match_start_point, max_return_elements, interpreter, matches),
+ m_include_support_files (include_support_files),
+ m_matching_files()
+{
+ FileSpec partial_spec (m_completion_str.c_str());
+ m_file_name = partial_spec.GetFilename().GetCString();
+ m_dir_name = partial_spec.GetDirectory().GetCString();
+}
+
+Searcher::Depth
+CommandCompletions::SourceFileCompleter::GetDepth()
+{
+ return eDepthCompUnit;
+}
+
+Searcher::CallbackReturn
+CommandCompletions::SourceFileCompleter::SearchCallback (
+ SearchFilter &filter,
+ SymbolContext &context,
+ Address *addr,
+ bool complete
+)
+{
+ if (context.comp_unit != NULL)
+ {
+ if (m_include_support_files)
+ {
+ FileSpecList supporting_files = context.comp_unit->GetSupportFiles();
+ for (size_t sfiles = 0; sfiles < supporting_files.GetSize(); sfiles++)
+ {
+ const FileSpec &sfile_spec = supporting_files.GetFileSpecAtIndex(sfiles);
+ const char *sfile_file_name = sfile_spec.GetFilename().GetCString();
+ const char *sfile_dir_name = sfile_spec.GetFilename().GetCString();
+ bool match = false;
+ if (m_file_name && sfile_file_name
+ && strstr (sfile_file_name, m_file_name) == sfile_file_name)
+ match = true;
+ if (match && m_dir_name && sfile_dir_name
+ && strstr (sfile_dir_name, m_dir_name) != sfile_dir_name)
+ match = false;
+
+ if (match)
+ {
+ m_matching_files.AppendIfUnique(sfile_spec);
+ }
+ }
+
+ }
+ else
+ {
+ const char *cur_file_name = context.comp_unit->GetFilename().GetCString();
+ const char *cur_dir_name = context.comp_unit->GetDirectory().GetCString();
+
+ bool match = false;
+ if (m_file_name && cur_file_name
+ && strstr (cur_file_name, m_file_name) == cur_file_name)
+ match = true;
+
+ if (match && m_dir_name && cur_dir_name
+ && strstr (cur_dir_name, m_dir_name) != cur_dir_name)
+ match = false;
+
+ if (match)
+ {
+ m_matching_files.AppendIfUnique(context.comp_unit);
+ }
+ }
+ }
+ return Searcher::eCallbackReturnContinue;
+}
+
+size_t
+CommandCompletions::SourceFileCompleter::DoCompletion (SearchFilter *filter)
+{
+ filter->Search (*this);
+ // Now convert the filelist to completions:
+ for (size_t i = 0; i < m_matching_files.GetSize(); i++)
+ {
+ m_matches.AppendString (m_matching_files.GetFileSpecAtIndex(i).GetFilename().GetCString());
+ }
+ return m_matches.GetSize();
+
+}
+
+//----------------------------------------------------------------------
+// SymbolCompleter
+//----------------------------------------------------------------------
+
+static bool
+regex_chars (const char comp)
+{
+ if (comp == '[' || comp == ']' || comp == '(' || comp == ')')
+ return true;
+ else
+ return false;
+}
+CommandCompletions::SymbolCompleter::SymbolCompleter (
+ const char *completion_str,
+ int match_start_point,
+ int max_return_elements,
+ CommandInterpreter *interpreter,
+ StringList &matches
+) :
+ CommandCompletions::Completer (completion_str, match_start_point, max_return_elements, interpreter, matches)
+{
+ std::string regex_str ("^");
+ regex_str.append(completion_str);
+ regex_str.append(".*");
+ std::string::iterator pos;
+
+ pos = find_if(regex_str.begin(), regex_str.end(), regex_chars);
+ while (pos < regex_str.end()) {
+ pos = regex_str.insert(pos, '\\');
+ pos += 2;
+ pos = find_if(pos, regex_str.end(), regex_chars);
+ }
+ m_regex.Compile(regex_str.c_str());
+}
+
+Searcher::Depth
+CommandCompletions::SymbolCompleter::GetDepth()
+{
+ return eDepthModule;
+}
+
+Searcher::CallbackReturn
+CommandCompletions::SymbolCompleter::SearchCallback (
+ SearchFilter &filter,
+ SymbolContext &context,
+ Address *addr,
+ bool complete
+)
+{
+ SymbolContextList func_list;
+ SymbolContextList sym_list;
+
+ if (context.module_sp != NULL)
+ {
+ if (context.module_sp)
+ {
+ context.module_sp->FindSymbolsMatchingRegExAndType (m_regex, lldb::eSymbolTypeCode, sym_list);
+ context.module_sp->FindFunctions (m_regex, true, func_list);
+ }
+
+ SymbolContext sc;
+ // Now add the functions & symbols to the list - only add if unique:
+ for (int i = 0; i < func_list.GetSize(); i++)
+ {
+ if (func_list.GetContextAtIndex(i, sc))
+ {
+ if (sc.function)
+ {
+ m_match_set.insert (sc.function->GetMangled().GetDemangledName());
+ }
+ }
+ }
+
+ for (int i = 0; i < sym_list.GetSize(); i++)
+ {
+ if (sym_list.GetContextAtIndex(i, sc))
+ {
+ if (sc.symbol && sc.symbol->GetAddressRangePtr())
+ {
+ m_match_set.insert (sc.symbol->GetMangled().GetDemangledName());
+ }
+ }
+ }
+ }
+ return Searcher::eCallbackReturnContinue;
+}
+
+size_t
+CommandCompletions::SymbolCompleter::DoCompletion (SearchFilter *filter)
+{
+ filter->Search (*this);
+ collection::iterator pos = m_match_set.begin(), end = m_match_set.end();
+ for (pos = m_match_set.begin(); pos != end; pos++)
+ m_matches.AppendString((*pos).GetCString());
+
+ return m_matches.GetSize();
+}
+
+//----------------------------------------------------------------------
+// ModuleCompleter
+//----------------------------------------------------------------------
+CommandCompletions::ModuleCompleter::ModuleCompleter (
+ const char *completion_str,
+ int match_start_point,
+ int max_return_elements,
+ CommandInterpreter *interpreter,
+ StringList &matches
+) :
+ CommandCompletions::Completer (completion_str, match_start_point, max_return_elements, interpreter, matches)
+{
+ FileSpec partial_spec (m_completion_str.c_str());
+ m_file_name = partial_spec.GetFilename().GetCString();
+ m_dir_name = partial_spec.GetDirectory().GetCString();
+}
+
+Searcher::Depth
+CommandCompletions::ModuleCompleter::GetDepth()
+{
+ return eDepthModule;
+}
+
+Searcher::CallbackReturn
+CommandCompletions::ModuleCompleter::SearchCallback (
+ SearchFilter &filter,
+ SymbolContext &context,
+ Address *addr,
+ bool complete
+)
+{
+ if (context.module_sp != NULL)
+ {
+ const char *cur_file_name = context.module_sp->GetFileSpec().GetFilename().GetCString();
+ const char *cur_dir_name = context.module_sp->GetFileSpec().GetDirectory().GetCString();
+
+ bool match = false;
+ if (m_file_name && cur_file_name
+ && strstr (cur_file_name, m_file_name) == cur_file_name)
+ match = true;
+
+ if (match && m_dir_name && cur_dir_name
+ && strstr (cur_dir_name, m_dir_name) != cur_dir_name)
+ match = false;
+
+ if (match)
+ {
+ m_matches.AppendString (cur_file_name);
+ }
+ }
+ return Searcher::eCallbackReturnContinue;
+}
+
+size_t
+CommandCompletions::ModuleCompleter::DoCompletion (SearchFilter *filter)
+{
+ filter->Search (*this);
+ return m_matches.GetSize();
+}
+
+
+
diff --git a/lldb/source/Commands/CommandObjectCrossref.cpp b/lldb/source/Commands/CommandObjectCrossref.cpp
new file mode 100644
index 00000000000..27b66379e87
--- /dev/null
+++ b/lldb/source/Commands/CommandObjectCrossref.cpp
@@ -0,0 +1,92 @@
+//===-- CommandObjectCrossref.cpp -------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Interpreter/CommandObjectCrossref.h"
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Interpreter/CommandReturnObject.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+//-------------------------------------------------------------------------
+// CommandObjectCrossref
+//-------------------------------------------------------------------------
+
+CommandObjectCrossref::CommandObjectCrossref
+(
+ const char *name,
+ const char *help,
+ const char *syntax
+) :
+ CommandObject (name, help, syntax),
+ m_crossref_object_types()
+{
+}
+
+CommandObjectCrossref::~CommandObjectCrossref ()
+{
+}
+
+bool
+CommandObjectCrossref::Execute
+(
+ Args& command,
+ CommandContext *context,
+ CommandInterpreter *interpreter,
+ CommandReturnObject &result
+)
+{
+ if (m_crossref_object_types.GetArgumentCount() == 0)
+ {
+ result.AppendErrorWithFormat ("There are no objects for which you can call '%s'.\n", GetCommandName());
+ result.SetStatus (eReturnStatusFailed);
+ }
+ else
+ {
+ GenerateHelpText (result);
+ }
+ return result.Succeeded();
+}
+
+void
+CommandObjectCrossref::AddObject (const char *obj_name)
+{
+ m_crossref_object_types.AppendArgument (obj_name);
+}
+
+const char **
+CommandObjectCrossref::GetObjectTypes () const
+{
+ return m_crossref_object_types.GetConstArgumentVector();
+}
+
+void
+CommandObjectCrossref::GenerateHelpText (CommandReturnObject &result)
+{
+ result.AppendMessage ("This command can be called on the following types of objects:");
+
+ for (int i = 0; i < m_crossref_object_types.GetArgumentCount(); ++i)
+ {
+ const char *obj_name = m_crossref_object_types.GetArgumentAtIndex(i);
+ result.AppendMessageWithFormat (" %s (e.g. '%s %s')\n", obj_name,
+ obj_name, GetCommandName());
+ }
+
+ result.SetStatus (eReturnStatusSuccessFinishNoResult);
+}
+
+bool
+CommandObjectCrossref::IsCrossRefObject ()
+{
+ return true;
+}
diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp
new file mode 100644
index 00000000000..874be0ea6a1
--- /dev/null
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -0,0 +1,263 @@
+//===-- CommandObjectMultiword.cpp ------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Interpreter/CommandObjectMultiword.h"
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Interpreter/CommandContext.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Core/Options.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+//-------------------------------------------------------------------------
+// CommandObjectMultiword
+//-------------------------------------------------------------------------
+
+CommandObjectMultiword::CommandObjectMultiword
+(
+ const char *name,
+ const char *help,
+ const char *syntax,
+ uint32_t flags
+) :
+ CommandObject (name, help, syntax, flags)
+{
+}
+
+CommandObjectMultiword::~CommandObjectMultiword ()
+{
+}
+
+CommandObjectSP
+CommandObjectMultiword::GetSubcommandSP (const char *sub_cmd, StringList *matches)
+{
+ CommandObjectSP return_cmd_sp;
+ CommandObject::CommandMap::iterator pos;
+
+ if (!m_subcommand_dict.empty())
+ {
+ pos = m_subcommand_dict.find (sub_cmd);
+ if (pos != m_subcommand_dict.end())
+ return_cmd_sp = pos->second;
+ else
+ {
+
+ StringList local_matches;
+ if (matches == NULL)
+ matches = &local_matches;
+ int num_matches = CommandObject::AddNamesMatchingPartialString (m_subcommand_dict, sub_cmd, *matches);
+
+ if (num_matches == 1)
+ {
+ // Cleaner, but slightly less efficient would be to call back into this function, since I now
+ // know I have an exact match...
+
+ sub_cmd = matches->GetStringAtIndex(0);
+ pos = m_subcommand_dict.find(sub_cmd);
+ if (pos != m_subcommand_dict.end())
+ return_cmd_sp = pos->second;
+ }
+ }
+ }
+ return return_cmd_sp;
+}
+
+CommandObject *
+CommandObjectMultiword::GetSubcommandObject (const char *sub_cmd, StringList *matches)
+{
+ return GetSubcommandSP(sub_cmd, matches).get();
+}
+
+bool
+CommandObjectMultiword::LoadSubCommand (CommandObjectSP cmd_obj, const char *name,
+ CommandInterpreter *interpreter)
+{
+ CommandMap::iterator pos;
+ bool success = true;
+
+ pos = m_subcommand_dict.find(name);
+ if (pos == m_subcommand_dict.end())
+ {
+ m_subcommand_dict[name] = cmd_obj;
+ interpreter->CrossRegisterCommand (name, GetCommandName());
+ }
+ else
+ success = false;
+
+ return success;
+}
+
+bool
+CommandObjectMultiword::Execute
+(
+ Args& args,
+ CommandContext *context,
+ CommandInterpreter *interpreter,
+ CommandReturnObject &result
+)
+{
+ const size_t argc = args.GetArgumentCount();
+ if (argc == 0)
+ {
+ GenerateHelpText (result, interpreter);
+ }
+ else
+ {
+ const char *sub_command = args.GetArgumentAtIndex (0);
+
+ if (sub_command)
+ {
+ if (::strcasecmp (sub_command, "help") == 0)
+ {
+ GenerateHelpText (result, interpreter);
+ }
+ else if (!m_subcommand_dict.empty())
+ {
+ StringList matches;
+ CommandObject *sub_cmd_obj = GetSubcommandObject(sub_command, &matches);
+ if (sub_cmd_obj != NULL)
+ {
+ // Now call CommandObject::Execute to process and options in 'rest_of_line'. From there
+ // the command-specific version of Execute will be called, with the processed arguments.
+
+ args.Shift();
+
+ sub_cmd_obj->ExecuteWithOptions (args, context, interpreter, result);
+ }
+ else
+ {
+ std::string error_msg;
+ int num_subcmd_matches = matches.GetSize();
+ if (num_subcmd_matches > 0)
+ error_msg.assign ("ambiguous command ");
+ else
+ error_msg.assign ("invalid command ");
+
+ error_msg.append ("'");
+ error_msg.append (GetCommandName());
+ error_msg.append (" ");
+ error_msg.append (sub_command);
+ error_msg.append ("'");
+
+ if (num_subcmd_matches > 0)
+ {
+ error_msg.append (" Possible completions:");
+ for (int i = 0; i < num_subcmd_matches; i++)
+ {
+ error_msg.append ("\n\t");
+ error_msg.append (matches.GetStringAtIndex (i));
+ }
+ }
+ error_msg.append ("\n");
+ result.AppendRawError (error_msg.c_str(), error_msg.size());
+ result.SetStatus (eReturnStatusFailed);
+ }
+ }
+ else
+ {
+ result.AppendErrorWithFormat ("'%s' does not have any subcommands.\n", GetCommandName());
+ result.SetStatus (eReturnStatusFailed);
+ }
+ }
+ }
+
+ return result.Succeeded();
+}
+
+void
+CommandObjectMultiword::GenerateHelpText (CommandReturnObject &result, CommandInterpreter *interpreter)
+{
+ // First time through here, generate the help text for the object and
+ // push it to the return result object as well
+
+ StreamString &output_stream = result.GetOutputStream();
+ output_stream.PutCString ("The following subcommands are supported:\n\n");
+
+ CommandMap::iterator pos;
+ std::string longest_word = interpreter->FindLongestCommandWord (m_subcommand_dict);
+ uint32_t max_len = 0;
+
+ if (! longest_word.empty())
+ max_len = strlen (longest_word.c_str()) + 4; // Indent the output by 4 spaces.
+
+ for (pos = m_subcommand_dict.begin(); pos != m_subcommand_dict.end(); ++pos)
+ {
+ std::string indented_command (" ");
+ indented_command.append (pos->first);
+ interpreter->OutputFormattedHelpText (result.GetOutputStream(), indented_command.c_str(), "--",
+ pos->second->GetHelp(), max_len);
+ }
+
+ output_stream.PutCString ("\nFor more help on any particular subcommand, type 'help <command> <subcommand>'.\n");
+
+ result.SetStatus (eReturnStatusSuccessFinishNoResult);
+}
+
+int
+CommandObjectMultiword::HandleCompletion
+(
+ Args &input,
+ int &cursor_index,
+ int &cursor_char_position,
+ int match_start_point,
+ int max_return_elements,
+ CommandInterpreter *interpreter,
+ StringList &matches
+)
+{
+ if (cursor_index == 0)
+ {
+ CommandObject::AddNamesMatchingPartialString (m_subcommand_dict, input.GetArgumentAtIndex(0), matches);
+
+ if (matches.GetSize() == 1
+ && matches.GetStringAtIndex(0) != NULL
+ && strcmp (input.GetArgumentAtIndex(0), matches.GetStringAtIndex(0)) == 0)
+ {
+ StringList temp_matches;
+ CommandObject *cmd_obj = GetSubcommandObject (input.GetArgumentAtIndex(0), &temp_matches);
+ if (cmd_obj != NULL)
+ {
+ matches.DeleteStringAtIndex (0);
+ input.Shift();
+ cursor_char_position = 0;
+ input.AppendArgument ("");
+ return cmd_obj->HandleCompletion (input, cursor_index, cursor_char_position, match_start_point,
+ max_return_elements, interpreter, matches);
+ }
+ else
+ return matches.GetSize();
+ }
+ else
+ return matches.GetSize();
+ }
+ else
+ {
+ CommandObject *sub_command_object = GetSubcommandObject (input.GetArgumentAtIndex(0), &matches);
+ if (sub_command_object == NULL)
+ {
+ return matches.GetSize();
+ }
+ else
+ {
+ // Remove the one match that we got from calling GetSubcommandObject.
+ matches.DeleteStringAtIndex(0);
+ input.Shift();
+ cursor_index--;
+ return sub_command_object->HandleCompletion (input, cursor_index, cursor_char_position, match_start_point,
+ max_return_elements, interpreter, matches);
+ }
+
+ }
+}
+
diff --git a/lldb/source/Commands/CommandObjectScript.cpp b/lldb/source/Commands/CommandObjectScript.cpp
deleted file mode 100644
index 64864be8d09..00000000000
--- a/lldb/source/Commands/CommandObjectScript.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-//===-- CommandObjectScript.cpp ---------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "CommandObjectScript.h"
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/Args.h"
-
-#include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Interpreter/ScriptInterpreter.h"
-#include "lldb/Interpreter/ScriptInterpreterPython.h"
-#include "lldb/Interpreter/ScriptInterpreterNone.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-//-------------------------------------------------------------------------
-// CommandObjectScript
-//-------------------------------------------------------------------------
-
-CommandObjectScript::CommandObjectScript (ScriptLanguage script_lang) :
- CommandObject ("script",
- "Passes an expression to the script interpreter for evaluation and returns the results. Drops user into the interactive interpreter if no expressions are given.",
- "script [<script-expressions-for-evaluation>]"),
- m_script_lang (script_lang),
- m_interpreter_ap ()
-{
-}
-
-CommandObjectScript::~CommandObjectScript ()
-{
-}
-
-bool
-CommandObjectScript::ExecuteRawCommandString
-(
- const char *command,
- CommandContext *context,
- CommandInterpreter *interpreter,
- CommandReturnObject &result
-)
-{
- std::string arg_str (command);
-
- ScriptInterpreter *script_interpreter = GetInterpreter ();
-
- if (script_interpreter == NULL)
- {
- result.AppendError("no script interpeter");
- result.SetStatus (eReturnStatusFailed);
- }
-
- FILE *out_fh = Debugger::GetSharedInstance().GetOutputFileHandle();
- FILE *err_fh = Debugger::GetSharedInstance().GetOutputFileHandle();
- if (out_fh && err_fh)
- {
- if (arg_str.empty())
- script_interpreter->ExecuteInterpreterLoop (out_fh, err_fh);
- else
- script_interpreter->ExecuteOneLine (arg_str, out_fh, err_fh);
- result.SetStatus (eReturnStatusSuccessFinishNoResult);
- }
- else
- {
- if (out_fh == NULL)
- result.AppendError("invalid output file handle");
- else
- result.AppendError("invalid error file handle");
- }
- return result.Succeeded();
-}
-
-bool
-CommandObjectScript::WantsRawCommandString()
-{
- return true;
-}
-
-bool
-CommandObjectScript::Execute
-(
- Args& command,
- CommandContext *context,
- CommandInterpreter *interpreter,
- CommandReturnObject &result
-)
-{
- std::string arg_str;
- ScriptInterpreter *script_interpreter = GetInterpreter ();
-
- if (script_interpreter == NULL)
- {
- result.AppendError("no script interpeter");
- result.SetStatus (eReturnStatusFailed);
- }
-
- const int argc = command.GetArgumentCount();
- for (int i = 0; i < argc; ++i)
- arg_str.append(command.GetArgumentAtIndex(i));
-
-
- FILE *out_fh = Debugger::GetSharedInstance().GetOutputFileHandle();
- FILE *err_fh = Debugger::GetSharedInstance().GetOutputFileHandle();
- if (out_fh && err_fh)
- {
- if (arg_str.empty())
- script_interpreter->ExecuteInterpreterLoop (out_fh, err_fh);
- else
- script_interpreter->ExecuteOneLine (arg_str, out_fh, err_fh);
- result.SetStatus (eReturnStatusSuccessFinishNoResult);
- }
- else
- {
- if (out_fh == NULL)
- result.AppendError("invalid output file handle");
- else
- result.AppendError("invalid error file handle");
- }
- return result.Succeeded();
-}
-
-
-ScriptInterpreter *
-CommandObjectScript::GetInterpreter ()
-{
- if (m_interpreter_ap.get() == NULL)
- {
- switch (m_script_lang)
- {
- case eScriptLanguagePython:
- m_interpreter_ap.reset (new ScriptInterpreterPython ());
- break;
-
- case eScriptLanguageNone:
- m_interpreter_ap.reset (new ScriptInterpreterNone ());
- break;
- }
- }
- return m_interpreter_ap.get();
-}
diff --git a/lldb/source/Commands/CommandObjectScript.h b/lldb/source/Commands/CommandObjectScript.h
deleted file mode 100644
index 7cd57518ff7..00000000000
--- a/lldb/source/Commands/CommandObjectScript.h
+++ /dev/null
@@ -1,58 +0,0 @@
-//===-- CommandObjectScript.h -----------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_CommandObjectScript_h_
-#define liblldb_CommandObjectScript_h_
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Interpreter/CommandObject.h"
-
-namespace lldb_private {
-
-//-------------------------------------------------------------------------
-// CommandObjectScript
-//-------------------------------------------------------------------------
-
-class CommandObjectScript : public CommandObject
-{
-public:
-
- CommandObjectScript (lldb::ScriptLanguage script_lang);
-
- virtual
- ~CommandObjectScript ();
-
- bool WantsRawCommandString();
-
- virtual bool
- ExecuteRawCommandString (const char *command,
- CommandContext *context,
- CommandInterpreter *interpreter,
- CommandReturnObject &result);
-
- virtual bool
- Execute (Args& command,
- CommandContext *context,
- CommandInterpreter *interpreter,
- CommandReturnObject &result);
-
- ScriptInterpreter *
- GetInterpreter ();
-
-private:
- lldb::ScriptLanguage m_script_lang;
- std::auto_ptr<ScriptInterpreter> m_interpreter_ap;
-};
-
-} // namespace lldb_private
-
-#endif // liblldb_CommandObjectScript_h_
OpenPOWER on IntegriCloud