diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-04-15 23:58:48 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-04-15 23:58:48 +0200 |
commit | d384c7815f92d9bd411033f0bc1d92250568b1c4 (patch) | |
tree | d300656db88c2341351ecbded80e5e266b6177b3 /Kernel/kmalloc.cpp | |
parent | bc6ac1c2f2a63292106f05b1a92460fa7257b5dd (diff) | |
download | serenity-d384c7815f92d9bd411033f0bc1d92250568b1c4.zip |
Kernel: Make it possible to have kmalloc() dump call stacks.
This can be enabled at any time using a sysctl:
sysctl kmalloc_stacks=1
The stacks will go to the debugger output only.
Diffstat (limited to 'Kernel/kmalloc.cpp')
-rw-r--r-- | Kernel/kmalloc.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Kernel/kmalloc.cpp b/Kernel/kmalloc.cpp index 9c952bf5cc..e7356efdb4 100644 --- a/Kernel/kmalloc.cpp +++ b/Kernel/kmalloc.cpp @@ -9,6 +9,7 @@ #include <Kernel/i386.h> #include <Kernel/Process.h> #include <Kernel/Scheduler.h> +#include <Kernel/KSyms.h> #include <AK/Assertions.h> #define SANITIZE_KMALLOC @@ -35,6 +36,7 @@ volatile size_t kmalloc_sum_eternal = 0; dword g_kmalloc_call_count; dword g_kfree_call_count; +bool g_dump_kmalloc_stacks; static byte* s_next_eternal_ptr; static byte* s_end_of_eternal_range; @@ -95,6 +97,11 @@ void* kmalloc_impl(size_t size) InterruptDisabler disabler; ++g_kmalloc_call_count; + if (g_dump_kmalloc_stacks && ksyms_ready) { + dbgprintf("kmalloc(%u)\n", size); + dump_backtrace(true); + } + // We need space for the allocation_t structure at the head of the block. size_t real_size = size + sizeof(allocation_t); |