This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/3] libdwfl: Search for the last matching address in lines


On Thu, Dec 11, 2014 at 05:23:36PM -0800, Josh Stone wrote:
> Now that libdw's srclines use a stable sort, we can reliably choose the
> *last* matching line record for a given address, which should be the
> innermost where inlines are concerned.
>
> +2014-12-11  Josh Stone  <jistone@redhat.com>
> +
> +	* dwfl_module_getsrc.c (dwfl_module_getsrc): Return the *last* line
> +	record <= addr, rather than returning immediately on matches.
> [...]
> +	  size_t l = 0, u = nlines - 1;
> +	  while (l < u)
> +	    {
> +	      size_t idx = u - (u - l) / 2;
> +	      Dwarf_Line *line = &lines->info[idx];
> +	      if (addr < line->addr)
> +		u = idx - 1;
> +	      else if (addr >= line->addr)
> +		l = idx;
> +	    }

That second check (addr >= line->addr) is redundent isn't it?
The compiler probably sees the same and will remove it, but it might be
cleaner if it is just not there. Unless it is needed for some reason
I am missing.

This is fine, with or without that change (but please explain it then).

Thanks,

Mark

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]