ValueObjectList.cpp revision 17dae081d7b88d24a7af6b07c10fc5981f81e2a9
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 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 54uint32_t 55ValueObjectList::GetSize() const 56{ 57 return m_value_objects.size(); 58} 59 60void 61ValueObjectList::Resize (uint32_t size) 62{ 63 m_value_objects.resize (size); 64} 65 66lldb::ValueObjectSP 67ValueObjectList::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 75void 76ValueObjectList::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 83ValueObjectSP 84ValueObjectList::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 101ValueObjectSP 102ValueObjectList::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 122ValueObjectSP 123ValueObjectList::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 140void 141ValueObjectList::Swap (ValueObjectList &value_object_list) 142{ 143 m_value_objects.swap (value_object_list.m_value_objects); 144} 145