1061da546Spatrick //===-- lldb-private-types.h ------------------------------------*- C++ -*-===//
2061da546Spatrick //
3061da546Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4061da546Spatrick // See https://llvm.org/LICENSE.txt for license information.
5061da546Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6061da546Spatrick //
7061da546Spatrick //===----------------------------------------------------------------------===//
8061da546Spatrick 
9dda28197Spatrick #ifndef LLDB_LLDB_PRIVATE_TYPES_H
10dda28197Spatrick #define LLDB_LLDB_PRIVATE_TYPES_H
11061da546Spatrick 
12061da546Spatrick #if defined(__cplusplus)
13061da546Spatrick 
14061da546Spatrick #include "lldb/lldb-private.h"
15061da546Spatrick 
16061da546Spatrick #include "llvm/ADT/ArrayRef.h"
17061da546Spatrick 
18*f6aab3d8Srobert #include <type_traits>
19*f6aab3d8Srobert 
20061da546Spatrick namespace llvm {
21061da546Spatrick namespace sys {
22061da546Spatrick class DynamicLibrary;
23061da546Spatrick }
24061da546Spatrick }
25061da546Spatrick 
26061da546Spatrick namespace lldb_private {
27061da546Spatrick class Platform;
28061da546Spatrick class ExecutionContext;
29061da546Spatrick 
30061da546Spatrick typedef llvm::sys::DynamicLibrary (*LoadPluginCallbackType)(
31061da546Spatrick     const lldb::DebuggerSP &debugger_sp, const FileSpec &spec, Status &error);
32061da546Spatrick 
33dda28197Spatrick /// Every register is described in detail including its name, alternate name
34dda28197Spatrick /// (optional), encoding, size in bytes and the default display format.
35061da546Spatrick struct RegisterInfo {
36dda28197Spatrick   /// Name of this register, can't be NULL.
37dda28197Spatrick   const char *name;
38dda28197Spatrick   /// Alternate name of this register, can be NULL.
39dda28197Spatrick   const char *alt_name;
40dda28197Spatrick   /// Size in bytes of the register.
41dda28197Spatrick   uint32_t byte_size;
42dda28197Spatrick   /// The byte offset in the register context data where this register's
43dda28197Spatrick   /// value is found.
44dda28197Spatrick   /// This is optional, and can be 0 if a particular RegisterContext does not
45dda28197Spatrick   /// need to address its registers by byte offset.
46dda28197Spatrick   uint32_t byte_offset;
47dda28197Spatrick   /// Encoding of the register bits.
48dda28197Spatrick   lldb::Encoding encoding;
49dda28197Spatrick   /// Default display format.
50dda28197Spatrick   lldb::Format format;
51dda28197Spatrick   /// Holds all of the various register numbers for all register kinds.
52dda28197Spatrick   uint32_t kinds[lldb::kNumRegisterKinds]; //
53dda28197Spatrick   /// List of registers (terminated with LLDB_INVALID_REGNUM). If this value is
54dda28197Spatrick   /// not null, all registers in this list will be read first, at which point
55dda28197Spatrick   /// the value for this register will be valid. For example, the value list
56*f6aab3d8Srobert   /// for ah would be eax (x86) or rax (x64). Register numbers are
57*f6aab3d8Srobert   /// of eRegisterKindLLDB. If multiple registers are listed, the final
58*f6aab3d8Srobert   /// value will be the concatenation of them.
59*f6aab3d8Srobert   uint32_t *value_regs;
60dda28197Spatrick   /// List of registers (terminated with LLDB_INVALID_REGNUM). If this value is
61dda28197Spatrick   /// not null, all registers in this list will be invalidated when the value of
62dda28197Spatrick   /// this register changes. For example, the invalidate list for eax would be
63dda28197Spatrick   /// rax ax, ah, and al.
64dda28197Spatrick   uint32_t *invalidate_regs;
65061da546Spatrick 
dataRegisterInfo66061da546Spatrick   llvm::ArrayRef<uint8_t> data(const uint8_t *context_base) const {
67061da546Spatrick     return llvm::ArrayRef<uint8_t>(context_base + byte_offset, byte_size);
68061da546Spatrick   }
69061da546Spatrick 
mutable_dataRegisterInfo70061da546Spatrick   llvm::MutableArrayRef<uint8_t> mutable_data(uint8_t *context_base) const {
71061da546Spatrick     return llvm::MutableArrayRef<uint8_t>(context_base + byte_offset,
72061da546Spatrick                                           byte_size);
73061da546Spatrick   }
74061da546Spatrick };
75*f6aab3d8Srobert static_assert(std::is_trivial<RegisterInfo>::value,
76*f6aab3d8Srobert               "RegisterInfo must be trivial.");
77061da546Spatrick 
78dda28197Spatrick /// Registers are grouped into register sets
79061da546Spatrick struct RegisterSet {
80dda28197Spatrick   /// Name of this register set.
81dda28197Spatrick   const char *name;
82dda28197Spatrick   /// A short name for this register set.
83dda28197Spatrick   const char *short_name;
84dda28197Spatrick   /// The number of registers in REGISTERS array below.
85dda28197Spatrick   size_t num_registers;
86dda28197Spatrick   /// An array of register indices in this set. The values in this array are
87dda28197Spatrick   /// *indices* (not register numbers) into a particular RegisterContext's
88dda28197Spatrick   /// register array.  For example, if eax is defined at index 4 for a
89dda28197Spatrick   /// particular RegisterContext, eax would be included in this RegisterSet by
90dda28197Spatrick   /// adding the value 4.  Not by adding the value lldb_eax_i386.
91dda28197Spatrick   const uint32_t *registers;
92061da546Spatrick };
93061da546Spatrick 
94061da546Spatrick struct OptionEnumValueElement {
95061da546Spatrick   int64_t value;
96061da546Spatrick   const char *string_value;
97061da546Spatrick   const char *usage;
98061da546Spatrick };
99061da546Spatrick 
100061da546Spatrick using OptionEnumValues = llvm::ArrayRef<OptionEnumValueElement>;
101061da546Spatrick 
102061da546Spatrick struct OptionValidator {
103be691f3bSpatrick   virtual ~OptionValidator() = default;
104061da546Spatrick   virtual bool IsValid(Platform &platform,
105061da546Spatrick                        const ExecutionContext &target) const = 0;
106061da546Spatrick   virtual const char *ShortConditionString() const = 0;
107061da546Spatrick   virtual const char *LongConditionString() const = 0;
108061da546Spatrick };
109061da546Spatrick 
110061da546Spatrick typedef struct type128 { uint64_t x[2]; } type128;
111061da546Spatrick typedef struct type256 { uint64_t x[4]; } type256;
112061da546Spatrick 
113*f6aab3d8Srobert /// Functor that returns a ValueObjectSP for a variable given its name
114*f6aab3d8Srobert /// and the StackFrame of interest. Used primarily in the Materializer
115*f6aab3d8Srobert /// to refetch a ValueObject when the ExecutionContextScope changes.
116*f6aab3d8Srobert using ValueObjectProviderTy =
117*f6aab3d8Srobert     std::function<lldb::ValueObjectSP(ConstString, StackFrame *)>;
118*f6aab3d8Srobert 
119061da546Spatrick } // namespace lldb_private
120061da546Spatrick 
121061da546Spatrick #endif // #if defined(__cplusplus)
122061da546Spatrick 
123dda28197Spatrick #endif // LLDB_LLDB_PRIVATE_TYPES_H
124