]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/tools/lldb/source/Core/ValueObjectList.cpp
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / llvm / tools / lldb / source / Core / ValueObjectList.cpp
1 //===-- 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
22 using namespace lldb;
23 using namespace lldb_private;
24
25 ValueObjectList::ValueObjectList () :
26     m_value_objects()
27 {
28 }
29
30 ValueObjectList::ValueObjectList (const ValueObjectList &rhs) :
31     m_value_objects(rhs.m_value_objects)
32 {
33 }
34
35
36 ValueObjectList::~ValueObjectList ()
37 {
38 }
39
40 const ValueObjectList &
41 ValueObjectList::operator = (const ValueObjectList &rhs)
42 {
43     if (this != &rhs)
44         m_value_objects = rhs.m_value_objects;
45     return *this;
46 }
47
48 void
49 ValueObjectList::Append (const ValueObjectSP &val_obj_sp)
50 {
51     m_value_objects.push_back(val_obj_sp);
52 }
53
54 void
55 ValueObjectList::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
64 size_t
65 ValueObjectList::GetSize() const
66 {
67     return m_value_objects.size();
68 }
69
70 void
71 ValueObjectList::Resize (size_t size)
72 {
73     m_value_objects.resize (size);
74 }
75
76 lldb::ValueObjectSP
77 ValueObjectList::GetValueObjectAtIndex (size_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
85 lldb::ValueObjectSP
86 ValueObjectList::RemoveValueObjectAtIndex (size_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
97 void
98 ValueObjectList::SetValueObjectAtIndex (size_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
105 ValueObjectSP
106 ValueObjectList::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     {
113         ValueObject *valobj = (*pos).get();
114         if (valobj && valobj->GetName() == name_const_str)
115         {
116             val_obj_sp = *pos;
117             break;
118         }
119     }
120     return val_obj_sp;
121 }
122
123 ValueObjectSP
124 ValueObjectList::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     {
131         // 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)
135         {
136             valobj_sp = *pos;
137             break;
138         }
139     }
140     return valobj_sp;
141 }
142
143
144 ValueObjectSP
145 ValueObjectList::FindValueObjectByPointer (ValueObject *find_valobj)
146 {
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     {
152         ValueObject *valobj = (*pos).get();
153         if (valobj && valobj == find_valobj)
154         {
155             valobj_sp = *pos;
156             break;
157         }
158     }
159     return valobj_sp;
160 }
161
162 void
163 ValueObjectList::Swap (ValueObjectList &value_object_list)
164 {
165     m_value_objects.swap (value_object_list.m_value_objects);
166 }