]> git.itanic.dy.fi Git - scan-pagemap/commitdiff
Analyzer: Print thread-ID only when --with-threads is enabled
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Thu, 22 Jul 2010 09:33:51 +0000 (12:33 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Thu, 22 Jul 2010 09:33:51 +0000 (12:33 +0300)
Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
analyze.c
analyze.h
main.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++;
        }
index 03a300b8d944c2936dd8dd1ccd9e08c2e28c4f27..5ec291484377e59af9756adaf4e89ec691f88a94 100644 (file)
--- a/analyze.h
+++ b/analyze.h
@@ -4,6 +4,7 @@
 #include "pagemap.h"
 
 void print_page_stats(struct pageframe *pf);
-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);
 
 #endif
diff --git a/main.c b/main.c
index 4ac6ccbe45aa7c4e37440bea506ced2c43badb78..bca7436681721f2d1219a9e3d91eb8340a3dbba5 100644 (file)
--- a/main.c
+++ b/main.c
@@ -74,7 +74,7 @@ int main(int argc, char *argv[])
        memset(&pf, 0, sizeof(pf));
 
        scan_all_pids(&pf, &process_list, &opts);
-       print_pid_stats(&pf, process_list);
+       print_pid_stats(&pf, process_list, &opts);
        print_page_stats(&pf);
 
        return 0;