1 /* Branch trace support for GDB, the GNU debugger.
3 Copyright (C) 2013-2014 Free Software Foundation, Inc.
5 Contributed by Intel Corp. <markus.t.metzger@intel.com>.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 /* Branch tracing (btrace) is a per-thread control-flow execution trace of the
26 inferior. For presentation purposes, the branch trace is represented as a
27 list of sequential control-flow blocks, one such list per thread. */
29 #include "btrace-common.h"
33 /* A branch trace instruction.
35 This represents a single instruction in a branch trace. */
38 /* The address of this instruction. */
42 /* A branch trace function.
44 This represents a function segment in a branch trace, i.e. a consecutive
45 number of instructions belonging to the same function. */
48 /* The full and minimal symbol for the function. One of them may be NULL. */
49 struct minimal_symbol *msym;
52 /* The source line range of this function segment (both inclusive). */
55 /* The instruction number range in the instruction trace corresponding
56 to this function segment (both inclusive). */
57 unsigned int ibegin, iend;
60 /* Branch trace may also be represented as a vector of:
62 - branch trace instructions starting with the oldest instruction.
63 - branch trace functions starting with the oldest function. */
64 typedef struct btrace_inst btrace_inst_s;
65 typedef struct btrace_func btrace_func_s;
67 /* Define functions operating on branch trace vectors. */
68 DEF_VEC_O (btrace_inst_s);
69 DEF_VEC_O (btrace_func_s);
71 /* Branch trace iteration state for "record instruction-history". */
72 struct btrace_insn_iterator
74 /* The instruction index range from begin (inclusive) to end (exclusive)
75 that has been covered last time.
76 If end < begin, the branch trace has just been updated. */
81 /* Branch trace iteration state for "record function-call-history". */
82 struct btrace_func_iterator
84 /* The function index range from begin (inclusive) to end (exclusive)
85 that has been covered last time.
86 If end < begin, the branch trace has just been updated. */
91 /* Branch trace information per thread.
93 This represents the branch trace configuration as well as the entry point
94 into the branch trace data. For the latter, it also contains the index into
95 an array of branch trace blocks used for iterating though the branch trace
96 blocks of a thread. */
97 struct btrace_thread_info
99 /* The target branch trace information for this thread.
101 This contains the branch trace configuration as well as any
102 target-specific information necessary for implementing branch tracing on
103 the underlying architecture. */
104 struct btrace_target_info *target;
106 /* The current branch trace for this thread. */
107 VEC (btrace_block_s) *btrace;
108 VEC (btrace_inst_s) *itrace;
109 VEC (btrace_func_s) *ftrace;
111 /* The instruction history iterator. */
112 struct btrace_insn_iterator insn_iterator;
114 /* The function call history iterator. */
115 struct btrace_func_iterator func_iterator;
118 /* Enable branch tracing for a thread. */
119 extern void btrace_enable (struct thread_info *tp);
121 /* Disable branch tracing for a thread.
122 This will also delete the current branch trace data. */
123 extern void btrace_disable (struct thread_info *);
125 /* Disable branch tracing for a thread during teardown.
126 This is similar to btrace_disable, except that it will use
127 target_teardown_btrace instead of target_disable_btrace. */
128 extern void btrace_teardown (struct thread_info *);
130 /* Fetch the branch trace for a single thread. */
131 extern void btrace_fetch (struct thread_info *);
133 /* Clear the branch trace for a single thread. */
134 extern void btrace_clear (struct thread_info *);
136 /* Clear the branch trace for all threads when an object file goes away. */
137 extern void btrace_free_objfile (struct objfile *);
139 /* Parse a branch trace xml document into a block vector. */
140 extern VEC (btrace_block_s) *parse_xml_btrace (const char*);
142 #endif /* BTRACE_H */