From 86300fc1c7313ceeca96bf2d6d6b94548bd07b5d Mon Sep 17 00:00:00 2001 From: Dr-Carlos Date: Sun, 17 Apr 2022 12:58:52 +0930 Subject: [PATCH] _isc: add positional arg to specify printed info --- shell/i.cpp | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/shell/i.cpp b/shell/i.cpp index 6c04ecc..f97af63 100644 --- a/shell/i.cpp +++ b/shell/i.cpp @@ -135,10 +135,11 @@ void _io(Session &session, std::string name) struct _isc_args { std::string vspace_name; - bool sort; + bool sort = false; + std::vector addresses; }; -static struct _isc_args parse_isc(Session &, Parser &parser) +static struct _isc_args parse_isc(Session &session, Parser &parser) { _isc_args args; @@ -149,6 +150,9 @@ static struct _isc_args parse_isc(Session &, Parser &parser) parser.accept_options(); + while(!parser.at_end()) + args.addresses.push_back(parser.expr(session.current_space)); + parser.end(); return args; } @@ -164,7 +168,8 @@ bool operator<(const SyscallInfo &left, const SyscallInfo &right) return (left.address < right.address) || (left.id < right.id); } -void _isc(Session &session, std::string vspace_name, bool sort) +void _isc(Session &session, std::string vspace_name, bool sort, + std::vector addresses) { VirtualSpace *space = session.current_space; if(!vspace_name.empty()) @@ -175,7 +180,7 @@ void _isc(Session &session, std::string vspace_name, bool sort) OS *os = space->os_analysis(); if(!os) { - if (!vspace_name.empty()) + if(!vspace_name.empty()) throw CommandError("OS analysis on '{}' failed", vspace_name); throw CommandError("OS analysis failed"); } @@ -183,9 +188,19 @@ void _isc(Session &session, std::string vspace_name, bool sort) int total = os->syscall_count(); auto info = std::make_unique(total); - for(int i = 0; i < total; i++) { + 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]); @@ -254,10 +269,10 @@ static ShellCommand _isc_cmd( "isc", [](Session &s, Parser &p) { auto args = parse_isc(s, p); - _isc(s, args.vspace_name, args.sort); + _isc(s, args.vspace_name, args.sort, args.addresses); }, [](Session &s, Parser &p) { parse_isc(s, p); }, "Info Syscalls", R"( -isc [sort=true] [vspace=] +isc [sort=true] [vspace=] [
...] Prints the syscall table for the specified virtual space (defaults to the current one). By default, syscalls are enumerated by syscall number. If