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