LLDB mainline
RegisterTypeBuilderClang.h
Go to the documentation of this file.
1//===-- RegisterTypeBuilderClang.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_REGISTERTYPEBUILDER_REGISTERTYPEBUILDERCLANG_H
10#define LLDB_SOURCE_PLUGINS_REGISTERTYPEBUILDER_REGISTERTYPEBUILDERCLANG_H
11
14#include "lldb/Target/Target.h"
16
17namespace lldb_private {
19public:
21
22 static void Initialize();
23 static void Terminate();
24 static llvm::StringRef GetPluginNameStatic() {
25 return "register-types-clang";
26 }
27 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
28 static llvm::StringRef GetPluginDescriptionStatic() {
29 return "Create register types using TypeSystemClang";
30 }
32
33 CompilerType GetRegisterType(const RegisterInfo &reg_info) override;
34
35private:
37 uint32_t expected_byte_size,
38 lldb::TypeSystemClangSP type_system);
39
40 CompilerType BuildEnumType(const RegisterTypeEnum *enum_type_info,
41 uint32_t register_byte_size,
42 lldb::TypeSystemClangSP type_system);
43
45 uint32_t register_byte_size,
46 lldb::TypeSystemClangSP type_system);
47
49
50 // A cache of previously created types. We do not cache by element ID because
51 // IDs are not unique across xml <feature> elements and this class does not
52 // know anything about features.
53 //
54 // The key contains the process-wide UID of the type and the size of the
55 // register we made it for. Some types (enums for example) use the register
56 // size in their type and must be rebuilt for a different size.
57 //
58 // 8 is chosen because types are only made when needed, and most lldb commands
59 // do not need them.
60 llvm::SmallDenseMap<std::pair<uint64_t, uint32_t>, CompilerType, 8>
62 std::weak_ptr<TypeSystemClang> m_cached_type_system;
63
64 std::optional<CompilerType>
65 GetExistingCompilerType(const RegisterType *register_type,
66 uint32_t register_byte_size);
67};
68} // namespace lldb_private
69
70#endif // LLDB_SOURCE_PLUGINS_REGISTERTYPEBUILDER_REGISTERTYPEBUILDERCLANG_H
Generic representation of a type in a programming language.
std::optional< CompilerType > GetExistingCompilerType(const RegisterType *register_type, uint32_t register_byte_size)
CompilerType BuildEnumType(const RegisterTypeEnum *enum_type_info, uint32_t register_byte_size, lldb::TypeSystemClangSP type_system)
CompilerType BuildFlagsType(const RegisterTypeFlags *flags_info, uint32_t register_byte_size, lldb::TypeSystemClangSP type_system)
std::weak_ptr< TypeSystemClang > m_cached_type_system
CompilerType GetRegisterType(const RegisterInfo &reg_info) override
Do not cache the returned CompilerType.
llvm::SmallDenseMap< std::pair< uint64_t, uint32_t >, CompilerType, 8 > m_type_cache
CompilerType BuildBuiltinType(const RegisterTypeBuiltin *builtin_type, uint32_t expected_byte_size, lldb::TypeSystemClangSP type_system)
static lldb::RegisterTypeBuilderSP CreateInstance(Target &target)
A predefined GDB target-description type.
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::RegisterTypeBuilder > RegisterTypeBuilderSP
std::shared_ptr< lldb_private::TypeSystemClang > TypeSystemClangSP
Every register is described in detail including its name, alternate name (optional),...