1 //===-- UniqueDWARFASTType.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 "UniqueDWARFASTType.h" 11 12 #include "lldb/Symbol/Declaration.h" 13 Find(const DWARFDIE & die,const lldb_private::Declaration & decl,const int32_t byte_size,UniqueDWARFASTType & entry) const14bool UniqueDWARFASTTypeList::Find(const DWARFDIE &die, 15 const lldb_private::Declaration &decl, 16 const int32_t byte_size, 17 UniqueDWARFASTType &entry) const { 18 for (const UniqueDWARFASTType &udt : m_collection) { 19 // Make sure the tags match 20 if (udt.m_die.Tag() == die.Tag()) { 21 // Validate byte sizes of both types only if both are valid. 22 if (udt.m_byte_size < 0 || byte_size < 0 || 23 udt.m_byte_size == byte_size) { 24 // Make sure the file and line match 25 if (udt.m_declaration == decl) { 26 // The type has the same name, and was defined on the same file and 27 // line. Now verify all of the parent DIEs match. 28 DWARFDIE parent_arg_die = die.GetParent(); 29 DWARFDIE parent_pos_die = udt.m_die.GetParent(); 30 bool match = true; 31 bool done = false; 32 while (!done && match && parent_arg_die && parent_pos_die) { 33 const dw_tag_t parent_arg_tag = parent_arg_die.Tag(); 34 const dw_tag_t parent_pos_tag = parent_pos_die.Tag(); 35 if (parent_arg_tag == parent_pos_tag) { 36 switch (parent_arg_tag) { 37 case DW_TAG_class_type: 38 case DW_TAG_structure_type: 39 case DW_TAG_union_type: 40 case DW_TAG_namespace: { 41 const char *parent_arg_die_name = parent_arg_die.GetName(); 42 if (parent_arg_die_name == 43 NULL) // Anonymous (i.e. no-name) struct 44 { 45 match = false; 46 } else { 47 const char *parent_pos_die_name = parent_pos_die.GetName(); 48 if (parent_pos_die_name == NULL || 49 ((parent_arg_die_name != parent_pos_die_name) && 50 strcmp(parent_arg_die_name, parent_pos_die_name))) 51 match = false; 52 } 53 } break; 54 55 case DW_TAG_compile_unit: 56 case DW_TAG_partial_unit: 57 done = true; 58 break; 59 } 60 } 61 parent_arg_die = parent_arg_die.GetParent(); 62 parent_pos_die = parent_pos_die.GetParent(); 63 } 64 65 if (match) { 66 entry = udt; 67 return true; 68 } 69 } 70 } 71 } 72 } 73 return false; 74 } 75