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 "lldb/lldb-enumerations.h"
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/Support/FormatProviders.h"
15 #include "llvm/Support/raw_ostream.h"
16 
17 namespace lldb_private {
18 
19 // Thread Step Types
20 enum StepType {
21   eStepTypeNone,
22   eStepTypeTrace,     ///< Single step one instruction.
23   eStepTypeTraceOver, ///< Single step one instruction, stepping over.
24   eStepTypeInto,      ///< Single step into a specified context.
25   eStepTypeOver,      ///< Single step over a specified context.
26   eStepTypeOut,       ///< Single step out a specified context.
27   eStepTypeScripted   ///< A step type implemented by the script interpreter.
28 };
29 
30 // Address Types
31 enum AddressType {
32   eAddressTypeInvalid = 0,
33   eAddressTypeFile, ///< Address is an address as found in an object or symbol
34                     /// file
35   eAddressTypeLoad, ///< Address is an address as in the current target inferior
36                     /// process
37   eAddressTypeHost  ///< Address is an address in the process that is running
38                     /// this code
39 };
40 
41 // Address Class
42 //
43 // A way of classifying an address used for disassembling and setting
44 // breakpoints. Many object files can track exactly what parts of their object
45 // files are code, data and other information. This is of course above and
46 // beyond just looking at the section types. For example, code might contain PC
47 // relative data and the object file might be able to tell us that an address
48 // in code is data.
49 enum class AddressClass {
50   eInvalid,
51   eUnknown,
52   eCode,
53   eCodeAlternateISA,
54   eData,
55   eDebug,
56   eRuntime
57 };
58 
59 // Votes - Need a tri-state, yes, no, no opinion...
60 enum Vote { eVoteNo = -1, eVoteNoOpinion = 0, eVoteYes = 1 };
61 
62 enum ArchitectureType {
63   eArchTypeInvalid,
64   eArchTypeMachO,
65   eArchTypeELF,
66   eArchTypeCOFF,
67   kNumArchTypes
68 };
69 
70 /// Settable state variable types.
71 ///
72 
73 // typedef enum SettableVariableType
74 //{
75 //    eSetVarTypeInt,
76 //    eSetVarTypeBoolean,
77 //    eSetVarTypeString,
78 //    eSetVarTypeArray,
79 //    eSetVarTypeDictionary,
80 //    eSetVarTypeEnum,
81 //    eSetVarTypeNone
82 //} SettableVariableType;
83 
84 enum VarSetOperationType {
85   eVarSetOperationReplace,
86   eVarSetOperationInsertBefore,
87   eVarSetOperationInsertAfter,
88   eVarSetOperationRemove,
89   eVarSetOperationAppend,
90   eVarSetOperationClear,
91   eVarSetOperationAssign,
92   eVarSetOperationInvalid
93 };
94 
95 enum ArgumentRepetitionType {
96   eArgRepeatPlain,        // Exactly one occurrence
97   eArgRepeatOptional,     // At most one occurrence, but it's optional
98   eArgRepeatPlus,         // One or more occurrences
99   eArgRepeatStar,         // Zero or more occurrences
100   eArgRepeatRange,        // Repetition of same argument, from 1 to n
101   eArgRepeatPairPlain,    // A pair of arguments that must always go together
102                           // ([arg-type arg-value]), occurs exactly once
103   eArgRepeatPairOptional, // A pair that occurs at most once (optional)
104   eArgRepeatPairPlus,     // One or more occurrences of a pair
105   eArgRepeatPairStar,     // Zero or more occurrences of a pair
106   eArgRepeatPairRange,    // A pair that repeats from 1 to n
107   eArgRepeatPairRangeOptional // A pair that repeats from 1 to n, but is
108                               // optional
109 };
110 
111 enum SortOrder {
112   eSortOrderNone,
113   eSortOrderByAddress,
114   eSortOrderByName,
115   eSortOrderBySize
116 };
117 
118 // LazyBool is for boolean values that need to be calculated lazily. Values
119 // start off set to eLazyBoolCalculate, and then they can be calculated once
120 // and set to eLazyBoolNo or eLazyBoolYes.
121 enum LazyBool { eLazyBoolCalculate = -1, eLazyBoolNo = 0, eLazyBoolYes = 1 };
122 
123 /// Instruction types
124 enum InstructionType {
125   eInstructionTypeAny, // Support for any instructions at all (at least one)
126   eInstructionTypePrologueEpilogue, // All prologue and epilogue instructions
127                                     // that push and pop register values and
128                                     // modify sp/fp
129   eInstructionTypePCModifying,      // Any instruction that modifies the program
130                                     // counter/instruction pointer
131   eInstructionTypeAll               // All instructions of any kind
132 
133 };
134 
135 /// Format category entry types
136 enum FormatCategoryItem {
137   eFormatCategoryItemSummary = 1,
138   eFormatCategoryItemFilter = 1 << 1,
139   eFormatCategoryItemSynth = 1 << 2,
140   eFormatCategoryItemFormat = 1 << 3,
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   Builtin = 1 << 10,
208 
209   Any = 1 << 15,
210   /// Match 0..n nested modules.
211   AnyModule = Any | Module,
212   /// Match any type.
213   AnyType = Any | Class | Struct | Union | Enum | Typedef | Builtin,
214   /// Math any declaration context.
215   AnyDeclContext = Any | Namespace | Class | Struct | Union | Enum | Function
216 };
217 
218 // Enumerations that can be used to specify the kind of metric we're looking at
219 // when collecting stats.
220 enum StatisticKind {
221   ExpressionSuccessful = 0,
222   ExpressionFailure = 1,
223   FrameVarSuccess = 2,
224   FrameVarFailure = 3,
225   StatisticMax = 4
226 };
227 
228 // Enumeration that can be used to specify a log handler.
229 enum LogHandlerKind {
230   eLogHandlerStream,
231   eLogHandlerCallback,
232   eLogHandlerCircular,
233   eLogHandlerSystem,
234   eLogHandlerDefault = eLogHandlerStream,
235 };
236 
237 enum LoadDependentFiles {
238   eLoadDependentsDefault,
239   eLoadDependentsYes,
240   eLoadDependentsNo,
241 };
242 
243 /// Useful for callbacks whose return type indicates
244 /// whether to continue iteration or short-circuit.
245 enum class IterationAction {
246   Continue = 0,
247   Stop,
248 };
249 
GetStatDescription(lldb_private::StatisticKind K)250 inline std::string GetStatDescription(lldb_private::StatisticKind K) {
251    switch (K) {
252    case StatisticKind::ExpressionSuccessful:
253      return "Number of expr evaluation successes";
254    case StatisticKind::ExpressionFailure:
255      return "Number of expr evaluation failures";
256    case StatisticKind::FrameVarSuccess:
257      return "Number of frame var successes";
258    case StatisticKind::FrameVarFailure:
259      return "Number of frame var failures";
260    case StatisticKind::StatisticMax:
261      return "";
262    }
263    llvm_unreachable("Statistic not registered!");
264 }
265 
266 } // namespace lldb_private
267 
268 namespace llvm {
269 template <> struct format_provider<lldb_private::Vote> {
270   static void format(const lldb_private::Vote &V, llvm::raw_ostream &Stream,
271                      StringRef Style) {
272     switch (V) {
273     case lldb_private::eVoteNo:
274       Stream << "no";
275       return;
276     case lldb_private::eVoteNoOpinion:
277       Stream << "no opinion";
278       return;
279     case lldb_private::eVoteYes:
280       Stream << "yes";
281       return;
282     }
283     Stream << "invalid";
284   }
285 };
286 }
287 
288 enum SelectMostRelevant : bool {
289   SelectMostRelevantFrame = true,
290   DoNoSelectMostRelevantFrame = false,
291 };
292 
293 enum InterruptionControl : bool {
294   AllowInterruption = true,
295   DoNotAllowInterruption = false,
296 };
297 
298 /// The hardware and native stub capabilities for a given target,
299 /// for translating a user's watchpoint request into hardware
300 /// capable watchpoint resources.
301 FLAGS_ENUM(WatchpointHardwareFeature){
302     /// lldb will fall back to a default that assumes the target
303     /// can watch up to pointer-size power-of-2 regions, aligned to
304     /// power-of-2.
305     eWatchpointHardwareFeatureUnknown = (1u << 0),
306 
307     /// Intel systems can watch 1, 2, 4, or 8 bytes (in 64-bit targets),
308     /// aligned naturally.
309     eWatchpointHardwareX86 = (1u << 1),
310 
311     /// ARM systems with Byte Address Select watchpoints
312     /// can watch any consecutive series of bytes up to the
313     /// size of a pointer (4 or 8 bytes), at a pointer-size
314     /// alignment.
315     eWatchpointHardwareArmBAS = (1u << 2),
316 
317     /// ARM systems with MASK watchpoints can watch any power-of-2
318     /// sized region from 8 bytes to 2 gigabytes, aligned to that
319     /// same power-of-2 alignment.
320     eWatchpointHardwareArmMASK = (1u << 3),
321 };
322 LLDB_MARK_AS_BITMASK_ENUM(WatchpointHardwareFeature)
323 
324 #endif // LLDB_LLDB_PRIVATE_ENUMERATIONS_H
325