1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:57:43 +00:00

UserspaceEmulator+LibC: Use sys$emuctl() to pass malloc info to UE

Get rid of the awkward secret handshake sequence between malloc and UE
and simply use sys$emuctl() to notify UE of malloc, free and realloc.
This commit is contained in:
Andreas Kling 2021-03-09 08:56:35 +01:00
parent 4faeaf101c
commit 9588f01739
8 changed files with 44 additions and 90 deletions

View file

@ -519,7 +519,7 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
case SC_fork:
return virt$fork();
case SC_emuctl:
return virt$emuctl();
return virt$emuctl(arg1, arg2, arg3);
case SC_sched_getparam:
return virt$sched_getparam(arg1, arg2);
case SC_sched_setparam:
@ -1267,9 +1267,24 @@ int Emulator::virt$ioctl([[maybe_unused]] int fd, unsigned request, [[maybe_unus
TODO();
}
int Emulator::virt$emuctl()
int Emulator::virt$emuctl(FlatPtr arg1, FlatPtr arg2, FlatPtr arg3)
{
return 0;
auto* tracer = malloc_tracer();
if (!tracer)
return 0;
switch (arg1) {
case 1:
tracer->target_did_malloc({}, arg3, arg2);
return 0;
case 2:
tracer->target_did_free({}, arg2);
return 0;
case 3:
tracer->target_did_realloc({}, arg3, arg2);
return 0;
default:
return -EINVAL;
}
}
int Emulator::virt$fork()