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

Utilities: Fix Build on x86_64

This commit is contained in:
Hendiadyoin1 2021-06-30 15:29:13 +02:00 committed by Andreas Kling
parent 8e575d2f62
commit 2c2cf90661
3 changed files with 31 additions and 15 deletions

View file

@ -243,7 +243,7 @@ int main(int argc, char** argv)
VERIFY(optional_regs.has_value());
const PtraceRegisters& regs = optional_regs.value();
#if ARCH(I686)
#if ARCH(I386)
const FlatPtr ip = regs.eip;
#else
const FlatPtr ip = regs.rip;

View file

@ -51,6 +51,7 @@ static void print_syscall(PtraceRegisters& regs, size_t depth)
}
const char* begin_color = g_should_output_color ? "\033[34;1m" : "";
const char* end_color = g_should_output_color ? "\033[0m" : "";
#if ARCH(I386)
outln("=> {}SC_{}(0x{:x}, 0x{:x}, 0x{:x}){}",
begin_color,
Syscall::to_string((Syscall::Function)regs.eax),
@ -58,6 +59,15 @@ static void print_syscall(PtraceRegisters& regs, size_t depth)
regs.ecx,
regs.ebx,
end_color);
#else
outln("=> {}SC_{}(0x{:x}, 0x{:x}, 0x{:x}){}",
begin_color,
Syscall::to_string((Syscall::Function)regs.rax),
regs.rdx,
regs.rcx,
regs.rbx,
end_color);
#endif
}
static NonnullOwnPtr<HashMap<void*, X86::Instruction>> instrument_code()
@ -133,13 +143,19 @@ int main(int argc, char** argv)
return Debug::DebugSession::DebugDecision::ContinueBreakAtSyscall;
}
#if ARCH(I386)
const FlatPtr ip = regs.value().eip;
#else
const FlatPtr ip = regs.value().rip;
#endif
if (new_function) {
auto function_name = g_debug_session->symbolicate(regs.value().eip);
auto function_name = g_debug_session->symbolicate(ip);
print_function_call(function_name.value().symbol, depth);
new_function = false;
return Debug::DebugSession::ContinueBreakAtSyscall;
}
auto instruction = instrumented->get((void*)regs.value().eip).value();
auto instruction = instrumented->get((void*)ip).value();
if (instruction.mnemonic() == "RET") {
if (depth != 0)

View file

@ -19,7 +19,7 @@
do { \
rc = syscall(arg1, arg2); \
if (rc >= 0 || errno != err) { \
warnln(__FILE__ ":{}: Expected " #err ": " #syscall "({:p}, {:p}), got rc={}, errno={}", __LINE__, (const void*)(arg1), (const void*)arg2, rc, errno); \
warnln(__FILE__ ":{}: Expected " #err ": " #syscall "({}, {}), got rc={}, errno={}", __LINE__, arg1, arg2, rc, errno); \
} \
} while (0)
@ -27,7 +27,7 @@
do { \
rc = syscall(arg1, arg2, arg3); \
if (rc >= 0 || errno != err) { \
warnln(__FILE__ ":{}: Expected " #err ": " #syscall "({:p}, {:p}, {:p}), got rc={}, errno={}", __LINE__, (const void*)(arg1), (const void*)(arg2), (const void*)(arg3), rc, errno); \
warnln(__FILE__ ":{}: Expected " #err ": " #syscall "({}, {}, {}), got rc={}, errno={}", __LINE__, arg1, arg2, arg3, rc, errno); \
} \
} while (0)