LLDB mainline
MsvcStlAtomic.cpp
Go to the documentation of this file.
1//===-- MsvcStlAtomic.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 "MsvcStl.h"
10
12#include "llvm/Support/ErrorExtras.h"
13
14using namespace lldb;
15
16namespace lldb_private {
17namespace formatters {
18
20public:
22
23 llvm::Expected<uint32_t> CalculateNumChildren() override;
24
25 lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;
26
28
29 llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override;
30
31private:
34};
35
36} // namespace formatters
37} // namespace lldb_private
38
45
50
53 uint32_t idx) {
54 if (idx == 0 && m_storage && m_element_type.IsValid())
55 return m_storage->Cast(m_element_type)->Clone(ConstString("Value"));
56 return nullptr;
57}
58
61 m_storage = nullptr;
62 m_element_type.Clear();
63
64 ValueObjectSP storage_sp = m_backend.GetChildMemberWithName("_Storage");
65 if (!storage_sp)
67
68 CompilerType backend_type = m_backend.GetCompilerType();
69 if (!backend_type)
71
73 if (!m_element_type) {
74 // PDB doesn't have info about templates, so use value_type which equals T.
75 m_element_type = backend_type.GetDirectNestedTypeWithName("value_type");
76
77 if (!m_element_type)
79 }
80
81 m_storage = storage_sp.get();
83}
84
85llvm::Expected<size_t> lldb_private::formatters::
87 if (name == "Value")
88 return 0;
89 return llvm::createStringErrorV("type has no child named '{0}'", name);
90}
91
95 if (valobj_sp && IsMsvcStlAtomic(*valobj_sp))
96 return new MsvcStlAtomicSyntheticFrontEnd(valobj_sp);
97 return nullptr;
98}
99
101 ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
102 ValueObjectSP synth_sp = valobj.GetSyntheticValue();
103 if (!synth_sp)
104 return false;
105
106 ValueObjectSP value_sp = synth_sp->GetChildAtIndex(0);
107 std::string summary;
108 if (value_sp->GetSummaryAsCString(summary, options) && !summary.empty()) {
109 stream << summary;
110 return true;
111 }
112 return false;
113}
114
116 if (auto valobj_sp = valobj.GetNonSyntheticValue())
117 return valobj_sp->GetChildMemberWithName("_Storage") != nullptr;
118 return false;
119}
Generic representation of a type in a programming language.
CompilerType GetTypeTemplateArgument(size_t idx, bool expand_pack=false) const
CompilerType GetDirectNestedTypeWithName(llvm::StringRef name) const
A uniqued constant string class.
Definition ConstString.h:40
A stream class that can stream formatted output to a file.
Definition Stream.h:28
SyntheticChildrenFrontEnd(ValueObject &backend)
lldb::ValueObjectSP GetSyntheticValue()
virtual lldb::ValueObjectSP GetNonSyntheticValue()
MsvcStlAtomicSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
llvm::Expected< size_t > GetIndexOfChildWithName(ConstString name) override
Determine the index of a named child.
llvm::Expected< uint32_t > CalculateNumChildren() override
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override
lldb::ChildCacheState Update() override
This function is assumed to always succeed and if it fails, the front-end should know to deal with it...
bool IsMsvcStlAtomic(ValueObject &valobj)
SyntheticChildrenFrontEnd * MsvcStlAtomicSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp)
bool MsvcStlAtomicSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options)
A class that represents a running process on the host machine.
ChildCacheState
Specifies if children need to be re-computed after a call to SyntheticChildrenFrontEnd::Update.
@ eRefetch
Children need to be recomputed dynamically.
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP