1 //===-- CommandCompletions.h ------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLDB_INTERPRETER_COMMANDCOMPLETIONS_H 10 #define LLDB_INTERPRETER_COMMANDCOMPLETIONS_H 11 12 #include <set> 13 14 #include "lldb/Core/FileSpecList.h" 15 #include "lldb/Core/SearchFilter.h" 16 #include "lldb/Interpreter/Options.h" 17 #include "lldb/Utility/CompletionRequest.h" 18 #include "lldb/Utility/RegularExpression.h" 19 #include "lldb/lldb-private.h" 20 21 #include "llvm/ADT/Twine.h" 22 23 namespace lldb_private { 24 class TildeExpressionResolver; 25 class CommandCompletions { 26 public: 27 enum CommonCompletionTypes { 28 eNoCompletion = 0u, 29 eSourceFileCompletion = (1u << 0), 30 eDiskFileCompletion = (1u << 1), 31 eDiskDirectoryCompletion = (1u << 2), 32 eSymbolCompletion = (1u << 3), 33 eModuleCompletion = (1u << 4), 34 eSettingsNameCompletion = (1u << 5), 35 ePlatformPluginCompletion = (1u << 6), 36 eArchitectureCompletion = (1u << 7), 37 eVariablePathCompletion = (1u << 8), 38 eRegisterCompletion = (1u << 9), 39 eBreakpointCompletion = (1u << 10), 40 eProcessPluginCompletion = (1u << 11), 41 eDisassemblyFlavorCompletion = (1u << 12), 42 eTypeLanguageCompletion = (1u << 13), 43 eFrameIndexCompletion = (1u << 14), 44 eModuleUUIDCompletion = (1u << 15), 45 eStopHookIDCompletion = (1u << 16), 46 eThreadIndexCompletion = (1u << 17), 47 eWatchPointIDCompletion = (1u << 18), 48 eBreakpointNameCompletion = (1u << 19), 49 eProcessIDCompletion = (1u << 20), 50 eProcessNameCompletion = (1u << 21), 51 eRemoteDiskFileCompletion = (1u << 22), 52 eRemoteDiskDirectoryCompletion = (1u << 23), 53 eTypeCategoryNameCompletion = (1u << 24), 54 // This item serves two purposes. It is the last element in the enum, so 55 // you can add custom enums starting from here in your Option class. Also 56 // if you & in this bit the base code will not process the option. 57 eCustomCompletion = (1u << 24) 58 }; 59 60 static bool InvokeCommonCompletionCallbacks( 61 CommandInterpreter &interpreter, uint32_t completion_mask, 62 lldb_private::CompletionRequest &request, SearchFilter *searcher); 63 64 // These are the generic completer functions: 65 static void DiskFiles(CommandInterpreter &interpreter, 66 CompletionRequest &request, SearchFilter *searcher); 67 68 static void DiskFiles(const llvm::Twine &partial_file_name, 69 StringList &matches, TildeExpressionResolver &Resolver); 70 71 static void DiskDirectories(CommandInterpreter &interpreter, 72 CompletionRequest &request, 73 SearchFilter *searcher); 74 75 static void DiskDirectories(const llvm::Twine &partial_file_name, 76 StringList &matches, 77 TildeExpressionResolver &Resolver); 78 79 static void RemoteDiskFiles(CommandInterpreter &interpreter, 80 CompletionRequest &request, 81 SearchFilter *searcher); 82 83 static void RemoteDiskDirectories(CommandInterpreter &interpreter, 84 CompletionRequest &request, 85 SearchFilter *searcher); 86 87 static void SourceFiles(CommandInterpreter &interpreter, 88 CompletionRequest &request, SearchFilter *searcher); 89 90 static void Modules(CommandInterpreter &interpreter, 91 CompletionRequest &request, SearchFilter *searcher); 92 93 static void ModuleUUIDs(CommandInterpreter &interpreter, 94 CompletionRequest &request, SearchFilter *searcher); 95 96 static void Symbols(CommandInterpreter &interpreter, 97 CompletionRequest &request, SearchFilter *searcher); 98 99 static void SettingsNames(CommandInterpreter &interpreter, 100 CompletionRequest &request, SearchFilter *searcher); 101 102 static void PlatformPluginNames(CommandInterpreter &interpreter, 103 CompletionRequest &request, 104 SearchFilter *searcher); 105 106 static void ArchitectureNames(CommandInterpreter &interpreter, 107 CompletionRequest &request, 108 SearchFilter *searcher); 109 110 static void VariablePath(CommandInterpreter &interpreter, 111 CompletionRequest &request, SearchFilter *searcher); 112 113 static void Registers(CommandInterpreter &interpreter, 114 CompletionRequest &request, SearchFilter *searcher); 115 116 static void Breakpoints(CommandInterpreter &interpreter, 117 CompletionRequest &request, SearchFilter *searcher); 118 119 static void BreakpointNames(CommandInterpreter &interpreter, 120 CompletionRequest &request, 121 SearchFilter *searcher); 122 123 static void ProcessPluginNames(CommandInterpreter &interpreter, 124 CompletionRequest &request, 125 SearchFilter *searcher); 126 127 static void ProcessIDs(CommandInterpreter &interpreter, 128 CompletionRequest &request, SearchFilter *searcher); 129 130 static void ProcessNames(CommandInterpreter &interpreter, 131 CompletionRequest &request, SearchFilter *searcher); 132 133 static void DisassemblyFlavors(CommandInterpreter &interpreter, 134 CompletionRequest &request, 135 SearchFilter *searcher); 136 137 static void TypeLanguages(CommandInterpreter &interpreter, 138 CompletionRequest &request, SearchFilter *searcher); 139 140 static void FrameIndexes(CommandInterpreter &interpreter, 141 CompletionRequest &request, SearchFilter *searcher); 142 143 static void StopHookIDs(CommandInterpreter &interpreter, 144 CompletionRequest &request, SearchFilter *searcher); 145 146 static void ThreadIndexes(CommandInterpreter &interpreter, 147 CompletionRequest &request, SearchFilter *searcher); 148 149 static void WatchPointIDs(CommandInterpreter &interpreter, 150 CompletionRequest &request, SearchFilter *searcher); 151 152 static void TypeCategoryNames(CommandInterpreter &interpreter, 153 CompletionRequest &request, 154 SearchFilter *searcher); 155 156 /// This completer works for commands whose only arguments are a command path. 157 /// It isn't tied to an argument type because it completes not on a single 158 /// argument but on the sequence of arguments, so you have to invoke it by 159 /// hand. 160 static void 161 CompleteModifiableCmdPathArgs(CommandInterpreter &interpreter, 162 CompletionRequest &request, 163 OptionElementVector &opt_element_vector); 164 }; 165 166 } // namespace lldb_private 167 168 #endif // LLDB_INTERPRETER_COMMANDCOMPLETIONS_H 169