1254721Semaste//===-- UniqueDWARFASTType.cpp ----------------------------------*- C++ -*-===// 2254721Semaste// 3254721Semaste// The LLVM Compiler Infrastructure 4254721Semaste// 5254721Semaste// This file is distributed under the University of Illinois Open Source 6254721Semaste// License. See LICENSE.TXT for details. 7254721Semaste// 8254721Semaste//===----------------------------------------------------------------------===// 9254721Semaste 10254721Semaste#include "UniqueDWARFASTType.h" 11254721Semaste 12254721Semaste// C Includes 13254721Semaste// C++ Includes 14254721Semaste// Other libraries and framework includes 15254721Semaste// Project includes 16254721Semaste#include "lldb/Symbol/Declaration.h" 17254721Semaste 18254721Semaste#include "DWARFDebugInfoEntry.h" 19254721Semaste 20254721Semastebool 21254721SemasteUniqueDWARFASTTypeList::Find 22254721Semaste( 23254721Semaste SymbolFileDWARF *symfile, 24254721Semaste const DWARFCompileUnit *cu, 25254721Semaste const DWARFDebugInfoEntry *die, 26254721Semaste const lldb_private::Declaration &decl, 27254721Semaste const int32_t byte_size, 28254721Semaste UniqueDWARFASTType &entry 29254721Semaste) const 30254721Semaste{ 31254721Semaste collection::const_iterator pos, end = m_collection.end(); 32254721Semaste for (pos = m_collection.begin(); pos != end; ++pos) 33254721Semaste { 34254721Semaste // Make sure the tags match 35254721Semaste if (pos->m_die->Tag() == die->Tag()) 36254721Semaste { 37254721Semaste // Validate byte sizes of both types only if both are valid. 38254721Semaste if (pos->m_byte_size < 0 || byte_size < 0 || pos->m_byte_size == byte_size) 39254721Semaste { 40254721Semaste // Make sure the file and line match 41254721Semaste if (pos->m_declaration == decl) 42254721Semaste { 43254721Semaste // The type has the same name, and was defined on the same 44254721Semaste // file and line. Now verify all of the parent DIEs match. 45254721Semaste const DWARFDebugInfoEntry *parent_arg_die = die->GetParent(); 46254721Semaste const DWARFDebugInfoEntry *parend_pos_die = pos->m_die->GetParent(); 47254721Semaste bool match = true; 48254721Semaste bool done = false; 49254721Semaste while (!done && match && parent_arg_die && parend_pos_die) 50254721Semaste { 51254721Semaste if (parent_arg_die->Tag() == parend_pos_die->Tag()) 52254721Semaste { 53254721Semaste const dw_tag_t tag = parent_arg_die->Tag(); 54254721Semaste switch (tag) 55254721Semaste { 56254721Semaste case DW_TAG_class_type: 57254721Semaste case DW_TAG_structure_type: 58254721Semaste case DW_TAG_union_type: 59254721Semaste case DW_TAG_namespace: 60254721Semaste { 61254721Semaste const char *parent_arg_die_name = parent_arg_die->GetName(symfile, cu); 62254721Semaste if (parent_arg_die_name == NULL) // Anonymous (i.e. no-name) struct 63254721Semaste { 64254721Semaste match = false; 65254721Semaste } 66254721Semaste else 67254721Semaste { 68254721Semaste const char *parent_pos_die_name = parend_pos_die->GetName(pos->m_symfile, pos->m_cu); 69254721Semaste if (parent_pos_die_name == NULL || strcmp (parent_arg_die_name, parent_pos_die_name)) 70254721Semaste match = false; 71254721Semaste } 72254721Semaste } 73254721Semaste break; 74254721Semaste 75254721Semaste case DW_TAG_compile_unit: 76254721Semaste done = true; 77254721Semaste break; 78254721Semaste } 79254721Semaste } 80254721Semaste parent_arg_die = parent_arg_die->GetParent(); 81254721Semaste parend_pos_die = parend_pos_die->GetParent(); 82254721Semaste } 83254721Semaste 84254721Semaste if (match) 85254721Semaste { 86254721Semaste entry = *pos; 87254721Semaste return true; 88254721Semaste } 89254721Semaste } 90254721Semaste } 91254721Semaste } 92254721Semaste } 93254721Semaste return false; 94254721Semaste} 95