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