lkml.org 
[lkml]   [2016]   [May]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH 1/2] perf tools: fix handling of zero-length symbols.
Em Sat, May 07, 2016 at 02:16:59AM -0700, Chris Phlipot escreveu:
> This change introduces a fix to symbols__find, so that it is able to find
> symbols of length zero (where start==end)
>
> The current code has the following problem:
> -The current implementation of symbols__find is unable to find any symbols
> of length zero.
> -The db-export framework explicitly creates zero length symbols at
> locations where no symbol currently exists.
>
> The combination of the two above behaviors results in behavior similar to
> the example below.

Ok, but you made the unlikely case be the first test, how about this one
liner instead?

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 415c4f6d98fd..7a0917569fb3 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -301,7 +301,7 @@ static struct symbol *symbols__find(struct rb_root *symbols, u64 ip)

if (ip < s->start)
n = n->rb_left;
- else if (ip >= s->end)
+ else if (ip > s->end || (ip == s->end && ip != s->start)
n = n->rb_right;
else
return s;

> +++ b/tools/perf/util/symbol.c
> @@ -299,7 +299,9 @@ static struct symbol *symbols__find(struct rb_root *symbols, u64 ip)
> while (n) {
> struct symbol *s = rb_entry(n, struct symbol, rb_node);
>
> - if (ip < s->start)
> + if (ip == s->start && s->start == s->end)
> + return s;
> + else if (ip < s->start)
> n = n->rb_left;
> else if (ip >= s->end)
> n = n->rb_right;
> --
> 2.7.4

\
 
 \ /
  Last update: 2016-05-09 19:21    [W:0.052 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site