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