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