diff options
-rw-r--r-- | kernel/features/mm.c | 10 | ||||
-rw-r--r-- | kernel/features/proc.c | 10 | ||||
-rw-r--r-- | kernel/inc/mm.h | 12 |
3 files changed, 22 insertions, 10 deletions
diff --git a/kernel/features/mm.c b/kernel/features/mm.c index 5356ab4..afee468 100644 --- a/kernel/features/mm.c +++ b/kernel/features/mm.c @@ -404,16 +404,6 @@ void memory_map_identity(struct page_dir *dir, struct memory_range prange, u32 f memset((void *)prange.base, 0, prange.size); } -struct memory_object { - u32 id; - u32 refs; - u8 shared; - struct memory_range prange; -}; -struct memory_proc_link { - struct memory_object *obj; - struct memory_range vrange; -}; static struct list *memory_objects = NULL; res memory_sys_alloc(struct page_dir *dir, u32 size, u32 *addr, u32 *id, u8 shared) { diff --git a/kernel/features/proc.c b/kernel/features/proc.c index a17a655..52627ed 100644 --- a/kernel/features/proc.c +++ b/kernel/features/proc.c @@ -148,6 +148,16 @@ void proc_exit(struct proc *proc, struct regs *r, s32 status) proc->name[0] ? proc->name : "UNKNOWN", proc->pid, status, status == 0 ? "success" : "error"); + if (proc->memory->head) { + printf("Process leaked memory:\n"); + struct node *iterator = proc->memory->head; + while (iterator) { + struct memory_proc_link *link = iterator->data; + printf("\t-> 0x%x: %dB\n", link->vrange.base, link->vrange.size); + iterator = iterator->next; + } + } + stack_destroy(proc->messages); list_destroy(proc->memory); // TODO: Decrement memory ref links virtual_destroy_dir(proc->page_dir); diff --git a/kernel/inc/mm.h b/kernel/inc/mm.h index fa9211c..5dee6d4 100644 --- a/kernel/inc/mm.h +++ b/kernel/inc/mm.h @@ -95,6 +95,18 @@ struct page_dir *virtual_kernel_dir(void); * Memory wrappers */ +struct memory_object { + u32 id; + u32 refs; + u8 shared; + struct memory_range prange; +}; + +struct memory_proc_link { + struct memory_object *obj; + struct memory_range vrange; +}; + #define MEMORY_NONE (0 << 0) #define MEMORY_USER (1 << 0) #define MEMORY_CLEAR (1 << 1) |