diff --git a/Kernel/PerformanceEventBuffer.cpp b/Kernel/PerformanceEventBuffer.cpp index 7f55359f9c4..0e329212e7b 100644 --- a/Kernel/PerformanceEventBuffer.cpp +++ b/Kernel/PerformanceEventBuffer.cpp @@ -25,16 +25,16 @@ NEVER_INLINE KResult PerformanceEventBuffer::append(int type, FlatPtr arg1, Flat FlatPtr ebp; asm volatile("movl %%ebp, %%eax" : "=a"(ebp)); - return append_with_eip_and_ebp(current_thread->pid(), current_thread->tid(), 0, ebp, type, 0, arg1, arg2, arg3); + return append_with_ip_and_bp(current_thread->pid(), current_thread->tid(), 0, ebp, type, 0, arg1, arg2, arg3); } -static Vector raw_backtrace(FlatPtr ebp, FlatPtr eip) +static Vector raw_backtrace(FlatPtr bp, FlatPtr ip) { Vector backtrace; - if (eip != 0) - backtrace.append(eip); + if (ip != 0) + backtrace.append(ip); FlatPtr stack_ptr_copy; - FlatPtr stack_ptr = (FlatPtr)ebp; + FlatPtr stack_ptr = bp; // FIXME: Figure out how to remove this SmapDisabler without breaking profile stacks. SmapDisabler disabler; while (stack_ptr) { @@ -54,8 +54,8 @@ static Vector raw_backtrace(Fl return backtrace; } -KResult PerformanceEventBuffer::append_with_eip_and_ebp(ProcessID pid, ThreadID tid, - u32 eip, u32 ebp, int type, u32 lost_samples, FlatPtr arg1, FlatPtr arg2, const StringView& arg3) +KResult PerformanceEventBuffer::append_with_ip_and_bp(ProcessID pid, ThreadID tid, + FlatPtr ip, FlatPtr bp, int type, u32 lost_samples, FlatPtr arg1, FlatPtr arg2, const StringView& arg3) { if (count() >= capacity()) return ENOBUFS; @@ -139,7 +139,7 @@ KResult PerformanceEventBuffer::append_with_eip_and_ebp(ProcessID pid, ThreadID return EINVAL; } - auto backtrace = raw_backtrace(ebp, eip); + auto backtrace = raw_backtrace(bp, ip); event.stack_size = min(sizeof(event.stack) / sizeof(FlatPtr), static_cast(backtrace.size())); memcpy(event.stack, backtrace.data(), event.stack_size * sizeof(FlatPtr)); @@ -269,17 +269,17 @@ void PerformanceEventBuffer::add_process(const Process& process, ProcessEventTyp else executable = String::formatted("<{}>", process.name()); - [[maybe_unused]] auto rc = append_with_eip_and_ebp(process.pid(), 0, 0, 0, + [[maybe_unused]] auto rc = append_with_ip_and_bp(process.pid(), 0, 0, 0, event_type == ProcessEventType::Create ? PERF_EVENT_PROCESS_CREATE : PERF_EVENT_PROCESS_EXEC, 0, process.pid().value(), 0, executable); process.for_each_thread([&](auto& thread) { - [[maybe_unused]] auto rc = append_with_eip_and_ebp(process.pid(), thread.tid().value(), + [[maybe_unused]] auto rc = append_with_ip_and_bp(process.pid(), thread.tid().value(), 0, 0, PERF_EVENT_THREAD_CREATE, 0, 0, 0, nullptr); }); for (auto& region : process.space().regions()) { - [[maybe_unused]] auto rc = append_with_eip_and_ebp(process.pid(), 0, + [[maybe_unused]] auto rc = append_with_ip_and_bp(process.pid(), 0, 0, 0, PERF_EVENT_MMAP, 0, region->range().base().get(), region->range().size(), region->name()); } } diff --git a/Kernel/PerformanceEventBuffer.h b/Kernel/PerformanceEventBuffer.h index fd0928984cf..4c7c2fd7486 100644 --- a/Kernel/PerformanceEventBuffer.h +++ b/Kernel/PerformanceEventBuffer.h @@ -95,7 +95,7 @@ public: static OwnPtr try_create_with_size(size_t buffer_size); KResult append(int type, FlatPtr arg1, FlatPtr arg2, const StringView& arg3, Thread* current_thread = Thread::current()); - KResult append_with_eip_and_ebp(ProcessID pid, ThreadID tid, u32 eip, u32 ebp, + KResult append_with_ip_and_bp(ProcessID pid, ThreadID tid, FlatPtr eip, FlatPtr ebp, int type, u32 lost_samples, FlatPtr arg1, FlatPtr arg2, const StringView& arg3); void clear() diff --git a/Kernel/PerformanceManager.h b/Kernel/PerformanceManager.h index eb340c80206..caa7940c0ef 100644 --- a/Kernel/PerformanceManager.h +++ b/Kernel/PerformanceManager.h @@ -33,7 +33,7 @@ public: { if (g_profiling_all_threads) { VERIFY(g_global_perf_events); - [[maybe_unused]] auto rc = g_global_perf_events->append_with_eip_and_ebp( + [[maybe_unused]] auto rc = g_global_perf_events->append_with_ip_and_bp( process.pid(), 0, 0, 0, PERF_EVENT_PROCESS_EXIT, 0, 0, 0, nullptr); } } @@ -61,15 +61,9 @@ public: if (current_thread.is_profiling_suppressed()) return; if (auto* event_buffer = current_thread.process().current_perf_events_buffer()) { -#if ARCH(I386) - [[maybe_unused]] auto rc = event_buffer->append_with_eip_and_ebp( + [[maybe_unused]] auto rc = event_buffer->append_with_ip_and_bp( current_thread.pid(), current_thread.tid(), - regs.eip, regs.ebp, PERF_EVENT_SAMPLE, lost_time, 0, 0, nullptr); -#else - [[maybe_unused]] auto rc = event_buffer->append_with_eip_and_ebp( - current_thread.pid(), current_thread.tid(), - regs.rip, regs.rbp, PERF_EVENT_SAMPLE, lost_time, 0, 0, nullptr); -#endif + regs.ip(), regs.bp(), PERF_EVENT_SAMPLE, lost_time, 0, 0, nullptr); } } @@ -119,15 +113,9 @@ public: if (thread.is_profiling_suppressed()) return; if (auto* event_buffer = thread.process().current_perf_events_buffer()) { -#if ARCH(I386) - [[maybe_unused]] auto rc = event_buffer->append_with_eip_and_ebp( + [[maybe_unused]] auto rc = event_buffer->append_with_ip_and_bp( thread.pid(), thread.tid(), - regs.eip, regs.ebp, PERF_EVENT_PAGE_FAULT, 0, 0, 0, nullptr); -#else - [[maybe_unused]] auto rc = event_buffer->append_with_eip_and_ebp( - thread.pid(), thread.tid(), - regs.rip, regs.rbp, PERF_EVENT_PAGE_FAULT, 0, 0, 0, nullptr); -#endif + regs.ip(), regs.bp(), PERF_EVENT_PAGE_FAULT, 0, 0, 0, nullptr); } }