diff options
Diffstat (limited to 'source/Interpreter/CommandObject.cpp')
-rw-r--r-- | source/Interpreter/CommandObject.cpp | 70 |
1 files changed, 34 insertions, 36 deletions
diff --git a/source/Interpreter/CommandObject.cpp b/source/Interpreter/CommandObject.cpp index 753e720..d67f76e 100644 --- a/source/Interpreter/CommandObject.cpp +++ b/source/Interpreter/CommandObject.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "lldb/Interpreter/CommandObject.h" #include <string> @@ -25,13 +23,12 @@ // FIXME: Make a separate file for the completers. #include "lldb/Host/FileSpec.h" #include "lldb/Core/FileSpecList.h" +#include "lldb/DataFormatters/FormatManager.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" -#include "lldb/Interpreter/ScriptInterpreter.h" -#include "lldb/Interpreter/ScriptInterpreterPython.h" using namespace lldb; using namespace lldb_private; @@ -123,6 +120,12 @@ CommandObject::SetHelp (const char *cstr) } void +CommandObject::SetHelp (std::string str) +{ + m_cmd_help_short = str; +} + +void CommandObject::SetHelpLong (const char *cstr) { m_cmd_help_long = cstr; @@ -221,20 +224,20 @@ CommandObject::CheckRequirements (CommandReturnObject &result) m_exe_ctx = m_interpreter.GetExecutionContext(); const uint32_t flags = GetFlags().Get(); - if (flags & (eFlagRequiresTarget | - eFlagRequiresProcess | - eFlagRequiresThread | - eFlagRequiresFrame | - eFlagTryTargetAPILock )) + if (flags & (eCommandRequiresTarget | + eCommandRequiresProcess | + eCommandRequiresThread | + eCommandRequiresFrame | + eCommandTryTargetAPILock )) { - if ((flags & eFlagRequiresTarget) && !m_exe_ctx.HasTargetScope()) + if ((flags & eCommandRequiresTarget) && !m_exe_ctx.HasTargetScope()) { result.AppendError (GetInvalidTargetDescription()); return false; } - if ((flags & eFlagRequiresProcess) && !m_exe_ctx.HasProcessScope()) + if ((flags & eCommandRequiresProcess) && !m_exe_ctx.HasProcessScope()) { if (!m_exe_ctx.HasTargetScope()) result.AppendError (GetInvalidTargetDescription()); @@ -243,7 +246,7 @@ CommandObject::CheckRequirements (CommandReturnObject &result) return false; } - if ((flags & eFlagRequiresThread) && !m_exe_ctx.HasThreadScope()) + if ((flags & eCommandRequiresThread) && !m_exe_ctx.HasThreadScope()) { if (!m_exe_ctx.HasTargetScope()) result.AppendError (GetInvalidTargetDescription()); @@ -254,7 +257,7 @@ CommandObject::CheckRequirements (CommandReturnObject &result) return false; } - if ((flags & eFlagRequiresFrame) && !m_exe_ctx.HasFrameScope()) + if ((flags & eCommandRequiresFrame) && !m_exe_ctx.HasFrameScope()) { if (!m_exe_ctx.HasTargetScope()) result.AppendError (GetInvalidTargetDescription()); @@ -267,13 +270,13 @@ CommandObject::CheckRequirements (CommandReturnObject &result) return false; } - if ((flags & eFlagRequiresRegContext) && (m_exe_ctx.GetRegisterContext() == nullptr)) + if ((flags & eCommandRequiresRegContext) && (m_exe_ctx.GetRegisterContext() == nullptr)) { result.AppendError (GetInvalidRegContextDescription()); return false; } - if (flags & eFlagTryTargetAPILock) + if (flags & eCommandTryTargetAPILock) { Target *target = m_exe_ctx.GetTargetPtr(); if (target) @@ -281,13 +284,13 @@ CommandObject::CheckRequirements (CommandReturnObject &result) } } - if (GetFlags().AnySet (CommandObject::eFlagProcessMustBeLaunched | CommandObject::eFlagProcessMustBePaused)) + if (GetFlags().AnySet (eCommandProcessMustBeLaunched | eCommandProcessMustBePaused)) { Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); if (process == nullptr) { // A process that is not running is considered paused. - if (GetFlags().Test(CommandObject::eFlagProcessMustBeLaunched)) + if (GetFlags().Test(eCommandProcessMustBeLaunched)) { result.AppendError ("Process must exist."); result.SetStatus (eReturnStatusFailed); @@ -311,7 +314,7 @@ CommandObject::CheckRequirements (CommandReturnObject &result) case eStateDetached: case eStateExited: case eStateUnloaded: - if (GetFlags().Test(CommandObject::eFlagProcessMustBeLaunched)) + if (GetFlags().Test(eCommandProcessMustBeLaunched)) { result.AppendError ("Process must be launched."); result.SetStatus (eReturnStatusFailed); @@ -321,7 +324,7 @@ CommandObject::CheckRequirements (CommandReturnObject &result) case eStateRunning: case eStateStepping: - if (GetFlags().Test(CommandObject::eFlagProcessMustBePaused)) + if (GetFlags().Test(eCommandProcessMustBePaused)) { result.AppendError ("Process is running. Use 'process interrupt' to pause execution."); result.SetStatus (eReturnStatusFailed); @@ -499,14 +502,14 @@ CommandObject::GetArgumentEntryAtIndex (int idx) return nullptr; } -CommandObject::ArgumentTableEntry * +const CommandObject::ArgumentTableEntry * CommandObject::FindArgumentDataByType (CommandArgumentType arg_type) { const ArgumentTableEntry *table = CommandObject::GetArgumentTable(); for (int i = 0; i < eArgTypeLastArg; ++i) if (table[i].arg_type == arg_type) - return (ArgumentTableEntry *) &(table[i]); + return &(table[i]); return nullptr; } @@ -515,7 +518,7 @@ void CommandObject::GetArgumentHelp (Stream &str, CommandArgumentType arg_type, CommandInterpreter &interpreter) { const ArgumentTableEntry* table = CommandObject::GetArgumentTable(); - ArgumentTableEntry *entry = (ArgumentTableEntry *) &(table[arg_type]); + const ArgumentTableEntry *entry = &(table[arg_type]); // The table is *supposed* to be kept in arg_type order, but someone *could* have messed it up... @@ -549,7 +552,7 @@ CommandObject::GetArgumentHelp (Stream &str, CommandArgumentType arg_type, Comma const char * CommandObject::GetArgumentName (CommandArgumentType arg_type) { - ArgumentTableEntry *entry = (ArgumentTableEntry *) &(CommandObject::GetArgumentTable()[arg_type]); + const ArgumentTableEntry *entry = &(CommandObject::GetArgumentTable()[arg_type]); // The table is *supposed* to be kept in arg_type order, but someone *could* have messed it up... @@ -843,12 +846,9 @@ LanguageTypeHelpTextCallback () StreamString sstr; sstr << "One of the following languages:\n"; - - for (unsigned int l = eLanguageTypeUnknown; l < eNumLanguageTypes; ++l) - { - sstr << " " << LanguageRuntime::GetNameForLanguageType(static_cast<LanguageType>(l)) << "\n"; - } - + + LanguageRuntime::PrintAllLanguages(sstr, " ", "\n"); + sstr.Flush(); std::string data = sstr.GetString(); @@ -1020,18 +1020,15 @@ CommandObject::AddIDsArgumentData(CommandArgumentEntry &arg, CommandArgumentType const char * CommandObject::GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type) { - if (arg_type >=0 && arg_type < eArgTypeLastArg) - return g_arguments_data[arg_type].arg_name; - return nullptr; - + assert(arg_type < eArgTypeLastArg && "Invalid argument type passed to GetArgumentTypeAsCString"); + return g_arguments_data[arg_type].arg_name; } const char * CommandObject::GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type) { - if (arg_type >=0 && arg_type < eArgTypeLastArg) - return g_arguments_data[arg_type].help_text; - return nullptr; + assert(arg_type < eArgTypeLastArg && "Invalid argument type passed to GetArgumentDescriptionAsCString"); + return g_arguments_data[arg_type].help_text; } Target * @@ -1192,6 +1189,7 @@ CommandObject::g_arguments_data[] = { eArgTypeThreadID, "thread-id", CommandCompletions::eNoCompletion, { nullptr, false }, "Thread ID number." }, { eArgTypeThreadIndex, "thread-index", CommandCompletions::eNoCompletion, { nullptr, false }, "Index into the process' list of threads." }, { eArgTypeThreadName, "thread-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The thread's name." }, + { eArgTypeTypeName, "type-name", CommandCompletions::eNoCompletion, { nullptr, false }, "A type name." }, { eArgTypeUnsignedInteger, "unsigned-integer", CommandCompletions::eNoCompletion, { nullptr, false }, "An unsigned integer." }, { eArgTypeUnixSignal, "unix-signal", CommandCompletions::eNoCompletion, { nullptr, false }, "A valid Unix signal name or number (e.g. SIGKILL, KILL or 9)." }, { eArgTypeVarName, "variable-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a variable in your program." }, |