From c9a8dfa1bf14e73bb91c53678754caa12e266785 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 23 Jun 2021 21:47:19 +0200 Subject: [PATCH] Userland: Add more TODO()s for arch-specific code This enables building more of the userspace applications for x86_64. --- Userland/Applications/Debugger/main.cpp | 6 ++++++ Userland/Libraries/LibCoreDump/Backtrace.cpp | 6 ++++++ Userland/Libraries/LibDebug/DebugSession.cpp | 5 +++++ Userland/Libraries/LibDebug/Dwarf/Expression.cpp | 4 +++- Userland/Libraries/LibPthread/pthread.cpp | 2 +- 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Userland/Applications/Debugger/main.cpp b/Userland/Applications/Debugger/main.cpp index dd8068628d0..2b9a0749e64 100644 --- a/Userland/Applications/Debugger/main.cpp +++ b/Userland/Applications/Debugger/main.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -81,6 +82,7 @@ static bool handle_disassemble_command(const String& command, void* first_instru static bool handle_backtrace_command(const PtraceRegisters& regs) { +#if ARCH(I386) auto ebp_val = regs.ebp; auto eip_val = regs.eip; outln("Backtrace:"); @@ -98,6 +100,10 @@ static bool handle_backtrace_command(const PtraceRegisters& regs) eip_val = (u32)next_eip.value(); ebp_val = (u32)next_ebp.value(); } +#else + (void)regs; + TODO(); +#endif return true; } diff --git a/Userland/Libraries/LibCoreDump/Backtrace.cpp b/Userland/Libraries/LibCoreDump/Backtrace.cpp index ad542e76685..b388bccef20 100644 --- a/Userland/Libraries/LibCoreDump/Backtrace.cpp +++ b/Userland/Libraries/LibCoreDump/Backtrace.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -51,6 +52,7 @@ static const ELFObjectInfo* object_info_for_region(const ELF::Core::MemoryRegion Backtrace::Backtrace(const Reader& coredump, const ELF::Core::ThreadInfo& thread_info) : m_thread_info(move(thread_info)) { +#if ARCH(I386) uint32_t* ebp = (uint32_t*)m_thread_info.regs.ebp; uint32_t* eip = (uint32_t*)m_thread_info.regs.eip; bool first_frame = true; @@ -70,6 +72,10 @@ Backtrace::Backtrace(const Reader& coredump, const ELF::Core::ThreadInfo& thread eip = (uint32_t*)next_eip.value(); ebp = (uint32_t*)next_ebp.value(); } +#else + (void)coredump; + TODO(); +#endif } Backtrace::~Backtrace() diff --git a/Userland/Libraries/LibDebug/DebugSession.cpp b/Userland/Libraries/LibDebug/DebugSession.cpp index 361280b6953..c874f5a12cd 100644 --- a/Userland/Libraries/LibDebug/DebugSession.cpp +++ b/Userland/Libraries/LibDebug/DebugSession.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -336,7 +337,11 @@ void* DebugSession::single_step() regs = get_registers(); regs.eflags &= ~(TRAP_FLAG); set_registers(regs); +#if ARCH(I386) return (void*)regs.eip; +#else + TODO(); +#endif } void DebugSession::detach() diff --git a/Userland/Libraries/LibDebug/Dwarf/Expression.cpp b/Userland/Libraries/LibDebug/Dwarf/Expression.cpp index 14fe9df93b9..7a50913d945 100644 --- a/Userland/Libraries/LibDebug/Dwarf/Expression.cpp +++ b/Userland/Libraries/LibDebug/Dwarf/Expression.cpp @@ -12,7 +12,7 @@ namespace Debug::Dwarf::Expression { -Value evaluate(ReadonlyBytes bytes, PtraceRegisters const& regs) +Value evaluate(ReadonlyBytes bytes, [[maybe_unused]] PtraceRegisters const& regs) { InputMemoryStream stream(bytes); @@ -21,6 +21,7 @@ Value evaluate(ReadonlyBytes bytes, PtraceRegisters const& regs) stream >> opcode; switch (static_cast(opcode)) { +#if ARCH(I386) case Operations::RegEbp: { ssize_t offset = 0; stream.read_LEB128_signed(offset); @@ -32,6 +33,7 @@ Value evaluate(ReadonlyBytes bytes, PtraceRegisters const& regs) stream.read_LEB128_signed(offset); return Value { Type::UnsignedIntetger, regs.ebp + 2 * sizeof(size_t) + offset }; } +#endif default: dbgln("DWARF expr addr: {}", (const void*)bytes.data()); diff --git a/Userland/Libraries/LibPthread/pthread.cpp b/Userland/Libraries/LibPthread/pthread.cpp index 9f82ec3e586..d49413c5277 100644 --- a/Userland/Libraries/LibPthread/pthread.cpp +++ b/Userland/Libraries/LibPthread/pthread.cpp @@ -66,7 +66,7 @@ static int create_thread(pthread_t* thread, void* (*entry)(void*), void* argumen while (((uintptr_t)stack - 16) % 16 != 0) push_on_stack(nullptr); - push_on_stack((void*)thread_params->m_stack_size); + push_on_stack((void*)(uintptr_t)thread_params->m_stack_size); push_on_stack(thread_params->m_stack_location); push_on_stack(argument); push_on_stack((void*)entry);