Fix elf64-ppc.c electric fence warning
[deliverable/binutils-gdb.git] / gdb / common / btrace-common.h
CommitLineData
02d27625
MM
1/* Branch trace support for GDB, the GNU debugger.
2
32d0add0 3 Copyright (C) 2013-2015 Free Software Foundation, Inc.
02d27625
MM
4
5 Contributed by Intel Corp. <markus.t.metzger@intel.com>.
6
7 This file is part of GDB.
8
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.
13
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.
18
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/>. */
21
22#ifndef BTRACE_COMMON_H
23#define BTRACE_COMMON_H
24
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. */
28
02d27625
MM
29#include "vec.h"
30
31/* A branch trace block.
32
33 This represents a block of sequential control-flow. Adjacent blocks will be
34 connected via calls, returns, or jumps. The latter can be direct or
35 indirect, conditional or unconditional. Branches can further be
36 asynchronous, e.g. interrupts. */
37struct btrace_block
38{
969c39fb
MM
39 /* The address of the first byte of the first instruction in the block.
40 The address may be zero if we do not know the beginning of this block,
41 such as for the first block in a delta trace. */
02d27625
MM
42 CORE_ADDR begin;
43
44 /* The address of the first byte of the last instruction in the block. */
45 CORE_ADDR end;
46};
47
02d27625 48/* Define functions operating on a vector of branch trace blocks. */
734b0e4b 49typedef struct btrace_block btrace_block_s;
02d27625
MM
50DEF_VEC_O (btrace_block_s);
51
734b0e4b
MM
52/* Enumeration of btrace formats. */
53
54enum btrace_format
55{
56 /* No branch trace format. */
57 BTRACE_FORMAT_NONE,
58
59 /* Branch trace is in Branch Trace Store (BTS) format.
60 Actually, the format is a sequence of blocks derived from BTS. */
61 BTRACE_FORMAT_BTS
62};
63
afb778a2
MM
64/* An enumeration of cpu vendors. */
65
66enum btrace_cpu_vendor
67{
68 /* We do not know this vendor. */
69 CV_UNKNOWN,
70
71 /* Intel. */
72 CV_INTEL
73};
74
75/* A cpu identifier. */
76
77struct btrace_cpu
78{
79 /* The processor vendor. */
80 enum btrace_cpu_vendor vendor;
81
82 /* The cpu family. */
83 unsigned short family;
84
85 /* The cpu model. */
86 unsigned char model;
87
88 /* The cpu stepping. */
89 unsigned char stepping;
90};
91
d33501a5
MM
92/* A BTS configuration. */
93
94struct btrace_config_bts
95{
96 /* The size of the branch trace buffer in bytes. */
97 unsigned int size;
98};
99
f4abbc16
MM
100/* A branch tracing configuration.
101
102 This describes the requested configuration as well as the actually
d33501a5
MM
103 obtained configuration.
104 We describe the configuration for all different formats so we can
105 easily switch between formats. */
f4abbc16
MM
106
107struct btrace_config
108{
109 /* The branch tracing format. */
110 enum btrace_format format;
d33501a5
MM
111
112 /* The BTS format configuration. */
113 struct btrace_config_bts bts;
f4abbc16
MM
114};
115
734b0e4b
MM
116/* Branch trace in BTS format. */
117struct btrace_data_bts
118{
119 /* Branch trace is represented as a vector of branch trace blocks starting
120 with the most recent block. */
121 VEC (btrace_block_s) *blocks;
122};
123
124/* The branch trace data. */
125struct btrace_data
126{
127 enum btrace_format format;
128
129 union
130 {
131 /* Format == BTRACE_FORMAT_BTS. */
132 struct btrace_data_bts bts;
133 } variant;
134};
135
02d27625
MM
136/* Target specific branch trace information. */
137struct btrace_target_info;
138
139/* Enumeration of btrace read types. */
140
141enum btrace_read_type
142{
143 /* Send all available trace. */
864089d2 144 BTRACE_READ_ALL,
02d27625
MM
145
146 /* Send all available trace, if it changed. */
969c39fb
MM
147 BTRACE_READ_NEW,
148
149 /* Send the trace since the last request. This will fail if the trace
150 buffer overflowed. */
151 BTRACE_READ_DELTA
152};
153
154/* Enumeration of btrace errors. */
155
156enum btrace_error
157{
158 /* No error. Everything is OK. */
159 BTRACE_ERR_NONE,
160
161 /* An unknown error. */
162 BTRACE_ERR_UNKNOWN,
163
164 /* Branch tracing is not supported on this system. */
165 BTRACE_ERR_NOT_SUPPORTED,
166
167 /* The branch trace buffer overflowed; no delta read possible. */
168 BTRACE_ERR_OVERFLOW
02d27625
MM
169};
170
734b0e4b
MM
171/* Return a string representation of FORMAT. */
172extern const char *btrace_format_string (enum btrace_format format);
173
174/* Initialize DATA. */
175extern void btrace_data_init (struct btrace_data *data);
176
177/* Cleanup DATA. */
178extern void btrace_data_fini (struct btrace_data *data);
179
180/* Return non-zero if DATA is empty; zero otherwise. */
181extern int btrace_data_empty (struct btrace_data *data);
182
02d27625 183#endif /* BTRACE_COMMON_H */
This page took 0.165753 seconds and 4 git commands to generate.