CommandInterpreter.h [plain text]
#ifndef liblldb_CommandInterpreter_h_
#define liblldb_CommandInterpreter_h_
#include "lldb/lldb-private.h"
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Log.h"
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
#include "lldb/Core/Event.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Core/StringList.h"
namespace lldb_private {
class CommandInterpreter :
public Broadcaster,
public Properties
{
public:
typedef std::map<std::string, OptionArgVectorSP> OptionArgMap;
enum
{
eBroadcastBitThreadShouldExit = (1 << 0),
eBroadcastBitResetPrompt = (1 << 1),
eBroadcastBitQuitCommandReceived = (1 << 2), eBroadcastBitAsynchronousOutputData = (1 << 3),
eBroadcastBitAsynchronousErrorData = (1 << 4)
};
enum ChildrenTruncatedWarningStatus {
eNoTruncation = 0, eUnwarnedTruncation = 1, eWarnedTruncation = 2 };
enum CommandTypes
{
eCommandTypesBuiltin = 0x0001, eCommandTypesUserDef = 0x0002, eCommandTypesAliases = 0x0004, eCommandTypesAllThem = 0xFFFF };
static ConstString &GetStaticBroadcasterClass ();
virtual ConstString &GetBroadcasterClass() const
{
return GetStaticBroadcasterClass();
}
void
SourceInitFile (bool in_cwd,
CommandReturnObject &result);
CommandInterpreter (Debugger &debugger,
lldb::ScriptLanguage script_language,
bool synchronous_execution);
virtual
~CommandInterpreter ();
bool
AddCommand (const char *name,
const lldb::CommandObjectSP &cmd_sp,
bool can_replace);
bool
AddUserCommand (std::string name,
const lldb::CommandObjectSP &cmd_sp,
bool can_replace);
lldb::CommandObjectSP
GetCommandSPExact (const char *cmd,
bool include_aliases);
CommandObject *
GetCommandObjectExact (const char *cmd_cstr,
bool include_aliases);
CommandObject *
GetCommandObject (const char *cmd,
StringList *matches = NULL);
bool
CommandExists (const char *cmd);
bool
AliasExists (const char *cmd);
bool
UserCommandExists (const char *cmd);
void
AddAlias (const char *alias_name,
lldb::CommandObjectSP& command_obj_sp);
bool
RemoveAlias (const char *alias_name);
bool
RemoveUser (const char *alias_name);
void
RemoveAllUser ()
{
m_user_dict.clear();
}
OptionArgVectorSP
GetAliasOptions (const char *alias_name);
bool
ProcessAliasOptionsArgs (lldb::CommandObjectSP &cmd_obj_sp,
const char *options_args,
OptionArgVectorSP &option_arg_vector_sp);
void
RemoveAliasOptions (const char *alias_name);
void
AddOrReplaceAliasOptions (const char *alias_name,
OptionArgVectorSP &option_arg_vector_sp);
CommandObject *
BuildAliasResult (const char *alias_name,
std::string &raw_input_string,
std::string &alias_result,
CommandReturnObject &result);
bool
HandleCommand (const char *command_line,
LazyBool add_to_history,
CommandReturnObject &result,
ExecutionContext *override_context = NULL,
bool repeat_on_empty_command = true,
bool no_context_switching = false);
void
HandleCommands (const StringList &commands,
ExecutionContext *context,
bool stop_on_continue,
bool stop_on_error,
bool echo_commands,
bool print_results,
LazyBool add_to_history,
CommandReturnObject &result);
void
HandleCommandsFromFile (FileSpec &file,
ExecutionContext *context,
bool stop_on_continue,
bool stop_on_error,
bool echo_commands,
bool print_results,
LazyBool add_to_history,
CommandReturnObject &result);
CommandObject *
GetCommandObjectForCommand (std::string &command_line);
int
HandleCompletion (const char *current_line,
const char *cursor,
const char *last_char,
int match_start_point,
int max_return_elements,
StringList &matches);
int
HandleCompletionMatches (Args &input,
int &cursor_index,
int &cursor_char_position,
int match_start_point,
int max_return_elements,
bool &word_complete,
StringList &matches);
int
GetCommandNamesMatchingPartialString (const char *cmd_cstr,
bool include_aliases,
StringList &matches);
void
GetHelp (CommandReturnObject &result,
uint32_t types = eCommandTypesAllThem);
void
GetAliasHelp (const char *alias_name,
const char *command_name,
StreamString &help_string);
void
OutputFormattedHelpText (Stream &stream,
const char *command_word,
const char *separator,
const char *help_text,
uint32_t max_word_len);
void
OutputHelpText (Stream &stream,
const char *command_word,
const char *separator,
const char *help_text,
uint32_t max_word_len);
Debugger &
GetDebugger ()
{
return m_debugger;
}
ExecutionContext
GetExecutionContext()
{
return m_exe_ctx_ref.Lock();
}
void
UpdateExecutionContext (ExecutionContext *override_context);
lldb::PlatformSP
GetPlatform (bool prefer_target_platform);
const char *
ProcessEmbeddedScriptCommands (const char *arg);
const char *
GetPrompt ();
void
SetPrompt (const char *);
bool Confirm (const char *message, bool default_answer);
static size_t
GetConfirmationInputReaderCallback (void *baton,
InputReader &reader,
lldb::InputReaderAction action,
const char *bytes,
size_t bytes_len);
void
LoadCommandDictionary ();
void
Initialize ();
void
CrossRegisterCommand (const char *dest_cmd,
const char *object_type);
void
SetScriptLanguage (lldb::ScriptLanguage lang);
bool
HasCommands ();
bool
HasAliases ();
bool
HasUserCommands ();
bool
HasAliasOptions ();
void
BuildAliasCommandArgs (CommandObject *alias_cmd_obj,
const char *alias_name,
Args &cmd_args,
std::string &raw_input_string,
CommandReturnObject &result);
int
GetOptionArgumentPosition (const char *in_string);
ScriptInterpreter *
GetScriptInterpreter (bool can_create = true);
void
SkipLLDBInitFiles (bool skip_lldbinit_files)
{
m_skip_lldbinit_files = skip_lldbinit_files;
}
void
SkipAppInitFiles (bool skip_app_init_files)
{
m_skip_app_init_files = m_skip_lldbinit_files;
}
bool
GetSynchronous ();
void
DumpHistory (Stream &stream, uint32_t count) const;
void
DumpHistory (Stream &stream, uint32_t start, uint32_t end) const;
const char *
FindHistoryString (const char *input_str) const;
size_t
FindLongestCommandWord (CommandObject::CommandMap &dict);
void
FindCommandsForApropos (const char *word,
StringList &commands_found,
StringList &commands_help);
bool
GetBatchCommandMode () { return m_batch_command_mode; }
void
SetBatchCommandMode (bool value) { m_batch_command_mode = value; }
void
ChildrenTruncated()
{
if (m_truncation_warning == eNoTruncation)
m_truncation_warning = eUnwarnedTruncation;
}
bool
TruncationWarningNecessary()
{
return (m_truncation_warning == eUnwarnedTruncation);
}
void
TruncationWarningGiven()
{
m_truncation_warning = eWarnedTruncation;
}
const char *
TruncationWarningText()
{
return "*** Some of your variables have more members than the debugger will show by default. To show all of them, you can either use the --show-all-children option to %s or raise the limit by changing the target.max-children-count setting.\n";
}
bool
GetExpandRegexAliases () const;
protected:
friend class Debugger;
void
SetSynchronous (bool value);
lldb::CommandObjectSP
GetCommandSP (const char *cmd, bool include_aliases = true, bool exact = true, StringList *matches = NULL);
private:
Error
PreprocessCommand (std::string &command);
Debugger &m_debugger; ExecutionContextRef m_exe_ctx_ref; bool m_synchronous_execution;
bool m_skip_lldbinit_files;
bool m_skip_app_init_files;
CommandObject::CommandMap m_command_dict; CommandObject::CommandMap m_alias_dict; CommandObject::CommandMap m_user_dict; OptionArgMap m_alias_options; std::vector<std::string> m_command_history;
std::string m_repeat_command; std::auto_ptr<ScriptInterpreter> m_script_interpreter_ap;
char m_comment_char;
char m_repeat_char;
bool m_batch_command_mode;
ChildrenTruncatedWarningStatus m_truncation_warning; uint32_t m_command_source_depth;
};
}
#endif // liblldb_CommandInterpreter_h_