_isc: use os->syscall_at instead of remove_if

This commit is contained in:
Dr-Carlos 2022-04-19 07:32:09 +09:30
parent e037d5889c
commit 08c000539c
1 changed files with 14 additions and 11 deletions

View File

@ -189,23 +189,26 @@ void _isc(Session &session, std::string vspace_name, bool sort,
return;
}
if(!addresses.empty()) {
for(uint32_t address: addresses) {
int syscall = os->find_syscall(address);
if(syscall == -1)
continue;
fmt::print(theme(3), " 0x{:08x}", address);
fmt::print(theme(10), " %{:01x}", syscall);
fmt::print("\n");
}
return;
}
int total = os->syscall_count();
auto info = std::make_unique<SyscallInfo[]>(total);
for(int i = 0; i < total; i++)
info[i] = (SyscallInfo) {.address = os->syscall(i), .id = i};
if(!addresses.empty())
std::remove_if(&info[0], &info[total],
[addresses, &total](const SyscallInfo &item) {
if(std::find(addresses.begin(), addresses.end(), item.address)
== addresses.end()) {
total--;
return true;
}
return false;
});
if(sort)
std::sort(&info[0], &info[total]);