2020-05-04 12:14:39 +03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-05-04 12:14:39 +03:00
|
|
|
*/
|
2021-05-15 00:27:09 +01:00
|
|
|
|
2020-05-04 12:14:39 +03:00
|
|
|
#include "CompilationUnit.h"
|
|
|
|
|
#include "DIE.h"
|
|
|
|
|
|
2020-08-25 04:33:07 +01:00
|
|
|
namespace Debug::Dwarf {
|
2020-05-04 12:14:39 +03:00
|
|
|
|
2021-06-19 15:33:03 +03:00
|
|
|
CompilationUnit::CompilationUnit(DwarfInfo const& dwarf_info, u32 offset, CompilationUnitHeader const& header, NonnullOwnPtr<LineProgram>&& line_program)
|
2020-05-04 12:14:39 +03:00
|
|
|
: m_dwarf_info(dwarf_info)
|
|
|
|
|
, m_offset(offset)
|
|
|
|
|
, m_header(header)
|
2021-04-28 22:13:58 +02:00
|
|
|
, m_abbreviations(dwarf_info, header.abbrev_offset())
|
2021-06-18 15:25:27 +03:00
|
|
|
, m_line_program(move(line_program))
|
2020-05-04 12:14:39 +03:00
|
|
|
{
|
2021-04-28 22:13:58 +02:00
|
|
|
VERIFY(header.version() < 5 || header.unit_type() == CompilationUnitType::Full);
|
2020-05-04 12:14:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DIE CompilationUnit::root_die() const
|
|
|
|
|
{
|
2021-04-28 22:13:58 +02:00
|
|
|
return DIE(*this, m_offset + m_header.header_size());
|
2020-05-04 12:14:39 +03:00
|
|
|
}
|
|
|
|
|
|
2021-06-12 10:29:33 +03:00
|
|
|
DIE CompilationUnit::get_die_at_offset(u32 die_offset) const
|
|
|
|
|
{
|
|
|
|
|
VERIFY(die_offset >= offset() && die_offset < offset() + size());
|
|
|
|
|
return DIE(*this, die_offset);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-04 12:14:39 +03:00
|
|
|
}
|