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:
parent
8e575d2f62
commit
2c2cf90661
3 changed files with 31 additions and 15 deletions
|
@ -243,7 +243,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
VERIFY(optional_regs.has_value());
|
VERIFY(optional_regs.has_value());
|
||||||
const PtraceRegisters& regs = optional_regs.value();
|
const PtraceRegisters& regs = optional_regs.value();
|
||||||
#if ARCH(I686)
|
#if ARCH(I386)
|
||||||
const FlatPtr ip = regs.eip;
|
const FlatPtr ip = regs.eip;
|
||||||
#else
|
#else
|
||||||
const FlatPtr ip = regs.rip;
|
const FlatPtr ip = regs.rip;
|
||||||
|
|
|
@ -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* begin_color = g_should_output_color ? "\033[34;1m" : "";
|
||||||
const char* end_color = g_should_output_color ? "\033[0m" : "";
|
const char* end_color = g_should_output_color ? "\033[0m" : "";
|
||||||
|
#if ARCH(I386)
|
||||||
outln("=> {}SC_{}(0x{:x}, 0x{:x}, 0x{:x}){}",
|
outln("=> {}SC_{}(0x{:x}, 0x{:x}, 0x{:x}){}",
|
||||||
begin_color,
|
begin_color,
|
||||||
Syscall::to_string((Syscall::Function)regs.eax),
|
Syscall::to_string((Syscall::Function)regs.eax),
|
||||||
|
@ -58,6 +59,15 @@ static void print_syscall(PtraceRegisters& regs, size_t depth)
|
||||||
regs.ecx,
|
regs.ecx,
|
||||||
regs.ebx,
|
regs.ebx,
|
||||||
end_color);
|
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()
|
static NonnullOwnPtr<HashMap<void*, X86::Instruction>> instrument_code()
|
||||||
|
@ -133,13 +143,19 @@ int main(int argc, char** argv)
|
||||||
return Debug::DebugSession::DebugDecision::ContinueBreakAtSyscall;
|
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) {
|
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);
|
print_function_call(function_name.value().symbol, depth);
|
||||||
new_function = false;
|
new_function = false;
|
||||||
return Debug::DebugSession::ContinueBreakAtSyscall;
|
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 (instruction.mnemonic() == "RET") {
|
||||||
if (depth != 0)
|
if (depth != 0)
|
||||||
|
|
|
@ -15,20 +15,20 @@
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#define EXPECT_ERROR_2(err, syscall, arg1, arg2) \
|
#define EXPECT_ERROR_2(err, syscall, arg1, arg2) \
|
||||||
do { \
|
do { \
|
||||||
rc = syscall(arg1, arg2); \
|
rc = syscall(arg1, arg2); \
|
||||||
if (rc >= 0 || errno != err) { \
|
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)
|
} while (0)
|
||||||
|
|
||||||
#define EXPECT_ERROR_3(err, syscall, arg1, arg2, arg3) \
|
#define EXPECT_ERROR_3(err, syscall, arg1, arg2, arg3) \
|
||||||
do { \
|
do { \
|
||||||
rc = syscall(arg1, arg2, arg3); \
|
rc = syscall(arg1, arg2, arg3); \
|
||||||
if (rc >= 0 || errno != err) { \
|
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)
|
} while (0)
|
||||||
|
|
||||||
static void test_read_from_directory()
|
static void test_read_from_directory()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue