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/Target/Process.h" 28 #include "lldb/Target/Target.h" 29 #include "lldb/Utility/FileSpec.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 Status 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 541 CommandObject::LookupArgumentName(llvm::StringRef arg_name) { 542 CommandArgumentType return_type = eArgTypeLastArg; 543 544 arg_name = arg_name.ltrim('<').rtrim('>'); 545 546 const ArgumentTableEntry *table = GetArgumentTable(); 547 for (int i = 0; i < eArgTypeLastArg; ++i) 548 if (arg_name == table[i].arg_name) 549 return_type = g_arguments_data[i].arg_type; 550 551 return return_type; 552 } 553 554 static llvm::StringRef RegisterNameHelpTextCallback() { 555 return "Register names can be specified using the architecture specific " 556 "names. " 557 "They can also be specified using generic names. Not all generic " 558 "entities have " 559 "registers backing them on all architectures. When they don't the " 560 "generic name " 561 "will return an error.\n" 562 "The generic names defined in lldb are:\n" 563 "\n" 564 "pc - program counter register\n" 565 "ra - return address register\n" 566 "fp - frame pointer register\n" 567 "sp - stack pointer register\n" 568 "flags - the flags register\n" 569 "arg{1-6} - integer argument passing registers.\n"; 570 } 571 572 static llvm::StringRef BreakpointIDHelpTextCallback() { 573 return "Breakpoints are identified using major and minor numbers; the major " 574 "number corresponds to the single entity that was created with a " 575 "'breakpoint " 576 "set' command; the minor numbers correspond to all the locations that " 577 "were " 578 "actually found/set based on the major breakpoint. A full breakpoint " 579 "ID might " 580 "look like 3.14, meaning the 14th location set for the 3rd " 581 "breakpoint. You " 582 "can specify all the locations of a breakpoint by just indicating the " 583 "major " 584 "breakpoint number. A valid breakpoint ID consists either of just the " 585 "major " 586 "number, or the major number followed by a dot and the location " 587 "number (e.g. " 588 "3 or 3.2 could both be valid breakpoint IDs.)"; 589 } 590 591 static llvm::StringRef BreakpointIDRangeHelpTextCallback() { 592 return "A 'breakpoint ID list' is a manner of specifying multiple " 593 "breakpoints. " 594 "This can be done through several mechanisms. The easiest way is to " 595 "just " 596 "enter a space-separated list of breakpoint IDs. To specify all the " 597 "breakpoint locations under a major breakpoint, you can use the major " 598 "breakpoint number followed by '.*', eg. '5.*' means all the " 599 "locations under " 600 "breakpoint 5. You can also indicate a range of breakpoints by using " 601 "<start-bp-id> - <end-bp-id>. The start-bp-id and end-bp-id for a " 602 "range can " 603 "be any valid breakpoint IDs. It is not legal, however, to specify a " 604 "range " 605 "using specific locations that cross major breakpoint numbers. I.e. " 606 "3.2 - 3.7" 607 " is legal; 2 - 5 is legal; but 3.2 - 4.4 is not legal."; 608 } 609 610 static llvm::StringRef BreakpointNameHelpTextCallback() { 611 return "A name that can be added to a breakpoint when it is created, or " 612 "later " 613 "on with the \"breakpoint name add\" command. " 614 "Breakpoint names can be used to specify breakpoints in all the " 615 "places breakpoint IDs " 616 "and breakpoint ID ranges can be used. As such they provide a " 617 "convenient way to group breakpoints, " 618 "and to operate on breakpoints you create without having to track the " 619 "breakpoint number. " 620 "Note, the attributes you set when using a breakpoint name in a " 621 "breakpoint command don't " 622 "adhere to the name, but instead are set individually on all the " 623 "breakpoints currently tagged with that " 624 "name. Future breakpoints " 625 "tagged with that name will not pick up the attributes previously " 626 "given using that name. " 627 "In order to distinguish breakpoint names from breakpoint IDs and " 628 "ranges, " 629 "names must start with a letter from a-z or A-Z and cannot contain " 630 "spaces, \".\" or \"-\". " 631 "Also, breakpoint names can only be applied to breakpoints, not to " 632 "breakpoint locations."; 633 } 634 635 static llvm::StringRef GDBFormatHelpTextCallback() { 636 return "A GDB format consists of a repeat count, a format letter and a size " 637 "letter. " 638 "The repeat count is optional and defaults to 1. The format letter is " 639 "optional " 640 "and defaults to the previous format that was used. The size letter " 641 "is optional " 642 "and defaults to the previous size that was used.\n" 643 "\n" 644 "Format letters include:\n" 645 "o - octal\n" 646 "x - hexadecimal\n" 647 "d - decimal\n" 648 "u - unsigned decimal\n" 649 "t - binary\n" 650 "f - float\n" 651 "a - address\n" 652 "i - instruction\n" 653 "c - char\n" 654 "s - string\n" 655 "T - OSType\n" 656 "A - float as hex\n" 657 "\n" 658 "Size letters include:\n" 659 "b - 1 byte (byte)\n" 660 "h - 2 bytes (halfword)\n" 661 "w - 4 bytes (word)\n" 662 "g - 8 bytes (giant)\n" 663 "\n" 664 "Example formats:\n" 665 "32xb - show 32 1 byte hexadecimal integer values\n" 666 "16xh - show 16 2 byte hexadecimal integer values\n" 667 "64 - show 64 2 byte hexadecimal integer values (format and size " 668 "from the last format)\n" 669 "dw - show 1 4 byte decimal integer value\n"; 670 } 671 672 static llvm::StringRef FormatHelpTextCallback() { 673 static std::string help_text; 674 675 if (!help_text.empty()) 676 return help_text; 677 678 StreamString sstr; 679 sstr << "One of the format names (or one-character names) that can be used " 680 "to show a variable's value:\n"; 681 for (Format f = eFormatDefault; f < kNumFormats; f = Format(f + 1)) { 682 if (f != eFormatDefault) 683 sstr.PutChar('\n'); 684 685 char format_char = FormatManager::GetFormatAsFormatChar(f); 686 if (format_char) 687 sstr.Printf("'%c' or ", format_char); 688 689 sstr.Printf("\"%s\"", FormatManager::GetFormatAsCString(f)); 690 } 691 692 sstr.Flush(); 693 694 help_text = sstr.GetString(); 695 696 return help_text; 697 } 698 699 static llvm::StringRef LanguageTypeHelpTextCallback() { 700 static std::string help_text; 701 702 if (!help_text.empty()) 703 return help_text; 704 705 StreamString sstr; 706 sstr << "One of the following languages:\n"; 707 708 Language::PrintAllLanguages(sstr, " ", "\n"); 709 710 sstr.Flush(); 711 712 help_text = sstr.GetString(); 713 714 return help_text; 715 } 716 717 static llvm::StringRef SummaryStringHelpTextCallback() { 718 return "A summary string is a way to extract information from variables in " 719 "order to present them using a summary.\n" 720 "Summary strings contain static text, variables, scopes and control " 721 "sequences:\n" 722 " - Static text can be any sequence of non-special characters, i.e. " 723 "anything but '{', '}', '$', or '\\'.\n" 724 " - Variables are sequences of characters beginning with ${, ending " 725 "with } and that contain symbols in the format described below.\n" 726 " - Scopes are any sequence of text between { and }. Anything " 727 "included in a scope will only appear in the output summary if there " 728 "were no errors.\n" 729 " - Control sequences are the usual C/C++ '\\a', '\\n', ..., plus " 730 "'\\$', '\\{' and '\\}'.\n" 731 "A summary string works by copying static text verbatim, turning " 732 "control sequences into their character counterpart, expanding " 733 "variables and trying to expand scopes.\n" 734 "A variable is expanded by giving it a value other than its textual " 735 "representation, and the way this is done depends on what comes after " 736 "the ${ marker.\n" 737 "The most common sequence if ${var followed by an expression path, " 738 "which is the text one would type to access a member of an aggregate " 739 "types, given a variable of that type" 740 " (e.g. if type T has a member named x, which has a member named y, " 741 "and if t is of type T, the expression path would be .x.y and the way " 742 "to fit that into a summary string would be" 743 " ${var.x.y}). You can also use ${*var followed by an expression path " 744 "and in that case the object referred by the path will be " 745 "dereferenced before being displayed." 746 " If the object is not a pointer, doing so will cause an error. For " 747 "additional details on expression paths, you can type 'help " 748 "expr-path'. \n" 749 "By default, summary strings attempt to display the summary for any " 750 "variable they reference, and if that fails the value. If neither can " 751 "be shown, nothing is displayed." 752 "In a summary string, you can also use an array index [n], or a " 753 "slice-like range [n-m]. This can have two different meanings " 754 "depending on what kind of object the expression" 755 " path refers to:\n" 756 " - if it is a scalar type (any basic type like int, float, ...) the " 757 "expression is a bitfield, i.e. the bits indicated by the indexing " 758 "operator are extracted out of the number" 759 " and displayed as an individual variable\n" 760 " - if it is an array or pointer the array items indicated by the " 761 "indexing operator are shown as the result of the variable. if the " 762 "expression is an array, real array items are" 763 " printed; if it is a pointer, the pointer-as-array syntax is used to " 764 "obtain the values (this means, the latter case can have no range " 765 "checking)\n" 766 "If you are trying to display an array for which the size is known, " 767 "you can also use [] instead of giving an exact range. This has the " 768 "effect of showing items 0 thru size - 1.\n" 769 "Additionally, a variable can contain an (optional) format code, as " 770 "in ${var.x.y%code}, where code can be any of the valid formats " 771 "described in 'help format', or one of the" 772 " special symbols only allowed as part of a variable:\n" 773 " %V: show the value of the object by default\n" 774 " %S: show the summary of the object by default\n" 775 " %@: show the runtime-provided object description (for " 776 "Objective-C, it calls NSPrintForDebugger; for C/C++ it does " 777 "nothing)\n" 778 " %L: show the location of the object (memory address or a " 779 "register name)\n" 780 " %#: show the number of children of the object\n" 781 " %T: show the type of the object\n" 782 "Another variable that you can use in summary strings is ${svar . " 783 "This sequence works exactly like ${var, including the fact that " 784 "${*svar is an allowed sequence, but uses" 785 " the object's synthetic children provider instead of the actual " 786 "objects. For instance, if you are using STL synthetic children " 787 "providers, the following summary string would" 788 " count the number of actual elements stored in an std::list:\n" 789 "type summary add -s \"${svar%#}\" -x \"std::list<\""; 790 } 791 792 static llvm::StringRef ExprPathHelpTextCallback() { 793 return "An expression path is the sequence of symbols that is used in C/C++ " 794 "to access a member variable of an aggregate object (class).\n" 795 "For instance, given a class:\n" 796 " class foo {\n" 797 " int a;\n" 798 " int b; .\n" 799 " foo* next;\n" 800 " };\n" 801 "the expression to read item b in the item pointed to by next for foo " 802 "aFoo would be aFoo.next->b.\n" 803 "Given that aFoo could just be any object of type foo, the string " 804 "'.next->b' is the expression path, because it can be attached to any " 805 "foo instance to achieve the effect.\n" 806 "Expression paths in LLDB include dot (.) and arrow (->) operators, " 807 "and most commands using expression paths have ways to also accept " 808 "the star (*) operator.\n" 809 "The meaning of these operators is the same as the usual one given to " 810 "them by the C/C++ standards.\n" 811 "LLDB also has support for indexing ([ ]) in expression paths, and " 812 "extends the traditional meaning of the square brackets operator to " 813 "allow bitfield extraction:\n" 814 "for objects of native types (int, float, char, ...) saying '[n-m]' " 815 "as an expression path (where n and m are any positive integers, e.g. " 816 "[3-5]) causes LLDB to extract" 817 " bits n thru m from the value of the variable. If n == m, [n] is " 818 "also allowed as a shortcut syntax. For arrays and pointers, " 819 "expression paths can only contain one index" 820 " and the meaning of the operation is the same as the one defined by " 821 "C/C++ (item extraction). Some commands extend bitfield-like syntax " 822 "for arrays and pointers with the" 823 " meaning of array slicing (taking elements n thru m inside the array " 824 "or pointed-to memory)."; 825 } 826 827 void CommandObject::FormatLongHelpText(Stream &output_strm, 828 llvm::StringRef long_help) { 829 CommandInterpreter &interpreter = GetCommandInterpreter(); 830 std::stringstream lineStream(long_help); 831 std::string line; 832 while (std::getline(lineStream, line)) { 833 if (line.empty()) { 834 output_strm << "\n"; 835 continue; 836 } 837 size_t result = line.find_first_not_of(" \t"); 838 if (result == std::string::npos) { 839 result = 0; 840 } 841 std::string whitespace_prefix = line.substr(0, result); 842 std::string remainder = line.substr(result); 843 interpreter.OutputFormattedHelpText(output_strm, whitespace_prefix.c_str(), 844 remainder.c_str()); 845 } 846 } 847 848 void CommandObject::GenerateHelpText(CommandReturnObject &result) { 849 GenerateHelpText(result.GetOutputStream()); 850 851 result.SetStatus(eReturnStatusSuccessFinishNoResult); 852 } 853 854 void CommandObject::GenerateHelpText(Stream &output_strm) { 855 CommandInterpreter &interpreter = GetCommandInterpreter(); 856 if (WantsRawCommandString()) { 857 std::string help_text(GetHelp()); 858 help_text.append(" Expects 'raw' input (see 'help raw-input'.)"); 859 interpreter.OutputFormattedHelpText(output_strm, "", "", help_text.c_str(), 860 1); 861 } else 862 interpreter.OutputFormattedHelpText(output_strm, "", "", GetHelp(), 1); 863 output_strm << "\nSyntax: " << GetSyntax() << "\n"; 864 Options *options = GetOptions(); 865 if (options != nullptr) { 866 options->GenerateOptionUsage( 867 output_strm, this, 868 GetCommandInterpreter().GetDebugger().GetTerminalWidth()); 869 } 870 llvm::StringRef long_help = GetHelpLong(); 871 if (!long_help.empty()) { 872 FormatLongHelpText(output_strm, long_help); 873 } 874 if (!IsDashDashCommand() && options && options->NumCommandOptions() > 0) { 875 if (WantsRawCommandString() && !WantsCompletion()) { 876 // Emit the message about using ' -- ' between the end of the command 877 // options and the raw input 878 // conditionally, i.e., only if the command object does not want 879 // completion. 880 interpreter.OutputFormattedHelpText( 881 output_strm, "", "", 882 "\nImportant Note: Because this command takes 'raw' input, if you " 883 "use any command options" 884 " you must use ' -- ' between the end of the command options and the " 885 "beginning of the raw input.", 886 1); 887 } else if (GetNumArgumentEntries() > 0) { 888 // Also emit a warning about using "--" in case you are using a command 889 // that takes options and arguments. 890 interpreter.OutputFormattedHelpText( 891 output_strm, "", "", 892 "\nThis command takes options and free-form arguments. If your " 893 "arguments resemble" 894 " option specifiers (i.e., they start with a - or --), you must use " 895 "' -- ' between" 896 " the end of the command options and the beginning of the arguments.", 897 1); 898 } 899 } 900 } 901 902 void CommandObject::AddIDsArgumentData(CommandArgumentEntry &arg, 903 CommandArgumentType ID, 904 CommandArgumentType IDRange) { 905 CommandArgumentData id_arg; 906 CommandArgumentData id_range_arg; 907 908 // Create the first variant for the first (and only) argument for this 909 // command. 910 id_arg.arg_type = ID; 911 id_arg.arg_repetition = eArgRepeatOptional; 912 913 // Create the second variant for the first (and only) argument for this 914 // command. 915 id_range_arg.arg_type = IDRange; 916 id_range_arg.arg_repetition = eArgRepeatOptional; 917 918 // The first (and only) argument for this command could be either an id or an 919 // id_range. 920 // Push both variants into the entry for the first argument for this command. 921 arg.push_back(id_arg); 922 arg.push_back(id_range_arg); 923 } 924 925 const char *CommandObject::GetArgumentTypeAsCString( 926 const lldb::CommandArgumentType arg_type) { 927 assert(arg_type < eArgTypeLastArg && 928 "Invalid argument type passed to GetArgumentTypeAsCString"); 929 return g_arguments_data[arg_type].arg_name; 930 } 931 932 const char *CommandObject::GetArgumentDescriptionAsCString( 933 const lldb::CommandArgumentType arg_type) { 934 assert(arg_type < eArgTypeLastArg && 935 "Invalid argument type passed to GetArgumentDescriptionAsCString"); 936 return g_arguments_data[arg_type].help_text; 937 } 938 939 Target *CommandObject::GetDummyTarget() { 940 return m_interpreter.GetDebugger().GetDummyTarget(); 941 } 942 943 Target *CommandObject::GetSelectedOrDummyTarget(bool prefer_dummy) { 944 return m_interpreter.GetDebugger().GetSelectedOrDummyTarget(prefer_dummy); 945 } 946 947 Thread *CommandObject::GetDefaultThread() { 948 Thread *thread_to_use = m_exe_ctx.GetThreadPtr(); 949 if (thread_to_use) 950 return thread_to_use; 951 952 Process *process = m_exe_ctx.GetProcessPtr(); 953 if (!process) { 954 Target *target = m_exe_ctx.GetTargetPtr(); 955 if (!target) { 956 target = m_interpreter.GetDebugger().GetSelectedTarget().get(); 957 } 958 if (target) 959 process = target->GetProcessSP().get(); 960 } 961 962 if (process) 963 return process->GetThreadList().GetSelectedThread().get(); 964 else 965 return nullptr; 966 } 967 968 bool CommandObjectParsed::Execute(const char *args_string, 969 CommandReturnObject &result) { 970 bool handled = false; 971 Args cmd_args(args_string); 972 if (HasOverrideCallback()) { 973 Args full_args(GetCommandName()); 974 full_args.AppendArguments(cmd_args); 975 handled = 976 InvokeOverrideCallback(full_args.GetConstArgumentVector(), result); 977 } 978 if (!handled) { 979 for (auto entry : llvm::enumerate(cmd_args.entries())) { 980 if (!entry.value().ref.empty() && entry.value().ref.front() == '`') { 981 cmd_args.ReplaceArgumentAtIndex( 982 entry.index(), 983 m_interpreter.ProcessEmbeddedScriptCommands(entry.value().c_str())); 984 } 985 } 986 987 if (CheckRequirements(result)) { 988 if (ParseOptions(cmd_args, result)) { 989 // Call the command-specific version of 'Execute', passing it the 990 // already processed arguments. 991 handled = DoExecute(cmd_args, result); 992 } 993 } 994 995 Cleanup(); 996 } 997 return handled; 998 } 999 1000 bool CommandObjectRaw::Execute(const char *args_string, 1001 CommandReturnObject &result) { 1002 bool handled = false; 1003 if (HasOverrideCallback()) { 1004 std::string full_command(GetCommandName()); 1005 full_command += ' '; 1006 full_command += args_string; 1007 const char *argv[2] = {nullptr, nullptr}; 1008 argv[0] = full_command.c_str(); 1009 handled = InvokeOverrideCallback(argv, result); 1010 } 1011 if (!handled) { 1012 if (CheckRequirements(result)) 1013 handled = DoExecute(args_string, result); 1014 1015 Cleanup(); 1016 } 1017 return handled; 1018 } 1019 1020 static llvm::StringRef arch_helper() { 1021 static StreamString g_archs_help; 1022 if (g_archs_help.Empty()) { 1023 StringList archs; 1024 ArchSpec::AutoComplete(llvm::StringRef(), archs); 1025 g_archs_help.Printf("These are the supported architecture names:\n"); 1026 archs.Join("\n", g_archs_help); 1027 } 1028 return g_archs_help.GetString(); 1029 } 1030 1031 CommandObject::ArgumentTableEntry CommandObject::g_arguments_data[] = { 1032 // clang-format off 1033 { eArgTypeAddress, "address", CommandCompletions::eNoCompletion, { nullptr, false }, "A valid address in the target program's execution space." }, 1034 { eArgTypeAddressOrExpression, "address-expression", CommandCompletions::eNoCompletion, { nullptr, false }, "An expression that resolves to an address." }, 1035 { eArgTypeAliasName, "alias-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of an abbreviation (alias) for a debugger command." }, 1036 { 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.)" }, 1037 { eArgTypeArchitecture, "arch", CommandCompletions::eArchitectureCompletion, { arch_helper, true }, "The architecture name, e.g. i386 or x86_64." }, 1038 { eArgTypeBoolean, "boolean", CommandCompletions::eNoCompletion, { nullptr, false }, "A Boolean value: 'true' or 'false'" }, 1039 { eArgTypeBreakpointID, "breakpt-id", CommandCompletions::eNoCompletion, { BreakpointIDHelpTextCallback, false }, nullptr }, 1040 { eArgTypeBreakpointIDRange, "breakpt-id-list", CommandCompletions::eNoCompletion, { BreakpointIDRangeHelpTextCallback, false }, nullptr }, 1041 { eArgTypeBreakpointName, "breakpoint-name", CommandCompletions::eNoCompletion, { BreakpointNameHelpTextCallback, false }, nullptr }, 1042 { eArgTypeByteSize, "byte-size", CommandCompletions::eNoCompletion, { nullptr, false }, "Number of bytes to use." }, 1043 { eArgTypeClassName, "class-name", CommandCompletions::eNoCompletion, { nullptr, false }, "Then name of a class from the debug information in the program." }, 1044 { eArgTypeCommandName, "cmd-name", CommandCompletions::eNoCompletion, { nullptr, false }, "A debugger command (may be multiple words), without any options or arguments." }, 1045 { eArgTypeCount, "count", CommandCompletions::eNoCompletion, { nullptr, false }, "An unsigned integer." }, 1046 { eArgTypeDirectoryName, "directory", CommandCompletions::eDiskDirectoryCompletion, { nullptr, false }, "A directory name." }, 1047 { 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" }, 1048 { eArgTypeDescriptionVerbosity, "description-verbosity", CommandCompletions::eNoCompletion, { nullptr, false }, "How verbose the output of 'po' should be." }, 1049 { eArgTypeEndAddress, "end-address", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." }, 1050 { eArgTypeExpression, "expr", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." }, 1051 { eArgTypeExpressionPath, "expr-path", CommandCompletions::eNoCompletion, { ExprPathHelpTextCallback, true }, nullptr }, 1052 { eArgTypeExprFormat, "expression-format", CommandCompletions::eNoCompletion, { nullptr, false }, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]" }, 1053 { eArgTypeFilename, "filename", CommandCompletions::eDiskFileCompletion, { nullptr, false }, "The name of a file (can include path)." }, 1054 { eArgTypeFormat, "format", CommandCompletions::eNoCompletion, { FormatHelpTextCallback, true }, nullptr }, 1055 { eArgTypeFrameIndex, "frame-index", CommandCompletions::eNoCompletion, { nullptr, false }, "Index into a thread's list of frames." }, 1056 { eArgTypeFullName, "fullname", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." }, 1057 { eArgTypeFunctionName, "function-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a function." }, 1058 { eArgTypeFunctionOrSymbol, "function-or-symbol", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a function or symbol." }, 1059 { eArgTypeGDBFormat, "gdb-format", CommandCompletions::eNoCompletion, { GDBFormatHelpTextCallback, true }, nullptr }, 1060 { eArgTypeHelpText, "help-text", CommandCompletions::eNoCompletion, { nullptr, false }, "Text to be used as help for some other entity in LLDB" }, 1061 { eArgTypeIndex, "index", CommandCompletions::eNoCompletion, { nullptr, false }, "An index into a list." }, 1062 { eArgTypeLanguage, "source-language", CommandCompletions::eNoCompletion, { LanguageTypeHelpTextCallback, true }, nullptr }, 1063 { eArgTypeLineNum, "linenum", CommandCompletions::eNoCompletion, { nullptr, false }, "Line number in a source file." }, 1064 { 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." }, 1065 { 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)." }, 1066 { eArgTypeMethod, "method", CommandCompletions::eNoCompletion, { nullptr, false }, "A C++ method name." }, 1067 { eArgTypeName, "name", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." }, 1068 { eArgTypeNewPathPrefix, "new-path-prefix", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." }, 1069 { eArgTypeNumLines, "num-lines", CommandCompletions::eNoCompletion, { nullptr, false }, "The number of lines to use." }, 1070 { eArgTypeNumberPerLine, "number-per-line", CommandCompletions::eNoCompletion, { nullptr, false }, "The number of items per line to display." }, 1071 { eArgTypeOffset, "offset", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." }, 1072 { eArgTypeOldPathPrefix, "old-path-prefix", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." }, 1073 { eArgTypeOneLiner, "one-line-command", CommandCompletions::eNoCompletion, { nullptr, false }, "A command that is entered as a single line of text." }, 1074 { eArgTypePath, "path", CommandCompletions::eDiskFileCompletion, { nullptr, false }, "Path." }, 1075 { eArgTypePermissionsNumber, "perms-numeric", CommandCompletions::eNoCompletion, { nullptr, false }, "Permissions given as an octal number (e.g. 755)." }, 1076 { eArgTypePermissionsString, "perms=string", CommandCompletions::eNoCompletion, { nullptr, false }, "Permissions given as a string value (e.g. rw-r-xr--)." }, 1077 { eArgTypePid, "pid", CommandCompletions::eNoCompletion, { nullptr, false }, "The process ID number." }, 1078 { eArgTypePlugin, "plugin", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." }, 1079 { eArgTypeProcessName, "process-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of the process." }, 1080 { eArgTypePythonClass, "python-class", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a Python class." }, 1081 { eArgTypePythonFunction, "python-function", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a Python function." }, 1082 { eArgTypePythonScript, "python-script", CommandCompletions::eNoCompletion, { nullptr, false }, "Source code written in Python." }, 1083 { eArgTypeQueueName, "queue-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of the thread queue." }, 1084 { eArgTypeRegisterName, "register-name", CommandCompletions::eNoCompletion, { RegisterNameHelpTextCallback, true }, nullptr }, 1085 { eArgTypeRegularExpression, "regular-expression", CommandCompletions::eNoCompletion, { nullptr, false }, "A regular expression." }, 1086 { eArgTypeRunArgs, "run-args", CommandCompletions::eNoCompletion, { nullptr, false }, "Arguments to be passed to the target program when it starts executing." }, 1087 { eArgTypeRunMode, "run-mode", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." }, 1088 { eArgTypeScriptedCommandSynchronicity, "script-cmd-synchronicity", CommandCompletions::eNoCompletion, { nullptr, false }, "The synchronicity to use to run scripted commands with regard to LLDB event system." }, 1089 { eArgTypeScriptLang, "script-language", CommandCompletions::eNoCompletion, { nullptr, false }, "The scripting language to be used for script-based commands. Currently only Python is valid." }, 1090 { eArgTypeSearchWord, "search-word", CommandCompletions::eNoCompletion, { nullptr, false }, "Any word of interest for search purposes." }, 1091 { eArgTypeSelector, "selector", CommandCompletions::eNoCompletion, { nullptr, false }, "An Objective-C selector name." }, 1092 { 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)." }, 1093 { 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)." }, 1094 { eArgTypeSettingPrefix, "setting-prefix", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a settable internal debugger variable up to a dot ('.'), e.g. 'target.process.'" }, 1095 { 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." }, 1096 { eArgTypeShlibName, "shlib-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a shared library." }, 1097 { eArgTypeSourceFile, "source-file", CommandCompletions::eSourceFileCompletion, { nullptr, false }, "The name of a source file.." }, 1098 { eArgTypeSortOrder, "sort-order", CommandCompletions::eNoCompletion, { nullptr, false }, "Specify a sort order when dumping lists." }, 1099 { eArgTypeStartAddress, "start-address", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." }, 1100 { eArgTypeSummaryString, "summary-string", CommandCompletions::eNoCompletion, { SummaryStringHelpTextCallback, true }, nullptr }, 1101 { eArgTypeSymbol, "symbol", CommandCompletions::eSymbolCompletion, { nullptr, false }, "Any symbol name (function name, variable, argument, etc.)" }, 1102 { eArgTypeThreadID, "thread-id", CommandCompletions::eNoCompletion, { nullptr, false }, "Thread ID number." }, 1103 { eArgTypeThreadIndex, "thread-index", CommandCompletions::eNoCompletion, { nullptr, false }, "Index into the process' list of threads." }, 1104 { eArgTypeThreadName, "thread-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The thread's name." }, 1105 { eArgTypeTypeName, "type-name", CommandCompletions::eNoCompletion, { nullptr, false }, "A type name." }, 1106 { eArgTypeUnsignedInteger, "unsigned-integer", CommandCompletions::eNoCompletion, { nullptr, false }, "An unsigned integer." }, 1107 { eArgTypeUnixSignal, "unix-signal", CommandCompletions::eNoCompletion, { nullptr, false }, "A valid Unix signal name or number (e.g. SIGKILL, KILL or 9)." }, 1108 { eArgTypeVarName, "variable-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a variable in your program." }, 1109 { eArgTypeValue, "value", CommandCompletions::eNoCompletion, { nullptr, false }, "A value could be anything, depending on where and how it is used." }, 1110 { eArgTypeWidth, "width", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." }, 1111 { eArgTypeNone, "none", CommandCompletions::eNoCompletion, { nullptr, false }, "No help available for this." }, 1112 { 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." }, 1113 { eArgTypeWatchpointID, "watchpt-id", CommandCompletions::eNoCompletion, { nullptr, false }, "Watchpoint IDs are positive integers." }, 1114 { eArgTypeWatchpointIDRange, "watchpt-id-list", CommandCompletions::eNoCompletion, { nullptr, false }, "For example, '1-3' or '1 to 3'." }, 1115 { eArgTypeWatchType, "watch-type", CommandCompletions::eNoCompletion, { nullptr, false }, "Specify the type for a watchpoint." }, 1116 { 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." }, 1117 { eArgTypeCommand, "command", CommandCompletions::eNoCompletion, { nullptr, false }, "An LLDB Command line command." } 1118 // clang-format on 1119 }; 1120 1121 const CommandObject::ArgumentTableEntry *CommandObject::GetArgumentTable() { 1122 // If this assertion fires, then the table above is out of date with the 1123 // CommandArgumentType enumeration 1124 assert((sizeof(CommandObject::g_arguments_data) / 1125 sizeof(CommandObject::ArgumentTableEntry)) == eArgTypeLastArg); 1126 return CommandObject::g_arguments_data; 1127 } 1128