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