]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gdb/btrace.c
btrace: Use binary search to find instruction.
authorTim Wiederhake <tim.wiederhake@intel.com>
Mon, 21 Nov 2016 15:39:57 +0000 (16:39 +0100)
committerTim Wiederhake <tim.wiederhake@intel.com>
Tue, 14 Feb 2017 09:57:56 +0000 (10:57 +0100)
commitfdd2bd920bd67e6a1e877baf52b9c138c00da13f
treed922fe98c14de1b2831fe4958b221eff5a298941
parent508352a9bf3f84f2d731397bb0d9382c84f27f25
btrace: Use binary search to find instruction.

Currently, btrace_find_insn_by_number will iterate over all function call
segments to find the one that contains the needed instruction.  This linear
search is too slow for the upcoming Python bindings that will use this
function to access instructions.  This patch introduces a vector in struct
btrace_thread_info that holds pointers to all recorded function segments and
allows to use binary search.

The proper solution is to turn the underlying tree into a vector of objects
and use indices for access.  This requires more work.  A patch set is
currently being worked on and will be published later.

Signed-off-by: Tim Wiederhake <tim.wiederhake@intel.com>
gdb/ChangeLog:
* btrace.c (btrace_fetch): Copy function call segments pointer
into a vector.
(btrace_clear): Clear the vector.
(btrace_find_insn_by_number): Use binary search to find the correct
function call segment.
* btrace.h (brace_fun_p): New typedef.
(struct btrace_thread_info) <functions>: New field.

Change-Id: I8a7f67e80bfe4ff62c4192f74a2153a70bf2a035
gdb/btrace.c
gdb/btrace.h