Example #1
0
bool
DWARFCompileUnit::Extract(const DWARFDataExtractor &debug_info, lldb::offset_t *offset_ptr)
{
    Clear();

    m_offset = *offset_ptr;

    if (debug_info.ValidOffset(*offset_ptr))
    {
        dw_offset_t abbr_offset;
        const DWARFDebugAbbrev *abbr = m_dwarf2Data->DebugAbbrev();
        m_length        = debug_info.GetDWARFInitialLength(offset_ptr);
        m_is_dwarf64    = debug_info.IsDWARF64();
        m_version       = debug_info.GetU16(offset_ptr);
        abbr_offset     = debug_info.GetDWARFOffset(offset_ptr);
        m_addr_size     = debug_info.GetU8 (offset_ptr);

        bool length_OK = debug_info.ValidOffset(GetNextCompileUnitOffset()-1);
        bool version_OK = SymbolFileDWARF::SupportedVersion(m_version);
        bool abbr_offset_OK = m_dwarf2Data->get_debug_abbrev_data().ValidOffset(abbr_offset);
        bool addr_size_OK = ((m_addr_size == 4) || (m_addr_size == 8));

        if (length_OK && version_OK && addr_size_OK && abbr_offset_OK && abbr != NULL)
        {
            m_abbrevs = abbr->GetAbbreviationDeclarationSet(abbr_offset);
            return true;
        }

        // reset the offset to where we tried to parse from if anything went wrong
        *offset_ptr = m_offset;
    }

    return false;
}
bool
DWARFDebugPubnames::Extract(const DWARFDataExtractor& data)
{
    Timer scoped_timer (__PRETTY_FUNCTION__,
                        "DWARFDebugPubnames::Extract (byte_size = %" PRIu64 ")",
                        (uint64_t)data.GetByteSize());
    Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_PUBNAMES));
    if (log)
        log->Printf("DWARFDebugPubnames::Extract (byte_size = %" PRIu64 ")", (uint64_t)data.GetByteSize());

    if (data.ValidOffset(0))
    {
        lldb::offset_t offset = 0;

        DWARFDebugPubnamesSet set;
        while (data.ValidOffset(offset))
        {
            if (set.Extract(data, &offset))
            {
                m_sets.push_back(set);
                offset = set.GetOffsetOfNextEntry();
            }
            else
                break;
        }
        if (log)
            Dump (log);
        return true;
    }
    return false;
}
bool
DWARFAbbreviationDeclaration::Extract(const DWARFDataExtractor& data, lldb::offset_t *offset_ptr, dw_uleb128_t code)
{
    m_code = code;
    m_attributes.clear();
    if (m_code)
    {
        m_tag = data.GetULEB128(offset_ptr);
        m_has_children = data.GetU8(offset_ptr);

        while (data.ValidOffset(*offset_ptr))
        {
            dw_attr_t attr = data.GetULEB128(offset_ptr);
            dw_form_t form = data.GetULEB128(offset_ptr);

            if (attr && form)
                m_attributes.push_back(DWARFAttribute(attr, form));
            else
                break;
        }

        return m_tag != 0;
    }
    else
    {
        m_tag = 0;
        m_has_children = 0;
    }

    return false;
}
Example #4
0
//----------------------------------------------------------------------
// DWARFDebugAbbrev::Parse()
//----------------------------------------------------------------------
void DWARFDebugAbbrev::Parse(const DWARFDataExtractor &data) {
  lldb::offset_t offset = 0;

  while (data.ValidOffset(offset)) {
    uint32_t initial_cu_offset = offset;
    DWARFAbbreviationDeclarationSet abbrevDeclSet;

    if (abbrevDeclSet.Extract(data, &offset))
      m_abbrevCollMap[initial_cu_offset] = abbrevDeclSet;
    else
      break;
  }
  m_prev_abbr_offset_pos = m_abbrevCollMap.end();
}
//----------------------------------------------------------------------
// Extract
//----------------------------------------------------------------------
bool DWARFDebugAranges::Extract(const DWARFDataExtractor &debug_aranges_data) {
  if (debug_aranges_data.ValidOffset(0)) {
    lldb::offset_t offset = 0;

    DWARFDebugArangeSet set;
    Range range;
    while (set.Extract(debug_aranges_data, &offset)) {
      const uint32_t num_descriptors = set.NumDescriptors();
      if (num_descriptors > 0) {
        const dw_offset_t cu_offset = set.GetCompileUnitDIEOffset();

        for (uint32_t i = 0; i < num_descriptors; ++i) {
          const DWARFDebugArangeSet::Descriptor &descriptor =
              set.GetDescriptorRef(i);
          m_aranges.Append(RangeToDIE::Entry(descriptor.address,
                                             descriptor.length, cu_offset));
        }
      }
      set.Clear();
    }
  }
  return false;
}