summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-11-05 04:46:47 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-11-05 04:46:47 +0000
commit04e89d7679fbdb42f9a28604f9acbb73b1247057 (patch)
tree6242205016efbd9d2c131aab103eeb140c4550fe
parentReleasing progress-linux version 1.0.0-1~progress6+u1. (diff)
downloadlibopencsd-04e89d7679fbdb42f9a28604f9acbb73b1247057.tar.xz
libopencsd-04e89d7679fbdb42f9a28604f9acbb73b1247057.zip
Merging upstream version 1.1.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
-rw-r--r--README.md14
-rw-r--r--decoder/build/linux/makefile1
-rw-r--r--decoder/build/linux/rctdl_c_api_lib/makefile2
-rw-r--r--decoder/docs/doxygen_config.dox2
-rw-r--r--decoder/include/common/ocsd_dcd_mngr.h6
-rw-r--r--decoder/include/opencsd/c_api/ocsd_c_api_types.h1
-rw-r--r--decoder/include/opencsd/c_api/opencsd_c_api.h22
-rw-r--r--decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h8
-rw-r--r--decoder/include/opencsd/ocsd_if_types.h5
-rw-r--r--decoder/include/opencsd/ocsd_if_version.h6
-rw-r--r--decoder/source/c_api/ocsd_c_api.cpp33
-rw-r--r--decoder/source/etmv4/trc_pkt_decode_etmv4i.cpp96
-rw-r--r--decoder/source/etmv4/trc_pkt_proc_etmv4i.cpp4
-rw-r--r--decoder/source/ocsd_dcd_tree.cpp2
-rw-r--r--decoder/source/ocsd_gen_elem_stack.cpp1
-rw-r--r--decoder/source/ptm/trc_pkt_proc_ptm.cpp1
-rw-r--r--decoder/tests/source/c_api_pkt_print_test.c103
17 files changed, 235 insertions, 72 deletions
diff --git a/README.md b/README.md
index bdedf3f..1647112 100644
--- a/README.md
+++ b/README.md
@@ -27,12 +27,12 @@ Releases will appear on the master branch in the git repository with an appropri
CoreSight Trace Component Support.
----------------------------------
-_Current Version 1.0.0_
+_Current Version 1.1.1_
### Current support:
- ETE (v1.1) instruction trace - packet processing and packet decode.
-- ETMv4 (v4.5 [A/R profile] v4.4 [M profile]) instruction trace - packet processing and packet decode.
+- ETMv4 (v4.6 [A/R profile] v4.4 [M profile]) instruction trace - packet processing and packet decode.
- PTM (v1.1) instruction trace - packet processing and packet decode.
- ETMv3 (v3.5) instruction trace - packet processing and packet decode.
- ETMv3 (v3.5) data trace - packet processing.
@@ -239,6 +239,16 @@ Version and Modification Information
- __Bugfix__: build: Fix clean install, and remove static lib build test from main makefile to
dev makefile only. (github issue #33)
+- _Version 1.1.0_:
+ - __Update__: ETM v4.6 support.
+ - __Update__: C-API - add API functions to get last error and convert error code to string.
+ - __Bugfix__: ETMv4/ETE - fix loop problem in commit elements.
+ - __Bugfix__: ETMv4/ETE - make error handling consistent.
+ - __Bugfix__: Add Pull request #36 from github (Ross Burton)
+ - __Bugfix__: Add Pull request #37 from github (Ian Rogers)
+
+- _Version 1.1.1_:
+ - __Bugfix__: Fix include and install for ETE decoder headers.
Licence Information
===================
diff --git a/decoder/build/linux/makefile b/decoder/build/linux/makefile
index f63868c..54dd031 100644
--- a/decoder/build/linux/makefile
+++ b/decoder/build/linux/makefile
@@ -133,6 +133,7 @@ endif
$(INSTALL) --mode=755 $(BIN_TEST_TARGET_DIR)/trc_pkt_lister $(INSTALL_BIN_DIR)/
install_man:
+ mkdir -p $(INSTALL_MAN_DIR)
$(INSTALL) --mode=644 $(OCSD_ROOT)/docs/man/trc_pkt_lister.1 $(INSTALL_MAN_DIR)/
diff --git a/decoder/build/linux/rctdl_c_api_lib/makefile b/decoder/build/linux/rctdl_c_api_lib/makefile
index a0bd5a3..7b4055d 100644
--- a/decoder/build/linux/rctdl_c_api_lib/makefile
+++ b/decoder/build/linux/rctdl_c_api_lib/makefile
@@ -113,6 +113,8 @@ install_inc:
$(INSTALL) --mode=0644 $(INST_INC_SRC)/etmv3/trc_pkt_types_etmv3.h $(INST_INC_DST)/etmv3/
$(INSTALL) -d --mode=0755 $(INST_INC_DST)/etmv4
$(INSTALL) --mode=0644 $(INST_INC_SRC)/etmv4/trc_pkt_types_etmv4.h $(INST_INC_DST)/etmv4/
+ $(INSTALL) -d --mode=0755 $(INST_INC_DST)/ete
+ $(INSTALL) --mode=0644 $(INST_INC_SRC)/ete/trc_pkt_types_ete.h $(INST_INC_DST)/ete/
$(INSTALL) -d --mode=0755 $(INST_INC_DST)/c_api
$(INSTALL) --mode=0644 $(INST_INC_SRC)/c_api/ocsd_c_api_types.h $(INST_INC_DST)/c_api/
$(INSTALL) --mode=0644 $(INST_INC_SRC)/c_api/opencsd_c_api.h $(INST_INC_DST)/c_api/
diff --git a/decoder/docs/doxygen_config.dox b/decoder/docs/doxygen_config.dox
index 65c8931..1a45ee7 100644
--- a/decoder/docs/doxygen_config.dox
+++ b/decoder/docs/doxygen_config.dox
@@ -38,7 +38,7 @@ PROJECT_NAME = "OpenCSD - CoreSight Trace Decode Library"
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = 1.0.0
+PROJECT_NUMBER = 1.1.1
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
diff --git a/decoder/include/common/ocsd_dcd_mngr.h b/decoder/include/common/ocsd_dcd_mngr.h
index 3b9ba97..34c4ef1 100644
--- a/decoder/include/common/ocsd_dcd_mngr.h
+++ b/decoder/include/common/ocsd_dcd_mngr.h
@@ -80,16 +80,16 @@ public:
private:
- ocsd_trace_protocol_t m_builtInProtocol; //!< Protocol ID if built in type.
+ const ocsd_trace_protocol_t m_builtInProtocol; //!< Protocol ID if built in type.
};
template <class P, class Pt, class Pc>
-DecoderMngrBase<P,Pt,Pc>::DecoderMngrBase(const std::string &decoderTypeName, ocsd_trace_protocol_t builtInProtocol)
+ DecoderMngrBase<P,Pt,Pc>::DecoderMngrBase(const std::string &decoderTypeName, ocsd_trace_protocol_t builtInProtocol) :
+ m_builtInProtocol(builtInProtocol)
{
OcsdLibDcdRegister *pDcdReg = OcsdLibDcdRegister::getDecoderRegister();
if(pDcdReg)
pDcdReg->registerDecoderTypeByName(decoderTypeName,this);
- m_builtInProtocol = builtInProtocol;
}
template <class P, class Pt, class Pc>
diff --git a/decoder/include/opencsd/c_api/ocsd_c_api_types.h b/decoder/include/opencsd/c_api/ocsd_c_api_types.h
index cde351f..7f9b4ba 100644
--- a/decoder/include/opencsd/c_api/ocsd_c_api_types.h
+++ b/decoder/include/opencsd/c_api/ocsd_c_api_types.h
@@ -46,6 +46,7 @@
#include "opencsd/etmv4/trc_pkt_types_etmv4.h"
#include "opencsd/ptm/trc_pkt_types_ptm.h"
#include "opencsd/stm/trc_pkt_types_stm.h"
+#include "opencsd/ete/trc_pkt_types_ete.h"
/** @ingroup lib_c_api
@{*/
diff --git a/decoder/include/opencsd/c_api/opencsd_c_api.h b/decoder/include/opencsd/c_api/opencsd_c_api.h
index 90201d4..25e9487 100644
--- a/decoder/include/opencsd/c_api/opencsd_c_api.h
+++ b/decoder/include/opencsd/c_api/opencsd_c_api.h
@@ -373,6 +373,28 @@ OCSD_C_API ocsd_err_t ocsd_def_errlog_set_strprint_cb(const dcd_tree_handle_t ha
*/
OCSD_C_API void ocsd_def_errlog_msgout(const char *msg);
+/*!
+ * Convert an error code into a string.
+ *
+ * @param err : error code.
+ * @param buffer : buffer for return string
+ * @param buffer_size : length of buffer.
+ */
+OCSD_C_API void ocsd_err_str(const ocsd_err_t err, char *buffer, const int buffer_size);
+
+/*!
+ * returns the last error logged by the system, with the related trace byte index, trace channel id,
+ * and any error message related string.
+ * If index or channel ID are not valid these will return OCSD_BAD_TRC_INDEX and OCSD_BAD_CS_SRC_ID.
+ *
+ * return value is the error code of the last logged error, OCSD_OK for no error available.
+ *
+ * @param index : returns trace byte index relating to error, or OCSD_BAD_TRC_INDEX
+ * @param chan_id : returns trace channel ID relating to error, or OCSD_BAD_CS_SRC_ID
+ * @param message : buffer to copy the last error message.
+ * @param message_len: length of message buffer.
+ */
+OCSD_C_API ocsd_err_t ocsd_get_last_err(ocsd_trc_index_t *index, uint8_t *chan_id, char *message, const int message_len);
/** @}*/
diff --git a/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h b/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h
index 607e21d..65230ff 100644
--- a/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h
+++ b/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h
@@ -101,7 +101,13 @@ protected:
ocsd_err_t processTransElem(TrcStackElem *pElem);
// process a bad packet
- ocsd_err_t handleBadPacket(const char *reason);
+ ocsd_err_t handleBadPacket(const char *reason, ocsd_trc_index_t index = OCSD_BAD_TRC_INDEX);
+
+ // sequencing error on packet processing - optionally continue
+ ocsd_err_t handlePacketSeqErr(ocsd_err_t err, ocsd_trc_index_t index, const char *reason);
+
+ // common packet error routine
+ ocsd_err_t handlePacketErr(ocsd_err_t err, ocsd_err_severity_t sev, ocsd_trc_index_t index, const char *reason);
ocsd_err_t addElemCC(TrcStackElemParam *pParamElem);
ocsd_err_t addElemTS(TrcStackElemParam *pParamElem, bool withCC);
diff --git a/decoder/include/opencsd/ocsd_if_types.h b/decoder/include/opencsd/ocsd_if_types.h
index 4b6e17e..2550f96 100644
--- a/decoder/include/opencsd/ocsd_if_types.h
+++ b/decoder/include/opencsd/ocsd_if_types.h
@@ -524,10 +524,11 @@ typedef struct _ocsd_file_mem_region {
(common flags share bitfield with pkt processor common flags and create flags)
@{*/
-#define OCSD_OPFLG_PKTDEC_ERROR_BAD_PKTS 0x00000100 /**< throw error on bad packets input (default is to unsync and wait) */
+#define OCSD_OPFLG_PKTDEC_ERROR_BAD_PKTS 0x00000100 /**< throw error on bad packets input (default is to warn) */
+#define OCSD_OPFLG_PKTDEC_HALT_BAD_PKTS 0x00000200 /**< halt decoder on bad packets (default is to log error and continue by resetting decoder and wait for sync */
/** mask to combine all common packet processor operational control flags */
-#define OCSD_OPFLG_PKTDEC_COMMON (OCSD_OPFLG_PKTDEC_ERROR_BAD_PKTS)
+#define OCSD_OPFLG_PKTDEC_COMMON (OCSD_OPFLG_PKTDEC_ERROR_BAD_PKTS | OCSD_OPFLG_PKTDEC_HALT_BAD_PKTS)
/** @}*/
diff --git a/decoder/include/opencsd/ocsd_if_version.h b/decoder/include/opencsd/ocsd_if_version.h
index 1a932a2..ea2b239 100644
--- a/decoder/include/opencsd/ocsd_if_version.h
+++ b/decoder/include/opencsd/ocsd_if_version.h
@@ -43,8 +43,8 @@
/** @name Library Versioning
@{*/
#define OCSD_VER_MAJOR 0x1 /**< Library Major Version */
-#define OCSD_VER_MINOR 0x0 /**< Library Minor Version */
-#define OCSD_VER_PATCH 0x0 /**< Library Patch Version */
+#define OCSD_VER_MINOR 0x1 /**< Library Minor Version */
+#define OCSD_VER_PATCH 0x1 /**< Library Patch Version */
/** Library version number - MMMMnnpp format.
MMMM = major version,
@@ -53,7 +53,7 @@
*/
#define OCSD_VER_NUM ((OCSD_VER_MAJOR << 16) | (OCSD_VER_MINOR << 8) | OCSD_VER_PATCH)
-#define OCSD_VER_STRING "1.0.0" /**< Library Version string */
+#define OCSD_VER_STRING "1.1.1" /**< Library Version string */
#define OCSD_LIB_NAME "OpenCSD Library" /**< Library name string */
#define OCSD_LIB_SHORT_NAME "OCSD" /**< Library Short name string */
/** @}*/
diff --git a/decoder/source/c_api/ocsd_c_api.cpp b/decoder/source/c_api/ocsd_c_api.cpp
index 4824c42..66bfce8 100644
--- a/decoder/source/c_api/ocsd_c_api.cpp
+++ b/decoder/source/c_api/ocsd_c_api.cpp
@@ -470,6 +470,39 @@ OCSD_C_API ocsd_err_t ocsd_dt_set_pkt_protocol_printer(const dcd_tree_handle_t h
return err;
}
+OCSD_C_API void ocsd_err_str(const ocsd_err_t err, char *buffer, const int buffer_size)
+{
+ std::string err_str;
+ err_str = ocsdError::getErrorString(ocsdError(OCSD_ERR_SEV_ERROR, err));
+ strncpy(buffer, err_str.c_str(), buffer_size - 1);
+ buffer[buffer_size - 1] = 0;
+}
+
+OCSD_C_API ocsd_err_t ocsd_get_last_err(ocsd_trc_index_t *index, uint8_t *chan_id, char *message, const int message_len)
+{
+ ocsdError *p_err;
+ ocsd_err_t err = OCSD_OK;
+ std::string err_str;
+
+ p_err = DecodeTree::getDefaultErrorLogger()->GetLastError();
+ if (p_err)
+ {
+ *index = p_err->getErrorIndex();
+ *chan_id = p_err->getErrorChanID();
+ err_str = p_err->getErrorString(ocsdError(p_err));
+ strncpy(message, err_str.c_str(), message_len - 1);
+ message[message_len - 1] = 0;
+ err = p_err->getErrorCode();
+ }
+ else
+ {
+ message[0] = 0;
+ *index = OCSD_BAD_TRC_INDEX;
+ *chan_id = OCSD_BAD_CS_SRC_ID;
+ }
+ return err;
+}
+
/*******************************************************************************/
/* C API local fns */
/*******************************************************************************/
diff --git a/decoder/source/etmv4/trc_pkt_decode_etmv4i.cpp b/decoder/source/etmv4/trc_pkt_decode_etmv4i.cpp
index e4caf0a..015a2f5 100644
--- a/decoder/source/etmv4/trc_pkt_decode_etmv4i.cpp
+++ b/decoder/source/etmv4/trc_pkt_decode_etmv4i.cpp
@@ -477,15 +477,15 @@ ocsd_err_t TrcPktDecodeEtmV4I::decodePacket()
break;
case ETM4_PKT_I_BAD_SEQUENCE:
- err = handleBadPacket("Bad byte sequence in packet.");
+ err = handleBadPacket("Bad byte sequence in packet.", m_index_curr_pkt);
break;
case ETM4_PKT_I_BAD_TRACEMODE:
- err = handleBadPacket("Invalid packet type for trace mode.");
+ err = handleBadPacket("Invalid packet type for trace mode.", m_index_curr_pkt);
break;
case ETM4_PKT_I_RESERVED:
- err = handleBadPacket("Reserved packet header");
+ err = handleBadPacket("Reserved packet header", m_index_curr_pkt);
break;
// speculation
@@ -568,7 +568,7 @@ ocsd_err_t TrcPktDecodeEtmV4I::decodePacket()
/* ETE commit window - not supported in current ETE versions - blocked by packet processor */
case ETE_PKT_I_COMMIT_WIN_MV:
err = OCSD_ERR_UNSUPP_DECODE_PKT;
- LogError(ocsdError(OCSD_ERR_SEV_ERROR, err, "ETE Commit Window Move, unsupported packet type."));
+ err = handlePacketSeqErr(err, m_index_curr_pkt, "ETE Commit Window Move, unsupported packet type.");
break;
/* conditional instruction tracing */
case ETM4_PKT_I_COND_FLUSH:
@@ -592,14 +592,16 @@ ocsd_err_t TrcPktDecodeEtmV4I::decodePacket()
//resp = OCSD_RESP_FATAL_INVALID_DATA;
#endif
err = OCSD_ERR_UNSUPP_DECODE_PKT;
- LogError(ocsdError(sev, err, "Data trace related, unsupported packet type."));
+ if (sev == OCSD_ERR_SEV_WARN)
+ LogError(ocsdError(sev, err, "Data trace related, unsupported packet type."));
+ else
+ err = handlePacketSeqErr(err, m_index_curr_pkt, "Data trace related, unsupported packet type.");
}
break;
default:
// any other packet - bad packet error
- err = OCSD_ERR_BAD_DECODE_PKT;
- LogError(ocsdError(OCSD_ERR_SEV_ERROR,err,"Unknown packet type."));
+ err = handleBadPacket("Unknown packet type.", m_index_curr_pkt);
break;
}
@@ -845,9 +847,8 @@ ocsd_err_t TrcPktDecodeEtmV4I::commitElements()
}
else
{
- // too few elements for commit operation - decode error.
- err = OCSD_ERR_COMMIT_PKT_OVERRUN;
- LogError(ocsdError(OCSD_ERR_SEV_ERROR,OCSD_ERR_COMMIT_PKT_OVERRUN,err_idx,m_CSID,"Not enough elements to commit"));
+ // too few elements for commit operation - decode error.
+ err = handlePacketSeqErr(OCSD_ERR_COMMIT_PKT_OVERRUN, err_idx, "Not enough elements to commit");
}
}
@@ -867,7 +868,7 @@ ocsd_err_t TrcPktDecodeEtmV4I::returnStackPop()
if (m_return_stack.overflow())
{
err = OCSD_ERR_RET_STACK_OVERFLOW;
- LogError(ocsdError(OCSD_ERR_SEV_ERROR, err, "Trace Return Stack Overflow."));
+ err = handlePacketSeqErr(err, OCSD_BAD_TRC_INDEX, "Trace Return Stack Overflow.");
}
else
{
@@ -1007,6 +1008,8 @@ ocsd_err_t TrcPktDecodeEtmV4I::cancelElements()
break;
}
}
+ if (m_P0_stack.size() == 0)
+ P0StackDone = true;
}
}
// may have some unseen elements
@@ -1020,21 +1023,23 @@ ocsd_err_t TrcPktDecodeEtmV4I::cancelElements()
{
// too few elements for commit operation - decode error.
err = OCSD_ERR_COMMIT_PKT_OVERRUN;
- LogError(ocsdError(OCSD_ERR_SEV_ERROR, err, m_index_curr_pkt, m_CSID, "Not enough elements to cancel"));
+ err = handlePacketSeqErr(err, m_index_curr_pkt, "Not enough elements to cancel");
m_elem_res.P0_cancel = 0;
break;
}
-
- if (temp.size())
+ }
+
+ /* restore any saved elements that are unaffected by cancel. */
+ if (temp.size())
+ {
+ while (temp.size())
{
- while (temp.size())
- {
- pElem = temp.back();
- m_P0_stack.push_front(pElem);
- temp.pop_back(false);
- }
+ pElem = temp.back();
+ m_P0_stack.push_front(pElem);
+ temp.pop_back(false);
}
}
+
m_curr_spec_depth -= num_cancel_req - m_elem_res.P0_cancel;
return err;
}
@@ -1076,7 +1081,8 @@ ocsd_err_t TrcPktDecodeEtmV4I::mispredictAtom()
if (!bFoundAtom && !m_unseen_spec_elem)
{
err = OCSD_ERR_COMMIT_PKT_OVERRUN;
- LogError(ocsdError(OCSD_ERR_SEV_ERROR, err, m_index_curr_pkt, m_CSID, "Not found mispredict atom"));
+ err = handlePacketSeqErr(err, m_index_curr_pkt, "Not found mispredict atom");
+ //LogError(ocsdError(OCSD_ERR_SEV_ERROR, err, m_index_curr_pkt, m_CSID, "Not found mispredict atom"));
}
m_elem_res.mispredict = false;
return err;
@@ -1266,7 +1272,8 @@ ocsd_err_t TrcPktDecodeEtmV4I::processAtom(const ocsd_atm_val atom)
}
else
{
- LogError(ocsdError(OCSD_ERR_SEV_ERROR,err,pElem->getRootIndex(),m_CSID,"Error processing atom packet."));
+ err = handlePacketSeqErr(err, pElem->getRootIndex(), "Error processing atom packet.");
+ //LogError(ocsdError(OCSD_ERR_SEV_ERROR,err,pElem->getRootIndex(),m_CSID,"Error processing atom packet."));
return err;
}
}
@@ -1372,9 +1379,11 @@ ocsd_err_t TrcPktDecodeEtmV4I::processException()
if (pElem->getP0Type() != P0_ADDR)
{
- // no following address element - indicate processing error.
- LogError(ocsdError(OCSD_ERR_SEV_ERROR, OCSD_ERR_BAD_PACKET_SEQ, excep_pkt_index, m_CSID, "Address missing in exception packet."));
- return OCSD_ERR_BAD_PACKET_SEQ;
+ // no following address element - indicate processing error.
+
+ err = handlePacketSeqErr(OCSD_ERR_BAD_PACKET_SEQ, m_index_curr_pkt, "Address missing in exception packet.");
+ //LogError(ocsdError(OCSD_ERR_SEV_ERROR, OCSD_ERR_BAD_PACKET_SEQ, excep_pkt_index, m_CSID, "Address missing in exception packet."));
+ return err;
}
else
{
@@ -1635,7 +1644,7 @@ ocsd_err_t TrcPktDecodeEtmV4I::processSourceAddress()
uint32_t opcode, bytesReq = 4;
ocsd_vaddr_t currAddr = m_instr_info.instr_addr; // get the latest decoded address.
instr_range_t out_range;
- bool bSplitRangeOnN = getComponentOpMode() & ETE_OPFLG_PKTDEC_SRCADDR_N_ATOMS;
+ bool bSplitRangeOnN = getComponentOpMode() & ETE_OPFLG_PKTDEC_SRCADDR_N_ATOMS ? true : false;
// check we can read instruction @ source address
err = accessMemory(srcAddr.val, getCurrMemSpace(), &bytesReq, (uint8_t *)&opcode);
@@ -1868,27 +1877,42 @@ void TrcPktDecodeEtmV4I::updateContext(TrcStackElemCtxt *pCtxtElem, OcsdTraceEle
m_need_ctxt = false;
}
-ocsd_err_t TrcPktDecodeEtmV4I::handleBadPacket(const char *reason)
+ocsd_err_t TrcPktDecodeEtmV4I::handleBadPacket(const char *reason, ocsd_trc_index_t index /* = OCSD_BAD_TRC_INDEX */)
{
- ocsd_err_t err = OCSD_OK;
+ ocsd_err_severity_t sev = OCSD_ERR_SEV_WARN;
+ if (getComponentOpMode() & OCSD_OPFLG_PKTDEC_ERROR_BAD_PKTS)
+ sev = OCSD_ERR_SEV_ERROR;
- if(getComponentOpMode() & OCSD_OPFLG_PKTDEC_ERROR_BAD_PKTS)
- {
- // error out - stop decoding
- err = OCSD_ERR_BAD_DECODE_PKT;
- LogError(ocsdError(OCSD_ERR_SEV_ERROR,err,reason));
- }
- else
+ return handlePacketErr(OCSD_ERR_BAD_DECODE_PKT, sev, index, reason);
+}
+
+ocsd_err_t TrcPktDecodeEtmV4I::handlePacketSeqErr(ocsd_err_t err, ocsd_trc_index_t index, const char *reason)
+{
+ return handlePacketErr(err, OCSD_ERR_SEV_ERROR, index, reason);
+}
+
+ocsd_err_t TrcPktDecodeEtmV4I::handlePacketErr(ocsd_err_t err, ocsd_err_severity_t sev, ocsd_trc_index_t index, const char *reason)
+{
+ bool resetOnBadPackets = true;
+
+ if(getComponentOpMode() & OCSD_OPFLG_PKTDEC_HALT_BAD_PKTS)
+ resetOnBadPackets = false;
+
+ LogError(ocsdError(sev, err, index, getCoreSightTraceID(), reason));
+
+ if (resetOnBadPackets)
{
- LogError(ocsdError(OCSD_ERR_SEV_WARN, OCSD_ERR_BAD_DECODE_PKT, reason));
// switch to unsync - clear decode state
resetDecoder();
m_curr_state = NO_SYNC;
m_unsync_eot_info = UNSYNC_BAD_PACKET;
+ err = OCSD_OK;
}
return err;
+
}
+
inline ocsd_mem_space_acc_t TrcPktDecodeEtmV4I::getCurrMemSpace()
{
static ocsd_mem_space_acc_t SMemSpace[] = {
diff --git a/decoder/source/etmv4/trc_pkt_proc_etmv4i.cpp b/decoder/source/etmv4/trc_pkt_proc_etmv4i.cpp
index 81ae9d7..4c92d9e 100644
--- a/decoder/source/etmv4/trc_pkt_proc_etmv4i.cpp
+++ b/decoder/source/etmv4/trc_pkt_proc_etmv4i.cpp
@@ -1501,8 +1501,8 @@ void TrcPktProcEtmV4I::BuildIPacketTable()
m_i_table[0x85+i].pptkFn = &TrcPktProcEtmV4I::iPktAddrCtxt;
}
- // 0b1000 1000 - ETE 1.1 TS Marker
- if (m_config.MajVersion() >= 0x5)
+ // 0b1000 1000 - ETE 1.1 TS Marker. also ETMv4.6
+ if(m_config.FullVersion() >= 0x46)
{
m_i_table[0x88].pkt_type = ETE_PKT_I_TS_MARKER;
m_i_table[0x88].pptkFn = &TrcPktProcEtmV4I::iPktNoPayload;
diff --git a/decoder/source/ocsd_dcd_tree.cpp b/decoder/source/ocsd_dcd_tree.cpp
index 5dafba9..b8c27a0 100644
--- a/decoder/source/ocsd_dcd_tree.cpp
+++ b/decoder/source/ocsd_dcd_tree.cpp
@@ -511,7 +511,7 @@ DecodeTreeElement *DecodeTree::getNextElement(uint8_t &elemID)
if(m_decode_elem_iter < 0x80)
{
// find a none zero entry or end of range
- while((m_decode_elements[m_decode_elem_iter] == 0) && (m_decode_elem_iter < 0x80))
+ while((m_decode_elem_iter < 0x80) && (m_decode_elements[m_decode_elem_iter] == 0))
m_decode_elem_iter++;
// return entry unless end of range
diff --git a/decoder/source/ocsd_gen_elem_stack.cpp b/decoder/source/ocsd_gen_elem_stack.cpp
index bb75842..66fe75d 100644
--- a/decoder/source/ocsd_gen_elem_stack.cpp
+++ b/decoder/source/ocsd_gen_elem_stack.cpp
@@ -42,6 +42,7 @@ OcsdGenElemStack::OcsdGenElemStack() :
m_curr_elem_idx(0),
m_send_elem_idx(0),
m_CSID(0),
+ m_sendIf(NULL),
m_is_init(false)
{
diff --git a/decoder/source/ptm/trc_pkt_proc_ptm.cpp b/decoder/source/ptm/trc_pkt_proc_ptm.cpp
index 7c90b62..a7419b0 100644
--- a/decoder/source/ptm/trc_pkt_proc_ptm.cpp
+++ b/decoder/source/ptm/trc_pkt_proc_ptm.cpp
@@ -224,6 +224,7 @@ void TrcPktProcPtm::InitProcessorState()
m_waitASyncSOPkt = false;
m_bAsyncRawOp = false;
m_bOPNotSyncPkt = false;
+ m_excepAltISA = 0;
m_curr_packet.ResetState();
InitPacketState();
diff --git a/decoder/tests/source/c_api_pkt_print_test.c b/decoder/tests/source/c_api_pkt_print_test.c
index 02c589e..caa67e9 100644
--- a/decoder/tests/source/c_api_pkt_print_test.c
+++ b/decoder/tests/source/c_api_pkt_print_test.c
@@ -116,6 +116,9 @@ static int test_printstr = 0;
/* test the library printer API */
static int test_lib_printers = 0;
+/* test the last error / error code api */
+static int test_error_api = 0;
+
/* Process command line options - choose the operation to use for the test. */
static int process_cmd_line(int argc, char *argv[])
{
@@ -124,52 +127,52 @@ static int process_cmd_line(int argc, char *argv[])
while(idx < argc)
{
- if(strcmp(argv[idx],"-decode_only") == 0)
+ if (strcmp(argv[idx], "-decode_only") == 0)
{
op = TEST_PKT_DECODEONLY;
}
- else if(strcmp(argv[idx],"-decode") == 0)
+ else if (strcmp(argv[idx], "-decode") == 0)
{
op = TEST_PKT_DECODE;
}
- else if(strcmp(argv[idx],"-id") == 0)
+ else if (strcmp(argv[idx], "-id") == 0)
{
idx++;
- if(idx < argc)
+ if (idx < argc)
{
- test_trc_id_override = (uint8_t)(strtoul(argv[idx],0,0));
- printf("ID override = 0x%02X\n",test_trc_id_override);
+ test_trc_id_override = (uint8_t)(strtoul(argv[idx], 0, 0));
+ printf("ID override = 0x%02X\n", test_trc_id_override);
}
}
- else if(strcmp(argv[idx],"-etmv3") == 0)
+ else if (strcmp(argv[idx], "-etmv3") == 0)
{
- test_protocol = OCSD_PROTOCOL_ETMV3;
+ test_protocol = OCSD_PROTOCOL_ETMV3;
selected_snapshot = tc2_snapshot;
mem_dump_address = mem_dump_address_tc2;
}
- else if(strcmp(argv[idx],"-ptm") == 0)
+ else if (strcmp(argv[idx], "-ptm") == 0)
{
- test_protocol = OCSD_PROTOCOL_PTM;
+ test_protocol = OCSD_PROTOCOL_PTM;
selected_snapshot = tc2_snapshot;
mem_dump_address = mem_dump_address_tc2;
}
- else if(strcmp(argv[idx],"-stm") == 0)
+ else if (strcmp(argv[idx], "-stm") == 0)
{
test_protocol = OCSD_PROTOCOL_STM;
trace_data_filename = stmtrace_data_filename;
}
- else if(strcmp(argv[idx],"-test_cb") == 0)
+ else if (strcmp(argv[idx], "-test_cb") == 0)
{
using_mem_acc_cb = 1;
use_region_file = 0;
}
else if (strcmp(argv[idx], "-test_cb_id") == 0)
- {
+ {
using_mem_acc_cb = 1;
use_region_file = 0;
using_mem_acc_cb_id = 1;
}
- else if(strcmp(argv[idx],"-test_region_file") == 0)
+ else if (strcmp(argv[idx], "-test_region_file") == 0)
{
use_region_file = 1;
using_mem_acc_cb = 0;
@@ -194,10 +197,10 @@ static int process_cmd_line(int argc, char *argv[])
{
test_lib_printers = 1;
}
- else if(strcmp(argv[idx],"-ss_path") == 0)
+ else if (strcmp(argv[idx], "-ss_path") == 0)
{
idx++;
- if((idx >= argc) || (strlen(argv[idx]) == 0))
+ if ((idx >= argc) || (strlen(argv[idx]) == 0))
{
printf("-ss_path: Missing path parameter or zero length\n");
return -1;
@@ -205,14 +208,18 @@ static int process_cmd_line(int argc, char *argv[])
else
{
len = strlen(argv[idx]);
- if(len > (MAX_TRACE_FILE_PATH_LEN - 32))
+ if (len > (MAX_TRACE_FILE_PATH_LEN - 32))
{
printf("-ss_path: path too long\n");
return -1;
}
usr_snapshot_path = argv[idx];
}
-
+
+ }
+ else if (strcmp(argv[idx], "-test_err_api") == 0)
+ {
+ test_error_api = 1;
}
else if(strcmp(argv[idx],"-help") == 0)
{
@@ -955,6 +962,57 @@ int process_trace_data(FILE *pf)
return (int)ret;
}
+#define ERR_BUFFER_SIZE 256
+int test_err_api()
+{
+ dcd_tree_handle_t dcdtree_handle = C_API_INVALID_TREE_HANDLE;
+ ocsd_err_t ret = OCSD_OK, err_test;
+ ocsd_trc_index_t index = 0, err_index = 0;
+ uint8_t cs_id;
+ char err_buffer[ERR_BUFFER_SIZE];
+
+ /* Create a decode tree for this source data.
+ source data is frame formatted, memory aligned from an ETR (no frame syncs) so create tree accordingly
+ */
+ dcdtree_handle = ocsd_create_dcd_tree(OCSD_TRC_SRC_SINGLE, OCSD_DFRMTR_FRAME_MEM_ALIGN);
+
+ if (dcdtree_handle != C_API_INVALID_TREE_HANDLE)
+ {
+
+ ret = create_decoder(dcdtree_handle);
+ if (ret == OCSD_OK)
+ {
+ /* attach the generic trace element output callback */
+ if (test_lib_printers)
+ ret = ocsd_dt_set_gen_elem_printer(dcdtree_handle);
+ else
+ ret = ocsd_dt_set_gen_elem_outfn(dcdtree_handle, gen_trace_elem_print, 0);
+ }
+
+
+ /* raw print and str print cb options tested in their init functions */
+ if (ret == OCSD_OK)
+ ret = test_printstr_cb(dcdtree_handle);
+
+ if (ret == OCSD_OK)
+ ret = attach_raw_printers(dcdtree_handle);
+
+ /* feed some duff data into a decoder to provoke an error! */
+ uint8_t trace_data[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x04, 0x60, 0x71 };
+
+ if (ret == OCSD_OK)
+ ret = process_data_block(dcdtree_handle, index, trace_data, sizeof(trace_data));
+
+ ocsd_err_str(ret, err_buffer, ERR_BUFFER_SIZE);
+ printf("testing error API for code %d: %s\n", ret, err_buffer);
+ err_test = ocsd_get_last_err(&err_index, &cs_id, err_buffer, ERR_BUFFER_SIZE);
+ printf("get last error:\ncode = 0x%02x; trace index %ld; cs_id 0x%02x;\nstring: %s\n", err_test, err_index, cs_id, err_buffer);
+
+ }
+ return ret;
+}
+
int main(int argc, char *argv[])
{
FILE *trace_data;
@@ -1012,9 +1070,12 @@ int main(int argc, char *argv[])
ocsd_def_errlog_msgout(message);
/* process the trace data */
- if(ret == 0)
- ret = process_trace_data(trace_data);
-
+ if (ret == 0) {
+ if (test_error_api)
+ ret = test_err_api();
+ else
+ ret = process_trace_data(trace_data);
+ }
/* close the data file */
fclose(trace_data);
}