瀏覽代碼

Kernel: Fetch the frame pointer using __builtin_frame_address()

This compiler builtin abstracts away the specifics of fetching the frame
pointer. This will allow the KSyms.cpp to be build for the aarch64
target. While we're here, lets also change the
PerformanceEventBuffer.cpp to not rely on x86_64 specifics.
Timon Kruiper 3 年之前
父節點
當前提交
442800db3e
共有 2 個文件被更改,包括 3 次插入16 次删除
  1. 2 8
      Kernel/KSyms.cpp
  2. 1 8
      Kernel/PerformanceEventBuffer.cpp

+ 2 - 8
Kernel/KSyms.cpp

@@ -168,14 +168,8 @@ void dump_backtrace(PrintToScreen print_to_screen)
         return;
     TemporaryChange change(in_dump_backtrace, true);
     TemporaryChange disable_kmalloc_stacks(g_dump_kmalloc_stacks, false);
-    FlatPtr base_pointer;
-#if ARCH(I386)
-    asm volatile("movl %%ebp, %%eax"
-                 : "=a"(base_pointer));
-#else
-    asm volatile("movq %%rbp, %%rax"
-                 : "=a"(base_pointer));
-#endif
+
+    FlatPtr base_pointer = (FlatPtr)__builtin_frame_address(0);
     dump_backtrace_impl(base_pointer, g_kernel_symbols_available, print_to_screen);
 }
 

+ 1 - 8
Kernel/PerformanceEventBuffer.cpp

@@ -24,14 +24,7 @@ PerformanceEventBuffer::PerformanceEventBuffer(NonnullOwnPtr<KBuffer> buffer)
 
 NEVER_INLINE ErrorOr<void> PerformanceEventBuffer::append(int type, FlatPtr arg1, FlatPtr arg2, StringView arg3, Thread* current_thread, FlatPtr arg4, u64 arg5, ErrorOr<FlatPtr> arg6)
 {
-    FlatPtr base_pointer;
-#if ARCH(I386)
-    asm volatile("movl %%ebp, %%eax"
-                 : "=a"(base_pointer));
-#else
-    asm volatile("movq %%rbp, %%rax"
-                 : "=a"(base_pointer));
-#endif
+    FlatPtr base_pointer = (FlatPtr)__builtin_frame_address(0);
     return append_with_ip_and_bp(current_thread->pid(), current_thread->tid(), 0, base_pointer, type, 0, arg1, arg2, arg3, arg4, arg5, arg6);
 }