aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung.kim@lge.com>2013-01-22 04:09:47 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-01-31 11:07:49 -0500
commite6ab07d027d47e55d8a5c0f33b16dfdd3e18c96f (patch)
treee53b70cb5b0517e1783cd10f888b775a4d8f25f3 /tools
parent00c7e1f10c6b8ae8a031f5c6a58ecd15d20c52cb (diff)
perf evlist: Add --group option
Add '-g/--group' option for showing event groups. For simplicity it is currently not compatible with other options. $ perf evlist --group {ref-cycles,cycles} $ perf evlist ref-cycles cycles Suggested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1358845787-1350-20-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/Documentation/perf-evlist.txt4
-rw-r--r--tools/perf/builtin-evlist.c7
-rw-r--r--tools/perf/util/evsel.c24
3 files changed, 33 insertions, 2 deletions
diff --git a/tools/perf/Documentation/perf-evlist.txt b/tools/perf/Documentation/perf-evlist.txt
index 15217345c2fa..1ceb3700ffbb 100644
--- a/tools/perf/Documentation/perf-evlist.txt
+++ b/tools/perf/Documentation/perf-evlist.txt
@@ -28,6 +28,10 @@ OPTIONS
28--verbose=:: 28--verbose=::
29 Show all fields. 29 Show all fields.
30 30
31-g::
32--group::
33 Show event group information.
34
31SEE ALSO 35SEE ALSO
32-------- 36--------
33linkperf:perf-record[1], linkperf:perf-list[1], 37linkperf:perf-record[1], linkperf:perf-list[1],
diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c
index 1312a5e03ec7..85a5e35dd147 100644
--- a/tools/perf/builtin-evlist.c
+++ b/tools/perf/builtin-evlist.c
@@ -39,6 +39,8 @@ int cmd_evlist(int argc, const char **argv, const char *prefix __maybe_unused)
39 OPT_BOOLEAN('F', "freq", &details.freq, "Show the sample frequency"), 39 OPT_BOOLEAN('F', "freq", &details.freq, "Show the sample frequency"),
40 OPT_BOOLEAN('v', "verbose", &details.verbose, 40 OPT_BOOLEAN('v', "verbose", &details.verbose,
41 "Show all event attr details"), 41 "Show all event attr details"),
42 OPT_BOOLEAN('g', "group", &symbol_conf.event_group,
43 "Show event group information"),
42 OPT_END() 44 OPT_END()
43 }; 45 };
44 const char * const evlist_usage[] = { 46 const char * const evlist_usage[] = {
@@ -50,5 +52,10 @@ int cmd_evlist(int argc, const char **argv, const char *prefix __maybe_unused)
50 if (argc) 52 if (argc)
51 usage_with_options(evlist_usage, options); 53 usage_with_options(evlist_usage, options);
52 54
55 if (symbol_conf.event_group && (details.verbose || details.freq)) {
56 pr_err("--group option is not compatible with other options\n");
57 usage_with_options(evlist_usage, options);
58 }
59
53 return __cmd_evlist(input_name, &details); 60 return __cmd_evlist(input_name, &details);
54} 61}
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 94e74043ded8..a54701504606 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1389,7 +1389,27 @@ int perf_evsel__fprintf(struct perf_evsel *evsel,
1389 struct perf_attr_details *details, FILE *fp) 1389 struct perf_attr_details *details, FILE *fp)
1390{ 1390{
1391 bool first = true; 1391 bool first = true;
1392 int printed = fprintf(fp, "%s", perf_evsel__name(evsel)); 1392 int printed = 0;
1393
1394 if (symbol_conf.event_group) {
1395 struct perf_evsel *pos;
1396
1397 if (!perf_evsel__is_group_leader(evsel))
1398 return 0;
1399
1400 if (evsel->nr_members > 1)
1401 printed += fprintf(fp, "%s{", evsel->group_name ?: "");
1402
1403 printed += fprintf(fp, "%s", perf_evsel__name(evsel));
1404 for_each_group_member(pos, evsel)
1405 printed += fprintf(fp, ",%s", perf_evsel__name(pos));
1406
1407 if (evsel->nr_members > 1)
1408 printed += fprintf(fp, "}");
1409 goto out;
1410 }
1411
1412 printed += fprintf(fp, "%s", perf_evsel__name(evsel));
1393 1413
1394 if (details->verbose || details->freq) { 1414 if (details->verbose || details->freq) {
1395 printed += comma_fprintf(fp, &first, " sample_freq=%" PRIu64, 1415 printed += comma_fprintf(fp, &first, " sample_freq=%" PRIu64,
@@ -1430,7 +1450,7 @@ int perf_evsel__fprintf(struct perf_evsel *evsel,
1430 if_print(bp_type); 1450 if_print(bp_type);
1431 if_print(branch_sample_type); 1451 if_print(branch_sample_type);
1432 } 1452 }
1433 1453out:
1434 fputc('\n', fp); 1454 fputc('\n', fp);
1435 return ++printed; 1455 return ++printed;
1436} 1456}