void
DWARFMappedHash::ExtractClassOrStructDIEArray (const DIEInfoArray &die_info_array,
                                               bool return_implementation_only_if_available,
                                               DIEArray &die_offsets)
{
    const size_t count = die_info_array.size();
    for (size_t i=0; i<count; ++i)
    {
        const dw_tag_t die_tag = die_info_array[i].tag;
        if (die_tag == 0 || die_tag == DW_TAG_class_type || die_tag == DW_TAG_structure_type)
        {
            if (die_info_array[i].type_flags & eTypeFlagClassIsImplementation)
            {
                if (return_implementation_only_if_available)
                {
                    // We found the one true definition for this class, so
                    // only return that
                    die_offsets.clear();                        
                    die_offsets.emplace_back(die_info_array[i].cu_offset, die_info_array[i].offset);
                    return;
                }
                else
                {
                    // Put the one true definition as the first entry so it
                    // matches first
                    die_offsets.emplace(die_offsets.begin(), die_info_array[i].cu_offset, die_info_array[i].offset);
                }
            }
            else
            {
                die_offsets.emplace_back(die_info_array[i].cu_offset, die_info_array[i].offset);
            }
        }
    }
}
示例#2
0
size_t NameToDIE::FindAllEntriesForCompileUnit(dw_offset_t cu_offset,
                                               DIEArray &info_array) const {
  const size_t initial_size = info_array.size();
  const uint32_t size = m_map.GetSize();
  for (uint32_t i = 0; i < size; ++i) {
    const DIERef &die_ref = m_map.GetValueAtIndexUnchecked(i);
    if (cu_offset == die_ref.cu_offset)
      info_array.push_back(die_ref);
  }
  return info_array.size() - initial_size;
}
示例#3
0
void ManualDWARFIndex::GetFunctions(ConstString name, DWARFDebugInfo &info,
                                    const CompilerDeclContext &parent_decl_ctx,
                                    uint32_t name_type_mask,
                                    std::vector<DWARFDIE> &dies) {
  Index();

  if (name_type_mask & eFunctionNameTypeFull) {
    DIEArray offsets;
    m_set.function_basenames.Find(name, offsets);
    m_set.function_methods.Find(name, offsets);
    m_set.function_fullnames.Find(name, offsets);
    for (const DIERef &die_ref: offsets) {
      DWARFDIE die = info.GetDIE(die_ref);
      if (!die)
        continue;
      if (SymbolFileDWARF::DIEInDeclContext(&parent_decl_ctx, die))
        dies.push_back(die);
    }
  }
  if (name_type_mask & eFunctionNameTypeBase) {
    DIEArray offsets;
    m_set.function_basenames.Find(name, offsets);
    for (const DIERef &die_ref: offsets) {
      DWARFDIE die = info.GetDIE(die_ref);
      if (!die)
        continue;
      if (SymbolFileDWARF::DIEInDeclContext(&parent_decl_ctx, die))
        dies.push_back(die);
    }
    offsets.clear();
  }

  if (name_type_mask & eFunctionNameTypeMethod && !parent_decl_ctx.IsValid()) {
    DIEArray offsets;
    m_set.function_methods.Find(name, offsets);
    for (const DIERef &die_ref: offsets) {
      if (DWARFDIE die = info.GetDIE(die_ref))
        dies.push_back(die);
    }
  }

  if (name_type_mask & eFunctionNameTypeSelector &&
      !parent_decl_ctx.IsValid()) {
    DIEArray offsets;
    m_set.function_selectors.Find(name, offsets);
    for (const DIERef &die_ref: offsets) {
      if (DWARFDIE die = info.GetDIE(die_ref))
        dies.push_back(die);
    }
  }
}
size_t
DWARFMappedHash::MemoryTable::FindCompleteObjCClassByName (const char *name,
                                                           DIEArray &die_offsets,
                                                           bool must_be_implementation)
{
    DIEInfoArray die_info_array;
    if (FindByName(name, die_info_array))
    {
        if (must_be_implementation && GetHeader().header_data.ContainsAtom (eAtomTypeTypeFlags))
        {
            // If we have two atoms, then we have the DIE offset and
            // the type flags so we can find the objective C class
            // efficiently.
            DWARFMappedHash::ExtractTypesFromDIEArray (die_info_array, 
                                                       UINT32_MAX,
                                                       eTypeFlagClassIsImplementation,
                                                       die_offsets);
        }
        else
        {
            // We don't only want the one true definition, so try and see
            // what we can find, and only return class or struct DIEs.
            // If we do have the full implementation, then return it alone,
            // else return all possible matches.
            const bool return_implementation_only_if_available = true;
            DWARFMappedHash::ExtractClassOrStructDIEArray (die_info_array, 
                                                           return_implementation_only_if_available,
                                                           die_offsets);
        }
    }
    return die_offsets.size();
}
void
DWARFMappedHash::ExtractDIEArray (const DIEInfoArray &die_info_array,
                                  const dw_tag_t tag,
                                  const uint32_t qualified_name_hash,
                                  DIEArray &die_offsets)
{
    if (tag == 0)
    {
        ExtractDIEArray (die_info_array, die_offsets);
    }
    else
    {
        const size_t count = die_info_array.size();
        for (size_t i=0; i<count; ++i)
        {
            if (qualified_name_hash != die_info_array[i].qualified_name_hash)
                continue;
            const dw_tag_t die_tag = die_info_array[i].tag;
            bool tag_matches = die_tag == 0 || tag == die_tag;
            if (!tag_matches)
            {
                if (die_tag == DW_TAG_class_type || die_tag == DW_TAG_structure_type)
                    tag_matches = tag == DW_TAG_structure_type || tag == DW_TAG_class_type;
            }
            if (tag_matches)
                die_offsets.emplace_back(die_info_array[i].cu_offset, die_info_array[i].offset);
        }
    }
}
void
DWARFMappedHash::ExtractDIEArray (const DIEInfoArray &die_info_array, DIEArray &die_offsets)
{
    const size_t count = die_info_array.size();
    for (size_t i=0; i<count; ++i)
        die_offsets.emplace_back(die_info_array[i].cu_offset, die_info_array[i].offset);
}
void
DWARFMappedHash::ExtractTypesFromDIEArray (const DIEInfoArray &die_info_array,
                                           uint32_t type_flag_mask,
                                           uint32_t type_flag_value,
                                           DIEArray &die_offsets)
{
    const size_t count = die_info_array.size();
    for (size_t i=0; i<count; ++i)
    {
        if ((die_info_array[i].type_flags & type_flag_mask) == type_flag_value)
            die_offsets.emplace_back(die_info_array[i].cu_offset, die_info_array[i].offset);
    }
}