mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 16:18:12 +00:00
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.
This commit is contained in:
parent
bc6ac1c2f2
commit
d384c7815f
4 changed files with 14 additions and 0 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue