svn commit: r353393 - in head: contrib/opencsd/decoder/include/common contrib/opencsd/decoder/include/i_dec contrib/opencsd/decoder/include/interfaces contrib/opencsd/decoder/include/mem_acc contri...

Ruslan Bukin br at FreeBSD.org
Thu Oct 10 13:30:18 UTC 2019


Author: br
Date: Thu Oct 10 13:30:13 2019
New Revision: 353393
URL: https://svnweb.freebsd.org/changeset/base/353393

Log:
  Update ARM CoreSight trace decoder library.
  
  Its latest version merged from:
  ^/vendor/opencsd/a1961c91b02a92f3c6ed8b145c636ac4c5565aca
  
  Sponsored by:	DARPA, AFRL

Added:
  head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_cache.h   (contents, props changed)
  head/contrib/opencsd/decoder/include/opencsd/ocsd_if_version.h   (contents, props changed)
  head/contrib/opencsd/decoder/source/mem_acc/trc_mem_acc_cache.cpp   (contents, props changed)
Modified:
  head/contrib/opencsd/decoder/include/common/ocsd_code_follower.h
  head/contrib/opencsd/decoder/include/common/ocsd_dcd_tree.h
  head/contrib/opencsd/decoder/include/common/ocsd_error_logger.h
  head/contrib/opencsd/decoder/include/common/ocsd_msg_logger.h
  head/contrib/opencsd/decoder/include/common/trc_gen_elem.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/interfaces/trc_error_log_i.h
  head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_base.h
  head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_bufptr.h
  head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_cb.h
  head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_file.h
  head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_mapper.h
  head/contrib/opencsd/decoder/include/opencsd/c_api/ocsd_c_api_types.h
  head/contrib/opencsd/decoder/include/opencsd/c_api/opencsd_c_api.h
  head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_cmp_cfg_etmv4.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_types_etmv4.h
  head/contrib/opencsd/decoder/include/opencsd/ocsd_if_types.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/c_api/ocsd_c_api.cpp
  head/contrib/opencsd/decoder/source/etmv3/trc_pkt_decode_etmv3.cpp
  head/contrib/opencsd/decoder/source/etmv4/trc_cmp_cfg_etmv4.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/etmv4/trc_pkt_proc_etmv4i_impl.cpp
  head/contrib/opencsd/decoder/source/etmv4/trc_pkt_proc_etmv4i_impl.h
  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/mem_acc/trc_mem_acc_cb.cpp
  head/contrib/opencsd/decoder/source/mem_acc/trc_mem_acc_file.cpp
  head/contrib/opencsd/decoder/source/mem_acc/trc_mem_acc_mapper.cpp
  head/contrib/opencsd/decoder/source/ocsd_code_follower.cpp
  head/contrib/opencsd/decoder/source/ocsd_dcd_tree.cpp
  head/contrib/opencsd/decoder/source/ocsd_error.cpp
  head/contrib/opencsd/decoder/source/ocsd_error_logger.cpp
  head/contrib/opencsd/decoder/source/ocsd_version.cpp
  head/contrib/opencsd/decoder/source/ptm/trc_pkt_decode_ptm.cpp
  head/contrib/opencsd/decoder/source/trc_core_arch_map.cpp
  head/contrib/opencsd/decoder/source/trc_frame_deformatter.cpp
  head/contrib/opencsd/decoder/source/trc_gen_elem.cpp
  head/contrib/opencsd/decoder/source/trc_printable_elem.cpp
  head/lib/libopencsd/Makefile

Modified: head/contrib/opencsd/decoder/include/common/ocsd_code_follower.h
==============================================================================
--- head/contrib/opencsd/decoder/include/common/ocsd_code_follower.h	Thu Oct 10 13:23:23 2019	(r353392)
+++ head/contrib/opencsd/decoder/include/common/ocsd_code_follower.h	Thu Oct 10 13:30:13 2019	(r353393)
@@ -95,6 +95,7 @@ class OcsdCodeFollower (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 
@@ -190,6 +191,11 @@ inline const ocsd_instr_type OcsdCodeFollower::getInst
 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

Modified: head/contrib/opencsd/decoder/include/common/ocsd_dcd_tree.h
==============================================================================
--- head/contrib/opencsd/decoder/include/common/ocsd_dcd_tree.h	Thu Oct 10 13:23:23 2019	(r353392)
+++ head/contrib/opencsd/decoder/include/common/ocsd_dcd_tree.h	Thu Oct 10 13:30:13 2019	(r353393)
@@ -313,7 +313,23 @@ class DecodeTree : public ITrcDataIn (public)
      */
     ocsd_err_t addBinFileRegionMemAcc(const ocsd_file_mem_region_t *region_array, const int num_regions, const ocsd_mem_space_acc_t mem_space, const std::string &filepath);
     
+
     /*!
+    * Updates/adds to a memory accessor for a memory block supplied as a one or more memory regions in a binary file.
+    * Region structures are created that describe the memory start address, the offset within the binary file
+    * for that address, and the length of the region. This accessor can be used to point to the code section
+    * in a program file for example.
+    *
+    * @param *region_array : array of valid memory regions in the file.
+    * @param num_regions : number of regions
+    * @param mem_space : Memory space
+    * @param &filepath : Path to the binary data file
+    *
+    * @return ocsd_err_t  : Library error code or OCSD_OK if successful.
+    */    
+    ocsd_err_t updateBinFileRegionMemAcc(const ocsd_file_mem_region_t *region_array, const int num_regions, const ocsd_mem_space_acc_t mem_space, const std::string &filepath);
+
+    /*!
      * This memory accessor allows the client to supply a callback function for the region 
      * defined by the start and end addresses. This can be used to supply a custom memory accessor, 
      * or to directly access memory if the decode is running live on a target system.
@@ -327,7 +343,8 @@ class DecodeTree : public ITrcDataIn (public)
      * @return ocsd_err_t  : Library error code or OCSD_OK if successful.
      */
     ocsd_err_t addCallbackMemAcc(const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address, const ocsd_mem_space_acc_t mem_space, Fn_MemAcc_CB p_cb_func, const void *p_context); 
-    
+    ocsd_err_t addCallbackIDMemAcc(const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address, const ocsd_mem_space_acc_t mem_space, Fn_MemAccID_CB p_cb_func, const void *p_context);
+
     /*!
      * Remove the memory accessor from the map, that begins at the given address, for the memory space provided.
      *
@@ -368,6 +385,9 @@ class DecodeTree : public ITrcDataIn (public)
     ocsd_err_t createDecodeElement(const uint8_t CSID);
     void destroyDecodeElement(const uint8_t CSID);
     void destroyMemAccMapper();
+    ocsd_err_t initCallbackMemAcc(const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address, 
+        const ocsd_mem_space_acc_t mem_space, void *p_cb_func, bool IDfn, const void *p_context);
+
 
     ocsd_dcd_tree_src_t m_dcd_tree_type;
 

Modified: head/contrib/opencsd/decoder/include/common/ocsd_error_logger.h
==============================================================================
--- head/contrib/opencsd/decoder/include/common/ocsd_error_logger.h	Thu Oct 10 13:23:23 2019	(r353392)
+++ head/contrib/opencsd/decoder/include/common/ocsd_error_logger.h	Thu Oct 10 13:30:13 2019	(r353393)
@@ -37,7 +37,7 @@
 
 #include <string>
 #include <vector>
-#include <fstream>
+//#include <fstream>
 
 #include "interfaces/trc_error_log_i.h"
 #include "ocsd_error.h"
@@ -49,7 +49,7 @@ class ocsdDefaultErrorLogger : public ITraceErrorLog (
     ocsdDefaultErrorLogger();
     virtual ~ocsdDefaultErrorLogger();
 
-    bool initErrorLogger(const ocsd_err_severity_t verbosity, bool bCreateOutputLogger = false);
+    bool initErrorLogger(const ocsd_err_severity_t verbosity, bool bCreateOutputLogger = false); //!< Initialise the error logger with a severity filter, optionally create an output logger on stderr.
     
     virtual ocsdMsgLogger *getOutputLogger() { return m_output_logger; };
     virtual void setOutputLogger(ocsdMsgLogger *pLogger);

Modified: head/contrib/opencsd/decoder/include/common/ocsd_msg_logger.h
==============================================================================
--- head/contrib/opencsd/decoder/include/common/ocsd_msg_logger.h	Thu Oct 10 13:23:23 2019	(r353392)
+++ head/contrib/opencsd/decoder/include/common/ocsd_msg_logger.h	Thu Oct 10 13:30:13 2019	(r353393)
@@ -53,23 +53,26 @@ class ocsdMsgLogger  (public)
     ocsdMsgLogger();
     ~ocsdMsgLogger();
 
+    /** Typedef enum providing flags to define the output methods for the message logger.
+    */
     typedef enum {
-        OUT_NONE = 0,
-        OUT_FILE = 1,
-        OUT_STDERR = 2,
-        OUT_STDOUT = 4,
-		OUT_STR_CB = 8	/* output to external string callback interface */
+        OUT_NONE = 0,   /*!< No output from logger*/
+        OUT_FILE = 1,   /*!< Output to file */
+        OUT_STDERR = 2, /*!< Output to stderr */
+        OUT_STDOUT = 4, /*!< Output to stdout */
+		OUT_STR_CB = 8	/*!< output to external string callback interface */
     } output_dest;
 
-    void setLogOpts(int logOpts);
-	const int getLogOpts() const { return m_outFlags; };
+    void setLogOpts(int logOpts); //!< set the output logging flags.
+	const int getLogOpts() const  //! get the current output logging flags value. 
+    { return m_outFlags; };
 	
-	void setLogFileName(const char *fileName);
-	void setStrOutFn(ocsdMsgLogStrOutI *p_IstrOut);
+	void setLogFileName(const char *fileName);  //!< Set the output log filename, and enable logging to file.
+	void setStrOutFn(ocsdMsgLogStrOutI *p_IstrOut); //!< Set the output log string callback and enable logging to callback.
 
-    void LogMsg(const std::string &msg);
+    void LogMsg(const std::string &msg); //!< Log a message to the current set output channels.
 
-    const bool isLogging() const;
+    const bool isLogging() const; //!< true if logging active
 
 private:
     int m_outFlags;

Modified: head/contrib/opencsd/decoder/include/common/trc_gen_elem.h
==============================================================================
--- head/contrib/opencsd/decoder/include/common/trc_gen_elem.h	Thu Oct 10 13:23:23 2019	(r353392)
+++ head/contrib/opencsd/decoder/include/common/trc_gen_elem.h	Thu Oct 10 13:30:13 2019	(r353393)
@@ -73,9 +73,10 @@ class OcsdTraceElement : public trcPrintableElem, publ
 
     void setTraceOnReason(const trace_on_reason_t reason);
 
-    void setAddrRange(const ocsd_vaddr_t  st_addr, const ocsd_vaddr_t en_addr);
-    void setLastInstrInfo(const bool exec, const ocsd_instr_type last_i_type, const ocsd_instr_subtype last_i_subtype);
+    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);
@@ -122,15 +123,17 @@ inline void OcsdTraceElement::setEvent(const event_t e
     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)
+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)
+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;
 }

Modified: head/contrib/opencsd/decoder/include/i_dec/trc_i_decode.h
==============================================================================
--- head/contrib/opencsd/decoder/include/i_dec/trc_i_decode.h	Thu Oct 10 13:23:23 2019	(r353392)
+++ head/contrib/opencsd/decoder/include/i_dec/trc_i_decode.h	Thu Oct 10 13:30:13 2019	(r353393)
@@ -49,6 +49,7 @@ class TrcIDecode : public IInstrDecode   (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);
 };
 
 #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	Thu Oct 10 13:23:23 2019	(r353392)
+++ head/contrib/opencsd/decoder/include/i_dec/trc_idec_arminst.h	Thu Oct 10 13:30:13 2019	(r353393)
@@ -73,7 +73,9 @@ 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);
 
 /*
 Get branch destination for a direct branch.
@@ -83,7 +85,9 @@ int inst_Thumb_branch_destination(uint32_t addr, uint3
 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_branch_and_link(uint32_t inst);
@@ -109,6 +113,10 @@ arm_barrier_t inst_ARM_barrier(uint32_t inst);
 arm_barrier_t inst_Thumb_barrier(uint32_t inst);
 arm_barrier_t inst_A64_barrier(uint32_t inst);
 
+int inst_ARM_wfiwfe(uint32_t inst);
+int inst_Thumb_wfiwfe(uint32_t inst);
+int inst_A64_wfiwfe(uint32_t inst);
+
 /*
 Test whether an instruction is definitely undefined, e.g. because
 allocated to a "permanently UNDEFINED" space (UDF mnemonic).
@@ -124,6 +132,9 @@ 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/interfaces/trc_error_log_i.h
==============================================================================
--- head/contrib/opencsd/decoder/include/interfaces/trc_error_log_i.h	Thu Oct 10 13:23:23 2019	(r353392)
+++ head/contrib/opencsd/decoder/include/interfaces/trc_error_log_i.h	Thu Oct 10 13:30:13 2019	(r353393)
@@ -56,8 +56,8 @@ class ocsdMsgLogger;
 class ITraceErrorLog
 {
 public:
-    ITraceErrorLog() {};    /**< default constructor */
-    virtual ~ITraceErrorLog() {};   /**< default destructor */
+    ITraceErrorLog() {};   
+    virtual ~ITraceErrorLog() {};  
 
     /*!
      * Register a named component error source. Allows the logger to associate errors with components.
@@ -111,7 +111,7 @@ class ITraceErrorLog (public)
      * Get the last error associated with the given Trace source channel ID.
      * returns a pointer to the error or 0 if no errors associated with the ID.
      *
-     * @param chan_id : ID.
+     * @param chan_id : Trace Source Channel ID (CoreSight Trace ID).
      *
      * @return ocsdError *: last error pointer for ID or 0.
      */

Modified: head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_base.h
==============================================================================
--- head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_base.h	Thu Oct 10 13:23:23 2019	(r353392)
+++ head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_base.h	Thu Oct 10 13:30:13 2019	(r353393)
@@ -123,12 +123,13 @@ class TrcMemAccessorBase (public)
      *
      * @param s_address : Start address of the read.
      * @param memSpace  : memory space for this access. 
+     * @param trcID     : Trace ID of trace source.
      * @param reqBytes : Number of bytes required.
      * @param *byteBuffer : Buffer to copy the bytes into.
      *
      * @return uint32_t : Number of bytes read, 0 if s_address out of range, or mem space not accessible.
      */
-    virtual const uint32_t readBytes(const ocsd_vaddr_t s_address, const ocsd_mem_space_acc_t memSpace, const uint32_t reqBytes, uint8_t *byteBuffer) = 0;
+    virtual const uint32_t readBytes(const ocsd_vaddr_t s_address, const ocsd_mem_space_acc_t memSpace, const uint8_t trcID, const uint32_t reqBytes, uint8_t *byteBuffer) = 0;
 
     /*!
      * Validate the address range - ensure addresses aligned, different, st < en etc.

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	Thu Oct 10 13:23:23 2019	(r353392)
+++ head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_bufptr.h	Thu Oct 10 13:30:13 2019	(r353393)
@@ -64,7 +64,7 @@ class TrcMemAccBufPtr: public TrcMemAccessorBase (publ
     virtual ~TrcMemAccBufPtr() {};  /**< default destructor */
 
     /** Memory access override - allow decoder to read bytes from the buffer. */
-    virtual const uint32_t readBytes(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t memSpace, const uint32_t reqBytes, uint8_t *byteBuffer);
+    virtual const uint32_t readBytes(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t memSpace, const uint8_t trcID, const uint32_t reqBytes, uint8_t *byteBuffer);
 
 private:
     const uint8_t *m_p_buffer;  /**< pointer to the memory buffer  */

Added: head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_cache.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_cache.h	Thu Oct 10 13:30:13 2019	(r353393)
@@ -0,0 +1,149 @@
+/*!
+* \file       trc_mem_acc_cache.h
+* \brief      OpenCSD : Memory accessor cache.
+*
+* \copyright  Copyright (c) 2018, 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_MEM_ACC_CACHE_H_INCLUDED
+#define ARM_TRC_MEM_ACC_CACHE_H_INCLUDED
+
+#include <string>
+#include "opencsd/ocsd_if_types.h"
+
+#define MEM_ACC_CACHE_PAGE_SIZE 256
+#define MEM_ACC_CACHE_MRU_SIZE 12
+
+class TrcMemAccessorBase;
+class ITraceErrorLog;
+
+typedef struct cache_block {
+    ocsd_vaddr_t st_addr;
+    uint32_t valid_len;
+    uint8_t data[MEM_ACC_CACHE_PAGE_SIZE];
+} cache_block_t;
+
+// enable define to collect stats for debugging / cache performance tests
+//#define LOG_CACHE_STATS
+
+
+/** class TrcMemAccCache - cache small amounts of data from accessors to speed up decode. */
+class TrcMemAccCache
+{
+public:
+    TrcMemAccCache();
+    ~TrcMemAccCache() {};
+
+    void enableCaching(bool bEnable) { m_bCacheEnabled = bEnable; };
+    void invalidateAll();
+    const bool enabled() const { return m_bCacheEnabled; };
+    const bool enabled_for_size(const uint32_t reqSize) const
+    {
+        return (m_bCacheEnabled && (reqSize <= MEM_ACC_CACHE_PAGE_SIZE));
+    }
+        
+    
+    /** read bytes from cache if possible - load new page if needed, bail out if data not available */
+    ocsd_err_t readBytesFromCache(TrcMemAccessorBase *p_accessor, const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint8_t trcID, uint32_t *numBytes, uint8_t *byteBuffer);
+
+    void setErrorLog(ITraceErrorLog *log);
+    void logAndClearCounts();
+
+private:
+    bool blockInCache(const ocsd_vaddr_t address, const uint32_t reqBytes); // run through each page to look for data.
+    bool blockInPage(const ocsd_vaddr_t address, const uint32_t reqBytes);
+    void logMsg(const std::string &szMsg);
+
+    cache_block_t m_mru[MEM_ACC_CACHE_MRU_SIZE];
+    int m_mru_idx = 0;  // in use index
+    int m_mru_next_new = 0; // next new page at this index.
+    bool m_bCacheEnabled = false;
+
+#ifdef LOG_CACHE_STATS    
+    uint32_t m_hits = 0;
+    uint32_t m_misses = 0;
+    uint32_t m_pages = 0;
+    uint32_t m_hit_rl[MEM_ACC_CACHE_MRU_SIZE];
+    uint32_t m_hit_rl_max[MEM_ACC_CACHE_MRU_SIZE];
+#endif
+    
+    ITraceErrorLog *m_err_log = 0;
+};
+
+inline TrcMemAccCache::TrcMemAccCache()
+{
+    for (int i = 0; i < MEM_ACC_CACHE_MRU_SIZE; i++)
+    {
+        m_mru[i].st_addr = 0;
+        m_mru[i].valid_len = 0;
+#ifdef LOG_CACHE_STATS
+        m_hit_rl[i] = 0;
+        m_hit_rl_max[i] = 0;
+#endif
+    }
+}
+
+inline bool TrcMemAccCache::blockInPage(const ocsd_vaddr_t address, const uint32_t reqBytes)
+{
+    if ((m_mru[m_mru_idx].st_addr <= address) &&
+        m_mru[m_mru_idx].st_addr + m_mru[m_mru_idx].valid_len >= (address + reqBytes))
+        return true;
+    return false;
+}
+
+inline bool TrcMemAccCache::blockInCache(const ocsd_vaddr_t address, const uint32_t reqBytes)
+{
+    int tests = MEM_ACC_CACHE_MRU_SIZE;
+    while (tests)
+    {        
+        if (blockInPage(address, reqBytes))
+            return true; // found address in page
+        tests--;
+        m_mru_idx++;
+        if (m_mru_idx == MEM_ACC_CACHE_MRU_SIZE)
+            m_mru_idx = 0;
+    }
+    return false;
+}
+
+inline void TrcMemAccCache::invalidateAll()
+{
+    for (int i = 0; i < MEM_ACC_CACHE_MRU_SIZE; i++)
+    {
+        m_mru[i].valid_len = 0;
+        m_mru[i].st_addr = 0;
+    }
+    m_mru_idx = 0;
+    m_mru_next_new = 0;
+}
+
+#endif // ARM_TRC_MEM_ACC_CACHE_H_INCLUDED
+
+/* End of File trc_mem_acc_cache.h */

Modified: head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_cb.h
==============================================================================
--- head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_cb.h	Thu Oct 10 13:23:23 2019	(r353392)
+++ head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_cb.h	Thu Oct 10 13:30:13 2019	(r353393)
@@ -49,32 +49,47 @@ class TrcMemAccCB : public TrcMemAccessorBase (public)
     virtual ~TrcMemAccCB() {};
     
     /** Memory access override - allow decoder to read bytes from the buffer. */
-    virtual const uint32_t readBytes(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t memSpace, const uint32_t reqBytes, uint8_t *byteBuffer);
+    virtual const uint32_t readBytes(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t memSpace, const uint8_t trcID, const uint32_t reqBytes, uint8_t *byteBuffer);
     
     void setCBIfClass(TrcMemAccCBIF *p_if);
     void setCBIfFn(Fn_MemAcc_CB p_fn, const void *p_context);
+    void setCBIDIfFn(Fn_MemAccID_CB p_fn, const void *p_context);
 
 private:
+    void clearCBptrs();
     TrcMemAccCBIF *m_p_CBclass;     //<! callback class.
     Fn_MemAcc_CB m_p_CBfn;          //<! callback function.
+    Fn_MemAccID_CB m_p_CBIDfn;       //<! callback with ID function.
     const void *m_p_cbfn_context;   //<! context pointer for callback function.
 };
 
+inline void TrcMemAccCB::clearCBptrs()
+{
+    m_p_CBclass = 0;
+    m_p_CBfn = 0;
+    m_p_CBIDfn = 0;
+    m_p_cbfn_context = 0;
+}
+
 inline void TrcMemAccCB::setCBIfClass(TrcMemAccCBIF *p_if) 
 { 
+    clearCBptrs();   // only one callback type per accessor.
     m_p_CBclass = p_if; 
-    m_p_CBfn = 0;       // only one callback type per accessor.
-    m_p_cbfn_context = 0;
 }
 
 inline void TrcMemAccCB::setCBIfFn(Fn_MemAcc_CB p_fn, const void *p_context) 
 { 
+    clearCBptrs();   // only one callback type per accessor.
     m_p_CBfn = p_fn;
     m_p_cbfn_context = p_context;
-    m_p_CBclass = 0;  // only one callback type per accessor.
 }
 
-
+inline void TrcMemAccCB::setCBIDIfFn(Fn_MemAccID_CB p_fn, const void *p_context)
+{
+    clearCBptrs();   // only one callback type per accessor.
+    m_p_CBIDfn = p_fn;
+    m_p_cbfn_context = p_context;
+}
 
 #endif // ARM_TRC_MEM_ACC_CB_H_INCLUDED
 

Modified: head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_file.h
==============================================================================
--- head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_file.h	Thu Oct 10 13:23:23 2019	(r353392)
+++ head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_file.h	Thu Oct 10 13:30:13 2019	(r353393)
@@ -56,7 +56,7 @@ class FileRegionMemAccessor : public TrcMemAccessorBas
     bool operator<(const FileRegionMemAccessor& rhs) { return this->m_startAddress < rhs.m_startAddress; };
 
     // not going to use these objects to read bytes - defer to the file class for that.
-    virtual const uint32_t readBytes(const ocsd_vaddr_t s_address, const ocsd_mem_space_acc_t memSpace, const uint32_t reqBytes, uint8_t *byteBuffer) { return 0; };
+    virtual const uint32_t readBytes(const ocsd_vaddr_t s_address, const ocsd_mem_space_acc_t memSpace, const uint8_t trcID, const uint32_t reqBytes, uint8_t *byteBuffer) { return 0; };
 
     const ocsd_vaddr_t regionStartAddress() const { return m_startAddress; };
 
@@ -77,7 +77,7 @@ class TrcMemAccessorFile : public TrcMemAccessorBase 
 {
 public:
     /** read bytes override - reads from file */
-    virtual const uint32_t readBytes(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t memSpace, const uint32_t reqBytes, uint8_t *byteBuffer);
+    virtual const uint32_t readBytes(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t memSpace, const uint8_t trcID, const uint32_t reqBytes, uint8_t *byteBuffer);
 
 protected:
     TrcMemAccessorFile();   /**< protected default constructor */

Modified: head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_mapper.h
==============================================================================
--- head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_mapper.h	Thu Oct 10 13:23:23 2019	(r353392)
+++ head/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_mapper.h	Thu Oct 10 13:30:13 2019	(r353393)
@@ -41,6 +41,7 @@
 #include "interfaces/trc_tgt_mem_access_i.h"
 #include "interfaces/trc_error_log_i.h"
 #include "mem_acc/trc_mem_acc_base.h"
+#include "mem_acc/trc_mem_acc_cache.h"
 
 typedef enum _memacc_mapper_t {
     MEMACC_MAP_GLOBAL,
@@ -76,7 +77,7 @@ class TrcMemAccMapper : public ITargetMemAccess (publi
     ocsd_err_t RemoveAccessorByAddress(const ocsd_vaddr_t st_address, const ocsd_mem_space_acc_t mem_space, const uint8_t cs_trace_id = 0);
     
     // set the error log.
-    void setErrorLog(ITraceErrorLog *err_log_i) { m_err_log = err_log_i;  };
+    void setErrorLog(ITraceErrorLog *err_log_i);
 
     // print out the ranges in this mapper.
     virtual void logMappedRanges() = 0;
@@ -89,11 +90,13 @@ class TrcMemAccMapper : public ITargetMemAccess (publi
     virtual void clearAccessorList() = 0;
 
     void LogMessage(const std::string &msg);
+    void LogWarn(const ocsd_err_t err, const std::string &msg);
 
     TrcMemAccessorBase *m_acc_curr;     // most recently used - try this first.
     uint8_t m_trace_id_curr;            // trace ID for the current accessor
     const bool m_using_trace_id;        // true if we are using separate memory spaces by TraceID.
     ITraceErrorLog *m_err_log;          // error log to print out mappings on request.
+    TrcMemAccCache m_cache;             // memory accessor caching.
 };
 
 

Modified: head/contrib/opencsd/decoder/include/opencsd/c_api/ocsd_c_api_types.h
==============================================================================
--- head/contrib/opencsd/decoder/include/opencsd/c_api/ocsd_c_api_types.h	Thu Oct 10 13:23:23 2019	(r353392)
+++ head/contrib/opencsd/decoder/include/opencsd/c_api/ocsd_c_api_types.h	Thu Oct 10 13:30:13 2019	(r353393)
@@ -37,6 +37,7 @@
 
 /* select the library types that are C compatible - the interface data types */
 #include "opencsd/ocsd_if_types.h"
+#include "opencsd/ocsd_if_version.h"
 #include "opencsd/trc_gen_elem_types.h"
 #include "opencsd/trc_pkt_types.h"
 

Modified: head/contrib/opencsd/decoder/include/opencsd/c_api/opencsd_c_api.h
==============================================================================
--- head/contrib/opencsd/decoder/include/opencsd/c_api/opencsd_c_api.h	Thu Oct 10 13:23:23 2019	(r353392)
+++ head/contrib/opencsd/decoder/include/opencsd/c_api/opencsd_c_api.h	Thu Oct 10 13:30:13 2019	(r353393)
@@ -84,7 +84,7 @@
 /** @name Library Version API
 
 @{*/
-/** Get Library version. Return a 32 bit version in form MMMMnnpp - MMMM = major verison, nn = minor version, pp = patch version */ 
+/** Get Library version. Return a 32 bit version in form MMMMnnpp - MMMM = major version, nn = minor version, pp = patch version */
 OCSD_C_API uint32_t ocsd_get_version(void);
 
 /** Get library version string */
@@ -285,6 +285,23 @@ OCSD_C_API ocsd_err_t ocsd_dt_add_buffer_mem_acc(const
  * @return OCSD_C_API ocsd_err_t  : Library error code -  RCDTL_OK if successful.
  */
 OCSD_C_API ocsd_err_t ocsd_dt_add_callback_mem_acc(const dcd_tree_handle_t handle, const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address, const ocsd_mem_space_acc_t mem_space, Fn_MemAcc_CB p_cb_func, const void *p_context); 
+
+
+/*!
+ * Add a memory access callback function. The decoder will call the function for opcode addresses in the 
+ * address range supplied for the memory spaces covered.
+ *
+ * @param handle : Handle to decode tree.
+ * @param st_address :  Start address of memory area covered by the callback.
+ * @param en_address :  End address of the memory area covered by the callback. (inclusive)
+ * @param mem_space : Memory space(s) covered by the callback.
+ * @param p_cb_func : Callback function - Signature for CB with Trace ID passed to client.
+ * @param p_context : opaque context pointer value used in callback function.
+ *
+ * @return OCSD_C_API ocsd_err_t  : Library error code -  RCDTL_OK if successful.
+ */
+OCSD_C_API ocsd_err_t ocsd_dt_add_callback_trcid_mem_acc(const dcd_tree_handle_t handle, const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address, const ocsd_mem_space_acc_t mem_space, Fn_MemAccID_CB p_cb_func, const void *p_context);
+
 
 /*!
  * Remove a memory accessor by address and memory space.

Modified: head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_cmp_cfg_etmv4.h
==============================================================================
--- head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_cmp_cfg_etmv4.h	Thu Oct 10 13:23:23 2019	(r353392)
+++ head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_cmp_cfg_etmv4.h	Thu Oct 10 13:30:13 2019	(r353393)
@@ -108,6 +108,7 @@ class EtmV4Config : public CSConfig // public ocsd_etm
     /* idr 1 */
     const uint8_t MajVersion() const;
     const uint8_t MinVersion() const;
+    const uint8_t FullVersion() const;
     
     /* idr 2 */
     const uint32_t iaSizeMax() const;
@@ -117,6 +118,7 @@ class EtmV4Config : public CSConfig // public ocsd_etm
     const uint32_t dvSize() const;
     const uint32_t ccSize() const;
     const bool vmidOpt() const;
+    const bool wfiwfeBranch() const;
 
     /* id regs 8-13*/
     const uint32_t MaxSpecDepth() const;
@@ -180,7 +182,11 @@ class EtmV4Config : public CSConfig // public ocsd_etm
     bool m_condTraceCalc;
     CondITrace_t m_CondTrace;
 
+protected:
     ocsd_etmv4_cfg m_cfg;
+    uint8_t m_MajVer;
+    uint8_t m_MinVer;
+
 };
 
 /* idr 0 */
@@ -265,14 +271,18 @@ inline const bool EtmV4Config::commitOpt1() const
     /* idr 1 */
 inline const uint8_t EtmV4Config::MajVersion() const
 {
-    return (uint8_t)((m_cfg.reg_idr1 >> 8) & 0xF);
+    return m_MajVer;
 }
 
 inline const uint8_t EtmV4Config::MinVersion() const
 {
-    return (uint8_t)((m_cfg.reg_idr1 >> 4) & 0xF);
+    return m_MinVer;
 }
 
+inline const uint8_t EtmV4Config::FullVersion() const
+{
+    return (m_MajVer << 4) | m_MinVer;
+}
 
 /* idr 2 */
 inline const uint32_t EtmV4Config::iaSizeMax() const
@@ -319,6 +329,12 @@ inline const bool EtmV4Config::vmidOpt() const
 {
     return (bool)((m_cfg.reg_idr2 & 0x20000000) == 0x20000000) && (MinVersion() > 0);
 }
+
+inline const bool EtmV4Config::wfiwfeBranch() const
+{
+    return (bool)((m_cfg.reg_idr2 & 0x80000000) && (FullVersion() >= 0x43));
+}
+
 
 /* id regs 8-13*/
 

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	Thu Oct 10 13:23:23 2019	(r353392)
+++ head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_etmv4_stack_elem.h	Thu Oct 10 13:30:13 2019	(r353393)
@@ -56,7 +56,8 @@ typedef enum _p0_elem_t 
     P0_TS,
     P0_CC,
     P0_TS_CC,
-    P0_OVERFLOW
+    P0_OVERFLOW,
+    P0_FUNC_RET,
 } p0_elem_t;
 
 
@@ -250,6 +251,7 @@ class EtmV4P0Stack (public)
     ~EtmV4P0Stack();
 
     void push_front(TrcStackElem *pElem);
+    void push_back(TrcStackElem *pElem);        // insert element when processing
     void pop_back();
     TrcStackElem *back();
     size_t size();
@@ -260,7 +262,7 @@ class EtmV4P0Stack (public)
 
     // creation functions - create and push if successful.
     TrcStackElemParam *createParamElem(const p0_elem_t p0_type, const bool isP0, const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, const std::vector<uint32_t> &params);
-    TrcStackElemParam *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);
+    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);
@@ -282,6 +284,12 @@ inline EtmV4P0Stack::~EtmV4P0Stack()
 inline void EtmV4P0Stack::push_front(TrcStackElem *pElem)
 {
     m_P0_stack.push_front(pElem);
+}
+
+// put an element on the back of the stack
+inline void EtmV4P0Stack::push_back(TrcStackElem *pElem)
+{
+    m_P0_stack.push_back(pElem);
 }
 
 // pop last element pointer off the stack and stash it for later deletion

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	Thu Oct 10 13:23:23 2019	(r353392)
+++ head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h	Thu Oct 10 13:30:13 2019	(r353393)
@@ -93,6 +93,8 @@ class TrcPktDecodeEtmV4I : public TrcPktDecodeBase<Etm
 
     ocsd_datapath_resp_t returnStackPop();  // pop return stack and update instruction address.
 
+    ocsd_datapath_resp_t outputTraceRange(const bool executed, ocsd_trc_index_t index);
+
 //** intra packet state (see ETMv4 spec 6.2.1);
 
     // timestamping
@@ -152,12 +154,17 @@ class TrcPktDecodeEtmV4I : public TrcPktDecodeBase<Etm
         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;
 
-    excep_proc_state_t m_excep_proc;  //!< state of exception processing
-    etmv4_addr_val_t m_excep_addr;    //!< excepiton return address.
-    ocsd_trc_index_t m_excep_index;  //!< trace index for exception element
+    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.
 

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	Thu Oct 10 13:23:23 2019	(r353392)
+++ head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4i.h	Thu Oct 10 13:30:13 2019	(r353393)
@@ -115,7 +115,7 @@ class EtmV4ITrcPacket :  public TrcPacketBase, public 
     void initNextPacket();  //!< clear any single packet only flags / state.
 
     void setType(const ocsd_etmv4_i_pkt_type pkt_type) { type = pkt_type; };
-    void updateErrType(const ocsd_etmv4_i_pkt_type err_pkt_type);
+    void updateErrType(const ocsd_etmv4_i_pkt_type err_pkt_type, const uint8_t val = 0);
 
     void clearTraceInfo();  //!< clear all the trace info data prior to setting for new trace info packet.
     void setTraceInfo(const uint32_t infoVal);
@@ -208,11 +208,12 @@ class EtmV4ITrcPacket :  public TrcPacketBase, public 
     Etmv4PktAddrStack m_addr_stack;
 };
 
-inline void  EtmV4ITrcPacket::updateErrType(const ocsd_etmv4_i_pkt_type err_pkt_type)
+inline void  EtmV4ITrcPacket::updateErrType(const ocsd_etmv4_i_pkt_type err_pkt_type, const uint8_t err_val /* = 0 */)
 {
     // set primary type to incoming error type, set packet err type to previous primary type.
     err_type = type;
     type = err_pkt_type;
+    err_hdr_val = err_val;
 }
 
 inline void EtmV4ITrcPacket::clearTraceInfo()
@@ -223,7 +224,9 @@ inline void EtmV4ITrcPacket::clearTraceInfo()
     pkt_valid.bits.spec_depth_valid = 0;
     pkt_valid.bits.cc_thresh_valid  = 0;
 
-    pkt_valid.bits.ts_valid = 0;    // mark TS as invalid - must be re-updated after trace info.
+    // set these as defaults - if they don't appear in TINFO this is the state.
+    setTraceInfo(0);        
+    setTraceInfoSpec(0);   
 }
 
 inline void EtmV4ITrcPacket::setTraceInfo(const uint32_t infoVal)
@@ -444,18 +447,20 @@ inline void EtmV4ITrcPacket::set32BitAddress(const uin
     uint64_t mask = OCSD_BIT_MASK(32);
     v_addr.pkt_bits = 32;
 
-    if (pkt_valid.bits.context_valid && context.SF)
-        v_addr.size = VA_64BIT;
+	if (pkt_valid.bits.context_valid && context.SF)
+	{
+		v_addr.size = VA_64BIT;
+		if (v_addr.valid_bits < 32) // may be updating a 64 bit address so only set 32 if currently less.
+			v_addr.valid_bits = 32;
+		v_addr.val = (v_addr.val & ~mask) | (addr & mask);
+	}
     else
     {
-        v_addr.val &= 0xFFFFFFFF;   // ensure vaddr is only 32 bits if not 64 bit 
+		v_addr.val = addr;
         v_addr.size = VA_32BIT;
-    }
-
-    if (v_addr.valid_bits < 32) // may be 64 bit address so only set 32 if less
-        v_addr.valid_bits = 32;
-
-    v_addr.val = (v_addr.val & ~mask) | (addr & mask);
+		v_addr.valid_bits = 32;
+	}
+	    
     v_addr_ISA = IS;
     push_vaddr();
 }

Modified: head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_types_etmv4.h
==============================================================================
--- head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_types_etmv4.h	Thu Oct 10 13:23:23 2019	(r353392)
+++ head/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_types_etmv4.h	Thu Oct 10 13:30:13 2019	(r353393)
@@ -1,8 +1,8 @@
 /*
  * \file       trc_pkt_types_etmv4.h
- * \brief      OpenCSD : 
+ * \brief      OpenCSD : ETMv4 packet info
  * 
- * \copyright  Copyright (c) 2015, ARM Limited. All Rights Reserved.
+ * \copyright  Copyright (c) 2015,2019 ARM Limited. All Rights Reserved.
  */
 
 
@@ -56,80 +56,95 @@ typedef enum _ocsd_etmv4_i_pkt_type
 		ETM4_PKT_I_BAD_SEQUENCE = 0x300,        /*!< invalid sequence for packet type. */
         ETM4_PKT_I_BAD_TRACEMODE,               /*!< invalid packet type for this trace mode. */
 		ETM4_PKT_I_RESERVED,                    /*!< packet type reserved. */
+        ETM4_PKT_I_RESERVED_CFG,                /*!< packet type reserved for current configuration */
 
 /* I stream packet types. */
     /* extension header. */
-        ETM4_PKT_I_EXTENSION = 0x00,            /*!< b00000000  */
+        ETM4_PKT_I_EXTENSION =          0x00,   /*!< b00000000  */
 
-    /* address amd context */
-        ETM4_PKT_I_ADDR_CTXT_L_32IS0 = 0x82,    /*!< b10000010  */
+   /* sync */    
+        ETM4_PKT_I_TRACE_INFO =         0x01,   /*!< b00000001 */
+        // timestamp
+        ETM4_PKT_I_TIMESTAMP =          0x02,   /*!< b0000001x */
+        ETM4_PKT_I_TRACE_ON =           0x04,   /*!< b00000100 */
+        ETM4_PKT_I_FUNC_RET =           0x05,   /*!< b00000101 (V8M only) */
+    // Exceptions
+        ETM4_PKT_I_EXCEPT =             0x06,   /*!< b00000110 */
+        ETM4_PKT_I_EXCEPT_RTN =         0x07,   /*!< b00000111 */
+
+        /* unused encodings             0x08-0xB     b00001000 to b00001011 */
+
+    /* cycle count packets */
+        ETM4_PKT_I_CCNT_F2 =            0x0C,   /*!< b0000110x */
+        ETM4_PKT_I_CCNT_F1 =            0x0E,   /*!< b0000111x */
+        ETM4_PKT_I_CCNT_F3 =            0x10,   /*!< b0001xxxx */
+
+    // data synchronisation markers
+        ETM4_PKT_I_NUM_DS_MKR =         0x20,   /*!< b00100xxx */
+        ETM4_PKT_I_UNNUM_DS_MKR =       0x28,   /*!< b00101000 to b00101100 0x2C */
+
+    // speculation 
+        ETM4_PKT_I_COMMIT =             0x2D,   /*!< b00101101 */
+        ETM4_PKT_I_CANCEL_F1 =          0x2E,   /*!< b0010111x */
+        ETM4_PKT_I_MISPREDICT =         0x30,   /*!< b001100xx */
+        ETM4_PKT_I_CANCEL_F2 =          0x34,   /*!< b001101xx */
+        ETM4_PKT_I_CANCEL_F3 =          0x38,   /*!< b00111xxx */
+
+    /* conditional instruction tracing */
+        ETM4_PKT_I_COND_I_F2 =          0x40,   /*!< b01000000 - b01000010 */
+        ETM4_PKT_I_COND_FLUSH =         0x43,   /*!< b01000011 */
+        ETM4_PKT_I_COND_RES_F4 =        0x44,   /*!< b0100010x, b01000110 */
+        /* unused encoding              0x47         b01000111 */
+        ETM4_PKT_I_COND_RES_F2 =        0x48,   /*!< b0100100x, b01001010, b0100110x, b01001110 */
+        /* unused encodings             0x4B,0x4F    b01001011, b01001111 */
+        ETM4_PKT_I_COND_RES_F3 =        0x50,   /*!< b0101xxxx */
+        /* unused encodings             0x60-0x67    b01100xxx */     
+        ETM4_PKT_I_COND_RES_F1 =        0x68,   /*!< b011010xx, b0110111x  0x68-0x6B, 0x6e-0x6F */
+        ETM4_PKT_I_COND_I_F1 =          0x6C,   /*!< b01101100 */
+        ETM4_PKT_I_COND_I_F3 =          0x6D,   /*!< b01101101 */
+
+        // event trace
+        ETM4_PKT_I_IGNORE =             0x70,   /*!< b01110000 */
+        ETM4_PKT_I_EVENT =              0x71,   /*!< b01110001 to 0x01111111 0x7F */
+
+    /* address and context */
+        ETM4_PKT_I_CTXT =               0x80,   /*!< b1000000x  */
+        ETM4_PKT_I_ADDR_CTXT_L_32IS0 =  0x82,   /*!< b10000010  */
         ETM4_PKT_I_ADDR_CTXT_L_32IS1,           /*!< b10000011  */
-        /* unused encoding                           b10000100  */
-        ETM4_PKT_I_ADDR_CTXT_L_64IS0 = 0x85,    /*!< b10000101  */
+        /* unused encoding              0x84         b10000100  */
+        ETM4_PKT_I_ADDR_CTXT_L_64IS0 =  0x85,   /*!< b10000101  */
         ETM4_PKT_I_ADDR_CTXT_L_64IS1,           /*!< b10000110  */
-        /* unused encoding                           b10000111  */
-        ETM4_PKT_I_CTXT = 0x80,                 /*!< b1000000x  */
-        ETM4_PKT_I_ADDR_MATCH = 0x90,           /*!< b10010000 to b10010010 */
-        ETM4_PKT_I_ADDR_L_32IS0 = 0x9A,         /*!< b10011010  */
+        /* unused encoding              0x87         b10000111  */
+        /* unused encodings             0x88-0x8F    b10001xxx  */
+        ETM4_PKT_I_ADDR_MATCH =         0x90,   /*!< b10010000 to b10010010 0x92 */
+        /* unused encodings             0x93-0x94    b10010011 to b10010010 */
+        ETM4_PKT_I_ADDR_S_IS0 =         0x95,   /*!< b10010101  */
+        ETM4_PKT_I_ADDR_S_IS1,                  /*!< b10010110  */
+        /* unused encodings             0x97         b10010111 to b10011001 0x99 */
+        ETM4_PKT_I_ADDR_L_32IS0 =       0x9A,   /*!< b10011010  */
         ETM4_PKT_I_ADDR_L_32IS1,                /*!< b10011011  */
-        /* unused encoding                           b10011100  */
-        ETM4_PKT_I_ADDR_L_64IS0 = 0x9D,         /*!< b10011101  */
+        /* unused encoding              0x9C         b10011100  */
+        ETM4_PKT_I_ADDR_L_64IS0 =       0x9D,   /*!< b10011101  */
         ETM4_PKT_I_ADDR_L_64IS1,                /*!< b10011110  */
-        /* unused encoding                           b10011111  */
-        ETM4_PKT_I_ADDR_S_IS0 = 0x95,           /*!< b10010101  */
-        ETM4_PKT_I_ADDR_S_IS1,                  /*!< b10010110  */
-        /* unused encoding                           b10010111  
-           unused encoding                           b10011000
-           unused encoding                           b10011001 */
+        /* unused encoding              0x9F         b10011111  */
 
     /* Q packets */
         ETM4_PKT_I_Q = 0xA0,                    /*!< b1010xxxx  */
 
+        /* unused encodings             0xB0-0xBF    b1011xxxx  */
+
     /* Atom packets */
-        ETM4_PKT_I_ATOM_F1 = 0xF6,              /*!< b1111011x */
-        ETM4_PKT_I_ATOM_F2 = 0xD8,              /*!< b110110xx */
-        ETM4_PKT_I_ATOM_F3 = 0xF8,              //!< b11111xxx
-        ETM4_PKT_I_ATOM_F4 = 0xDC,              //!< b110111xx
-        ETM4_PKT_I_ATOM_F5 = 0xD5,              //!< b11010101 - b11010111, b11110101
-        ETM4_PKT_I_ATOM_F6 = 0xC0,              //!< b11000000 - b11010100, b11100000 - b11110100
+        ETM4_PKT_I_ATOM_F6 =            0xC0,   /*!< b11000000 - b11010100 0xC0 - 0xD4, b11100000 - b11110100 0xE0 - 0xF4 */
+        ETM4_PKT_I_ATOM_F5 =            0xD5,   /*!< b11010101 - b11010111 0xD5 - 0xD7, b11110101 0xF5 */
+        ETM4_PKT_I_ATOM_F2 =            0xD8,   /*!< b110110xx to 0xDB */
+        ETM4_PKT_I_ATOM_F4 =            0xDC,   /*!< b110111xx to 0xDF */
+        ETM4_PKT_I_ATOM_F1 =            0xF6,   /*!< b1111011x to 0xF7 */
+        ETM4_PKT_I_ATOM_F3 =            0xF8,   /*!< b11111xxx to 0xFF */
 
-    /* conditional instruction tracing */
-        ETM4_PKT_I_COND_FLUSH = 0x43,           //!< b01000011
-        ETM4_PKT_I_COND_I_F1 = 0x6C,            //!< b01101100
-        ETM4_PKT_I_COND_I_F2 = 0x40,            //!< b01000000 - b01000010
-        ETM4_PKT_I_COND_I_F3 = 0x6D,            //!< b01101101
-        ETM4_PKT_I_COND_RES_F1 = 0x68,          //!< b0110111x, b011010xx
-        ETM4_PKT_I_COND_RES_F2 = 0x48,          //!< b0100100x, b01001010, b0100110x, b01001110 
-        ETM4_PKT_I_COND_RES_F3 = 0x50,          //!< b0101xxxx
-        ETM4_PKT_I_COND_RES_F4 = 0x44,          //!< b0100010x, b01000110
-
-    /* cycle count packets */
-        ETM4_PKT_I_CCNT_F1 = 0x0E,             //!< b0000111x
-        ETM4_PKT_I_CCNT_F2 = 0x0C,             //!< b0000110x
-        ETM4_PKT_I_CCNT_F3 = 0x10,             //!< b0001xxxx
-    // data synchronisation markers
-        ETM4_PKT_I_NUM_DS_MKR = 0x20,          //!< b00100xxx
-        ETM4_PKT_I_UNNUM_DS_MKR = 0x28,        //!< b00101000 - b00101100
-    // event trace
-        ETM4_PKT_I_EVENT = 0x70,               //!< b0111xxxx
-    // Exceptions
-        ETM4_PKT_I_EXCEPT = 0x06,              //!< b00000110
-        ETM4_PKT_I_EXCEPT_RTN = 0x07,          //!< b00000111
-    // timestamp
-        ETM4_PKT_I_TIMESTAMP = 0x02,           //!< b0000001x
-    // speculation 
-        ETM4_PKT_I_CANCEL_F1 = 0x2E,           //!< b0010111x
-        ETM4_PKT_I_CANCEL_F2 = 0x34,           //!< b001101xx
-        ETM4_PKT_I_CANCEL_F3 = 0x38,           //!< b00111xxx
-        ETM4_PKT_I_COMMIT = 0x2D,              //!< b00101101
-        ETM4_PKT_I_MISPREDICT = 0x30,          //!< b001100xx
-    // Sync
-        ETM4_PKT_I_TRACE_INFO = 0x01,          //!< b00000001
-        ETM4_PKT_I_TRACE_ON = 0x04,            //!< b00000100    
     // extension packets - follow 0x00 header
         ETM4_PKT_I_ASYNC = 0x100,              //!< b00000000
         ETM4_PKT_I_DISCARD = 0x103,            //!< b00000011
-        ETM4_PKT_I_OVERFLOW = 0x105            //!< b00000101
+        ETM4_PKT_I_OVERFLOW = 0x105,           //!< b00000101
 
 } ocsd_etmv4_i_pkt_type;
 
@@ -139,7 +154,7 @@ typedef union _etmv4_trace_info_t {
         uint32_t cc_enabled:1;      //!< 1 if cycle count enabled
         uint32_t cond_enabled:3;    //!< conditional trace enabeld type
         uint32_t p0_load:1;         //!< 1 if tracing with P0 load elements (for data trace)
-        uint32_t p0_store:1;        //1< 1 if tracing with P0 store elements (for data trace)
+        uint32_t p0_store:1;        //!< 1 if tracing with P0 store elements (for data trace)
     } bits;         //!< bitfields for trace info value.
 } etmv4_trace_info_t;
 
@@ -259,6 +274,7 @@ typedef struct _ocsd_etmv4_i_pkt
 
     // original header type when packet type changed to error on decode error.
     ocsd_etmv4_i_pkt_type err_type;
+    uint8_t err_hdr_val;
 
 } ocsd_etmv4_i_pkt;
 
@@ -341,6 +357,7 @@ typedef struct _ocsd_etmv4_cfg 
     ocsd_arch_version_t    arch_ver;   /**< Architecture version */
     ocsd_core_profile_t    core_prof;  /**< Core Profile */
 } ocsd_etmv4_cfg;
+
 
 /** @}*/
 /** @}*/

Modified: head/contrib/opencsd/decoder/include/opencsd/ocsd_if_types.h
==============================================================================
--- head/contrib/opencsd/decoder/include/opencsd/ocsd_if_types.h	Thu Oct 10 13:23:23 2019	(r353392)
+++ head/contrib/opencsd/decoder/include/opencsd/ocsd_if_types.h	Thu Oct 10 13:30:13 2019	(r353393)
@@ -107,6 +107,7 @@ typedef enum _ocsd_err_t {
     OCSD_ERR_DATA_DECODE_FATAL,    /**< A decoder in the data path has returned a fatal error. */
     /* frame deformatter errors */
     OCSD_ERR_DFMTR_NOTCONTTRACE,    /**< Trace input to deformatter none-continuous */
+    OCSD_ERR_DFMTR_BAD_FHSYNC,      /**< Bad frame or half frame sync in trace deformatter */
     /* packet processor errors - protocol issues etc */
     OCSD_ERR_BAD_PACKET_SEQ,        /**< Bad packet sequence */
     OCSD_ERR_INVALID_PCKT_HDR,      /**< Invalid packet header */
@@ -126,6 +127,7 @@ typedef enum _ocsd_err_t {
     OCSD_ERR_MEM_ACC_FILE_NOT_FOUND,    /**< Memory access file could not be opened */
     OCSD_ERR_MEM_ACC_FILE_DIFF_RANGE,   /**< Attempt to re-use the same memory access file for a different address range */
     OCSD_ERR_MEM_ACC_RANGE_INVALID,     /**< Address range in accessor set to invalid values */
+    OCSD_ERR_MEM_ACC_BAD_LEN,           /**< Memory accessor returned a bad read length value (larger than requested */
     /* test errors - errors generated only by the test code, not the library */
     OCSD_ERR_TEST_SNAPSHOT_PARSE,       /**< test snapshot file parse error */
     OCSD_ERR_TEST_SNAPSHOT_PARSE_INFO,  /**< test snapshot file parse information */
@@ -137,7 +139,7 @@ typedef enum _ocsd_err_t {
     OCSD_ERR_DCDREG_TYPE_UNKNOWN,       /**< attempted to find a decoder with a type that is not known in the library */
     OCSD_ERR_DCDREG_TOOMANY,            /**< attempted to register too many custom decoders */
     /* decoder config */
-    OCSD_ERR_DCD_INTERFACE_UNUSED,      /**< Attempt to connect or use and inteface not supported by this decoder. */
+    OCSD_ERR_DCD_INTERFACE_UNUSED,      /**< Attempt to connect or use and interface not supported by this decoder. */
     /* end marker*/
     OCSD_ERR_LAST
 } ocsd_err_t;
@@ -272,11 +274,16 @@ typedef enum _ocsd_dcd_tree_src_t {
 /** Core Architecture Version */
 typedef enum _ocsd_arch_version {
     ARCH_UNKNOWN,   /**< unknown architecture */
+    ARCH_CUSTOM,    /**< None ARM, custom architecture */
     ARCH_V7,        /**< V7 architecture */
     ARCH_V8,        /**< V8 architecture */

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


More information about the svn-src-head mailing list