diff options
author | Tim Wiederhake <tim.wiederhake@intel.com> | 2016-11-21 16:39:57 +0100 |
---|---|---|
committer | Tim Wiederhake <tim.wiederhake@intel.com> | 2017-02-14 10:57:56 +0100 |
commit | fdd2bd920bd67e6a1e877baf52b9c138c00da13f (patch) | |
tree | d922fe98c14de1b2831fe4958b221eff5a298941 /gdb/btrace.h | |
parent | 508352a9bf3f84f2d731397bb0d9382c84f27f25 (diff) | |
download | gdb-fdd2bd920bd67e6a1e877baf52b9c138c00da13f.zip gdb-fdd2bd920bd67e6a1e877baf52b9c138c00da13f.tar.gz gdb-fdd2bd920bd67e6a1e877baf52b9c138c00da13f.tar.bz2 |
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
Diffstat (limited to 'gdb/btrace.h')
-rw-r--r-- | gdb/btrace.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gdb/btrace.h b/gdb/btrace.h index 1c0b6b3..07ed10c 100644 --- a/gdb/btrace.h +++ b/gdb/btrace.h @@ -187,6 +187,9 @@ struct btrace_function btrace_function_flags flags; }; +typedef struct btrace_function *btrace_fun_p; +DEF_VEC_P (btrace_fun_p); + /* A branch trace instruction iterator. */ struct btrace_insn_iterator { @@ -337,6 +340,10 @@ struct btrace_thread_info struct btrace_function *begin; struct btrace_function *end; + /* Vector of pointer to decoded function segments. These are in execution + order with the first element == BEGIN and the last element == END. */ + VEC (btrace_fun_p) *functions; + /* The function level offset. When added to each function's LEVEL, this normalizes the function levels such that the smallest level becomes zero. */ |