LLDB  mainline
ValueObjectList.cpp
Go to the documentation of this file.
1 //===-- ValueObjectList.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 
10 
11 #include "lldb/Core/ValueObject.h"
13 
14 #include <utility>
15 
16 using namespace lldb;
17 using namespace lldb_private;
18 
19 const ValueObjectList &ValueObjectList::operator=(const ValueObjectList &rhs) {
20  if (this != &rhs)
21  m_value_objects = rhs.m_value_objects;
22  return *this;
23 }
24 
25 void ValueObjectList::Append(const ValueObjectSP &val_obj_sp) {
26  m_value_objects.push_back(val_obj_sp);
27 }
28 
29 void ValueObjectList::Append(const ValueObjectList &valobj_list) {
30  std::copy(valobj_list.m_value_objects.begin(), // source begin
31  valobj_list.m_value_objects.end(), // source end
32  back_inserter(m_value_objects)); // destination
33 }
34 
35 size_t ValueObjectList::GetSize() const { return m_value_objects.size(); }
36 
37 void ValueObjectList::Resize(size_t size) { m_value_objects.resize(size); }
38 
39 lldb::ValueObjectSP ValueObjectList::GetValueObjectAtIndex(size_t idx) {
40  lldb::ValueObjectSP valobj_sp;
41  if (idx < m_value_objects.size())
42  valobj_sp = m_value_objects[idx];
43  return valobj_sp;
44 }
45 
46 lldb::ValueObjectSP ValueObjectList::RemoveValueObjectAtIndex(size_t idx) {
47  lldb::ValueObjectSP valobj_sp;
48  if (idx < m_value_objects.size()) {
49  valobj_sp = m_value_objects[idx];
50  m_value_objects.erase(m_value_objects.begin() + idx);
51  }
52  return valobj_sp;
53 }
54 
55 void ValueObjectList::SetValueObjectAtIndex(size_t idx,
56  const ValueObjectSP &valobj_sp) {
57  if (idx >= m_value_objects.size())
58  m_value_objects.resize(idx + 1);
59  m_value_objects[idx] = valobj_sp;
60 }
61 
62 ValueObjectSP ValueObjectList::FindValueObjectByValueName(const char *name) {
63  ConstString name_const_str(name);
64  ValueObjectSP val_obj_sp;
65  collection::iterator pos, end = m_value_objects.end();
66  for (pos = m_value_objects.begin(); pos != end; ++pos) {
67  ValueObject *valobj = (*pos).get();
68  if (valobj && valobj->GetName() == name_const_str) {
69  val_obj_sp = *pos;
70  break;
71  }
72  }
73  return val_obj_sp;
74 }
75 
76 ValueObjectSP ValueObjectList::FindValueObjectByUID(lldb::user_id_t uid) {
77  ValueObjectSP valobj_sp;
78  collection::iterator pos, end = m_value_objects.end();
79 
80  for (pos = m_value_objects.begin(); pos != end; ++pos) {
81  // Watch out for NULL objects in our list as the list might get resized to
82  // a specific size and lazily filled in
83  ValueObject *valobj = (*pos).get();
84  if (valobj && valobj->GetID() == uid) {
85  valobj_sp = *pos;
86  break;
87  }
88  }
89  return valobj_sp;
90 }
91 
92 ValueObjectSP
93 ValueObjectList::FindValueObjectByPointer(ValueObject *find_valobj) {
94  ValueObjectSP valobj_sp;
95  collection::iterator pos, end = m_value_objects.end();
96 
97  for (pos = m_value_objects.begin(); pos != end; ++pos) {
98  ValueObject *valobj = (*pos).get();
99  if (valobj && valobj == find_valobj) {
100  valobj_sp = *pos;
101  break;
102  }
103  }
104  return valobj_sp;
105 }
106 
107 void ValueObjectList::Swap(ValueObjectList &value_object_list) {
108  m_value_objects.swap(value_object_list.m_value_objects);
109 }
lldb_private::ValueObjectList
A collection of ValueObject values that.
Definition: ValueObjectList.h:23
lldb_private::ValueObject::GetID
lldb::user_id_t GetID() const
Returns a unique id for this ValueObject.
Definition: ValueObject.h:470
lldb_private::ConstString
Definition: ConstString.h:40
ValueObject.h
lldb_private::ValueObject
ValueObject:
Definition: ValueObject.h:105
lldb_private::ValueObject::GetName
ConstString GetName() const
Definition: ValueObject.h:467
lldb_private::ValueObjectList::m_value_objects
collection m_value_objects
Definition: ValueObjectList.h:57
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
ConstString.h
lldb
Definition: SBAddress.h:15
ValueObjectList.h