From owner-svn-src-all@freebsd.org Wed Jun 17 10:42:24 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AFBFB34A7E8; Wed, 17 Jun 2020 10:42:24 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49n1q44VBRz4bbv; Wed, 17 Jun 2020 10:42:24 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7AD961EEDE; Wed, 17 Jun 2020 10:42:24 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 05HAgOwZ083701; Wed, 17 Jun 2020 10:42:24 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 05HAgKkO083681; Wed, 17 Jun 2020 10:42:20 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <202006171042.05HAgKkO083681@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Wed, 17 Jun 2020 10:42:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: 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... X-SVN-Group: head X-SVN-Commit-Author: andrew X-SVN-Commit-Paths: 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/opencsd/decoder/include/... X-SVN-Commit-Revision: 362263 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jun 2020 10:42:24 -0000 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::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 *pProcBase = dynamic_cast< TrcPktProcBase *>(pkt_proc); if(pProcBase == 0) @@ -132,6 +135,9 @@ ocsd_err_t DecoderMngrBase::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 *pBase = dynamic_cast< TrcPktDecodeBase *>(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 *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 *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 *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 #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 core_profiles; + std::map 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::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 + +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 *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 *pkt; + +}; + +// init the buffer +inline void TraceRawBuffer::init(const uint32_t size, const uint8_t *rawtrace, std::vector *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 +/* 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 m_P0_stack; //!< P0 decode element stack std::vector m_popped_elem; //!< save list of popped but not deleted elements. - + std::deque::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