Commit d41687c8 authored by He Kuang's avatar He Kuang Committed by Greg Kroah-Hartman

perf report: Don't shadow inlined symbol with different addr range

[ Upstream commit 7346195e ]

We can't assume inlined symbols with the same name are equal, because
their address range may be different. This will cause the symbols with
different addresses be shadowed when adding to the hist entry, and lead
to ERANGE error when checking the symbol address during sample parse,
the addr should be within the range of [sym.start, sym.end].

The error message is like: "0x36aea60f [0x8]: failed to process type: 68".

The second parameter of symbol__new() is the length of the fake symbol
for the inline frame, which is the subtraction of the end and start
address of base_sym.
Signed-off-by: default avatarHe Kuang <hekuang@huawei.com>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Milian Wolff <milian.wolff@kdab.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Fixes: aa441895 ("perf report: Compare symbol name for inlined frames when sorting")
Link: http://lkml.kernel.org/r/20190219130531.15692-1-hekuang@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 801b8d8c
...@@ -229,8 +229,14 @@ static int64_t _sort__sym_cmp(struct symbol *sym_l, struct symbol *sym_r) ...@@ -229,8 +229,14 @@ static int64_t _sort__sym_cmp(struct symbol *sym_l, struct symbol *sym_r)
if (sym_l == sym_r) if (sym_l == sym_r)
return 0; return 0;
if (sym_l->inlined || sym_r->inlined) if (sym_l->inlined || sym_r->inlined) {
return strcmp(sym_l->name, sym_r->name); int ret = strcmp(sym_l->name, sym_r->name);
if (ret)
return ret;
if ((sym_l->start <= sym_r->end) && (sym_l->end >= sym_r->start))
return 0;
}
if (sym_l->start != sym_r->start) if (sym_l->start != sym_r->start)
return (int64_t)(sym_r->start - sym_l->start); return (int64_t)(sym_r->start - sym_l->start);
......
...@@ -104,7 +104,7 @@ static struct symbol *new_inline_sym(struct dso *dso, ...@@ -104,7 +104,7 @@ static struct symbol *new_inline_sym(struct dso *dso,
} else { } else {
/* create a fake symbol for the inline frame */ /* create a fake symbol for the inline frame */
inline_sym = symbol__new(base_sym ? base_sym->start : 0, inline_sym = symbol__new(base_sym ? base_sym->start : 0,
base_sym ? base_sym->end : 0, base_sym ? (base_sym->end - base_sym->start) : 0,
base_sym ? base_sym->binding : 0, base_sym ? base_sym->binding : 0,
base_sym ? base_sym->type : 0, base_sym ? base_sym->type : 0,
funcname); funcname);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment