Commit e6ab07d0 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarNamhyung 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.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 00c7e1f1
...@@ -28,6 +28,10 @@ OPTIONS ...@@ -28,6 +28,10 @@ OPTIONS
--verbose=:: --verbose=::
Show all fields. Show all fields.
-g::
--group::
Show event group information.
SEE ALSO SEE ALSO
-------- --------
linkperf:perf-record[1], linkperf:perf-list[1], linkperf:perf-record[1], linkperf:perf-list[1],
......
...@@ -39,6 +39,8 @@ int cmd_evlist(int argc, const char **argv, const char *prefix __maybe_unused) ...@@ -39,6 +39,8 @@ int cmd_evlist(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_BOOLEAN('F', "freq", &details.freq, "Show the sample frequency"), OPT_BOOLEAN('F', "freq", &details.freq, "Show the sample frequency"),
OPT_BOOLEAN('v', "verbose", &details.verbose, OPT_BOOLEAN('v', "verbose", &details.verbose,
"Show all event attr details"), "Show all event attr details"),
OPT_BOOLEAN('g', "group", &symbol_conf.event_group,
"Show event group information"),
OPT_END() OPT_END()
}; };
const char * const evlist_usage[] = { const char * const evlist_usage[] = {
...@@ -50,5 +52,10 @@ int cmd_evlist(int argc, const char **argv, const char *prefix __maybe_unused) ...@@ -50,5 +52,10 @@ int cmd_evlist(int argc, const char **argv, const char *prefix __maybe_unused)
if (argc) if (argc)
usage_with_options(evlist_usage, options); usage_with_options(evlist_usage, options);
if (symbol_conf.event_group && (details.verbose || details.freq)) {
pr_err("--group option is not compatible with other options\n");
usage_with_options(evlist_usage, options);
}
return __cmd_evlist(input_name, &details); return __cmd_evlist(input_name, &details);
} }
...@@ -1389,7 +1389,27 @@ int perf_evsel__fprintf(struct perf_evsel *evsel, ...@@ -1389,7 +1389,27 @@ int perf_evsel__fprintf(struct perf_evsel *evsel,
struct perf_attr_details *details, FILE *fp) struct perf_attr_details *details, FILE *fp)
{ {
bool first = true; bool first = true;
int printed = fprintf(fp, "%s", perf_evsel__name(evsel)); int printed = 0;
if (symbol_conf.event_group) {
struct perf_evsel *pos;
if (!perf_evsel__is_group_leader(evsel))
return 0;
if (evsel->nr_members > 1)
printed += fprintf(fp, "%s{", evsel->group_name ?: "");
printed += fprintf(fp, "%s", perf_evsel__name(evsel));
for_each_group_member(pos, evsel)
printed += fprintf(fp, ",%s", perf_evsel__name(pos));
if (evsel->nr_members > 1)
printed += fprintf(fp, "}");
goto out;
}
printed += fprintf(fp, "%s", perf_evsel__name(evsel));
if (details->verbose || details->freq) { if (details->verbose || details->freq) {
printed += comma_fprintf(fp, &first, " sample_freq=%" PRIu64, printed += comma_fprintf(fp, &first, " sample_freq=%" PRIu64,
...@@ -1430,7 +1450,7 @@ int perf_evsel__fprintf(struct perf_evsel *evsel, ...@@ -1430,7 +1450,7 @@ int perf_evsel__fprintf(struct perf_evsel *evsel,
if_print(bp_type); if_print(bp_type);
if_print(branch_sample_type); if_print(branch_sample_type);
} }
out:
fputc('\n', fp); fputc('\n', fp);
return ++printed; return ++printed;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment