LLDB mainline
SymbolFileCTF.cpp
Go to the documentation of this file.
1//===-- SymbolFileCTF.cpp ----------------------------------------------===//
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#include "SymbolFileCTF.h"
10
11#include "lldb/Core/Module.h"
13#include "lldb/Host/Config.h"
17#include "lldb/Symbol/Symbol.h"
19#include "lldb/Symbol/Symtab.h"
21#include "lldb/Symbol/TypeMap.h"
26#include "lldb/Utility/Log.h"
30#include "lldb/Utility/Timer.h"
31#include "llvm/Config/llvm-config.h" // for LLVM_ENABLE_ZLIB
32#include "llvm/Support/MemoryBuffer.h"
33
36
37#include <memory>
38#include <optional>
39
40#if LLVM_ENABLE_ZLIB
41#include <zlib.h>
42#endif
43
44using namespace llvm;
45using namespace lldb;
46using namespace lldb_private;
47
49
51
53 : SymbolFileCommon(std::move(objfile_sp)) {}
54
58}
59
62}
63
65 return "Compact C Type Format Symbol Reader";
66}
67
69 return new SymbolFileCTF(std::move(objfile_sp));
70}
71
73 if (m_header)
74 return true;
75
77
78 ModuleSP module_sp(m_objfile_sp->GetModule());
79 const SectionList *section_list = module_sp->GetSectionList();
80 if (!section_list)
81 return false;
82
83 SectionSP section_sp(
84 section_list->FindSectionByType(lldb::eSectionTypeCTF, true));
85 if (!section_sp)
86 return false;
87
88 m_objfile_sp->ReadSectionData(section_sp.get(), m_data);
89
90 if (m_data.GetByteSize() == 0)
91 return false;
92
93 StreamString module_desc;
94 GetObjectFile()->GetModule()->GetDescription(module_desc.AsRawOstream(),
96 LLDB_LOG(log, "Parsing Compact C Type format for {0}", module_desc.GetData());
97
98 lldb::offset_t offset = 0;
99
100 // Parse CTF header.
101 constexpr size_t ctf_header_size = sizeof(ctf_header_t);
102 if (!m_data.ValidOffsetForDataOfSize(offset, ctf_header_size)) {
103 LLDB_LOG(log, "CTF parsing failed: insufficient data for CTF header");
104 return false;
105 }
106
107 m_header.emplace();
108
109 ctf_header_t &ctf_header = *m_header;
110 ctf_header.preamble.magic = m_data.GetU16(&offset);
111 ctf_header.preamble.version = m_data.GetU8(&offset);
112 ctf_header.preamble.flags = m_data.GetU8(&offset);
113 ctf_header.parlabel = m_data.GetU32(&offset);
114 ctf_header.parname = m_data.GetU32(&offset);
115 ctf_header.lbloff = m_data.GetU32(&offset);
116 ctf_header.objtoff = m_data.GetU32(&offset);
117 ctf_header.funcoff = m_data.GetU32(&offset);
118 ctf_header.typeoff = m_data.GetU32(&offset);
119 ctf_header.stroff = m_data.GetU32(&offset);
120 ctf_header.strlen = m_data.GetU32(&offset);
121
122 // Validate the preamble.
123 if (ctf_header.preamble.magic != g_ctf_magic) {
124 LLDB_LOG(log, "CTF parsing failed: invalid magic: {0:x}",
125 ctf_header.preamble.magic);
126 return false;
127 }
128
129 if (ctf_header.preamble.version != g_ctf_version) {
130 LLDB_LOG(log, "CTF parsing failed: unsupported version: {0}",
131 ctf_header.preamble.version);
132 return false;
133 }
134
135 LLDB_LOG(log, "Parsed valid CTF preamble: version {0}, flags {1:x}",
136 ctf_header.preamble.version, ctf_header.preamble.flags);
137
138 m_body_offset = offset;
139
140 if (ctf_header.preamble.flags & eFlagCompress) {
141 // The body has been compressed with zlib deflate. Header offsets point into
142 // the decompressed data.
143#if LLVM_ENABLE_ZLIB
144 const std::size_t decompressed_size = ctf_header.stroff + ctf_header.strlen;
145 DataBufferSP decompressed_data =
146 std::make_shared<DataBufferHeap>(decompressed_size, 0x0);
147
148 z_stream zstr;
149 memset(&zstr, 0, sizeof(zstr));
150 zstr.next_in = (Bytef *)const_cast<uint8_t *>(m_data.GetDataStart() +
151 sizeof(ctf_header_t));
152 zstr.avail_in = m_data.BytesLeft(offset);
153 zstr.next_out =
154 (Bytef *)const_cast<uint8_t *>(decompressed_data->GetBytes());
155 zstr.avail_out = decompressed_size;
156
157 int rc = inflateInit(&zstr);
158 if (rc != Z_OK) {
159 LLDB_LOG(log, "CTF parsing failed: inflate initialization error: {0}",
160 zError(rc));
161 return false;
162 }
163
164 rc = inflate(&zstr, Z_FINISH);
165 if (rc != Z_STREAM_END) {
166 LLDB_LOG(log, "CTF parsing failed: inflate error: {0}", zError(rc));
167 return false;
168 }
169
170 rc = inflateEnd(&zstr);
171 if (rc != Z_OK) {
172 LLDB_LOG(log, "CTF parsing failed: inflate end error: {0}", zError(rc));
173 return false;
174 }
175
176 if (zstr.total_out != decompressed_size) {
177 LLDB_LOG(log,
178 "CTF parsing failed: decompressed size ({0}) doesn't match "
179 "expected size ([1})",
180 zstr.total_out, decompressed_size);
181 return false;
182 }
183
184 m_data = DataExtractor(decompressed_data, m_data.GetByteOrder(),
186 m_body_offset = 0;
187#else
188 LLDB_LOG(
189 log,
190 "CTF parsing failed: data is compressed but no zlib inflate support");
191 return false;
192#endif
193 }
194
195 // Validate the header.
196 if (!m_data.ValidOffset(m_body_offset + ctf_header.lbloff)) {
197 LLDB_LOG(log,
198 "CTF parsing failed: invalid label section offset in header: {0}",
199 ctf_header.lbloff);
200 return false;
201 }
202
203 if (!m_data.ValidOffset(m_body_offset + ctf_header.objtoff)) {
204 LLDB_LOG(log,
205 "CTF parsing failed: invalid object section offset in header: {0}",
206 ctf_header.objtoff);
207 return false;
208 }
209
210 if (!m_data.ValidOffset(m_body_offset + ctf_header.funcoff)) {
211 LLDB_LOG(
212 log,
213 "CTF parsing failed: invalid function section offset in header: {0}",
214 ctf_header.funcoff);
215 return false;
216 }
217
218 if (!m_data.ValidOffset(m_body_offset + ctf_header.typeoff)) {
219 LLDB_LOG(log,
220 "CTF parsing failed: invalid type section offset in header: {0}",
221 ctf_header.typeoff);
222 return false;
223 }
224
225 if (!m_data.ValidOffset(m_body_offset + ctf_header.stroff)) {
226 LLDB_LOG(log,
227 "CTF parsing failed: invalid string section offset in header: {0}",
228 ctf_header.stroff);
229 return false;
230 }
231
232 const lldb::offset_t str_end_offset =
233 m_body_offset + ctf_header.stroff + ctf_header.strlen;
234 if (!m_data.ValidOffset(str_end_offset - 1)) {
235 LLDB_LOG(log,
236 "CTF parsing failed: invalid string section length in header: {0}",
237 ctf_header.strlen);
238 return false;
239 }
240
241 if (m_body_offset + ctf_header.stroff + ctf_header.parlabel >
242 str_end_offset) {
243 LLDB_LOG(log,
244 "CTF parsing failed: invalid parent label offset: {0} exceeds end "
245 "of string section ({1})",
246 ctf_header.parlabel, str_end_offset);
247 return false;
248 }
249
250 if (m_body_offset + ctf_header.stroff + ctf_header.parname > str_end_offset) {
251 LLDB_LOG(log,
252 "CTF parsing failed: invalid parent name offset: {0} exceeds end "
253 "of string section ({1})",
254 ctf_header.parname, str_end_offset);
255 return false;
256 }
257
258 LLDB_LOG(log,
259 "Parsed valid CTF header: lbloff = {0}, objtoff = {1}, funcoff = "
260 "{2}, typeoff = {3}, stroff = {4}, strlen = {5}",
261 ctf_header.lbloff, ctf_header.objtoff, ctf_header.funcoff,
262 ctf_header.typeoff, ctf_header.stroff, ctf_header.strlen);
263
264 return true;
265}
266
269
270 auto type_system_or_err = GetTypeSystemForLanguage(lldb::eLanguageTypeC);
271 if (auto err = type_system_or_err.takeError()) {
272 LLDB_LOG_ERROR(log, std::move(err), "Unable to get type system: {0}");
273 return;
274 }
275
276 auto ts = *type_system_or_err;
277 m_ast = llvm::dyn_cast_or_null<TypeSystemClang>(ts.get());
278 LazyBool optimized = eLazyBoolNo;
279 m_comp_unit_sp = std::make_shared<CompileUnit>(
280 m_objfile_sp->GetModule(), nullptr, "", 0, eLanguageTypeC, optimized);
281
283}
284
285llvm::StringRef SymbolFileCTF::ReadString(lldb::offset_t str_offset) const {
286 lldb::offset_t offset = m_body_offset + m_header->stroff + str_offset;
287 if (!m_data.ValidOffset(offset))
288 return "(invalid)";
289 const char *str = m_data.GetCStr(&offset);
290 if (str && !*str)
291 return "(anon)";
292 return llvm::StringRef(str);
293}
294
295/// Return the integer display representation encoded in the given data.
296static uint32_t GetEncoding(uint32_t data) {
297 // Mask bits 24–31.
298 return ((data)&0xff000000) >> 24;
299}
300
301/// Return the integral width in bits encoded in the given data.
302static uint32_t GetBits(uint32_t data) {
303 // Mask bits 0-15.
304 return (data)&0x0000ffff;
305}
306
307/// Return the type kind encoded in the given data.
308uint32_t GetKind(uint32_t data) {
309 // Mask bits 26–31.
310 return ((data)&0xf800) >> 11;
311}
312
313/// Return the variable length encoded in the given data.
314uint32_t GetVLen(uint32_t data) {
315 // Mask bits 0–24.
316 return (data)&0x3ff;
317}
318
319static uint32_t GetBytes(uint32_t bits) { return bits / sizeof(unsigned); }
320
321static clang::TagTypeKind TranslateRecordKind(CTFType::Kind type) {
322 switch (type) {
324 return clang::TagTypeKind::Struct;
326 return clang::TagTypeKind::Union;
327 default:
328 lldbassert(false && "Invalid record kind!");
329 return clang::TagTypeKind::Struct;
330 }
331}
332
333llvm::Expected<TypeSP>
335 lldb::BasicType basic_type =
337 if (basic_type == eBasicTypeInvalid)
338 return llvm::make_error<llvm::StringError>(
339 llvm::formatv("unsupported integer type: no corresponding basic clang "
340 "type for '{0}'",
341 ctf_integer.name),
342 llvm::inconvertibleErrorCode());
343
344 CompilerType compiler_type = m_ast->GetBasicType(basic_type);
345
346 if (basic_type != eBasicTypeVoid && basic_type != eBasicTypeBool) {
347 // Make sure the type we got is an integer type.
348 bool compiler_type_is_signed = false;
349 if (!compiler_type.IsIntegerType(compiler_type_is_signed))
350 return llvm::make_error<llvm::StringError>(
351 llvm::formatv(
352 "Found compiler type for '{0}' but it's not an integer type: {1}",
353 ctf_integer.name,
354 compiler_type.GetDisplayTypeName().GetStringRef()),
355 llvm::inconvertibleErrorCode());
356
357 // Make sure the signing matches between the CTF and the compiler type.
358 const bool type_is_signed = (ctf_integer.encoding & IntEncoding::eSigned);
359 if (compiler_type_is_signed != type_is_signed)
360 return llvm::make_error<llvm::StringError>(
361 llvm::formatv("Found integer compiler type for {0} but compiler type "
362 "is {1} and {0} is {2}",
363 ctf_integer.name,
364 compiler_type_is_signed ? "signed" : "unsigned",
365 type_is_signed ? "signed" : "unsigned"),
366 llvm::inconvertibleErrorCode());
367 }
368
369 Declaration decl;
370 return MakeType(ctf_integer.uid, ConstString(ctf_integer.name),
371 GetBytes(ctf_integer.bits), nullptr, LLDB_INVALID_UID,
372 lldb_private::Type::eEncodingIsUID, decl, compiler_type,
374}
375
376llvm::Expected<lldb::TypeSP>
378 Type *ref_type = ResolveTypeUID(ctf_modifier.type);
379 if (!ref_type)
380 return llvm::make_error<llvm::StringError>(
381 llvm::formatv("Could not find modified type: {0}", ctf_modifier.type),
382 llvm::inconvertibleErrorCode());
383
384 CompilerType compiler_type;
385
386 switch (ctf_modifier.kind) {
388 compiler_type = ref_type->GetFullCompilerType().GetPointerType();
389 break;
390 case CTFType::eConst:
391 compiler_type = ref_type->GetFullCompilerType().AddConstModifier();
392 break;
394 compiler_type = ref_type->GetFullCompilerType().AddVolatileModifier();
395 break;
397 compiler_type = ref_type->GetFullCompilerType().AddRestrictModifier();
398 break;
399 default:
400 return llvm::make_error<llvm::StringError>(
401 llvm::formatv("ParseModifier called with unsupported kind: {0}",
402 ctf_modifier.kind),
403 llvm::inconvertibleErrorCode());
404 }
405
406 Declaration decl;
407 return MakeType(ctf_modifier.uid, ConstString(), 0, nullptr, LLDB_INVALID_UID,
408 Type::eEncodingIsUID, decl, compiler_type,
410}
411
412llvm::Expected<lldb::TypeSP>
414 Type *underlying_type = ResolveTypeUID(ctf_typedef.type);
415 if (!underlying_type)
416 return llvm::make_error<llvm::StringError>(
417 llvm::formatv("Could not find typedef underlying type: {0}",
418 ctf_typedef.type),
419 llvm::inconvertibleErrorCode());
420
421 CompilerType target_ast_type = underlying_type->GetFullCompilerType();
422 clang::DeclContext *decl_ctx = m_ast->GetTranslationUnitDecl();
423 CompilerType ast_typedef = target_ast_type.CreateTypedef(
424 ctf_typedef.name.data(), m_ast->CreateDeclContext(decl_ctx), 0);
425
426 Declaration decl;
427 return MakeType(ctf_typedef.uid, ConstString(ctf_typedef.name), 0, nullptr,
430}
431
432llvm::Expected<lldb::TypeSP>
434 Type *element_type = ResolveTypeUID(ctf_array.type);
435 if (!element_type)
436 return llvm::make_error<llvm::StringError>(
437 llvm::formatv("Could not find array element type: {0}", ctf_array.type),
438 llvm::inconvertibleErrorCode());
439
440 std::optional<uint64_t> element_size = element_type->GetByteSize(nullptr);
441 if (!element_size)
442 return llvm::make_error<llvm::StringError>(
443 llvm::formatv("could not get element size of type: {0}",
444 ctf_array.type),
445 llvm::inconvertibleErrorCode());
446
447 uint64_t size = ctf_array.nelems * *element_size;
448
449 CompilerType compiler_type = m_ast->CreateArrayType(
450 element_type->GetFullCompilerType(), ctf_array.nelems,
451 /*is_gnu_vector*/ false);
452
453 Declaration decl;
454 return MakeType(ctf_array.uid, ConstString(), size, nullptr, LLDB_INVALID_UID,
455 Type::eEncodingIsUID, decl, compiler_type,
457}
458
459llvm::Expected<lldb::TypeSP>
461 Declaration decl;
465 /*is_scoped=*/false);
466
467 for (const CTFEnum::Value &value : ctf_enum.values) {
468 Declaration value_decl;
470 enum_type, value_decl, value.name.data(), value.value, ctf_enum.size);
471 }
473
474 return MakeType(ctf_enum.uid, ConstString(), 0, nullptr, LLDB_INVALID_UID,
475 Type::eEncodingIsUID, decl, enum_type,
477}
478
479llvm::Expected<lldb::TypeSP>
481 std::vector<CompilerType> arg_types;
482 for (uint32_t arg : ctf_function.args) {
483 if (Type *arg_type = ResolveTypeUID(arg))
484 arg_types.push_back(arg_type->GetFullCompilerType());
485 }
486
487 Type *ret_type = ResolveTypeUID(ctf_function.return_type);
488 if (!ret_type)
489 return llvm::make_error<llvm::StringError>(
490 llvm::formatv("Could not find function return type: {0}",
491 ctf_function.return_type),
492 llvm::inconvertibleErrorCode());
493
495 ret_type->GetFullCompilerType(), arg_types.data(), arg_types.size(),
496 ctf_function.variadic, 0, clang::CallingConv::CC_C);
497
498 Declaration decl;
499 return MakeType(ctf_function.uid, ConstString(ctf_function.name), 0, nullptr,
500 LLDB_INVALID_UID, Type::eEncodingIsUID, decl, func_type,
502}
503
504llvm::Expected<lldb::TypeSP>
506 const clang::TagTypeKind tag_kind = TranslateRecordKind(ctf_record.kind);
507 CompilerType record_type = m_ast->CreateRecordType(
508 nullptr, OptionalClangModuleID(), eAccessPublic, ctf_record.name.data(),
509 llvm::to_underlying(tag_kind), eLanguageTypeC);
510 m_compiler_types[record_type.GetOpaqueQualType()] = &ctf_record;
511 Declaration decl;
512 return MakeType(ctf_record.uid, ConstString(ctf_record.name), ctf_record.size,
515}
516
518 // Check if we have a CTF type for the given incomplete compiler type.
519 auto it = m_compiler_types.find(compiler_type.GetOpaqueQualType());
520 if (it == m_compiler_types.end())
521 return false;
522
523 const CTFType *ctf_type = it->second;
524 assert(ctf_type && "m_compiler_types should only contain valid CTF types");
525
526 // We only support resolving record types.
527 assert(llvm::isa<CTFRecord>(ctf_type));
528
529 // Cast to the appropriate CTF type.
530 const CTFRecord *ctf_record = static_cast<const CTFRecord *>(ctf_type);
531
532 // If any of the fields are incomplete, we cannot complete the type.
533 for (const CTFRecord::Field &field : ctf_record->fields) {
534 if (!ResolveTypeUID(field.type)) {
536 "Cannot complete type {0} because field {1} is incomplete",
537 ctf_type->uid, field.type);
538 return false;
539 }
540 }
541
542 // Complete the record type.
543 m_ast->StartTagDeclarationDefinition(compiler_type);
544 for (const CTFRecord::Field &field : ctf_record->fields) {
545 Type *field_type = ResolveTypeUID(field.type);
546 assert(field_type && "field must be complete");
547 const uint32_t field_size = field_type->GetByteSize(nullptr).value_or(0);
548 TypeSystemClang::AddFieldToRecordType(compiler_type, field.name,
549 field_type->GetFullCompilerType(),
550 eAccessPublic, field_size);
551 }
553
554 // Now that the compiler type is complete, we don't need to remember it
555 // anymore and can remove the CTF record type.
556 m_compiler_types.erase(compiler_type.GetOpaqueQualType());
557 m_ctf_types.erase(ctf_type->uid);
558
559 return true;
560}
561
562llvm::Expected<lldb::TypeSP>
564 CompilerType forward_compiler_type = m_ast->CreateRecordType(
565 nullptr, OptionalClangModuleID(), eAccessPublic, ctf_forward.name,
566 llvm::to_underlying(clang::TagTypeKind::Struct), eLanguageTypeC);
567 Declaration decl;
568 return MakeType(ctf_forward.uid, ConstString(ctf_forward.name), 0, nullptr,
570 forward_compiler_type, Type::ResolveState::Forward);
571}
572
573llvm::Expected<TypeSP> SymbolFileCTF::CreateType(CTFType *ctf_type) {
574 if (!ctf_type)
575 return llvm::make_error<llvm::StringError>(
576 "cannot create type for unparsed type", llvm::inconvertibleErrorCode());
577
578 switch (ctf_type->kind) {
580 return CreateInteger(*static_cast<CTFInteger *>(ctf_type));
585 return CreateModifier(*static_cast<CTFModifier *>(ctf_type));
587 return CreateTypedef(*static_cast<CTFTypedef *>(ctf_type));
589 return CreateArray(*static_cast<CTFArray *>(ctf_type));
591 return CreateEnum(*static_cast<CTFEnum *>(ctf_type));
593 return CreateFunction(*static_cast<CTFFunction *>(ctf_type));
596 return CreateRecord(*static_cast<CTFRecord *>(ctf_type));
598 return CreateForward(*static_cast<CTFForward *>(ctf_type));
602 return llvm::make_error<llvm::StringError>(
603 llvm::formatv("unsupported type (uid = {0}, name = {1}, kind = {2})",
604 ctf_type->uid, ctf_type->name, ctf_type->kind),
605 llvm::inconvertibleErrorCode());
606 }
607 llvm_unreachable("Unexpected CTF type kind");
608}
609
610llvm::Expected<std::unique_ptr<CTFType>>
612 ctf_stype_t ctf_stype;
613 ctf_stype.name = m_data.GetU32(&offset);
614 ctf_stype.info = m_data.GetU32(&offset);
615 ctf_stype.size = m_data.GetU32(&offset);
616
617 llvm::StringRef name = ReadString(ctf_stype.name);
618 const uint32_t kind = GetKind(ctf_stype.info);
619 const uint32_t variable_length = GetVLen(ctf_stype.info);
620 const uint32_t type = ctf_stype.GetType();
621 const uint32_t size = ctf_stype.GetSize();
622
623 switch (kind) {
624 case TypeKind::eInteger: {
625 const uint32_t vdata = m_data.GetU32(&offset);
626 const uint32_t bits = GetBits(vdata);
627 const uint32_t encoding = GetEncoding(vdata);
628 return std::make_unique<CTFInteger>(uid, name, bits, encoding);
629 }
630 case TypeKind::eConst:
631 return std::make_unique<CTFConst>(uid, type);
633 return std::make_unique<CTFPointer>(uid, type);
635 return std::make_unique<CTFRestrict>(uid, type);
637 return std::make_unique<CTFVolatile>(uid, type);
639 return std::make_unique<CTFTypedef>(uid, name, type);
640 case TypeKind::eArray: {
641 const uint32_t type = m_data.GetU32(&offset);
642 const uint32_t index = m_data.GetU32(&offset);
643 const uint32_t nelems = m_data.GetU32(&offset);
644 return std::make_unique<CTFArray>(uid, name, type, index, nelems);
645 }
646 case TypeKind::eEnum: {
647 std::vector<CTFEnum::Value> values;
648 for (uint32_t i = 0; i < variable_length; ++i) {
649 const uint32_t value_name = m_data.GetU32(&offset);
650 const uint32_t value = m_data.GetU32(&offset);
651 values.emplace_back(ReadString(value_name), value);
652 }
653 return std::make_unique<CTFEnum>(uid, name, variable_length, size, values);
654 }
655 case TypeKind::eFunction: {
656 std::vector<uint32_t> args;
657 bool variadic = false;
658 for (uint32_t i = 0; i < variable_length; ++i) {
659 const uint32_t arg_uid = m_data.GetU32(&offset);
660 // If the last argument is 0, this is a variadic function.
661 if (arg_uid == 0) {
662 variadic = true;
663 break;
664 }
665 args.push_back(arg_uid);
666 }
667 // If the number of arguments is odd, a single uint32_t of padding is
668 // inserted to maintain alignment.
669 if (variable_length % 2 == 1)
670 m_data.GetU32(&offset);
671 return std::make_unique<CTFFunction>(uid, name, variable_length, type, args,
672 variadic);
673 }
675 case TypeKind::eUnion: {
676 std::vector<CTFRecord::Field> fields;
677 for (uint32_t i = 0; i < variable_length; ++i) {
678 const uint32_t field_name = m_data.GetU32(&offset);
679 const uint32_t type = m_data.GetU32(&offset);
680 uint64_t field_offset = 0;
681 if (size < g_ctf_field_threshold) {
682 field_offset = m_data.GetU16(&offset);
683 m_data.GetU16(&offset); // Padding
684 } else {
685 const uint32_t offset_hi = m_data.GetU32(&offset);
686 const uint32_t offset_lo = m_data.GetU32(&offset);
687 field_offset = (((uint64_t)offset_hi) << 32) | ((uint64_t)offset_lo);
688 }
689 fields.emplace_back(ReadString(field_name), type, field_offset);
690 }
691 return std::make_unique<CTFRecord>(static_cast<CTFType::Kind>(kind), uid,
692 name, variable_length, size, fields);
693 }
695 return std::make_unique<CTFForward>(uid, name);
697 return std::make_unique<CTFType>(static_cast<CTFType::Kind>(kind), uid,
698 name);
699 case TypeKind::eFloat:
700 case TypeKind::eSlice:
701 offset += (variable_length * sizeof(uint32_t));
702 break;
703 }
704
705 return llvm::make_error<llvm::StringError>(
706 llvm::formatv("unsupported type (name = {0}, kind = {1}, vlength = {2})",
707 name, kind, variable_length),
708 llvm::inconvertibleErrorCode());
709}
710
712 if (!ParseHeader())
713 return 0;
714
715 if (!m_types.empty())
716 return 0;
717
718 if (!m_ast)
719 return 0;
720
722 LLDB_LOG(log, "Parsing CTF types");
723
724 lldb::offset_t type_offset = m_body_offset + m_header->typeoff;
725 const lldb::offset_t type_offset_end = m_body_offset + m_header->stroff;
726
727 lldb::user_id_t type_uid = 1;
728 while (type_offset < type_offset_end) {
729 llvm::Expected<std::unique_ptr<CTFType>> type_or_error =
730 ParseType(type_offset, type_uid);
731 if (type_or_error) {
732 m_ctf_types[(*type_or_error)->uid] = std::move(*type_or_error);
733 } else {
734 LLDB_LOG_ERROR(log, type_or_error.takeError(),
735 "Failed to parse type {1} at offset {2}: {0}", type_uid,
736 type_offset);
737 }
738 type_uid++;
739 }
740
741 LLDB_LOG(log, "Parsed {0} CTF types", m_ctf_types.size());
742
743 for (lldb::user_id_t uid = 1; uid < type_uid; ++uid)
744 ResolveTypeUID(uid);
745
746 LLDB_LOG(log, "Created {0} CTF types", m_types.size());
747
748 return m_types.size();
749}
750
752 if (!ParseHeader())
753 return 0;
754
755 if (!m_functions.empty())
756 return 0;
757
758 if (!m_ast)
759 return 0;
760
761 Symtab *symtab = GetObjectFile()->GetModule()->GetSymtab();
762 if (!symtab)
763 return 0;
764
766 LLDB_LOG(log, "Parsing CTF functions");
767
768 lldb::offset_t function_offset = m_body_offset + m_header->funcoff;
769 const lldb::offset_t function_offset_end = m_body_offset + m_header->typeoff;
770
771 uint32_t symbol_idx = 0;
772 Declaration decl;
773 while (function_offset < function_offset_end) {
774 const uint32_t info = m_data.GetU32(&function_offset);
775 const uint16_t kind = GetKind(info);
776 const uint16_t variable_length = GetVLen(info);
777
778 Symbol *symbol = symtab->FindSymbolWithType(
780
781 // Skip padding.
782 if (kind == TypeKind::eUnknown && variable_length == 0)
783 continue;
784
785 // Skip unexpected kinds.
786 if (kind != TypeKind::eFunction)
787 continue;
788
789 const uint32_t ret_uid = m_data.GetU32(&function_offset);
790 const uint32_t num_args = variable_length;
791
792 std::vector<CompilerType> arg_types;
793 arg_types.reserve(num_args);
794
795 bool is_variadic = false;
796 for (uint32_t i = 0; i < variable_length; i++) {
797 const uint32_t arg_uid = m_data.GetU32(&function_offset);
798
799 // If the last argument is 0, this is a variadic function.
800 if (arg_uid == 0) {
801 is_variadic = true;
802 break;
803 }
804
805 Type *arg_type = ResolveTypeUID(arg_uid);
806 arg_types.push_back(arg_type ? arg_type->GetFullCompilerType()
807 : CompilerType());
808 }
809
810 if (symbol) {
811 Type *ret_type = ResolveTypeUID(ret_uid);
812 AddressRange func_range =
813 AddressRange(symbol->GetFileAddress(), symbol->GetByteSize(),
814 GetObjectFile()->GetModule()->GetSectionList());
815
816 // Create function type.
818 ret_type ? ret_type->GetFullCompilerType() : CompilerType(),
819 arg_types.data(), arg_types.size(), is_variadic, 0,
820 clang::CallingConv::CC_C);
821 lldb::user_id_t function_type_uid = m_types.size() + 1;
822 TypeSP type_sp =
823 MakeType(function_type_uid, symbol->GetName(), 0, nullptr,
824 LLDB_INVALID_UID, Type::eEncodingIsUID, decl, func_type,
826 m_types[function_type_uid] = type_sp;
827
828 // Create function.
829 lldb::user_id_t func_uid = m_functions.size();
830 FunctionSP function_sp = std::make_shared<Function>(
831 &cu, func_uid, function_type_uid, symbol->GetMangled(), type_sp.get(),
832 AddressRanges{func_range});
833 m_functions.emplace_back(function_sp);
834 cu.AddFunction(function_sp);
835 }
836 }
837
838 LLDB_LOG(log, "CTF parsed {0} functions", m_functions.size());
839
840 return m_functions.size();
841}
842
844 const Symbol &symbol) {
845 if (!module_sp)
846 return DWARFExpression();
847
848 const ArchSpec &architecture = module_sp->GetArchitecture();
849 ByteOrder byte_order = architecture.GetByteOrder();
850 uint32_t address_size = architecture.GetAddressByteSize();
851 uint32_t byte_size = architecture.GetDataByteSize();
852
853 StreamBuffer<32> stream(Stream::eBinary, address_size, byte_order);
854 stream.PutHex8(lldb_private::dwarf::DW_OP_addr);
855 stream.PutMaxHex64(symbol.GetFileAddress(), address_size, byte_order);
856
857 DataBufferSP buffer =
858 std::make_shared<DataBufferHeap>(stream.GetData(), stream.GetSize());
859 lldb_private::DataExtractor extractor(buffer, byte_order, address_size,
860 byte_size);
861 DWARFExpression result(extractor);
863
864 return result;
865}
866
868 if (!ParseHeader())
869 return 0;
870
871 if (!m_variables.empty())
872 return 0;
873
874 if (!m_ast)
875 return 0;
876
877 ModuleSP module_sp = GetObjectFile()->GetModule();
878 Symtab *symtab = module_sp->GetSymtab();
879 if (!symtab)
880 return 0;
881
883 LLDB_LOG(log, "Parsing CTF objects");
884
885 lldb::offset_t object_offset = m_body_offset + m_header->objtoff;
886 const lldb::offset_t object_offset_end = m_body_offset + m_header->funcoff;
887
888 uint32_t symbol_idx = 0;
889 Declaration decl;
890 while (object_offset < object_offset_end) {
891 const uint32_t type_uid = m_data.GetU32(&object_offset);
892
893 if (Symbol *symbol =
895 Symtab::eVisibilityAny, symbol_idx)) {
896 Variable::RangeList ranges;
897 ranges.Append(symbol->GetFileAddress(), symbol->GetByteSize());
898
899 auto type_sp = std::make_shared<SymbolFileType>(*this, type_uid);
900
901 DWARFExpressionList location(
902 module_sp, CreateDWARFExpression(module_sp, *symbol), nullptr);
903
904 lldb::user_id_t variable_type_uid = m_variables.size();
905 m_variables.emplace_back(std::make_shared<Variable>(
906 variable_type_uid, symbol->GetName().AsCString(),
907 symbol->GetName().AsCString(), type_sp, eValueTypeVariableGlobal,
908 m_comp_unit_sp.get(), ranges, &decl, location, symbol->IsExternal(),
909 /*artificial=*/false,
910 /*location_is_constant_data*/ false));
911 }
912 }
913
914 LLDB_LOG(log, "Parsed {0} CTF objects", m_variables.size());
915
916 return m_variables.size();
917}
918
920 if (!m_objfile_sp)
921 return 0;
922
923 if (!ParseHeader())
924 return 0;
925
927}
928
930 SymbolContextItem resolve_scope,
931 SymbolContext &sc) {
932 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
933 if (m_objfile_sp->GetSymtab() == nullptr)
934 return 0;
935
936 uint32_t resolved_flags = 0;
937
938 // Resolve symbols.
939 if (resolve_scope & eSymbolContextSymbol) {
940 sc.symbol = m_objfile_sp->GetSymtab()->FindSymbolContainingFileAddress(
941 so_addr.GetFileAddress());
942 if (sc.symbol)
943 resolved_flags |= eSymbolContextSymbol;
944 }
945
946 // Resolve functions.
947 if (resolve_scope & eSymbolContextFunction) {
948 for (FunctionSP function_sp : m_functions) {
949 if (function_sp->GetAddressRange().ContainsFileAddress(
950 so_addr.GetFileAddress())) {
951 sc.function = function_sp.get();
952 resolved_flags |= eSymbolContextFunction;
953 break;
954 }
955 }
956 }
957
958 // Resolve variables.
959 if (resolve_scope & eSymbolContextVariable) {
960 for (VariableSP variable_sp : m_variables) {
961 if (variable_sp->LocationIsValidForAddress(so_addr.GetFileAddress())) {
962 sc.variable = variable_sp.get();
963 break;
964 }
965 }
966 }
967
968 return resolved_flags;
969}
970
972 if (idx == 0)
973 return m_comp_unit_sp;
974 return {};
975}
976
977size_t
980}
981
983 // CTF does not encode symbols.
984 // We rely on the existing symbol table to map symbols to type.
985}
986
988 auto type_it = m_types.find(type_uid);
989 if (type_it != m_types.end())
990 return type_it->second.get();
991
992 auto ctf_type_it = m_ctf_types.find(type_uid);
993 if (ctf_type_it == m_ctf_types.end())
994 return nullptr;
995
996 CTFType *ctf_type = ctf_type_it->second.get();
997 assert(ctf_type && "m_ctf_types should only contain valid CTF types");
998
1000
1001 llvm::Expected<TypeSP> type_or_error = CreateType(ctf_type);
1002 if (!type_or_error) {
1003 LLDB_LOG_ERROR(log, type_or_error.takeError(),
1004 "Failed to create type for {1}: {0}", ctf_type->uid);
1005 return {};
1006 }
1007
1008 TypeSP type_sp = *type_or_error;
1009
1010 if (log) {
1011 StreamString ss;
1012 type_sp->Dump(&ss, true);
1013 LLDB_LOGV(log, "Adding type {0}: {1}", type_sp->GetID(),
1014 llvm::StringRef(ss.GetString()).rtrim());
1015 }
1016
1017 m_types[type_uid] = type_sp;
1018
1019 // Except for record types which we'll need to complete later, we don't need
1020 // the CTF type anymore.
1021 if (!isa<CTFRecord>(ctf_type))
1022 m_ctf_types.erase(type_uid);
1023
1024 return type_sp.get();
1025}
1026
1028 lldb_private::TypeResults &results) {
1029 // Make sure we haven't already searched this SymbolFile before.
1030 if (results.AlreadySearched(this))
1031 return;
1032
1033 ConstString name = match.GetTypeBasename();
1034 for (TypeSP type_sp : GetTypeList().Types()) {
1035 if (type_sp && type_sp->GetName() == name) {
1036 results.InsertUnique(type_sp);
1037 if (results.Done(match))
1038 return;
1039 }
1040 }
1041}
1042
1044 const lldb_private::RegularExpression &regex, uint32_t max_matches,
1045 lldb_private::TypeMap &types) {
1047
1048 size_t matches = 0;
1049 for (TypeSP type_sp : GetTypeList().Types()) {
1050 if (matches == max_matches)
1051 break;
1052 if (type_sp && regex.Execute(type_sp->GetName()))
1053 types.Insert(type_sp);
1054 matches++;
1055 }
1056}
1057
1059 const lldb_private::Module::LookupInfo &lookup_info,
1060 const lldb_private::CompilerDeclContext &parent_decl_ctx,
1061 bool include_inlines, lldb_private::SymbolContextList &sc_list) {
1063
1064 ConstString name = lookup_info.GetLookupName();
1065 for (FunctionSP function_sp : m_functions) {
1066 if (function_sp && function_sp->GetName() == name) {
1068 sc.comp_unit = m_comp_unit_sp.get();
1069 sc.function = function_sp.get();
1070 sc_list.Append(sc);
1071 }
1072 }
1073}
1074
1076 bool include_inlines,
1078 for (FunctionSP function_sp : m_functions) {
1079 if (function_sp && regex.Execute(function_sp->GetName())) {
1081 sc.comp_unit = m_comp_unit_sp.get();
1082 sc.function = function_sp.get();
1083 sc_list.Append(sc);
1084 }
1085 }
1086}
1087
1090 const lldb_private::CompilerDeclContext &parent_decl_ctx,
1091 uint32_t max_matches, lldb_private::VariableList &variables) {
1093
1094 size_t matches = 0;
1095 for (VariableSP variable_sp : m_variables) {
1096 if (matches == max_matches)
1097 break;
1098 if (variable_sp && variable_sp->GetName() == name) {
1099 variables.AddVariable(variable_sp);
1100 matches++;
1101 }
1102 }
1103}
1104
1106 const lldb_private::RegularExpression &regex, uint32_t max_matches,
1107 lldb_private::VariableList &variables) {
1109
1110 size_t matches = 0;
1111 for (VariableSP variable_sp : m_variables) {
1112 if (matches == max_matches)
1113 break;
1114 if (variable_sp && regex.Execute(variable_sp->GetName())) {
1115 variables.AddVariable(variable_sp);
1116 matches++;
1117 }
1118 }
1119}
#define lldbassert(x)
Definition: LLDBAssert.h:15
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition: Log.h:369
#define LLDB_LOG_ERROR(log, error,...)
Definition: Log.h:392
#define LLDB_LOGV(log,...)
Definition: Log.h:383
#define LLDB_PLUGIN_DEFINE(PluginName)
Definition: PluginManager.h:32
uint32_t GetKind(uint32_t data)
Return the type kind encoded in the given data.
static DWARFExpression CreateDWARFExpression(ModuleSP module_sp, const Symbol &symbol)
uint32_t GetVLen(uint32_t data)
Return the variable length encoded in the given data.
static clang::TagTypeKind TranslateRecordKind(CTFType::Kind type)
static uint32_t GetEncoding(uint32_t data)
Return the integer display representation encoded in the given data.
static uint32_t GetBits(uint32_t data)
Return the integral width in bits encoded in the given data.
static uint32_t GetBytes(uint32_t bits)
A section + offset based address range class.
Definition: AddressRange.h:25
A section + offset based address class.
Definition: Address.h:62
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:293
An architecture specification class.
Definition: ArchSpec.h:31
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
Definition: ArchSpec.cpp:709
uint32_t GetDataByteSize() const
Architecture data byte width accessor.
Definition: ArchSpec.cpp:693
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
Definition: ArchSpec.cpp:756
A class that describes a compilation unit.
Definition: CompileUnit.h:43
void AddFunction(lldb::FunctionSP &function_sp)
Add a function to this compile unit.
Represents a generic declaration context in a program.
Generic representation of a type in a programming language.
Definition: CompilerType.h:36
CompilerType AddConstModifier() const
Return a new CompilerType adds a const modifier to this type if this type is valid and the type syste...
ConstString GetDisplayTypeName() const
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
lldb::opaque_compiler_type_t GetOpaqueQualType() const
Definition: CompilerType.h:289
CompilerType AddVolatileModifier() const
Return a new CompilerType adds a volatile modifier to this type if this type is valid and the type sy...
CompilerType AddRestrictModifier() const
Return a new CompilerType adds a restrict modifier to this type if this type is valid and the type sy...
bool IsIntegerType(bool &is_signed) const
CompilerType CreateTypedef(const char *name, const CompilerDeclContext &decl_ctx, uint32_t payload) const
Create a typedef to this type using "name" as the name of the typedef this type is valid and the type...
A uniqued constant string class.
Definition: ConstString.h:40
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
Definition: ConstString.h:197
"lldb/Expression/DWARFExpressionList.h" Encapsulates a range map from file address range to a single ...
"lldb/Expression/DWARFExpression.h" Encapsulates a DWARF location expression and interprets it.
void SetRegisterKind(lldb::RegisterKind reg_kind)
Set the call-frame-info style register kind.
An data extractor class.
Definition: DataExtractor.h:48
const char * GetCStr(lldb::offset_t *offset_ptr) const
Extract a C string from *offset_ptr.
bool ValidOffsetForDataOfSize(lldb::offset_t offset, lldb::offset_t length) const
Test the availability of length bytes of data from offset.
uint32_t GetU32(lldb::offset_t *offset_ptr) const
Extract a uint32_t value from *offset_ptr.
uint64_t GetByteSize() const
Get the number of bytes contained in this object.
uint16_t GetU16(lldb::offset_t *offset_ptr) const
Extract a uint16_t value from *offset_ptr.
const uint8_t * GetDataStart() const
Get the data start pointer.
bool ValidOffset(lldb::offset_t offset) const
Test the validity of offset.
uint32_t GetAddressByteSize() const
Get the current address size.
lldb::offset_t BytesLeft(lldb::offset_t offset) const
lldb::ByteOrder GetByteOrder() const
Get the current byte order value.
uint8_t GetU8(lldb::offset_t *offset_ptr) const
Extract a uint8_t value from *offset_ptr.
A class that describes the declaration location of a lldb object.
Definition: Declaration.h:24
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
Definition: ModuleChild.cpp:24
A class that encapsulates name lookup information.
Definition: Module.h:907
ConstString GetLookupName() const
Definition: Module.h:918
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
void Append(const Entry &entry)
Definition: RangeMap.h:179
bool Execute(llvm::StringRef string, llvm::SmallVectorImpl< llvm::StringRef > *matches=nullptr) const
Execute a regular expression match using the compiled regular expression that is already in this obje...
lldb::SectionSP FindSectionByType(lldb::SectionType sect_type, bool check_children, size_t start_idx=0) const
Definition: Section.cpp:598
const char * GetData() const
Definition: StreamBuffer.h:38
const char * GetData() const
Definition: StreamString.h:45
llvm::StringRef GetString() const
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
Definition: Stream.h:401
@ eBinary
Get and put data as binary instead of as the default string mode.
Definition: Stream.h:32
size_t size_t PutHex8(uint8_t uvalue)
Append an uint8_t value in the hexadecimal format to the stream.
Definition: Stream.cpp:261
size_t PutMaxHex64(uint64_t uvalue, size_t byte_size, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
Definition: Stream.cpp:315
Defines a list of symbol context objects.
void Append(const SymbolContext &sc)
Append a new symbol context to the list.
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:34
Function * function
The Function for a given query.
CompileUnit * comp_unit
The CompileUnit for a given query.
Variable * variable
The global variable matching the given query.
Symbol * symbol
The Symbol for a given query.
void FindTypesByRegex(const lldb_private::RegularExpression &regex, uint32_t max_matches, lldb_private::TypeMap &types)
Type * ResolveTypeUID(lldb::user_id_t type_uid) override
static constexpr uint16_t g_ctf_magic
llvm::Expected< lldb::TypeSP > CreateFunction(const CTFFunction &ctf_function)
void AddSymbols(Symtab &symtab) override
bool CompleteType(CompilerType &compiler_type) override
lldb::CompUnitSP m_comp_unit_sp
std::vector< lldb::FunctionSP > m_functions
static char ID
LLVM RTTI support.
Definition: SymbolFileCTF.h:24
llvm::Expected< lldb::TypeSP > CreateTypedef(const CTFTypedef &ctf_typedef)
size_t ParseFunctions(CompileUnit &comp_unit) override
static llvm::StringRef GetPluginDescriptionStatic()
llvm::DenseMap< lldb::opaque_compiler_type_t, const CTFType * > m_compiler_types
To complete types, we need a way to map (imcomplete) compiler types back to parsed CTF types.
void FindFunctions(const lldb_private::Module::LookupInfo &lookup_info, const lldb_private::CompilerDeclContext &parent_decl_ctx, bool include_inlines, lldb_private::SymbolContextList &sc_list) override
llvm::Expected< lldb::TypeSP > CreateArray(const CTFArray &ctf_array)
uint32_t CalculateAbilities() override
size_t ParseVariablesForContext(const SymbolContext &sc) override
static lldb_private::SymbolFile * CreateInstance(lldb::ObjectFileSP objfile_sp)
lldb::offset_t m_body_offset
The start offset of the CTF body into m_data.
static constexpr uint16_t g_ctf_field_threshold
lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override
static llvm::StringRef GetPluginNameStatic()
Definition: SymbolFileCTF.h:41
size_t ParseObjects(CompileUnit &comp_unit)
llvm::Expected< lldb::TypeSP > CreateForward(const CTFForward &ctf_forward)
llvm::Expected< lldb::TypeSP > CreateEnum(const CTFEnum &ctf_enum)
void InitializeObject() override
Initialize the SymbolFile object.
void FindTypes(const lldb_private::TypeQuery &match, lldb_private::TypeResults &results) override
Find types using a type-matching object that contains all search parameters.
llvm::StringRef ReadString(lldb::offset_t offset) const
llvm::Expected< lldb::TypeSP > CreateRecord(const CTFRecord &ctf_record)
void FindGlobalVariables(lldb_private::ConstString name, const lldb_private::CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, lldb_private::VariableList &variables) override
llvm::Expected< lldb::TypeSP > CreateInteger(const CTFInteger &ctf_integer)
static constexpr uint8_t g_ctf_version
llvm::DenseMap< lldb::user_id_t, lldb::TypeSP > m_types
Parsed LLDB types.
std::vector< lldb::VariableSP > m_variables
llvm::DenseMap< lldb::user_id_t, std::unique_ptr< CTFType > > m_ctf_types
Parsed CTF types.
llvm::Expected< lldb::TypeSP > CreateModifier(const CTFModifier &ctf_modifier)
llvm::Expected< lldb::TypeSP > CreateType(CTFType *ctf_type)
SymbolFileCTF(lldb::ObjectFileSP objfile_sp)
uint32_t ResolveSymbolContext(const lldb_private::Address &so_addr, lldb::SymbolContextItem resolve_scope, lldb_private::SymbolContext &sc) override
llvm::Expected< std::unique_ptr< CTFType > > ParseType(lldb::offset_t &offset, lldb::user_id_t uid)
std::optional< ctf_header_t > m_header
size_t ParseTypes(CompileUnit &cu) override
Containing protected virtual methods for child classes to override.
Definition: SymbolFile.h:507
ObjectFile * GetObjectFile() override
Definition: SymbolFile.h:536
virtual TypeList & GetTypeList()
Definition: SymbolFile.h:609
lldb::ObjectFileSP m_objfile_sp
Definition: SymbolFile.h:612
llvm::Expected< lldb::TypeSystemSP > GetTypeSystemForLanguage(lldb::LanguageType language) override
Definition: SymbolFile.cpp:220
lldb::TypeSP MakeType(lldb::user_id_t uid, ConstString name, std::optional< uint64_t > byte_size, SymbolContextScope *context, lldb::user_id_t encoding_uid, Type::EncodingDataType encoding_uid_type, const Declaration &decl, const CompilerType &compiler_qual_type, Type::ResolveState compiler_type_resolve_state, uint32_t opaque_payload=0) override
This function is used to create types that belong to a SymbolFile.
Definition: SymbolFile.h:580
Provides public interface for all SymbolFiles.
Definition: SymbolFile.h:50
virtual std::recursive_mutex & GetModuleMutex() const
Symbols file subclasses should override this to return the Module that owns the TypeSystem that this ...
Definition: SymbolFile.cpp:36
lldb::addr_t GetFileAddress() const
Definition: Symbol.cpp:534
Mangled & GetMangled()
Definition: Symbol.h:146
lldb::addr_t GetByteSize() const
Definition: Symbol.cpp:468
ConstString GetName() const
Definition: Symbol.cpp:548
Symbol * FindSymbolWithType(lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, uint32_t &start_idx)
Definition: Symtab.cpp:805
void Insert(const lldb::TypeSP &type)
Definition: TypeMap.cpp:27
A class that contains all state required for type lookups.
Definition: Type.h:104
ConstString GetTypeBasename() const
Get the type basename to use when searching the type indexes in each SymbolFile object.
Definition: Type.cpp:112
This class tracks the state and results of a TypeQuery.
Definition: Type.h:344
bool InsertUnique(const lldb::TypeSP &type_sp)
When types that match a TypeQuery are found, this API is used to insert the matching types.
Definition: Type.cpp:193
bool Done(const TypeQuery &query) const
Check if the type matching has found all of the matches that it needs.
Definition: Type.cpp:199
bool AlreadySearched(lldb_private::SymbolFile *sym_file)
Check if a SymbolFile object has already been searched by this type match object.
Definition: Type.cpp:189
clang::TranslationUnitDecl * GetTranslationUnitDecl()
CompilerType GetBasicType(lldb::BasicType type)
static clang::FieldDecl * AddFieldToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &field_type, lldb::AccessType access, uint32_t bitfield_bit_size)
CompilerType CreateArrayType(const CompilerType &element_type, std::optional< size_t > element_count, bool is_vector)
static lldb::BasicType GetBasicTypeEnumeration(llvm::StringRef name)
CompilerDeclContext CreateDeclContext(clang::DeclContext *ctx)
Creates a CompilerDeclContext from the given DeclContext with the current TypeSystemClang instance as...
clang::EnumConstantDecl * AddEnumerationValueToEnumerationType(const CompilerType &enum_type, const Declaration &decl, const char *name, int64_t enum_value, uint32_t enum_value_bit_size)
static bool CompleteTagDeclarationDefinition(const CompilerType &type)
CompilerType CreateRecordType(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, llvm::StringRef name, int kind, lldb::LanguageType language, std::optional< ClangASTMetadata > metadata=std::nullopt, bool exports_symbols=false)
CompilerType CreateEnumerationType(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const Declaration &decl, const CompilerType &integer_qual_type, bool is_scoped)
static bool StartTagDeclarationDefinition(const CompilerType &type)
CompilerType CreateFunctionType(const CompilerType &result_type, const CompilerType *args, unsigned num_args, bool is_variadic, unsigned type_quals, clang::CallingConv cc=clang::CC_C, clang::RefQualifierKind ref_qual=clang::RQ_None)
@ eEncodingIsUID
This type is the type whose UID is m_encoding_uid.
Definition: Type.h:423
std::optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope)
Definition: Type.cpp:458
CompilerType GetFullCompilerType()
Definition: Type.cpp:764
void AddVariable(const lldb::VariableSP &var_sp)
#define LLDB_INVALID_UID
Definition: lldb-defines.h:88
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:332
static uint32_t bits(const uint32_t val, const uint32_t msbit, const uint32_t lsbit)
Definition: ARMUtils.h:265
Definition: SBAddress.h:15
std::shared_ptr< lldb_private::Function > FunctionSP
Definition: lldb-forward.h:355
@ eDescriptionLevelBrief
BasicType
Basic types enumeration for the public API SBType::GetBasicType().
@ eBasicTypeInvalid
uint64_t offset_t
Definition: lldb-types.h:85
std::shared_ptr< lldb_private::ObjectFile > ObjectFileSP
Definition: lldb-forward.h:375
@ eLanguageTypeC
Non-standardized C, such as K&R.
std::shared_ptr< lldb_private::Type > TypeSP
Definition: lldb-forward.h:461
ByteOrder
Byte ordering definitions.
std::shared_ptr< lldb_private::Variable > VariableSP
Definition: lldb-forward.h:486
uint64_t user_id_t
Definition: lldb-types.h:82
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
Definition: lldb-forward.h:336
std::shared_ptr< lldb_private::Section > SectionSP
Definition: lldb-forward.h:418
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:373
std::shared_ptr< lldb_private::CompileUnit > CompUnitSP
Definition: lldb-forward.h:335
@ eValueTypeVariableGlobal
globals variable
@ eRegisterKindDWARF
the register numbers seen DWARF
Definition: Debugger.h:54
llvm::StringRef name
Definition: CTFTypes.h:120
std::vector< Value > values
Definition: CTFTypes.h:135
std::vector< uint32_t > args
Definition: CTFTypes.h:149
std::vector< Field > fields
Definition: CTFTypes.h:175
llvm::StringRef name
Definition: CTFTypes.h:38
lldb::user_id_t uid
Definition: CTFTypes.h:37