mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-26 09:22:34 +00:00 
			
		
		
		
	 6d64b13a1b
			
		
	
	
		6d64b13a1b
		
	
	
	
	
		
			
			And limit the `void*` to the functions that interface the system (i.e. ptrace wrappers). This generally makes the code less riddled with casts.
		
			
				
	
	
		
			47 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * 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, [[maybe_unused]] PtraceRegisters const& regs)
 | |
| {
 | |
|     InputMemoryStream stream(bytes);
 | |
| 
 | |
|     while (!stream.eof()) {
 | |
|         u8 opcode = 0;
 | |
|         stream >> opcode;
 | |
| 
 | |
|         switch (static_cast<Operations>(opcode)) {
 | |
| #if ARCH(I386)
 | |
|         case Operations::RegEbp: {
 | |
|             ssize_t offset = 0;
 | |
|             stream.read_LEB128_signed(offset);
 | |
|             return Value { Type::UnsignedInteger, { regs.ebp + offset } };
 | |
|         }
 | |
| 
 | |
|         case Operations::FbReg: {
 | |
|             ssize_t offset = 0;
 | |
|             stream.read_LEB128_signed(offset);
 | |
|             return Value { Type::UnsignedInteger, { regs.ebp + 2 * sizeof(size_t) + offset } };
 | |
|         }
 | |
| #endif
 | |
| 
 | |
|         default:
 | |
|             dbgln("DWARF expr addr: {:p}", bytes.data());
 | |
|             dbgln("unsupported opcode: {}", opcode);
 | |
|             VERIFY_NOT_REACHED();
 | |
|         }
 | |
|     }
 | |
|     VERIFY_NOT_REACHED();
 | |
| }
 | |
| 
 | |
| }
 |