OpenCSD - CoreSight Trace Decode Library 1.3.3
trc_gen_elem.h
Go to the documentation of this file.
1
8/*
9 * Redistribution and use in source and binary forms, with or without modification,
10 * are permitted provided that the following conditions are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 *
19 * 3. Neither the name of the copyright holder nor the names of its contributors
20 * may be used to endorse or promote products derived from this software without
21 * specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34#ifndef ARM_TRC_GEN_ELEM_H_INCLUDED
35#define ARM_TRC_GEN_ELEM_H_INCLUDED
36
38#include "trc_printable_elem.h"
39#include "ocsd_pe_context.h"
40
50{
51public:
54 virtual ~OcsdTraceElement() {};
55
56 void init();
57
58// set elements API
59
60 void setType(const ocsd_gen_trc_elem_t type);
61 void updateType(const ocsd_gen_trc_elem_t type);
62
63 void setContext(const ocsd_pe_context &new_context) { context = new_context; };
64 void setISA(const ocsd_isa isa_update);
65
66 void setCycleCount(const uint32_t cycleCount);
67 void setEvent(const event_t ev_type, const uint16_t number);
68 void setTS(const uint64_t ts, const bool freqChange = false);
69
71 void setExceptionNum(uint32_t excepNum) { exception_number = excepNum; };
72 void setTraceOnReason(const trace_on_reason_t reason);
73 void setUnSyncEOTReason(const unsync_info_t reason);
74 void setTransactionType(const trace_memtrans_t trans) { mem_trans = trans; };
75
76 void setAddrRange(const ocsd_vaddr_t st_addr, const ocsd_vaddr_t en_addr, const int num_instr = 1);
77 void setLastInstrInfo(const bool exec, const ocsd_instr_type last_i_type, const ocsd_instr_subtype last_i_subtype, const uint8_t size);
78 void setAddrStart(const ocsd_vaddr_t st_addr) { this->st_addr = st_addr; };
79 void setLastInstrCond(const int is_cond) { this->last_instr_cond = is_cond; };
80
81 void setSWTInfo(const ocsd_swt_info_t swt_info) { sw_trace_info = swt_info; };
82 void setExtendedDataPtr(const void *data_ptr);
83
84 void setSyncMarker(const trace_marker_payload_t &marker);
85
86// stringize the element
87
88 virtual void toString(std::string &str) const;
89
90// get elements API
91
93
94 const ocsd_gen_trc_elem_t getType() const { return elem_type; };
95
96 // return current context
97 const ocsd_pe_context &getContext() const { return context; };
98
99 void copyPersistentData(const OcsdTraceElement &src);
100
101private:
102 void printSWInfoPkt(std::ostringstream &oss) const;
103 void clearPerPktData();
104
105};
106
108{
109 elem_type = type;
110}
111
113{
115}
116
117inline void OcsdTraceElement::setCycleCount(const uint32_t cycleCount)
118{
119 cycle_count = cycleCount;
120 has_cc = 1;
121}
122
123inline void OcsdTraceElement::setEvent(const event_t ev_type, const uint16_t number)
124{
125 trace_event.ev_type = (uint16_t)ev_type;
126 trace_event.ev_number = ev_type == EVENT_NUMBERED ? number : 0;
127}
128
129inline void OcsdTraceElement::setAddrRange(const ocsd_vaddr_t st_addr, const ocsd_vaddr_t en_addr, const int num_instr /* = 1 */)
130{
131 this->st_addr = st_addr;
132 this->en_addr = en_addr;
133 this->num_instr_range = num_instr;
134}
135
136inline void OcsdTraceElement::setLastInstrInfo(const bool exec, const ocsd_instr_type last_i_type, const ocsd_instr_subtype last_i_subtype, const uint8_t size)
137{
138 last_instr_exec = exec ? 1 : 0;
139 last_instr_sz = size & 0x7;
140 this->last_i_type = last_i_type;
141 this->last_i_subtype = last_i_subtype;
142}
143
145{
146 // set the type and clear down the per element flags
147 elem_type = type;
148
149 clearPerPktData();
150}
151
153{
154 elem_type = type;
155}
156
158{
161
162 cycle_count = 0;
163 timestamp = 0;
164
167 context.el_valid = 0;
168
171
172 clearPerPktData();
173}
174
175inline void OcsdTraceElement::clearPerPktData()
176{
177 flag_bits = 0; // bit-field with various flags.
178 exception_number = 0; // union with trace_on_reason / trace_event
179 ptr_extended_data = 0; // extended data pointer
180}
181
183{
184 trace_on_reason = reason;
185}
186
188{
189 unsync_eot_info = reason;
190}
191
192inline void OcsdTraceElement::setISA(const ocsd_isa isa_update)
193{
194 isa = isa_update;
197}
198
199inline void OcsdTraceElement::setTS(const uint64_t ts, const bool freqChange /*= false*/)
200{
201 timestamp = ts;
202 cpu_freq_change = freqChange ? 1 : 0;
203 has_ts = 1;
204}
205
206inline void OcsdTraceElement::setExtendedDataPtr(const void *data_ptr)
207{
208 extended_data = 1;
209 ptr_extended_data = data_ptr;
210}
211
213{
214 sync_marker = marker;
215}
216
217// set persistent data between output packets.
219{
220 isa = src.isa;
221 context = src.context;
222}
223
226#endif // ARM_TRC_GEN_ELEM_H_INCLUDED
227
228/* End of File trc_gen_elem.h */
Generic trace element class.
Definition: trc_gen_elem.h:50
void setTransactionType(const trace_memtrans_t trans)
Definition: trc_gen_elem.h:74
virtual ~OcsdTraceElement()
Definition: trc_gen_elem.h:54
void setExcepMarker()
Definition: trc_gen_elem.h:70
virtual void toString(std::string &str) const
const ocsd_pe_context & getContext() const
Definition: trc_gen_elem.h:97
void setAddrStart(const ocsd_vaddr_t st_addr)
Definition: trc_gen_elem.h:78
void setContext(const ocsd_pe_context &new_context)
Definition: trc_gen_elem.h:63
OcsdTraceElement & operator=(const ocsd_generic_trace_elem *p_elem)
const ocsd_gen_trc_elem_t getType() const
Definition: trc_gen_elem.h:94
void setSWTInfo(const ocsd_swt_info_t swt_info)
Definition: trc_gen_elem.h:81
void setExceptionNum(uint32_t excepNum)
Definition: trc_gen_elem.h:71
void setLastInstrCond(const int is_cond)
Definition: trc_gen_elem.h:79
Class to provide trace element strings for printing.
enum _trace_on_reason_t trace_on_reason_t
void setLastInstrInfo(const bool exec, const ocsd_instr_type last_i_type, const ocsd_instr_subtype last_i_subtype, const uint8_t size)
Definition: trc_gen_elem.h:136
enum _unsync_info_t unsync_info_t
void setAddrRange(const ocsd_vaddr_t st_addr, const ocsd_vaddr_t en_addr, const int num_instr=1)
Definition: trc_gen_elem.h:129
void setCycleCount(const uint32_t cycleCount)
Definition: trc_gen_elem.h:117
enum _event_t event_t
void setType(const ocsd_gen_trc_elem_t type)
set type and init flags
Definition: trc_gen_elem.h:144
void updateType(const ocsd_gen_trc_elem_t type)
change type only - no init
Definition: trc_gen_elem.h:152
void setEvent(const event_t ev_type, const uint16_t number)
Definition: trc_gen_elem.h:123
enum _memtrans_t trace_memtrans_t
void setTS(const uint64_t ts, const bool freqChange=false)
Definition: trc_gen_elem.h:199
void setISA(const ocsd_isa isa_update)
Definition: trc_gen_elem.h:192
void setSyncMarker(const trace_marker_payload_t &marker)
Definition: trc_gen_elem.h:212
void setUnSyncEOTReason(const unsync_info_t reason)
Definition: trc_gen_elem.h:187
enum _ocsd_gen_trc_elem_t ocsd_gen_trc_elem_t
void setTraceOnReason(const trace_on_reason_t reason)
Definition: trc_gen_elem.h:182
void copyPersistentData(const OcsdTraceElement &src)
Definition: trc_gen_elem.h:218
void setExtendedDataPtr(const void *data_ptr)
Definition: trc_gen_elem.h:206
@ EVENT_NUMBERED
@ OCSD_GEN_TRC_ELEM_UNKNOWN
enum _ocsd_instr_subtype ocsd_instr_subtype
enum _ocsd_instr_type ocsd_instr_type
enum _ocsd_isa ocsd_isa
uint64_t ocsd_vaddr_t
@ ocsd_isa_unknown
@ OCSD_S_INSTR_NONE
@ OCSD_INSTR_OTHER
trace_marker_payload_t sync_marker
ocsd_instr_subtype last_i_subtype
trace_on_reason_t trace_on_reason
ocsd_gen_trc_elem_t elem_type
uint32_t ctxt_id_valid
OpenCSD : Decoder Output Generic Element types.
OpenCSD : Standard printable element base class.