This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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 v2] This patch replaces the linear search in find_pc_sect_line with a binary search for faster performance.


Stephen Roberts <stephen.roberts@arm.com> writes:

> I've made all the suggested changes except for one - I break on a specific line because the code is templatized so I can't set breakpoints on specific methods.
> I know I could use rbreak, but I feel that this would make the test less clear and would include the overhead of looking up functions by regex, which is not relevant to this fix.
> If you still think I should go ahead and use rbreak, let me know.
>

That is fine by me.

>  
> -      for (i = 0; i < len; i++, item++)
> -	{
> -	  /* Leave prev pointing to the linetable entry for the last line
> -	     that started at or before PC.  */
> -	  if (item->pc > pc)
> -	    break;
> +    auto pc_compare = [](const CORE_ADDR & pc,
> +			 const struct linetable_entry & lhs)->bool

The indentation looks wrong.  It needs six spaces before "auto" instead
of four spaces.

> +    {
> +      return pc < lhs.pc;
> +    };
>  
> -	  prev = item;
> -	}
> +    struct linetable_entry *first = item;
> +    struct linetable_entry *last = item + len;
> +    item = std::upper_bound (first, last, pc, pc_compare);
> +    if (item != first)
> +      prev = item - 1;		/* Found a matching item.  */

Otherwise, patch is good to me.  If no one has comments in three days,
you can push it in.

Do you have a sourceware account?  With that account/ssh key, you can
push your commit to gdb repository.
https://sourceware.org/cgi-bin/pdw/ps_form.cgi

-- 
Yao (齐尧)


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