diff --git a/src/bin/debug/strace/area.cpp b/src/bin/debug/strace/area.cpp index d57964d05c..63680f4f8a 100644 --- a/src/bin/debug/strace/area.cpp +++ b/src/bin/debug/strace/area.cpp @@ -28,7 +28,30 @@ static const FlagsTypeHandler::FlagInfo kAreaProtectionFlagInfos[] = { }; +struct enum_info { + unsigned int index; + const char *name; +}; + +#define ENUM_INFO_ENTRY(name) \ + { name, #name } + +static const enum_info kAddressSpecs[] = { + ENUM_INFO_ENTRY(B_ANY_ADDRESS), + ENUM_INFO_ENTRY(B_EXACT_ADDRESS), + ENUM_INFO_ENTRY(B_BASE_ADDRESS), + ENUM_INFO_ENTRY(B_CLONE_ADDRESS), + ENUM_INFO_ENTRY(B_ANY_KERNEL_ADDRESS), + ENUM_INFO_ENTRY(B_RANDOMIZED_ANY_ADDRESS), + ENUM_INFO_ENTRY(B_RANDOMIZED_BASE_ADDRESS), + + { 0, NULL } +}; + + static FlagsTypeHandler::FlagsList kAreaProtectionFlags; +static EnumTypeHandler::EnumMap kAddressSpecsMap; + void patch_area() @@ -36,19 +59,33 @@ patch_area() for (int i = 0; kAreaProtectionFlagInfos[i].name != NULL; i++) { kAreaProtectionFlags.push_back(kAreaProtectionFlagInfos[i]); } + for (int i = 0; kAddressSpecs[i].name != NULL; i++) { + kAddressSpecsMap[kAddressSpecs[i].index] = kAddressSpecs[i].name; + } Syscall *create = get_syscall("_kern_create_area"); create->GetParameter("address")->SetInOut(true); + create->GetParameter("addressSpec")->SetHandler( + new EnumTypeHandler(kAddressSpecsMap)); create->GetParameter("protection")->SetHandler( new FlagsTypeHandler(kAreaProtectionFlags)); + Syscall *transfer = get_syscall("_kern_transfer_area"); + transfer->GetParameter("_address")->SetInOut(true); + transfer->GetParameter("addressSpec")->SetHandler( + new EnumTypeHandler(kAddressSpecsMap)); + Syscall *clone = get_syscall("_kern_clone_area"); clone->GetParameter("_address")->SetInOut(true); + clone->GetParameter("addressSpec")->SetHandler( + new EnumTypeHandler(kAddressSpecsMap)); clone->GetParameter("protection")->SetHandler( new FlagsTypeHandler(kAreaProtectionFlags)); Syscall *reserve_address_range = get_syscall("_kern_reserve_address_range"); reserve_address_range->GetParameter("_address")->SetInOut(true); + reserve_address_range->GetParameter("addressSpec")->SetHandler( + new EnumTypeHandler(kAddressSpecsMap)); Syscall *set_area_protection = get_syscall("_kern_set_area_protection"); set_area_protection->GetParameter("newProtection")->SetHandler( @@ -56,6 +93,8 @@ patch_area() Syscall *map_file = get_syscall("_kern_map_file"); map_file->GetParameter("address")->SetInOut(true); + map_file->GetParameter("addressSpec")->SetHandler( + new EnumTypeHandler(kAddressSpecsMap)); map_file->GetParameter("protection")->SetHandler( new FlagsTypeHandler(kAreaProtectionFlags));