2011-03-15 22:04:13 +08:00
|
|
|
/*
|
|
|
|
* Builtin evlist command: Show the list of event selectors present
|
|
|
|
* in a perf.data file.
|
|
|
|
*/
|
|
|
|
#include "builtin.h"
|
|
|
|
|
|
|
|
#include "util/util.h"
|
|
|
|
|
|
|
|
#include <linux/list.h>
|
|
|
|
|
|
|
|
#include "perf.h"
|
|
|
|
#include "util/evlist.h"
|
|
|
|
#include "util/evsel.h"
|
|
|
|
#include "util/parse-events.h"
|
2015-12-15 23:39:39 +08:00
|
|
|
#include <subcmd/parse-options.h>
|
2011-03-15 22:04:13 +08:00
|
|
|
#include "util/session.h"
|
2013-10-15 22:27:32 +08:00
|
|
|
#include "util/data.h"
|
2014-07-15 05:46:48 +08:00
|
|
|
#include "util/debug.h"
|
2011-03-15 22:04:13 +08:00
|
|
|
|
2012-10-30 11:56:02 +08:00
|
|
|
static int __cmd_evlist(const char *file_name, struct perf_attr_details *details)
|
2011-03-15 22:04:13 +08:00
|
|
|
{
|
|
|
|
struct perf_session *session;
|
|
|
|
struct perf_evsel *pos;
|
2017-01-24 05:07:59 +08:00
|
|
|
struct perf_data data = {
|
2013-10-15 22:27:32 +08:00
|
|
|
.path = file_name,
|
|
|
|
.mode = PERF_DATA_MODE_READ,
|
2015-04-02 21:47:10 +08:00
|
|
|
.force = details->force,
|
2013-10-15 22:27:32 +08:00
|
|
|
};
|
perf evlist: Add --trace-fields option to show trace fields
To use dynamic sort keys, it might be good to add an option to see the
list of field names.
$ perf evlist -i perf.data.sched
sched:sched_switch
sched:sched_stat_wait
sched:sched_stat_sleep
sched:sched_stat_iowait
sched:sched_stat_runtime
sched:sched_process_fork
sched:sched_wakeup
sched:sched_wakeup_new
sched:sched_migrate_task
# Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events
$ perf evlist -i perf.data.sched --trace-fields
sched:sched_switch: trace_fields: prev_comm,prev_pid,prev_prio,prev_state,next_comm,next_pid,next_prio
sched:sched_stat_wait: trace_fields: comm,pid,delay
sched:sched_stat_sleep: trace_fields: comm,pid,delay
sched:sched_stat_iowait: trace_fields: comm,pid,delay
sched:sched_stat_runtime: trace_fields: comm,pid,runtime,vruntime
sched:sched_process_fork: trace_fields: parent_comm,parent_pid,child_comm,child_pid
sched:sched_wakeup: trace_fields: comm,pid,prio,success,target_cpu
sched:sched_wakeup_new: trace_fields: comm,pid,prio,success,target_cpu
sched:sched_migrate_task: trace_fields: comm,pid,prio,orig_cpu,dest_cpu
Committer notes:
For another file, in verbose mode:
# perf evlist -v --trace-fields
sched:sched_switch: type: 2, size: 112, config: 0x10b, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW, disabled: 1, inherit: 1, mmap: 1, comm: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, trace_fields: prev_comm,prev_pid,prev_prio,prev_state,next_comm,next_pid,next_prio
#
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1452125549-1511-5-git-send-email-namhyung@kernel.org
[ Replaced 'trace_fields=' with 'trace_fields: ' to make the output consistent in -v mode ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-01-07 08:12:29 +08:00
|
|
|
bool has_tracepoint = false;
|
2011-03-15 22:04:13 +08:00
|
|
|
|
2017-01-24 05:07:59 +08:00
|
|
|
session = perf_session__new(&data, 0, NULL);
|
2011-03-15 22:04:13 +08:00
|
|
|
if (session == NULL)
|
2014-09-24 09:33:37 +08:00
|
|
|
return -1;
|
2011-03-15 22:04:13 +08:00
|
|
|
|
2016-06-23 22:26:15 +08:00
|
|
|
evlist__for_each_entry(session->evlist, pos) {
|
2012-12-11 05:17:08 +08:00
|
|
|
perf_evsel__fprintf(pos, details, stdout);
|
2011-03-15 22:04:13 +08:00
|
|
|
|
perf evlist: Add --trace-fields option to show trace fields
To use dynamic sort keys, it might be good to add an option to see the
list of field names.
$ perf evlist -i perf.data.sched
sched:sched_switch
sched:sched_stat_wait
sched:sched_stat_sleep
sched:sched_stat_iowait
sched:sched_stat_runtime
sched:sched_process_fork
sched:sched_wakeup
sched:sched_wakeup_new
sched:sched_migrate_task
# Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events
$ perf evlist -i perf.data.sched --trace-fields
sched:sched_switch: trace_fields: prev_comm,prev_pid,prev_prio,prev_state,next_comm,next_pid,next_prio
sched:sched_stat_wait: trace_fields: comm,pid,delay
sched:sched_stat_sleep: trace_fields: comm,pid,delay
sched:sched_stat_iowait: trace_fields: comm,pid,delay
sched:sched_stat_runtime: trace_fields: comm,pid,runtime,vruntime
sched:sched_process_fork: trace_fields: parent_comm,parent_pid,child_comm,child_pid
sched:sched_wakeup: trace_fields: comm,pid,prio,success,target_cpu
sched:sched_wakeup_new: trace_fields: comm,pid,prio,success,target_cpu
sched:sched_migrate_task: trace_fields: comm,pid,prio,orig_cpu,dest_cpu
Committer notes:
For another file, in verbose mode:
# perf evlist -v --trace-fields
sched:sched_switch: type: 2, size: 112, config: 0x10b, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW, disabled: 1, inherit: 1, mmap: 1, comm: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, trace_fields: prev_comm,prev_pid,prev_prio,prev_state,next_comm,next_pid,next_prio
#
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1452125549-1511-5-git-send-email-namhyung@kernel.org
[ Replaced 'trace_fields=' with 'trace_fields: ' to make the output consistent in -v mode ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-01-07 08:12:29 +08:00
|
|
|
if (pos->attr.type == PERF_TYPE_TRACEPOINT)
|
|
|
|
has_tracepoint = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (has_tracepoint && !details->trace_fields)
|
|
|
|
printf("# Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events\n");
|
|
|
|
|
2011-03-15 22:04:13 +08:00
|
|
|
perf_session__delete(session);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-03-27 22:47:20 +08:00
|
|
|
int cmd_evlist(int argc, const char **argv)
|
2011-03-15 22:04:13 +08:00
|
|
|
{
|
perf evlist: Show event attribute details
There was no easy way to see the frequency used, and with the change of
default, we better provide one.
[root@sandy linux]# perf evlist -F
cycles: sample_freq=4000
[root@sandy linux]# perf evlist -v
cycles: sample_freq=4000, size: 80, sample_type: 391, read_format: 7, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, sample_id_all: 1, exclude_guest: 1
[root@sandy linux]#
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-e1p9poez3nwrgycbmwqmhlsu@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-05-23 01:30:11 +08:00
|
|
|
struct perf_attr_details details = { .verbose = false, };
|
|
|
|
const struct option options[] = {
|
2012-10-02 02:20:58 +08:00
|
|
|
OPT_STRING('i', "input", &input_name, "file", "Input file name"),
|
|
|
|
OPT_BOOLEAN('F', "freq", &details.freq, "Show the sample frequency"),
|
|
|
|
OPT_BOOLEAN('v', "verbose", &details.verbose,
|
|
|
|
"Show all event attr details"),
|
2013-02-07 04:20:02 +08:00
|
|
|
OPT_BOOLEAN('g', "group", &details.event_group,
|
2013-01-22 17:09:47 +08:00
|
|
|
"Show event group information"),
|
2015-04-02 21:47:10 +08:00
|
|
|
OPT_BOOLEAN('f', "force", &details.force, "don't complain, do it"),
|
perf evlist: Add --trace-fields option to show trace fields
To use dynamic sort keys, it might be good to add an option to see the
list of field names.
$ perf evlist -i perf.data.sched
sched:sched_switch
sched:sched_stat_wait
sched:sched_stat_sleep
sched:sched_stat_iowait
sched:sched_stat_runtime
sched:sched_process_fork
sched:sched_wakeup
sched:sched_wakeup_new
sched:sched_migrate_task
# Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events
$ perf evlist -i perf.data.sched --trace-fields
sched:sched_switch: trace_fields: prev_comm,prev_pid,prev_prio,prev_state,next_comm,next_pid,next_prio
sched:sched_stat_wait: trace_fields: comm,pid,delay
sched:sched_stat_sleep: trace_fields: comm,pid,delay
sched:sched_stat_iowait: trace_fields: comm,pid,delay
sched:sched_stat_runtime: trace_fields: comm,pid,runtime,vruntime
sched:sched_process_fork: trace_fields: parent_comm,parent_pid,child_comm,child_pid
sched:sched_wakeup: trace_fields: comm,pid,prio,success,target_cpu
sched:sched_wakeup_new: trace_fields: comm,pid,prio,success,target_cpu
sched:sched_migrate_task: trace_fields: comm,pid,prio,orig_cpu,dest_cpu
Committer notes:
For another file, in verbose mode:
# perf evlist -v --trace-fields
sched:sched_switch: type: 2, size: 112, config: 0x10b, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW, disabled: 1, inherit: 1, mmap: 1, comm: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, trace_fields: prev_comm,prev_pid,prev_prio,prev_state,next_comm,next_pid,next_prio
#
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1452125549-1511-5-git-send-email-namhyung@kernel.org
[ Replaced 'trace_fields=' with 'trace_fields: ' to make the output consistent in -v mode ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-01-07 08:12:29 +08:00
|
|
|
OPT_BOOLEAN(0, "trace-fields", &details.trace_fields, "Show tracepoint fields"),
|
2012-10-02 02:20:58 +08:00
|
|
|
OPT_END()
|
|
|
|
};
|
|
|
|
const char * const evlist_usage[] = {
|
|
|
|
"perf evlist [<options>]",
|
|
|
|
NULL
|
perf evlist: Show event attribute details
There was no easy way to see the frequency used, and with the change of
default, we better provide one.
[root@sandy linux]# perf evlist -F
cycles: sample_freq=4000
[root@sandy linux]# perf evlist -v
cycles: sample_freq=4000, size: 80, sample_type: 391, read_format: 7, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, sample_id_all: 1, exclude_guest: 1
[root@sandy linux]#
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-e1p9poez3nwrgycbmwqmhlsu@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-05-23 01:30:11 +08:00
|
|
|
};
|
|
|
|
|
2011-03-15 22:04:13 +08:00
|
|
|
argc = parse_options(argc, argv, options, evlist_usage, 0);
|
|
|
|
if (argc)
|
|
|
|
usage_with_options(evlist_usage, options);
|
|
|
|
|
2013-02-07 04:20:02 +08:00
|
|
|
if (details.event_group && (details.verbose || details.freq)) {
|
2015-10-24 23:49:27 +08:00
|
|
|
usage_with_options_msg(evlist_usage, options,
|
|
|
|
"--group option is not compatible with other options\n");
|
2013-01-22 17:09:47 +08:00
|
|
|
}
|
|
|
|
|
perf evlist: Show event attribute details
There was no easy way to see the frequency used, and with the change of
default, we better provide one.
[root@sandy linux]# perf evlist -F
cycles: sample_freq=4000
[root@sandy linux]# perf evlist -v
cycles: sample_freq=4000, size: 80, sample_type: 391, read_format: 7, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, sample_id_all: 1, exclude_guest: 1
[root@sandy linux]#
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-e1p9poez3nwrgycbmwqmhlsu@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-05-23 01:30:11 +08:00
|
|
|
return __cmd_evlist(input_name, &details);
|
2011-03-15 22:04:13 +08:00
|
|
|
}
|