Skip to content

Commit

Permalink
Print process name and PID when kmalloc() panics.
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Jan 12, 2019
1 parent edc8270 commit 2e2d883
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Kernel/kmalloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "StdLib.h"
#include "i386.h"
#include "system.h"
#include "Process.h"
#include "Scheduler.h"
#include <AK/Assertions.h>

#define SANITIZE_KMALLOC
Expand Down Expand Up @@ -100,7 +102,7 @@ void* kmalloc(dword size)
real_size = size + sizeof(allocation_t);

if (sum_free < real_size) {
kprintf("kmalloc(): PANIC! Out of memory (sucks, dude)\nsum_free=%u, real_size=%x\n", sum_free, real_size);
kprintf("%s<%u> kmalloc(): PANIC! Out of memory (sucks, dude)\nsum_free=%u, real_size=%x\n", current->name().characters(), current->pid(), sum_free, real_size);
HANG;
return 0L;
}
Expand Down Expand Up @@ -161,7 +163,7 @@ void* kmalloc(dword size)
}
}

kprintf("kmalloc(): PANIC! Out of memory (no suitable block for size %u)\n", size);
kprintf("%s<%u> kmalloc(): PANIC! Out of memory (no suitable block for size %u)\n", current->name().characters(), current->pid(), size);
HANG;

return nullptr;
Expand Down

0 comments on commit 2e2d883

Please sign in to comment.