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