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
13using namespace lldb;
14
15namespace lldb_private {
16namespace formatters {
17
19public:
21
22 llvm::Expected<uint32_t> CalculateNumChildren() override;
23
24 lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;
25
27
28 llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override;
29
30private:
33};
34
35} // namespace formatters
36} // namespace lldb_private
37
44
49
52 uint32_t idx) {
53 if (idx == 0 && m_storage && m_element_type.IsValid())
54 return m_storage->Cast(m_element_type)->Clone(ConstString("Value"));
55 return nullptr;
56}
57
60 m_storage = nullptr;
61 m_element_type.Clear();
62
63 ValueObjectSP storage_sp = m_backend.GetChildMemberWithName("_Storage");
64 if (!storage_sp)
66
67 CompilerType backend_type = m_backend.GetCompilerType();
68 if (!backend_type)
70
72 if (!m_element_type) {
73 // PDB doesn't have info about templates, so use value_type which equals T.
74 m_element_type = backend_type.GetDirectNestedTypeWithName("value_type");
75
76 if (!m_element_type)
78 }
79
80 m_storage = storage_sp.get();
82}
83
84llvm::Expected<size_t> lldb_private::formatters::
86 if (name == "Value")
87 return 0;
88 return llvm::createStringError("Type has no child named '%s'",
89 name.AsCString());
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
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
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
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