Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- CommandObject.cpp ---------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Daniel Malea | 93a6430 | 2012-12-05 00:20:57 +0000 | [diff] [blame] | 10 | #include "lldb/lldb-python.h" |
| 11 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 12 | #include "lldb/Interpreter/CommandObject.h" |
| 13 | |
| 14 | #include <string> |
| 15 | #include <map> |
| 16 | |
| 17 | #include <getopt.h> |
| 18 | #include <stdlib.h> |
| 19 | #include <ctype.h> |
| 20 | |
| 21 | #include "lldb/Core/Address.h" |
Johnny Chen | ca7835c | 2012-05-26 00:32:39 +0000 | [diff] [blame] | 22 | #include "lldb/Core/ArchSpec.h" |
Jim Ingham | 40af72e | 2010-06-15 19:49:27 +0000 | [diff] [blame] | 23 | #include "lldb/Interpreter/Options.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 24 | |
| 25 | // These are for the Sourcename completers. |
| 26 | // FIXME: Make a separate file for the completers. |
Greg Clayton | 53239f0 | 2011-02-08 05:05:52 +0000 | [diff] [blame] | 27 | #include "lldb/Host/FileSpec.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 28 | #include "lldb/Core/FileSpecList.h" |
| 29 | #include "lldb/Target/Process.h" |
| 30 | #include "lldb/Target/Target.h" |
| 31 | |
| 32 | #include "lldb/Interpreter/CommandInterpreter.h" |
| 33 | #include "lldb/Interpreter/CommandReturnObject.h" |
| 34 | #include "lldb/Interpreter/ScriptInterpreter.h" |
| 35 | #include "lldb/Interpreter/ScriptInterpreterPython.h" |
| 36 | |
| 37 | using namespace lldb; |
| 38 | using namespace lldb_private; |
| 39 | |
| 40 | //------------------------------------------------------------------------- |
| 41 | // CommandObject |
| 42 | //------------------------------------------------------------------------- |
| 43 | |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 44 | CommandObject::CommandObject |
| 45 | ( |
| 46 | CommandInterpreter &interpreter, |
| 47 | const char *name, |
| 48 | const char *help, |
| 49 | const char *syntax, |
| 50 | uint32_t flags |
| 51 | ) : |
| 52 | m_interpreter (interpreter), |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 53 | m_cmd_name (name), |
| 54 | m_cmd_help_short (), |
| 55 | m_cmd_help_long (), |
| 56 | m_cmd_syntax (), |
Jim Ingham | 279a6c2 | 2010-07-06 22:46:59 +0000 | [diff] [blame] | 57 | m_is_alias (false), |
Caroline Tice | e139cf2 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 58 | m_flags (flags), |
Greg Clayton | a9f7b79 | 2012-02-29 04:21:24 +0000 | [diff] [blame] | 59 | m_arguments(), |
| 60 | m_command_override_callback (NULL), |
| 61 | m_command_override_baton (NULL) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 62 | { |
| 63 | if (help && help[0]) |
| 64 | m_cmd_help_short = help; |
| 65 | if (syntax && syntax[0]) |
| 66 | m_cmd_syntax = syntax; |
| 67 | } |
| 68 | |
| 69 | CommandObject::~CommandObject () |
| 70 | { |
| 71 | } |
| 72 | |
| 73 | const char * |
| 74 | CommandObject::GetHelp () |
| 75 | { |
| 76 | return m_cmd_help_short.c_str(); |
| 77 | } |
| 78 | |
| 79 | const char * |
| 80 | CommandObject::GetHelpLong () |
| 81 | { |
| 82 | return m_cmd_help_long.c_str(); |
| 83 | } |
| 84 | |
| 85 | const char * |
| 86 | CommandObject::GetSyntax () |
| 87 | { |
Caroline Tice | e139cf2 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 88 | if (m_cmd_syntax.length() == 0) |
| 89 | { |
| 90 | StreamString syntax_str; |
| 91 | syntax_str.Printf ("%s", GetCommandName()); |
| 92 | if (GetOptions() != NULL) |
Caroline Tice | 405fe67 | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 93 | syntax_str.Printf (" <cmd-options>"); |
Caroline Tice | e139cf2 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 94 | if (m_arguments.size() > 0) |
| 95 | { |
| 96 | syntax_str.Printf (" "); |
Enrico Granata | ca5acdb | 2013-06-18 01:17:46 +0000 | [diff] [blame] | 97 | if (WantsRawCommandString() && GetOptions() && GetOptions()->NumCommandOptions()) |
Sean Callanan | a4c6ad1 | 2012-01-04 19:11:25 +0000 | [diff] [blame] | 98 | syntax_str.Printf("-- "); |
Caroline Tice | e139cf2 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 99 | GetFormattedCommandArguments (syntax_str); |
| 100 | } |
| 101 | m_cmd_syntax = syntax_str.GetData (); |
| 102 | } |
| 103 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 104 | return m_cmd_syntax.c_str(); |
| 105 | } |
| 106 | |
| 107 | const char * |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 108 | CommandObject::GetCommandName () |
| 109 | { |
| 110 | return m_cmd_name.c_str(); |
| 111 | } |
| 112 | |
| 113 | void |
| 114 | CommandObject::SetCommandName (const char *name) |
| 115 | { |
| 116 | m_cmd_name = name; |
| 117 | } |
| 118 | |
| 119 | void |
| 120 | CommandObject::SetHelp (const char *cstr) |
| 121 | { |
| 122 | m_cmd_help_short = cstr; |
| 123 | } |
| 124 | |
| 125 | void |
| 126 | CommandObject::SetHelpLong (const char *cstr) |
| 127 | { |
| 128 | m_cmd_help_long = cstr; |
| 129 | } |
| 130 | |
| 131 | void |
Enrico Granata | 99f0b8f | 2011-08-17 01:30:04 +0000 | [diff] [blame] | 132 | CommandObject::SetHelpLong (std::string str) |
| 133 | { |
| 134 | m_cmd_help_long = str; |
| 135 | } |
| 136 | |
| 137 | void |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 138 | CommandObject::SetSyntax (const char *cstr) |
| 139 | { |
| 140 | m_cmd_syntax = cstr; |
| 141 | } |
| 142 | |
| 143 | Options * |
| 144 | CommandObject::GetOptions () |
| 145 | { |
| 146 | // By default commands don't have options unless this virtual function |
| 147 | // is overridden by base classes. |
| 148 | return NULL; |
| 149 | } |
| 150 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 151 | bool |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 152 | CommandObject::ParseOptions |
| 153 | ( |
| 154 | Args& args, |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 155 | CommandReturnObject &result |
| 156 | ) |
| 157 | { |
| 158 | // See if the subclass has options? |
| 159 | Options *options = GetOptions(); |
| 160 | if (options != NULL) |
| 161 | { |
| 162 | Error error; |
Greg Clayton | f6b8b58 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 163 | options->NotifyOptionParsingStarting(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 164 | |
Greg Clayton | b7ad58a | 2013-04-04 20:35:24 +0000 | [diff] [blame] | 165 | // ParseOptions calls getopt_long_only, which always skips the zero'th item in the array and starts at position 1, |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 166 | // so we need to push a dummy value into position zero. |
| 167 | args.Unshift("dummy_string"); |
| 168 | error = args.ParseOptions (*options); |
| 169 | |
| 170 | // The "dummy_string" will have already been removed by ParseOptions, |
| 171 | // so no need to remove it. |
| 172 | |
Greg Clayton | f6b8b58 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 173 | if (error.Success()) |
| 174 | error = options->NotifyOptionParsingFinished(); |
| 175 | |
| 176 | if (error.Success()) |
| 177 | { |
| 178 | if (options->VerifyOptions (result)) |
| 179 | return true; |
| 180 | } |
| 181 | else |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 182 | { |
| 183 | const char *error_cstr = error.AsCString(); |
| 184 | if (error_cstr) |
| 185 | { |
| 186 | // We got an error string, lets use that |
Greg Clayton | 86edbf4 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 187 | result.AppendError(error_cstr); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 188 | } |
| 189 | else |
| 190 | { |
| 191 | // No error string, output the usage information into result |
Greg Clayton | eb0103f | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 192 | options->GenerateOptionUsage (result.GetErrorStream(), this); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 193 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 194 | } |
Greg Clayton | f6b8b58 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 195 | result.SetStatus (eReturnStatusFailed); |
| 196 | return false; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 197 | } |
| 198 | return true; |
| 199 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 200 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 201 | |
| 202 | |
| 203 | bool |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 204 | CommandObject::CheckRequirements (CommandReturnObject &result) |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 205 | { |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 206 | #ifdef LLDB_CONFIGURATION_DEBUG |
| 207 | // Nothing should be stored in m_exe_ctx between running commands as m_exe_ctx |
| 208 | // has shared pointers to the target, process, thread and frame and we don't |
| 209 | // want any CommandObject instances to keep any of these objects around |
| 210 | // longer than for a single command. Every command should call |
| 211 | // CommandObject::Cleanup() after it has completed |
| 212 | assert (m_exe_ctx.GetTargetPtr() == NULL); |
| 213 | assert (m_exe_ctx.GetProcessPtr() == NULL); |
| 214 | assert (m_exe_ctx.GetThreadPtr() == NULL); |
| 215 | assert (m_exe_ctx.GetFramePtr() == NULL); |
| 216 | #endif |
| 217 | |
| 218 | // Lock down the interpreter's execution context prior to running the |
| 219 | // command so we guarantee the selected target, process, thread and frame |
| 220 | // can't go away during the execution |
| 221 | m_exe_ctx = m_interpreter.GetExecutionContext(); |
| 222 | |
| 223 | const uint32_t flags = GetFlags().Get(); |
| 224 | if (flags & (eFlagRequiresTarget | |
| 225 | eFlagRequiresProcess | |
| 226 | eFlagRequiresThread | |
| 227 | eFlagRequiresFrame | |
| 228 | eFlagTryTargetAPILock )) |
| 229 | { |
| 230 | |
| 231 | if ((flags & eFlagRequiresTarget) && !m_exe_ctx.HasTargetScope()) |
| 232 | { |
| 233 | result.AppendError (GetInvalidTargetDescription()); |
| 234 | return false; |
| 235 | } |
| 236 | |
| 237 | if ((flags & eFlagRequiresProcess) && !m_exe_ctx.HasProcessScope()) |
| 238 | { |
| 239 | result.AppendError (GetInvalidProcessDescription()); |
| 240 | return false; |
| 241 | } |
| 242 | |
| 243 | if ((flags & eFlagRequiresThread) && !m_exe_ctx.HasThreadScope()) |
| 244 | { |
| 245 | result.AppendError (GetInvalidThreadDescription()); |
| 246 | return false; |
| 247 | } |
| 248 | |
| 249 | if ((flags & eFlagRequiresFrame) && !m_exe_ctx.HasFrameScope()) |
| 250 | { |
| 251 | result.AppendError (GetInvalidFrameDescription()); |
| 252 | return false; |
| 253 | } |
| 254 | |
| 255 | if ((flags & eFlagRequiresRegContext) && (m_exe_ctx.GetRegisterContext() == NULL)) |
| 256 | { |
| 257 | result.AppendError (GetInvalidRegContextDescription()); |
| 258 | return false; |
| 259 | } |
| 260 | |
| 261 | if (flags & eFlagTryTargetAPILock) |
| 262 | { |
| 263 | Target *target = m_exe_ctx.GetTargetPtr(); |
| 264 | if (target) |
| 265 | { |
| 266 | if (m_api_locker.TryLock (target->GetAPIMutex(), NULL) == false) |
| 267 | { |
| 268 | result.AppendError ("failed to get API lock"); |
| 269 | return false; |
| 270 | } |
| 271 | } |
| 272 | } |
| 273 | } |
| 274 | |
Greg Clayton | b766a73 | 2011-02-04 01:58:07 +0000 | [diff] [blame] | 275 | if (GetFlags().AnySet (CommandObject::eFlagProcessMustBeLaunched | CommandObject::eFlagProcessMustBePaused)) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 276 | { |
Greg Clayton | c14ee32 | 2011-09-22 04:58:26 +0000 | [diff] [blame] | 277 | Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); |
Greg Clayton | b766a73 | 2011-02-04 01:58:07 +0000 | [diff] [blame] | 278 | if (process == NULL) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 279 | { |
Jim Ingham | b8e8a5f | 2011-07-09 00:55:34 +0000 | [diff] [blame] | 280 | // A process that is not running is considered paused. |
| 281 | if (GetFlags().Test(CommandObject::eFlagProcessMustBeLaunched)) |
| 282 | { |
| 283 | result.AppendError ("Process must exist."); |
| 284 | result.SetStatus (eReturnStatusFailed); |
| 285 | return false; |
| 286 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 287 | } |
Greg Clayton | b766a73 | 2011-02-04 01:58:07 +0000 | [diff] [blame] | 288 | else |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 289 | { |
Greg Clayton | b766a73 | 2011-02-04 01:58:07 +0000 | [diff] [blame] | 290 | StateType state = process->GetState(); |
Greg Clayton | b766a73 | 2011-02-04 01:58:07 +0000 | [diff] [blame] | 291 | switch (state) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 292 | { |
Greg Clayton | 7a5388b | 2011-03-20 04:57:14 +0000 | [diff] [blame] | 293 | case eStateInvalid: |
Greg Clayton | b766a73 | 2011-02-04 01:58:07 +0000 | [diff] [blame] | 294 | case eStateSuspended: |
| 295 | case eStateCrashed: |
| 296 | case eStateStopped: |
| 297 | break; |
| 298 | |
| 299 | case eStateConnected: |
| 300 | case eStateAttaching: |
| 301 | case eStateLaunching: |
| 302 | case eStateDetached: |
| 303 | case eStateExited: |
| 304 | case eStateUnloaded: |
| 305 | if (GetFlags().Test(CommandObject::eFlagProcessMustBeLaunched)) |
| 306 | { |
| 307 | result.AppendError ("Process must be launched."); |
| 308 | result.SetStatus (eReturnStatusFailed); |
| 309 | return false; |
| 310 | } |
| 311 | break; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 312 | |
Greg Clayton | b766a73 | 2011-02-04 01:58:07 +0000 | [diff] [blame] | 313 | case eStateRunning: |
| 314 | case eStateStepping: |
| 315 | if (GetFlags().Test(CommandObject::eFlagProcessMustBePaused)) |
| 316 | { |
| 317 | result.AppendError ("Process is running. Use 'process interrupt' to pause execution."); |
| 318 | result.SetStatus (eReturnStatusFailed); |
| 319 | return false; |
| 320 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 321 | } |
| 322 | } |
| 323 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 324 | return true; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 325 | } |
| 326 | |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 327 | void |
| 328 | CommandObject::Cleanup () |
| 329 | { |
| 330 | m_exe_ctx.Clear(); |
| 331 | m_api_locker.Unlock(); |
| 332 | } |
| 333 | |
| 334 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 335 | class CommandDictCommandPartialMatch |
| 336 | { |
| 337 | public: |
| 338 | CommandDictCommandPartialMatch (const char *match_str) |
| 339 | { |
| 340 | m_match_str = match_str; |
| 341 | } |
| 342 | bool operator() (const std::pair<std::string, lldb::CommandObjectSP> map_element) const |
| 343 | { |
| 344 | // A NULL or empty string matches everything. |
| 345 | if (m_match_str == NULL || *m_match_str == '\0') |
Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 346 | return true; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 347 | |
Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 348 | return map_element.first.find (m_match_str, 0) == 0; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | private: |
| 352 | const char *m_match_str; |
| 353 | }; |
| 354 | |
| 355 | int |
| 356 | CommandObject::AddNamesMatchingPartialString (CommandObject::CommandMap &in_map, const char *cmd_str, |
| 357 | StringList &matches) |
| 358 | { |
| 359 | int number_added = 0; |
| 360 | CommandDictCommandPartialMatch matcher(cmd_str); |
| 361 | |
| 362 | CommandObject::CommandMap::iterator matching_cmds = std::find_if (in_map.begin(), in_map.end(), matcher); |
| 363 | |
| 364 | while (matching_cmds != in_map.end()) |
| 365 | { |
| 366 | ++number_added; |
| 367 | matches.AppendString((*matching_cmds).first.c_str()); |
| 368 | matching_cmds = std::find_if (++matching_cmds, in_map.end(), matcher);; |
| 369 | } |
| 370 | return number_added; |
| 371 | } |
| 372 | |
| 373 | int |
| 374 | CommandObject::HandleCompletion |
| 375 | ( |
| 376 | Args &input, |
| 377 | int &cursor_index, |
| 378 | int &cursor_char_position, |
| 379 | int match_start_point, |
| 380 | int max_return_elements, |
Jim Ingham | 558ce12 | 2010-06-30 05:02:46 +0000 | [diff] [blame] | 381 | bool &word_complete, |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 382 | StringList &matches |
| 383 | ) |
| 384 | { |
Johnny Chen | 6561d15 | 2012-01-20 00:59:19 +0000 | [diff] [blame] | 385 | // Default implmentation of WantsCompletion() is !WantsRawCommandString(). |
| 386 | // Subclasses who want raw command string but desire, for example, |
| 387 | // argument completion should override WantsCompletion() to return true, |
| 388 | // instead. |
Johnny Chen | 6f99b63 | 2012-01-19 22:16:06 +0000 | [diff] [blame] | 389 | if (WantsRawCommandString() && !WantsCompletion()) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 390 | { |
| 391 | // FIXME: Abstract telling the completion to insert the completion character. |
| 392 | matches.Clear(); |
| 393 | return -1; |
| 394 | } |
| 395 | else |
| 396 | { |
| 397 | // Can we do anything generic with the options? |
| 398 | Options *cur_options = GetOptions(); |
| 399 | CommandReturnObject result; |
| 400 | OptionElementVector opt_element_vector; |
| 401 | |
| 402 | if (cur_options != NULL) |
| 403 | { |
| 404 | // Re-insert the dummy command name string which will have been |
| 405 | // stripped off: |
| 406 | input.Unshift ("dummy-string"); |
| 407 | cursor_index++; |
| 408 | |
| 409 | |
| 410 | // I stick an element on the end of the input, because if the last element is |
Greg Clayton | b7ad58a | 2013-04-04 20:35:24 +0000 | [diff] [blame] | 411 | // option that requires an argument, getopt_long_only will freak out. |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 412 | |
| 413 | input.AppendArgument ("<FAKE-VALUE>"); |
| 414 | |
Jim Ingham | d43e009 | 2010-06-24 20:31:04 +0000 | [diff] [blame] | 415 | input.ParseArgsForCompletion (*cur_options, opt_element_vector, cursor_index); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 416 | |
| 417 | input.DeleteArgumentAtIndex(input.GetArgumentCount() - 1); |
| 418 | |
| 419 | bool handled_by_options; |
Greg Clayton | eb0103f | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 420 | handled_by_options = cur_options->HandleOptionCompletion (input, |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 421 | opt_element_vector, |
| 422 | cursor_index, |
| 423 | cursor_char_position, |
| 424 | match_start_point, |
| 425 | max_return_elements, |
Jim Ingham | 558ce12 | 2010-06-30 05:02:46 +0000 | [diff] [blame] | 426 | word_complete, |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 427 | matches); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 428 | if (handled_by_options) |
| 429 | return matches.GetSize(); |
| 430 | } |
| 431 | |
| 432 | // If we got here, the last word is not an option or an option argument. |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 433 | return HandleArgumentCompletion (input, |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 434 | cursor_index, |
| 435 | cursor_char_position, |
| 436 | opt_element_vector, |
| 437 | match_start_point, |
| 438 | max_return_elements, |
Jim Ingham | 558ce12 | 2010-06-30 05:02:46 +0000 | [diff] [blame] | 439 | word_complete, |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 440 | matches); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 441 | } |
| 442 | } |
| 443 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 444 | bool |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 445 | CommandObject::HelpTextContainsWord (const char *search_word) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 446 | { |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 447 | std::string options_usage_help; |
| 448 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 449 | bool found_word = false; |
| 450 | |
Greg Clayton | 998255b | 2012-10-13 02:07:45 +0000 | [diff] [blame] | 451 | const char *short_help = GetHelp(); |
| 452 | const char *long_help = GetHelpLong(); |
| 453 | const char *syntax_help = GetSyntax(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 454 | |
Greg Clayton | 998255b | 2012-10-13 02:07:45 +0000 | [diff] [blame] | 455 | if (short_help && strcasestr (short_help, search_word)) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 456 | found_word = true; |
Greg Clayton | 998255b | 2012-10-13 02:07:45 +0000 | [diff] [blame] | 457 | else if (long_help && strcasestr (long_help, search_word)) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 458 | found_word = true; |
Greg Clayton | 998255b | 2012-10-13 02:07:45 +0000 | [diff] [blame] | 459 | else if (syntax_help && strcasestr (syntax_help, search_word)) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 460 | found_word = true; |
| 461 | |
| 462 | if (!found_word |
| 463 | && GetOptions() != NULL) |
| 464 | { |
| 465 | StreamString usage_help; |
Greg Clayton | eb0103f | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 466 | GetOptions()->GenerateOptionUsage (usage_help, this); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 467 | if (usage_help.GetSize() > 0) |
| 468 | { |
| 469 | const char *usage_text = usage_help.GetData(); |
Caroline Tice | 4b6fbf3 | 2010-10-12 22:16:53 +0000 | [diff] [blame] | 470 | if (strcasestr (usage_text, search_word)) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 471 | found_word = true; |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | return found_word; |
| 476 | } |
Caroline Tice | e139cf2 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 477 | |
| 478 | int |
| 479 | CommandObject::GetNumArgumentEntries () |
| 480 | { |
| 481 | return m_arguments.size(); |
| 482 | } |
| 483 | |
| 484 | CommandObject::CommandArgumentEntry * |
| 485 | CommandObject::GetArgumentEntryAtIndex (int idx) |
| 486 | { |
| 487 | if (idx < m_arguments.size()) |
| 488 | return &(m_arguments[idx]); |
| 489 | |
| 490 | return NULL; |
| 491 | } |
| 492 | |
| 493 | CommandObject::ArgumentTableEntry * |
| 494 | CommandObject::FindArgumentDataByType (CommandArgumentType arg_type) |
| 495 | { |
| 496 | const ArgumentTableEntry *table = CommandObject::GetArgumentTable(); |
| 497 | |
| 498 | for (int i = 0; i < eArgTypeLastArg; ++i) |
| 499 | if (table[i].arg_type == arg_type) |
| 500 | return (ArgumentTableEntry *) &(table[i]); |
| 501 | |
| 502 | return NULL; |
| 503 | } |
| 504 | |
| 505 | void |
| 506 | CommandObject::GetArgumentHelp (Stream &str, CommandArgumentType arg_type, CommandInterpreter &interpreter) |
| 507 | { |
| 508 | const ArgumentTableEntry* table = CommandObject::GetArgumentTable(); |
| 509 | ArgumentTableEntry *entry = (ArgumentTableEntry *) &(table[arg_type]); |
| 510 | |
| 511 | // The table is *supposed* to be kept in arg_type order, but someone *could* have messed it up... |
| 512 | |
| 513 | if (entry->arg_type != arg_type) |
| 514 | entry = CommandObject::FindArgumentDataByType (arg_type); |
| 515 | |
| 516 | if (!entry) |
| 517 | return; |
| 518 | |
| 519 | StreamString name_str; |
| 520 | name_str.Printf ("<%s>", entry->arg_name); |
| 521 | |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 522 | if (entry->help_function) |
Enrico Granata | 82a7d98 | 2011-07-07 00:38:40 +0000 | [diff] [blame] | 523 | { |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 524 | const char* help_text = entry->help_function(); |
Enrico Granata | 82a7d98 | 2011-07-07 00:38:40 +0000 | [diff] [blame] | 525 | if (!entry->help_function.self_formatting) |
| 526 | { |
| 527 | interpreter.OutputFormattedHelpText (str, name_str.GetData(), "--", help_text, |
| 528 | name_str.GetSize()); |
| 529 | } |
| 530 | else |
| 531 | { |
| 532 | interpreter.OutputHelpText(str, name_str.GetData(), "--", help_text, |
| 533 | name_str.GetSize()); |
| 534 | } |
| 535 | } |
Caroline Tice | e139cf2 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 536 | else |
| 537 | interpreter.OutputFormattedHelpText (str, name_str.GetData(), "--", entry->help_text, name_str.GetSize()); |
| 538 | } |
| 539 | |
| 540 | const char * |
| 541 | CommandObject::GetArgumentName (CommandArgumentType arg_type) |
| 542 | { |
Caroline Tice | deaab22 | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 543 | ArgumentTableEntry *entry = (ArgumentTableEntry *) &(CommandObject::GetArgumentTable()[arg_type]); |
| 544 | |
| 545 | // The table is *supposed* to be kept in arg_type order, but someone *could* have messed it up... |
| 546 | |
| 547 | if (entry->arg_type != arg_type) |
| 548 | entry = CommandObject::FindArgumentDataByType (arg_type); |
| 549 | |
Johnny Chen | e6acf35 | 2010-10-08 22:01:52 +0000 | [diff] [blame] | 550 | if (entry) |
| 551 | return entry->arg_name; |
| 552 | |
| 553 | StreamString str; |
| 554 | str << "Arg name for type (" << arg_type << ") not in arg table!"; |
| 555 | return str.GetData(); |
Caroline Tice | e139cf2 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 556 | } |
| 557 | |
Caroline Tice | 405fe67 | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 558 | bool |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 559 | CommandObject::IsPairType (ArgumentRepetitionType arg_repeat_type) |
Caroline Tice | 405fe67 | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 560 | { |
| 561 | if ((arg_repeat_type == eArgRepeatPairPlain) |
| 562 | || (arg_repeat_type == eArgRepeatPairOptional) |
| 563 | || (arg_repeat_type == eArgRepeatPairPlus) |
| 564 | || (arg_repeat_type == eArgRepeatPairStar) |
| 565 | || (arg_repeat_type == eArgRepeatPairRange) |
| 566 | || (arg_repeat_type == eArgRepeatPairRangeOptional)) |
| 567 | return true; |
| 568 | |
| 569 | return false; |
| 570 | } |
| 571 | |
Johnny Chen | 34ddc8d | 2012-02-08 01:13:31 +0000 | [diff] [blame] | 572 | static CommandObject::CommandArgumentEntry |
| 573 | OptSetFiltered(uint32_t opt_set_mask, CommandObject::CommandArgumentEntry &cmd_arg_entry) |
| 574 | { |
| 575 | CommandObject::CommandArgumentEntry ret_val; |
| 576 | for (unsigned i = 0; i < cmd_arg_entry.size(); ++i) |
| 577 | if (opt_set_mask & cmd_arg_entry[i].arg_opt_set_association) |
| 578 | ret_val.push_back(cmd_arg_entry[i]); |
| 579 | return ret_val; |
| 580 | } |
| 581 | |
| 582 | // Default parameter value of opt_set_mask is LLDB_OPT_SET_ALL, which means take |
| 583 | // all the argument data into account. On rare cases where some argument sticks |
| 584 | // with certain option sets, this function returns the option set filtered args. |
Caroline Tice | e139cf2 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 585 | void |
Johnny Chen | 34ddc8d | 2012-02-08 01:13:31 +0000 | [diff] [blame] | 586 | CommandObject::GetFormattedCommandArguments (Stream &str, uint32_t opt_set_mask) |
Caroline Tice | e139cf2 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 587 | { |
| 588 | int num_args = m_arguments.size(); |
| 589 | for (int i = 0; i < num_args; ++i) |
| 590 | { |
| 591 | if (i > 0) |
| 592 | str.Printf (" "); |
Johnny Chen | 34ddc8d | 2012-02-08 01:13:31 +0000 | [diff] [blame] | 593 | CommandArgumentEntry arg_entry = |
| 594 | opt_set_mask == LLDB_OPT_SET_ALL ? m_arguments[i] |
| 595 | : OptSetFiltered(opt_set_mask, m_arguments[i]); |
Caroline Tice | e139cf2 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 596 | int num_alternatives = arg_entry.size(); |
Caroline Tice | 405fe67 | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 597 | |
| 598 | if ((num_alternatives == 2) |
| 599 | && IsPairType (arg_entry[0].arg_repetition)) |
Caroline Tice | e139cf2 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 600 | { |
Caroline Tice | 405fe67 | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 601 | const char *first_name = GetArgumentName (arg_entry[0].arg_type); |
| 602 | const char *second_name = GetArgumentName (arg_entry[1].arg_type); |
| 603 | switch (arg_entry[0].arg_repetition) |
| 604 | { |
| 605 | case eArgRepeatPairPlain: |
| 606 | str.Printf ("<%s> <%s>", first_name, second_name); |
| 607 | break; |
| 608 | case eArgRepeatPairOptional: |
| 609 | str.Printf ("[<%s> <%s>]", first_name, second_name); |
| 610 | break; |
| 611 | case eArgRepeatPairPlus: |
| 612 | str.Printf ("<%s> <%s> [<%s> <%s> [...]]", first_name, second_name, first_name, second_name); |
| 613 | break; |
| 614 | case eArgRepeatPairStar: |
| 615 | str.Printf ("[<%s> <%s> [<%s> <%s> [...]]]", first_name, second_name, first_name, second_name); |
| 616 | break; |
| 617 | case eArgRepeatPairRange: |
| 618 | str.Printf ("<%s_1> <%s_1> ... <%s_n> <%s_n>", first_name, second_name, first_name, second_name); |
| 619 | break; |
| 620 | case eArgRepeatPairRangeOptional: |
| 621 | str.Printf ("[<%s_1> <%s_1> ... <%s_n> <%s_n>]", first_name, second_name, first_name, second_name); |
| 622 | break; |
Caroline Tice | ca1176a | 2011-03-23 22:31:13 +0000 | [diff] [blame] | 623 | // Explicitly test for all the rest of the cases, so if new types get added we will notice the |
| 624 | // missing case statement(s). |
| 625 | case eArgRepeatPlain: |
| 626 | case eArgRepeatOptional: |
| 627 | case eArgRepeatPlus: |
| 628 | case eArgRepeatStar: |
| 629 | case eArgRepeatRange: |
| 630 | // These should not be reached, as they should fail the IsPairType test above. |
| 631 | break; |
Caroline Tice | 405fe67 | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 632 | } |
Caroline Tice | e139cf2 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 633 | } |
Caroline Tice | 405fe67 | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 634 | else |
Caroline Tice | e139cf2 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 635 | { |
Caroline Tice | 405fe67 | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 636 | StreamString names; |
| 637 | for (int j = 0; j < num_alternatives; ++j) |
| 638 | { |
| 639 | if (j > 0) |
| 640 | names.Printf (" | "); |
| 641 | names.Printf ("%s", GetArgumentName (arg_entry[j].arg_type)); |
| 642 | } |
| 643 | switch (arg_entry[0].arg_repetition) |
| 644 | { |
| 645 | case eArgRepeatPlain: |
| 646 | str.Printf ("<%s>", names.GetData()); |
| 647 | break; |
| 648 | case eArgRepeatPlus: |
| 649 | str.Printf ("<%s> [<%s> [...]]", names.GetData(), names.GetData()); |
| 650 | break; |
| 651 | case eArgRepeatStar: |
| 652 | str.Printf ("[<%s> [<%s> [...]]]", names.GetData(), names.GetData()); |
| 653 | break; |
| 654 | case eArgRepeatOptional: |
| 655 | str.Printf ("[<%s>]", names.GetData()); |
| 656 | break; |
| 657 | case eArgRepeatRange: |
Jason Molenda | fd54b36 | 2011-09-20 21:44:10 +0000 | [diff] [blame] | 658 | str.Printf ("<%s_1> .. <%s_n>", names.GetData(), names.GetData()); |
Caroline Tice | ca1176a | 2011-03-23 22:31:13 +0000 | [diff] [blame] | 659 | break; |
| 660 | // Explicitly test for all the rest of the cases, so if new types get added we will notice the |
| 661 | // missing case statement(s). |
| 662 | case eArgRepeatPairPlain: |
| 663 | case eArgRepeatPairOptional: |
| 664 | case eArgRepeatPairPlus: |
| 665 | case eArgRepeatPairStar: |
| 666 | case eArgRepeatPairRange: |
| 667 | case eArgRepeatPairRangeOptional: |
| 668 | // These should not be hit, as they should pass the IsPairType test above, and control should |
| 669 | // have gone into the other branch of the if statement. |
| 670 | break; |
Caroline Tice | 405fe67 | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 671 | } |
Caroline Tice | e139cf2 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 672 | } |
| 673 | } |
| 674 | } |
| 675 | |
Stephen Wilson | 0c16aa6 | 2011-03-23 02:12:10 +0000 | [diff] [blame] | 676 | CommandArgumentType |
Caroline Tice | e139cf2 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 677 | CommandObject::LookupArgumentName (const char *arg_name) |
| 678 | { |
| 679 | CommandArgumentType return_type = eArgTypeLastArg; |
| 680 | |
| 681 | std::string arg_name_str (arg_name); |
| 682 | size_t len = arg_name_str.length(); |
| 683 | if (arg_name[0] == '<' |
| 684 | && arg_name[len-1] == '>') |
| 685 | arg_name_str = arg_name_str.substr (1, len-2); |
| 686 | |
Johnny Chen | 331eff3 | 2011-07-14 22:20:12 +0000 | [diff] [blame] | 687 | const ArgumentTableEntry *table = GetArgumentTable(); |
Caroline Tice | e139cf2 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 688 | for (int i = 0; i < eArgTypeLastArg; ++i) |
Johnny Chen | 331eff3 | 2011-07-14 22:20:12 +0000 | [diff] [blame] | 689 | if (arg_name_str.compare (table[i].arg_name) == 0) |
Caroline Tice | e139cf2 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 690 | return_type = g_arguments_data[i].arg_type; |
| 691 | |
| 692 | return return_type; |
| 693 | } |
| 694 | |
| 695 | static const char * |
Jim Ingham | 931e674 | 2012-08-23 23:37:31 +0000 | [diff] [blame] | 696 | RegisterNameHelpTextCallback () |
| 697 | { |
| 698 | return "Register names can be specified using the architecture specific names. " |
Jim Ingham | 84c7bd7 | 2012-08-23 23:47:08 +0000 | [diff] [blame] | 699 | "They can also be specified using generic names. Not all generic entities have " |
| 700 | "registers backing them on all architectures. When they don't the generic name " |
| 701 | "will return an error.\n" |
Jim Ingham | 931e674 | 2012-08-23 23:37:31 +0000 | [diff] [blame] | 702 | "The generic names defined in lldb are:\n" |
| 703 | "\n" |
| 704 | "pc - program counter register\n" |
| 705 | "ra - return address register\n" |
| 706 | "fp - frame pointer register\n" |
| 707 | "sp - stack pointer register\n" |
Jim Ingham | 84c7bd7 | 2012-08-23 23:47:08 +0000 | [diff] [blame] | 708 | "flags - the flags register\n" |
Jim Ingham | 931e674 | 2012-08-23 23:37:31 +0000 | [diff] [blame] | 709 | "arg{1-6} - integer argument passing registers.\n"; |
| 710 | } |
| 711 | |
| 712 | static const char * |
Caroline Tice | e139cf2 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 713 | BreakpointIDHelpTextCallback () |
| 714 | { |
Greg Clayton | 86edbf4 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 715 | return "Breakpoint ID's consist major and minor numbers; the major number " |
| 716 | "corresponds to the single entity that was created with a 'breakpoint set' " |
| 717 | "command; the minor numbers correspond to all the locations that were actually " |
| 718 | "found/set based on the major breakpoint. A full breakpoint ID might look like " |
| 719 | "3.14, meaning the 14th location set for the 3rd breakpoint. You can specify " |
| 720 | "all the locations of a breakpoint by just indicating the major breakpoint " |
| 721 | "number. A valid breakpoint id consists either of just the major id number, " |
| 722 | "or the major number, a dot, and the location number (e.g. 3 or 3.2 could " |
| 723 | "both be valid breakpoint ids)."; |
Caroline Tice | e139cf2 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 724 | } |
| 725 | |
| 726 | static const char * |
| 727 | BreakpointIDRangeHelpTextCallback () |
| 728 | { |
Greg Clayton | 86edbf4 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 729 | return "A 'breakpoint id list' is a manner of specifying multiple breakpoints. " |
| 730 | "This can be done through several mechanisms. The easiest way is to just " |
| 731 | "enter a space-separated list of breakpoint ids. To specify all the " |
| 732 | "breakpoint locations under a major breakpoint, you can use the major " |
| 733 | "breakpoint number followed by '.*', eg. '5.*' means all the locations under " |
| 734 | "breakpoint 5. You can also indicate a range of breakpoints by using " |
| 735 | "<start-bp-id> - <end-bp-id>. The start-bp-id and end-bp-id for a range can " |
| 736 | "be any valid breakpoint ids. It is not legal, however, to specify a range " |
| 737 | "using specific locations that cross major breakpoint numbers. I.e. 3.2 - 3.7" |
| 738 | " is legal; 2 - 5 is legal; but 3.2 - 4.4 is not legal."; |
Caroline Tice | e139cf2 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 739 | } |
| 740 | |
Enrico Granata | 0a3958e | 2011-07-02 00:25:22 +0000 | [diff] [blame] | 741 | static const char * |
Greg Clayton | 86edbf4 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 742 | GDBFormatHelpTextCallback () |
| 743 | { |
Greg Clayton | f91381e | 2011-10-26 18:35:21 +0000 | [diff] [blame] | 744 | return "A GDB format consists of a repeat count, a format letter and a size letter. " |
| 745 | "The repeat count is optional and defaults to 1. The format letter is optional " |
| 746 | "and defaults to the previous format that was used. The size letter is optional " |
| 747 | "and defaults to the previous size that was used.\n" |
| 748 | "\n" |
| 749 | "Format letters include:\n" |
| 750 | "o - octal\n" |
| 751 | "x - hexadecimal\n" |
| 752 | "d - decimal\n" |
| 753 | "u - unsigned decimal\n" |
| 754 | "t - binary\n" |
| 755 | "f - float\n" |
| 756 | "a - address\n" |
| 757 | "i - instruction\n" |
| 758 | "c - char\n" |
| 759 | "s - string\n" |
| 760 | "T - OSType\n" |
| 761 | "A - float as hex\n" |
| 762 | "\n" |
| 763 | "Size letters include:\n" |
| 764 | "b - 1 byte (byte)\n" |
| 765 | "h - 2 bytes (halfword)\n" |
| 766 | "w - 4 bytes (word)\n" |
| 767 | "g - 8 bytes (giant)\n" |
| 768 | "\n" |
| 769 | "Example formats:\n" |
| 770 | "32xb - show 32 1 byte hexadecimal integer values\n" |
| 771 | "16xh - show 16 2 byte hexadecimal integer values\n" |
| 772 | "64 - show 64 2 byte hexadecimal integer values (format and size from the last format)\n" |
| 773 | "dw - show 1 4 byte decimal integer value\n" |
| 774 | ; |
Greg Clayton | 86edbf4 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 775 | } |
| 776 | |
| 777 | static const char * |
Enrico Granata | 0a3958e | 2011-07-02 00:25:22 +0000 | [diff] [blame] | 778 | FormatHelpTextCallback () |
| 779 | { |
Enrico Granata | 82a7d98 | 2011-07-07 00:38:40 +0000 | [diff] [blame] | 780 | |
| 781 | static char* help_text_ptr = NULL; |
| 782 | |
| 783 | if (help_text_ptr) |
| 784 | return help_text_ptr; |
| 785 | |
Enrico Granata | 0a3958e | 2011-07-02 00:25:22 +0000 | [diff] [blame] | 786 | StreamString sstr; |
| 787 | sstr << "One of the format names (or one-character names) that can be used to show a variable's value:\n"; |
| 788 | for (Format f = eFormatDefault; f < kNumFormats; f = Format(f+1)) |
| 789 | { |
Enrico Granata | 82a7d98 | 2011-07-07 00:38:40 +0000 | [diff] [blame] | 790 | if (f != eFormatDefault) |
| 791 | sstr.PutChar('\n'); |
| 792 | |
Enrico Granata | 0a3958e | 2011-07-02 00:25:22 +0000 | [diff] [blame] | 793 | char format_char = FormatManager::GetFormatAsFormatChar(f); |
| 794 | if (format_char) |
| 795 | sstr.Printf("'%c' or ", format_char); |
| 796 | |
Enrico Granata | 82a7d98 | 2011-07-07 00:38:40 +0000 | [diff] [blame] | 797 | sstr.Printf ("\"%s\"", FormatManager::GetFormatAsCString(f)); |
Enrico Granata | 0a3958e | 2011-07-02 00:25:22 +0000 | [diff] [blame] | 798 | } |
| 799 | |
| 800 | sstr.Flush(); |
| 801 | |
| 802 | std::string data = sstr.GetString(); |
| 803 | |
Enrico Granata | 82a7d98 | 2011-07-07 00:38:40 +0000 | [diff] [blame] | 804 | help_text_ptr = new char[data.length()+1]; |
Enrico Granata | 0a3958e | 2011-07-02 00:25:22 +0000 | [diff] [blame] | 805 | |
Enrico Granata | 82a7d98 | 2011-07-07 00:38:40 +0000 | [diff] [blame] | 806 | data.copy(help_text_ptr, data.length()); |
Enrico Granata | 0a3958e | 2011-07-02 00:25:22 +0000 | [diff] [blame] | 807 | |
Enrico Granata | 82a7d98 | 2011-07-07 00:38:40 +0000 | [diff] [blame] | 808 | return help_text_ptr; |
Enrico Granata | 0a3958e | 2011-07-02 00:25:22 +0000 | [diff] [blame] | 809 | } |
| 810 | |
| 811 | static const char * |
Sean Callanan | d947739 | 2012-10-23 00:50:09 +0000 | [diff] [blame] | 812 | LanguageTypeHelpTextCallback () |
| 813 | { |
| 814 | static char* help_text_ptr = NULL; |
| 815 | |
| 816 | if (help_text_ptr) |
| 817 | return help_text_ptr; |
| 818 | |
| 819 | StreamString sstr; |
| 820 | sstr << "One of the following languages:\n"; |
| 821 | |
Daniel Malea | 48947c7 | 2012-12-04 00:23:45 +0000 | [diff] [blame] | 822 | for (unsigned int l = eLanguageTypeUnknown; l < eNumLanguageTypes; ++l) |
Sean Callanan | d947739 | 2012-10-23 00:50:09 +0000 | [diff] [blame] | 823 | { |
Daniel Malea | 48947c7 | 2012-12-04 00:23:45 +0000 | [diff] [blame] | 824 | sstr << " " << LanguageRuntime::GetNameForLanguageType(static_cast<LanguageType>(l)) << "\n"; |
Sean Callanan | d947739 | 2012-10-23 00:50:09 +0000 | [diff] [blame] | 825 | } |
| 826 | |
| 827 | sstr.Flush(); |
| 828 | |
| 829 | std::string data = sstr.GetString(); |
| 830 | |
| 831 | help_text_ptr = new char[data.length()+1]; |
| 832 | |
| 833 | data.copy(help_text_ptr, data.length()); |
| 834 | |
| 835 | return help_text_ptr; |
| 836 | } |
| 837 | |
| 838 | static const char * |
Enrico Granata | 82a7d98 | 2011-07-07 00:38:40 +0000 | [diff] [blame] | 839 | SummaryStringHelpTextCallback() |
Enrico Granata | 0a3958e | 2011-07-02 00:25:22 +0000 | [diff] [blame] | 840 | { |
Enrico Granata | 82a7d98 | 2011-07-07 00:38:40 +0000 | [diff] [blame] | 841 | return |
| 842 | "A summary string is a way to extract information from variables in order to present them using a summary.\n" |
| 843 | "Summary strings contain static text, variables, scopes and control sequences:\n" |
| 844 | " - Static text can be any sequence of non-special characters, i.e. anything but '{', '}', '$', or '\\'.\n" |
| 845 | " - Variables are sequences of characters beginning with ${, ending with } and that contain symbols in the format described below.\n" |
| 846 | " - 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" |
| 847 | " - Control sequences are the usual C/C++ '\\a', '\\n', ..., plus '\\$', '\\{' and '\\}'.\n" |
| 848 | "A summary string works by copying static text verbatim, turning control sequences into their character counterpart, expanding variables and trying to expand scopes.\n" |
| 849 | "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" |
| 850 | "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" |
| 851 | " (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" |
Enrico Granata | 9128ee2 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 852 | " ${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." |
| 853 | " 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" |
Enrico Granata | 82a7d98 | 2011-07-07 00:38:40 +0000 | [diff] [blame] | 854 | "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." |
| 855 | "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" |
| 856 | " path refers to:\n" |
| 857 | " - 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" |
| 858 | " and displayed as an individual variable\n" |
| 859 | " - 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" |
| 860 | " 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" |
Enrico Granata | 9128ee2 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 861 | "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" |
| 862 | "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" |
| 863 | " special symbols only allowed as part of a variable:\n" |
| 864 | " %V: show the value of the object by default\n" |
| 865 | " %S: show the summary of the object by default\n" |
| 866 | " %@: show the runtime-provided object description (for Objective-C, it calls NSPrintForDebugger; for C/C++ it does nothing)\n" |
| 867 | " %L: show the location of the object (memory address or a register name)\n" |
| 868 | " %#: show the number of children of the object\n" |
| 869 | " %T: show the type of the object\n" |
| 870 | "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" |
| 871 | " 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" |
| 872 | " count the number of actual elements stored in an std::list:\n" |
| 873 | "type summary add -s \"${svar%#}\" -x \"std::list<\""; |
| 874 | } |
| 875 | |
| 876 | static const char * |
| 877 | ExprPathHelpTextCallback() |
| 878 | { |
| 879 | return |
| 880 | "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" |
| 881 | "For instance, given a class:\n" |
| 882 | " class foo {\n" |
| 883 | " int a;\n" |
| 884 | " int b; .\n" |
| 885 | " foo* next;\n" |
| 886 | " };\n" |
| 887 | "the expression to read item b in the item pointed to by next for foo aFoo would be aFoo.next->b.\n" |
| 888 | "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" |
| 889 | "Expression paths in LLDB include dot (.) and arrow (->) operators, and most commands using expression paths have ways to also accept the star (*) operator.\n" |
| 890 | "The meaning of these operators is the same as the usual one given to them by the C/C++ standards.\n" |
| 891 | "LLDB also has support for indexing ([ ]) in expression paths, and extends the traditional meaning of the square brackets operator to allow bitfield extraction:\n" |
| 892 | "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" |
| 893 | " 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" |
| 894 | " 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" |
| 895 | " meaning of array slicing (taking elements n thru m inside the array or pointed-to memory)."; |
Enrico Granata | 0a3958e | 2011-07-02 00:25:22 +0000 | [diff] [blame] | 896 | } |
| 897 | |
Johnny Chen | 184d7a7 | 2011-09-21 01:00:02 +0000 | [diff] [blame] | 898 | void |
Enrico Granata | 9b62d1d | 2013-06-12 01:50:57 +0000 | [diff] [blame] | 899 | CommandObject::GenerateHelpText (CommandReturnObject &result) |
| 900 | { |
| 901 | GenerateHelpText(result.GetOutputStream()); |
| 902 | |
| 903 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 904 | } |
| 905 | |
| 906 | void |
| 907 | CommandObject::GenerateHelpText (Stream &output_strm) |
| 908 | { |
| 909 | CommandInterpreter& interpreter = GetCommandInterpreter(); |
| 910 | if (GetOptions() != NULL) |
| 911 | { |
| 912 | if (WantsRawCommandString()) |
| 913 | { |
| 914 | std::string help_text (GetHelp()); |
| 915 | help_text.append (" This command takes 'raw' input (no need to quote stuff)."); |
| 916 | interpreter.OutputFormattedHelpText (output_strm, "", "", help_text.c_str(), 1); |
| 917 | } |
| 918 | else |
| 919 | interpreter.OutputFormattedHelpText (output_strm, "", "", GetHelp(), 1); |
| 920 | output_strm.Printf ("\nSyntax: %s\n", GetSyntax()); |
| 921 | GetOptions()->GenerateOptionUsage (output_strm, this); |
| 922 | const char *long_help = GetHelpLong(); |
| 923 | if ((long_help != NULL) |
| 924 | && (strlen (long_help) > 0)) |
| 925 | output_strm.Printf ("\n%s", long_help); |
| 926 | if (WantsRawCommandString() && !WantsCompletion()) |
| 927 | { |
| 928 | // Emit the message about using ' -- ' between the end of the command options and the raw input |
| 929 | // conditionally, i.e., only if the command object does not want completion. |
| 930 | interpreter.OutputFormattedHelpText (output_strm, "", "", |
| 931 | "\nIMPORTANT NOTE: Because this command takes 'raw' input, if you use any command options" |
| 932 | " you must use ' -- ' between the end of the command options and the beginning of the raw input.", 1); |
| 933 | } |
| 934 | else if (GetNumArgumentEntries() > 0 |
| 935 | && GetOptions() |
| 936 | && GetOptions()->NumCommandOptions() > 0) |
| 937 | { |
| 938 | // Also emit a warning about using "--" in case you are using a command that takes options and arguments. |
| 939 | interpreter.OutputFormattedHelpText (output_strm, "", "", |
| 940 | "\nThis command takes options and free-form arguments. If your arguments resemble" |
| 941 | " option specifiers (i.e., they start with a - or --), you must use ' -- ' between" |
| 942 | " the end of the command options and the beginning of the arguments.", 1); |
| 943 | } |
| 944 | } |
| 945 | else if (IsMultiwordObject()) |
| 946 | { |
| 947 | if (WantsRawCommandString()) |
| 948 | { |
| 949 | std::string help_text (GetHelp()); |
| 950 | help_text.append (" This command takes 'raw' input (no need to quote stuff)."); |
| 951 | interpreter.OutputFormattedHelpText (output_strm, "", "", help_text.c_str(), 1); |
| 952 | } |
| 953 | else |
| 954 | interpreter.OutputFormattedHelpText (output_strm, "", "", GetHelp(), 1); |
| 955 | GenerateHelpText (output_strm); |
| 956 | } |
| 957 | else |
| 958 | { |
| 959 | const char *long_help = GetHelpLong(); |
| 960 | if ((long_help != NULL) |
| 961 | && (strlen (long_help) > 0)) |
| 962 | output_strm.Printf ("%s", long_help); |
| 963 | else if (WantsRawCommandString()) |
| 964 | { |
| 965 | std::string help_text (GetHelp()); |
| 966 | help_text.append (" This command takes 'raw' input (no need to quote stuff)."); |
| 967 | interpreter.OutputFormattedHelpText (output_strm, "", "", help_text.c_str(), 1); |
| 968 | } |
| 969 | else |
| 970 | interpreter.OutputFormattedHelpText (output_strm, "", "", GetHelp(), 1); |
| 971 | output_strm.Printf ("\nSyntax: %s\n", GetSyntax()); |
| 972 | } |
| 973 | } |
| 974 | |
| 975 | void |
Johnny Chen | de75346 | 2011-09-22 22:34:09 +0000 | [diff] [blame] | 976 | CommandObject::AddIDsArgumentData(CommandArgumentEntry &arg, CommandArgumentType ID, CommandArgumentType IDRange) |
Johnny Chen | 184d7a7 | 2011-09-21 01:00:02 +0000 | [diff] [blame] | 977 | { |
| 978 | CommandArgumentData id_arg; |
| 979 | CommandArgumentData id_range_arg; |
| 980 | |
| 981 | // Create the first variant for the first (and only) argument for this command. |
Johnny Chen | de75346 | 2011-09-22 22:34:09 +0000 | [diff] [blame] | 982 | id_arg.arg_type = ID; |
Johnny Chen | 184d7a7 | 2011-09-21 01:00:02 +0000 | [diff] [blame] | 983 | id_arg.arg_repetition = eArgRepeatOptional; |
| 984 | |
| 985 | // Create the second variant for the first (and only) argument for this command. |
Johnny Chen | de75346 | 2011-09-22 22:34:09 +0000 | [diff] [blame] | 986 | id_range_arg.arg_type = IDRange; |
Johnny Chen | 184d7a7 | 2011-09-21 01:00:02 +0000 | [diff] [blame] | 987 | id_range_arg.arg_repetition = eArgRepeatOptional; |
| 988 | |
Johnny Chen | a323473 | 2011-09-21 01:04:49 +0000 | [diff] [blame] | 989 | // The first (and only) argument for this command could be either an id or an id_range. |
Johnny Chen | 184d7a7 | 2011-09-21 01:00:02 +0000 | [diff] [blame] | 990 | // Push both variants into the entry for the first argument for this command. |
| 991 | arg.push_back(id_arg); |
| 992 | arg.push_back(id_range_arg); |
| 993 | } |
| 994 | |
Greg Clayton | 9d0402b | 2011-02-20 02:15:07 +0000 | [diff] [blame] | 995 | const char * |
| 996 | CommandObject::GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type) |
| 997 | { |
| 998 | if (arg_type >=0 && arg_type < eArgTypeLastArg) |
| 999 | return g_arguments_data[arg_type].arg_name; |
| 1000 | return NULL; |
| 1001 | |
| 1002 | } |
| 1003 | |
| 1004 | const char * |
| 1005 | CommandObject::GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type) |
| 1006 | { |
| 1007 | if (arg_type >=0 && arg_type < eArgTypeLastArg) |
| 1008 | return g_arguments_data[arg_type].help_text; |
| 1009 | return NULL; |
| 1010 | } |
| 1011 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1012 | bool |
| 1013 | CommandObjectParsed::Execute (const char *args_string, CommandReturnObject &result) |
| 1014 | { |
| 1015 | CommandOverrideCallback command_callback = GetOverrideCallback(); |
| 1016 | bool handled = false; |
| 1017 | Args cmd_args (args_string); |
| 1018 | if (command_callback) |
| 1019 | { |
| 1020 | Args full_args (GetCommandName ()); |
| 1021 | full_args.AppendArguments(cmd_args); |
| 1022 | handled = command_callback (GetOverrideCallbackBaton(), full_args.GetConstArgumentVector()); |
| 1023 | } |
| 1024 | if (!handled) |
| 1025 | { |
| 1026 | for (size_t i = 0; i < cmd_args.GetArgumentCount(); ++i) |
| 1027 | { |
| 1028 | const char *tmp_str = cmd_args.GetArgumentAtIndex (i); |
| 1029 | if (tmp_str[0] == '`') // back-quote |
| 1030 | cmd_args.ReplaceArgumentAtIndex (i, m_interpreter.ProcessEmbeddedScriptCommands (tmp_str)); |
| 1031 | } |
| 1032 | |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 1033 | if (CheckRequirements(result)) |
| 1034 | { |
| 1035 | if (ParseOptions (cmd_args, result)) |
| 1036 | { |
| 1037 | // Call the command-specific version of 'Execute', passing it the already processed arguments. |
| 1038 | handled = DoExecute (cmd_args, result); |
| 1039 | } |
| 1040 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1041 | |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 1042 | Cleanup(); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1043 | } |
| 1044 | return handled; |
| 1045 | } |
| 1046 | |
| 1047 | bool |
| 1048 | CommandObjectRaw::Execute (const char *args_string, CommandReturnObject &result) |
| 1049 | { |
| 1050 | CommandOverrideCallback command_callback = GetOverrideCallback(); |
| 1051 | bool handled = false; |
| 1052 | if (command_callback) |
| 1053 | { |
| 1054 | std::string full_command (GetCommandName ()); |
| 1055 | full_command += ' '; |
| 1056 | full_command += args_string; |
| 1057 | const char *argv[2] = { NULL, NULL }; |
| 1058 | argv[0] = full_command.c_str(); |
| 1059 | handled = command_callback (GetOverrideCallbackBaton(), argv); |
| 1060 | } |
| 1061 | if (!handled) |
| 1062 | { |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 1063 | if (CheckRequirements(result)) |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1064 | handled = DoExecute (args_string, result); |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 1065 | |
| 1066 | Cleanup(); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1067 | } |
| 1068 | return handled; |
| 1069 | } |
| 1070 | |
Johnny Chen | ca7835c | 2012-05-26 00:32:39 +0000 | [diff] [blame] | 1071 | static |
| 1072 | const char *arch_helper() |
| 1073 | { |
Greg Clayton | d70b14e | 2012-05-26 17:21:14 +0000 | [diff] [blame] | 1074 | static StreamString g_archs_help; |
Johnny Chen | 797a1b3 | 2012-05-29 20:04:10 +0000 | [diff] [blame] | 1075 | if (g_archs_help.Empty()) |
Greg Clayton | d70b14e | 2012-05-26 17:21:14 +0000 | [diff] [blame] | 1076 | { |
| 1077 | StringList archs; |
| 1078 | ArchSpec::AutoComplete(NULL, archs); |
| 1079 | g_archs_help.Printf("These are the supported architecture names:\n"); |
Johnny Chen | 797a1b3 | 2012-05-29 20:04:10 +0000 | [diff] [blame] | 1080 | archs.Join("\n", g_archs_help); |
Greg Clayton | d70b14e | 2012-05-26 17:21:14 +0000 | [diff] [blame] | 1081 | } |
| 1082 | return g_archs_help.GetData(); |
Johnny Chen | ca7835c | 2012-05-26 00:32:39 +0000 | [diff] [blame] | 1083 | } |
| 1084 | |
Caroline Tice | e139cf2 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 1085 | CommandObject::ArgumentTableEntry |
| 1086 | CommandObject::g_arguments_data[] = |
| 1087 | { |
Enrico Granata | 7f941d9 | 2011-07-07 15:49:54 +0000 | [diff] [blame] | 1088 | { eArgTypeAddress, "address", CommandCompletions::eNoCompletion, { NULL, false }, "A valid address in the target program's execution space." }, |
Enrico Granata | 59de94b | 2013-01-29 02:46:04 +0000 | [diff] [blame] | 1089 | { eArgTypeAddressOrExpression, "address-expression", CommandCompletions::eNoCompletion, { NULL, false }, "An expression that resolves to an address." }, |
Enrico Granata | 7f941d9 | 2011-07-07 15:49:54 +0000 | [diff] [blame] | 1090 | { eArgTypeAliasName, "alias-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of an abbreviation (alias) for a debugger command." }, |
| 1091 | { 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.)" }, |
Johnny Chen | ca7835c | 2012-05-26 00:32:39 +0000 | [diff] [blame] | 1092 | { eArgTypeArchitecture, "arch", CommandCompletions::eArchitectureCompletion, { arch_helper, true }, "The architecture name, e.g. i386 or x86_64." }, |
Enrico Granata | 7f941d9 | 2011-07-07 15:49:54 +0000 | [diff] [blame] | 1093 | { eArgTypeBoolean, "boolean", CommandCompletions::eNoCompletion, { NULL, false }, "A Boolean value: 'true' or 'false'" }, |
| 1094 | { eArgTypeBreakpointID, "breakpt-id", CommandCompletions::eNoCompletion, { BreakpointIDHelpTextCallback, false }, NULL }, |
| 1095 | { eArgTypeBreakpointIDRange, "breakpt-id-list", CommandCompletions::eNoCompletion, { BreakpointIDRangeHelpTextCallback, false }, NULL }, |
| 1096 | { eArgTypeByteSize, "byte-size", CommandCompletions::eNoCompletion, { NULL, false }, "Number of bytes to use." }, |
| 1097 | { eArgTypeClassName, "class-name", CommandCompletions::eNoCompletion, { NULL, false }, "Then name of a class from the debug information in the program." }, |
| 1098 | { eArgTypeCommandName, "cmd-name", CommandCompletions::eNoCompletion, { NULL, false }, "A debugger command (may be multiple words), without any options or arguments." }, |
| 1099 | { eArgTypeCount, "count", CommandCompletions::eNoCompletion, { NULL, false }, "An unsigned integer." }, |
Sean Callanan | 3154255 | 2012-10-24 01:12:14 +0000 | [diff] [blame] | 1100 | { eArgTypeDirectoryName, "directory", CommandCompletions::eDiskDirectoryCompletion, { NULL, false }, "A directory name." }, |
Jim Ingham | 0f063ba | 2013-03-02 00:26:47 +0000 | [diff] [blame] | 1101 | { eArgTypeDisassemblyFlavor, "disassembly-flavor", CommandCompletions::eNoCompletion, { NULL, false }, "A disassembly flavor recognized by your disassembly plugin. Currently the only valid options are \"att\" and \"intel\" for Intel targets" }, |
Enrico Granata | 7f941d9 | 2011-07-07 15:49:54 +0000 | [diff] [blame] | 1102 | { eArgTypeEndAddress, "end-address", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, |
| 1103 | { eArgTypeExpression, "expr", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, |
Enrico Granata | 9128ee2 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 1104 | { eArgTypeExpressionPath, "expr-path", CommandCompletions::eNoCompletion, { ExprPathHelpTextCallback, true }, NULL }, |
Enrico Granata | 7f941d9 | 2011-07-07 15:49:54 +0000 | [diff] [blame] | 1105 | { eArgTypeExprFormat, "expression-format", CommandCompletions::eNoCompletion, { NULL, false }, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]" }, |
| 1106 | { eArgTypeFilename, "filename", CommandCompletions::eDiskFileCompletion, { NULL, false }, "The name of a file (can include path)." }, |
| 1107 | { eArgTypeFormat, "format", CommandCompletions::eNoCompletion, { FormatHelpTextCallback, true }, NULL }, |
| 1108 | { eArgTypeFrameIndex, "frame-index", CommandCompletions::eNoCompletion, { NULL, false }, "Index into a thread's list of frames." }, |
| 1109 | { eArgTypeFullName, "fullname", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, |
| 1110 | { eArgTypeFunctionName, "function-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a function." }, |
Sean Callanan | cd8b7cd | 2012-09-13 21:11:40 +0000 | [diff] [blame] | 1111 | { eArgTypeFunctionOrSymbol, "function-or-symbol", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a function or symbol." }, |
Greg Clayton | 86edbf4 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 1112 | { eArgTypeGDBFormat, "gdb-format", CommandCompletions::eNoCompletion, { GDBFormatHelpTextCallback, true }, NULL }, |
Enrico Granata | 7f941d9 | 2011-07-07 15:49:54 +0000 | [diff] [blame] | 1113 | { eArgTypeIndex, "index", CommandCompletions::eNoCompletion, { NULL, false }, "An index into a list." }, |
Sean Callanan | d947739 | 2012-10-23 00:50:09 +0000 | [diff] [blame] | 1114 | { eArgTypeLanguage, "language", CommandCompletions::eNoCompletion, { LanguageTypeHelpTextCallback, true }, NULL }, |
Enrico Granata | 7f941d9 | 2011-07-07 15:49:54 +0000 | [diff] [blame] | 1115 | { eArgTypeLineNum, "linenum", CommandCompletions::eNoCompletion, { NULL, false }, "Line number in a source file." }, |
| 1116 | { 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." }, |
| 1117 | { 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)." }, |
| 1118 | { eArgTypeMethod, "method", CommandCompletions::eNoCompletion, { NULL, false }, "A C++ method name." }, |
| 1119 | { eArgTypeName, "name", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, |
| 1120 | { eArgTypeNewPathPrefix, "new-path-prefix", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, |
| 1121 | { eArgTypeNumLines, "num-lines", CommandCompletions::eNoCompletion, { NULL, false }, "The number of lines to use." }, |
| 1122 | { eArgTypeNumberPerLine, "number-per-line", CommandCompletions::eNoCompletion, { NULL, false }, "The number of items per line to display." }, |
| 1123 | { eArgTypeOffset, "offset", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, |
| 1124 | { eArgTypeOldPathPrefix, "old-path-prefix", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, |
| 1125 | { eArgTypeOneLiner, "one-line-command", CommandCompletions::eNoCompletion, { NULL, false }, "A command that is entered as a single line of text." }, |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame^] | 1126 | { eArgTypePath, "path", CommandCompletions::eDiskFileCompletion, { NULL, false }, "Path." }, |
| 1127 | { eArgTypePermissionsNumber, "perms-numeric", CommandCompletions::eNoCompletion, { NULL, false }, "Permissions given as an octal number (e.g. 755)." }, |
| 1128 | { eArgTypePermissionsString, "perms=string", CommandCompletions::eNoCompletion, { NULL, false }, "Permissions given as a string value (e.g. rw-r-xr--)." }, |
Enrico Granata | 7f941d9 | 2011-07-07 15:49:54 +0000 | [diff] [blame] | 1129 | { eArgTypePid, "pid", CommandCompletions::eNoCompletion, { NULL, false }, "The process ID number." }, |
| 1130 | { eArgTypePlugin, "plugin", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, |
| 1131 | { eArgTypeProcessName, "process-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of the process." }, |
Enrico Granata | 9128ee2 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 1132 | { eArgTypePythonClass, "python-class", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a Python class." }, |
| 1133 | { eArgTypePythonFunction, "python-function", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a Python function." }, |
| 1134 | { eArgTypePythonScript, "python-script", CommandCompletions::eNoCompletion, { NULL, false }, "Source code written in Python." }, |
Enrico Granata | 7f941d9 | 2011-07-07 15:49:54 +0000 | [diff] [blame] | 1135 | { eArgTypeQueueName, "queue-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of the thread queue." }, |
Jim Ingham | 931e674 | 2012-08-23 23:37:31 +0000 | [diff] [blame] | 1136 | { eArgTypeRegisterName, "register-name", CommandCompletions::eNoCompletion, { RegisterNameHelpTextCallback, true }, NULL }, |
Enrico Granata | 7f941d9 | 2011-07-07 15:49:54 +0000 | [diff] [blame] | 1137 | { eArgTypeRegularExpression, "regular-expression", CommandCompletions::eNoCompletion, { NULL, false }, "A regular expression." }, |
| 1138 | { eArgTypeRunArgs, "run-args", CommandCompletions::eNoCompletion, { NULL, false }, "Arguments to be passed to the target program when it starts executing." }, |
| 1139 | { eArgTypeRunMode, "run-mode", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, |
Enrico Granata | 0a305db | 2011-11-07 22:57:04 +0000 | [diff] [blame] | 1140 | { eArgTypeScriptedCommandSynchronicity, "script-cmd-synchronicity", CommandCompletions::eNoCompletion, { NULL, false }, "The synchronicity to use to run scripted commands with regard to LLDB event system." }, |
Enrico Granata | 7f941d9 | 2011-07-07 15:49:54 +0000 | [diff] [blame] | 1141 | { eArgTypeScriptLang, "script-language", CommandCompletions::eNoCompletion, { NULL, false }, "The scripting language to be used for script-based commands. Currently only Python is valid." }, |
| 1142 | { eArgTypeSearchWord, "search-word", CommandCompletions::eNoCompletion, { NULL, false }, "The word for which you wish to search for information about." }, |
| 1143 | { eArgTypeSelector, "selector", CommandCompletions::eNoCompletion, { NULL, false }, "An Objective-C selector name." }, |
| 1144 | { 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)." }, |
| 1145 | { 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)." }, |
| 1146 | { eArgTypeSettingPrefix, "setting-prefix", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a settable internal debugger variable up to a dot ('.'), e.g. 'target.process.'" }, |
| 1147 | { 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." }, |
| 1148 | { eArgTypeShlibName, "shlib-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a shared library." }, |
| 1149 | { eArgTypeSourceFile, "source-file", CommandCompletions::eSourceFileCompletion, { NULL, false }, "The name of a source file.." }, |
| 1150 | { eArgTypeSortOrder, "sort-order", CommandCompletions::eNoCompletion, { NULL, false }, "Specify a sort order when dumping lists." }, |
| 1151 | { eArgTypeStartAddress, "start-address", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, |
| 1152 | { eArgTypeSummaryString, "summary-string", CommandCompletions::eNoCompletion, { SummaryStringHelpTextCallback, true }, NULL }, |
| 1153 | { eArgTypeSymbol, "symbol", CommandCompletions::eSymbolCompletion, { NULL, false }, "Any symbol name (function name, variable, argument, etc.)" }, |
| 1154 | { eArgTypeThreadID, "thread-id", CommandCompletions::eNoCompletion, { NULL, false }, "Thread ID number." }, |
| 1155 | { eArgTypeThreadIndex, "thread-index", CommandCompletions::eNoCompletion, { NULL, false }, "Index into the process' list of threads." }, |
| 1156 | { eArgTypeThreadName, "thread-name", CommandCompletions::eNoCompletion, { NULL, false }, "The thread's name." }, |
Johnny Chen | 331eff3 | 2011-07-14 22:20:12 +0000 | [diff] [blame] | 1157 | { eArgTypeUnsignedInteger, "unsigned-integer", CommandCompletions::eNoCompletion, { NULL, false }, "An unsigned integer." }, |
Enrico Granata | 7f941d9 | 2011-07-07 15:49:54 +0000 | [diff] [blame] | 1158 | { eArgTypeUnixSignal, "unix-signal", CommandCompletions::eNoCompletion, { NULL, false }, "A valid Unix signal name or number (e.g. SIGKILL, KILL or 9)." }, |
| 1159 | { eArgTypeVarName, "variable-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a variable in your program." }, |
| 1160 | { eArgTypeValue, "value", CommandCompletions::eNoCompletion, { NULL, false }, "A value could be anything, depending on where and how it is used." }, |
| 1161 | { eArgTypeWidth, "width", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, |
| 1162 | { eArgTypeNone, "none", CommandCompletions::eNoCompletion, { NULL, false }, "No help available for this." }, |
Johnny Chen | b1d7529 | 2011-09-09 23:25:26 +0000 | [diff] [blame] | 1163 | { 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." }, |
Johnny Chen | de75346 | 2011-09-22 22:34:09 +0000 | [diff] [blame] | 1164 | { eArgTypeWatchpointID, "watchpt-id", CommandCompletions::eNoCompletion, { NULL, false }, "Watchpoint IDs are positive integers." }, |
| 1165 | { eArgTypeWatchpointIDRange, "watchpt-id-list", CommandCompletions::eNoCompletion, { NULL, false }, "For example, '1-3' or '1 to 3'." }, |
Johnny Chen | 887062a | 2011-09-12 23:38:44 +0000 | [diff] [blame] | 1166 | { eArgTypeWatchType, "watch-type", CommandCompletions::eNoCompletion, { NULL, false }, "Specify the type for a watchpoint." } |
Caroline Tice | e139cf2 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 1167 | }; |
| 1168 | |
| 1169 | const CommandObject::ArgumentTableEntry* |
| 1170 | CommandObject::GetArgumentTable () |
| 1171 | { |
Greg Clayton | 9d0402b | 2011-02-20 02:15:07 +0000 | [diff] [blame] | 1172 | // If this assertion fires, then the table above is out of date with the CommandArgumentType enumeration |
| 1173 | assert ((sizeof (CommandObject::g_arguments_data) / sizeof (CommandObject::ArgumentTableEntry)) == eArgTypeLastArg); |
Caroline Tice | e139cf2 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 1174 | return CommandObject::g_arguments_data; |
| 1175 | } |
| 1176 | |
| 1177 | |