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

Mark Wielaard mjw at redhat.com
Sat Dec 13 19:42:56 UTC 2014


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 at 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


More information about the elfutils-devel mailing list