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>
.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)
+
+ 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)
+{
- 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))
- 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;