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