blob: 0924219770a45ef4f36be7b464d5203902275923 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
/*
* Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "Expression.h"
#include <AK/Format.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();
}
}
|