130fdc8d8SChris Lattner //===-- CommandObject.cpp ---------------------------------------*- C++ -*-===// 230fdc8d8SChris Lattner // 330fdc8d8SChris Lattner // The LLVM Compiler Infrastructure 430fdc8d8SChris Lattner // 530fdc8d8SChris Lattner // This file is distributed under the University of Illinois Open Source 630fdc8d8SChris Lattner // License. See LICENSE.TXT for details. 730fdc8d8SChris Lattner // 830fdc8d8SChris Lattner //===----------------------------------------------------------------------===// 930fdc8d8SChris Lattner 1093a64300SDaniel Malea #include "lldb/lldb-python.h" 1193a64300SDaniel Malea 1230fdc8d8SChris Lattner #include "lldb/Interpreter/CommandObject.h" 1330fdc8d8SChris Lattner 1430fdc8d8SChris Lattner #include <string> 1530fdc8d8SChris Lattner #include <map> 1630fdc8d8SChris Lattner 1730fdc8d8SChris Lattner #include <getopt.h> 1830fdc8d8SChris Lattner #include <stdlib.h> 1930fdc8d8SChris Lattner #include <ctype.h> 2030fdc8d8SChris Lattner 2130fdc8d8SChris Lattner #include "lldb/Core/Address.h" 22ca7835c6SJohnny Chen #include "lldb/Core/ArchSpec.h" 2340af72e1SJim Ingham #include "lldb/Interpreter/Options.h" 2430fdc8d8SChris Lattner 2530fdc8d8SChris Lattner // These are for the Sourcename completers. 2630fdc8d8SChris Lattner // FIXME: Make a separate file for the completers. 2753239f00SGreg Clayton #include "lldb/Host/FileSpec.h" 2830fdc8d8SChris Lattner #include "lldb/Core/FileSpecList.h" 2930fdc8d8SChris Lattner #include "lldb/Target/Process.h" 3030fdc8d8SChris Lattner #include "lldb/Target/Target.h" 3130fdc8d8SChris Lattner 3230fdc8d8SChris Lattner #include "lldb/Interpreter/CommandInterpreter.h" 3330fdc8d8SChris Lattner #include "lldb/Interpreter/CommandReturnObject.h" 3430fdc8d8SChris Lattner #include "lldb/Interpreter/ScriptInterpreter.h" 3530fdc8d8SChris Lattner #include "lldb/Interpreter/ScriptInterpreterPython.h" 3630fdc8d8SChris Lattner 3730fdc8d8SChris Lattner using namespace lldb; 3830fdc8d8SChris Lattner using namespace lldb_private; 3930fdc8d8SChris Lattner 4030fdc8d8SChris Lattner //------------------------------------------------------------------------- 4130fdc8d8SChris Lattner // CommandObject 4230fdc8d8SChris Lattner //------------------------------------------------------------------------- 4330fdc8d8SChris Lattner 44a7015092SGreg Clayton CommandObject::CommandObject 45a7015092SGreg Clayton ( 46a7015092SGreg Clayton CommandInterpreter &interpreter, 47a7015092SGreg Clayton const char *name, 48a7015092SGreg Clayton const char *help, 49a7015092SGreg Clayton const char *syntax, 50a7015092SGreg Clayton uint32_t flags 51a7015092SGreg Clayton ) : 52a7015092SGreg Clayton m_interpreter (interpreter), 5330fdc8d8SChris Lattner m_cmd_name (name), 5430fdc8d8SChris Lattner m_cmd_help_short (), 5530fdc8d8SChris Lattner m_cmd_help_long (), 5630fdc8d8SChris Lattner m_cmd_syntax (), 57279a6c26SJim Ingham m_is_alias (false), 58e139cf23SCaroline Tice m_flags (flags), 59a9f7b79dSGreg Clayton m_arguments(), 60a9f7b79dSGreg Clayton m_command_override_callback (NULL), 61a9f7b79dSGreg Clayton m_command_override_baton (NULL) 6230fdc8d8SChris Lattner { 6330fdc8d8SChris Lattner if (help && help[0]) 6430fdc8d8SChris Lattner m_cmd_help_short = help; 6530fdc8d8SChris Lattner if (syntax && syntax[0]) 6630fdc8d8SChris Lattner m_cmd_syntax = syntax; 6730fdc8d8SChris Lattner } 6830fdc8d8SChris Lattner 6930fdc8d8SChris Lattner CommandObject::~CommandObject () 7030fdc8d8SChris Lattner { 7130fdc8d8SChris Lattner } 7230fdc8d8SChris Lattner 7330fdc8d8SChris Lattner const char * 7430fdc8d8SChris Lattner CommandObject::GetHelp () 7530fdc8d8SChris Lattner { 7630fdc8d8SChris Lattner return m_cmd_help_short.c_str(); 7730fdc8d8SChris Lattner } 7830fdc8d8SChris Lattner 7930fdc8d8SChris Lattner const char * 8030fdc8d8SChris Lattner CommandObject::GetHelpLong () 8130fdc8d8SChris Lattner { 8230fdc8d8SChris Lattner return m_cmd_help_long.c_str(); 8330fdc8d8SChris Lattner } 8430fdc8d8SChris Lattner 8530fdc8d8SChris Lattner const char * 8630fdc8d8SChris Lattner CommandObject::GetSyntax () 8730fdc8d8SChris Lattner { 88e139cf23SCaroline Tice if (m_cmd_syntax.length() == 0) 89e139cf23SCaroline Tice { 90e139cf23SCaroline Tice StreamString syntax_str; 91e139cf23SCaroline Tice syntax_str.Printf ("%s", GetCommandName()); 92e139cf23SCaroline Tice if (GetOptions() != NULL) 93e139cf23SCaroline Tice syntax_str.Printf (" <cmd-options>"); 94e139cf23SCaroline Tice if (m_arguments.size() > 0) 95e139cf23SCaroline Tice { 96e139cf23SCaroline Tice syntax_str.Printf (" "); 97a4c6ad19SSean Callanan if (WantsRawCommandString()) 98a4c6ad19SSean Callanan syntax_str.Printf("-- "); 99e139cf23SCaroline Tice GetFormattedCommandArguments (syntax_str); 100e139cf23SCaroline Tice } 101e139cf23SCaroline Tice m_cmd_syntax = syntax_str.GetData (); 102e139cf23SCaroline Tice } 103e139cf23SCaroline Tice 10430fdc8d8SChris Lattner return m_cmd_syntax.c_str(); 10530fdc8d8SChris Lattner } 10630fdc8d8SChris Lattner 10730fdc8d8SChris Lattner const char * 10830fdc8d8SChris Lattner CommandObject::Translate () 10930fdc8d8SChris Lattner { 11030fdc8d8SChris Lattner //return m_cmd_func_name.c_str(); 11130fdc8d8SChris Lattner return "This function is currently not implemented."; 11230fdc8d8SChris Lattner } 11330fdc8d8SChris Lattner 11430fdc8d8SChris Lattner const char * 11530fdc8d8SChris Lattner CommandObject::GetCommandName () 11630fdc8d8SChris Lattner { 11730fdc8d8SChris Lattner return m_cmd_name.c_str(); 11830fdc8d8SChris Lattner } 11930fdc8d8SChris Lattner 12030fdc8d8SChris Lattner void 12130fdc8d8SChris Lattner CommandObject::SetCommandName (const char *name) 12230fdc8d8SChris Lattner { 12330fdc8d8SChris Lattner m_cmd_name = name; 12430fdc8d8SChris Lattner } 12530fdc8d8SChris Lattner 12630fdc8d8SChris Lattner void 12730fdc8d8SChris Lattner CommandObject::SetHelp (const char *cstr) 12830fdc8d8SChris Lattner { 12930fdc8d8SChris Lattner m_cmd_help_short = cstr; 13030fdc8d8SChris Lattner } 13130fdc8d8SChris Lattner 13230fdc8d8SChris Lattner void 13330fdc8d8SChris Lattner CommandObject::SetHelpLong (const char *cstr) 13430fdc8d8SChris Lattner { 13530fdc8d8SChris Lattner m_cmd_help_long = cstr; 13630fdc8d8SChris Lattner } 13730fdc8d8SChris Lattner 13830fdc8d8SChris Lattner void 13999f0b8f9SEnrico Granata CommandObject::SetHelpLong (std::string str) 14099f0b8f9SEnrico Granata { 14199f0b8f9SEnrico Granata m_cmd_help_long = str; 14299f0b8f9SEnrico Granata } 14399f0b8f9SEnrico Granata 14499f0b8f9SEnrico Granata void 14530fdc8d8SChris Lattner CommandObject::SetSyntax (const char *cstr) 14630fdc8d8SChris Lattner { 14730fdc8d8SChris Lattner m_cmd_syntax = cstr; 14830fdc8d8SChris Lattner } 14930fdc8d8SChris Lattner 15030fdc8d8SChris Lattner Options * 15130fdc8d8SChris Lattner CommandObject::GetOptions () 15230fdc8d8SChris Lattner { 15330fdc8d8SChris Lattner // By default commands don't have options unless this virtual function 15430fdc8d8SChris Lattner // is overridden by base classes. 15530fdc8d8SChris Lattner return NULL; 15630fdc8d8SChris Lattner } 15730fdc8d8SChris Lattner 15830fdc8d8SChris Lattner bool 15930fdc8d8SChris Lattner CommandObject::ParseOptions 16030fdc8d8SChris Lattner ( 16130fdc8d8SChris Lattner Args& args, 16230fdc8d8SChris Lattner CommandReturnObject &result 16330fdc8d8SChris Lattner ) 16430fdc8d8SChris Lattner { 16530fdc8d8SChris Lattner // See if the subclass has options? 16630fdc8d8SChris Lattner Options *options = GetOptions(); 16730fdc8d8SChris Lattner if (options != NULL) 16830fdc8d8SChris Lattner { 16930fdc8d8SChris Lattner Error error; 170f6b8b581SGreg Clayton options->NotifyOptionParsingStarting(); 17130fdc8d8SChris Lattner 17230fdc8d8SChris Lattner // ParseOptions calls getopt_long, which always skips the zero'th item in the array and starts at position 1, 17330fdc8d8SChris Lattner // so we need to push a dummy value into position zero. 17430fdc8d8SChris Lattner args.Unshift("dummy_string"); 17530fdc8d8SChris Lattner error = args.ParseOptions (*options); 17630fdc8d8SChris Lattner 17730fdc8d8SChris Lattner // The "dummy_string" will have already been removed by ParseOptions, 17830fdc8d8SChris Lattner // so no need to remove it. 17930fdc8d8SChris Lattner 180f6b8b581SGreg Clayton if (error.Success()) 181f6b8b581SGreg Clayton error = options->NotifyOptionParsingFinished(); 182f6b8b581SGreg Clayton 183f6b8b581SGreg Clayton if (error.Success()) 184f6b8b581SGreg Clayton { 185f6b8b581SGreg Clayton if (options->VerifyOptions (result)) 186f6b8b581SGreg Clayton return true; 187f6b8b581SGreg Clayton } 188f6b8b581SGreg Clayton else 18930fdc8d8SChris Lattner { 19030fdc8d8SChris Lattner const char *error_cstr = error.AsCString(); 19130fdc8d8SChris Lattner if (error_cstr) 19230fdc8d8SChris Lattner { 19330fdc8d8SChris Lattner // We got an error string, lets use that 19486edbf41SGreg Clayton result.AppendError(error_cstr); 19530fdc8d8SChris Lattner } 19630fdc8d8SChris Lattner else 19730fdc8d8SChris Lattner { 19830fdc8d8SChris Lattner // No error string, output the usage information into result 199eb0103f2SGreg Clayton options->GenerateOptionUsage (result.GetErrorStream(), this); 20030fdc8d8SChris Lattner } 201f6b8b581SGreg Clayton } 20230fdc8d8SChris Lattner result.SetStatus (eReturnStatusFailed); 20330fdc8d8SChris Lattner return false; 20430fdc8d8SChris Lattner } 20530fdc8d8SChris Lattner return true; 20630fdc8d8SChris Lattner } 20730fdc8d8SChris Lattner 2085a988416SJim Ingham 2095a988416SJim Ingham 2105a988416SJim Ingham bool 211f9fc609fSGreg Clayton CommandObject::CheckRequirements (CommandReturnObject &result) 2125a988416SJim Ingham { 213f9fc609fSGreg Clayton #ifdef LLDB_CONFIGURATION_DEBUG 214f9fc609fSGreg Clayton // Nothing should be stored in m_exe_ctx between running commands as m_exe_ctx 215f9fc609fSGreg Clayton // has shared pointers to the target, process, thread and frame and we don't 216f9fc609fSGreg Clayton // want any CommandObject instances to keep any of these objects around 217f9fc609fSGreg Clayton // longer than for a single command. Every command should call 218f9fc609fSGreg Clayton // CommandObject::Cleanup() after it has completed 219f9fc609fSGreg Clayton assert (m_exe_ctx.GetTargetPtr() == NULL); 220f9fc609fSGreg Clayton assert (m_exe_ctx.GetProcessPtr() == NULL); 221f9fc609fSGreg Clayton assert (m_exe_ctx.GetThreadPtr() == NULL); 222f9fc609fSGreg Clayton assert (m_exe_ctx.GetFramePtr() == NULL); 223f9fc609fSGreg Clayton #endif 224f9fc609fSGreg Clayton 225f9fc609fSGreg Clayton // Lock down the interpreter's execution context prior to running the 226f9fc609fSGreg Clayton // command so we guarantee the selected target, process, thread and frame 227f9fc609fSGreg Clayton // can't go away during the execution 228f9fc609fSGreg Clayton m_exe_ctx = m_interpreter.GetExecutionContext(); 229f9fc609fSGreg Clayton 230f9fc609fSGreg Clayton const uint32_t flags = GetFlags().Get(); 231f9fc609fSGreg Clayton if (flags & (eFlagRequiresTarget | 232f9fc609fSGreg Clayton eFlagRequiresProcess | 233f9fc609fSGreg Clayton eFlagRequiresThread | 234f9fc609fSGreg Clayton eFlagRequiresFrame | 235f9fc609fSGreg Clayton eFlagTryTargetAPILock )) 236f9fc609fSGreg Clayton { 237f9fc609fSGreg Clayton 238f9fc609fSGreg Clayton if ((flags & eFlagRequiresTarget) && !m_exe_ctx.HasTargetScope()) 239f9fc609fSGreg Clayton { 240f9fc609fSGreg Clayton result.AppendError (GetInvalidTargetDescription()); 241f9fc609fSGreg Clayton return false; 242f9fc609fSGreg Clayton } 243f9fc609fSGreg Clayton 244f9fc609fSGreg Clayton if ((flags & eFlagRequiresProcess) && !m_exe_ctx.HasProcessScope()) 245f9fc609fSGreg Clayton { 246f9fc609fSGreg Clayton result.AppendError (GetInvalidProcessDescription()); 247f9fc609fSGreg Clayton return false; 248f9fc609fSGreg Clayton } 249f9fc609fSGreg Clayton 250f9fc609fSGreg Clayton if ((flags & eFlagRequiresThread) && !m_exe_ctx.HasThreadScope()) 251f9fc609fSGreg Clayton { 252f9fc609fSGreg Clayton result.AppendError (GetInvalidThreadDescription()); 253f9fc609fSGreg Clayton return false; 254f9fc609fSGreg Clayton } 255f9fc609fSGreg Clayton 256f9fc609fSGreg Clayton if ((flags & eFlagRequiresFrame) && !m_exe_ctx.HasFrameScope()) 257f9fc609fSGreg Clayton { 258f9fc609fSGreg Clayton result.AppendError (GetInvalidFrameDescription()); 259f9fc609fSGreg Clayton return false; 260f9fc609fSGreg Clayton } 261f9fc609fSGreg Clayton 262f9fc609fSGreg Clayton if ((flags & eFlagRequiresRegContext) && (m_exe_ctx.GetRegisterContext() == NULL)) 263f9fc609fSGreg Clayton { 264f9fc609fSGreg Clayton result.AppendError (GetInvalidRegContextDescription()); 265f9fc609fSGreg Clayton return false; 266f9fc609fSGreg Clayton } 267f9fc609fSGreg Clayton 268f9fc609fSGreg Clayton if (flags & eFlagTryTargetAPILock) 269f9fc609fSGreg Clayton { 270f9fc609fSGreg Clayton Target *target = m_exe_ctx.GetTargetPtr(); 271f9fc609fSGreg Clayton if (target) 272f9fc609fSGreg Clayton { 273f9fc609fSGreg Clayton if (m_api_locker.TryLock (target->GetAPIMutex(), NULL) == false) 274f9fc609fSGreg Clayton { 275f9fc609fSGreg Clayton result.AppendError ("failed to get API lock"); 276f9fc609fSGreg Clayton return false; 277f9fc609fSGreg Clayton } 278f9fc609fSGreg Clayton } 279f9fc609fSGreg Clayton } 280f9fc609fSGreg Clayton } 281f9fc609fSGreg Clayton 282b766a73dSGreg Clayton if (GetFlags().AnySet (CommandObject::eFlagProcessMustBeLaunched | CommandObject::eFlagProcessMustBePaused)) 283b766a73dSGreg Clayton { 284c14ee32dSGreg Clayton Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); 28530fdc8d8SChris Lattner if (process == NULL) 28630fdc8d8SChris Lattner { 287b8e8a5f3SJim Ingham // A process that is not running is considered paused. 288b8e8a5f3SJim Ingham if (GetFlags().Test(CommandObject::eFlagProcessMustBeLaunched)) 289b8e8a5f3SJim Ingham { 29030fdc8d8SChris Lattner result.AppendError ("Process must exist."); 29130fdc8d8SChris Lattner result.SetStatus (eReturnStatusFailed); 29230fdc8d8SChris Lattner return false; 29330fdc8d8SChris Lattner } 294b8e8a5f3SJim Ingham } 29530fdc8d8SChris Lattner else 29630fdc8d8SChris Lattner { 29730fdc8d8SChris Lattner StateType state = process->GetState(); 29830fdc8d8SChris Lattner 29930fdc8d8SChris Lattner switch (state) 30030fdc8d8SChris Lattner { 3017a5388bfSGreg Clayton case eStateInvalid: 30230fdc8d8SChris Lattner case eStateSuspended: 30330fdc8d8SChris Lattner case eStateCrashed: 30430fdc8d8SChris Lattner case eStateStopped: 30530fdc8d8SChris Lattner break; 30630fdc8d8SChris Lattner 307b766a73dSGreg Clayton case eStateConnected: 308b766a73dSGreg Clayton case eStateAttaching: 309b766a73dSGreg Clayton case eStateLaunching: 31030fdc8d8SChris Lattner case eStateDetached: 31130fdc8d8SChris Lattner case eStateExited: 31230fdc8d8SChris Lattner case eStateUnloaded: 31373b472d4SGreg Clayton if (GetFlags().Test(CommandObject::eFlagProcessMustBeLaunched)) 31430fdc8d8SChris Lattner { 31530fdc8d8SChris Lattner result.AppendError ("Process must be launched."); 31630fdc8d8SChris Lattner result.SetStatus (eReturnStatusFailed); 31730fdc8d8SChris Lattner return false; 31830fdc8d8SChris Lattner } 31930fdc8d8SChris Lattner break; 32030fdc8d8SChris Lattner 32130fdc8d8SChris Lattner case eStateRunning: 32230fdc8d8SChris Lattner case eStateStepping: 32373b472d4SGreg Clayton if (GetFlags().Test(CommandObject::eFlagProcessMustBePaused)) 32430fdc8d8SChris Lattner { 32530fdc8d8SChris Lattner result.AppendError ("Process is running. Use 'process interrupt' to pause execution."); 32630fdc8d8SChris Lattner result.SetStatus (eReturnStatusFailed); 32730fdc8d8SChris Lattner return false; 32830fdc8d8SChris Lattner } 32930fdc8d8SChris Lattner } 33030fdc8d8SChris Lattner } 331b766a73dSGreg Clayton } 3325a988416SJim Ingham return true; 33330fdc8d8SChris Lattner } 33430fdc8d8SChris Lattner 335f9fc609fSGreg Clayton void 336f9fc609fSGreg Clayton CommandObject::Cleanup () 337f9fc609fSGreg Clayton { 338f9fc609fSGreg Clayton m_exe_ctx.Clear(); 339f9fc609fSGreg Clayton m_api_locker.Unlock(); 340f9fc609fSGreg Clayton } 341f9fc609fSGreg Clayton 342f9fc609fSGreg Clayton 34330fdc8d8SChris Lattner class CommandDictCommandPartialMatch 34430fdc8d8SChris Lattner { 34530fdc8d8SChris Lattner public: 34630fdc8d8SChris Lattner CommandDictCommandPartialMatch (const char *match_str) 34730fdc8d8SChris Lattner { 34830fdc8d8SChris Lattner m_match_str = match_str; 34930fdc8d8SChris Lattner } 35030fdc8d8SChris Lattner bool operator() (const std::pair<std::string, lldb::CommandObjectSP> map_element) const 35130fdc8d8SChris Lattner { 35230fdc8d8SChris Lattner // A NULL or empty string matches everything. 35330fdc8d8SChris Lattner if (m_match_str == NULL || *m_match_str == '\0') 354*c7bece56SGreg Clayton return true; 35530fdc8d8SChris Lattner 356*c7bece56SGreg Clayton return map_element.first.find (m_match_str, 0) == 0; 35730fdc8d8SChris Lattner } 35830fdc8d8SChris Lattner 35930fdc8d8SChris Lattner private: 36030fdc8d8SChris Lattner const char *m_match_str; 36130fdc8d8SChris Lattner }; 36230fdc8d8SChris Lattner 36330fdc8d8SChris Lattner int 36430fdc8d8SChris Lattner CommandObject::AddNamesMatchingPartialString (CommandObject::CommandMap &in_map, const char *cmd_str, 36530fdc8d8SChris Lattner StringList &matches) 36630fdc8d8SChris Lattner { 36730fdc8d8SChris Lattner int number_added = 0; 36830fdc8d8SChris Lattner CommandDictCommandPartialMatch matcher(cmd_str); 36930fdc8d8SChris Lattner 37030fdc8d8SChris Lattner CommandObject::CommandMap::iterator matching_cmds = std::find_if (in_map.begin(), in_map.end(), matcher); 37130fdc8d8SChris Lattner 37230fdc8d8SChris Lattner while (matching_cmds != in_map.end()) 37330fdc8d8SChris Lattner { 37430fdc8d8SChris Lattner ++number_added; 37530fdc8d8SChris Lattner matches.AppendString((*matching_cmds).first.c_str()); 37630fdc8d8SChris Lattner matching_cmds = std::find_if (++matching_cmds, in_map.end(), matcher);; 37730fdc8d8SChris Lattner } 37830fdc8d8SChris Lattner return number_added; 37930fdc8d8SChris Lattner } 38030fdc8d8SChris Lattner 38130fdc8d8SChris Lattner int 38230fdc8d8SChris Lattner CommandObject::HandleCompletion 38330fdc8d8SChris Lattner ( 38430fdc8d8SChris Lattner Args &input, 38530fdc8d8SChris Lattner int &cursor_index, 38630fdc8d8SChris Lattner int &cursor_char_position, 38730fdc8d8SChris Lattner int match_start_point, 38830fdc8d8SChris Lattner int max_return_elements, 389558ce124SJim Ingham bool &word_complete, 39030fdc8d8SChris Lattner StringList &matches 39130fdc8d8SChris Lattner ) 39230fdc8d8SChris Lattner { 3936561d15dSJohnny Chen // Default implmentation of WantsCompletion() is !WantsRawCommandString(). 3946561d15dSJohnny Chen // Subclasses who want raw command string but desire, for example, 3956561d15dSJohnny Chen // argument completion should override WantsCompletion() to return true, 3966561d15dSJohnny Chen // instead. 3976f99b637SJohnny Chen if (WantsRawCommandString() && !WantsCompletion()) 39830fdc8d8SChris Lattner { 39930fdc8d8SChris Lattner // FIXME: Abstract telling the completion to insert the completion character. 40030fdc8d8SChris Lattner matches.Clear(); 40130fdc8d8SChris Lattner return -1; 40230fdc8d8SChris Lattner } 40330fdc8d8SChris Lattner else 40430fdc8d8SChris Lattner { 40530fdc8d8SChris Lattner // Can we do anything generic with the options? 40630fdc8d8SChris Lattner Options *cur_options = GetOptions(); 40730fdc8d8SChris Lattner CommandReturnObject result; 40830fdc8d8SChris Lattner OptionElementVector opt_element_vector; 40930fdc8d8SChris Lattner 41030fdc8d8SChris Lattner if (cur_options != NULL) 41130fdc8d8SChris Lattner { 41230fdc8d8SChris Lattner // Re-insert the dummy command name string which will have been 41330fdc8d8SChris Lattner // stripped off: 41430fdc8d8SChris Lattner input.Unshift ("dummy-string"); 41530fdc8d8SChris Lattner cursor_index++; 41630fdc8d8SChris Lattner 41730fdc8d8SChris Lattner 41830fdc8d8SChris Lattner // I stick an element on the end of the input, because if the last element is 41930fdc8d8SChris Lattner // option that requires an argument, getopt_long will freak out. 42030fdc8d8SChris Lattner 42130fdc8d8SChris Lattner input.AppendArgument ("<FAKE-VALUE>"); 42230fdc8d8SChris Lattner 423d43e0094SJim Ingham input.ParseArgsForCompletion (*cur_options, opt_element_vector, cursor_index); 42430fdc8d8SChris Lattner 42530fdc8d8SChris Lattner input.DeleteArgumentAtIndex(input.GetArgumentCount() - 1); 42630fdc8d8SChris Lattner 42730fdc8d8SChris Lattner bool handled_by_options; 428eb0103f2SGreg Clayton handled_by_options = cur_options->HandleOptionCompletion (input, 42930fdc8d8SChris Lattner opt_element_vector, 43030fdc8d8SChris Lattner cursor_index, 43130fdc8d8SChris Lattner cursor_char_position, 43230fdc8d8SChris Lattner match_start_point, 43330fdc8d8SChris Lattner max_return_elements, 434558ce124SJim Ingham word_complete, 43530fdc8d8SChris Lattner matches); 43630fdc8d8SChris Lattner if (handled_by_options) 43730fdc8d8SChris Lattner return matches.GetSize(); 43830fdc8d8SChris Lattner } 43930fdc8d8SChris Lattner 44030fdc8d8SChris Lattner // If we got here, the last word is not an option or an option argument. 441a7015092SGreg Clayton return HandleArgumentCompletion (input, 44230fdc8d8SChris Lattner cursor_index, 44330fdc8d8SChris Lattner cursor_char_position, 44430fdc8d8SChris Lattner opt_element_vector, 44530fdc8d8SChris Lattner match_start_point, 44630fdc8d8SChris Lattner max_return_elements, 447558ce124SJim Ingham word_complete, 44830fdc8d8SChris Lattner matches); 44930fdc8d8SChris Lattner } 45030fdc8d8SChris Lattner } 45130fdc8d8SChris Lattner 45230fdc8d8SChris Lattner bool 453a7015092SGreg Clayton CommandObject::HelpTextContainsWord (const char *search_word) 45430fdc8d8SChris Lattner { 45530fdc8d8SChris Lattner std::string options_usage_help; 45630fdc8d8SChris Lattner 45730fdc8d8SChris Lattner bool found_word = false; 45830fdc8d8SChris Lattner 459998255bfSGreg Clayton const char *short_help = GetHelp(); 460998255bfSGreg Clayton const char *long_help = GetHelpLong(); 461998255bfSGreg Clayton const char *syntax_help = GetSyntax(); 46230fdc8d8SChris Lattner 463998255bfSGreg Clayton if (short_help && strcasestr (short_help, search_word)) 46430fdc8d8SChris Lattner found_word = true; 465998255bfSGreg Clayton else if (long_help && strcasestr (long_help, search_word)) 46630fdc8d8SChris Lattner found_word = true; 467998255bfSGreg Clayton else if (syntax_help && strcasestr (syntax_help, search_word)) 46830fdc8d8SChris Lattner found_word = true; 46930fdc8d8SChris Lattner 47030fdc8d8SChris Lattner if (!found_word 47130fdc8d8SChris Lattner && GetOptions() != NULL) 47230fdc8d8SChris Lattner { 47330fdc8d8SChris Lattner StreamString usage_help; 474eb0103f2SGreg Clayton GetOptions()->GenerateOptionUsage (usage_help, this); 47530fdc8d8SChris Lattner if (usage_help.GetSize() > 0) 47630fdc8d8SChris Lattner { 47730fdc8d8SChris Lattner const char *usage_text = usage_help.GetData(); 4784b6fbf37SCaroline Tice if (strcasestr (usage_text, search_word)) 47930fdc8d8SChris Lattner found_word = true; 48030fdc8d8SChris Lattner } 48130fdc8d8SChris Lattner } 48230fdc8d8SChris Lattner 48330fdc8d8SChris Lattner return found_word; 48430fdc8d8SChris Lattner } 485e139cf23SCaroline Tice 486e139cf23SCaroline Tice int 487e139cf23SCaroline Tice CommandObject::GetNumArgumentEntries () 488e139cf23SCaroline Tice { 489e139cf23SCaroline Tice return m_arguments.size(); 490e139cf23SCaroline Tice } 491e139cf23SCaroline Tice 492e139cf23SCaroline Tice CommandObject::CommandArgumentEntry * 493e139cf23SCaroline Tice CommandObject::GetArgumentEntryAtIndex (int idx) 494e139cf23SCaroline Tice { 495e139cf23SCaroline Tice if (idx < m_arguments.size()) 496e139cf23SCaroline Tice return &(m_arguments[idx]); 497e139cf23SCaroline Tice 498e139cf23SCaroline Tice return NULL; 499e139cf23SCaroline Tice } 500e139cf23SCaroline Tice 501e139cf23SCaroline Tice CommandObject::ArgumentTableEntry * 502e139cf23SCaroline Tice CommandObject::FindArgumentDataByType (CommandArgumentType arg_type) 503e139cf23SCaroline Tice { 504e139cf23SCaroline Tice const ArgumentTableEntry *table = CommandObject::GetArgumentTable(); 505e139cf23SCaroline Tice 506e139cf23SCaroline Tice for (int i = 0; i < eArgTypeLastArg; ++i) 507e139cf23SCaroline Tice if (table[i].arg_type == arg_type) 508e139cf23SCaroline Tice return (ArgumentTableEntry *) &(table[i]); 509e139cf23SCaroline Tice 510e139cf23SCaroline Tice return NULL; 511e139cf23SCaroline Tice } 512e139cf23SCaroline Tice 513e139cf23SCaroline Tice void 514e139cf23SCaroline Tice CommandObject::GetArgumentHelp (Stream &str, CommandArgumentType arg_type, CommandInterpreter &interpreter) 515e139cf23SCaroline Tice { 516e139cf23SCaroline Tice const ArgumentTableEntry* table = CommandObject::GetArgumentTable(); 517e139cf23SCaroline Tice ArgumentTableEntry *entry = (ArgumentTableEntry *) &(table[arg_type]); 518e139cf23SCaroline Tice 519e139cf23SCaroline Tice // The table is *supposed* to be kept in arg_type order, but someone *could* have messed it up... 520e139cf23SCaroline Tice 521e139cf23SCaroline Tice if (entry->arg_type != arg_type) 522e139cf23SCaroline Tice entry = CommandObject::FindArgumentDataByType (arg_type); 523e139cf23SCaroline Tice 524e139cf23SCaroline Tice if (!entry) 525e139cf23SCaroline Tice return; 526e139cf23SCaroline Tice 527e139cf23SCaroline Tice StreamString name_str; 528e139cf23SCaroline Tice name_str.Printf ("<%s>", entry->arg_name); 529e139cf23SCaroline Tice 530fc7a7f3bSEnrico Granata if (entry->help_function) 53182a7d983SEnrico Granata { 532fc7a7f3bSEnrico Granata const char* help_text = entry->help_function(); 53382a7d983SEnrico Granata if (!entry->help_function.self_formatting) 53482a7d983SEnrico Granata { 53582a7d983SEnrico Granata interpreter.OutputFormattedHelpText (str, name_str.GetData(), "--", help_text, 536e139cf23SCaroline Tice name_str.GetSize()); 53782a7d983SEnrico Granata } 53882a7d983SEnrico Granata else 53982a7d983SEnrico Granata { 54082a7d983SEnrico Granata interpreter.OutputHelpText(str, name_str.GetData(), "--", help_text, 54182a7d983SEnrico Granata name_str.GetSize()); 54282a7d983SEnrico Granata } 54382a7d983SEnrico Granata } 544e139cf23SCaroline Tice else 545e139cf23SCaroline Tice interpreter.OutputFormattedHelpText (str, name_str.GetData(), "--", entry->help_text, name_str.GetSize()); 546e139cf23SCaroline Tice } 547e139cf23SCaroline Tice 548e139cf23SCaroline Tice const char * 549e139cf23SCaroline Tice CommandObject::GetArgumentName (CommandArgumentType arg_type) 550e139cf23SCaroline Tice { 551deaab222SCaroline Tice ArgumentTableEntry *entry = (ArgumentTableEntry *) &(CommandObject::GetArgumentTable()[arg_type]); 552deaab222SCaroline Tice 553deaab222SCaroline Tice // The table is *supposed* to be kept in arg_type order, but someone *could* have messed it up... 554deaab222SCaroline Tice 555deaab222SCaroline Tice if (entry->arg_type != arg_type) 556deaab222SCaroline Tice entry = CommandObject::FindArgumentDataByType (arg_type); 557deaab222SCaroline Tice 558e6acf355SJohnny Chen if (entry) 559deaab222SCaroline Tice return entry->arg_name; 560e6acf355SJohnny Chen 561e6acf355SJohnny Chen StreamString str; 562e6acf355SJohnny Chen str << "Arg name for type (" << arg_type << ") not in arg table!"; 563e6acf355SJohnny Chen return str.GetData(); 564e139cf23SCaroline Tice } 565e139cf23SCaroline Tice 566405fe67fSCaroline Tice bool 567e0d378b3SGreg Clayton CommandObject::IsPairType (ArgumentRepetitionType arg_repeat_type) 568405fe67fSCaroline Tice { 569405fe67fSCaroline Tice if ((arg_repeat_type == eArgRepeatPairPlain) 570405fe67fSCaroline Tice || (arg_repeat_type == eArgRepeatPairOptional) 571405fe67fSCaroline Tice || (arg_repeat_type == eArgRepeatPairPlus) 572405fe67fSCaroline Tice || (arg_repeat_type == eArgRepeatPairStar) 573405fe67fSCaroline Tice || (arg_repeat_type == eArgRepeatPairRange) 574405fe67fSCaroline Tice || (arg_repeat_type == eArgRepeatPairRangeOptional)) 575405fe67fSCaroline Tice return true; 576405fe67fSCaroline Tice 577405fe67fSCaroline Tice return false; 578405fe67fSCaroline Tice } 579405fe67fSCaroline Tice 58034ddc8dbSJohnny Chen static CommandObject::CommandArgumentEntry 58134ddc8dbSJohnny Chen OptSetFiltered(uint32_t opt_set_mask, CommandObject::CommandArgumentEntry &cmd_arg_entry) 58234ddc8dbSJohnny Chen { 58334ddc8dbSJohnny Chen CommandObject::CommandArgumentEntry ret_val; 58434ddc8dbSJohnny Chen for (unsigned i = 0; i < cmd_arg_entry.size(); ++i) 58534ddc8dbSJohnny Chen if (opt_set_mask & cmd_arg_entry[i].arg_opt_set_association) 58634ddc8dbSJohnny Chen ret_val.push_back(cmd_arg_entry[i]); 58734ddc8dbSJohnny Chen return ret_val; 58834ddc8dbSJohnny Chen } 58934ddc8dbSJohnny Chen 59034ddc8dbSJohnny Chen // Default parameter value of opt_set_mask is LLDB_OPT_SET_ALL, which means take 59134ddc8dbSJohnny Chen // all the argument data into account. On rare cases where some argument sticks 59234ddc8dbSJohnny Chen // with certain option sets, this function returns the option set filtered args. 593e139cf23SCaroline Tice void 59434ddc8dbSJohnny Chen CommandObject::GetFormattedCommandArguments (Stream &str, uint32_t opt_set_mask) 595e139cf23SCaroline Tice { 596e139cf23SCaroline Tice int num_args = m_arguments.size(); 597e139cf23SCaroline Tice for (int i = 0; i < num_args; ++i) 598e139cf23SCaroline Tice { 599e139cf23SCaroline Tice if (i > 0) 600e139cf23SCaroline Tice str.Printf (" "); 60134ddc8dbSJohnny Chen CommandArgumentEntry arg_entry = 60234ddc8dbSJohnny Chen opt_set_mask == LLDB_OPT_SET_ALL ? m_arguments[i] 60334ddc8dbSJohnny Chen : OptSetFiltered(opt_set_mask, m_arguments[i]); 604e139cf23SCaroline Tice int num_alternatives = arg_entry.size(); 605405fe67fSCaroline Tice 606405fe67fSCaroline Tice if ((num_alternatives == 2) 607405fe67fSCaroline Tice && IsPairType (arg_entry[0].arg_repetition)) 608405fe67fSCaroline Tice { 609405fe67fSCaroline Tice const char *first_name = GetArgumentName (arg_entry[0].arg_type); 610405fe67fSCaroline Tice const char *second_name = GetArgumentName (arg_entry[1].arg_type); 611405fe67fSCaroline Tice switch (arg_entry[0].arg_repetition) 612405fe67fSCaroline Tice { 613405fe67fSCaroline Tice case eArgRepeatPairPlain: 614405fe67fSCaroline Tice str.Printf ("<%s> <%s>", first_name, second_name); 615405fe67fSCaroline Tice break; 616405fe67fSCaroline Tice case eArgRepeatPairOptional: 617405fe67fSCaroline Tice str.Printf ("[<%s> <%s>]", first_name, second_name); 618405fe67fSCaroline Tice break; 619405fe67fSCaroline Tice case eArgRepeatPairPlus: 620405fe67fSCaroline Tice str.Printf ("<%s> <%s> [<%s> <%s> [...]]", first_name, second_name, first_name, second_name); 621405fe67fSCaroline Tice break; 622405fe67fSCaroline Tice case eArgRepeatPairStar: 623405fe67fSCaroline Tice str.Printf ("[<%s> <%s> [<%s> <%s> [...]]]", first_name, second_name, first_name, second_name); 624405fe67fSCaroline Tice break; 625405fe67fSCaroline Tice case eArgRepeatPairRange: 626405fe67fSCaroline Tice str.Printf ("<%s_1> <%s_1> ... <%s_n> <%s_n>", first_name, second_name, first_name, second_name); 627405fe67fSCaroline Tice break; 628405fe67fSCaroline Tice case eArgRepeatPairRangeOptional: 629405fe67fSCaroline Tice str.Printf ("[<%s_1> <%s_1> ... <%s_n> <%s_n>]", first_name, second_name, first_name, second_name); 630405fe67fSCaroline Tice break; 631ca1176aaSCaroline Tice // Explicitly test for all the rest of the cases, so if new types get added we will notice the 632ca1176aaSCaroline Tice // missing case statement(s). 633ca1176aaSCaroline Tice case eArgRepeatPlain: 634ca1176aaSCaroline Tice case eArgRepeatOptional: 635ca1176aaSCaroline Tice case eArgRepeatPlus: 636ca1176aaSCaroline Tice case eArgRepeatStar: 637ca1176aaSCaroline Tice case eArgRepeatRange: 638ca1176aaSCaroline Tice // These should not be reached, as they should fail the IsPairType test above. 639ca1176aaSCaroline Tice break; 640405fe67fSCaroline Tice } 641405fe67fSCaroline Tice } 642405fe67fSCaroline Tice else 643405fe67fSCaroline Tice { 644e139cf23SCaroline Tice StreamString names; 645e139cf23SCaroline Tice for (int j = 0; j < num_alternatives; ++j) 646e139cf23SCaroline Tice { 647e139cf23SCaroline Tice if (j > 0) 648e139cf23SCaroline Tice names.Printf (" | "); 649e139cf23SCaroline Tice names.Printf ("%s", GetArgumentName (arg_entry[j].arg_type)); 650e139cf23SCaroline Tice } 651e139cf23SCaroline Tice switch (arg_entry[0].arg_repetition) 652e139cf23SCaroline Tice { 653e139cf23SCaroline Tice case eArgRepeatPlain: 654e139cf23SCaroline Tice str.Printf ("<%s>", names.GetData()); 655e139cf23SCaroline Tice break; 656e139cf23SCaroline Tice case eArgRepeatPlus: 657e139cf23SCaroline Tice str.Printf ("<%s> [<%s> [...]]", names.GetData(), names.GetData()); 658e139cf23SCaroline Tice break; 659e139cf23SCaroline Tice case eArgRepeatStar: 660e139cf23SCaroline Tice str.Printf ("[<%s> [<%s> [...]]]", names.GetData(), names.GetData()); 661e139cf23SCaroline Tice break; 662e139cf23SCaroline Tice case eArgRepeatOptional: 663e139cf23SCaroline Tice str.Printf ("[<%s>]", names.GetData()); 664e139cf23SCaroline Tice break; 665405fe67fSCaroline Tice case eArgRepeatRange: 666fd54b368SJason Molenda str.Printf ("<%s_1> .. <%s_n>", names.GetData(), names.GetData()); 667ca1176aaSCaroline Tice break; 668ca1176aaSCaroline Tice // Explicitly test for all the rest of the cases, so if new types get added we will notice the 669ca1176aaSCaroline Tice // missing case statement(s). 670ca1176aaSCaroline Tice case eArgRepeatPairPlain: 671ca1176aaSCaroline Tice case eArgRepeatPairOptional: 672ca1176aaSCaroline Tice case eArgRepeatPairPlus: 673ca1176aaSCaroline Tice case eArgRepeatPairStar: 674ca1176aaSCaroline Tice case eArgRepeatPairRange: 675ca1176aaSCaroline Tice case eArgRepeatPairRangeOptional: 676ca1176aaSCaroline Tice // These should not be hit, as they should pass the IsPairType test above, and control should 677ca1176aaSCaroline Tice // have gone into the other branch of the if statement. 678ca1176aaSCaroline Tice break; 679405fe67fSCaroline Tice } 680e139cf23SCaroline Tice } 681e139cf23SCaroline Tice } 682e139cf23SCaroline Tice } 683e139cf23SCaroline Tice 6840c16aa6dSStephen Wilson CommandArgumentType 685e139cf23SCaroline Tice CommandObject::LookupArgumentName (const char *arg_name) 686e139cf23SCaroline Tice { 687e139cf23SCaroline Tice CommandArgumentType return_type = eArgTypeLastArg; 688e139cf23SCaroline Tice 689e139cf23SCaroline Tice std::string arg_name_str (arg_name); 690e139cf23SCaroline Tice size_t len = arg_name_str.length(); 691e139cf23SCaroline Tice if (arg_name[0] == '<' 692e139cf23SCaroline Tice && arg_name[len-1] == '>') 693e139cf23SCaroline Tice arg_name_str = arg_name_str.substr (1, len-2); 694e139cf23SCaroline Tice 695331eff39SJohnny Chen const ArgumentTableEntry *table = GetArgumentTable(); 696e139cf23SCaroline Tice for (int i = 0; i < eArgTypeLastArg; ++i) 697331eff39SJohnny Chen if (arg_name_str.compare (table[i].arg_name) == 0) 698e139cf23SCaroline Tice return_type = g_arguments_data[i].arg_type; 699e139cf23SCaroline Tice 700e139cf23SCaroline Tice return return_type; 701e139cf23SCaroline Tice } 702e139cf23SCaroline Tice 703e139cf23SCaroline Tice static const char * 704931e674aSJim Ingham RegisterNameHelpTextCallback () 705931e674aSJim Ingham { 706931e674aSJim Ingham return "Register names can be specified using the architecture specific names. " 70784c7bd74SJim Ingham "They can also be specified using generic names. Not all generic entities have " 70884c7bd74SJim Ingham "registers backing them on all architectures. When they don't the generic name " 70984c7bd74SJim Ingham "will return an error.\n" 710931e674aSJim Ingham "The generic names defined in lldb are:\n" 711931e674aSJim Ingham "\n" 712931e674aSJim Ingham "pc - program counter register\n" 713931e674aSJim Ingham "ra - return address register\n" 714931e674aSJim Ingham "fp - frame pointer register\n" 715931e674aSJim Ingham "sp - stack pointer register\n" 71684c7bd74SJim Ingham "flags - the flags register\n" 717931e674aSJim Ingham "arg{1-6} - integer argument passing registers.\n"; 718931e674aSJim Ingham } 719931e674aSJim Ingham 720931e674aSJim Ingham static const char * 721e139cf23SCaroline Tice BreakpointIDHelpTextCallback () 722e139cf23SCaroline Tice { 72386edbf41SGreg Clayton return "Breakpoint ID's consist major and minor numbers; the major number " 72486edbf41SGreg Clayton "corresponds to the single entity that was created with a 'breakpoint set' " 72586edbf41SGreg Clayton "command; the minor numbers correspond to all the locations that were actually " 72686edbf41SGreg Clayton "found/set based on the major breakpoint. A full breakpoint ID might look like " 72786edbf41SGreg Clayton "3.14, meaning the 14th location set for the 3rd breakpoint. You can specify " 72886edbf41SGreg Clayton "all the locations of a breakpoint by just indicating the major breakpoint " 72986edbf41SGreg Clayton "number. A valid breakpoint id consists either of just the major id number, " 73086edbf41SGreg Clayton "or the major number, a dot, and the location number (e.g. 3 or 3.2 could " 73186edbf41SGreg Clayton "both be valid breakpoint ids)."; 732e139cf23SCaroline Tice } 733e139cf23SCaroline Tice 734e139cf23SCaroline Tice static const char * 735e139cf23SCaroline Tice BreakpointIDRangeHelpTextCallback () 736e139cf23SCaroline Tice { 73786edbf41SGreg Clayton return "A 'breakpoint id list' is a manner of specifying multiple breakpoints. " 73886edbf41SGreg Clayton "This can be done through several mechanisms. The easiest way is to just " 73986edbf41SGreg Clayton "enter a space-separated list of breakpoint ids. To specify all the " 74086edbf41SGreg Clayton "breakpoint locations under a major breakpoint, you can use the major " 74186edbf41SGreg Clayton "breakpoint number followed by '.*', eg. '5.*' means all the locations under " 74286edbf41SGreg Clayton "breakpoint 5. You can also indicate a range of breakpoints by using " 74386edbf41SGreg Clayton "<start-bp-id> - <end-bp-id>. The start-bp-id and end-bp-id for a range can " 74486edbf41SGreg Clayton "be any valid breakpoint ids. It is not legal, however, to specify a range " 74586edbf41SGreg Clayton "using specific locations that cross major breakpoint numbers. I.e. 3.2 - 3.7" 74686edbf41SGreg Clayton " is legal; 2 - 5 is legal; but 3.2 - 4.4 is not legal."; 74786edbf41SGreg Clayton } 74886edbf41SGreg Clayton 74986edbf41SGreg Clayton static const char * 75086edbf41SGreg Clayton GDBFormatHelpTextCallback () 75186edbf41SGreg Clayton { 752f91381e8SGreg Clayton return "A GDB format consists of a repeat count, a format letter and a size letter. " 753f91381e8SGreg Clayton "The repeat count is optional and defaults to 1. The format letter is optional " 754f91381e8SGreg Clayton "and defaults to the previous format that was used. The size letter is optional " 755f91381e8SGreg Clayton "and defaults to the previous size that was used.\n" 756f91381e8SGreg Clayton "\n" 757f91381e8SGreg Clayton "Format letters include:\n" 758f91381e8SGreg Clayton "o - octal\n" 759f91381e8SGreg Clayton "x - hexadecimal\n" 760f91381e8SGreg Clayton "d - decimal\n" 761f91381e8SGreg Clayton "u - unsigned decimal\n" 762f91381e8SGreg Clayton "t - binary\n" 763f91381e8SGreg Clayton "f - float\n" 764f91381e8SGreg Clayton "a - address\n" 765f91381e8SGreg Clayton "i - instruction\n" 766f91381e8SGreg Clayton "c - char\n" 767f91381e8SGreg Clayton "s - string\n" 768f91381e8SGreg Clayton "T - OSType\n" 769f91381e8SGreg Clayton "A - float as hex\n" 770f91381e8SGreg Clayton "\n" 771f91381e8SGreg Clayton "Size letters include:\n" 772f91381e8SGreg Clayton "b - 1 byte (byte)\n" 773f91381e8SGreg Clayton "h - 2 bytes (halfword)\n" 774f91381e8SGreg Clayton "w - 4 bytes (word)\n" 775f91381e8SGreg Clayton "g - 8 bytes (giant)\n" 776f91381e8SGreg Clayton "\n" 777f91381e8SGreg Clayton "Example formats:\n" 778f91381e8SGreg Clayton "32xb - show 32 1 byte hexadecimal integer values\n" 779f91381e8SGreg Clayton "16xh - show 16 2 byte hexadecimal integer values\n" 780f91381e8SGreg Clayton "64 - show 64 2 byte hexadecimal integer values (format and size from the last format)\n" 781f91381e8SGreg Clayton "dw - show 1 4 byte decimal integer value\n" 782f91381e8SGreg Clayton ; 783e139cf23SCaroline Tice } 784e139cf23SCaroline Tice 7850a3958e0SEnrico Granata static const char * 7860a3958e0SEnrico Granata FormatHelpTextCallback () 7870a3958e0SEnrico Granata { 78882a7d983SEnrico Granata 78982a7d983SEnrico Granata static char* help_text_ptr = NULL; 79082a7d983SEnrico Granata 79182a7d983SEnrico Granata if (help_text_ptr) 79282a7d983SEnrico Granata return help_text_ptr; 79382a7d983SEnrico Granata 7940a3958e0SEnrico Granata StreamString sstr; 7950a3958e0SEnrico Granata sstr << "One of the format names (or one-character names) that can be used to show a variable's value:\n"; 7960a3958e0SEnrico Granata for (Format f = eFormatDefault; f < kNumFormats; f = Format(f+1)) 7970a3958e0SEnrico Granata { 79882a7d983SEnrico Granata if (f != eFormatDefault) 79982a7d983SEnrico Granata sstr.PutChar('\n'); 80082a7d983SEnrico Granata 8010a3958e0SEnrico Granata char format_char = FormatManager::GetFormatAsFormatChar(f); 8020a3958e0SEnrico Granata if (format_char) 8030a3958e0SEnrico Granata sstr.Printf("'%c' or ", format_char); 8040a3958e0SEnrico Granata 80582a7d983SEnrico Granata sstr.Printf ("\"%s\"", FormatManager::GetFormatAsCString(f)); 8060a3958e0SEnrico Granata } 8070a3958e0SEnrico Granata 8080a3958e0SEnrico Granata sstr.Flush(); 8090a3958e0SEnrico Granata 8100a3958e0SEnrico Granata std::string data = sstr.GetString(); 8110a3958e0SEnrico Granata 81282a7d983SEnrico Granata help_text_ptr = new char[data.length()+1]; 8130a3958e0SEnrico Granata 81482a7d983SEnrico Granata data.copy(help_text_ptr, data.length()); 8150a3958e0SEnrico Granata 81682a7d983SEnrico Granata return help_text_ptr; 8170a3958e0SEnrico Granata } 8180a3958e0SEnrico Granata 8190a3958e0SEnrico Granata static const char * 820d9477397SSean Callanan LanguageTypeHelpTextCallback () 821d9477397SSean Callanan { 822d9477397SSean Callanan static char* help_text_ptr = NULL; 823d9477397SSean Callanan 824d9477397SSean Callanan if (help_text_ptr) 825d9477397SSean Callanan return help_text_ptr; 826d9477397SSean Callanan 827d9477397SSean Callanan StreamString sstr; 828d9477397SSean Callanan sstr << "One of the following languages:\n"; 829d9477397SSean Callanan 83048947c7bSDaniel Malea for (unsigned int l = eLanguageTypeUnknown; l < eNumLanguageTypes; ++l) 831d9477397SSean Callanan { 83248947c7bSDaniel Malea sstr << " " << LanguageRuntime::GetNameForLanguageType(static_cast<LanguageType>(l)) << "\n"; 833d9477397SSean Callanan } 834d9477397SSean Callanan 835d9477397SSean Callanan sstr.Flush(); 836d9477397SSean Callanan 837d9477397SSean Callanan std::string data = sstr.GetString(); 838d9477397SSean Callanan 839d9477397SSean Callanan help_text_ptr = new char[data.length()+1]; 840d9477397SSean Callanan 841d9477397SSean Callanan data.copy(help_text_ptr, data.length()); 842d9477397SSean Callanan 843d9477397SSean Callanan return help_text_ptr; 844d9477397SSean Callanan } 845d9477397SSean Callanan 846d9477397SSean Callanan static const char * 84782a7d983SEnrico Granata SummaryStringHelpTextCallback() 8480a3958e0SEnrico Granata { 84982a7d983SEnrico Granata return 85082a7d983SEnrico Granata "A summary string is a way to extract information from variables in order to present them using a summary.\n" 85182a7d983SEnrico Granata "Summary strings contain static text, variables, scopes and control sequences:\n" 85282a7d983SEnrico Granata " - Static text can be any sequence of non-special characters, i.e. anything but '{', '}', '$', or '\\'.\n" 85382a7d983SEnrico Granata " - Variables are sequences of characters beginning with ${, ending with } and that contain symbols in the format described below.\n" 85482a7d983SEnrico Granata " - Scopes are any sequence of text between { and }. Anything included in a scope will only appear in the output summary if there were no errors.\n" 85582a7d983SEnrico Granata " - Control sequences are the usual C/C++ '\\a', '\\n', ..., plus '\\$', '\\{' and '\\}'.\n" 85682a7d983SEnrico Granata "A summary string works by copying static text verbatim, turning control sequences into their character counterpart, expanding variables and trying to expand scopes.\n" 85782a7d983SEnrico Granata "A variable is expanded by giving it a value other than its textual representation, and the way this is done depends on what comes after the ${ marker.\n" 85882a7d983SEnrico Granata "The most common sequence if ${var followed by an expression path, which is the text one would type to access a member of an aggregate types, given a variable of that type" 85982a7d983SEnrico Granata " (e.g. if type T has a member named x, which has a member named y, and if t is of type T, the expression path would be .x.y and the way to fit that into a summary string would be" 8609128ee2fSEnrico Granata " ${var.x.y}). You can also use ${*var followed by an expression path and in that case the object referred by the path will be dereferenced before being displayed." 8619128ee2fSEnrico Granata " If the object is not a pointer, doing so will cause an error. For additional details on expression paths, you can type 'help expr-path'. \n" 86282a7d983SEnrico Granata "By default, summary strings attempt to display the summary for any variable they reference, and if that fails the value. If neither can be shown, nothing is displayed." 86382a7d983SEnrico Granata "In a summary string, you can also use an array index [n], or a slice-like range [n-m]. This can have two different meanings depending on what kind of object the expression" 86482a7d983SEnrico Granata " path refers to:\n" 86582a7d983SEnrico Granata " - if it is a scalar type (any basic type like int, float, ...) the expression is a bitfield, i.e. the bits indicated by the indexing operator are extracted out of the number" 86682a7d983SEnrico Granata " and displayed as an individual variable\n" 86782a7d983SEnrico Granata " - if it is an array or pointer the array items indicated by the indexing operator are shown as the result of the variable. if the expression is an array, real array items are" 86882a7d983SEnrico Granata " printed; if it is a pointer, the pointer-as-array syntax is used to obtain the values (this means, the latter case can have no range checking)\n" 8699128ee2fSEnrico Granata "If you are trying to display an array for which the size is known, you can also use [] instead of giving an exact range. This has the effect of showing items 0 thru size - 1.\n" 8709128ee2fSEnrico Granata "Additionally, a variable can contain an (optional) format code, as in ${var.x.y%code}, where code can be any of the valid formats described in 'help format', or one of the" 8719128ee2fSEnrico Granata " special symbols only allowed as part of a variable:\n" 8729128ee2fSEnrico Granata " %V: show the value of the object by default\n" 8739128ee2fSEnrico Granata " %S: show the summary of the object by default\n" 8749128ee2fSEnrico Granata " %@: show the runtime-provided object description (for Objective-C, it calls NSPrintForDebugger; for C/C++ it does nothing)\n" 8759128ee2fSEnrico Granata " %L: show the location of the object (memory address or a register name)\n" 8769128ee2fSEnrico Granata " %#: show the number of children of the object\n" 8779128ee2fSEnrico Granata " %T: show the type of the object\n" 8789128ee2fSEnrico Granata "Another variable that you can use in summary strings is ${svar . This sequence works exactly like ${var, including the fact that ${*svar is an allowed sequence, but uses" 8799128ee2fSEnrico Granata " the object's synthetic children provider instead of the actual objects. For instance, if you are using STL synthetic children providers, the following summary string would" 8809128ee2fSEnrico Granata " count the number of actual elements stored in an std::list:\n" 8819128ee2fSEnrico Granata "type summary add -s \"${svar%#}\" -x \"std::list<\""; 8829128ee2fSEnrico Granata } 8839128ee2fSEnrico Granata 8849128ee2fSEnrico Granata static const char * 8859128ee2fSEnrico Granata ExprPathHelpTextCallback() 8869128ee2fSEnrico Granata { 8879128ee2fSEnrico Granata return 8889128ee2fSEnrico Granata "An expression path is the sequence of symbols that is used in C/C++ to access a member variable of an aggregate object (class).\n" 8899128ee2fSEnrico Granata "For instance, given a class:\n" 8909128ee2fSEnrico Granata " class foo {\n" 8919128ee2fSEnrico Granata " int a;\n" 8929128ee2fSEnrico Granata " int b; .\n" 8939128ee2fSEnrico Granata " foo* next;\n" 8949128ee2fSEnrico Granata " };\n" 8959128ee2fSEnrico Granata "the expression to read item b in the item pointed to by next for foo aFoo would be aFoo.next->b.\n" 8969128ee2fSEnrico Granata "Given that aFoo could just be any object of type foo, the string '.next->b' is the expression path, because it can be attached to any foo instance to achieve the effect.\n" 8979128ee2fSEnrico Granata "Expression paths in LLDB include dot (.) and arrow (->) operators, and most commands using expression paths have ways to also accept the star (*) operator.\n" 8989128ee2fSEnrico Granata "The meaning of these operators is the same as the usual one given to them by the C/C++ standards.\n" 8999128ee2fSEnrico Granata "LLDB also has support for indexing ([ ]) in expression paths, and extends the traditional meaning of the square brackets operator to allow bitfield extraction:\n" 9009128ee2fSEnrico Granata "for objects of native types (int, float, char, ...) saying '[n-m]' as an expression path (where n and m are any positive integers, e.g. [3-5]) causes LLDB to extract" 9019128ee2fSEnrico Granata " bits n thru m from the value of the variable. If n == m, [n] is also allowed as a shortcut syntax. For arrays and pointers, expression paths can only contain one index" 9029128ee2fSEnrico Granata " and the meaning of the operation is the same as the one defined by C/C++ (item extraction). Some commands extend bitfield-like syntax for arrays and pointers with the" 9039128ee2fSEnrico Granata " meaning of array slicing (taking elements n thru m inside the array or pointed-to memory)."; 9040a3958e0SEnrico Granata } 9050a3958e0SEnrico Granata 906184d7a72SJohnny Chen void 907de753464SJohnny Chen CommandObject::AddIDsArgumentData(CommandArgumentEntry &arg, CommandArgumentType ID, CommandArgumentType IDRange) 908184d7a72SJohnny Chen { 909184d7a72SJohnny Chen CommandArgumentData id_arg; 910184d7a72SJohnny Chen CommandArgumentData id_range_arg; 911184d7a72SJohnny Chen 912184d7a72SJohnny Chen // Create the first variant for the first (and only) argument for this command. 913de753464SJohnny Chen id_arg.arg_type = ID; 914184d7a72SJohnny Chen id_arg.arg_repetition = eArgRepeatOptional; 915184d7a72SJohnny Chen 916184d7a72SJohnny Chen // Create the second variant for the first (and only) argument for this command. 917de753464SJohnny Chen id_range_arg.arg_type = IDRange; 918184d7a72SJohnny Chen id_range_arg.arg_repetition = eArgRepeatOptional; 919184d7a72SJohnny Chen 920a3234732SJohnny Chen // The first (and only) argument for this command could be either an id or an id_range. 921184d7a72SJohnny Chen // Push both variants into the entry for the first argument for this command. 922184d7a72SJohnny Chen arg.push_back(id_arg); 923184d7a72SJohnny Chen arg.push_back(id_range_arg); 924184d7a72SJohnny Chen } 925184d7a72SJohnny Chen 9269d0402b1SGreg Clayton const char * 9279d0402b1SGreg Clayton CommandObject::GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type) 9289d0402b1SGreg Clayton { 9299d0402b1SGreg Clayton if (arg_type >=0 && arg_type < eArgTypeLastArg) 9309d0402b1SGreg Clayton return g_arguments_data[arg_type].arg_name; 9319d0402b1SGreg Clayton return NULL; 9329d0402b1SGreg Clayton 9339d0402b1SGreg Clayton } 9349d0402b1SGreg Clayton 9359d0402b1SGreg Clayton const char * 9369d0402b1SGreg Clayton CommandObject::GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type) 9379d0402b1SGreg Clayton { 9389d0402b1SGreg Clayton if (arg_type >=0 && arg_type < eArgTypeLastArg) 9399d0402b1SGreg Clayton return g_arguments_data[arg_type].help_text; 9409d0402b1SGreg Clayton return NULL; 9419d0402b1SGreg Clayton } 9429d0402b1SGreg Clayton 9435a988416SJim Ingham bool 9445a988416SJim Ingham CommandObjectParsed::Execute (const char *args_string, CommandReturnObject &result) 9455a988416SJim Ingham { 9465a988416SJim Ingham CommandOverrideCallback command_callback = GetOverrideCallback(); 9475a988416SJim Ingham bool handled = false; 9485a988416SJim Ingham Args cmd_args (args_string); 9495a988416SJim Ingham if (command_callback) 9505a988416SJim Ingham { 9515a988416SJim Ingham Args full_args (GetCommandName ()); 9525a988416SJim Ingham full_args.AppendArguments(cmd_args); 9535a988416SJim Ingham handled = command_callback (GetOverrideCallbackBaton(), full_args.GetConstArgumentVector()); 9545a988416SJim Ingham } 9555a988416SJim Ingham if (!handled) 9565a988416SJim Ingham { 9575a988416SJim Ingham for (size_t i = 0; i < cmd_args.GetArgumentCount(); ++i) 9585a988416SJim Ingham { 9595a988416SJim Ingham const char *tmp_str = cmd_args.GetArgumentAtIndex (i); 9605a988416SJim Ingham if (tmp_str[0] == '`') // back-quote 9615a988416SJim Ingham cmd_args.ReplaceArgumentAtIndex (i, m_interpreter.ProcessEmbeddedScriptCommands (tmp_str)); 9625a988416SJim Ingham } 9635a988416SJim Ingham 964f9fc609fSGreg Clayton if (CheckRequirements(result)) 965f9fc609fSGreg Clayton { 966f9fc609fSGreg Clayton if (ParseOptions (cmd_args, result)) 967f9fc609fSGreg Clayton { 9685a988416SJim Ingham // Call the command-specific version of 'Execute', passing it the already processed arguments. 9695a988416SJim Ingham handled = DoExecute (cmd_args, result); 9705a988416SJim Ingham } 971f9fc609fSGreg Clayton } 972f9fc609fSGreg Clayton 973f9fc609fSGreg Clayton Cleanup(); 974f9fc609fSGreg Clayton } 9755a988416SJim Ingham return handled; 9765a988416SJim Ingham } 9775a988416SJim Ingham 9785a988416SJim Ingham bool 9795a988416SJim Ingham CommandObjectRaw::Execute (const char *args_string, CommandReturnObject &result) 9805a988416SJim Ingham { 9815a988416SJim Ingham CommandOverrideCallback command_callback = GetOverrideCallback(); 9825a988416SJim Ingham bool handled = false; 9835a988416SJim Ingham if (command_callback) 9845a988416SJim Ingham { 9855a988416SJim Ingham std::string full_command (GetCommandName ()); 9865a988416SJim Ingham full_command += ' '; 9875a988416SJim Ingham full_command += args_string; 9885a988416SJim Ingham const char *argv[2] = { NULL, NULL }; 9895a988416SJim Ingham argv[0] = full_command.c_str(); 9905a988416SJim Ingham handled = command_callback (GetOverrideCallbackBaton(), argv); 9915a988416SJim Ingham } 9925a988416SJim Ingham if (!handled) 9935a988416SJim Ingham { 994f9fc609fSGreg Clayton if (CheckRequirements(result)) 9955a988416SJim Ingham handled = DoExecute (args_string, result); 996f9fc609fSGreg Clayton 997f9fc609fSGreg Clayton Cleanup(); 9985a988416SJim Ingham } 9995a988416SJim Ingham return handled; 10005a988416SJim Ingham } 10015a988416SJim Ingham 1002ca7835c6SJohnny Chen static 1003ca7835c6SJohnny Chen const char *arch_helper() 1004ca7835c6SJohnny Chen { 1005d70b14eaSGreg Clayton static StreamString g_archs_help; 1006797a1b37SJohnny Chen if (g_archs_help.Empty()) 1007d70b14eaSGreg Clayton { 1008ca7835c6SJohnny Chen StringList archs; 1009ca7835c6SJohnny Chen ArchSpec::AutoComplete(NULL, archs); 1010d70b14eaSGreg Clayton g_archs_help.Printf("These are the supported architecture names:\n"); 1011797a1b37SJohnny Chen archs.Join("\n", g_archs_help); 1012d70b14eaSGreg Clayton } 1013d70b14eaSGreg Clayton return g_archs_help.GetData(); 1014ca7835c6SJohnny Chen } 1015ca7835c6SJohnny Chen 1016e139cf23SCaroline Tice CommandObject::ArgumentTableEntry 1017e139cf23SCaroline Tice CommandObject::g_arguments_data[] = 1018e139cf23SCaroline Tice { 10197f941d95SEnrico Granata { eArgTypeAddress, "address", CommandCompletions::eNoCompletion, { NULL, false }, "A valid address in the target program's execution space." }, 10207f941d95SEnrico Granata { eArgTypeAliasName, "alias-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of an abbreviation (alias) for a debugger command." }, 10217f941d95SEnrico Granata { eArgTypeAliasOptions, "options-for-aliased-command", CommandCompletions::eNoCompletion, { NULL, false }, "Command options to be used as part of an alias (abbreviation) definition. (See 'help commands alias' for more information.)" }, 1022ca7835c6SJohnny Chen { eArgTypeArchitecture, "arch", CommandCompletions::eArchitectureCompletion, { arch_helper, true }, "The architecture name, e.g. i386 or x86_64." }, 10237f941d95SEnrico Granata { eArgTypeBoolean, "boolean", CommandCompletions::eNoCompletion, { NULL, false }, "A Boolean value: 'true' or 'false'" }, 10247f941d95SEnrico Granata { eArgTypeBreakpointID, "breakpt-id", CommandCompletions::eNoCompletion, { BreakpointIDHelpTextCallback, false }, NULL }, 10257f941d95SEnrico Granata { eArgTypeBreakpointIDRange, "breakpt-id-list", CommandCompletions::eNoCompletion, { BreakpointIDRangeHelpTextCallback, false }, NULL }, 10267f941d95SEnrico Granata { eArgTypeByteSize, "byte-size", CommandCompletions::eNoCompletion, { NULL, false }, "Number of bytes to use." }, 10277f941d95SEnrico Granata { eArgTypeClassName, "class-name", CommandCompletions::eNoCompletion, { NULL, false }, "Then name of a class from the debug information in the program." }, 10287f941d95SEnrico Granata { eArgTypeCommandName, "cmd-name", CommandCompletions::eNoCompletion, { NULL, false }, "A debugger command (may be multiple words), without any options or arguments." }, 10297f941d95SEnrico Granata { eArgTypeCount, "count", CommandCompletions::eNoCompletion, { NULL, false }, "An unsigned integer." }, 10303154255fSSean Callanan { eArgTypeDirectoryName, "directory", CommandCompletions::eDiskDirectoryCompletion, { NULL, false }, "A directory name." }, 10317f941d95SEnrico Granata { eArgTypeEndAddress, "end-address", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, 10327f941d95SEnrico Granata { eArgTypeExpression, "expr", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, 10339128ee2fSEnrico Granata { eArgTypeExpressionPath, "expr-path", CommandCompletions::eNoCompletion, { ExprPathHelpTextCallback, true }, NULL }, 10347f941d95SEnrico Granata { eArgTypeExprFormat, "expression-format", CommandCompletions::eNoCompletion, { NULL, false }, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]" }, 10357f941d95SEnrico Granata { eArgTypeFilename, "filename", CommandCompletions::eDiskFileCompletion, { NULL, false }, "The name of a file (can include path)." }, 10367f941d95SEnrico Granata { eArgTypeFormat, "format", CommandCompletions::eNoCompletion, { FormatHelpTextCallback, true }, NULL }, 10377f941d95SEnrico Granata { eArgTypeFrameIndex, "frame-index", CommandCompletions::eNoCompletion, { NULL, false }, "Index into a thread's list of frames." }, 10387f941d95SEnrico Granata { eArgTypeFullName, "fullname", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, 10397f941d95SEnrico Granata { eArgTypeFunctionName, "function-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a function." }, 1040cd8b7cd0SSean Callanan { eArgTypeFunctionOrSymbol, "function-or-symbol", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a function or symbol." }, 104186edbf41SGreg Clayton { eArgTypeGDBFormat, "gdb-format", CommandCompletions::eNoCompletion, { GDBFormatHelpTextCallback, true }, NULL }, 10427f941d95SEnrico Granata { eArgTypeIndex, "index", CommandCompletions::eNoCompletion, { NULL, false }, "An index into a list." }, 1043d9477397SSean Callanan { eArgTypeLanguage, "language", CommandCompletions::eNoCompletion, { LanguageTypeHelpTextCallback, true }, NULL }, 10447f941d95SEnrico Granata { eArgTypeLineNum, "linenum", CommandCompletions::eNoCompletion, { NULL, false }, "Line number in a source file." }, 10457f941d95SEnrico Granata { eArgTypeLogCategory, "log-category", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a category within a log channel, e.g. all (try \"log list\" to see a list of all channels and their categories." }, 10467f941d95SEnrico Granata { eArgTypeLogChannel, "log-channel", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a log channel, e.g. process.gdb-remote (try \"log list\" to see a list of all channels and their categories)." }, 10477f941d95SEnrico Granata { eArgTypeMethod, "method", CommandCompletions::eNoCompletion, { NULL, false }, "A C++ method name." }, 10487f941d95SEnrico Granata { eArgTypeName, "name", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, 10497f941d95SEnrico Granata { eArgTypeNewPathPrefix, "new-path-prefix", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, 10507f941d95SEnrico Granata { eArgTypeNumLines, "num-lines", CommandCompletions::eNoCompletion, { NULL, false }, "The number of lines to use." }, 10517f941d95SEnrico Granata { eArgTypeNumberPerLine, "number-per-line", CommandCompletions::eNoCompletion, { NULL, false }, "The number of items per line to display." }, 10527f941d95SEnrico Granata { eArgTypeOffset, "offset", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, 10537f941d95SEnrico Granata { eArgTypeOldPathPrefix, "old-path-prefix", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, 10547f941d95SEnrico Granata { eArgTypeOneLiner, "one-line-command", CommandCompletions::eNoCompletion, { NULL, false }, "A command that is entered as a single line of text." }, 10557f941d95SEnrico Granata { eArgTypePid, "pid", CommandCompletions::eNoCompletion, { NULL, false }, "The process ID number." }, 10567f941d95SEnrico Granata { eArgTypePlugin, "plugin", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, 10577f941d95SEnrico Granata { eArgTypeProcessName, "process-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of the process." }, 10589128ee2fSEnrico Granata { eArgTypePythonClass, "python-class", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a Python class." }, 10599128ee2fSEnrico Granata { eArgTypePythonFunction, "python-function", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a Python function." }, 10609128ee2fSEnrico Granata { eArgTypePythonScript, "python-script", CommandCompletions::eNoCompletion, { NULL, false }, "Source code written in Python." }, 10617f941d95SEnrico Granata { eArgTypeQueueName, "queue-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of the thread queue." }, 1062931e674aSJim Ingham { eArgTypeRegisterName, "register-name", CommandCompletions::eNoCompletion, { RegisterNameHelpTextCallback, true }, NULL }, 10637f941d95SEnrico Granata { eArgTypeRegularExpression, "regular-expression", CommandCompletions::eNoCompletion, { NULL, false }, "A regular expression." }, 10647f941d95SEnrico Granata { eArgTypeRunArgs, "run-args", CommandCompletions::eNoCompletion, { NULL, false }, "Arguments to be passed to the target program when it starts executing." }, 10657f941d95SEnrico Granata { eArgTypeRunMode, "run-mode", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, 10660a305db7SEnrico Granata { eArgTypeScriptedCommandSynchronicity, "script-cmd-synchronicity", CommandCompletions::eNoCompletion, { NULL, false }, "The synchronicity to use to run scripted commands with regard to LLDB event system." }, 10677f941d95SEnrico Granata { eArgTypeScriptLang, "script-language", CommandCompletions::eNoCompletion, { NULL, false }, "The scripting language to be used for script-based commands. Currently only Python is valid." }, 10687f941d95SEnrico Granata { eArgTypeSearchWord, "search-word", CommandCompletions::eNoCompletion, { NULL, false }, "The word for which you wish to search for information about." }, 10697f941d95SEnrico Granata { eArgTypeSelector, "selector", CommandCompletions::eNoCompletion, { NULL, false }, "An Objective-C selector name." }, 10707f941d95SEnrico Granata { eArgTypeSettingIndex, "setting-index", CommandCompletions::eNoCompletion, { NULL, false }, "An index into a settings variable that is an array (try 'settings list' to see all the possible settings variables and their types)." }, 10717f941d95SEnrico Granata { eArgTypeSettingKey, "setting-key", CommandCompletions::eNoCompletion, { NULL, false }, "A key into a settings variables that is a dictionary (try 'settings list' to see all the possible settings variables and their types)." }, 10727f941d95SEnrico Granata { eArgTypeSettingPrefix, "setting-prefix", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a settable internal debugger variable up to a dot ('.'), e.g. 'target.process.'" }, 10737f941d95SEnrico Granata { eArgTypeSettingVariableName, "setting-variable-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a settable internal debugger variable. Type 'settings list' to see a complete list of such variables." }, 10747f941d95SEnrico Granata { eArgTypeShlibName, "shlib-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a shared library." }, 10757f941d95SEnrico Granata { eArgTypeSourceFile, "source-file", CommandCompletions::eSourceFileCompletion, { NULL, false }, "The name of a source file.." }, 10767f941d95SEnrico Granata { eArgTypeSortOrder, "sort-order", CommandCompletions::eNoCompletion, { NULL, false }, "Specify a sort order when dumping lists." }, 10777f941d95SEnrico Granata { eArgTypeStartAddress, "start-address", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, 10787f941d95SEnrico Granata { eArgTypeSummaryString, "summary-string", CommandCompletions::eNoCompletion, { SummaryStringHelpTextCallback, true }, NULL }, 10797f941d95SEnrico Granata { eArgTypeSymbol, "symbol", CommandCompletions::eSymbolCompletion, { NULL, false }, "Any symbol name (function name, variable, argument, etc.)" }, 10807f941d95SEnrico Granata { eArgTypeThreadID, "thread-id", CommandCompletions::eNoCompletion, { NULL, false }, "Thread ID number." }, 10817f941d95SEnrico Granata { eArgTypeThreadIndex, "thread-index", CommandCompletions::eNoCompletion, { NULL, false }, "Index into the process' list of threads." }, 10827f941d95SEnrico Granata { eArgTypeThreadName, "thread-name", CommandCompletions::eNoCompletion, { NULL, false }, "The thread's name." }, 1083331eff39SJohnny Chen { eArgTypeUnsignedInteger, "unsigned-integer", CommandCompletions::eNoCompletion, { NULL, false }, "An unsigned integer." }, 10847f941d95SEnrico Granata { eArgTypeUnixSignal, "unix-signal", CommandCompletions::eNoCompletion, { NULL, false }, "A valid Unix signal name or number (e.g. SIGKILL, KILL or 9)." }, 10857f941d95SEnrico Granata { eArgTypeVarName, "variable-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a variable in your program." }, 10867f941d95SEnrico Granata { eArgTypeValue, "value", CommandCompletions::eNoCompletion, { NULL, false }, "A value could be anything, depending on where and how it is used." }, 10877f941d95SEnrico Granata { eArgTypeWidth, "width", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, 10887f941d95SEnrico Granata { eArgTypeNone, "none", CommandCompletions::eNoCompletion, { NULL, false }, "No help available for this." }, 1089b1d7529eSJohnny Chen { eArgTypePlatform, "platform-name", CommandCompletions::ePlatformPluginCompletion, { NULL, false }, "The name of an installed platform plug-in . Type 'platform list' to see a complete list of installed platforms." }, 1090de753464SJohnny Chen { eArgTypeWatchpointID, "watchpt-id", CommandCompletions::eNoCompletion, { NULL, false }, "Watchpoint IDs are positive integers." }, 1091de753464SJohnny Chen { eArgTypeWatchpointIDRange, "watchpt-id-list", CommandCompletions::eNoCompletion, { NULL, false }, "For example, '1-3' or '1 to 3'." }, 1092887062aeSJohnny Chen { eArgTypeWatchType, "watch-type", CommandCompletions::eNoCompletion, { NULL, false }, "Specify the type for a watchpoint." } 1093e139cf23SCaroline Tice }; 1094e139cf23SCaroline Tice 1095e139cf23SCaroline Tice const CommandObject::ArgumentTableEntry* 1096e139cf23SCaroline Tice CommandObject::GetArgumentTable () 1097e139cf23SCaroline Tice { 10989d0402b1SGreg Clayton // If this assertion fires, then the table above is out of date with the CommandArgumentType enumeration 10999d0402b1SGreg Clayton assert ((sizeof (CommandObject::g_arguments_data) / sizeof (CommandObject::ArgumentTableEntry)) == eArgTypeLastArg); 1100e139cf23SCaroline Tice return CommandObject::g_arguments_data; 1101e139cf23SCaroline Tice } 1102e139cf23SCaroline Tice 1103e139cf23SCaroline Tice 1104