1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:14:58 +00:00

LibDebug+Everywhere: Avoid void* -> FlatPtr -> void* dance

And limit the `void*` to the functions that interface the system (i.e.
ptrace wrappers).
This generally makes the code less riddled with casts.
This commit is contained in:
Ali Mohammad Pur 2022-01-27 04:46:27 +03:30 committed by Linus Groh
parent b27b22a68c
commit 6d64b13a1b
15 changed files with 97 additions and 96 deletions

View file

@ -68,9 +68,9 @@ static void print_syscall(PtraceRegisters& regs, size_t depth)
#endif
}
static NonnullOwnPtr<HashMap<void*, X86::Instruction>> instrument_code()
static NonnullOwnPtr<HashMap<FlatPtr, X86::Instruction>> instrument_code()
{
auto instrumented = make<HashMap<void*, X86::Instruction>>();
auto instrumented = make<HashMap<FlatPtr, X86::Instruction>>();
g_debug_session->for_each_loaded_library([&](const Debug::LoadedLibrary& lib) {
lib.debug_info->elf().for_each_section_of_type(SHT_PROGBITS, [&](const ELF::Image::Section& section) {
if (section.name() != ".text")
@ -80,7 +80,7 @@ static NonnullOwnPtr<HashMap<void*, X86::Instruction>> instrument_code()
X86::Disassembler disassembler(stream);
for (;;) {
auto offset = stream.offset();
void* instruction_address = (void*)(section.address() + offset + lib.base_address);
auto instruction_address = section.address() + offset + lib.base_address;
auto insn = disassembler.next();
if (!insn.has_value())
break;
@ -150,7 +150,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
new_function = false;
return Debug::DebugSession::ContinueBreakAtSyscall;
}
auto instruction = instrumented->get((void*)ip).value();
auto instruction = instrumented->get(ip).value();
if (instruction.mnemonic() == "RET") {
if (depth != 0)