From c2cb0469674304a16761414a8642396af7db515a Mon Sep 17 00:00:00 2001 From: Timo Kokkonen Date: Thu, 22 Jul 2010 12:33:51 +0300 Subject: [PATCH] Analyzer: Print thread-ID only when --with-threads is enabled Signed-off-by: Timo Kokkonen --- analyze.c | 18 ++++++++++++++---- analyze.h | 3 ++- main.c | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/analyze.c b/analyze.c index a56f94d..8280ff4 100644 --- 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++; } diff --git a/analyze.h b/analyze.h index 03a300b..5ec2914 100644 --- 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 4ac6ccb..bca7436 100644 --- 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; -- 2.45.0