ladybird/Userland/Libraries/LibDebug/Dwarf/AttributeValue.h
Daniel Bertalan ac53569bd1 LibDebug: Support addrx*, strx* and rnglistx forms
These forms were introduced in DWARF5, and have a fair deal of
advantages over the more traditional encodings: they reduce the size of
the binary and the number of relocations.

GCC does not emit these with `-g1` by default, but Clang does at all
debug levels.
2021-10-17 17:09:58 +01:00

59 lines
1.3 KiB
C++

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