1 //===-- lldb-private-types.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_TYPES_H
10 #define LLDB_LLDB_PRIVATE_TYPES_H
11 
12 #if defined(__cplusplus)
13 
14 #include "lldb/lldb-private.h"
15 
16 #include "llvm/ADT/ArrayRef.h"
17 
18 namespace llvm {
19 namespace sys {
20 class DynamicLibrary;
21 }
22 }
23 
24 namespace lldb_private {
25 class Platform;
26 class ExecutionContext;
27 
28 typedef llvm::sys::DynamicLibrary (*LoadPluginCallbackType)(
29     const lldb::DebuggerSP &debugger_sp, const FileSpec &spec, Status &error);
30 
31 /// Every register is described in detail including its name, alternate name
32 /// (optional), encoding, size in bytes and the default display format.
33 struct RegisterInfo {
34   /// Name of this register, can't be NULL.
35   const char *name;
36   /// Alternate name of this register, can be NULL.
37   const char *alt_name;
38   /// Size in bytes of the register.
39   uint32_t byte_size;
40   /// The byte offset in the register context data where this register's
41   /// value is found.
42   /// This is optional, and can be 0 if a particular RegisterContext does not
43   /// need to address its registers by byte offset.
44   uint32_t byte_offset;
45   /// Encoding of the register bits.
46   lldb::Encoding encoding;
47   /// Default display format.
48   lldb::Format format;
49   /// Holds all of the various register numbers for all register kinds.
50   uint32_t kinds[lldb::kNumRegisterKinds]; //
51   /// List of registers (terminated with LLDB_INVALID_REGNUM). If this value is
52   /// not null, all registers in this list will be read first, at which point
53   /// the value for this register will be valid. For example, the value list
54   /// for ah would be eax (x86) or rax (x64). Register numbers are
55   /// of eRegisterKindLLDB. If multiple registers are listed, the final
56   /// value will be the concatenation of them.
57   uint32_t *value_regs;
58   /// List of registers (terminated with LLDB_INVALID_REGNUM). If this value is
59   /// not null, all registers in this list will be invalidated when the value of
60   /// this register changes. For example, the invalidate list for eax would be
61   /// rax ax, ah, and al.
62   uint32_t *invalidate_regs;
63 
64   llvm::ArrayRef<uint8_t> data(const uint8_t *context_base) const {
65     return llvm::ArrayRef<uint8_t>(context_base + byte_offset, byte_size);
66   }
67 
68   llvm::MutableArrayRef<uint8_t> mutable_data(uint8_t *context_base) const {
69     return llvm::MutableArrayRef<uint8_t>(context_base + byte_offset,
70                                           byte_size);
71   }
72 };
73 
74 /// Registers are grouped into register sets
75 struct RegisterSet {
76   /// Name of this register set.
77   const char *name;
78   /// A short name for this register set.
79   const char *short_name;
80   /// The number of registers in REGISTERS array below.
81   size_t num_registers;
82   /// An array of register indices in this set. The values in this array are
83   /// *indices* (not register numbers) into a particular RegisterContext's
84   /// register array.  For example, if eax is defined at index 4 for a
85   /// particular RegisterContext, eax would be included in this RegisterSet by
86   /// adding the value 4.  Not by adding the value lldb_eax_i386.
87   const uint32_t *registers;
88 };
89 
90 struct OptionEnumValueElement {
91   int64_t value;
92   const char *string_value;
93   const char *usage;
94 };
95 
96 using OptionEnumValues = llvm::ArrayRef<OptionEnumValueElement>;
97 
98 struct OptionValidator {
99   virtual ~OptionValidator() = default;
100   virtual bool IsValid(Platform &platform,
101                        const ExecutionContext &target) const = 0;
102   virtual const char *ShortConditionString() const = 0;
103   virtual const char *LongConditionString() const = 0;
104 };
105 
106 typedef struct type128 { uint64_t x[2]; } type128;
107 typedef struct type256 { uint64_t x[4]; } type256;
108 
109 /// Functor that returns a ValueObjectSP for a variable given its name
110 /// and the StackFrame of interest. Used primarily in the Materializer
111 /// to refetch a ValueObject when the ExecutionContextScope changes.
112 using ValueObjectProviderTy =
113     std::function<lldb::ValueObjectSP(ConstString, StackFrame *)>;
114 
115 } // namespace lldb_private
116 
117 #endif // #if defined(__cplusplus)
118 
119 #endif // LLDB_LLDB_PRIVATE_TYPES_H
120