LLDB mainline
ValueObjectVTable.h
Go to the documentation of this file.
1//===-- ValueObjectVTable.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_CORE_VALUEOBJECTVTABLE_H
10#define LLDB_CORE_VALUEOBJECTVTABLE_H
11
13
14namespace lldb_private {
15
16/// A class that represents a virtual function table for a C++ class.
17///
18/// ValueObject::GetError() will be in the success state if this value
19/// represents a C++ class with a vtable, or an appropriate error describing
20/// that the object isn't a C++ class with a vtable or not a C++ class.
21///
22/// ValueObject::GetName() will be the demangled symbol name for the virtual
23/// function table like "vtable for <classname>".
24///
25/// ValueObject::GetValueAsCString() will be the address of the first vtable
26/// entry if the current ValueObject is a class with a vtable, or nothing the
27/// current ValueObject is not a C++ class or not a C++ class that has a
28/// vtable.
29///
30/// ValueObject::GetValueAtUnsigned(...) will return the address of the first
31/// vtable entry.
32///
33/// ValueObject::GetAddressOf() will return the address of the vtable pointer
34/// found in the parent ValueObject.
35///
36/// ValueObject::GetNumChildren() will return the number of virtual function
37/// pointers in the vtable, or zero on error.
38///
39/// ValueObject::GetChildAtIndex(...) will return each virtual function pointer
40/// as a ValueObject object.
41///
42/// The child ValueObjects will have the following values:
43///
44/// ValueObject::GetError() will indicate success if the vtable entry was
45/// successfully read from memory, or an error if not.
46///
47/// ValueObject::GetName() will be the vtable function index in the form "[%u]"
48/// where %u is the index.
49///
50/// ValueObject::GetValueAsCString() will be the virtual function pointer value
51///
52/// ValueObject::GetValueAtUnsigned(...) will return the virtual function
53/// pointer value.
54///
55/// ValueObject::GetAddressOf() will return the address of the virtual function
56/// pointer.
57///
58/// ValueObject::GetNumChildren() returns 0
60public:
62
64
65 std::optional<uint64_t> GetByteSize() override;
66
67 llvm::Expected<uint32_t> CalculateNumChildren(uint32_t max) override;
68
69 lldb::ValueType GetValueType() const override;
70
71 ConstString GetTypeName() override;
72
74
76
77 bool IsInScope() override;
78
79protected:
80 bool UpdateValue() override;
81
83
84 /// The symbol for the C++ virtual function table.
85 const Symbol *m_vtable_symbol = nullptr;
86 /// Cache the number of vtable children when we update the value.
88 /// Cache the address size in bytes to avoid checking with the process to
89 /// many times.
90 uint32_t m_addr_size = 0;
91
92private:
94
95 ValueObject *CreateChildAtIndex(size_t idx) override;
97 return nullptr;
98 }
99
100 // For ValueObject only
103};
104
105} // namespace lldb_private
106
107#endif // LLDB_CORE_VALUEOBJECTVTABLE_H
Generic representation of a type in a programming language.
Definition: CompilerType.h:36
A uniqued constant string class.
Definition: ConstString.h:40
A class that represents a virtual function table for a C++ class.
const Symbol * m_vtable_symbol
The symbol for the C++ virtual function table.
llvm::Expected< uint32_t > CalculateNumChildren(uint32_t max) override
Should only be called by ValueObject::GetNumChildren().
uint32_t m_addr_size
Cache the address size in bytes to avoid checking with the process to many times.
ValueObject * CreateSyntheticArrayMember(size_t idx) override
Should only be called by ValueObject::GetSyntheticArrayMember().
ConstString GetQualifiedTypeName() override
ValueObject * CreateChildAtIndex(size_t idx) override
Should only be called by ValueObject::GetChildAtIndex().
static lldb::ValueObjectSP Create(ValueObject &parent)
lldb::ValueType GetValueType() const override
std::optional< uint64_t > GetByteSize() override
ConstString GetTypeName() override
uint32_t m_num_vtable_entries
Cache the number of vtable children when we update the value.
const ValueObjectVTable & operator=(const ValueObjectVTable &)=delete
ConstString GetDisplayTypeName() override
CompilerType GetCompilerTypeImpl() override
ValueObjectVTable(const ValueObjectVTable &)=delete
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Definition: lldb-forward.h:480