size_t NameToDIE::Find (const lldb_private::RegularExpression& regex, std::vector<Info> &info_array) const { const size_t initial_info_array_size = info_array.size(); collection::const_iterator pos, end = m_collection.end(); for (pos = m_collection.begin(); pos != end; ++pos) { if (regex.Execute(pos->first)) info_array.push_back (pos->second); } return info_array.size() - initial_info_array_size; }
DWARFMappedHash::MemoryTable::Result DWARFMappedHash::MemoryTable::AppendHashDataForRegularExpression ( const lldb_private::RegularExpression& regex, lldb::offset_t* hash_data_offset_ptr, Pair &pair) const { pair.key = m_data.GetU32 (hash_data_offset_ptr); // If the key is zero, this terminates our chain of HashData objects // for this hash value. if (pair.key == 0) return eResultEndOfHashData; // There definitely should be a string for this string offset, if // there isn't, there is something wrong, return and error const char *strp_cstr = m_string_table.PeekCStr (pair.key); if (strp_cstr == NULL) return eResultError; const uint32_t count = m_data.GetU32 (hash_data_offset_ptr); const size_t min_total_hash_data_size = count * m_header.header_data.GetMinimumHashDataByteSize(); if (count > 0 && m_data.ValidOffsetForDataOfSize (*hash_data_offset_ptr, min_total_hash_data_size)) { const bool match = regex.Execute(strp_cstr); if (!match && m_header.header_data.HashDataHasFixedByteSize()) { // If the regex doesn't match and we have fixed size data, // we can just add the total byte size of all HashData objects // to the hash data offset and be done... *hash_data_offset_ptr += min_total_hash_data_size; } else { // If the string does match, or we don't have fixed size data // then we need to read the hash data as a stream. If the // string matches we also append all HashData objects to the // value array. for (uint32_t i=0; i<count; ++i) { DIEInfo die_info; if (m_header.Read(m_data, hash_data_offset_ptr, die_info)) { // Only happened if the HashData of the string matched... if (match) pair.value.push_back (die_info); } else { // Something went wrong while reading the data *hash_data_offset_ptr = UINT32_MAX; return eResultError; } } } // Return the correct response depending on if the string matched // or not... if (match) return eResultKeyMatch; // The key (cstring) matches and we have lookup results! else return eResultKeyMismatch; // The key doesn't match, this function will get called // again for the next key/value or the key terminator // which in our case is a zero .debug_str offset. } else { *hash_data_offset_ptr = UINT32_MAX; return eResultError; } }