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