Loading...
Searching...
No Matches
trc_gen_elem.h
Go to the documentation of this file.
/*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ARM_TRC_GEN_ELEM_H_INCLUDED
#define ARM_TRC_GEN_ELEM_H_INCLUDED
#include "opencsd/trc_gen_elem_types.h"
#include "trc_printable_elem.h"
#include "ocsd_pe_context.h"
class OcsdTraceElement : public trcPrintableElem, public ocsd_generic_trace_elem
{
public:
OcsdTraceElement();
OcsdTraceElement(ocsd_gen_trc_elem_t type);
virtual ~OcsdTraceElement() {};
void init();
// set elements API
void setType(const ocsd_gen_trc_elem_t type);
void updateType(const ocsd_gen_trc_elem_t type);
void setContext(const ocsd_pe_context &new_context) { context = new_context; };
void setISA(const ocsd_isa isa_update);
void setCycleCount(const uint32_t cycleCount);
void setEvent(const event_t ev_type, const uint16_t number);
void setTS(const uint64_t ts, const bool freqChange = false);
void setExcepMarker() { excep_data_marker = 1; };
void setExceptionNum(uint32_t excepNum) { exception_number = excepNum; };
void setTraceOnReason(const trace_on_reason_t reason);
void setUnSyncEOTReason(const unsync_info_t reason);
void setTransactionType(const trace_memtrans_t trans) { mem_trans = trans; };
void setAddrRange(const ocsd_vaddr_t st_addr, const ocsd_vaddr_t en_addr, const int num_instr = 1);
void setLastInstrInfo(const bool exec, const ocsd_instr_type last_i_type, const ocsd_instr_subtype last_i_subtype, const uint8_t size);
void setAddrStart(const ocsd_vaddr_t st_addr) { this->st_addr = st_addr; };
void setLastInstrCond(const int is_cond) { this->last_instr_cond = is_cond; };
void setSWTInfo(const ocsd_swt_info_t swt_info) { sw_trace_info = swt_info; };
void setExtendedDataPtr(const void *data_ptr);
void setITEInfo(const trace_sw_ite_t sw_instrumentation) { sw_ite = sw_instrumentation; };
void setSyncMarker(const trace_marker_payload_t &marker);
// stringize the element
virtual void toString(std::string &str) const;
// get elements API
OcsdTraceElement &operator =(const ocsd_generic_trace_elem* p_elem);
const ocsd_gen_trc_elem_t getType() const { return elem_type; };
// return current context
const ocsd_pe_context &getContext() const { return context; };
void copyPersistentData(const OcsdTraceElement &src);
private:
void printSWInfoPkt(std::ostringstream &oss) const;
void clearPerPktData();
};
inline OcsdTraceElement::OcsdTraceElement(ocsd_gen_trc_elem_t type)
{
elem_type = type;
}
inline OcsdTraceElement::OcsdTraceElement()
{
elem_type = OCSD_GEN_TRC_ELEM_UNKNOWN;
}
inline void OcsdTraceElement::setCycleCount(const uint32_t cycleCount)
{
cycle_count = cycleCount;
has_cc = 1;
}
inline void OcsdTraceElement::setEvent(const event_t ev_type, const uint16_t number)
{
trace_event.ev_type = (uint16_t)ev_type;
trace_event.ev_number = ev_type == EVENT_NUMBERED ? number : 0;
}
inline void OcsdTraceElement::setAddrRange(const ocsd_vaddr_t st_addr, const ocsd_vaddr_t en_addr, const int num_instr /* = 1 */)
{
this->st_addr = st_addr;
this->en_addr = en_addr;
this->num_instr_range = num_instr;
}
inline void OcsdTraceElement::setLastInstrInfo(const bool exec, const ocsd_instr_type last_i_type, const ocsd_instr_subtype last_i_subtype, const uint8_t size)
{
last_instr_exec = exec ? 1 : 0;
last_instr_sz = size & 0x7;
this->last_i_type = last_i_type;
this->last_i_subtype = last_i_subtype;
}
inline void OcsdTraceElement::setType(const ocsd_gen_trc_elem_t type)
{
// set the type and clear down the per element flags
elem_type = type;
clearPerPktData();
}
inline void OcsdTraceElement::updateType(const ocsd_gen_trc_elem_t type)
{
elem_type = type;
}
inline void OcsdTraceElement::init()
{
st_addr = en_addr = (ocsd_vaddr_t)-1;
isa = ocsd_isa_unknown;
cycle_count = 0;
timestamp = 0;
context.ctxt_id_valid = 0;
context.vmid_valid = 0;
context.el_valid = 0;
last_i_type = OCSD_INSTR_OTHER;
last_i_subtype = OCSD_S_INSTR_NONE;
clearPerPktData();
}
inline void OcsdTraceElement::clearPerPktData()
{
flag_bits = 0; // bit-field with various flags.
exception_number = 0; // union with trace_on_reason / trace_event
ptr_extended_data = 0; // extended data pointer
}
inline void OcsdTraceElement::setTraceOnReason(const trace_on_reason_t reason)
{
trace_on_reason = reason;
}
inline void OcsdTraceElement::setUnSyncEOTReason(const unsync_info_t reason)
{
unsync_eot_info = reason;
}
inline void OcsdTraceElement::setISA(const ocsd_isa isa_update)
{
isa = isa_update;
if(isa > ocsd_isa_unknown)
isa = ocsd_isa_unknown;
}
inline void OcsdTraceElement::setTS(const uint64_t ts, const bool freqChange /*= false*/)
{
timestamp = ts;
cpu_freq_change = freqChange ? 1 : 0;
has_ts = 1;
}
inline void OcsdTraceElement::setExtendedDataPtr(const void *data_ptr)
{
extended_data = 1;
ptr_extended_data = data_ptr;
}
inline void OcsdTraceElement::setSyncMarker(const trace_marker_payload_t &marker)
{
sync_marker = marker;
}
// set persistent data between output packets.
inline void OcsdTraceElement::copyPersistentData(const OcsdTraceElement &src)
{
isa = src.isa;
context = src.context;
}
#endif // ARM_TRC_GEN_ELEM_H_INCLUDED
/* End of File trc_gen_elem.h */
OcsdTraceElement
Generic trace element class.
Definition trc_gen_elem.h:50
OcsdTraceElement::setTransactionType
void setTransactionType(const trace_memtrans_t trans)
Definition trc_gen_elem.h:74
OcsdTraceElement::~OcsdTraceElement
virtual ~OcsdTraceElement()
Definition trc_gen_elem.h:54
OcsdTraceElement::setExcepMarker
void setExcepMarker()
Definition trc_gen_elem.h:70
OcsdTraceElement::toString
virtual void toString(std::string &str) const
OcsdTraceElement::getContext
const ocsd_pe_context & getContext() const
Definition trc_gen_elem.h:99
OcsdTraceElement::setAddrStart
void setAddrStart(const ocsd_vaddr_t st_addr)
Definition trc_gen_elem.h:78
OcsdTraceElement::setContext
void setContext(const ocsd_pe_context &new_context)
Definition trc_gen_elem.h:63
OcsdTraceElement::operator=
OcsdTraceElement & operator=(const ocsd_generic_trace_elem *p_elem)
OcsdTraceElement::getType
const ocsd_gen_trc_elem_t getType() const
Definition trc_gen_elem.h:96
OcsdTraceElement::setSWTInfo
void setSWTInfo(const ocsd_swt_info_t swt_info)
Definition trc_gen_elem.h:81
OcsdTraceElement::setITEInfo
void setITEInfo(const trace_sw_ite_t sw_instrumentation)
Definition trc_gen_elem.h:84
OcsdTraceElement::setExceptionNum
void setExceptionNum(uint32_t excepNum)
Definition trc_gen_elem.h:71
OcsdTraceElement::setLastInstrCond
void setLastInstrCond(const int is_cond)
Definition trc_gen_elem.h:79
trcPrintableElem
Class to provide trace element strings for printing.
Definition trc_printable_elem.h:56
trace_on_reason_t
enum _trace_on_reason_t trace_on_reason_t
OcsdTraceElement::setLastInstrInfo
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:138
unsync_info_t
enum _unsync_info_t unsync_info_t
OcsdTraceElement::setAddrRange
void setAddrRange(const ocsd_vaddr_t st_addr, const ocsd_vaddr_t en_addr, const int num_instr=1)
Definition trc_gen_elem.h:131
OcsdTraceElement::setCycleCount
void setCycleCount(const uint32_t cycleCount)
Definition trc_gen_elem.h:119
event_t
enum _event_t event_t
OcsdTraceElement::OcsdTraceElement
OcsdTraceElement()
Definition trc_gen_elem.h:114
OcsdTraceElement::init
void init()
Definition trc_gen_elem.h:159
OcsdTraceElement::setType
void setType(const ocsd_gen_trc_elem_t type)
set type and init flags
Definition trc_gen_elem.h:146
OcsdTraceElement::updateType
void updateType(const ocsd_gen_trc_elem_t type)
change type only - no init
Definition trc_gen_elem.h:154
OcsdTraceElement::setEvent
void setEvent(const event_t ev_type, const uint16_t number)
Definition trc_gen_elem.h:125
trace_memtrans_t
enum _memtrans_t trace_memtrans_t
OcsdTraceElement::setTS
void setTS(const uint64_t ts, const bool freqChange=false)
Definition trc_gen_elem.h:201
OcsdTraceElement::setISA
void setISA(const ocsd_isa isa_update)
Definition trc_gen_elem.h:194
OcsdTraceElement::setSyncMarker
void setSyncMarker(const trace_marker_payload_t &marker)
Definition trc_gen_elem.h:214
OcsdTraceElement::setUnSyncEOTReason
void setUnSyncEOTReason(const unsync_info_t reason)
Definition trc_gen_elem.h:189
ocsd_gen_trc_elem_t
enum _ocsd_gen_trc_elem_t ocsd_gen_trc_elem_t
OcsdTraceElement::setTraceOnReason
void setTraceOnReason(const trace_on_reason_t reason)
Definition trc_gen_elem.h:184
OcsdTraceElement::copyPersistentData
void copyPersistentData(const OcsdTraceElement &src)
Definition trc_gen_elem.h:220
OcsdTraceElement::setExtendedDataPtr
void setExtendedDataPtr(const void *data_ptr)
Definition trc_gen_elem.h:208
EVENT_NUMBERED
@ EVENT_NUMBERED
Definition trc_gen_elem_types.h:162
OCSD_GEN_TRC_ELEM_UNKNOWN
@ OCSD_GEN_TRC_ELEM_UNKNOWN
Definition trc_gen_elem_types.h:49
ocsd_instr_subtype
enum _ocsd_instr_subtype ocsd_instr_subtype
ocsd_instr_type
enum _ocsd_instr_type ocsd_instr_type
ocsd_isa
enum _ocsd_isa ocsd_isa
ocsd_vaddr_t
uint64_t ocsd_vaddr_t
Definition ocsd_if_types.h:310
ocsd_isa_unknown
@ ocsd_isa_unknown
Definition ocsd_if_types.h:334
OCSD_S_INSTR_NONE
@ OCSD_S_INSTR_NONE
Definition ocsd_if_types.h:374
OCSD_INSTR_OTHER
@ OCSD_INSTR_OTHER
Definition ocsd_if_types.h:361
ocsd_pe_context.h
_ocsd_generic_trace_elem
Definition trc_gen_elem_types.h:113
_ocsd_generic_trace_elem::cycle_count
uint32_t cycle_count
Definition trc_gen_elem_types.h:120
_ocsd_generic_trace_elem::last_instr_sz
uint32_t last_instr_sz
Definition trc_gen_elem_types.h:128
_ocsd_generic_trace_elem::isa
ocsd_isa isa
Definition trc_gen_elem_types.h:115
_ocsd_generic_trace_elem::excep_data_marker
uint32_t excep_data_marker
Definition trc_gen_elem_types.h:132
_ocsd_generic_trace_elem::sync_marker
trace_marker_payload_t sync_marker
Definition trc_gen_elem_types.h:149
_ocsd_generic_trace_elem::mem_trans
trace_memtrans_t mem_trans
Definition trc_gen_elem_types.h:150
_ocsd_generic_trace_elem::extended_data
uint32_t extended_data
Definition trc_gen_elem_types.h:133
_ocsd_generic_trace_elem::exception_number
uint32_t exception_number
Definition trc_gen_elem_types.h:143
_ocsd_generic_trace_elem::cpu_freq_change
uint32_t cpu_freq_change
Definition trc_gen_elem_types.h:130
_ocsd_generic_trace_elem::st_addr
ocsd_vaddr_t st_addr
Definition trc_gen_elem_types.h:116
_ocsd_generic_trace_elem::last_i_subtype
ocsd_instr_subtype last_i_subtype
Definition trc_gen_elem_types.h:122
_ocsd_generic_trace_elem::last_instr_exec
uint32_t last_instr_exec
Definition trc_gen_elem_types.h:127
_ocsd_generic_trace_elem::timestamp
uint64_t timestamp
Definition trc_gen_elem_types.h:119
_ocsd_generic_trace_elem::ptr_extended_data
const void * ptr_extended_data
Definition trc_gen_elem_types.h:154
_ocsd_generic_trace_elem::trace_event
trace_event_t trace_event
Definition trc_gen_elem_types.h:144
_ocsd_generic_trace_elem::sw_trace_info
ocsd_swt_info_t sw_trace_info
Definition trc_gen_elem_types.h:146
_ocsd_generic_trace_elem::last_instr_cond
uint32_t last_instr_cond
Definition trc_gen_elem_types.h:135
_ocsd_generic_trace_elem::trace_on_reason
trace_on_reason_t trace_on_reason
Definition trc_gen_elem_types.h:145
_ocsd_generic_trace_elem::has_cc
uint32_t has_cc
Definition trc_gen_elem_types.h:129
_ocsd_generic_trace_elem::sw_ite
trace_sw_ite_t sw_ite
Definition trc_gen_elem_types.h:151
_ocsd_generic_trace_elem::flag_bits
uint32_t flag_bits
Definition trc_gen_elem_types.h:138
_ocsd_generic_trace_elem::num_instr_range
uint32_t num_instr_range
Definition trc_gen_elem_types.h:147
_ocsd_generic_trace_elem::unsync_eot_info
unsync_info_t unsync_eot_info
Definition trc_gen_elem_types.h:148
_ocsd_generic_trace_elem::elem_type
ocsd_gen_trc_elem_t elem_type
Definition trc_gen_elem_types.h:114
_ocsd_generic_trace_elem::has_ts
uint32_t has_ts
Definition trc_gen_elem_types.h:134
_ocsd_generic_trace_elem::last_i_type
ocsd_instr_type last_i_type
Definition trc_gen_elem_types.h:121
_ocsd_generic_trace_elem::context
ocsd_pe_context context
Definition trc_gen_elem_types.h:118
_ocsd_generic_trace_elem::en_addr
ocsd_vaddr_t en_addr
Definition trc_gen_elem_types.h:117
_ocsd_pe_context
Definition ocsd_if_types.h:411
_ocsd_pe_context::vmid_valid
uint32_t vmid_valid
Definition ocsd_if_types.h:419
_ocsd_pe_context::el_valid
uint32_t el_valid
Definition ocsd_if_types.h:420
_ocsd_pe_context::ctxt_id_valid
uint32_t ctxt_id_valid
Definition ocsd_if_types.h:418
_ocsd_swt_info
Definition ocsd_if_types.h:613
_sw_ite_t
Definition trc_gen_elem_types.h:108
_trace_event_t::ev_type
uint16_t ev_type
Definition trc_gen_elem_types.h:78
_trace_event_t::ev_number
uint16_t ev_number
Definition trc_gen_elem_types.h:79
_trace_marker_payload_t
Definition trc_gen_elem_types.h:96
trc_gen_elem_types.h
OpenCSD : Decoder Output Generic Element types.
trc_printable_elem.h
OpenCSD : Standard printable element base class.