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