kernel: Reenable userspace stack tracing, but hidden behind a config flag
All checks were successful
continuous-integration/drone/push Build is passing

Sometimes this is needed for userspace program debugging (such as ports),
but sometimes it can crash, so we leave it off by default.
This commit is contained in:
apio 2023-07-25 17:02:09 +02:00
parent 905e71527e
commit 105ed79f8f
Signed by: asleepymoon
GPG Key ID: B8A7D06E42258954
2 changed files with 8 additions and 1 deletions

View File

@ -15,3 +15,7 @@
# control characters, leading/trailing spaces, problematic characters and invalid UTF-8). Keep in mind that this restriction
# is only enforced when creating files; existing files with such illegal filenames are parsed correctly and fully usable.
# target_compile_definitions(moon PRIVATE MOON_DISABLE_FILENAME_RESTRICTIONS)
# Uncomment the line below to make the kernel also calculate stack traces for userspace addresses on program crashes.
# This can aid in debugging, but makes the kernel more unstable as stack tracing will access arbitrary userspace memory.
# target_compile_definitions(moon PRIVATE MOON_ENABLE_USERSPACE_STACK_TRACES)

View File

@ -326,7 +326,10 @@ namespace CPU
static void backtrace_impl(u64 base_pointer, void (*callback)(u64, void*), void* arg)
{
StackFrame* current_frame = (StackFrame*)base_pointer;
while (current_frame && (u64)current_frame >= 0xFFFF'FFFF'8000'0000 &&
while (current_frame &&
#ifndef MOON_ENABLE_USERSPACE_STACK_TRACES
(u64)current_frame >= 0xFFFF'FFFF'8000'0000 &&
#endif
MemoryManager::validate_access(current_frame, sizeof(*current_frame), MemoryManager::DEFAULT_ACCESS) &&
current_frame->instruction)
{