]> git.itanic.dy.fi Git - scan-pagemap/commitdiff
parser: More strict process scanning decision
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Wed, 8 Sep 2010 18:16:59 +0000 (21:16 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Wed, 8 Sep 2010 18:16:59 +0000 (21:16 +0300)
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 <kaapeli@itanic.dy.fi>
parse.c

diff --git a/parse.c b/parse.c
index 67fc0f781dd0e2b284bdc598e872aba010d1e747..2c493742371b01a1b2b652b81572fee2812de092 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -105,22 +105,35 @@ struct bintree_ops pageframe_ops = {
        .compare = compare_pageframe,
 };
 
        .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;
 {
        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;
 
        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;
                                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;
 
        if (is_parse_option(opts, PARSE_NOADD_TREE))
                match = !match;