]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - tools/perf/util/auxtrace.c
Merge branch 'ras-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[karo-tx-linux.git] / tools / perf / util / auxtrace.c
index 83d9dd96fe08ea8c613d1bda4db9b00bf4d04cd9..7f10430af39c3ac9e47f4da1aca93e37a8f9cf87 100644 (file)
@@ -47,6 +47,9 @@
 #include "debug.h"
 #include "parse-options.h"
 
+#include "intel-pt.h"
+#include "intel-bts.h"
+
 int auxtrace_mmap__mmap(struct auxtrace_mmap *mm,
                        struct auxtrace_mmap_params *mp,
                        void *userpg, int fd)
@@ -876,7 +879,7 @@ static bool auxtrace__dont_decode(struct perf_session *session)
 
 int perf_event__process_auxtrace_info(struct perf_tool *tool __maybe_unused,
                                      union perf_event *event,
-                                     struct perf_session *session __maybe_unused)
+                                     struct perf_session *session)
 {
        enum auxtrace_type type = event->auxtrace_info.type;
 
@@ -884,6 +887,10 @@ int perf_event__process_auxtrace_info(struct perf_tool *tool __maybe_unused,
                fprintf(stdout, " type: %u\n", type);
 
        switch (type) {
+       case PERF_AUXTRACE_INTEL_PT:
+               return intel_pt_process_auxtrace_info(event, session);
+       case PERF_AUXTRACE_INTEL_BTS:
+               return intel_bts_process_auxtrace_info(event, session);
        case PERF_AUXTRACE_UNKNOWN:
        default:
                return -EINVAL;
@@ -919,6 +926,8 @@ s64 perf_event__process_auxtrace(struct perf_tool *tool,
 #define PERF_ITRACE_DEFAULT_PERIOD             100000
 #define PERF_ITRACE_DEFAULT_CALLCHAIN_SZ       16
 #define PERF_ITRACE_MAX_CALLCHAIN_SZ           1024
+#define PERF_ITRACE_DEFAULT_LAST_BRANCH_SZ     64
+#define PERF_ITRACE_MAX_LAST_BRANCH_SZ         1024
 
 void itrace_synth_opts__set_default(struct itrace_synth_opts *synth_opts)
 {
@@ -929,6 +938,7 @@ void itrace_synth_opts__set_default(struct itrace_synth_opts *synth_opts)
        synth_opts->period_type = PERF_ITRACE_DEFAULT_PERIOD_TYPE;
        synth_opts->period = PERF_ITRACE_DEFAULT_PERIOD;
        synth_opts->callchain_sz = PERF_ITRACE_DEFAULT_CALLCHAIN_SZ;
+       synth_opts->last_branch_sz = PERF_ITRACE_DEFAULT_LAST_BRANCH_SZ;
 }
 
 /*
@@ -942,6 +952,8 @@ int itrace_parse_synth_opts(const struct option *opt, const char *str,
        struct itrace_synth_opts *synth_opts = opt->value;
        const char *p;
        char *endptr;
+       bool period_type_set = false;
+       bool period_set = false;
 
        synth_opts->set = true;
 
@@ -963,6 +975,7 @@ int itrace_parse_synth_opts(const struct option *opt, const char *str,
                                p += 1;
                        if (isdigit(*p)) {
                                synth_opts->period = strtoull(p, &endptr, 10);
+                               period_set = true;
                                p = endptr;
                                while (*p == ' ' || *p == ',')
                                        p += 1;
@@ -970,10 +983,12 @@ int itrace_parse_synth_opts(const struct option *opt, const char *str,
                                case 'i':
                                        synth_opts->period_type =
                                                PERF_ITRACE_PERIOD_INSTRUCTIONS;
+                                       period_type_set = true;
                                        break;
                                case 't':
                                        synth_opts->period_type =
                                                PERF_ITRACE_PERIOD_TICKS;
+                                       period_type_set = true;
                                        break;
                                case 'm':
                                        synth_opts->period *= 1000;
@@ -986,6 +1001,7 @@ int itrace_parse_synth_opts(const struct option *opt, const char *str,
                                                goto out_err;
                                        synth_opts->period_type =
                                                PERF_ITRACE_PERIOD_NANOSECS;
+                                       period_type_set = true;
                                        break;
                                case '\0':
                                        goto out;
@@ -1030,6 +1046,23 @@ int itrace_parse_synth_opts(const struct option *opt, const char *str,
                                synth_opts->callchain_sz = val;
                        }
                        break;
+               case 'l':
+                       synth_opts->last_branch = true;
+                       synth_opts->last_branch_sz =
+                                       PERF_ITRACE_DEFAULT_LAST_BRANCH_SZ;
+                       while (*p == ' ' || *p == ',')
+                               p += 1;
+                       if (isdigit(*p)) {
+                               unsigned int val;
+
+                               val = strtoul(p, &endptr, 10);
+                               p = endptr;
+                               if (!val ||
+                                   val > PERF_ITRACE_MAX_LAST_BRANCH_SZ)
+                                       goto out_err;
+                               synth_opts->last_branch_sz = val;
+                       }
+                       break;
                case ' ':
                case ',':
                        break;
@@ -1039,10 +1072,10 @@ int itrace_parse_synth_opts(const struct option *opt, const char *str,
        }
 out:
        if (synth_opts->instructions) {
-               if (!synth_opts->period_type)
+               if (!period_type_set)
                        synth_opts->period_type =
                                        PERF_ITRACE_DEFAULT_PERIOD_TYPE;
-               if (!synth_opts->period)
+               if (!period_set)
                        synth_opts->period = PERF_ITRACE_DEFAULT_PERIOD;
        }