perf tools: Add stat events fprintf functions
authorJiri Olsa <jolsa@kernel.org>
Sun, 25 Oct 2015 14:51:35 +0000 (15:51 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 17 Dec 2015 18:09:38 +0000 (15:09 -0300)
Introducing the following functions to display the stat events for raw
dump.

  perf_event__fprintf_stat
  perf_event__fprintf_stat_round
  perf_event__fprintf_stat_config

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Kan Liang <kan.liang@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1445784728-21732-20-git-send-email-jolsa@kernel.org
[ s/stat/st/g and s/round/rd/g parameters to fix 'already defined' build error with older distros (e.g. RHEL6.7) ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/stat.c
tools/perf/util/stat.h

index 0ad59cea318c1a97306146c85bfa4a0e16f3c163..2f901d15e06370d26d579869d351811f4d31f940 100644 (file)
@@ -364,3 +364,42 @@ int perf_event__process_stat_event(struct perf_tool *tool __maybe_unused,
        counter->supported = true;
        return 0;
 }
+
+size_t perf_event__fprintf_stat(union perf_event *event, FILE *fp)
+{
+       struct stat_event *st = (struct stat_event *) event;
+       size_t ret;
+
+       ret  = fprintf(fp, "\n... id %" PRIu64 ", cpu %d, thread %d\n",
+                      st->id, st->cpu, st->thread);
+       ret += fprintf(fp, "... value %" PRIu64 ", enabled %" PRIu64 ", running %" PRIu64 "\n",
+                      st->val, st->ena, st->run);
+
+       return ret;
+}
+
+size_t perf_event__fprintf_stat_round(union perf_event *event, FILE *fp)
+{
+       struct stat_round_event *rd = (struct stat_round_event *)event;
+       size_t ret;
+
+       ret = fprintf(fp, "\n... time %" PRIu64 ", type %s\n", rd->time,
+                     rd->type == PERF_STAT_ROUND_TYPE__FINAL ? "FINAL" : "INTERVAL");
+
+       return ret;
+}
+
+size_t perf_event__fprintf_stat_config(union perf_event *event, FILE *fp)
+{
+       struct perf_stat_config sc;
+       size_t ret;
+
+       perf_event__read_stat_config(&sc, &event->stat_config);
+
+       ret  = fprintf(fp, "\n");
+       ret += fprintf(fp, "... aggr_mode %d\n", sc.aggr_mode);
+       ret += fprintf(fp, "... scale     %d\n", sc.scale);
+       ret += fprintf(fp, "... interval  %u\n", sc.interval);
+
+       return ret;
+}
index afe6844e5219cbb4bb65a3407667550dba023495..086f4e128d6351f0e0de862c2ebcc44801cbc2f8 100644 (file)
@@ -96,4 +96,8 @@ struct perf_session;
 int perf_event__process_stat_event(struct perf_tool *tool,
                                   union perf_event *event,
                                   struct perf_session *session);
+
+size_t perf_event__fprintf_stat(union perf_event *event, FILE *fp);
+size_t perf_event__fprintf_stat_round(union perf_event *event, FILE *fp);
+size_t perf_event__fprintf_stat_config(union perf_event *event, FILE *fp);
 #endif