mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:07:35 +00:00
Add sys$set_mmap_name and use it from LibC's malloc.
It's nice to be able to identify mmap's in /proc/PID/vm.
This commit is contained in:
parent
e904f193c1
commit
1d5afbdffc
7 changed files with 35 additions and 8 deletions
|
@ -16,4 +16,10 @@ int munmap(void* addr, size_t size)
|
|||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int set_mmap_name(void* addr, size_t size, const char* name)
|
||||
{
|
||||
int rc = Syscall::invoke(Syscall::SetMmapName, (dword)addr, (dword)size, (dword)name);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,5 +6,6 @@ extern "C" {
|
|||
|
||||
void* mmap(void*, size_t);
|
||||
int munmap(void*, size_t);
|
||||
int set_mmap_name(void*, size_t, const char*);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "stdlib.h"
|
||||
#include "mman.h"
|
||||
#include "stdio.h"
|
||||
#include <Kernel/Syscall.h>
|
||||
#include <AK/Assertions.h>
|
||||
|
||||
|
@ -12,6 +13,12 @@ void* malloc(size_t size)
|
|||
*crashme = 0;
|
||||
}
|
||||
void* ptr = mmap(nullptr, 4096);
|
||||
if (ptr) {
|
||||
int rc = set_mmap_name(ptr, 4096, "malloc");
|
||||
if (rc < 0) {
|
||||
perror("set_mmap_name failed");
|
||||
}
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue