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