1 //===-- lldb-private-enumerations.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_LLDB_PRIVATE_ENUMERATIONS_H
10 #define LLDB_LLDB_PRIVATE_ENUMERATIONS_H
11 
12 #include "llvm/ADT/StringRef.h"
13 #include "llvm/Support/FormatProviders.h"
14 #include "llvm/Support/raw_ostream.h"
15 
16 namespace lldb_private {
17 
18 // Thread Step Types
19 enum StepType {
20   eStepTypeNone,
21   eStepTypeTrace,     ///< Single step one instruction.
22   eStepTypeTraceOver, ///< Single step one instruction, stepping over.
23   eStepTypeInto,      ///< Single step into a specified context.
24   eStepTypeOver,      ///< Single step over a specified context.
25   eStepTypeOut,       ///< Single step out a specified context.
26   eStepTypeScripted   ///< A step type implemented by the script interpreter.
27 };
28 
29 // Address Types
30 enum AddressType {
31   eAddressTypeInvalid = 0,
32   eAddressTypeFile, ///< Address is an address as found in an object or symbol
33                     /// file
34   eAddressTypeLoad, ///< Address is an address as in the current target inferior
35                     /// process
36   eAddressTypeHost  ///< Address is an address in the process that is running
37                     /// this code
38 };
39 
40 // Address Class
41 //
42 // A way of classifying an address used for disassembling and setting
43 // breakpoints. Many object files can track exactly what parts of their object
44 // files are code, data and other information. This is of course above and
45 // beyond just looking at the section types. For example, code might contain PC
46 // relative data and the object file might be able to tell us that an address
47 // in code is data.
48 enum class AddressClass {
49   eInvalid,
50   eUnknown,
51   eCode,
52   eCodeAlternateISA,
53   eData,
54   eDebug,
55   eRuntime
56 };
57 
58 // Votes - Need a tri-state, yes, no, no opinion...
59 enum Vote { eVoteNo = -1, eVoteNoOpinion = 0, eVoteYes = 1 };
60 
61 enum ArchitectureType {
62   eArchTypeInvalid,
63   eArchTypeMachO,
64   eArchTypeELF,
65   eArchTypeCOFF,
66   kNumArchTypes
67 };
68 
69 /// Settable state variable types.
70 ///
71 
72 // typedef enum SettableVariableType
73 //{
74 //    eSetVarTypeInt,
75 //    eSetVarTypeBoolean,
76 //    eSetVarTypeString,
77 //    eSetVarTypeArray,
78 //    eSetVarTypeDictionary,
79 //    eSetVarTypeEnum,
80 //    eSetVarTypeNone
81 //} SettableVariableType;
82 
83 enum VarSetOperationType {
84   eVarSetOperationReplace,
85   eVarSetOperationInsertBefore,
86   eVarSetOperationInsertAfter,
87   eVarSetOperationRemove,
88   eVarSetOperationAppend,
89   eVarSetOperationClear,
90   eVarSetOperationAssign,
91   eVarSetOperationInvalid
92 };
93 
94 enum ArgumentRepetitionType {
95   eArgRepeatPlain,        // Exactly one occurrence
96   eArgRepeatOptional,     // At most one occurrence, but it's optional
97   eArgRepeatPlus,         // One or more occurrences
98   eArgRepeatStar,         // Zero or more occurrences
99   eArgRepeatRange,        // Repetition of same argument, from 1 to n
100   eArgRepeatPairPlain,    // A pair of arguments that must always go together
101                           // ([arg-type arg-value]), occurs exactly once
102   eArgRepeatPairOptional, // A pair that occurs at most once (optional)
103   eArgRepeatPairPlus,     // One or more occurrences of a pair
104   eArgRepeatPairStar,     // Zero or more occurrences of a pair
105   eArgRepeatPairRange,    // A pair that repeats from 1 to n
106   eArgRepeatPairRangeOptional // A pair that repeats from 1 to n, but is
107                               // optional
108 };
109 
110 enum SortOrder { eSortOrderNone, eSortOrderByAddress, eSortOrderByName };
111 
112 // LazyBool is for boolean values that need to be calculated lazily. Values
113 // start off set to eLazyBoolCalculate, and then they can be calculated once
114 // and set to eLazyBoolNo or eLazyBoolYes.
115 enum LazyBool { eLazyBoolCalculate = -1, eLazyBoolNo = 0, eLazyBoolYes = 1 };
116 
117 /// Instruction types
118 enum InstructionType {
119   eInstructionTypeAny, // Support for any instructions at all (at least one)
120   eInstructionTypePrologueEpilogue, // All prologue and epilogue instructions
121                                     // that push and pop register values and
122                                     // modify sp/fp
123   eInstructionTypePCModifying,      // Any instruction that modifies the program
124                                     // counter/instruction pointer
125   eInstructionTypeAll               // All instructions of any kind
126 
127 };
128 
129 /// Format category entry types
130 enum FormatCategoryItem {
131   eFormatCategoryItemSummary = 0x0001,
132   eFormatCategoryItemRegexSummary = 0x0002,
133   eFormatCategoryItemFilter = 0x0004,
134   eFormatCategoryItemRegexFilter = 0x0008,
135   eFormatCategoryItemSynth = 0x0010,
136   eFormatCategoryItemRegexSynth = 0x0020,
137   eFormatCategoryItemValue = 0x0040,
138   eFormatCategoryItemRegexValue = 0x0080,
139   eFormatCategoryItemValidator = 0x0100,
140   eFormatCategoryItemRegexValidator = 0x0200
141 };
142 
143 /// Expression execution policies
144 enum ExecutionPolicy {
145   eExecutionPolicyOnlyWhenNeeded,
146   eExecutionPolicyNever,
147   eExecutionPolicyAlways,
148   eExecutionPolicyTopLevel // used for top-level code
149 };
150 
151 // Synchronicity behavior of scripted commands
152 enum ScriptedCommandSynchronicity {
153   eScriptedCommandSynchronicitySynchronous,
154   eScriptedCommandSynchronicityAsynchronous,
155   eScriptedCommandSynchronicityCurrentValue // use whatever the current
156                                             // synchronicity is
157 };
158 
159 // Verbosity mode of "po" output
160 enum LanguageRuntimeDescriptionDisplayVerbosity {
161   eLanguageRuntimeDescriptionDisplayVerbosityCompact, // only print the
162                                                       // description string, if
163                                                       // any
164   eLanguageRuntimeDescriptionDisplayVerbosityFull,    // print the full-blown
165                                                       // output
166 };
167 
168 // Loading modules from memory
169 enum MemoryModuleLoadLevel {
170   eMemoryModuleLoadLevelMinimal,  // Load sections only
171   eMemoryModuleLoadLevelPartial,  // Load function bounds but no symbols
172   eMemoryModuleLoadLevelComplete, // Load sections and all symbols
173 };
174 
175 // Behavior on fork/vfork
176 enum FollowForkMode {
177   eFollowParent, // Follow parent process
178   eFollowChild,  // Follow child process
179 };
180 
181 // Result enums for when reading multiple lines from IOHandlers
182 enum class LineStatus {
183   Success, // The line that was just edited if good and should be added to the
184            // lines
185   Status,  // There is an error with the current line and it needs to be
186            // re-edited
187            // before it can be accepted
188   Done     // Lines are complete
189 };
190 
191 // Boolean result of running a Type Validator
192 enum class TypeValidatorResult : bool { Success = true, Failure = false };
193 
194 // Enumerations that can be used to specify scopes types when looking up types.
195 enum class CompilerContextKind : uint16_t {
196   Invalid = 0,
197   TranslationUnit = 1,
198   Module = 1 << 1,
199   Namespace = 1 << 2,
200   Class = 1 << 3,
201   Struct = 1 << 4,
202   Union = 1 << 5,
203   Function = 1 << 6,
204   Variable = 1 << 7,
205   Enum = 1 << 8,
206   Typedef = 1 << 9,
207 
208   Any = 1 << 15,
209   /// Match 0..n nested modules.
210   AnyModule = Any | Module,
211   /// Match any type.
212   AnyType = Any | Class | Struct | Union | Enum | Typedef
213 };
214 
215 // Enumerations that can be used to specify the kind of metric we're looking at
216 // when collecting stats.
217 enum StatisticKind {
218   ExpressionSuccessful = 0,
219   ExpressionFailure = 1,
220   FrameVarSuccess = 2,
221   FrameVarFailure = 3,
222   StatisticMax = 4
223 };
224 
225 // Enumeration that can be used to specify a log handler.
226 enum LogHandlerKind {
227   eLogHandlerStream,
228   eLogHandlerCallback,
229   eLogHandlerCircular,
230   eLogHandlerSystem,
231   eLogHandlerDefault = eLogHandlerStream,
232 };
233 
234 enum ReproducerProvider {
235   eReproducerProviderCommands,
236   eReproducerProviderFiles,
237   eReproducerProviderSymbolFiles,
238   eReproducerProviderGDB,
239   eReproducerProviderProcessInfo,
240   eReproducerProviderVersion,
241   eReproducerProviderWorkingDirectory,
242   eReproducerProviderHomeDirectory,
243   eReproducerProviderNone,
244 };
245 
246 enum ReproducerCrashSignal {
247   eReproducerCrashSigill,
248   eReproducerCrashSigsegv,
249 };
250 
251 enum LoadDependentFiles {
252   eLoadDependentsDefault,
253   eLoadDependentsYes,
254   eLoadDependentsNo,
255 };
256 
257 inline std::string GetStatDescription(lldb_private::StatisticKind K) {
258    switch (K) {
259    case StatisticKind::ExpressionSuccessful:
260      return "Number of expr evaluation successes";
261    case StatisticKind::ExpressionFailure:
262      return "Number of expr evaluation failures";
263    case StatisticKind::FrameVarSuccess:
264      return "Number of frame var successes";
265    case StatisticKind::FrameVarFailure:
266      return "Number of frame var failures";
267    case StatisticKind::StatisticMax:
268      return "";
269    }
270    llvm_unreachable("Statistic not registered!");
271 }
272 
273 } // namespace lldb_private
274 
275 namespace llvm {
276 template <> struct format_provider<lldb_private::Vote> {
277   static void format(const lldb_private::Vote &V, llvm::raw_ostream &Stream,
278                      StringRef Style) {
279     switch (V) {
280     case lldb_private::eVoteNo:
281       Stream << "no";
282       return;
283     case lldb_private::eVoteNoOpinion:
284       Stream << "no opinion";
285       return;
286     case lldb_private::eVoteYes:
287       Stream << "yes";
288       return;
289     }
290     Stream << "invalid";
291   }
292 };
293 }
294 
295 #endif // LLDB_LLDB_PRIVATE_ENUMERATIONS_H
296