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
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
2020-05-28 20:40:53 +02:00
|
|
|
|
2020-05-04 12:14:39 +03:00
|
|
|
#include "AbbreviationsMap.h"
|
2021-06-18 15:25:27 +03:00
|
|
|
#include "DIE.h"
|
|
|
|
|
#include "LineProgram.h"
|
2021-06-18 14:31:03 +03:00
|
|
|
#include <AK/Noncopyable.h>
|
2020-05-04 12:14:39 +03:00
|
|
|
#include <AK/Types.h>
|
|
|
|
|
|
2020-08-25 04:33:07 +01:00
|
|
|
namespace Debug::Dwarf {
|
2020-05-04 12:14:39 +03:00
|
|
|
|
|
|
|
|
class DwarfInfo;
|
|
|
|
|
class DIE;
|
2021-06-18 15:25:27 +03:00
|
|
|
class LineProgram;
|
2020-05-04 12:14:39 +03:00
|
|
|
|
|
|
|
|
class CompilationUnit {
|
2021-06-18 14:31:03 +03:00
|
|
|
AK_MAKE_NONCOPYABLE(CompilationUnit);
|
|
|
|
|
AK_MAKE_NONMOVABLE(CompilationUnit);
|
|
|
|
|
|
2020-05-04 12:14:39 +03:00
|
|
|
public:
|
2021-06-19 15:33:03 +03:00
|
|
|
CompilationUnit(DwarfInfo const& dwarf_info, u32 offset, CompilationUnitHeader const&, NonnullOwnPtr<LineProgram>&& line_program);
|
2020-05-04 12:14:39 +03:00
|
|
|
|
|
|
|
|
u32 offset() const { return m_offset; }
|
2021-04-28 22:13:58 +02:00
|
|
|
u32 size() const { return m_header.length() + sizeof(u32); }
|
2020-05-04 12:14:39 +03:00
|
|
|
|
|
|
|
|
DIE root_die() const;
|
2021-06-12 10:29:33 +03:00
|
|
|
DIE get_die_at_offset(u32 offset) const;
|
2020-05-04 12:14:39 +03:00
|
|
|
|
2021-10-09 17:38:26 +02:00
|
|
|
FlatPtr get_address(size_t index) const;
|
|
|
|
|
char const* get_string(size_t index) const;
|
|
|
|
|
|
2021-06-19 15:33:03 +03:00
|
|
|
DwarfInfo const& dwarf_info() const { return m_dwarf_info; }
|
|
|
|
|
AbbreviationsMap const& abbreviations_map() const { return m_abbreviations; }
|
|
|
|
|
LineProgram const& line_program() const { return *m_line_program; }
|
2021-09-28 13:26:49 +03:00
|
|
|
Optional<FlatPtr> base_address() const;
|
2020-05-04 12:14:39 +03:00
|
|
|
|
2021-10-09 17:38:26 +02:00
|
|
|
// DW_AT_addr_base
|
|
|
|
|
u64 address_table_base() const;
|
|
|
|
|
// DW_AT_str_offsets_base
|
|
|
|
|
u64 string_offsets_base() const;
|
|
|
|
|
// DW_AT_rnglists_base
|
|
|
|
|
u64 range_lists_base() const;
|
|
|
|
|
|
2020-05-04 12:14:39 +03:00
|
|
|
private:
|
2021-06-19 15:33:03 +03:00
|
|
|
DwarfInfo const& m_dwarf_info;
|
2020-05-04 12:14:39 +03:00
|
|
|
u32 m_offset { 0 };
|
|
|
|
|
CompilationUnitHeader m_header;
|
|
|
|
|
AbbreviationsMap m_abbreviations;
|
2021-06-18 15:25:27 +03:00
|
|
|
NonnullOwnPtr<LineProgram> m_line_program;
|
2021-10-09 17:38:26 +02:00
|
|
|
mutable bool m_has_cached_base_address : 1 { false };
|
|
|
|
|
mutable bool m_has_cached_address_table_base : 1 { false };
|
|
|
|
|
mutable bool m_has_cached_string_offsets_base : 1 { false };
|
|
|
|
|
mutable bool m_has_cached_range_lists_base : 1 { false };
|
2021-09-28 13:26:49 +03:00
|
|
|
mutable Optional<FlatPtr> m_cached_base_address;
|
2021-10-09 17:38:26 +02:00
|
|
|
mutable u64 m_cached_address_table_base { 0 };
|
|
|
|
|
mutable u64 m_cached_string_offsets_base { 0 };
|
|
|
|
|
mutable u64 m_cached_range_lists_base { 0 };
|
2020-05-04 12:14:39 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|