Merge tag 'dt-for-3.17' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
[firefly-linux-kernel-4.4.55.git] / tools / perf / builtin-script.c
index 9e9c91f5b7fae97de166583b46bd801fc4ccc2f1..f57035b89c15d11a5178cd3468cf5bd9b03405c1 100644 (file)
@@ -358,27 +358,6 @@ static void print_sample_start(struct perf_sample *sample,
        }
 }
 
-static bool is_bts_event(struct perf_event_attr *attr)
-{
-       return ((attr->type == PERF_TYPE_HARDWARE) &&
-               (attr->config & PERF_COUNT_HW_BRANCH_INSTRUCTIONS) &&
-               (attr->sample_period == 1));
-}
-
-static bool sample_addr_correlates_sym(struct perf_event_attr *attr)
-{
-       if ((attr->type == PERF_TYPE_SOFTWARE) &&
-           ((attr->config == PERF_COUNT_SW_PAGE_FAULTS) ||
-            (attr->config == PERF_COUNT_SW_PAGE_FAULTS_MIN) ||
-            (attr->config == PERF_COUNT_SW_PAGE_FAULTS_MAJ)))
-               return true;
-
-       if (is_bts_event(attr))
-               return true;
-
-       return false;
-}
-
 static void print_sample_addr(union perf_event *event,
                          struct perf_sample *sample,
                          struct machine *machine,
@@ -386,24 +365,13 @@ static void print_sample_addr(union perf_event *event,
                          struct perf_event_attr *attr)
 {
        struct addr_location al;
-       u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
 
        printf("%16" PRIx64, sample->addr);
 
        if (!sample_addr_correlates_sym(attr))
                return;
 
-       thread__find_addr_map(thread, machine, cpumode, MAP__FUNCTION,
-                             sample->addr, &al);
-       if (!al.map)
-               thread__find_addr_map(thread, machine, cpumode, MAP__VARIABLE,
-                                     sample->addr, &al);
-
-       al.cpu = sample->cpu;
-       al.sym = NULL;
-
-       if (al.map)
-               al.sym = map__find_symbol(al.map, al.addr, NULL);
+       perf_event__preprocess_sample_addr(event, sample, machine, thread, &al);
 
        if (PRINT_FIELD(SYM)) {
                printf(" ");
@@ -427,25 +395,35 @@ static void print_sample_bts(union perf_event *event,
                             struct addr_location *al)
 {
        struct perf_event_attr *attr = &evsel->attr;
+       bool print_srcline_last = false;
 
        /* print branch_from information */
        if (PRINT_FIELD(IP)) {
-               if (!symbol_conf.use_callchain)
-                       printf(" ");
-               else
+               unsigned int print_opts = output[attr->type].print_ip_opts;
+
+               if (symbol_conf.use_callchain && sample->callchain) {
                        printf("\n");
-               perf_evsel__print_ip(evsel, sample, al,
-                                    output[attr->type].print_ip_opts,
+               } else {
+                       printf(" ");
+                       if (print_opts & PRINT_IP_OPT_SRCLINE) {
+                               print_srcline_last = true;
+                               print_opts &= ~PRINT_IP_OPT_SRCLINE;
+                       }
+               }
+               perf_evsel__print_ip(evsel, sample, al, print_opts,
                                     PERF_MAX_STACK_DEPTH);
        }
 
-       printf(" => ");
-
        /* print branch_to information */
        if (PRINT_FIELD(ADDR) ||
            ((evsel->attr.sample_type & PERF_SAMPLE_ADDR) &&
-            !output[attr->type].user_set))
+            !output[attr->type].user_set)) {
+               printf(" => ");
                print_sample_addr(event, sample, al->machine, thread, attr);
+       }
+
+       if (print_srcline_last)
+               map__fprintf_srcline(al->map, al->addr, "\n  ", stdout);
 
        printf("\n");
 }