strace: Add area protection flags printing.

Using the new FlagsTypeHandler.
This commit is contained in:
Augustin Cavalier
2023-03-28 13:00:58 -04:00
parent 37f7aba689
commit 0f3ea49704
3 changed files with 58 additions and 0 deletions
+1
View File
@@ -22,6 +22,7 @@ local straceSources =
fcntl.cpp
ioctl.cpp
area.cpp
;
# Our compiler badly chokes when compiling the generated file. So will
+55
View File
@@ -0,0 +1,55 @@
/*
* Copyright 2023, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <OS.h>
#include <vm_defs.h>
#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));
}
+2
View File
@@ -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);