LLDB mainline
CTFTypes.h
Go to the documentation of this file.
1//===-- CTFTypes.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_SOURCE_PLUGINS_SYMBOLFILE_CTF_CTFTYPES_H
10#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_CTF_CTFTYPES_H
11
12#include "lldb/lldb-types.h"
13#include "llvm/ADT/StringRef.h"
14
15namespace lldb_private {
16
17struct CTFType {
18 enum Kind : uint32_t {
21 eFloat = 2,
23 eArray = 4,
26 eUnion = 7,
27 eEnum = 8,
31 eConst = 12,
33 eSlice = 14,
34 };
35
38 llvm::StringRef name;
39
41 : kind(kind), uid(uid), name(name) {}
42};
43
44struct CTFInteger : public CTFType {
45 CTFInteger(lldb::user_id_t uid, llvm::StringRef name, uint32_t bits,
46 uint32_t encoding)
48
49 static bool classof(const CTFType *T) { return T->kind == eInteger; }
50
51 uint32_t bits;
52 uint32_t encoding;
53};
54
55struct CTFModifier : public CTFType {
56protected:
58 : CTFType(kind, uid, ""), type(type) {}
59
60 static bool classof(const CTFType *T) {
61 return T->kind == ePointer || T->kind == eConst || T->kind == eVolatile ||
62 T->kind == eRestrict;
63 }
64
65public:
66 uint32_t type;
67};
68
69struct CTFPointer : public CTFModifier {
72
73 static bool classof(const CTFType *T) { return T->kind == ePointer; }
74};
75
76struct CTFConst : public CTFModifier {
79
80 static bool classof(const CTFType *T) { return T->kind == eConst; }
81};
82
83struct CTFVolatile : public CTFModifier {
86
87 static bool classof(const CTFType *T) { return T->kind == eVolatile; }
88};
89
90struct CTFRestrict : public CTFModifier {
93 static bool classof(const CTFType *T) { return T->kind == eRestrict; }
94};
95
96struct CTFTypedef : public CTFType {
97 CTFTypedef(lldb::user_id_t uid, llvm::StringRef name, uint32_t type)
99
100 static bool classof(const CTFType *T) { return T->kind == eTypedef; }
101
102 uint32_t type;
103};
104
105struct CTFArray : public CTFType {
106 CTFArray(lldb::user_id_t uid, llvm::StringRef name, uint32_t type,
107 uint32_t index, uint32_t nelems)
109
110 static bool classof(const CTFType *T) { return T->kind == eArray; }
111
112 uint32_t type;
113 uint32_t index;
114 uint32_t nelems;
115};
116
117struct CTFEnum : public CTFType {
118 struct Value {
119 Value(llvm::StringRef name, uint32_t value) : name(name), value(value){};
120 llvm::StringRef name;
121 uint32_t value;
122 };
123
124 CTFEnum(lldb::user_id_t uid, llvm::StringRef name, uint32_t nelems,
125 uint32_t size, std::vector<Value> values)
127 values(std::move(values)) {
128 assert(this->values.size() == nelems);
129 }
130
131 static bool classof(const CTFType *T) { return T->kind == eEnum; }
132
133 uint32_t nelems;
134 uint32_t size;
135 std::vector<Value> values;
136};
137
138struct CTFFunction : public CTFType {
139 CTFFunction(lldb::user_id_t uid, llvm::StringRef name, uint32_t nargs,
140 uint32_t return_type, std::vector<uint32_t> args, bool variadic)
142 args(std::move(args)), variadic(variadic) {}
143
144 static bool classof(const CTFType *T) { return T->kind == eFunction; }
145
146 uint32_t nargs;
147 uint32_t return_type;
148
149 std::vector<uint32_t> args;
150 bool variadic = false;
151};
152
153struct CTFRecord : public CTFType {
154public:
155 struct Field {
156 Field(llvm::StringRef name, uint32_t type, uint64_t offset)
157 : name(name), type(type), offset(offset) {}
158
159 llvm::StringRef name;
160 uint32_t type;
161 uint64_t offset;
162 };
163
165 uint32_t nfields, uint32_t size, std::vector<Field> fields)
167 fields(std::move(fields)) {}
168
169 static bool classof(const CTFType *T) {
170 return T->kind == eStruct || T->kind == eUnion;
171 }
172
173 uint32_t nfields;
174 uint32_t size;
175 std::vector<Field> fields;
176};
177
178struct CTFStruct : public CTFRecord {
179 CTFStruct(lldb::user_id_t uid, llvm::StringRef name, uint32_t nfields,
180 uint32_t size, std::vector<Field> fields)
181 : CTFRecord(eStruct, uid, name, nfields, size, std::move(fields)){};
182
183 static bool classof(const CTFType *T) { return T->kind == eStruct; }
184};
185
186struct CTFUnion : public CTFRecord {
187 CTFUnion(lldb::user_id_t uid, llvm::StringRef name, uint32_t nfields,
188 uint32_t size, std::vector<Field> fields)
189 : CTFRecord(eUnion, uid, name, nfields, size, std::move(fields)){};
190
191 static bool classof(const CTFType *T) { return T->kind == eUnion; }
192};
193
194struct CTFForward : public CTFType {
196 : CTFType(eForward, uid, name) {}
197
198 static bool classof(const CTFType *T) { return T->kind == eForward; }
199};
200
201} // namespace lldb_private
202
203#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_CTF_CTFTYPES_H
A class that represents a running process on the host machine.
uint64_t user_id_t
Definition: lldb-types.h:82
static bool classof(const CTFType *T)
Definition: CTFTypes.h:110
CTFArray(lldb::user_id_t uid, llvm::StringRef name, uint32_t type, uint32_t index, uint32_t nelems)
Definition: CTFTypes.h:106
CTFConst(lldb::user_id_t uid, uint32_t type)
Definition: CTFTypes.h:77
static bool classof(const CTFType *T)
Definition: CTFTypes.h:80
Value(llvm::StringRef name, uint32_t value)
Definition: CTFTypes.h:119
llvm::StringRef name
Definition: CTFTypes.h:120
CTFEnum(lldb::user_id_t uid, llvm::StringRef name, uint32_t nelems, uint32_t size, std::vector< Value > values)
Definition: CTFTypes.h:124
static bool classof(const CTFType *T)
Definition: CTFTypes.h:131
std::vector< Value > values
Definition: CTFTypes.h:135
static bool classof(const CTFType *T)
Definition: CTFTypes.h:198
CTFForward(lldb::user_id_t uid, llvm::StringRef name)
Definition: CTFTypes.h:195
CTFFunction(lldb::user_id_t uid, llvm::StringRef name, uint32_t nargs, uint32_t return_type, std::vector< uint32_t > args, bool variadic)
Definition: CTFTypes.h:139
std::vector< uint32_t > args
Definition: CTFTypes.h:149
static bool classof(const CTFType *T)
Definition: CTFTypes.h:144
static bool classof(const CTFType *T)
Definition: CTFTypes.h:49
CTFInteger(lldb::user_id_t uid, llvm::StringRef name, uint32_t bits, uint32_t encoding)
Definition: CTFTypes.h:45
static bool classof(const CTFType *T)
Definition: CTFTypes.h:60
CTFModifier(Kind kind, lldb::user_id_t uid, uint32_t type)
Definition: CTFTypes.h:57
CTFPointer(lldb::user_id_t uid, uint32_t type)
Definition: CTFTypes.h:70
static bool classof(const CTFType *T)
Definition: CTFTypes.h:73
Field(llvm::StringRef name, uint32_t type, uint64_t offset)
Definition: CTFTypes.h:156
static bool classof(const CTFType *T)
Definition: CTFTypes.h:169
CTFRecord(Kind kind, lldb::user_id_t uid, llvm::StringRef name, uint32_t nfields, uint32_t size, std::vector< Field > fields)
Definition: CTFTypes.h:164
std::vector< Field > fields
Definition: CTFTypes.h:175
CTFRestrict(lldb::user_id_t uid, uint32_t type)
Definition: CTFTypes.h:91
static bool classof(const CTFType *T)
Definition: CTFTypes.h:93
static bool classof(const CTFType *T)
Definition: CTFTypes.h:183
CTFStruct(lldb::user_id_t uid, llvm::StringRef name, uint32_t nfields, uint32_t size, std::vector< Field > fields)
Definition: CTFTypes.h:179
llvm::StringRef name
Definition: CTFTypes.h:38
CTFType(Kind kind, lldb::user_id_t uid, llvm::StringRef name)
Definition: CTFTypes.h:40
lldb::user_id_t uid
Definition: CTFTypes.h:37
static bool classof(const CTFType *T)
Definition: CTFTypes.h:100
CTFTypedef(lldb::user_id_t uid, llvm::StringRef name, uint32_t type)
Definition: CTFTypes.h:97
CTFUnion(lldb::user_id_t uid, llvm::StringRef name, uint32_t nfields, uint32_t size, std::vector< Field > fields)
Definition: CTFTypes.h:187
static bool classof(const CTFType *T)
Definition: CTFTypes.h:191
CTFVolatile(lldb::user_id_t uid, uint32_t type)
Definition: CTFTypes.h:84
static bool classof(const CTFType *T)
Definition: CTFTypes.h:87