]> git.itanic.dy.fi Git - scan-pagemap/blobdiff - parse.c
Print verbose output during operation
[scan-pagemap] / parse.c
diff --git a/parse.c b/parse.c
index 5f3196c50cbfe1b242b2b0d846184c2a25b91d97..5e29ea576d730d9d49c5a3e5940ec72505be15b5 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -379,6 +379,7 @@ int scan_all_pids(struct pageframe *pf, struct process *process_list,
        DIR *dir = NULL;
        int pid;
        int count = 0;
+       int len = 0, i;
 
        if (is_parse_option(opts, PARSE_PID)) {
                list_for_each_entry_safe(pidlist, n, &opts->pidlist, list) {
@@ -398,23 +399,45 @@ int scan_all_pids(struct pageframe *pf, struct process *process_list,
 
        if (is_parse_option(opts, PARSE_MAP_NAME) &&
                !is_parse_option(opts, PARSE_PID)) {
+               printf("Scanning page mappings for process: ");
                while (1) {
                        pid = get_next_pid(&dir);
                        if (pid <= 0)
                                break;
+
+                       for (i = 0; i < len; i++)
+                               putchar('\b');
+                       len = printf("% 5d", pid);
+                       fflush(stdout);
+
                        read_pageframe_with_threads(pid, pf, process_list,
                                                opts);
                }
+
+               for (i = 0; i < len; i++)
+                       putchar('\b');
+               printf("Done  \n");
+               len = 0;
        }
        /* Do not add new pages in the tree after the initial scan */
        opts->parse_mask |= PARSE_NOADD_TREE;
 
+       printf("Scanning page mappings for process: ");
        while (1) {
                pid = get_next_pid(&dir);
                if (pid <= 0)
                        break;
+
+               for (i = 0; i < len; i++)
+                       putchar('\b');
+               len = printf("% 5d", pid);
+               fflush(stdout);
+
                read_pageframe_with_threads(pid, pf, process_list, opts);
        }
+       for (i = 0; i < len; i++)
+               putchar('\b');
+       printf("Done  \n");
 
        return 0;
 }