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