diff --git a/src/bin/debug/strace/Jamfile b/src/bin/debug/strace/Jamfile index 1ceb3765a4..320bbc37c2 100644 --- a/src/bin/debug/strace/Jamfile +++ b/src/bin/debug/strace/Jamfile @@ -22,6 +22,7 @@ local straceSources = fcntl.cpp ioctl.cpp + area.cpp ; # Our compiler badly chokes when compiling the generated file. So will diff --git a/src/bin/debug/strace/area.cpp b/src/bin/debug/strace/area.cpp new file mode 100644 index 0000000000..8c714fba2c --- /dev/null +++ b/src/bin/debug/strace/area.cpp @@ -0,0 +1,55 @@ +/* + * Copyright 2023, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include +#include + +#include "strace.h" +#include "Syscall.h" +#include "TypeHandler.h" + + +#define FLAG_INFO_ENTRY(name) \ + { name, #name } + +static const FlagsTypeHandler::FlagInfo kAreaProtectionFlagInfos[] = { + FLAG_INFO_ENTRY(B_READ_AREA), + FLAG_INFO_ENTRY(B_WRITE_AREA), + FLAG_INFO_ENTRY(B_EXECUTE_AREA), + FLAG_INFO_ENTRY(B_STACK_AREA), + + FLAG_INFO_ENTRY(B_CLONEABLE_AREA), + FLAG_INFO_ENTRY(B_OVERCOMMITTING_AREA), + + { 0, NULL } +}; + + +static FlagsTypeHandler::FlagsList kAreaProtectionFlags; + +void +patch_area() +{ + for (int i = 0; kAreaProtectionFlagInfos[i].name != NULL; i++) { + kAreaProtectionFlags.push_back(kAreaProtectionFlagInfos[i]); + } + + Syscall *open = get_syscall("_kern_create_area"); + open->GetParameter("protection")->SetHandler( + new FlagsTypeHandler(kAreaProtectionFlags)); + + Syscall *clone = get_syscall("_kern_clone_area"); + clone->GetParameter("protection")->SetHandler( + new FlagsTypeHandler(kAreaProtectionFlags)); + + Syscall *set_area_protection = get_syscall("_kern_set_area_protection"); + set_area_protection->GetParameter("newProtection")->SetHandler( + new FlagsTypeHandler(kAreaProtectionFlags)); + + Syscall *map_file = get_syscall("_kern_map_file"); + map_file->GetParameter("protection")->SetHandler( + new FlagsTypeHandler(kAreaProtectionFlags)); +} diff --git a/src/bin/debug/strace/strace.cpp b/src/bin/debug/strace/strace.cpp index 8d9dcd49a6..528cbd23ab 100644 --- a/src/bin/debug/strace/strace.cpp +++ b/src/bin/debug/strace/strace.cpp @@ -267,9 +267,11 @@ patch_syscalls() // kernel/syscalls.h and have it parsed automatically extern void patch_fcntl(); extern void patch_ioctl(); + extern void patch_area(); patch_fcntl(); patch_ioctl(); + patch_area(); Syscall *poll = get_syscall("_kern_poll"); poll->ParameterAt(0)->SetInOut(true);