On 12/13/2014 11:42 AM, Mark Wielaard wrote:
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(a)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.
Ah, yes, of course. I squashed the old else (==) into that branch, but
somehow didn't think about that becoming a plain else itself. :)
This is fine, with or without that change (but please explain it
then).
I'll simplify it as you suggest.
Thanks,
Josh