perf srcline: Do not consider empty files as valid srclines
authorMilian Wolff <milian.wolff@kdab.com>
Sun, 6 Aug 2017 21:24:45 +0000 (23:24 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 11 Aug 2017 19:06:31 +0000 (16:06 -0300)
Sometimes we get a non-null, but empty, string for the filename from
bfd. This then results in srclines of the form ":0", which is different
from the canonical SRCLINE_UNKNOWN in the form "??:0".  Set the file to
NULL if it is empty to fix this.

Signed-off-by: Milian Wolff <milian.wolff@kdab.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Yao Jin <yao.jin@linux.intel.com>
Link: http://lkml.kernel.org/r/20170806212446.24925-14-milian.wolff@kdab.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/srcline.c

index ebc88a7..ed8e8d2 100644 (file)
@@ -155,6 +155,9 @@ static void find_address_in_section(bfd *abfd, asection *section, void *data)
        a2l->found = bfd_find_nearest_line(abfd, section, a2l->syms, pc - vma,
                                           &a2l->filename, &a2l->funcname,
                                           &a2l->line);
+
+       if (a2l->filename && !strlen(a2l->filename))
+               a2l->filename = NULL;
 }
 
 static struct a2l_data *addr2line_init(const char *path)
@@ -248,6 +251,9 @@ static int addr2line(const char *dso_name, u64 addr,
                                             &a2l->funcname, &a2l->line) &&
                       cnt++ < MAX_INLINE_NEST) {
 
+                       if (a2l->filename && !strlen(a2l->filename))
+                               a2l->filename = NULL;
+
                        if (node != NULL) {
                                if (inline_list__append_dso_a2l(dso, node))
                                        return 0;