9#include "clang/AST/DeclCXX.h"
22 static llvm::once_flag g_once_flag;
23 llvm::call_once(g_once_flag, []() {
25 GetPluginDescriptionStatic(), CreateInstance);
33 return std::make_shared<RegisterTypeBuilderClang>(target);
46 std::string register_type_name =
"__lldb_register_fields_" + name;
49 type_system->GetTypeForIdentifier<clang::CXXRecordDecl>(
60 fields_type = type_system->CreateRecordType(
62 register_type_name, llvm::to_underlying(clang::TagTypeKind::Struct),
64 type_system->StartTagDeclarationDefinition(fields_type);
71 if (
const FieldEnum *enum_type = field.GetEnum()) {
73 if (!enumerators.empty()) {
78 std::string enum_type_name =
"__lldb_register_fields_enum_" +
79 enum_type->GetID() +
"_" +
80 std::to_string(byte_size);
85 type_system->GetTypeForIdentifier<clang::EnumDecl>(
89 field_type = field_enum_type;
91 field_type = type_system->CreateEnumerationType(
92 enum_type_name, type_system->GetTranslationUnitDecl(),
95 type_system->StartTagDeclarationDefinition(field_type);
98 for (
auto enumerator : enumerators) {
99 type_system->AddEnumerationValueToEnumerationType(
100 field_type, decl, enumerator.m_name.c_str(),
101 enumerator.m_value, byte_size * 8);
104 type_system->CompleteTagDeclarationDefinition(field_type);
109 type_system->AddFieldToRecordType(fields_type, field.GetName(),
111 field.GetSizeInBits());
114 type_system->CompleteTagDeclarationDefinition(fields_type);
116 type_system->SetIsPacked(fields_type);
#define LLDB_PLUGIN_DEFINE(PluginName)
Generic representation of a type in a programming language.
std::optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
A class that describes the declaration location of a lldb object.
std::vector< Enumerator > Enumerators
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
const std::vector< Field > & GetFields() const
RegisterTypeBuilderClang(Target &target)
CompilerType GetRegisterType(const std::string &name, const lldb_private::RegisterFlags &flags, uint32_t byte_size) override
static lldb::RegisterTypeBuilderSP CreateInstance(Target &target)
static lldb::TypeSystemClangSP GetForTarget(Target &target, std::optional< IsolatedASTKind > ast_kind=DefaultAST, bool create_on_demand=true)
Returns the scratch TypeSystemClang for the given target.
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::RegisterTypeBuilder > RegisterTypeBuilderSP
@ eLanguageTypeC
Non-standardized C, such as K&R.
@ eEncodingUint
unsigned integer
std::shared_ptr< lldb_private::TypeSystemClang > TypeSystemClangSP