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