summaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
authordzwdz2022-05-03 19:18:28 +0200
committerdzwdz2022-05-03 19:18:28 +0200
commit48bba6c6883f53b9c101d3dc31914797153ab019 (patch)
tree181a1cb78da52dacdbb04d60285191778f221dab /src/kernel
parent600dd0bb30d9d8d5c7645156c1c50ad68ec1b334 (diff)
kernel/alloc: print who allocated unfreed memory on shutdown
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/mem/alloc.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/kernel/mem/alloc.c b/src/kernel/mem/alloc.c
index 9067fb8..d099a31 100644
--- a/src/kernel/mem/alloc.c
+++ b/src/kernel/mem/alloc.c
@@ -12,6 +12,7 @@ struct malloc_hdr {
uint32_t magic;
uint32_t page_amt;
struct malloc_hdr *next, *prev;
+ void *stacktrace[4];
};
struct malloc_hdr *malloc_last = NULL;
@@ -49,7 +50,10 @@ void mem_debugprint(void) {
kprintf("current kmallocs:\n");
kprintf("addr pages\n");
for (struct malloc_hdr *iter = malloc_last; iter; iter = iter->prev) {
- kprintf("%08x %05x\n", iter, iter->page_amt);
+ kprintf("%08x %05x", iter, iter->page_amt);
+ for (size_t i = 0; i < 4; i++)
+ kprintf(" k/%08x", iter->stacktrace[i]);
+ kprintf("\n");
total++;
}
kprintf(" total 0x%x\n", total);
@@ -124,6 +128,10 @@ void *kmalloc(size_t len) {
assert(!addr->prev->next);
addr->prev->next = addr;
}
+
+ for (size_t i = 0; i < 4; i++)
+ addr->stacktrace[i] = debug_caller(i);
+
malloc_last = addr;
kmalloc_sanity(addr);