Merge tag 'iomap-5.5-merge-14' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
[linux-2.6-microblaze.git] / tools / perf / builtin-script.c
index f86c5cc..e2406b2 100644 (file)
@@ -448,7 +448,7 @@ static int perf_evsel__check_attr(struct evsel *evsel,
                       "selected. Hence, no address to lookup the source line number.\n");
                return -EINVAL;
        }
-       if (PRINT_FIELD(BRSTACKINSN) &&
+       if (PRINT_FIELD(BRSTACKINSN) && !allow_user_set &&
            !(perf_evlist__combined_branch_type(session->evlist) &
              PERF_SAMPLE_BRANCH_ANY)) {
                pr_err("Display of branch stack assembler requested, but non all-branch filter set\n"
@@ -932,6 +932,48 @@ static int grab_bb(u8 *buffer, u64 start, u64 end,
        return len;
 }
 
+static int map__fprintf_srccode(struct map *map, u64 addr, FILE *fp, struct srccode_state *state)
+{
+       char *srcfile;
+       int ret = 0;
+       unsigned line;
+       int len;
+       char *srccode;
+
+       if (!map || !map->dso)
+               return 0;
+       srcfile = get_srcline_split(map->dso,
+                                   map__rip_2objdump(map, addr),
+                                   &line);
+       if (!srcfile)
+               return 0;
+
+       /* Avoid redundant printing */
+       if (state &&
+           state->srcfile &&
+           !strcmp(state->srcfile, srcfile) &&
+           state->line == line) {
+               free(srcfile);
+               return 0;
+       }
+
+       srccode = find_sourceline(srcfile, line, &len);
+       if (!srccode)
+               goto out_free_line;
+
+       ret = fprintf(fp, "|%-8d %.*s", line, len, srccode);
+
+       if (state) {
+               state->srcfile = srcfile;
+               state->line = line;
+       }
+       return ret;
+
+out_free_line:
+       free(srcfile);
+       return ret;
+}
+
 static int print_srccode(struct thread *thread, u8 cpumode, uint64_t addr)
 {
        struct addr_location al;
@@ -1084,7 +1126,7 @@ static int perf_sample__fprintf_brstackinsn(struct perf_sample *sample,
                                insn++;
                        }
                }
-               if (off != (unsigned)len)
+               if (off != end - start)
                        printed += fprintf(fp, "\tmismatch of LBR data and executable\n");
        }