1 //===-- NameToDIE.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 "NameToDIE.h" 11 #include "lldb/Core/Stream.h" 12 13 size_t 14 NameToDIE::Find (const lldb_private::ConstString &name, std::vector<Info> &info_array) const 15 { 16 const char *name_cstr = name.AsCString(); 17 const size_t initial_info_array_size = info_array.size(); 18 collection::const_iterator pos, end = m_collection.end(); 19 for (pos = m_collection.lower_bound (name_cstr); pos != end && pos->first == name_cstr; ++pos) 20 { 21 info_array.push_back (pos->second); 22 } 23 return info_array.size() - initial_info_array_size; 24 } 25 26 size_t 27 NameToDIE::Find (const lldb_private::RegularExpression& regex, std::vector<Info> &info_array) const 28 { 29 const size_t initial_info_array_size = info_array.size(); 30 collection::const_iterator pos, end = m_collection.end(); 31 for (pos = m_collection.begin(); pos != end; ++pos) 32 { 33 if (regex.Execute(pos->first)) 34 info_array.push_back (pos->second); 35 } 36 return info_array.size() - initial_info_array_size; 37 } 38 39 size_t 40 NameToDIE::FindAllEntriesForCompileUnitWithIndex (const uint32_t cu_idx, std::vector<Info> &info_array) const 41 { 42 const size_t initial_info_array_size = info_array.size(); 43 collection::const_iterator pos, end = m_collection.end(); 44 for (pos = m_collection.begin(); pos != end; ++pos) 45 { 46 if (cu_idx == pos->second.cu_idx) 47 info_array.push_back (pos->second); 48 } 49 return info_array.size() - initial_info_array_size; 50 } 51 52 void 53 NameToDIE::Dump (lldb_private::Stream *s) 54 { 55 collection::const_iterator pos, end = m_collection.end(); 56 for (pos = m_collection.begin(); pos != end; ++pos) 57 { 58 s->Printf("%p: 0x%8.8x 0x%8.8x \"%s\"\n", pos->first, pos->second.cu_idx, pos->second.die_idx, pos->first); 59 } 60 } 61