1 //===-- DWARFDIECollection.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 "DWARFDIECollection.h" 11 12 #include <algorithm> 13 14 #include "lldb/Core/Stream.h" 15 16 #include "DWARFDebugInfoEntry.h" 17 18 using namespace lldb_private; 19 using namespace std; 20 21 bool 22 DWARFDIECollection::Insert(const DWARFDebugInfoEntry *die) 23 { 24 iterator end_pos = m_dies.end(); 25 iterator insert_pos = upper_bound(m_dies.begin(), end_pos, die); 26 if (insert_pos != end_pos && (*insert_pos == die)) 27 return false; 28 m_dies.insert(insert_pos, die); 29 return true; 30 } 31 32 void 33 DWARFDIECollection::Append (const DWARFDebugInfoEntry *die) 34 { 35 m_dies.push_back (die); 36 } 37 38 const DWARFDebugInfoEntry * 39 DWARFDIECollection::GetDIEPtrAtIndex(uint32_t idx) const 40 { 41 if (idx < m_dies.size()) 42 return m_dies[idx]; 43 return NULL; 44 } 45 46 47 size_t 48 DWARFDIECollection::Size() const 49 { 50 return m_dies.size(); 51 } 52 53 void 54 DWARFDIECollection::Dump(Stream *s, const char* title) const 55 { 56 if (title && title[0] != '\0') 57 s->Printf( "%s\n", title); 58 const_iterator end_pos = m_dies.end(); 59 const_iterator pos; 60 for (pos = m_dies.begin(); pos != end_pos; ++pos) 61 s->Printf( "0x%8.8x\n", (*pos)->GetOffset()); 62 } 63