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 uint32_t 55 ValueObjectList::GetSize() const 56 { 57 return m_value_objects.size(); 58 } 59 60 void 61 ValueObjectList::Resize (uint32_t size) 62 { 63 m_value_objects.resize (size); 64 } 65 66 lldb::ValueObjectSP 67 ValueObjectList::GetValueObjectAtIndex (uint32_t idx) 68 { 69 lldb::ValueObjectSP valobj_sp; 70 if (idx < m_value_objects.size()) 71 valobj_sp = m_value_objects[idx]; 72 return valobj_sp; 73 } 74 75 void 76 ValueObjectList::SetValueObjectAtIndex (uint32_t idx, const ValueObjectSP &valobj_sp) 77 { 78 if (idx >= m_value_objects.size()) 79 m_value_objects.resize (idx + 1); 80 m_value_objects[idx] = valobj_sp; 81 } 82 83 ValueObjectSP 84 ValueObjectList::FindValueObjectByValueName (const char *name) 85 { 86 ConstString name_const_str(name); 87 ValueObjectSP val_obj_sp; 88 collection::iterator pos, end = m_value_objects.end(); 89 for (pos = m_value_objects.begin(); pos != end; ++pos) 90 { 91 ValueObject *valobj = (*pos).get(); 92 if (valobj && valobj->GetName() == name_const_str) 93 { 94 val_obj_sp = *pos; 95 break; 96 } 97 } 98 return val_obj_sp; 99 } 100 101 ValueObjectSP 102 ValueObjectList::FindValueObjectByUID (lldb::user_id_t uid) 103 { 104 ValueObjectSP valobj_sp; 105 collection::iterator pos, end = m_value_objects.end(); 106 107 for (pos = m_value_objects.begin(); pos != end; ++pos) 108 { 109 // Watch out for NULL objects in our list as the list 110 // might get resized to a specific size and lazily filled in 111 ValueObject *valobj = (*pos).get(); 112 if (valobj && valobj->GetID() == uid) 113 { 114 valobj_sp = *pos; 115 break; 116 } 117 } 118 return valobj_sp; 119 } 120 121 122 ValueObjectSP 123 ValueObjectList::FindValueObjectByPointer (ValueObject *find_valobj) 124 { 125 ValueObjectSP valobj_sp; 126 collection::iterator pos, end = m_value_objects.end(); 127 128 for (pos = m_value_objects.begin(); pos != end; ++pos) 129 { 130 ValueObject *valobj = (*pos).get(); 131 if (valobj && valobj == find_valobj) 132 { 133 valobj_sp = *pos; 134 break; 135 } 136 } 137 return valobj_sp; 138 } 139 140 void 141 ValueObjectList::Swap (ValueObjectList &value_object_list) 142 { 143 m_value_objects.swap (value_object_list.m_value_objects); 144 } 145