btrace: support Intel(R) Processor Trace
[deliverable/binutils-gdb.git] / gdb / common / btrace-common.c
1 /* Copyright (C) 2014-2015 Free Software Foundation, Inc.
2
3 Contributed by Intel Corp. <markus.t.metzger@intel.com>
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #include "common-defs.h"
21 #include "btrace-common.h"
22
23
24 /* See btrace-common.h. */
25
26 const char *
27 btrace_format_string (enum btrace_format format)
28 {
29 switch (format)
30 {
31 case BTRACE_FORMAT_NONE:
32 return _("No or unknown format");
33
34 case BTRACE_FORMAT_BTS:
35 return _("Branch Trace Store");
36
37 case BTRACE_FORMAT_PT:
38 return _("Intel(R) Processor Trace");
39 }
40
41 internal_error (__FILE__, __LINE__, _("Unknown branch trace format"));
42 }
43
44 /* See btrace-common.h. */
45
46 void
47 btrace_data_init (struct btrace_data *data)
48 {
49 data->format = BTRACE_FORMAT_NONE;
50 }
51
52 /* See btrace-common.h. */
53
54 void
55 btrace_data_fini (struct btrace_data *data)
56 {
57 switch (data->format)
58 {
59 case BTRACE_FORMAT_NONE:
60 /* Nothing to do. */
61 return;
62
63 case BTRACE_FORMAT_BTS:
64 VEC_free (btrace_block_s, data->variant.bts.blocks);
65 return;
66
67 case BTRACE_FORMAT_PT:
68 xfree (data->variant.pt.data);
69 return;
70 }
71
72 internal_error (__FILE__, __LINE__, _("Unkown branch trace format."));
73 }
74
75 /* See btrace-common.h. */
76
77 int
78 btrace_data_empty (struct btrace_data *data)
79 {
80 switch (data->format)
81 {
82 case BTRACE_FORMAT_NONE:
83 return 1;
84
85 case BTRACE_FORMAT_BTS:
86 return VEC_empty (btrace_block_s, data->variant.bts.blocks);
87
88 case BTRACE_FORMAT_PT:
89 return (data->variant.pt.size == 0);
90 }
91
92 internal_error (__FILE__, __LINE__, _("Unkown branch trace format."));
93 }
This page took 0.05831 seconds and 4 git commands to generate.