//===-- LibCxxAtomic.cpp --------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "LibCxxAtomic.h" #include "lldb/DataFormatters/FormattersHelpers.h" usingnamespacelldb; usingnamespacelldb_private; usingnamespacelldb_private::formatters; // // We are supporting two versions of libc++ std::atomic // // Given std::atomic<int> i; // // The previous version of std::atomic was laid out like this // // (lldb) frame var -L -R i // 0x00007ffeefbff9a0: (std::__1::atomic<int>) i = { // 0x00007ffeefbff9a0: std::__1::__atomic_base<int, true> = { // 0x00007ffeefbff9a0: std::__1::__atomic_base<int, false> = { // 0x00007ffeefbff9a0: __a_ = 5 // } // } // } // // In this case we need to obtain __a_ and the current version is laid out as so // // (lldb) frame var -L -R i // 0x00007ffeefbff9b0: (std::__1::atomic<int>) i = { // 0x00007ffeefbff9b0: std::__1::__atomic_base<int, true> = { // 0x00007ffeefbff9b0: std::__1::__atomic_base<int, false> = { // 0x00007ffeefbff9b0: __a_ = { // 0x00007ffeefbff9b0: std::__1::__cxx_atomic_base_impl<int> = { // 0x00007ffeefbff9b0: __a_value = 5 // } // } // } // } //} // // In this case we need to obtain __a_value // // The below method covers both cases and returns the relevant member as a // ValueObjectSP // ValueObjectSP lldb_private::formatters::GetLibCxxAtomicValue(ValueObject &valobj) { … } bool lldb_private::formatters::LibCxxAtomicSummaryProvider( ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { … } namespace lldb_private { namespace formatters { class LibcxxStdAtomicSyntheticFrontEnd : public SyntheticChildrenFrontEnd { … }; } // namespace formatters } // namespace lldb_private lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd:: LibcxxStdAtomicSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp) : … { … } lldb::ChildCacheState lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::Update() { … } bool lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd:: MightHaveChildren() { … } llvm::Expected<uint32_t> lldb_private::formatters:: LibcxxStdAtomicSyntheticFrontEnd::CalculateNumChildren() { … } lldb::ValueObjectSP lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::GetChildAtIndex( uint32_t idx) { … } size_t lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd:: GetIndexOfChildWithName(ConstString name) { … } SyntheticChildrenFrontEnd * lldb_private::formatters::LibcxxAtomicSyntheticFrontEndCreator( CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) { … }