/* * builtin-top.c * * Builtin top command: Display a continuously updated profile of * any workload, CPU or specific PID. * * Copyright (C) 2008, Red Hat Inc, Ingo Molnar <mingo@redhat.com> * * Improvements and fixes by: * * Arjan van de Ven <arjan@linux.intel.com> * Yanmin Zhang <yanmin.zhang@intel.com> * Wu Fengguang <fengguang.wu@intel.com> * Mike Galbraith <efault@gmx.de> * Paul Mackerras <paulus@samba.org> * * Released under the GPL v2. (and only v2, not any later version) */#include"builtin.h"#include"perf.h"#include"util/color.h"#include"util/session.h"#include"util/symbol.h"#include"util/thread.h"#include"util/util.h"#include<linux/rbtree.h>#include"util/parse-options.h"#include"util/parse-events.h"#include"util/debug.h"#include<assert.h>#include<fcntl.h>#include<stdio.h>#include<termios.h>#include<unistd.h>#include<errno.h>#include<time.h>#include<sched.h>#include<pthread.h>#include<sys/syscall.h>#include<sys/ioctl.h>#include<sys/poll.h>#include<sys/prctl.h>#include<sys/wait.h>#include<sys/uio.h>#include<sys/mman.h>#include<linux/unistd.h>#include<linux/types.h>staticintfd[MAX_NR_CPUS][MAX_COUNTERS];staticintsystem_wide=0;staticintdefault_interval=0;staticintcount_filter=5;staticintprint_entries;staticinttarget_pid=-1;staticintinherit=0;staticintprofile_cpu=-1;staticintnr_cpus=0;staticunsignedintrealtime_prio=0;staticintgroup=0;staticunsignedintpage_size;staticunsignedintmmap_pages=16;staticintfreq=1000;/* 1 KHz */staticintdelay_secs=2;staticintzero=0;staticintdump_symtab=0;staticboolhide_kernel_symbols=false;staticboolhide_user_symbols=false;staticstructwinsizewinsize;/* * Source */structsource_line{u64eip;unsignedlongcount[MAX_COUNTERS];char*line;structsource_line*next;};staticchar*sym_filter=NULL;structsym_entry*sym_filter_entry=NULL;staticintsym_pcnt_filter