blob: 9f7185aa6682266b64aca4df1d47f7e341e60a1b [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- ValueObjectList.cpp -------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "lldb/Core/ValueObjectList.h"
11
12// C Includes
13// C++ Includes
14// Other libraries and framework includes
15// Project includes
16#include "lldb/Core/ValueObjectChild.h"
17#include "lldb/Core/ValueObjectRegister.h"
18#include "lldb/Core/ValueObjectVariable.h"
19#include "lldb/Target/ExecutionContext.h"
20#include "lldb/Target/Process.h"
21
22using namespace lldb;
23using namespace lldb_private;
24
25ValueObjectList::ValueObjectList () :
26 m_value_objects()
27{
28}
29
30ValueObjectList::ValueObjectList (const ValueObjectList &rhs) :
31 m_value_objects(rhs.m_value_objects)
32{
33}
34
35
36ValueObjectList::~ValueObjectList ()
37{
38}
39
40const ValueObjectList &
41ValueObjectList::operator = (const ValueObjectList &rhs)
42{
43 if (this != &rhs)
44 m_value_objects = rhs.m_value_objects;
45 return *this;
46}
47
48void
49ValueObjectList::Append (const ValueObjectSP &val_obj_sp)
50{
51 m_value_objects.push_back(val_obj_sp);
52}
53
Greg Clayton917c0002011-06-29 22:09:02 +000054void
55ValueObjectList::Append (const ValueObjectList &valobj_list)
56{
57 std::copy(valobj_list.m_value_objects.begin(), // source begin
58 valobj_list.m_value_objects.end(), // source end
59 back_inserter(m_value_objects)); // destination
60
61}
62
63
Chris Lattner24943d22010-06-08 16:52:24 +000064uint32_t
65ValueObjectList::GetSize() const
66{
67 return m_value_objects.size();
68}
69
Greg Clayton17dae082010-09-02 02:59:18 +000070void
71ValueObjectList::Resize (uint32_t size)
72{
73 m_value_objects.resize (size);
74}
75
Chris Lattner24943d22010-06-08 16:52:24 +000076lldb::ValueObjectSP
77ValueObjectList::GetValueObjectAtIndex (uint32_t idx)
78{
79 lldb::ValueObjectSP valobj_sp;
80 if (idx < m_value_objects.size())
81 valobj_sp = m_value_objects[idx];
82 return valobj_sp;
83}
84
Greg Clayton5d81f492011-07-08 21:46:14 +000085lldb::ValueObjectSP
86ValueObjectList::RemoveValueObjectAtIndex (uint32_t idx)
87{
88 lldb::ValueObjectSP valobj_sp;
89 if (idx < m_value_objects.size())
90 {
91 valobj_sp = m_value_objects[idx];
92 m_value_objects.erase (m_value_objects.begin() + idx);
93 }
94 return valobj_sp;
95}
96
Greg Clayton17dae082010-09-02 02:59:18 +000097void
98ValueObjectList::SetValueObjectAtIndex (uint32_t idx, const ValueObjectSP &valobj_sp)
99{
100 if (idx >= m_value_objects.size())
101 m_value_objects.resize (idx + 1);
102 m_value_objects[idx] = valobj_sp;
103}
104
Chris Lattner24943d22010-06-08 16:52:24 +0000105ValueObjectSP
106ValueObjectList::FindValueObjectByValueName (const char *name)
107{
108 ConstString name_const_str(name);
109 ValueObjectSP val_obj_sp;
110 collection::iterator pos, end = m_value_objects.end();
111 for (pos = m_value_objects.begin(); pos != end; ++pos)
112 {
Greg Clayton17dae082010-09-02 02:59:18 +0000113 ValueObject *valobj = (*pos).get();
114 if (valobj && valobj->GetName() == name_const_str)
Chris Lattner24943d22010-06-08 16:52:24 +0000115 {
116 val_obj_sp = *pos;
117 break;
118 }
119 }
120 return val_obj_sp;
121}
122
123ValueObjectSP
124ValueObjectList::FindValueObjectByUID (lldb::user_id_t uid)
125{
126 ValueObjectSP valobj_sp;
127 collection::iterator pos, end = m_value_objects.end();
128
129 for (pos = m_value_objects.begin(); pos != end; ++pos)
130 {
Greg Clayton17dae082010-09-02 02:59:18 +0000131 // Watch out for NULL objects in our list as the list
132 // might get resized to a specific size and lazily filled in
133 ValueObject *valobj = (*pos).get();
134 if (valobj && valobj->GetID() == uid)
Chris Lattner24943d22010-06-08 16:52:24 +0000135 {
136 valobj_sp = *pos;
137 break;
138 }
139 }
140 return valobj_sp;
141}
142
143
144ValueObjectSP
Greg Clayton17dae082010-09-02 02:59:18 +0000145ValueObjectList::FindValueObjectByPointer (ValueObject *find_valobj)
Chris Lattner24943d22010-06-08 16:52:24 +0000146{
147 ValueObjectSP valobj_sp;
148 collection::iterator pos, end = m_value_objects.end();
149
150 for (pos = m_value_objects.begin(); pos != end; ++pos)
151 {
Greg Clayton17dae082010-09-02 02:59:18 +0000152 ValueObject *valobj = (*pos).get();
153 if (valobj && valobj == find_valobj)
Chris Lattner24943d22010-06-08 16:52:24 +0000154 {
155 valobj_sp = *pos;
156 break;
157 }
158 }
159 return valobj_sp;
160}
Greg Clayton870a1cd2010-08-27 21:47:54 +0000161
162void
163ValueObjectList::Swap (ValueObjectList &value_object_list)
164{
165 m_value_objects.swap (value_object_list.m_value_objects);
166}