LLDB mainline
lldb-private-types.h
Go to the documentation of this file.
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#include "lldb/lldb-types.h"
13#include "llvm/ADT/ArrayRef.h"
14#include "llvm/ADT/SmallString.h"
15#include <type_traits>
16
17namespace llvm {
18namespace sys {
19class DynamicLibrary;
20}
21}
22
23namespace lldb_private {
24class Platform;
25class ExecutionContext;
26class RegisterFlags;
27
28typedef llvm::SmallString<256> PathSmallString;
29
30typedef 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.
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.
49 /// Default display format.
51 /// Holds all of the various register numbers for all register kinds.
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 /// If not nullptr, a type defined by XML descriptions.
66 /// Register info tables are constructed as const, but this field may need to
67 /// be updated if a specific target OS has a different layout. To enable that,
68 /// this is mutable. The data pointed to is still const, so you must swap a
69 /// whole set of flags for another.
70 mutable const RegisterFlags *flags_type;
71
72 llvm::ArrayRef<uint8_t> data(const uint8_t *context_base) const {
73 return llvm::ArrayRef<uint8_t>(context_base + byte_offset, byte_size);
74 }
75
76 llvm::MutableArrayRef<uint8_t> mutable_data(uint8_t *context_base) const {
77 return llvm::MutableArrayRef<uint8_t>(context_base + byte_offset,
78 byte_size);
79 }
80};
81static_assert(std::is_trivial<RegisterInfo>::value,
82 "RegisterInfo must be trivial.");
83
84/// Registers are grouped into register sets
86 /// Name of this register set.
87 const char *name;
88 /// A short name for this register set.
89 const char *short_name;
90 /// The number of registers in REGISTERS array below.
92 /// An array of register indices in this set. The values in this array are
93 /// *indices* (not register numbers) into a particular RegisterContext's
94 /// register array. For example, if eax is defined at index 4 for a
95 /// particular RegisterContext, eax would be included in this RegisterSet by
96 /// adding the value 4. Not by adding the value lldb_eax_i386.
97 const uint32_t *registers;
98};
99
100/// A type-erased pair of llvm::dwarf::SourceLanguageName and version.
102 SourceLanguage() = default;
103 explicit SourceLanguage(lldb::LanguageType language_type);
104
105 SourceLanguage(uint16_t name, uint32_t version)
106 : name(name), version(version) {}
107
109 std::optional<std::pair<uint16_t, uint32_t>> name_vers)
110 : name(name_vers ? name_vers->first : 0),
111 version(name_vers ? name_vers->second : 0) {}
112
113 explicit operator bool() const { return name > 0; }
114
116 llvm::StringRef GetDescription() const;
117 bool IsC() const;
118 bool IsObjC() const;
119 bool IsCPlusPlus() const;
120 uint16_t name = 0;
121 uint32_t version = 0;
122};
123
125 int64_t value;
126 const char *string_value;
127 const char *usage;
128};
129
130using OptionEnumValues = llvm::ArrayRef<OptionEnumValueElement>;
131
133 virtual ~OptionValidator() = default;
134 virtual bool IsValid(Platform &platform,
135 const ExecutionContext &target) const = 0;
136 virtual const char *ShortConditionString() const = 0;
137 virtual const char *LongConditionString() const = 0;
138};
139
140typedef struct type128 { uint64_t x[2]; } type128;
141typedef struct type256 { uint64_t x[4]; } type256;
142
143/// Functor that returns a ValueObjectSP for a variable given its name
144/// and the StackFrame of interest. Used primarily in the Materializer
145/// to refetch a ValueObject when the ExecutionContextScope changes.
147 std::function<lldb::ValueObjectSP(ConstString, StackFrame *)>;
148
149typedef void (*DebuggerDestroyCallback)(lldb::user_id_t debugger_id,
150 void *baton);
152 void *baton, const char **argv, lldb_private::CommandReturnObject &result);
153} // namespace lldb_private
154
155#endif // LLDB_LLDB_PRIVATE_TYPES_H
static llvm::raw_ostream & error(Stream &strm)
A uniqued constant string class.
Definition ConstString.h:40
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
A file utility class.
Definition FileSpec.h:57
A plug-in interface definition class for debug platform that includes many platform abilities such as...
Definition Platform.h:79
This base class provides an interface to stack frames.
Definition StackFrame.h:44
An error handling class.
Definition Status.h:118
A class that represents a running process on the host machine.
std::function< lldb::ValueObjectSP(ConstString, StackFrame *)> ValueObjectProviderTy
Functor that returns a ValueObjectSP for a variable given its name and the StackFrame of interest.
llvm::SmallString< 256 > PathSmallString
void(* DebuggerDestroyCallback)(lldb::user_id_t debugger_id, void *baton)
bool(* CommandOverrideCallbackWithResult)(void *baton, const char **argv, lldb_private::CommandReturnObject &result)
llvm::sys::DynamicLibrary(* LoadPluginCallbackType)(const lldb::DebuggerSP &debugger_sp, const FileSpec &spec, Status &error)
llvm::ArrayRef< OptionEnumValueElement > OptionEnumValues
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Format
Display format definitions.
LanguageType
Programming language type.
std::shared_ptr< lldb_private::Debugger > DebuggerSP
Encoding
Register encoding definitions.
uint64_t user_id_t
Definition lldb-types.h:82
virtual ~OptionValidator()=default
virtual const char * LongConditionString() const =0
virtual const char * ShortConditionString() const =0
virtual bool IsValid(Platform &platform, const ExecutionContext &target) const =0
Every register is described in detail including its name, alternate name (optional),...
llvm::MutableArrayRef< uint8_t > mutable_data(uint8_t *context_base) const
lldb::Encoding encoding
Encoding of the register bits.
const char * alt_name
Alternate name of this register, can be NULL.
uint32_t * value_regs
List of registers (terminated with LLDB_INVALID_REGNUM).
uint32_t byte_offset
The byte offset in the register context data where this register's value is found.
uint32_t byte_size
Size in bytes of the register.
uint32_t kinds[lldb::kNumRegisterKinds]
Holds all of the various register numbers for all register kinds.
const RegisterFlags * flags_type
If not nullptr, a type defined by XML descriptions.
llvm::ArrayRef< uint8_t > data(const uint8_t *context_base) const
const char * name
Name of this register, can't be NULL.
lldb::Format format
Default display format.
uint32_t * invalidate_regs
List of registers (terminated with LLDB_INVALID_REGNUM).
Registers are grouped into register sets.
size_t num_registers
The number of registers in REGISTERS array below.
const uint32_t * registers
An array of register indices in this set.
const char * name
Name of this register set.
const char * short_name
A short name for this register set.
lldb::LanguageType AsLanguageType() const
Definition Language.cpp:614
SourceLanguage(std::optional< std::pair< uint16_t, uint32_t > > name_vers)
SourceLanguage(uint16_t name, uint32_t version)
llvm::StringRef GetDescription() const
Definition Language.cpp:621