LLDB mainline
VectorIterator.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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 "VectorIterator.h"
10
12
13#include "lldb/Utility/Status.h"
15#include "llvm/Support/ErrorExtras.h"
16
17using namespace lldb;
18using namespace lldb_private;
19using namespace lldb_private::formatters;
20
22 lldb::ValueObjectSP valobj_sp, llvm::ArrayRef<ConstString> item_names)
24 m_item_names(item_names), m_item_sp() {
25 if (valobj_sp)
26 Update();
27}
28
30 m_item_sp.reset();
31
32 ValueObjectSP valobj_sp = m_backend.GetSP();
33 if (!valobj_sp)
35
36 ValueObjectSP item_ptr =
38 if (!item_ptr)
40 if (item_ptr->GetValueAsUnsigned(0) == 0)
42 Status err;
43 m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
45 "item", item_ptr->GetValueAsUnsigned(0), m_exe_ctx_ref,
46 item_ptr->GetCompilerType().GetPointeeType());
47 if (err.Fail())
48 m_item_sp.reset();
50}
51
52llvm::Expected<uint32_t>
56
59 if (idx == 0)
60 return m_item_sp;
61 return lldb::ValueObjectSP();
62}
63
64llvm::Expected<size_t>
66 if (name == "item")
67 return 0;
68 return llvm::createStringErrorV("type has no child named '{0}'", name);
69}
A uniqued constant string class.
Definition ConstString.h:40
An error handling class.
Definition Status.h:118
bool Fail() const
Test for error condition.
Definition Status.cpp:293
lldb::ValueObjectSP CreateChildValueObjectFromAddress(llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx, CompilerType type, bool do_deref=true)
SyntheticChildrenFrontEnd(ValueObject &backend)
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override
llvm::Expected< uint32_t > CalculateNumChildren() override
llvm::Expected< size_t > GetIndexOfChildWithName(ConstString name) override
Determine the index of a named child.
VectorIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp, llvm::ArrayRef< ConstString > item_names)
lldb::ChildCacheState Update() override
This function is assumed to always succeed and if it fails, the front-end should know to deal with it...
lldb::ValueObjectSP GetChildMemberWithName(ValueObject &obj, llvm::ArrayRef< ConstString > alternative_names)
Find a child member of obj_sp, trying all alternative names in order.
Definition LibCxx.cpp:62
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