1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-25 14:25:07 +00:00
serenity/Userland/Libraries/LibDebug/Dwarf/Expression.cpp
Brian Gianforcaro 1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00

44 lines
1.1 KiB
C++

/*
* Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "Expression.h"
#include <AK/MemoryStream.h>
#include <sys/arch/i386/regs.h>
namespace Debug::Dwarf::Expression {
Value evaluate(ReadonlyBytes bytes, const PtraceRegisters& regs)
{
InputMemoryStream stream(bytes);
while (!stream.eof()) {
u8 opcode = 0;
stream >> opcode;
switch (static_cast<Operations>(opcode)) {
case Operations::RegEbp: {
ssize_t offset = 0;
stream.read_LEB128_signed(offset);
return Value { Type::UnsignedIntetger, regs.ebp + offset };
}
case Operations::FbReg: {
ssize_t offset = 0;
stream.read_LEB128_signed(offset);
return Value { Type::UnsignedIntetger, regs.ebp + 2 * sizeof(size_t) + offset };
}
default:
dbgln("DWARF expr addr: {}", (const void*)bytes.data());
dbgln("unsupported opcode: {}", (u8)opcode);
VERIFY_NOT_REACHED();
}
}
VERIFY_NOT_REACHED();
}
}