libroot: Add private __arch_get_stack_trace().

It can be used to get a stack trace of the current thread. Note that
this works by walking frame pointers and will not produce anything
useful if an application is compiled with the frame pointers omitted.

The stack base and end addresses have to be provided as arguments and
are used to check that the frame pointers fall within that range. These
values are thread specific and can be retrieved with get_thread_info().
No other sanity checks (like checking for loops in the linked list) are
done.

This is a simplified rewrite of the stack trace code from the kernel
debugger.

As this code is common to x86 and x86_64 but is not generic across
architectures I introduced x86_common as a directory to put such
sources.
This commit is contained in:
Michael Lotz
2015-04-11 23:37:54 +02:00
parent 9ac1c4c25e
commit c012e7e930
4 changed files with 62 additions and 1 deletions
@@ -44,6 +44,8 @@ bigtime_t __get_system_time_offset();
void __init_pwd_backend(void);
void __reinit_pwd_backend_after_fork(void);
void* __arch_get_caller(void);
int32 __arch_get_stack_trace(addr_t* returnAddresses, int32 maxCount,
int32 skipFrames, addr_t stackBase, addr_t stackEnd);
void __set_stack_protection(void);