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