1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:07:34 +00:00

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.
This commit is contained in:
Daniel Bertalan 2021-10-09 17:38:26 +02:00 committed by Linus Groh
parent 8e5b70a0ba
commit ac53569bd1
7 changed files with 213 additions and 3 deletions

View file

@ -0,0 +1,49 @@
/*
* Copyright (c) 2021, Daniel Bertalan <dani@danielbertalan.dev>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "AttributeValue.h"
#include "CompilationUnit.h"
namespace Debug::Dwarf {
FlatPtr AttributeValue::as_addr() const
{
switch (m_form) {
case AttributeDataForm::Addr:
return m_data.as_addr;
case AttributeDataForm::AddrX:
case AttributeDataForm::AddrX1:
case AttributeDataForm::AddrX2:
case AttributeDataForm::AddrX3:
case AttributeDataForm::AddrX4: {
auto index = m_data.as_unsigned;
return m_compilation_unit->get_address(index);
}
default:
VERIFY_NOT_REACHED();
}
}
char const* AttributeValue::as_string() const
{
switch (m_form) {
case AttributeDataForm::String:
case AttributeDataForm::StringPointer:
case AttributeDataForm::LineStrP:
return m_data.as_string;
case AttributeDataForm::StrX:
case AttributeDataForm::StrX1:
case AttributeDataForm::StrX2:
case AttributeDataForm::StrX3:
case AttributeDataForm::StrX4: {
auto index = m_data.as_unsigned;
return m_compilation_unit->get_string(index);
}
default:
VERIFY_NOT_REACHED();
}
}
}