aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Leach <mike.leach@linaro.org>2018-05-03 11:36:36 +0100
committerMike Leach <mike.leach@linaro.org>2018-06-20 11:41:50 +0100
commit10060efdc2c6a1602d7eebcc4c8c82ed86d6d8dc (patch)
tree05fa2c010ab16fb47c366dc9496948ec9e5951b5
parent4f7a4a75f7e583cd7005d0d8457e3cef19e01292 (diff)
opencsd: Output last instruction size in instruction range packet
Clients may need last instruction size to calculate the address of the last instruction from the range - when ISA is T32, this can be 16 bits. Size returned in bytes. Generic packet printer adjusted to print this new element. Signed-off-by: Mike Leach <mike.leach@linaro.org>
-rw-r--r--decoder/include/common/ocsd_code_follower.h6
-rw-r--r--decoder/include/common/trc_gen_elem.h5
-rw-r--r--decoder/include/opencsd/trc_gen_elem_types.h1
-rw-r--r--decoder/source/etmv3/trc_pkt_decode_etmv3.cpp2
-rw-r--r--decoder/source/etmv4/trc_pkt_decode_etmv4i.cpp8
-rw-r--r--decoder/source/ptm/trc_pkt_decode_ptm.cpp4
-rw-r--r--decoder/source/trc_gen_elem.cpp1
7 files changed, 18 insertions, 9 deletions
diff --git a/decoder/include/common/ocsd_code_follower.h b/decoder/include/common/ocsd_code_follower.h
index 0e8691034a68..b024aa02a368 100644
--- a/decoder/include/common/ocsd_code_follower.h
+++ b/decoder/include/common/ocsd_code_follower.h
@@ -95,6 +95,7 @@ public:
const bool isLink() const; //!< is a link (branch with link etc)
const bool ISAChanged() const; //!< next ISA different from input ISA.
const ocsd_isa nextISA() const; //!< ISA for next instruction
+ const uint8_t getInstrSize() const; //!< Get the last instruction size.
// information on error conditions
const bool isNacc() const; //!< true if Memory Not Accessible (nacc) error occurred
@@ -192,6 +193,11 @@ inline const ocsd_instr_subtype OcsdCodeFollower::getInstrSubType() const
return m_instr_info.sub_type;
}
+inline const uint8_t OcsdCodeFollower::getInstrSize() const
+{
+ return m_instr_info.instr_size;
+}
+
inline const bool OcsdCodeFollower::isCondInstr() const
{
return (bool)(m_instr_info.is_conditional == 1);
diff --git a/decoder/include/common/trc_gen_elem.h b/decoder/include/common/trc_gen_elem.h
index 813992999c30..c345e2616519 100644
--- a/decoder/include/common/trc_gen_elem.h
+++ b/decoder/include/common/trc_gen_elem.h
@@ -74,7 +74,7 @@ public:
void setTraceOnReason(const trace_on_reason_t reason);
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);
+ 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 setSWTInfo(const ocsd_swt_info_t swt_info) { sw_trace_info = swt_info; };
@@ -129,9 +129,10 @@ inline void OcsdTraceElement::setAddrRange(const ocsd_vaddr_t st_addr, const oc
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)
+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;
}
diff --git a/decoder/include/opencsd/trc_gen_elem_types.h b/decoder/include/opencsd/trc_gen_elem_types.h
index 401aee83a784..813bc2055998 100644
--- a/decoder/include/opencsd/trc_gen_elem_types.h
+++ b/decoder/include/opencsd/trc_gen_elem_types.h
@@ -90,6 +90,7 @@ typedef struct _ocsd_generic_trace_elem {
union {
struct {
uint32_t last_instr_exec:1; /**< 1 if last instruction in range was executed; */
+ uint32_t last_instr_sz:3; /**< size of last instruction in bytes (2/4) */
uint32_t has_cc:1; /**< 1 if this packet has a valid cycle count included (e.g. cycle count included as part of instruction range packet, always 1 for pure cycle count packet.*/
uint32_t cpu_freq_change:1; /**< 1 if this packet indicates a change in CPU frequency */
uint32_t excep_ret_addr:1; /**< 1 if en_addr is the preferred exception return address on exception packet type */
diff --git a/decoder/source/etmv3/trc_pkt_decode_etmv3.cpp b/decoder/source/etmv3/trc_pkt_decode_etmv3.cpp
index bd7cb60b5b63..66ce697483c4 100644
--- a/decoder/source/etmv3/trc_pkt_decode_etmv3.cpp
+++ b/decoder/source/etmv3/trc_pkt_decode_etmv3.cpp
@@ -598,7 +598,7 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV3::processPHdr()
pElem->setAddrRange(m_IAddr,m_code_follower.getRangeEn());
pElem->setLastInstrInfo(atoms.getCurrAtomVal() == ATOM_E,
m_code_follower.getInstrType(),
- m_code_follower.getInstrSubType());
+ m_code_follower.getInstrSubType(),m_code_follower.getInstrSize());
pElem->setISA(isa);
if(m_code_follower.hasNextAddr())
m_IAddr = m_code_follower.getNextAddr();
diff --git a/decoder/source/etmv4/trc_pkt_decode_etmv4i.cpp b/decoder/source/etmv4/trc_pkt_decode_etmv4i.cpp
index d125e4db0299..b2709fbe0ba1 100644
--- a/decoder/source/etmv4/trc_pkt_decode_etmv4i.cpp
+++ b/decoder/source/etmv4/trc_pkt_decode_etmv4i.cpp
@@ -835,7 +835,7 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV4I::processAtom(const ocsd_atm_val atom, bo
break;
}
m_output_elem.setType(OCSD_GEN_TRC_ELEM_INSTR_RANGE);
- m_output_elem.setLastInstrInfo((atom == ATOM_E),m_instr_info.type, m_instr_info.sub_type);
+ m_output_elem.setLastInstrInfo((atom == ATOM_E),m_instr_info.type, m_instr_info.sub_type, m_instr_info.instr_size);
m_output_elem.setISA(m_instr_info.isa);
resp = outputTraceElementIdx(pElem->getRootIndex(),m_output_elem);
@@ -849,7 +849,7 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV4I::processAtom(const ocsd_atm_val atom, bo
{
// some trace before we were out of memory access range
m_output_elem.setType(OCSD_GEN_TRC_ELEM_INSTR_RANGE);
- m_output_elem.setLastInstrInfo(true,m_instr_info.type, m_instr_info.sub_type);
+ m_output_elem.setLastInstrInfo(true,m_instr_info.type, m_instr_info.sub_type,m_instr_info.instr_size);
m_output_elem.setISA(m_instr_info.isa);
resp = outputTraceElementIdx(pElem->getRootIndex(),m_output_elem);
}
@@ -971,7 +971,7 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV4I::processException()
}
}
m_output_elem.setType(OCSD_GEN_TRC_ELEM_INSTR_RANGE);
- m_output_elem.setLastInstrInfo(true,m_instr_info.type, m_instr_info.sub_type);
+ m_output_elem.setLastInstrInfo(true,m_instr_info.type, m_instr_info.sub_type,m_instr_info.instr_size);
m_output_elem.setISA(m_instr_info.isa);
resp = outputTraceElementIdx(m_excep_index, m_output_elem);
m_excep_proc = EXCEP_EXCEP;
@@ -985,7 +985,7 @@ ocsd_datapath_resp_t TrcPktDecodeEtmV4I::processException()
{
// some trace before we were out of memory access range
m_output_elem.setType(OCSD_GEN_TRC_ELEM_INSTR_RANGE);
- m_output_elem.setLastInstrInfo(true,m_instr_info.type, m_instr_info.sub_type);
+ m_output_elem.setLastInstrInfo(true,m_instr_info.type, m_instr_info.sub_type, m_instr_info.instr_size);
m_output_elem.setISA(m_instr_info.isa);
resp = outputTraceElementIdx(m_excep_index,m_output_elem);
}
diff --git a/decoder/source/ptm/trc_pkt_decode_ptm.cpp b/decoder/source/ptm/trc_pkt_decode_ptm.cpp
index 24faacae2598..938711e75a74 100644
--- a/decoder/source/ptm/trc_pkt_decode_ptm.cpp
+++ b/decoder/source/ptm/trc_pkt_decode_ptm.cpp
@@ -576,7 +576,7 @@ ocsd_datapath_resp_t TrcPktDecodePtm::processAtomRange(const ocsd_atm_val A, con
}
m_output_elem.setType(OCSD_GEN_TRC_ELEM_INSTR_RANGE);
- m_output_elem.setLastInstrInfo((A == ATOM_E),m_instr_info.type, m_instr_info.sub_type);
+ m_output_elem.setLastInstrInfo((A == ATOM_E),m_instr_info.type, m_instr_info.sub_type,m_instr_info.instr_size);
m_output_elem.setISA(m_curr_pe_state.isa);
if(m_curr_packet_in->hasCC())
m_output_elem.setCycleCount(m_curr_packet_in->getCCVal());
@@ -594,7 +594,7 @@ ocsd_datapath_resp_t TrcPktDecodePtm::processAtomRange(const ocsd_atm_val A, con
{
// some trace before we were out of memory access range
m_output_elem.setType(OCSD_GEN_TRC_ELEM_INSTR_RANGE);
- m_output_elem.setLastInstrInfo(true,m_instr_info.type, m_instr_info.sub_type);
+ m_output_elem.setLastInstrInfo(true,m_instr_info.type, m_instr_info.sub_type,m_instr_info.instr_size);
m_output_elem.setISA(m_curr_pe_state.isa);
resp = outputTraceElementIdx(m_index_curr_pkt,m_output_elem);
}
diff --git a/decoder/source/trc_gen_elem.cpp b/decoder/source/trc_gen_elem.cpp
index c4b2ddb3d7ac..5b0bbc732414 100644
--- a/decoder/source/trc_gen_elem.cpp
+++ b/decoder/source/trc_gen_elem.cpp
@@ -106,6 +106,7 @@ void OcsdTraceElement::toString(std::string &str) const
case OCSD_GEN_TRC_ELEM_INSTR_RANGE:
oss << "exec range=0x" << std::hex << st_addr << ":[0x" << en_addr << "] ";
oss << "num_i(" << std::dec << num_instr_range << ") ";
+ oss << "last_sz(" << last_instr_sz << ") ";
oss << "(ISA=" << s_isa_str[(int)isa] << ") ";
oss << ((last_instr_exec == 1) ? "E " : "N ");
if((int)last_i_type < T_SIZE)