From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751501AbcEIRvb (ORCPT ); Mon, 9 May 2016 13:51:31 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:35932 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751152AbcEIRv3 convert rfc822-to-8bit (ORCPT ); Mon, 9 May 2016 13:51:29 -0400 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (1.0) Subject: Re: [PATCH 1/2] perf tools: fix handling of zero-length symbols. From: Chris Phlipot X-Mailer: iPhone Mail (13E238) In-Reply-To: <20160509170631.GC5101@kernel.org> Date: Mon, 9 May 2016 10:51:24 -0700 Cc: adrian.hunter@intel.com, peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <5AB18302-4E55-47D2-96DC-14571CAA1865@gmail.com> References: <1462612620-25008-1-git-send-email-cphlipot0@gmail.com> <20160509170631.GC5101@kernel.org> To: Arnaldo Carvalho de Melo Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On May 9, 2016, at 10:06 AM, Arnaldo Carvalho de Melo wrote: > > 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; > > I agree. This looks like a better fix. >> +++ 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