]> git.itanic.dy.fi Git - scan-pagemap/blobdiff - analyze.c
Analyzer: Print thread-ID only when --with-threads is enabled
[scan-pagemap] / analyze.c
index a56f94d60f9c30c3dca72ab95eae03361f6984ce..8280ff47712519a811d926c2697885a9f422652c 100644 (file)
--- a/analyze.c
+++ b/analyze.c
@@ -91,7 +91,8 @@ void print_page_stats(struct pageframe *pf)
                PAGE_TO_NICE_UNIT(count));
 }
 
-void print_pid_stats(struct pageframe *pf, struct process *process_list)
+void print_pid_stats(struct pageframe *pf, struct process *process_list,
+               struct parse_opts *opts)
 {
        struct analyze_frames af;
        struct process *ps;
@@ -114,7 +115,10 @@ void print_pid_stats(struct pageframe *pf, struct process *process_list)
                biggest = MAX(biggest, ps->pages_present + ps->pages_swapped);
        }
 
-       printf("   in ram   swapped   pid   tid name\n");
+       printf("   in ram   swapped   pid");
+       if (opts->with_threads)
+               printf("   tid");
+       printf(" name\n");
 
 restart:
        second_biggest = 0;
@@ -135,10 +139,16 @@ restart:
                if (total == 0)
                        continue;
 
-               printf("%6lld %sB %6lld %sB %5d %5d %s\n",
+               printf("%6lld %sB %6lld %sB %5d ",
                        PAGE_TO_NICE(present), PAGE_TO_NICE_UNIT(present),
                        PAGE_TO_NICE(swapped), PAGE_TO_NICE_UNIT(swapped),
-                       ps->pid, ps->tid,ps->name);
+                       ps->pid);
+
+               if (opts->with_threads)
+                       printf("%5d ", ps->tid);
+
+               printf("%s\n", ps->name);
+
                count++;
                processes++;
        }