svn commit: r362263 - in head: . contrib/opencsd/decoder/include/common contrib/opencsd/decoder/include/i_dec contrib/opencsd/decoder/include/mem_acc contrib/opencsd/decoder/include/opencsd contrib...

Andrew Turner andrew at FreeBSD.org
Wed Jun 17 10:42:24 UTC 2020


Author: andrew
Date: Wed Jun 17 10:42:20 2020
New Revision: 362263
URL: https://svnweb.freebsd.org/changeset/base/362263

Log:
  Update opencsd to 0.14.2
  
  Sponsored by:	Innovate UK

Added:
  head/contrib/opencsd/decoder/include/common/ocsd_gen_elem_stack.h
     - copied unchanged from r362220, vendor/opencsd/dist/decoder/include/common/ocsd_gen_elem_stack.h
  head/contrib/opencsd/decoder/include/common/trc_raw_buffer.h
     - copied unchanged from r362220, vendor/opencsd/dist/decoder/include/common/trc_raw_buffer.h
  head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_proc_etmv4i.h
     - copied unchanged from r362220, vendor/opencsd/dist/decoder/include/opencsd/etmv4/trc_pkt_proc_etmv4i.h
  head/contrib/opencsd/decoder/source/etmv4/trc_pkt_proc_etmv4i.cpp
     - copied unchanged from r362220, vendor/opencsd/dist/decoder/source/etmv4/trc_pkt_proc_etmv4i.cpp
  head/contrib/opencsd/decoder/source/ocsd_gen_elem_stack.cpp
     - copied unchanged from r362220, vendor/opencsd/dist/decoder/source/ocsd_gen_elem_stack.cpp
Deleted:
  head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4d.h
  head/contrib/opencsd/decoder/source/etmv4/trc_pkt_elem_etmv4d.cpp
  head/contrib/opencsd/decoder/source/etmv4/trc_pkt_proc_etmv4.cpp
  head/contrib/opencsd/decoder/source/etmv4/trc_pkt_proc_etmv4d_impl.h
  head/contrib/opencsd/decoder/source/etmv4/trc_pkt_proc_etmv4i_impl.cpp
  head/contrib/opencsd/decoder/source/etmv4/trc_pkt_proc_etmv4i_impl.h
Modified:
  head/ObsoleteFiles.inc
  head/contrib/opencsd/decoder/include/common/ocsd_dcd_mngr.h
  head/contrib/opencsd/decoder/include/common/ocsd_gen_elem_list.h
  head/contrib/opencsd/decoder/include/common/trc_core_arch_map.h
  head/contrib/opencsd/decoder/include/common/trc_gen_elem.h
  head/contrib/opencsd/decoder/include/common/trc_pkt_decode_base.h
  head/contrib/opencsd/decoder/include/i_dec/trc_i_decode.h
  head/contrib/opencsd/decoder/include/i_dec/trc_idec_arminst.h
  head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_bufptr.h
  head/contrib/opencsd/decoder/include/opencsd/etmv3/trc_pkt_decode_etmv3.h
  head/contrib/opencsd/decoder/include/opencsd/etmv4/etmv4_decoder.h
  head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_etmv4_stack_elem.h
  head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h
  head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4i.h
  head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_proc_etmv4.h
  head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_types_etmv4.h
  head/contrib/opencsd/decoder/include/opencsd/ocsd_if_types.h
  head/contrib/opencsd/decoder/include/opencsd/ocsd_if_version.h
  head/contrib/opencsd/decoder/include/opencsd/ptm/trc_pkt_decode_ptm.h
  head/contrib/opencsd/decoder/include/opencsd/stm/trc_pkt_decode_stm.h
  head/contrib/opencsd/decoder/include/opencsd/trc_gen_elem_types.h
  head/contrib/opencsd/decoder/include/pkt_printers/pkt_printer_t.h
  head/contrib/opencsd/decoder/source/etmv3/trc_pkt_decode_etmv3.cpp
  head/contrib/opencsd/decoder/source/etmv4/trc_etmv4_stack_elem.cpp
  head/contrib/opencsd/decoder/source/etmv4/trc_pkt_decode_etmv4i.cpp
  head/contrib/opencsd/decoder/source/etmv4/trc_pkt_elem_etmv4i.cpp
  head/contrib/opencsd/decoder/source/i_dec/trc_i_decode.cpp
  head/contrib/opencsd/decoder/source/i_dec/trc_idec_arminst.cpp
  head/contrib/opencsd/decoder/source/mem_acc/trc_mem_acc_bufptr.cpp
  head/contrib/opencsd/decoder/source/ocsd_dcd_tree.cpp
  head/contrib/opencsd/decoder/source/ocsd_error.cpp
  head/contrib/opencsd/decoder/source/ptm/trc_pkt_decode_ptm.cpp
  head/contrib/opencsd/decoder/source/stm/trc_pkt_decode_stm.cpp
  head/contrib/opencsd/decoder/source/trc_component.cpp
  head/contrib/opencsd/decoder/source/trc_core_arch_map.cpp
  head/contrib/opencsd/decoder/source/trc_gen_elem.cpp
  head/lib/libopencsd/Makefile
Directory Properties:
  head/contrib/opencsd/   (props changed)

Modified: head/ObsoleteFiles.inc
==============================================================================
--- head/ObsoleteFiles.inc	Wed Jun 17 10:41:01 2020	(r362262)
+++ head/ObsoleteFiles.inc	Wed Jun 17 10:42:20 2020	(r362263)
@@ -36,6 +36,9 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20200617: update opencsd to 0.14.2
+OLD_FILES+=usr/include/opencsd/etmv4/trc_pkt_elem_etmv4d.h
+
 # 20200606: retire binutils build infrastructure
 .if !defined(WITH_PORT_BASE_BINUTILS)
 OLD_FILES+=usr/bin/as

Modified: head/contrib/opencsd/decoder/include/common/ocsd_dcd_mngr.h
==============================================================================
--- head/contrib/opencsd/decoder/include/common/ocsd_dcd_mngr.h	Wed Jun 17 10:41:01 2020	(r362262)
+++ head/contrib/opencsd/decoder/include/common/ocsd_dcd_mngr.h	Wed Jun 17 10:42:20 2020	(r362263)
@@ -115,6 +115,9 @@ ocsd_err_t  DecoderMngrBase<P,Pt,Pc>::createDecoder(co
     if(!pkt_proc)
         return OCSD_ERR_MEM;
 
+    // set the op mode flags
+    pkt_proc->setComponentOpMode(create_flags & (OCSD_OPFLG_COMP_MODE_MASK | OCSD_OPFLG_PKTPROC_COMMON));
+
     // set the configuration
     TrcPktProcBase<P,Pt,Pc> *pProcBase = dynamic_cast< TrcPktProcBase<P,Pt,Pc> *>(pkt_proc);       
     if(pProcBase == 0)
@@ -132,6 +135,9 @@ ocsd_err_t  DecoderMngrBase<P,Pt,Pc>::createDecoder(co
         pkt_dcd = createPktDecode(bUseInstID, instID);
         if(!pkt_dcd)
             return OCSD_ERR_MEM;
+
+        // set the op mode flags
+        pkt_dcd->setComponentOpMode(create_flags & (OCSD_OPFLG_COMP_MODE_MASK | OCSD_OPFLG_PKTDEC_COMMON));
 
         // get the decoder base
         TrcPktDecodeBase<P,Pc> *pBase = dynamic_cast< TrcPktDecodeBase<P,Pc> *>(pkt_dcd);       

Modified: head/contrib/opencsd/decoder/include/common/ocsd_gen_elem_list.h
==============================================================================
--- head/contrib/opencsd/decoder/include/common/ocsd_gen_elem_list.h	Wed Jun 17 10:41:01 2020	(r362262)
+++ head/contrib/opencsd/decoder/include/common/ocsd_gen_elem_list.h	Wed Jun 17 10:42:20 2020	(r362263)
@@ -1,6 +1,6 @@
 /*
- * \file       ocsd_gen_elem_stack.h
- * \brief      OpenCSD : Generic element output stack.
+ * \file       ocsd_gen_elem_list.h
+ * \brief      OpenCSD : Generic element output list.
  * 
  * \copyright  Copyright (c) 2016, ARM Limited. All Rights Reserved.
  */
@@ -47,7 +47,7 @@
  * This should remove some of the requirement on the packet processing to be re-enterant,
  * simplifying this code.
  *
- * Last element(s) on this stack can be marked pending to allow for later cancellation.
+ * Last element(s) on this list can be marked pending to allow for later cancellation.
  * (This required for cancel element in ETMv3 exeception branch).
  * 
  * The "list" is actually a ring buffer - maintaining pointers to indicate current valid elements.
@@ -150,4 +150,4 @@ inline void OcsdGenElemList::initSendIf(componentAttac
     m_sendIf = pGenElemIf;
 }
 
-/* End of File ocsd_gen_elem_stack.h */
+/* End of File ocsd_gen_elem_list.h */

Copied: head/contrib/opencsd/decoder/include/common/ocsd_gen_elem_stack.h (from r362220, vendor/opencsd/dist/decoder/include/common/ocsd_gen_elem_stack.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/contrib/opencsd/decoder/include/common/ocsd_gen_elem_stack.h	Wed Jun 17 10:42:20 2020	(r362263, copy of r362220, vendor/opencsd/dist/decoder/include/common/ocsd_gen_elem_stack.h)
@@ -0,0 +1,109 @@
+/*
+* \file       ocsd_gen_elem_stack.h
+* \brief      OpenCSD : Generic element output stack.
+*
+* \copyright  Copyright (c) 2020, ARM Limited. All Rights Reserved.
+*/
+
+/*
+* 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.
+*/
+
+#include "trc_gen_elem.h"
+#include "comp_attach_pt_t.h"
+#include "interfaces/trc_gen_elem_in_i.h"
+
+/* element stack to handle cases where a trace element can generate multiple output packets 
+  
+   maintains the "current" element, which might be sent independently of this stack, and also
+   ensures that persistent data in the output elements is maintained between elements.
+*/
+class OcsdGenElemStack
+{
+public:
+    OcsdGenElemStack();
+    ~OcsdGenElemStack();
+
+    void initSendIf(componentAttachPt<ITrcGenElemIn> *pGenElemIf);
+    void initCSID(const uint8_t CSID) { m_CSID = CSID; };
+
+    OcsdTraceElement &getCurrElem();    //!< get the current element. 
+    ocsd_err_t resetElemStack();        //!< set pointers to base of stack
+    ocsd_err_t addElem(const ocsd_trc_index_t trc_pkt_idx);    //!< add elem to stack and set current.
+    void setCurrElemIdx(const ocsd_trc_index_t trc_pkt_idx);   //!< packet index for this element
+    ocsd_err_t addElemType(const ocsd_trc_index_t trc_pkt_idx, ocsd_gen_trc_elem_t elem_type);
+
+    ocsd_datapath_resp_t sendElements();    //!< send elements on the stack
+    const int numElemToSend() const;
+
+private:
+    typedef struct _elemPtr {
+        OcsdTraceElement *pElem;        //!< pointer to the listed trace element
+        ocsd_trc_index_t trc_pkt_idx;   //!< packet index in the trace stream
+    } elemPtr_t;
+
+    const bool isInit();              //!< check correctly initialised.
+
+    ocsd_err_t growArray();
+    void copyPersistentData(int src, int dst);  //!< copy across persistent state data between elements
+    void resetIndexes();    //!< clear down all indexes - reset or send complete.
+
+    elemPtr_t *m_pElemArray;    //!< an array of pointers to elements.
+    int m_elemArraySize;        //!< number of element pointers in the array 
+
+    int m_elem_to_send;     //!< number of live elements in the stack - init to 1.
+    int m_curr_elem_idx;    //!< index into the element array.
+    int m_send_elem_idx;    //!< next element to send.
+
+    //!< send packet info
+    uint8_t m_CSID;
+    componentAttachPt<ITrcGenElemIn> *m_sendIf; //!< element send interface.
+
+    bool m_is_init;
+};
+
+inline const int OcsdGenElemStack::numElemToSend() const
+{
+    return m_elem_to_send;
+}
+
+inline void OcsdGenElemStack::initSendIf(componentAttachPt<ITrcGenElemIn> *pGenElemIf)
+{
+    m_sendIf = pGenElemIf;
+}
+
+inline void OcsdGenElemStack::setCurrElemIdx(const ocsd_trc_index_t trc_pkt_idx)
+{
+    m_pElemArray[m_curr_elem_idx].trc_pkt_idx = trc_pkt_idx;
+}
+
+inline OcsdTraceElement &OcsdGenElemStack::getCurrElem()
+{
+    return *(m_pElemArray[m_curr_elem_idx].pElem);
+}
+
+
+/* End of File ocsd_gen_elem_stack.h */

Modified: head/contrib/opencsd/decoder/include/common/trc_core_arch_map.h
==============================================================================
--- head/contrib/opencsd/decoder/include/common/trc_core_arch_map.h	Wed Jun 17 10:41:01 2020	(r362262)
+++ head/contrib/opencsd/decoder/include/common/trc_core_arch_map.h	Wed Jun 17 10:42:20 2020	(r362263)
@@ -39,6 +39,23 @@
 #include <string>
 #include "opencsd/ocsd_if_types.h"
 
+/** @class CoreArchProfileMap
+ *
+ *  @brief Map core / arch name to profile for decoder.
+ *
+ *  Helper class for library clients to map core or architecture version names onto 
+ *  a profile / arch version pair suitable for use with the decode library.
+ * 
+ *  Valid core names are:-
+ *   - Cortex-Axx : where xx = 5,7,12,15,17,32,35,53,55,57,65,72,73,75,76,77;
+ *   - Cortex-Rxx : where xx = 5,7,8,52;
+ *   - Cortex-Mxx : where xx = 0,0+,3,4,23,33;
+ *
+ *  Valid architecture profile names are:-
+ *   - ARMv7-A, ARMv7-R, ARMv7-M;
+ *   - ARMv8-A, ARMv8.3A, ARMv8-R, ARMv8-M;
+ *  
+ */
 class CoreArchProfileMap
 {
 public:
@@ -50,16 +67,31 @@ class CoreArchProfileMap (public)
 private:
 
     std::map<std::string, ocsd_arch_profile_t> core_profiles;
+    std::map<std::string, ocsd_arch_profile_t> arch_profiles;
 };
 
 inline ocsd_arch_profile_t CoreArchProfileMap::getArchProfile(const std::string &coreName)
 {
     ocsd_arch_profile_t ap = { ARCH_UNKNOWN, profile_Unknown };
+    bool bFound = false;
 
     std::map<std::string, ocsd_arch_profile_t>::const_iterator it;
+
+    /* match against the core name map. */
     it = core_profiles.find(coreName);
-    if(it != core_profiles.end())
+    if (it != core_profiles.end())
+    {
         ap = it->second;
+        bFound = true;
+    }
+
+    /* scan architecture profiles on no core name match */
+    if (!bFound)
+    {
+        it = arch_profiles.find(coreName);
+        if (it != arch_profiles.end())
+            ap = it->second;
+    }
     return ap;
 }
 

Modified: head/contrib/opencsd/decoder/include/common/trc_gen_elem.h
==============================================================================
--- head/contrib/opencsd/decoder/include/common/trc_gen_elem.h	Wed Jun 17 10:41:01 2020	(r362262)
+++ head/contrib/opencsd/decoder/include/common/trc_gen_elem.h	Wed Jun 17 10:42:20 2020	(r362263)
@@ -72,6 +72,7 @@ class OcsdTraceElement : public trcPrintableElem, publ
 
 
     void setTraceOnReason(const trace_on_reason_t reason);
+    void setUnSyncEOTReason(const unsync_info_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, const uint8_t size);
@@ -94,7 +95,8 @@ class OcsdTraceElement : public trcPrintableElem, publ
     // 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(); //!< clear flags that indicate validity / have values on a per packet basis
@@ -171,8 +173,8 @@ inline void OcsdTraceElement::init()
 
 inline void OcsdTraceElement::clearPerPktData()
 {
-    flag_bits = 0; // union with trace_on_reason / trace_event
-
+    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
 }
 
@@ -181,6 +183,11 @@ inline void OcsdTraceElement::setTraceOnReason(const t
     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;
@@ -201,6 +208,12 @@ inline void OcsdTraceElement::setExtendedDataPtr(const
     ptr_extended_data = data_ptr;
 }
 
+// set persistent data between output packets.
+inline void OcsdTraceElement::copyPersistentData(const OcsdTraceElement &src)
+{
+    isa = src.isa;
+    context = src.context;
+}
 
 /** @}*/
 

Modified: head/contrib/opencsd/decoder/include/common/trc_pkt_decode_base.h
==============================================================================
--- head/contrib/opencsd/decoder/include/common/trc_pkt_decode_base.h	Wed Jun 17 10:41:01 2020	(r362262)
+++ head/contrib/opencsd/decoder/include/common/trc_pkt_decode_base.h	Wed Jun 17 10:42:20 2020	(r362263)
@@ -85,7 +85,10 @@ class TrcPktDecodeI : public TraceComponent (protected
     virtual ocsd_err_t onProtocolConfig() = 0;
     virtual const uint8_t getCoreSightTraceID() = 0;
 
+    /* init handling */
     const bool checkInit();
+    /* Called on first init confirmation */
+    virtual void onFirstInitOK() {};
 
     /* data output */
     ocsd_datapath_resp_t outputTraceElement(const OcsdTraceElement &elem);    // use current index
@@ -147,6 +150,8 @@ inline const bool TrcPktDecodeI::checkInit()
             init_err_msg = "No instruction decoder interface attached and enabled";
         else
             m_decode_init_ok = true;
+        if (m_decode_init_ok)
+            onFirstInitOK();
     }
     return m_decode_init_ok;
 }

Copied: head/contrib/opencsd/decoder/include/common/trc_raw_buffer.h (from r362220, vendor/opencsd/dist/decoder/include/common/trc_raw_buffer.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/contrib/opencsd/decoder/include/common/trc_raw_buffer.h	Wed Jun 17 10:42:20 2020	(r362263, copy of r362220, vendor/opencsd/dist/decoder/include/common/trc_raw_buffer.h)
@@ -0,0 +1,96 @@
+/*
+* \file       trc_raw_buffer.h
+* \brief      OpenCSD : Trace raw data byte buffer
+*
+* \copyright  Copyright (c) 2019, ARM Limited. All Rights Reserved.
+*/
+
+/*
+* 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_RAW_BUFFER_H_INCLUDED
+#define ARM_TRC_RAW_BUFFER_H_INCLUDED
+
+#include <vector>
+
+class TraceRawBuffer
+{
+public:
+    TraceRawBuffer() : 
+        m_bufSize(0), 
+        m_bufProcessed(0), 
+        m_pBuffer(0), 
+        pkt(0)
+    {};
+    ~TraceRawBuffer() {};
+
+    // init the buffer
+    void init(const uint32_t size, const uint8_t *rawtrace, std::vector<uint8_t> *out_packet);
+    void copyByteToPkt();   // move a byte to the packet buffer     
+    uint8_t peekNextByte(); // value of next byte in buffer.
+
+    bool empty() { return m_bufProcessed == m_bufSize; };
+    // bytes processed.
+    uint32_t processed() { return m_bufProcessed; };
+    // buffer size;
+    uint32_t size() { return m_bufSize; }
+
+private:
+    uint32_t m_bufSize;
+    uint32_t m_bufProcessed;
+    const uint8_t *m_pBuffer;
+    std::vector<uint8_t> *pkt;
+
+};
+
+// init the buffer
+inline void TraceRawBuffer::init(const uint32_t size, const uint8_t *rawtrace, std::vector<uint8_t> *out_packet)
+{
+    m_bufSize = size;
+    m_bufProcessed = 0;
+    m_pBuffer = rawtrace;
+    pkt = out_packet;
+}
+
+inline void TraceRawBuffer::copyByteToPkt()
+{
+    if (!empty()) {
+        pkt->push_back(m_pBuffer[m_bufProcessed]);
+        m_bufProcessed++;
+    }
+}
+
+inline uint8_t TraceRawBuffer::peekNextByte()
+{
+    uint8_t val = 0;
+    if (!empty())
+        val = m_pBuffer[m_bufProcessed];
+    return val;
+}
+
+#endif // ARM_TRC_RAW_BUFFER_H_INCLUDED
+

Modified: head/contrib/opencsd/decoder/include/i_dec/trc_i_decode.h
==============================================================================
--- head/contrib/opencsd/decoder/include/i_dec/trc_i_decode.h	Wed Jun 17 10:41:01 2020	(r362262)
+++ head/contrib/opencsd/decoder/include/i_dec/trc_i_decode.h	Wed Jun 17 10:42:20 2020	(r362263)
@@ -46,10 +46,9 @@ class TrcIDecode : public IInstrDecode   (public)
     virtual ocsd_err_t DecodeInstruction(ocsd_instr_info *instr_info);
 
 private:
-    ocsd_err_t DecodeA32(ocsd_instr_info *instr_info);
-    ocsd_err_t DecodeA64(ocsd_instr_info *instr_info);
-    ocsd_err_t DecodeT32(ocsd_instr_info *instr_info);
-    void SetArchVersion(ocsd_instr_info *instr_info);
+    ocsd_err_t DecodeA32(ocsd_instr_info *instr_info, struct decode_info *info);
+    ocsd_err_t DecodeA64(ocsd_instr_info *instr_info, struct decode_info *info);
+    ocsd_err_t DecodeT32(ocsd_instr_info *instr_info, struct decode_info *info);
 };
 
 #endif // ARM_TRC_I_DECODE_H_INCLUDED

Modified: head/contrib/opencsd/decoder/include/i_dec/trc_idec_arminst.h
==============================================================================
--- head/contrib/opencsd/decoder/include/i_dec/trc_idec_arminst.h	Wed Jun 17 10:41:01 2020	(r362262)
+++ head/contrib/opencsd/decoder/include/i_dec/trc_idec_arminst.h	Wed Jun 17 10:42:20 2020	(r362263)
@@ -42,6 +42,12 @@
 #include "opencsd/ocsd_if_types.h"
 #include <cstdint>
 
+/* supplementary decode information */
+struct decode_info {
+    uint16_t arch_version;
+    ocsd_instr_subtype instr_sub_type;
+};
+
 /*
 For Thumb2, test if a halfword is the first half of a 32-bit instruction,
 as opposed to a complete 16-bit instruction.
@@ -63,19 +69,19 @@ instructions that write to the PC.  It does not includ
 instructions such as SVC, HVC and SMC.
 (Performance event 0x0C includes these.)
 */
-int inst_ARM_is_branch(uint32_t inst);
-int inst_Thumb_is_branch(uint32_t inst);
-int inst_A64_is_branch(uint32_t inst);
+int inst_ARM_is_branch(uint32_t inst, struct decode_info *info);
+int inst_Thumb_is_branch(uint32_t inst, struct decode_info *info);
+int inst_A64_is_branch(uint32_t inst, struct decode_info *info);
 
 /*
 Test whether an instruction is a direct (aka immediate) branch.
 Performance event 0x0D counts these.
 */
 int inst_ARM_is_direct_branch(uint32_t inst);
-int inst_Thumb_is_direct_branch(uint32_t inst);
-int inst_Thumb_is_direct_branch_link(uint32_t inst, uint8_t *is_link, uint8_t *is_cond);
-int inst_A64_is_direct_branch(uint32_t inst);
-int inst_A64_is_direct_branch_link(uint32_t inst, uint8_t *is_link);
+int inst_Thumb_is_direct_branch(uint32_t inst, struct decode_info *info);
+int inst_Thumb_is_direct_branch_link(uint32_t inst, uint8_t *is_link, uint8_t *is_cond, struct decode_info *info);
+int inst_A64_is_direct_branch(uint32_t inst, struct decode_info *info);
+int inst_A64_is_direct_branch_link(uint32_t inst, uint8_t *is_link, struct decode_info *info);
 
 /*
 Get branch destination for a direct branch.
@@ -84,15 +90,15 @@ int inst_ARM_branch_destination(uint32_t addr, uint32_
 int inst_Thumb_branch_destination(uint32_t addr, uint32_t inst, uint32_t *pnpc);
 int inst_A64_branch_destination(uint64_t addr, uint32_t inst, uint64_t *pnpc);
 
-int inst_ARM_is_indirect_branch(uint32_t inst);
-int inst_Thumb_is_indirect_branch_link(uint32_t inst, uint8_t *is_link);
-int inst_Thumb_is_indirect_branch(uint32_t inst);
-int inst_A64_is_indirect_branch_link(uint32_t inst, uint8_t *is_link);
-int inst_A64_is_indirect_branch(uint32_t inst);
+int inst_ARM_is_indirect_branch(uint32_t inst, struct decode_info *info);
+int inst_Thumb_is_indirect_branch_link(uint32_t inst, uint8_t *is_link, struct decode_info *info);
+int inst_Thumb_is_indirect_branch(uint32_t inst, struct decode_info *info);
+int inst_A64_is_indirect_branch_link(uint32_t inst, uint8_t *is_link, struct decode_info *info);
+int inst_A64_is_indirect_branch(uint32_t inst, struct decode_info *info);
 
-int inst_ARM_is_branch_and_link(uint32_t inst);
-int inst_Thumb_is_branch_and_link(uint32_t inst);
-int inst_A64_is_branch_and_link(uint32_t inst);
+int inst_ARM_is_branch_and_link(uint32_t inst, struct decode_info *info);
+int inst_Thumb_is_branch_and_link(uint32_t inst, struct decode_info *info);
+int inst_A64_is_branch_and_link(uint32_t inst, struct decode_info *info);
 
 int inst_ARM_is_conditional(uint32_t inst);
 int inst_Thumb_is_conditional(uint32_t inst);
@@ -127,14 +133,6 @@ intended to be helpful in 'runaway decode' prevention.
 int inst_ARM_is_UDF(uint32_t inst);
 int inst_Thumb_is_UDF(uint32_t inst);
 int inst_A64_is_UDF(uint32_t inst);
-
-
-/* access sub-type information */
-ocsd_instr_subtype get_instr_subtype();
-void clear_instr_subtype();
-
-/* set arch version info. */
-void set_arch_version(uint16_t version);
 
 #endif // ARM_TRC_IDEC_ARMINST_H_INCLUDED
 

Modified: head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_bufptr.h
==============================================================================
--- head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_bufptr.h	Wed Jun 17 10:41:01 2020	(r362262)
+++ head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_bufptr.h	Wed Jun 17 10:42:20 2020	(r362263)
@@ -68,7 +68,6 @@ class TrcMemAccBufPtr: public TrcMemAccessorBase (publ
 
 private:
     const uint8_t *m_p_buffer;  /**< pointer to the memory buffer  */
-    const uint32_t m_size;  /**< size of the memory buffer. */
 };
 
 #endif // ARM_TRC_MEM_ACC_BUFPTR_H_INCLUDED

Modified: head/contrib/opencsd/decoder/include/opencsd/etmv3/trc_pkt_decode_etmv3.h
==============================================================================
--- head/contrib/opencsd/decoder/include/opencsd/etmv3/trc_pkt_decode_etmv3.h	Wed Jun 17 10:41:01 2020	(r362262)
+++ head/contrib/opencsd/decoder/include/opencsd/etmv3/trc_pkt_decode_etmv3.h	Wed Jun 17 10:42:20 2020	(r362263)
@@ -264,6 +264,7 @@ class TrcPktDecodeEtmV3 :  public TrcPktDecodeBase<Etm
     } processor_state_t;
 
     processor_state_t m_curr_state;
+    unsync_info_t m_unsync_info;    //!< additional state for unsync
 
     uint8_t m_CSID; //!< Coresight trace ID for this decoder.
 };

Modified: head/contrib/opencsd/decoder/include/opencsd/etmv4/etmv4_decoder.h
==============================================================================
--- head/contrib/opencsd/decoder/include/opencsd/etmv4/etmv4_decoder.h	Wed Jun 17 10:41:01 2020	(r362262)
+++ head/contrib/opencsd/decoder/include/opencsd/etmv4/etmv4_decoder.h	Wed Jun 17 10:42:20 2020	(r362263)
@@ -38,7 +38,6 @@
 
 #include "trc_cmp_cfg_etmv4.h"
 #include "trc_pkt_elem_etmv4i.h"
-#include "trc_pkt_elem_etmv4d.h"
 #include "trc_pkt_proc_etmv4.h"
 #include "trc_pkt_types_etmv4.h"
 #include "trc_pkt_decode_etmv4i.h"

Modified: head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_etmv4_stack_elem.h
==============================================================================
--- head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_etmv4_stack_elem.h	Wed Jun 17 10:41:01 2020	(r362262)
+++ head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_etmv4_stack_elem.h	Wed Jun 17 10:42:20 2020	(r362263)
@@ -56,6 +56,7 @@ typedef enum _p0_elem_t 
     P0_TS,
     P0_CC,
     P0_TS_CC,
+    P0_Q,
     P0_OVERFLOW,
     P0_FUNC_RET,
 } p0_elem_t;
@@ -120,6 +121,44 @@ inline TrcStackElemAddr::TrcStackElemAddr(const ocsd_e
 }
 
 /************************************************************/
+/** Q element */
+class TrcStackQElem : public TrcStackElem
+{
+protected:
+    TrcStackQElem(const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index);
+    virtual ~TrcStackQElem() {};
+
+    friend class EtmV4P0Stack;
+
+public:
+    void setInstrCount(const int instr_count) { m_instr_count = instr_count; };
+    const int getInstrCount() const { return m_instr_count;  }
+
+    void setAddr(const etmv4_addr_val_t &addr_val) 
+    {
+        m_addr_val = addr_val; 
+        m_has_addr = true; 
+    };
+    const etmv4_addr_val_t &getAddr() const { return m_addr_val; };
+    const bool hasAddr() const { return  m_has_addr; };
+
+private:
+    bool m_has_addr;
+    etmv4_addr_val_t m_addr_val;
+    int m_instr_count;
+
+};
+
+inline TrcStackQElem::TrcStackQElem(const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index) :
+    TrcStackElem(P0_Q , true, root_pkt, root_index)
+{
+    m_addr_val.val = 0;
+    m_addr_val.isa = 0;
+    m_has_addr = false;
+    m_instr_count = 0;
+}
+
+/************************************************************/
 /** Context element */
     
 class TrcStackElemCtxt : public TrcStackElem
@@ -133,9 +172,12 @@ class TrcStackElemCtxt : public TrcStackElem (protecte
 public:
     void setContext(const  etmv4_context_t &ctxt) { m_context = ctxt; };
     const  etmv4_context_t &getContext() const  { return m_context; }; 
+    void setIS(const uint8_t IS) { m_IS = IS; };
+    const uint8_t getIS() const { return m_IS; };
 
 private:
      etmv4_context_t m_context;
+     uint8_t m_IS;  //!< IS value at time of generation of packet.
 };
 
 inline TrcStackElemCtxt::TrcStackElemCtxt(const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index) :
@@ -188,6 +230,7 @@ class TrcStackElemAtom : public TrcStackElem (public)
 
     const ocsd_atm_val commitOldest();
     int cancelNewest(const int nCancel);
+    void mispredictNewest();
     const bool isEmpty() const { return (m_atom.num == 0); };
 
 private:
@@ -217,6 +260,16 @@ inline int TrcStackElemAtom::cancelNewest(const int nC
     return nRemove;
 }
 
+// mispredict newest - flip the bit of the newest atom
+inline void TrcStackElemAtom::mispredictNewest()
+{
+    uint32_t mask = 0x1 << (m_atom.num - 1);
+    if (m_atom.En_bits & mask)
+        m_atom.En_bits &= ~mask;
+    else
+        m_atom.En_bits |= mask;
+}
+
 /************************************************************/
 /** Generic param element */
 
@@ -252,12 +305,20 @@ class EtmV4P0Stack (public)
 
     void push_front(TrcStackElem *pElem);
     void push_back(TrcStackElem *pElem);        // insert element when processing
-    void pop_back();
+    void pop_back(bool pend_delete = true);
+    void pop_front(bool pend_delete = true);
     TrcStackElem *back();
+    TrcStackElem *front();
     size_t size();
 
+    // iterate through stack from front
+    void from_front_init();
+    TrcStackElem *from_front_next();
+    void erase_curr_from_front();  // erase the element last returned 
+    
     void delete_all();
     void delete_back();
+    void delete_front();
     void delete_popped();
 
     // creation functions - create and push if successful.
@@ -265,13 +326,13 @@ class EtmV4P0Stack (public)
     TrcStackElem *createParamElemNoParam(const p0_elem_t p0_type, const bool isP0, const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, bool back = false);
     TrcStackElemAtom *createAtomElem (const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, const ocsd_pkt_atom &atom);
     TrcStackElemExcept *createExceptElem(const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, const bool bSame, const uint16_t excepNum);
-    TrcStackElemCtxt *createContextElem(const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, const etmv4_context_t &context);
+    TrcStackElemCtxt *createContextElem(const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, const etmv4_context_t &context, const uint8_t IS, const bool back = false);
     TrcStackElemAddr *createAddrElem(const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, const etmv4_addr_val_t &addr_val);
-
+    TrcStackQElem *createQElem(const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, const int count);
 private:
     std::deque<TrcStackElem *> m_P0_stack;  //!< P0 decode element stack
     std::vector<TrcStackElem *> m_popped_elem;  //!< save list of popped but not deleted elements.
-
+    std::deque<TrcStackElem *>::iterator m_iter;    //!< iterate across the list w/o removing stuff
 };
 
 inline EtmV4P0Stack::~EtmV4P0Stack()
@@ -293,12 +354,20 @@ inline void EtmV4P0Stack::push_back(TrcStackElem *pEle
 }
 
 // pop last element pointer off the stack and stash it for later deletion
-inline void EtmV4P0Stack::pop_back()
+inline void EtmV4P0Stack::pop_back(bool pend_delete /* = true */)
 {
-    m_popped_elem.push_back(m_P0_stack.back());
+    if (pend_delete)
+        m_popped_elem.push_back(m_P0_stack.back());
     m_P0_stack.pop_back();
 }
 
+inline void EtmV4P0Stack::pop_front(bool pend_delete /* = true */)
+{
+    if (pend_delete)
+        m_popped_elem.push_back(m_P0_stack.front());
+    m_P0_stack.pop_front();
+}
+
 // pop last element pointer off the stack and delete immediately
 inline void EtmV4P0Stack::delete_back()
 {
@@ -310,10 +379,28 @@ inline void EtmV4P0Stack::delete_back()
     }
 }
 
+// pop first element pointer off the stack and delete immediately
+inline void EtmV4P0Stack::delete_front()
+{
+    if (m_P0_stack.size() > 0)
+    {
+        TrcStackElem* pElem = m_P0_stack.front();
+        delete pElem;
+        m_P0_stack.pop_front();
+    }
+}
+
+
+
 // get a pointer to the last element on the stack
 inline TrcStackElem *EtmV4P0Stack::back()
 {
     return m_P0_stack.back();
+}
+
+inline TrcStackElem *EtmV4P0Stack::front()
+{
+    return m_P0_stack.front();
 }
 
 // remove and delete all the elements left on the stack

Modified: head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h
==============================================================================
--- head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h	Wed Jun 17 10:41:01 2020	(r362262)
+++ head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h	Wed Jun 17 10:42:20 2020	(r362263)
@@ -40,6 +40,7 @@
 #include "opencsd/etmv4/trc_cmp_cfg_etmv4.h"
 #include "common/trc_gen_elem.h"
 #include "common/trc_ret_stack.h"
+#include "common/ocsd_gen_elem_stack.h"
 #include "opencsd/etmv4/trc_etmv4_stack_elem.h"
 
 class TrcStackElem;
@@ -65,36 +66,70 @@ class TrcPktDecodeEtmV4I : public TrcPktDecodeBase<Etm
     /* local decode methods */
     void initDecoder();      // initial state on creation (zeros all config)
     void resetDecoder();     // reset state to start of decode. (moves state, retains config)
+    virtual void onFirstInitOK(); // override to set init related info.
 
-    ocsd_datapath_resp_t decodePacket(bool &Complete);    // return true to indicate decode complete - can change FSM to commit state - return is false.
-    ocsd_datapath_resp_t commitElements(bool &Complete);   // commit elements - may get wait response, or flag completion.
-    ocsd_datapath_resp_t flushEOT();
+    ocsd_err_t decodePacket();    // decode packet into trace elements. return true to indicate decode complete - can change FSM to commit state - return is false.
+    ocsd_datapath_resp_t resolveElements();   // commit/cancel trace elements generated from latest / prior packets & send to output - may get wait response, or flag completion.
+    ocsd_err_t commitElements(); // commit elements - process element stack to generate output packets.
+    ocsd_err_t commitElemOnEOT();
+    ocsd_err_t cancelElements();    // cancel elements. These not output  
+    ocsd_err_t mispredictAtom();    // mispredict an atom
+    ocsd_err_t discardElements();   // discard elements and flush
 
     void doTraceInfoPacket();
-    void updateContext(TrcStackElemCtxt *pCtxtElem);
+    void updateContext(TrcStackElemCtxt *pCtxtElem, OcsdTraceElement &elem);
     
-    // process atom will output instruction trace, or no memory access trace elements. 
-    ocsd_datapath_resp_t processAtom(const ocsd_atm_val, bool &bCont);
+    // process atom will create instruction trace, or no memory access trace output elements. 
+    ocsd_err_t processAtom(const ocsd_atm_val atom);
 
     // process an exception element - output instruction trace + exception generic type.
-    ocsd_datapath_resp_t processException(); 
+    ocsd_err_t processException(); 
 
+    // process Q element
+    ocsd_err_t processQElement();
+
+    // process an element that cannot be cancelled / discarded
+    ocsd_err_t processTS_CC_EventElem(TrcStackElem *pElem); 
+
     // process a bad packet
-    ocsd_datapath_resp_t handleBadPacket(const char *reason);
+    ocsd_err_t handleBadPacket(const char *reason);
 
-    ocsd_datapath_resp_t outputCC(TrcStackElemParam *pParamElem);
-    ocsd_datapath_resp_t outputTS(TrcStackElemParam *pParamElem, bool withCC);
-    ocsd_datapath_resp_t outputEvent(TrcStackElemParam *pParamElem);
+    ocsd_err_t addElemCC(TrcStackElemParam *pParamElem);
+    ocsd_err_t addElemTS(TrcStackElemParam *pParamElem, bool withCC);
+    ocsd_err_t addElemEvent(TrcStackElemParam *pParamElem);
      
 private:
     void SetInstrInfoInAddrISA(const ocsd_vaddr_t addr_val, const uint8_t isa); 
+    const ocsd_isa calcISA(const bool SF, const uint8_t IS) const
+    {
+        if (SF)
+            return ocsd_isa_aarch64;
+        return (IS == 0) ? ocsd_isa_arm : ocsd_isa_thumb2;
+    }
+    typedef enum {
+        WP_NOT_FOUND,
+        WP_FOUND,
+        WP_NACC
+    } WP_res_t;
 
-    ocsd_err_t traceInstrToWP(bool &bWPFound, const bool traceToAddrNext = false, const ocsd_vaddr_t nextAddrMatch = 0);      //!< follow instructions from the current address to a WP. true if good, false if memory cannot be accessed.
+    typedef struct {
+        ocsd_vaddr_t st_addr;
+        ocsd_vaddr_t en_addr;
+        uint32_t num_instr;
+    } instr_range_t;
 
-    ocsd_datapath_resp_t returnStackPop();  // pop return stack and update instruction address.
+    //!< follow instructions from the current address to a WP. true if good, false if memory cannot be accessed.
+    ocsd_err_t traceInstrToWP(instr_range_t &instr_range, WP_res_t &WPRes, const bool traceToAddrNext = false, const ocsd_vaddr_t nextAddrMatch = 0);
 
-    ocsd_datapath_resp_t outputTraceRange(const bool executed, ocsd_trc_index_t index);
+    inline const bool WPFound(WP_res_t res) const { return (res == WP_FOUND); };
+    inline const bool WPNacc(WP_res_t res) const { return (res == WP_NACC); };
+        
+    ocsd_err_t returnStackPop();  // pop return stack and update instruction address.
 
+    void setElemTraceRange(OcsdTraceElement &elemIn, const instr_range_t &addr_range, const bool executed, ocsd_trc_index_t index);
+
+    ocsd_mem_space_acc_t getCurrMemSpace();
+
 //** intra packet state (see ETMv4 spec 6.2.1);
 
     // timestamping
@@ -105,14 +140,18 @@ class TrcPktDecodeEtmV4I : public TrcPktDecodeBase<Etm
     uint32_t m_vmid_id;                 // most recent VMID
     bool m_is_secure;                   // true if Secure
     bool m_is_64bit;                    // true if 64 bit
+    uint8_t m_last_IS;                  // last instruction set value from address packet.
 
     // cycle counts 
     int m_cc_threshold;
 
-    // speculative trace (unsupported at present in the decoder).
+    // speculative trace 
     int m_curr_spec_depth;                
-    int m_max_spec_depth; 
-    
+    int m_max_spec_depth;   // nax depth - from ID reg, beyond which auto-commit occurs 
+    int m_unseen_spec_elem; // speculative elements at decode start
+
+/** Remove elements that are associated with data trace */
+#ifdef DATA_TRACE_SUPPORTED
     // data trace associative elements (unsupported at present in the decoder).
     int m_p0_key;
     int m_p0_key_max;
@@ -121,6 +160,7 @@ class TrcPktDecodeEtmV4I : public TrcPktDecodeBase<Etm
     int m_cond_c_key;
     int m_cond_r_key;
     int m_cond_key_max_incr;
+#endif
 
     uint8_t m_CSID; //!< Coresight trace ID for this decoder.
 
@@ -134,55 +174,52 @@ class TrcPktDecodeEtmV4I : public TrcPktDecodeBase<Etm
         WAIT_SYNC,      //!< waiting for sync packet.
         WAIT_TINFO,     //!< waiting for trace info packet.
         DECODE_PKTS,    //!< processing packets - creating decode elements on stack
-        COMMIT_ELEM,    //!< commit elements for execution - create generic trace elements and pass on.
+        RESOLVE_ELEM,   //!< analyze / resolve decode elements - create generic trace elements and pass on.
     } processor_state_t;
 
     processor_state_t m_curr_state;
+    unsync_info_t m_unsync_eot_info;   //!< addition info when / why unsync / eot
 
 //** P0 element stack
     EtmV4P0Stack m_P0_stack;    //!< P0 decode element stack
 
-    int m_P0_commit;    //!< number of elements to commit
+    // element resolution
+    struct {
+        int P0_commit;    //!< number of elements to commit
+        int P0_cancel;    //!< elements to cancel
+        bool mispredict;  //!< mispredict latest atom
+        bool discard;     //!< discard elements 
+    } m_elem_res;
 
+    //! true if any of the element resolution fields are non-zero
+    const bool isElemForRes() const {
+        return (m_elem_res.P0_commit || m_elem_res.P0_cancel || 
+            m_elem_res.mispredict || m_elem_res.discard);
+    }
+
+    void clearElemRes() {
+        m_elem_res.P0_commit = 0;
+        m_elem_res.P0_cancel = 0;
+        m_elem_res.mispredict = false;
+        m_elem_res.discard = false;
+    }
+
     // packet decode state
     bool m_need_ctxt;   //!< need context to continue
     bool m_need_addr;   //!< need an address to continue
-    bool m_except_pending_addr;    //!< next address packet is part of exception.
+    bool m_elem_pending_addr;    //!< next address packet is needed for prev element.
 
-    // exception packet processing state (may need excep elem only, range+excep, range+
-    typedef enum {
-        EXCEP_POP, // start of processing read exception packets off the stack and analyze
-        EXCEP_RANGE, // output a range element
-        EXCEP_NACC,  // output a nacc element
-        EXCEP_CTXT,  // output a ctxt element
-        EXCEP_EXCEP, // output an ecxeption element.
-    } excep_proc_state_t;
-
-    struct {
-        excep_proc_state_t proc;    //!< state of exception processing
-        etmv4_addr_val_t addr;      //!< excetion return address.
-        uint32_t number;            //!< exception number.
-        ocsd_trc_index_t index;     //!< trace index for exception element
-        bool addr_b_tgt;            //!< return address is also branch tgt address.
-    } m_excep_info; //!< exception info when processing exception packets
-
     ocsd_instr_info m_instr_info;  //!< instruction info for code follower - in address is the next to be decoded.
 
-    bool m_mem_nacc_pending;    //!< need to output a memory access failure packet
-    ocsd_vaddr_t m_nacc_addr;  //!< record unaccessible address 
-
-    ocsd_pe_context m_pe_context;  //!< current context information
     etmv4_trace_info_t m_trace_info; //!< trace info for this trace run.
 
     bool m_prev_overflow;
 
-    bool m_flush_EOT;           //!< true if doing an end of trace flush - cleans up lingering events / TS / CC
+    TrcAddrReturnStack m_return_stack;  //!< the address return stack.
 
-    TrcAddrReturnStack m_return_stack;
-
-//** output element
-    OcsdTraceElement m_output_elem;
-
+//** output element handling
+    OcsdGenElemStack m_out_elem;  //!< output element stack.
+    OcsdTraceElement &outElem() { return m_out_elem.getCurrElem(); };   //!< current  out element
 };
 
 #endif // ARM_TRC_PKT_DECODE_ETMV4I_H_INCLUDED

Modified: head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4i.h
==============================================================================
--- head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4i.h	Wed Jun 17 10:41:01 2020	(r362262)
+++ head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4i.h	Wed Jun 17 10:42:20 2020	(r362263)
@@ -57,14 +57,7 @@ class Etmv4PktAddrStack
 public:
     Etmv4PktAddrStack()
     {
-        for (int i = 0; i < 3; i++)
-        {
-            m_v_addr[i].pkt_bits = 0;
-            m_v_addr[i].size = VA_64BIT;
-            m_v_addr[i].val = 0;
-            m_v_addr[i].valid_bits = 0;
-            m_v_addr_ISA[i] = 0;
-        }
+        reset_stack();
     }
     ~Etmv4PktAddrStack() {};
 
@@ -87,6 +80,20 @@ class Etmv4PktAddrStack
         }
     }
 
+    // explicit reset for TInfo.
+    void reset_stack()
+    {
+        for (int i = 0; i < 3; i++)
+        {
+            m_v_addr[i].pkt_bits = 0;
+            m_v_addr[i].size = OCSD_MAX_VA_BITSIZE == 64 ? VA_64BIT : VA_32BIT;
+            m_v_addr[i].val = 0;
+            m_v_addr[i].valid_bits = OCSD_MAX_VA_BITSIZE;
+            m_v_addr_ISA[i] = 0;
+        }
+
+    }
+
 private:
     ocsd_pkt_vaddr m_v_addr[3];         //!< most recently broadcast address packet
     uint8_t        m_v_addr_ISA[3];
@@ -172,6 +179,7 @@ class EtmV4ITrcPacket :  public TrcPacketBase, public 
 
     // atom
     const ocsd_pkt_atom &getAtom() const { return atom; };
+    const int getNumAtoms() const { return atom.num; };
 
     // context
     const etmv4_context_t &getContext() const { return context; };
@@ -188,6 +196,10 @@ class EtmV4ITrcPacket :  public TrcPacketBase, public 
     // cc
     const uint32_t getCC() const { return pkt_valid.bits.cc_valid ? cycle_count : 0; };
 
+    // speculation
+    const int getCommitElem() const { return commit_elements; };
+    const int getCancelElem() const { return cancel_elements; };
+
     // packet type
     const bool isBadPacket() const;
 
@@ -227,6 +239,10 @@ inline void EtmV4ITrcPacket::clearTraceInfo()
     // set these as defaults - if they don't appear in TINFO this is the state.
     setTraceInfo(0);        
     setTraceInfoSpec(0);   
+
+    // explicitly reset the stack & zero the current address. 
+    m_addr_stack.reset_stack();
+    m_addr_stack.get_idx(0, v_addr, v_addr_ISA);
 }
 
 inline void EtmV4ITrcPacket::setTraceInfo(const uint32_t infoVal)
@@ -450,17 +466,17 @@ inline void EtmV4ITrcPacket::set32BitAddress(const uin
 	if (pkt_valid.bits.context_valid && context.SF)
 	{
 		v_addr.size = VA_64BIT;

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-head mailing list