kernel/arch: Make arch_debug_get_caller() a macro implemented by a builtin.

Only the x86 and PPC implementations look like they would have worked,
while the builtin is available and will work across all architectures.
We already use it unconditionally in some parts of libroot.

Change-Id: I2dffb3b2c7cdd605092382b9d649151adb921bb4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6942
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Augustin Cavalier
2023-09-23 18:41:04 +00:00
committed by waddlesplash
parent d0c34f9331
commit ef9e2f627b
8 changed files with 2 additions and 59 deletions
+2 -1
View File
@@ -33,9 +33,10 @@ using BKernel::Thread;
extern "C" { extern "C" {
#endif #endif
#define arch_debug_get_caller() __builtin_return_address(0)
status_t arch_debug_init(kernel_args *args); status_t arch_debug_init(kernel_args *args);
void arch_debug_stack_trace(void); void arch_debug_stack_trace(void);
void *arch_debug_get_caller(void);
int32 arch_debug_get_stack_trace(addr_t* returnAddresses, int32 maxCount, int32 arch_debug_get_stack_trace(addr_t* returnAddresses, int32 maxCount,
int32 skipIframes, int32 skipFrames, uint32 flags); int32 skipIframes, int32 skipFrames, uint32 flags);
void* arch_debug_get_interrupt_pc(bool* _isSyscall); void* arch_debug_get_interrupt_pc(bool* _isSyscall);
@@ -467,15 +467,6 @@ arch_debug_stack_trace(void)
} }
void *
arch_debug_get_caller(void)
{
/* Return the thread id as the kernel (for example the lock code) actually
gets a somewhat valid indication of the caller back. */
return (void*) thread_get_current_thread_id();
}
int32 int32
arch_debug_get_stack_trace(addr_t* returnAddresses, int32 maxCount, arch_debug_get_stack_trace(addr_t* returnAddresses, int32 maxCount,
int32 skipIframes, int32 skipFrames, uint32 flags) int32 skipIframes, int32 skipFrames, uint32 flags)
@@ -449,13 +449,6 @@ arch_debug_stack_trace(void)
} }
void *
arch_debug_get_caller(void)
{
return NULL;
}
int32 int32
arch_debug_get_stack_trace(addr_t* returnAddresses, int32 maxCount, arch_debug_get_stack_trace(addr_t* returnAddresses, int32 maxCount,
int32 skipIframes, int32 skipFrames, uint32 flags) int32 skipIframes, int32 skipFrames, uint32 flags)
@@ -269,18 +269,6 @@ arch_debug_contains_call(Thread *thread, const char *symbol,
} }
void *
arch_debug_get_caller(void)
{
// TODO: implement me
//return __builtin_frame_address(1);
struct stack_frame *frame;
//frame = __builtin_frame_address(0);
frame = get_current_stack_frame();
return (void *)frame->previous->return_address;
}
int32 int32
arch_debug_get_stack_trace(addr_t* returnAddresses, int32 maxCount, arch_debug_get_stack_trace(addr_t* returnAddresses, int32 maxCount,
int32 skipIframes, int32 skipFrames, uint32 flags) int32 skipIframes, int32 skipFrames, uint32 flags)
@@ -280,14 +280,6 @@ arch_debug_contains_call(Thread *thread, const char *symbol,
} }
void *
arch_debug_get_caller(void)
{
struct stack_frame *frame = get_current_stack_frame()->previous;
return (void *)frame->previous->return_address;
}
int32 int32
arch_debug_get_stack_trace(addr_t* returnAddresses, int32 maxCount, arch_debug_get_stack_trace(addr_t* returnAddresses, int32 maxCount,
int32 skipIframes, int32 skipFrames, uint32 flags) int32 skipIframes, int32 skipFrames, uint32 flags)
@@ -358,13 +358,6 @@ arch_debug_contains_call(Thread *thread, const char *symbol,
} }
void *
arch_debug_get_caller(void)
{
return NULL;
}
void void
arch_debug_save_registers(struct arch_debug_registers* registers) arch_debug_save_registers(struct arch_debug_registers* registers)
{ {
@@ -24,13 +24,6 @@ arch_debug_contains_call(Thread *thread, const char *symbol,
} }
void *
arch_debug_get_caller(void)
{
return NULL;
}
void void
arch_debug_save_registers(struct arch_debug_registers* registers) arch_debug_save_registers(struct arch_debug_registers* registers)
{ {
@@ -1117,14 +1117,6 @@ arch_debug_contains_call(Thread* thread, const char* symbol, addr_t start,
} }
void*
arch_debug_get_caller(void)
{
stack_frame* frame = (stack_frame*)x86_get_stack_frame();
return (void*)frame->previous->return_address;
}
/*! Captures a stack trace (the return addresses) of the current thread. /*! Captures a stack trace (the return addresses) of the current thread.
\param returnAddresses The array the return address shall be written to. \param returnAddresses The array the return address shall be written to.
\param maxCount The maximum number of return addresses to be captured. \param maxCount The maximum number of return addresses to be captured.