LLDB mainline
LibCxxQueue.cpp
Go to the documentation of this file.
1//===-- LibCxxQueue.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 "LibCxx.h"
11
12using namespace lldb;
13using namespace lldb_private;
14
15namespace {
16
17class QueueFrontEnd : public SyntheticChildrenFrontEnd {
18public:
19 QueueFrontEnd(ValueObject &valobj) : SyntheticChildrenFrontEnd(valobj) {
20 Update();
21 }
22
23 size_t GetIndexOfChildWithName(ConstString name) override {
24 return m_container_sp ? m_container_sp->GetIndexOfChildWithName(name)
25 : UINT32_MAX;
26 }
27
28 bool MightHaveChildren() override { return true; }
30
31 llvm::Expected<uint32_t> CalculateNumChildren() override {
32 return m_container_sp ? m_container_sp->GetNumChildren() : 0;
33 }
34
35 ValueObjectSP GetChildAtIndex(uint32_t idx) override {
36 return m_container_sp ? m_container_sp->GetChildAtIndex(idx)
37 : nullptr;
38 }
39
40private:
41 // The lifetime of a ValueObject and all its derivative ValueObjects
42 // (children, clones, etc.) is managed by a ClusterManager. These
43 // objects are only destroyed when every shared pointer to any of them
44 // is destroyed, so we must not store a shared pointer to any ValueObject
45 // derived from our backend ValueObject (since we're in the same cluster).
46 ValueObject* m_container_sp = nullptr;
47};
48} // namespace
49
50lldb::ChildCacheState QueueFrontEnd::Update() {
51 m_container_sp = nullptr;
52 ValueObjectSP c_sp = m_backend.GetChildMemberWithName("c");
53 if (!c_sp)
55 m_container_sp = c_sp->GetSyntheticValue().get();
57}
58
61 lldb::ValueObjectSP valobj_sp) {
62 if (valobj_sp)
63 return new QueueFrontEnd(*valobj_sp);
64 return nullptr;
65}
A uniqued constant string class.
Definition: ConstString.h:40
virtual lldb::ValueObjectSP GetChildAtIndex(uint32_t idx)=0
virtual lldb::ChildCacheState Update()=0
This function is assumed to always succeed and if it fails, the front-end should know to deal with it...
virtual size_t GetIndexOfChildWithName(ConstString name)=0
virtual llvm::Expected< uint32_t > CalculateNumChildren()=0
virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name, bool can_create=true)
#define UINT32_MAX
Definition: lldb-defines.h:19
SyntheticChildrenFrontEnd * LibcxxQueueFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
Definition: LibCxxQueue.cpp:60
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Definition: SBAddress.h:15
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
Definition: lldb-forward.h:472