Path: blob/main/contrib/llvm-project/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp
39642 views
//===-- LibCxxQueue.cpp ---------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "LibCxx.h"9#include "lldb/DataFormatters/FormattersHelpers.h"1011using namespace lldb;12using namespace lldb_private;1314namespace {1516class QueueFrontEnd : public SyntheticChildrenFrontEnd {17public:18QueueFrontEnd(ValueObject &valobj) : SyntheticChildrenFrontEnd(valobj) {19Update();20}2122size_t GetIndexOfChildWithName(ConstString name) override {23return m_container_sp ? m_container_sp->GetIndexOfChildWithName(name)24: UINT32_MAX;25}2627bool MightHaveChildren() override { return true; }28lldb::ChildCacheState Update() override;2930llvm::Expected<uint32_t> CalculateNumChildren() override {31return m_container_sp ? m_container_sp->GetNumChildren() : 0;32}3334ValueObjectSP GetChildAtIndex(uint32_t idx) override {35return m_container_sp ? m_container_sp->GetChildAtIndex(idx)36: nullptr;37}3839private:40// The lifetime of a ValueObject and all its derivative ValueObjects41// (children, clones, etc.) is managed by a ClusterManager. These42// objects are only destroyed when every shared pointer to any of them43// is destroyed, so we must not store a shared pointer to any ValueObject44// derived from our backend ValueObject (since we're in the same cluster).45ValueObject* m_container_sp = nullptr;46};47} // namespace4849lldb::ChildCacheState QueueFrontEnd::Update() {50m_container_sp = nullptr;51ValueObjectSP c_sp = m_backend.GetChildMemberWithName("c");52if (!c_sp)53return lldb::ChildCacheState::eRefetch;54m_container_sp = c_sp->GetSyntheticValue().get();55return lldb::ChildCacheState::eRefetch;56}5758SyntheticChildrenFrontEnd *59formatters::LibcxxQueueFrontEndCreator(CXXSyntheticChildren *,60lldb::ValueObjectSP valobj_sp) {61if (valobj_sp)62return new QueueFrontEnd(*valobj_sp);63return nullptr;64}656667