2021-06-18 14:15:01 +03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2021, Itamar S. <itamar8910@gmail.com>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2021-10-09 16:58:48 +02:00
|
|
|
#include <AK/Span.h>
|
2021-06-18 14:15:01 +03:00
|
|
|
#include <AK/Types.h>
|
2021-06-19 11:34:59 +03:00
|
|
|
#include <LibDebug/Dwarf/DwarfTypes.h>
|
2021-06-18 14:15:01 +03:00
|
|
|
|
|
|
|
|
namespace Debug::Dwarf {
|
|
|
|
|
|
2021-10-09 16:58:48 +02:00
|
|
|
class CompilationUnit;
|
|
|
|
|
|
|
|
|
|
class AttributeValue {
|
|
|
|
|
friend class DwarfInfo;
|
|
|
|
|
|
|
|
|
|
public:
|
2021-06-18 14:15:01 +03:00
|
|
|
enum class Type : u8 {
|
|
|
|
|
UnsignedNumber,
|
|
|
|
|
SignedNumber,
|
|
|
|
|
String,
|
|
|
|
|
DieReference, // Reference to another DIE in the same compilation unit
|
|
|
|
|
Boolean,
|
|
|
|
|
DwarfExpression,
|
|
|
|
|
SecOffset,
|
|
|
|
|
RawBytes,
|
2021-10-09 16:58:48 +02:00
|
|
|
Address
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Type type() const { return m_type; }
|
|
|
|
|
AttributeDataForm form() const { return m_form; }
|
2021-06-18 14:15:01 +03:00
|
|
|
|
2021-10-09 16:58:48 +02:00
|
|
|
FlatPtr as_addr() const { return m_data.as_addr; }
|
|
|
|
|
u64 as_unsigned() const { return m_data.as_unsigned; }
|
|
|
|
|
i64 as_signed() const { return m_data.as_signed; }
|
|
|
|
|
const char* as_string() const { return m_data.as_string; }
|
|
|
|
|
bool as_bool() const { return m_data.as_bool; }
|
|
|
|
|
ReadonlyBytes as_raw_bytes() const { return m_data.as_raw_bytes; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Type m_type;
|
2021-06-18 14:15:01 +03:00
|
|
|
union {
|
2021-07-13 18:16:36 +02:00
|
|
|
FlatPtr as_addr;
|
2021-07-27 11:03:24 +02:00
|
|
|
u64 as_unsigned;
|
|
|
|
|
i64 as_signed;
|
2021-06-18 14:15:01 +03:00
|
|
|
const char* as_string; // points to bytes in the memory mapped elf image
|
|
|
|
|
bool as_bool;
|
2021-10-09 16:58:48 +02:00
|
|
|
ReadonlyBytes as_raw_bytes;
|
|
|
|
|
} m_data {};
|
|
|
|
|
|
|
|
|
|
AttributeDataForm m_form {};
|
2021-06-19 11:34:59 +03:00
|
|
|
|
2021-10-09 16:58:48 +02:00
|
|
|
CompilationUnit const* m_compilation_unit { nullptr };
|
2021-06-18 14:15:01 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|