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 liblldb_lldb_private_types_h_ 10 #define liblldb_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 const char *name; // Name of this register, can't be NULL 35 const char *alt_name; // Alternate name of this register, can be NULL 36 uint32_t byte_size; // Size in bytes of the register 37 uint32_t byte_offset; // The byte offset in the register context data where 38 // this register's value is found. 39 // This is optional, and can be 0 if a particular RegisterContext does not 40 // need to address its registers by byte offset. 41 lldb::Encoding encoding; // Encoding of the register bits 42 lldb::Format format; // Default display format 43 uint32_t kinds[lldb::kNumRegisterKinds]; // Holds all of the various register 44 // numbers for all register kinds 45 uint32_t *value_regs; // List of registers (terminated with 46 // LLDB_INVALID_REGNUM). If this value is not null, 47 // all registers in this list will be read first, at 48 // which point the value for this register will be 49 // valid. For example, the value list for ah would be 50 // eax (x86) or rax (x64). 51 uint32_t *invalidate_regs; // List of registers (terminated with 52 // LLDB_INVALID_REGNUM). If this value is not 53 // null, all registers in this list will be 54 // invalidated when the value of this register 55 // changes. For example, the invalidate list for 56 // eax would be rax ax, ah, and al. 57 const uint8_t *dynamic_size_dwarf_expr_bytes; // A DWARF expression that when 58 // evaluated gives 59 // the byte size of this register. 60 size_t dynamic_size_dwarf_len; // The length of the DWARF expression in bytes 61 // in the dynamic_size_dwarf_expr_bytes 62 // member. 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 const char *name; // Name of this register set 77 const char *short_name; // A short name for this register set 78 size_t num_registers; // The number of registers in REGISTERS array below 79 const uint32_t *registers; // An array of register indices in this set. The 80 // values in this array are 81 // *indices* (not register numbers) into a particular RegisterContext's 82 // register array. For example, if eax is defined at index 4 for a 83 // particular RegisterContext, eax would be included in this RegisterSet by 84 // adding the value 4. Not by adding the value lldb_eax_i386. 85 }; 86 87 struct OptionEnumValueElement { 88 int64_t value; 89 const char *string_value; 90 const char *usage; 91 }; 92 93 using OptionEnumValues = llvm::ArrayRef<OptionEnumValueElement>; 94 95 struct OptionValidator { 96 virtual ~OptionValidator() {} 97 virtual bool IsValid(Platform &platform, 98 const ExecutionContext &target) const = 0; 99 virtual const char *ShortConditionString() const = 0; 100 virtual const char *LongConditionString() const = 0; 101 }; 102 103 struct OptionDefinition { 104 uint32_t usage_mask; // Used to mark options that can be used together. If (1 105 // << n & usage_mask) != 0 106 // then this option belongs to option set n. 107 bool required; // This option is required (in the current usage level) 108 const char *long_option; // Full name for this option. 109 int short_option; // Single character for this option. 110 int option_has_arg; // no_argument, required_argument or optional_argument 111 OptionValidator *validator; // If non-NULL, option is valid iff 112 // |validator->IsValid()|, otherwise always valid. 113 OptionEnumValues enum_values; // If not empty, an array of enum values. 114 uint32_t completion_type; // Cookie the option class can use to do define the 115 // argument completion. 116 lldb::CommandArgumentType argument_type; // Type of argument this option takes 117 const char *usage_text; // Full text explaining what this options does and 118 // what (if any) argument to 119 // pass it. 120 }; 121 122 typedef struct type128 { uint64_t x[2]; } type128; 123 typedef struct type256 { uint64_t x[4]; } type256; 124 125 } // namespace lldb_private 126 127 #endif // #if defined(__cplusplus) 128 129 #endif // liblldb_lldb_private_types_h_ 130