CompilationUnit.cpp 875 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include "CompilationUnit.h"
  7. #include "DIE.h"
  8. namespace Debug::Dwarf {
  9. CompilationUnit::CompilationUnit(const DwarfInfo& dwarf_info, u32 offset, const CompilationUnitHeader& header, NonnullOwnPtr<LineProgram>&& line_program)
  10. : m_dwarf_info(dwarf_info)
  11. , m_offset(offset)
  12. , m_header(header)
  13. , m_abbreviations(dwarf_info, header.abbrev_offset())
  14. , m_line_program(move(line_program))
  15. {
  16. VERIFY(header.version() < 5 || header.unit_type() == CompilationUnitType::Full);
  17. }
  18. DIE CompilationUnit::root_die() const
  19. {
  20. return DIE(*this, m_offset + m_header.header_size());
  21. }
  22. DIE CompilationUnit::get_die_at_offset(u32 die_offset) const
  23. {
  24. VERIFY(die_offset >= offset() && die_offset < offset() + size());
  25. return DIE(*this, die_offset);
  26. }
  27. }