From: Timo Kokkonen Date: Wed, 8 Sep 2010 18:16:59 +0000 (+0300) Subject: parser: More strict process scanning decision X-Git-Url: http://git.itanic.dy.fi/?p=scan-pagemap;a=commitdiff_plain;h=8acea8ee73b2035f48f51c514400304897162b10 parser: More strict process scanning decision If user has given a list of processes and a mapping name, then only the given processes should be scanned for the mapping names. Signed-off-by: Timo Kokkonen --- diff --git a/parse.c b/parse.c index 67fc0f7..2c49374 100644 --- a/parse.c +++ b/parse.c @@ -105,22 +105,35 @@ struct bintree_ops pageframe_ops = { .compare = compare_pageframe, }; -static int should_scan_process(struct parse_opts *opts, struct process *process) +static int pid_is_match(int pidn, struct list_head *pidlist) { struct pidlist *pid; + + list_for_each_entry(pid, pidlist, list) { + if (pid->pid == pidn) + return 1; + } + + return 0; +} + +static int should_scan_process(struct parse_opts *opts, struct process *process) +{ int match = 0; - if (is_parse_option(opts, PARSE_PID)) { - list_for_each_entry(pid, &opts->pidlist, list) { - if (pid->pid == process->pid) { + if (is_parse_option(opts, PARSE_PID) && + is_parse_option(opts, PARSE_MAP_NAME)) { + if (pid_is_match(process->pid, &opts->pidlist)) + match = 1; + } else { + if (is_parse_option(opts, PARSE_PID)) { + if (pid_is_match(process->pid, &opts->pidlist)) match = 1; - break; - } } - } - if (is_parse_option(opts, PARSE_MAP_NAME)) - match = 1; + if (is_parse_option(opts, PARSE_MAP_NAME)) + match = 1; + } if (is_parse_option(opts, PARSE_NOADD_TREE)) match = !match;