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 ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
70 int32_t synthetic_index) override;
71
72 lldb::ValueType GetValueType() const override;
73
74 ConstString GetTypeName() override;
75
77
79
80 bool IsInScope() override;
81
82protected:
83 bool UpdateValue() override;
84
86
87 /// The symbol for the C++ virtual function table.
88 const Symbol *m_vtable_symbol = nullptr;
89 /// Cache the number of vtable children when we update the value.
91 /// Cache the address size in bytes to avoid checking with the process to
92 /// many times.
93 uint32_t m_addr_size = 0;
94
95private:
97
98 // For ValueObject only
101};
102
103} // namespace lldb_private
104
105#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.
ConstString GetQualifiedTypeName() override
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
ValueObject * CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index) override
Should only be called by ValueObject::GetChildAtIndex().
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Definition: lldb-forward.h:472