1/* 2* \file trc_etmv4_stack_elem.cpp 3* \brief OpenCSD : ETMv4 decoder 4* 5* \copyright Copyright (c) 2017, ARM Limited. All Rights Reserved. 6*/ 7 8 9/* 10* Redistribution and use in source and binary forms, with or without modification, 11* are permitted provided that the following conditions are met: 12* 13* 1. Redistributions of source code must retain the above copyright notice, 14* this list of conditions and the following disclaimer. 15* 16* 2. Redistributions in binary form must reproduce the above copyright notice, 17* this list of conditions and the following disclaimer in the documentation 18* and/or other materials provided with the distribution. 19* 20* 3. Neither the name of the copyright holder nor the names of its contributors 21* may be used to endorse or promote products derived from this software without 22* specific prior written permission. 23* 24* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND 25* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 27* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 31* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34*/ 35 36#include "opencsd/etmv4/trc_etmv4_stack_elem.h" 37 38/* implementation of P0 element stack in ETM v4 trace*/ 39TrcStackElemParam *EtmV4P0Stack::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) 40{ 41 std::vector<uint32_t> params; 42 params.clear(); 43 return createParamElem(p0_type, isP0, root_pkt, root_index, params); 44} 45 46TrcStackElemParam *EtmV4P0Stack::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> ¶ms) 47{ 48 TrcStackElemParam *pElem = new (std::nothrow) TrcStackElemParam(p0_type, isP0, root_pkt, root_index); 49 if (pElem) 50 { 51 int param_idx = 0; 52 int params_to_fill = params.size(); 53 while ((param_idx < 4) && params_to_fill) 54 { 55 pElem->setParam(params[param_idx], param_idx); 56 param_idx++; 57 params_to_fill--; 58 } 59 push_front(pElem); 60 } 61 return pElem; 62} 63 64TrcStackElemAtom *EtmV4P0Stack::createAtomElem(const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, const ocsd_pkt_atom &atom) 65{ 66 TrcStackElemAtom *pElem = new (std::nothrow) TrcStackElemAtom(root_pkt, root_index); 67 if (pElem) 68 { 69 pElem->setAtom(atom); 70 push_front(pElem); 71 } 72 return pElem; 73} 74 75TrcStackElemExcept *EtmV4P0Stack::createExceptElem(const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, const bool bSame, const uint16_t excepNum) 76{ 77 TrcStackElemExcept *pElem = new (std::nothrow) TrcStackElemExcept(root_pkt, root_index); 78 if (pElem) 79 { 80 pElem->setExcepNum(excepNum); 81 pElem->setPrevSame(bSame); 82 push_front(pElem); 83 } 84 return pElem; 85} 86 87TrcStackElemCtxt *EtmV4P0Stack::createContextElem(const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, const etmv4_context_t &context) 88{ 89 TrcStackElemCtxt *pElem = new (std::nothrow) TrcStackElemCtxt(root_pkt, root_index); 90 if (pElem) 91 { 92 pElem->setContext(context); 93 push_front(pElem); 94 } 95 return pElem; 96 97} 98 99TrcStackElemAddr *EtmV4P0Stack::createAddrElem(const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, const etmv4_addr_val_t &addr_val) 100{ 101 TrcStackElemAddr *pElem = new (std::nothrow) TrcStackElemAddr(root_pkt, root_index); 102 if (pElem) 103 { 104 pElem->setAddr(addr_val); 105 push_front(pElem); 106 } 107 return pElem; 108} 109 110/* End of file trc_etmv4_stack_elem.cpp */ 111