1 /* Copyright (C) 2014-2015 Free Software Foundation, Inc.
3 Contributed by Intel Corp. <markus.t.metzger@intel.com>
5 This file is part of GDB.
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.
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.
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/>. */
20 #include "common-defs.h"
21 #include "btrace-common.h"
24 /* See btrace-common.h. */
27 btrace_format_string (enum btrace_format format
)
31 case BTRACE_FORMAT_NONE
:
32 return _("No or unknown format");
34 case BTRACE_FORMAT_BTS
:
35 return _("Branch Trace Store");
37 case BTRACE_FORMAT_PT
:
38 return _("Intel(R) Processor Trace");
41 internal_error (__FILE__
, __LINE__
, _("Unknown branch trace format"));
44 /* See btrace-common.h. */
47 btrace_data_init (struct btrace_data
*data
)
49 data
->format
= BTRACE_FORMAT_NONE
;
52 /* See btrace-common.h. */
55 btrace_data_fini (struct btrace_data
*data
)
59 case BTRACE_FORMAT_NONE
:
63 case BTRACE_FORMAT_BTS
:
64 VEC_free (btrace_block_s
, data
->variant
.bts
.blocks
);
67 case BTRACE_FORMAT_PT
:
68 xfree (data
->variant
.pt
.data
);
72 internal_error (__FILE__
, __LINE__
, _("Unkown branch trace format."));
75 /* See btrace-common.h. */
78 btrace_data_empty (struct btrace_data
*data
)
82 case BTRACE_FORMAT_NONE
:
85 case BTRACE_FORMAT_BTS
:
86 return VEC_empty (btrace_block_s
, data
->variant
.bts
.blocks
);
88 case BTRACE_FORMAT_PT
:
89 return (data
->variant
.pt
.size
== 0);
92 internal_error (__FILE__
, __LINE__
, _("Unkown branch trace format."));
95 /* See btrace-common.h. */
98 btrace_data_clear (struct btrace_data
*data
)
100 btrace_data_fini (data
);
101 btrace_data_init (data
);
104 /* See btrace-common.h. */
107 btrace_data_append (struct btrace_data
*dst
,
108 const struct btrace_data
*src
)
112 case BTRACE_FORMAT_NONE
:
115 case BTRACE_FORMAT_BTS
:
121 case BTRACE_FORMAT_NONE
:
122 dst
->format
= BTRACE_FORMAT_BTS
;
123 dst
->variant
.bts
.blocks
= NULL
;
126 case BTRACE_FORMAT_BTS
:
130 /* We copy blocks in reverse order to have the oldest block at
132 blk
= VEC_length (btrace_block_s
, src
->variant
.bts
.blocks
);
135 btrace_block_s
*block
;
137 block
= VEC_index (btrace_block_s
, src
->variant
.bts
.blocks
,
140 VEC_safe_push (btrace_block_s
, dst
->variant
.bts
.blocks
, block
);
146 case BTRACE_FORMAT_PT
:
152 case BTRACE_FORMAT_NONE
:
153 dst
->format
= BTRACE_FORMAT_PT
;
154 dst
->variant
.pt
.data
= NULL
;
155 dst
->variant
.pt
.size
= 0;
158 case BTRACE_FORMAT_PT
:
163 size
= src
->variant
.pt
.size
+ dst
->variant
.pt
.size
;
164 data
= (gdb_byte
*) xmalloc (size
);
166 memcpy (data
, dst
->variant
.pt
.data
, dst
->variant
.pt
.size
);
167 memcpy (data
+ dst
->variant
.pt
.size
, src
->variant
.pt
.data
,
168 src
->variant
.pt
.size
);
170 xfree (dst
->variant
.pt
.data
);
172 dst
->variant
.pt
.data
= data
;
173 dst
->variant
.pt
.size
= size
;
179 internal_error (__FILE__
, __LINE__
, _("Unkown branch trace format."));
This page took 0.03388 seconds and 4 git commands to generate.